akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;

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

  int N,ans=10000000;
  string S;
  cin>>N>>S;
  vector<int> w(N);
  if(S[0]=='.'){
    w[0]=1;
  }else{
    w[0]=0;
  }
  for(int i=1;i<N;i++){
    if(S[i]=='.'){
      w[i]=w[i-1]+1;
    }else{
      w[i]=w[i-1];
    }
  }
  for(int i=0;i<N;i++){
    ans=min(ans,(i+1-w[i])+(w[N-1]-w[i]));
  }
  ans=min(ans,w[N-1]);
  cout<<ans<<endl;
}

Measured memory_bytes: 1428
s = input() #sys.stdin.readlineは最後が改行
if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

s=list(s)
oa = ord('a')
alp = [True]*26
for i in range(len(s)):
    alp[ord(s[i])-oa]=False

if len(s)<26:
    nokori_min =alp.index(True)
    add = chr(nokori_min + ord('a'))
    s+=add

    print(*s,sep='')
    exit()

nokori = []


from bisect import bisect_right

for i in reversed(range(len(s))):
    if ord(s[i-1]) > ord(s[i]):
        nokori.append(s.pop())
    else:
        if nokori == []:
            tmp = s.pop()
            s[-1] = tmp
            break
        else:

            nokori.append(s.pop())
            nokori.sort()
            index = bisect_right(nokori, s[-1])
            s[-1] = nokori[index]
            break

print(*s,sep='')


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
  	ll c = 0;
  	for(ll i = 1; i <= 100; i++){
    	ll n = i;
  		for( int j = 2; j <= 10; j++){
    		n *= i;
      	    if( n <= x ) c = max( n , c );
        }
    }
    cout << c;
}


Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())

	h := make([]int, n, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		tmp, _ := strconv.Atoi(scanner.Text())
		h[i] = tmp
	}
	sort.Ints(h)

	answer := int64(0)
	for i := 0; i < n - k; i++ {
		answer += int64(h[i])
	}

	fmt.Println(answer)
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define int ll
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair


const int md = 1000000007;
const int INF = 1<<30;



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

    vi a(m);
    cin >> a;

    vi dp(n+1);
    dp[0] = 1;
    dp[1] = 1;

    rep(i,n-1){
        bool f1 = binary_search(ALL(a),i+1);
        bool f2 = binary_search(ALL(a),i);

        if(!f1 and !f2){
            dp[i+2] = (dp[i+1] + dp[i])%md;
        }else if(!f1 and f2){
            dp[i+2] = dp[i+1];
        }else if(f1 and !f2){
            dp[i+2] = dp[i];
        }else{
            dp[i+2] = 0;
        }
    }

    cout << dp[n] << endl;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    bool ok = true;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if(i%2==0) //RUD
        {
            if(s[i]=='L') ok=false;
        }
        else    //LUD
        {
            if(s[i]=='R') ok=false;            
        }
    }
    
    if(ok)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    
    return 0;
}

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


int main(){
	int a,b;
	cin >> a;
	cin >> b;
	if (a % 3 == 0) {
		cout << "Possible" << endl;
	}else if (b % 3 == 0) {
		cout << "Possible" << endl;
	}else if ((a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}else {
		cout << "Impossible" << endl;
	}
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    vector<pair<int, int>> dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    for (int i0 = 0; i0 < n; i0++) {
        for (int j0 = 0; j0 < m; j0++) {
            if (a[i0][j0] == '#') {
                continue;
            }
            vector<pair<int, int>> q = {{i0, j0}};
            map<pair<int, int>, int> dist;
            dist[{i0, j0}] = 0;
            for (int qi = 0; qi < q.size(); qi++) {
                auto cur = q[qi];
                for (auto dir: dirs) {
                    int i = cur.first + dir.first;
                    int j = cur.second + dir.second;
                    if (dist.count({i, j}) == 0 && i >= 0 && i < n && j >= 0 && j < m && a[i][j] == '.') {
                        q.push_back({i, j});
                        int d = dist[cur] + 1;
                        dist[{i, j}] = d;
                        ans = max(ans, d);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var a, b, t int
	_, _ = fmt.Fscan(reader, &a)
	_, _ = fmt.Fscan(reader, &b)
	_, _ = fmt.Fscan(reader, &t)
	v := b * int((float64(t)+0.5)/float64(a))
	_, _ = fmt.Fprintf(writer, "%d", v)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N, M;
  	cin >> N >> M;
  	vector<int> num(N);
  	for(int i = 0; i < N; i++){
    	num[i] = 10;
    }
  	int ans = 0;
  	for(int i = 0; i < M; i++){
      	int s, c;
      	cin >> s >> c;
    	if(num[s-1] == 10) num[s-1] = c;
      	else if(num[s-1] == c) num[s-1] = c;
      	else{
        	ans = -1;
          	break;
        }
    }
  	if(num[0] == 0) ans = -1;
  	if(N == 1 && (num[0] == 0 || num[0] == 10)) cout << '0' << endl;
  	else if(ans == -1) cout << ans << endl;
  	else{
      for(int i = 0; i < N; i++){
          if(num[i] == 10 && i == 0) num[i] = 1;
          else if(num[i] == 10) num[i] = 0;
          cout << num[i];
      }
      cout << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
taka = []
aoki = []
sum_of_both = {}
for i in range(N):
    a, b = map(int, input().split())
    taka.append(a)
    aoki.append(b)
    sum_of_both[i] = a + b

p_taka = 0
p_aoki = 0
turn = 0
for k, v in sorted(sum_of_both.items(), key=lambda x: x[1], reverse=True):
    if turn % 2 == 0:
        p_taka += taka[k]
    else:
        p_aoki += aoki[k]
    turn += 1

print(p_taka - p_aoki)

Measured memory_bytes: 33056
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    string str;
    cin >> str;

    if (str[2]==str[3] && str[4]==str[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x = int(input())

ans = 0
tmp = 1
for i in range(1, int(x**0.5)+1):
    for j in range(2, x):
      tmp = pow(i, j)
      if tmp > x:
          tmp = pow(i, j-1)
          #print(tmp, i, j)
          break

    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 9464
n = int(input())
a = list(map(int, input().split()))
r = list((0,))*len(a)

flag = False
for i in range(len(a)):
	tmp = a[i]
	if tmp%2:
		flag= True
	while not(tmp%2):
		r[i]+=1
		tmp/=2
if flag:
	print(0)
else:
	print(min(r))

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, x; cin >> N >> x;
  if (x==1||x==2*N-1) { cout << "No" << endl; return 0; }
  int diff = x-N;
  cout << "Yes" << endl;
  rep(i,2*N-1) cout << (i+diff+(2*N-1))%(2*N-1)+1 << " ";
  cout << endl;
  return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout<<S.size()<<endl;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
vector<int> E[202020];

vector<pair<int,int>> V[202020];
vector<pair<int,int>> L[202020],R[202020];
int A[202020],B[202020];
ll ret=0;
map<int,pair<int,int>> memo[202020];

pair<int,int> dfs(int cur,int pre) {
	V[cur].resize(E[cur].size());
	
	int D=0, is=S[cur], i;
	FOR(i,E[cur].size()) {
		int r=E[cur][i];
		if(r!=pre) {
			V[cur][i]=dfs(r,cur);
			V[cur][i].first++;
			D=max(D,V[cur][i].first);
			is|=V[cur][i].second;
		}
	}
	return memo[cur][pre] = make_pair(D,is);
}

void dfs2(int cur,int pre,pair<int,int> par) {
	par.first++;
	int i;
	
	FOR(i,E[cur].size()) {
		int r=E[cur][i];
		if(r==pre) V[cur][i]=par;
	}
	L[cur].resize(E[cur].size());
	R[cur].resize(E[cur].size());
	L[cur][0].second = R[cur].back().second = S[cur];
	for(i=1;i<L[cur].size();i++) {
		L[cur][i].first=max(L[cur][i-1].first,V[cur][i-1].first);
		L[cur][i].second=L[cur][i-1].second | V[cur][i-1].second;
	}
	for(i=R[cur].size()-2;i>=0;i--) {
		R[cur][i].first=max(R[cur][i+1].first,V[cur][i+1].first);
		R[cur][i].second=R[cur][i+1].second | V[cur][i+1].second;
	}
	FOR(i,E[cur].size()) {
		int r=E[cur][i];
		if(r!=pre) {
			pair<int,int> p={max(L[cur][i].first,R[cur][i].first),L[cur][i].second|R[cur][i].second};
			memo[cur][r]=p;
			dfs2(r,cur,p);
		}
	}
	
}

void centerv(int a) {
	vector<pair<int,int>> C=V[a];
	
	C.push_back({0,S[a]});
	C.push_back({0,S[a]});
	
	sort(ALL(C));
	reverse(ALL(C));
	int Rmax=C[1].first;
	int Rmin=201010;
	FORR(v,C) if(v.second) Rmin=min(Rmin,v.first);
	
	if(Rmin<=Rmax) {
		ret+=Rmax-Rmin+1;
	}
}

void centere(int a,int b) {
	pair<int,int> p[2]={memo[a][b],memo[b][a]};
	
	if(p[0].first<p[1].first) {
		ret+=p[0].second;
	}
	else if(p[0].first>p[1].first) {
		ret+=p[1].second;
	}
	else {
		ret++;
	}

}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>A[i]>>B[i];
		A[i]--, B[i]--;
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}
	cin>>S;
	FORR(c,S) c-='0';
	
	auto p=dfs(0,-1);
	dfs2(0,-1,{0,0});
	FOR(i,N) centerv(i);
	FOR(i,N-1) centere(A[i],B[i]);
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 99472
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m, num[100005];
bool red[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	red[0] = true;
	fill(num, num+n, 1);
	FOR(i, m) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		num[x]--;
		num[y]++;
		if (red[x]) {
			red[y] = true;
			if (num[x] == 0) red[x] = false;
		}
	}
	int cnt = 0;
	FOR(i, n) {
		if (red[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 768
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

// let k = a + b + c
// E(a,b,c) := Expected no. of trials required to reach (0,0,0) from (a,b,c)
// E(a,b,c) = (n-k)/n * (1 + E(a,b,c)) + a/n * (1 + E(a-1,b,c)) + b/n * (1 + E(a+1,b-1,c)) + c/n * (1 + E(a,b+1,c-1))
// hence, E(a,b,c) = n/k + a/k * E(a-1,b,c) + b/k * E(a+1,b-1,c) + c/k * E(a,b+1,c-1)

const int N = 304;

ff E[N][N][N];
int n, cnt[3];

void solve() {
   E[0][0][0] = 0;

   for (int c = 0; c <= n; ++c) {
      for (int b = 0; b+c <= n; ++b) {
         for (int a = 0; a+b+c <= n; ++a) {
            if (a + b + c > n) continue;
            if (!a && !b && !c) continue;

            int k = a + b + c;

            E[a][b][c] = n;

            if (a) E[a][b][c] += E[a-1][b][c] * a;
            if (b) E[a][b][c] += E[a+1][b-1][c] * b;
            if (c) E[a][b][c] += E[a][b+1][c-1] * c;

            E[a][b][c] /= k;
         }
      }
   }
   cout << E[cnt[0]][cnt[1]][cnt[2]] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;

   cnt[0] = cnt[1] = cnt[2] = 0;

   for (int i = 0, foo; i < n; ++i)
      cin >> foo, cnt[foo-1]++;

   solve();

   return EXIT_SUCCESS;
}



Measured memory_bytes: 434432
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200010
using namespace std;
typedef long long ll;
int n,m,a,b,fac[N]={1},inv[N],ans;
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%dalao)if(b&1)r=1ll*r*a%dalao;return r;}
inline void upd(int& a,int b){a=a+b>=dalao?a+b-dalao:a+b;}
inline int C(int a,int b){return a<b?0:1ll*fac[a]*inv[b]%dalao*inv[a-b]%dalao;}
int main(){
	cin>>n>>m>>a>>b;
	for(int i=1;i<=n+m;i++)fac[i]=1ll*fac[i-1]*i%dalao;
	inv[n+m]=pw(fac[n+m],dalao-2);
	for(int i=n+m-1;~i;i--)inv[i]=1ll*inv[i+1]*(i+1)%dalao;
	for(int i=b+1;i<=m;i++)upd(ans,1ll*C(n-a+i-2,i-1)*C(m-i-1+a,a-1)%dalao);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int cal(int a,int b,char c)
{
	if(c=='+')return a+b;
	else if(c=='-')return a-b;
	else if(c=='*')return a*b;
	else return -1;
}
int main()
{
	int i,j,k,l;
	int table[4];
	char enzansi[3]={'+','-','*'};
	int pt[24][4]=
	{
		{0,1,2,3},
		{0,1,3,2},
		{0,2,1,3},
		{0,2,3,1},
		{0,3,1,2},
		{0,3,2,1},
		{1,0,2,3},
		{1,0,3,2},
		{1,2,0,3},
		{1,2,3,0},
		{1,3,0,2},
		{1,3,2,0},
		{2,0,1,3},
		{2,0,3,1},
		{2,1,0,3},
		{2,1,3,0},
		{2,3,0,1},
		{2,3,1,0},
		{3,0,1,2},
		{3,0,2,1},
		{3,1,0,2},
		{3,1,2,0},
		{3,2,0,1},
		{3,2,1,0}
	};
	while(1)
	{
		cin >> table[0] >> table[1] >> table[2] >> table[3];
		if(table[0]==0&&table[1]==0&&table[2]==0&&table[3]==0)break;
		for(i=0;i<24;i++)
		{
			for(j=0;j<3;j++)
			{
				for(k=0;k<3;k++)
				{
					for(l=0;l<3;l++)
					{
						if(cal(cal(table[pt[i][0]],table[pt[i][1]],enzansi[j]),cal(table[pt[i][2]],table[pt[i][3]],enzansi[l]),enzansi[k])==10)
						{
							printf("((%d %c %d) %c (%d %c %d))\n",table[pt[i][0]],enzansi[j],table[pt[i][1]],enzansi[k],table[pt[i][2]],enzansi[l],table[pt[i][3]]);
							goto end;
						}	
						if(cal(cal(cal(table[pt[i][0]],table[pt[i][1]],enzansi[j]),table[pt[i][2]],enzansi[k]),table[pt[i][3]],enzansi[l])==10)
						{
							printf("(((%d %c %d) %c %d) %c %d)\n",table[pt[i][0]],enzansi[j],table[pt[i][1]],enzansi[k],table[pt[i][2]],enzansi[l],table[pt[i][3]]);
							goto end;
						}
						if(cal(cal(table[pt[i][0]],cal(table[pt[i][1]],table[pt[i][2]],enzansi[k]),enzansi[j]),table[pt[i][3]],enzansi[l])==10)
						{
							printf("((%d %c (%d %c %d)) %c %d)\n",table[pt[i][0]],enzansi[j],table[pt[i][1]],enzansi[k],table[pt[i][2]],enzansi[l],table[pt[i][3]]);
							goto end;
						}
						if(cal(table[pt[i][0]],cal(cal(table[pt[i][1]],table[pt[i][2]],enzansi[k]),table[pt[i][3]],enzansi[l]),enzansi[j])==10)
						{
							printf("(%d %c ((%d %c %d) %c %d))\n",table[pt[i][0]],enzansi[j],table[pt[i][1]],enzansi[k],table[pt[i][2]],enzansi[l],table[pt[i][3]]);
							goto end;
						}
						if(cal(table[pt[i][0]],cal(table[pt[i][1]],cal(table[pt[i][2]],table[pt[i][3]],enzansi[l]),enzansi[k]),enzansi[j])==10)
						{
							printf("(%d %c (%d %c (%d %c %d)))\n",table[pt[i][0]],enzansi[j],table[pt[i][1]],enzansi[k],table[pt[i][2]],enzansi[l],table[pt[i][3]]);
							goto end;
						}
					}
				}
			}
		}
		printf("0\n");
		end: ;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int n, cnt, ans;
char ch;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> ch;
        if(ch == 68) cnt--;
        else cnt++;
        ans = max(ans, cnt);
    }
    cout << ans << (char)10;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N,K;
	cin>>N;
	string S;
	cin>>S;
	cin>>K;
	K--;
	char x=S[K];
	rep(i,N){
		if(S[i]==x)cout<<x;
		else cout<<"*";
	}
	cout<<endl;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long koumoku = B - A + 1;

//		long kosu = koumoku - (koumoku / C) - (koumoku / D) + (koumoku / (C * D));
		long kosu = koumoku - kosu(A, B, C) - kosu(A, B, D) + kosu(A, B, lcm(C,D));
		System.out.println(kosu);
	}

	public static long kosu(long min, long max, long wari){

		long start;

		if (min % wari == 0){
			start = min;
		} else {
			start = min + (wari - min % wari);
		}

		long mod = (max - start + 1) % wari;
		long kosu = (max - start + 1) / wari;
		if (mod > 0){
			kosu += 1;
		}

		return kosu;
	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}

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

#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(int argc, char const *argv[])
{
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for (i = 1; i <= n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1;
	tail = n + 1;

	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0) 
			enqueue(u);
		else 
			printf("%s %d\n", u.name, elaps);

	}
	return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <vector>

using namespace std;

int main() {
  string S;
  cin >> S;

  int val;
  if(S == "SUN") val = 7;
  else if(S == "MON") val = 6;
  else if(S == "TUE") val = 5;
  else if(S == "WED") val = 4;
  else if(S == "THU") val = 3;
  else if(S == "FRI") val = 2;
  else if(S == "SAT") val = 1;

  cout << val << endl;

  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

struct QType{
	int v,d,c;
} Q[N];
struct Edge{
	int y,nxt;
} E[N*2];
int las[N],col[N],f[N];
int n,m,cnt,q;

void Link(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,las[y]};las[y]=cnt++;
}
void Work(int x,int d,int c){
	if (f[x]>=d) return;
	f[x]=d;
	if (!col[x]) col[x]=c;
	for (int i=las[x];~i;i=E[i].nxt){
		Work(E[i].y,d-1,c);
	}
}

int main(){
	memset(las,-1,sizeof(las));
	n=IN(),m=IN();
	For(i,0,m) Link(IN(),IN());
	q=IN();
	For(i,1,q+1) Q[i]=(QType){IN(),IN(),IN()};
	for (int i=q;i;i--){
		Work(Q[i].v,Q[i].d+1,Q[i].c);
	}
	For(i,1,n+1) printf("%d\n",col[i]);
}

Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define vecc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    int A[N];
    rep(i, N) cin >> A[i];

    int ans=X;
    rep(i, N) rep(j, D) if(1 + j * A[i] <= D) ans++;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>

using namespace std;

bool is_palindrome(string::const_iterator begin, const string::const_iterator end) {
  int len = distance(begin, end);
  for (int i = 0; i < len / 2; i++) {
    if (*(begin + i) != *(end - i - 1)) {
      return false;
    }
  }

  return true;
}

bool is_strong_palindrome(string &s) {
  return is_palindrome(s.begin(), s.end())
    && is_palindrome(s.begin(), s.begin() + (s.size() - 1) / 2)
    && is_palindrome(s.begin() + (s.size() + 3) / 2 - 1, s.end());
}

int main(int argc, const char *argv[])
{
  string s;
  cin >> s;
  cout << (is_strong_palindrome(s) ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    H=list(map(int,input().split()))
    H=H[::-1]
    cnt=[0]*N
    for i in range(1,N):
        if H[i]>=H[i-1]:
            cnt[i]=cnt[i-1]+1
    print(max(cnt))
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 86144
import java.util.*;
     
    public class Main{
      public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1; i <= 9; i++){
          for(int j = 1; j <= 9; j++){
            int kake = i * j;
            if(kake == n){
              count++;
            }
          }
        }
        if(count == 0){
          System.out.println("No");
        }else {
          System.out.println("Yes");
        }
      }
    }
        

Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

double dp[3][106];
int ma[106];

int main(){
	int i, j, n, t, l, b,ins;
	while(1){
		cin >> n >> t >> l >> b;
		if(!n) break;
		REP(a,n+7){
			dp[0][a]=0;
			dp[1][a]=0;
			dp[2][a]=0;
			ma[a]=0;
		}
		dp[0][0] = 1;
		REP(a,l){
			cin >> ins;
			ma[ins] = 1;
			if(n-ins<=5) ma[n+(n-ins)]=1;
		}
		REP(a,b){
			cin >> ins;
			ma[ins] = -1;
			if(n-ins<=5) ma[n+(n-ins)]=-1;
		}
		
		REP(a,t){
			/*REP(b, 3){
				REP(a,n+1) printf("%.5f ",dp[b][a]);
				cout << endl;
			}*/
			REP(b,n){
				REP(c,6){
					if(ma[b+c+1]==-1) dp[1][0] += dp[0][b] / 6;
					else if(ma[b+c+1]==1) dp[2][b+c+1]+=dp[0][b]/6;
					else dp[1][b+c+1] += dp[0][b] / 6;
				}
			}
			dp[1][n]+=dp[0][n];
			REP(b,5){
				dp[1][n-b-1] += dp[1][n+b+1];
				dp[1][n+b+1] = 0;
				dp[2][n-b-1] += dp[2][n+b+1];
				dp[2][n+b+1] = 0;
			}
			REP(b,n+1){
				dp[0][b] = dp[1][b];
				dp[1][b] = 0;
				dp[1][b] += dp[2][b];
				dp[2][b] = 0;
			}
		}
		printf("%.13f\n", dp[0][n]);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main()
{   
	int n;
	string s;
	cin >> n >> s;
	int count=0;
	int end=0;
	for (int i=0; i<s.size(); i++) {
		if (s[i]=='R') end++;
	}
	for (int i=0; i<s.size(); i++) {
		if (s[i]=='R'&&i>end-1) count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  vector<int>res(10);
  int k=0;
  
  for(int i=0;i<S.size();i++){
    int a=S.at(i);
    if(a=='A'||a=='G'||a=='C'||a=='T'){
      res.at(k)++;
    }
    else{
      k++;
    }
  }
  
  sort(res.begin(),res.end());
  reverse(res.begin(),res.end());
  cout<<res.at(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int A, B, C, D;
bool check()
{
    while(true)
    {
        C -= B;
        if(C<=0)
            return 1;
        A -= D;
        if(A<=0)
            return 0;
    }
}

void solve()
{
    cin >> A >> B >> C >> D;
    bool flag = check();
    if(flag)
        puts("Yes");
    else
        puts("No");
}

    int main()
    {
        TIME_START = clock();
        int Test = 1;
        // cin >> Test;
        while (Test--)
            solve();
        TIME_END = clock();
        program_end();
        return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int P = inputVal<int>();
	const int Q = inputVal<int>();
	const int R = inputVal<int>();

	int pq = P + Q;
	int qr = Q + R;
	int rp = R + P;
	
	outputVal(min(min(pq, qr), rp));
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt() + 2;
        int w = sc.nextInt() + 2;
        String[] line = new String[h - 2];
        for (int i = 0; i < h - 2; i++) {
            line[i] = sc.next();
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 || i == h -1 || j == 0 || j == w - 1) {
                    System.out.print("#");
                } else {
                    System.out.print(line[i - 1].charAt(j - 1));
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 24788
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e12;

multiset<ll> st;

ll N,X,f,s,number_of_single,number_of_double;

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N;
	for(int A=1;A<=N;A++)
	{
		cin>>X;
		st.insert(X);
	}
	f=*st.begin();
	s=*(--st.end());	 
	if(f==s)
	{
		if(f+1!=N and 2*f>N)
			cout<<"No";
		else
			cout<<"Yes";
	}
	else
	{
		number_of_single=st.count(f);
		number_of_double=f+1-number_of_single;
		if(f+1!=s or number_of_single<=0 or number_of_double<=0 or number_of_single+2*number_of_double>N)
			cout<<"No";
		else   
			cout<<"Yes";
	}
	return 0;
}

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

signed main() {
  int n; cin >> n;
  vector<ll> as(n);
  rep(i,n) cin >> as[i];
  ll whole = 0;
  rep(i,n) whole += as[i];

  ll odds = 0, evens = 0;
  rep(i,n/2) {
    odds += as[(i*2+1)%n];
    evens += as[(i*2+2)%n];
  }
  rep(i,n) {
    // 0を求めるためには、1,3,....を足せば良い
    // 1を求めるためには、2,4,....を足せば良い
    // 2を求めるためには、3,5,....を足せば良い
    if (i%2==0) {
      cout << (i?" ":"") << (whole - odds*2);
      odds -= as[(i+1)%n];
      odds += as[i%n];
    } else {
      cout << (i?" ":"") << (whole - evens*2);
      evens -= as[(i+1)%n];
      evens += as[i%n];
    }
  }
  cout << endl;
}


Measured memory_bytes: 2048
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;

void main(){
    while(true){
	int n,m;
	auto s = split(readln()).to!(int[]);
	n = s[0];
	m = s[1];
	if(n==0&&m==0) break;
	int count;
	int d;
	int i = -1;
	bool[1001] al;
	for(int j=0;j<=1000;j++){
	    al[j] = false;
	}
	while(true){
	    i = (i+1)%n;
	    if(!al[i]) count++;
	    else continue;
	    if(count%m==0){
	       	al[i] = true;
		d++;
	    }
	    if(d==n-1) break;
	}
	for(int j=0;j<n;j++){
	    if(!al[j]) writeln(j+1);
	}
    }
}

Measured memory_bytes: 2440
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	char c;
	cin >> c;
	cout << (char) (c + 1) << endl;
}









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

using namespace std;

#define INF int(1e9)
#define ii pair<int, int>
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define x first
#define y second


int main () {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    for(int i=0; i<n; i++)
        cout << a[i] << b[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    vll orda(n), ordb(n);

    iota(ALL(orda), 0LL);
    sort(ALL(orda), [&](ll i, ll j) {
        return a[i] < a[j];
    });
    iota(ALL(ordb), 0LL);
    sort(ALL(ordb), [&](ll i, ll j) {
        return b[i] < b[j];
    });

    REP(i, n) {
        if (a[orda[i]] > b[ordb[i]]) {
            cout << "No\n";
            return 0;
        }
    }

    REP(i, n - 1) {
        if (b[ordb[i]] >= a[orda[i + 1]]) {
            cout << "Yes\n";
            return 0;
        }
    }

    vll a2b(n, -1);
    REP(i, n) a2b[orda[i]] = ordb[i];
    vll used(n, 0);
    ll tmp = 0, cnt = 0;
    while (used[tmp] == 0) {
        cnt++;
        used[tmp] = 1;
        tmp = a2b[tmp];
    }

    if (cnt == n) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 4992
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  string s; cin >> s;
  map<char, int> M;
  for (auto&&c: s) {
    M[c]++;
  }
  
  if (M['7']) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3596
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def func(a,b):
    cnt = 0
    exp = 1
    borg = b
    while True:
        b = pow(borg, exp)
        if(a%b != 0):
            break
        a = a/b
        exp = exp + 1
        cnt = cnt + 1

    return cnt

input = input()
c = collections.Counter(prime_factorize(int(input)))
L = list(c.values())
K = list(c.keys())
ans = 0
k = 0
for i in range(len(L)):
    k = int(K[i])
    f = func(int(input),k)
    ans = ans + f

print(ans)


Measured memory_bytes: 9536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int n;
    cin >> n;
    int p = 0, w = 0, g = 0, y = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "P") p = 1;
        else if (s == "W") w = 1;
        else if (s == "G") g = 1;
        else y = 1;
    }

    if (p+w+g+y == 4) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
SC=[list(map(int,input().split())) for _ in range(m)]
for ans in range(10**n+1):
  if len(str(ans))==n and all(str(SC[i][1])==str(ans)[SC[i][0]-1] for i in range(m)):
    print(ans)
    break
else:
  print(-1)

Measured memory_bytes: 38484
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define f(i,n)   for(int i=0;i<n;i++)
int main(){
    string s;
    cin>>s;
    string t;
    f(i,s.length()){
        if(s[i]=='9')   t+='1';
        else if(s[i]=='1')  t+='9';
        else    t+=s[i];
    }
    cout<<t;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n, INF<int>), c(n);
    v[0] = 0;
    for (auto &&i : c) scanf("%d", &i);
    for (int i = 0; i < n-1; ++i) {
        if(i+1 < n) v[i+1] = min(v[i+1],v[i]+abs(c[i+1]-c[i]));
        if(i+2 < n) v[i+2] = min(v[i+2],v[i]+abs(c[i+2]-c[i]));
    }
    cout << v[n-1] << "\n";
    return 0;
}


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

int N;

int main()
{
    char c;
    scanf(" %c",&c);
    scanf(" %c",&c);
    N = (c - '0') * 10;
    scanf(" %c",&c);
    N += (c - '0');
    if(N % 4)
    {
        printf("NO\n");
    }
    else
    {
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<bitset>
#include<map>
#include<math.h>
#include<cstring>
#include<string>
#include<stack>
#include<algorithm>
typedef long long LL; 
using namespace std;
const int maxn=15;
const int INF=999999999;
LL n;
int re=0;
void dfs(LL num,bool f3,bool f5,bool f7){
	if(num>n) return;
	if(f3 && f5 && f7){
		re++;
		//cout<<num<<" "<<f3<<" "<<f5<<" "<<f7<<endl;	
	} 
	dfs(num*10+3,1,f5,f7);
	dfs(num*10+5,f3,1,f7);
	dfs(num*10+7,f3,f5,1);
}
int main(){
	cin>>n;
	bitset<3> a;
	dfs(0,0,0,0);
	cout<<re<<endl;
	return 0;
}            

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

typedef pair<int,int> P;

const int INF = 9223372036854775807;
vector<int> d;
int n,m;
struct edge{int from, to, cost;};
vector<edge> es;

signed main(void){
  cin >> n >> m;

  for(int i = 0; i < m; i++){
    edge buf;
    cin >> buf.from >> buf.to >> buf.cost;
    buf.from--;
    buf.to--;
    buf.cost = -buf.cost;
    es.push_back(buf);
  }


  int d1,d2;
  for(int i = 0; i < n; i++) d.push_back(INF);
  d[0] = 0;
  for(int j = 0; j < 2*n; j++){
    bool update = false;
    for(int i = 0; i < m; i++){
      edge e = es[i];
      if( d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update=true;
      }
    }
    if(!update) break;
  }
  d1 = -  d[n-1];

  for(int j = 0; j < 2*n; j++){
    bool update = false;
    for(int i = 0; i < m; i++){
      edge e = es[i];
      if( d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update=true;
      }
    }
    if(!update) break;
  }
  d2 = -  d[n-1];

  if(d1==d2){
    cout << d1 << "\r\n";
  }else{
    cout << "inf\r\n";
  }
  return 0;
}


Measured memory_bytes: 384
def solv(arr)
  change = true
  while change do
    change = false

    line_checked = arr.map { |line| line.all?{ |c| c == '.' } ? nil : line }.compact
    change = true if arr.size != line_checked.size

    transed = line_checked.transpose
    line_checked = transed.map { |line| line.all?{ |c| c == '.' } ? nil : line }.compact
    change = true if transed.size != line_checked.size

    arr = line_checked
  end
  arr.map { |line| line.join('')}
end

=begin
str = ["##.#",
       "....",
       "##.#",
       ".#.#"]

str = str.map{ |l| l.split('')}
puts solv(str)
exit 1
=end

cd = gets.chomp.split(' ').map(&:to_i)

str = []
cd[0].times { str << gets.chomp.split('') }

puts solv(str)




Measured memory_bytes: 2684
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  int res = 0;
  for (int i = 1; i <= N; i += 2) {
    int div = 0;
    for (int j = 1; j <= i; ++j)
      if (i % j == 0) ++div;
    if (div == 8) ++res;
  }
  printf("%d\n", res);
}

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

using namespace std;

int main()
{
    long long n; cin >> n;
    set<long long> s;

    for(long long i = 1; i*i <=n-1; i++)
    {
        if((n-1)%i == 0)
        {
            s.insert(i);
            s.insert((n-1)/i);
        }
    }
    for(long long i = 2; i*i <=n; i++)
    {

        long long tmp = n;
        while(tmp%i == 0)
        {
            tmp = tmp/i;
            if(tmp == 1)
                s.insert(i);
        }
        if((tmp - 1) % i==0)
            s.insert(i);
    }
    cout << s.size() << endl;



    return 0;
}


Measured memory_bytes: 256
C = [ list(map(int,input().split())) for _ in range(3)]
if (C[0][0] + C[1][1]) != (C[0][1] + C[1][0])  :
    print("No")
elif (C[0][1] + C[1][2]) != (C[0][2] + C[1][1])  :
    print("No")
elif (C[1][0] + C[2][1]) != (C[1][1] + C[2][0])  :
    print("No")
elif (C[1][1] + C[2][2]) != (C[1][2] + C[2][1])  :
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 
int main(){
	//in_o();
 	int n,ans=0,x=0;string s;
 	cin>>n>>s;
 	FOR(i,0,n){
 		if(s[i]=='I')	x++;
 		else x--;
 		ans=max(ans,x);
 	}
 	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/9/ITP1_9_C
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n, taro_p = 0, hanako_p = 0;
    cin >> n;
    string taro, hanako;
    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if (taro.compare(hanako) == 0) {
            taro_p += 1;
            hanako_p += 1;
        } else if (taro.compare(hanako) > 0) {
            taro_p += 3;
        } else if (taro.compare(hanako) < 0) {
            hanako_p += 3;
        }
    }
    cout << taro_p << " " << hanako_p << endl;
}


Measured memory_bytes: 3228
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  if (a <= k) {
    ans += a;
    k -= a;
  } else {
    cout << k << endl;
    return 0;
  }

  if (b <= k) {
    k -= b;
    cout << ans - k << endl;
    return 0;
  } else {
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 3636