akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const LL inf = 1e16;
const int maxn = 1e5+5;
LL A[maxn], n, dp[maxn][2][2];

LL dfs(const int i, const int j, const int k)
{
    if (i == n-1) {
        const LL x = k ? -A[i] : A[i];
        if (j == 0)
            return +x + A[i+1];
        else
            return -x - A[i+1];
    }
    LL& ans = dp[i][j][k];
    if (-1 == ans) {
        ans = -inf;
        const LL x = k ? -A[i] : A[i];
        if (j) {
            const LL a = dfs(i+1,0,j) - x;
            const LL b = dfs(i+1,1,j) - x;
            ans = max(ans, max(a,b));
        }
        else {
            const LL a = dfs(i+1,0,j) + x;
            const LL b = dfs(i+1,1,j) + x;
            ans = max(ans, max(a,b));
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n) {
        memset(dp,-1,sizeof(dp));
        FOR(i,1,n+1) 
            cin >> A[i];
        const LL ans = max(dfs(1,0,0),dfs(1,1,0));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12032
#include <stdio.h>
#include <string.h>
int main(){
	char S[200000];
	scanf("%s",S);
	int l;
	l=strlen(S);
	int i;
	long long int b;
	b=0;
	long long int ans;
	ans=0;
	for(i=0;i<l;i++){
		if(S[i]=='B'){
			b=b+1;
		}else{
			ans=ans+b;
		}
	}
	printf("%lld",ans);
}

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

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

    int most_fish = -1, most_people = 0;
    for(int i = 0; i < n; i++) {
        int a, v;
        cin >> a >> v;
        if (most_fish < v) {
            most_fish = v;
            most_people = a;
        } else if (most_fish == v && most_people > a) {
            most_people = a;
        }
    }
    cout << most_people  << " " << most_fish << endl;
}



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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

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

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

int a[26];

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

	int k = 26;
	int b[3] = {(n / 2) * (m / 2), 0, (n & 1) & (m & 1)};
	b[1] = (n * m - b[2] - b[0] * 4) / 2;

	for (int i = 0; i < k; ++i){
		int t = min(b[0], a[i] / 4);
		b[0] -= t, a[i] -= t << 2;
	}
	for (int i = 0; i < k; ++i){
		int t = min(b[1], a[i] / 2);
		b[1] -= t, a[i] -= t << 1;
	}
	puts(b[0] == 0 && b[1] == 0 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String[] lines = reader.readLine().split(" ");

		Map<String, Integer> memo = new HashMap<String, Integer>();
		int max = 0;
		int maxLength = 0;
		String maxName = "";
		String maxLengthName = "";
		for (int i = 0; i < lines.length; i++) {
			Integer num = memo.get(lines[i]);
			if (num == null) {
				memo.put(lines[i], 1);
				if (maxLength < lines[i].length()) {
					maxLength = lines[i].length();
					maxLengthName = lines[i];
				}
			} else {
				int result = memo.put(lines[i], num + 1) + 1;
				if (max < result) {
					max = result;
					maxName = lines[i];
				}
			}

		}
		System.out.println(maxName + " " + maxLengthName);

	}
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
long long func(long long num){
    long long sum = 0;
    while(num > 0){ 
        sum += num % 10; 
        num /= 10;
    }
    return sum;
}

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> d(K);
    bool a[10] = {};
    for (int i = 0; i < K; i++){
        cin >> d[i];
        a[d[i]] = true;
    }
    vector<int> dlike;
    for (int i = 0; i < 10; i++){
        if (a[i]){
            dlike.push_back(i);
        }
    }

    int i = 0;
    while(1) {
        vector<int> num;
        int ans = N+i;
        int tmp = ans;
        while(tmp > 0) {
            num.push_back(tmp % 10);
            tmp /= 10;
        }

        bool ok = true;
        for(int k = 0; k < (int)num.size(); k++){
            for (int p = 0; p < (int)dlike.size(); ++p){
                if (num[k] == dlike[p]){
                    ok = false;
                }
            }
        }

        if (ok) {
            cout << ans << endl;
            break;
        }

        ++i;
    }



    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  vector<ll> a(3);
  cin >>a[0] >>a[1] >>a[2];
  sort(all(a));
  set<pair<pair<int,int>,int>> S;
  S.insert({{a[0], a[1]}, a[2]});
  ll res = 0;
  while (true){
    if (a[0] % 2 == 1 || a[1] % 2 == 1 || a[2] % 2 == 1){
      cout <<res <<endl; return 0;
    }
    ll aa = a[1]/2 + a[2]/2;
    ll bb = a[0]/2 + a[2]/2;
    ll cc = a[0]/2 + a[1]/2;
    a[0] = aa; a[1] = bb; a[2] = cc;
    sort(all(a));
    if (S.count({{a[0],a[1]},a[2]})){
      cout <<-1 <<endl; return 0;
    }
    S.insert({{a[0],a[1]},a[2]});
    res++;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000000
#define N 10000005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int mn=1e15;
   int n;
   cin>>n;
   for(int i=1;i*i<=n;i++)
   {
       if(n%i==0)
       {
           int sum=(i + n/i);
           mn=min(mn,abs(sum - 2LL));
       }
   }
   cout<<mn<<endl;


}


Measured memory_bytes: 3660
#include<stdio.h>

int a[100][100];
int b[100];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(int i=0;i<m;i++)scanf("%d",b+i);
	for(int i=0;i<n;i++){
		int ans=0;
		for(int j=0;j<m;j++)ans+=a[i][j]*b[j];
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 2112
# -*- coding: utf-8 -*-
h,w = map(int, input().split())
n = int(input())

l = []
a = [int(x) for x in input().split()]
for i in range(n):
    l.extend([i+1 for _ in range(a[i])])

for hi in range(h):
    line = []
    for wi in range(w):
        line.append(l[w*hi+wi])
    if hi%2==1:
        line = line[::-1]

    print(*line)


Measured memory_bytes: 3920
/*	Success may not come to me immediately,
 *	but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li	int64_t
#define ld	double_t
#define ulli	uint64_t
//=====================================================================
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define repi(i,v)	for(i=v.begin();i!=v.end();i++)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
#define nl		cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>	 vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb	push_back
#define pob	pop_back
#define pf	push_front
#define pof	pop_front
#define all(v)	v.begin(),v.end()
#define itr	iterator
#define sz	size()
#define lb	lower_bound
#define ub	upper_bound
#define bs	binary_search
#define mp	make_pair
#define F	first
#define S	second
//=====================================================================
#define mod	1000000007
#define inf	1000000000000000005
#define MX1	100005
#define MX2	1000005
#define pi	acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
	li a,b,c;cin>>a>>b>>c;
	li x=a*100+b*10+c;
	if(x%4==0) cout<<"YES";
	else cout<<"NO";
}

int main(){
    opt
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    li t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int K = 25600;
int n, m, i, a[88][88], b[88][88], c[88][88];
short d[88][88][K * 2 + 100];
int has;
// int depe(int aa,int bb,int sisa)
// {
//     if(aa > n || bb > m || sisa < 0 || sisa > (2*K))
//         return 0;
//     if(aa == n && bb == m && ((sisa + c[aa][bb] == K) || (sisa - c[aa][bb] == K)))
//         return 1;
//     if(aa == n && bb == m)
//         return 0;
//     int ret = d[aa][bb][sisa];
//     if(ret == -1)
//     {
//         ret = max(ret, depe(aa + 1, bb, sisa - c[aa][bb]));
//         ret = max(ret, depe(aa + 1, bb, sisa + c[aa][bb]));
//         ret = max(ret, depe(aa, bb + 1, sisa - c[aa][bb]));
//         ret = max(ret, depe(aa, bb + 1, sisa + c[aa][bb]));
//     }
//     return d[aa][bb][sisa] = ret;
// }
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            cin >> a[i][j];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            cin >> b[i][j];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            c[i][j] = abs(a[i][j] - b[i][j]);
    for(int i = n; i >= 1; i--)
        for(int j = m; j >= 1; j--)
            for(int k = 0; k <= 2*K; k++)
            {
                if(i == n && j == m)
                {
                    if(k + c[i][j] == K || k - c[i][j] == K)
                        d[i][j][k] = 1;
                }
                else
                {
                    if(0 <= k - c[i][j])
                    {
                        d[i][j][k] = max(d[i][j][k], d[i + 1][j][k - c[i][j]]);
                        d[i][j][k] = max(d[i][j][k], d[i][j + 1][k - c[i][j]]);
                    }
                    if(k + c[i][j] <= 2 * K)
                    {
                        d[i][j][k] = max(d[i][j][k], d[i + 1][j][k + c[i][j]]);
                        d[i][j][k] = max(d[i][j][k], d[i][j + 1][k + c[i][j]]);
                    }
                }
            }
    has = 1e9;
    for(int i = -K; i <= K; i++)
        if(d[1][1][i + K])
        {
            has = min(has, abs(i));
            // cout  << i << "\n";
        }
    cout << has << "\n";
}

Measured memory_bytes: 707072
# import sys
# input = sys.stdin.readline

n = int(input())
s = input()


l = 0
r = s.count("R")
ans = r
for i in range(n):
    if s[i] == "W":
        l += 1
    else:
        r -= 1
    ans = min(ans,max(l,r))
print(ans)

Measured memory_bytes: 67868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) + "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,m,n) for(i=m;i<n;i++)

typedef long long ll;

using namespace std;

int main()
{
    int n,i,j;

    cin>>n;
    int a[n];
    rep(i,0,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);

    if(n%2==0)
    {
        cout<<a[n/2]-a[n/2-1]<<"\n";
    }

    else
    {
        cout<<"0\n";
    }

    return 0;
}


Measured memory_bytes: 640
S = int(input())

if S < 3:
  print(0)
  import sys
  sys.exit()

DP = [0]*(S+1)
DP[0] = 0
DP[1] = 0
DP[2] = 0

for i in range(3, S + 1):
  DP[i] += 1
  for j in range(i - 3 + 1):
    DP[i] += DP[j]

print(DP[S] % (10 ** 9 + 7))


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;
int64_t dp[2005];
int main() {
  string s;
  cin>>s;
  for(char c='a';c<='z';c++){
    bool ok=true;
    for(int i=0;i<s.size();i++){
      if(s[i]==c){ok=false;}
    }
    if(ok){cout<<c<<endl;return 0;}
  }
  cout<<"None"<<endl;
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
using namespace std;
/*
string HOSHINOtoHOSHINA(string str) {
  string str2(str);
  int idx = 0;
  int len = 7; // "Hoshina" has 7 character
  while( (idx = str2.find("Hoshino", idx)) >= 0) {
	str2.replace(idx, len, "Hoshina");
  }
  return str2;
}
*/
string replaceAAAtoBBB(const string& str) {
  string str2(str);
  string before = "Hoshino";
  string after = "Hoshina";
  int idx = 0;

  while( (idx = str2.find(before, idx)) >= 0) {
	str2.replace(idx, before.length(), after);
  }
  return str2;
}

int main() {
  int n;
  string buf;

  cin >> n;
  cin.ignore();
  
  for(int i = 0; i < n; ++i) {
	getline(cin, buf);
	//cout << HOSHINOtoHOSHINA(buf) << endl;
	cout << replaceAAAtoBBB(buf) << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    if a%b == 0:
        print(a+b)
    else:
        print(b-a)
    return

#B
def B():
    n,m = LI()
    d = defaultdict(int)
    for i in range(n):
        l = LI()
        for j in range(1,len(l)):
            d[l[j]] += 1
    ans = 0
    for i in d.values():
        if i == n:
            ans += 1
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 38768
#include<iostream>
#include<string>
using namespace std;
long d=0,z=0,b[1000000];
void ChentrucTiep(long long a[],long n,long h){
	int x,k;
	for(int i=h;i<n;i++){
		x=a[i];
		k=i-h;
		while(k>=0&& a[k]>x)
		{
			a[k+h]=a[k];
			k-=h;
			d++;
		}
		a[k+h]=x;
	}
}
void shellSort(long long a[],long n){

	for(int i=1;i<=n;)
	{
		b[z]=i;
		z+=1;
		i=i*3+1;
	}
	for(int x=z-1;x>=0;x--)
		ChentrucTiep(a,n,b[x]);
}


int main(){
	long  n;
	long long a[1000000];
	cin >>n;
	for(int i=0;i<n;i++)
		cin >>a[i];
	shellSort(a,n);
	cout << z << endl;
	for(int i=z-1;i>=0;i--){
		cout << b[i];
		if(i)
			cout<<" ";
	}
	cout <<endl << d << endl;
	for(int i=0;i<n;i++){
		cout << a[i] << endl;}

	return 0;
}

Measured memory_bytes: 10908
/*
 * FileName:     B
 * CreatedDate:  2020-06-25 21:37:28 +0900
 * LastModified: 2020-06-25 22:11:01 +0900
 */

#include <stdio.h>
#include <string.h>
int main(void){
    char s[11];
    char acgt[4] = {'A','C','G','T'};
    scanf("%s",s);
    int long_s = 0;
    for(int i=0; i<strlen(s);){
        int cnt = 0;
        for(int j=i; j<strlen(s); j++){
            int flag = 0;
            for(int k=0; k<4; k++){
                if((int)s[j]==(int)acgt[k]){
                    cnt++;
                    flag = 1;
                }
            }
            if(flag==0){
                break;
            }
        }
        if(long_s<cnt){
            long_s = cnt;
        }
        if(cnt == 0){
            i++;
        }
        else{
            i += cnt;
        }
//        printf("%d:%d\n",i,cnt);
    }
    printf("%d\n",long_s);
    return 0;
}


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

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

using namespace std;

const int maxn = 1e5 + 7;

int x,y,a,b,c;
ll p[maxn], q[maxn], r[maxn];
multiset<ll>fir,sec;
multiset<ll>::iterator it1;
multiset<ll>::iterator it2;

int main () {

    cin >> x >> y >> a >> b >> c;

    for (int i = 1; i <= a; i++) cin >> p[i];
    for (int i = 1; i <= b; i++) cin >> q[i];
    for (int i = 1; i <= c; i++) cin >> r[i];

    sort(p + 1, p + a + 1);
    reverse(p + 1, p + a + 1);
    sort(q + 1, q + b + 1);
    reverse(q + 1, q + b + 1);
    sort(r + 1, r + c + 1);
    reverse(r + 1, r + c + 1);

    vector<ll>vec;

    for (int i = 1; i <= x; i++) vec.pb(p[i]);
    for (int i = 1; i <= y; i++) vec.pb(q[i]);
    for (int i = 1; i <= c; i++) vec.pb(r[i]);

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    ll ans = 0;
    for (int i = 0; i < x + y; i++) {
        ans+=vec[i];
    }
    cout << ans;

    /*
    for (int i = 1; i <= x; i++)
        fir.insert(p[i]);
    for (int i = 1; i <= y; i++)
        sec.insert(q[i]);


    for (int i = 1; i <= c; i++) {
        it1 = fir.end();
        it1++;
        it2 = sec.end();
        it2++;
        int num1 = *it1;
        int num2 = *it2;
        if (r[i] >= num1 && r[i] >= num2) {
            if (num1 < num2) {
                fir.erase(it1);
                fir.insert(r[i]);
            }
            else {
                sec.erase(it2);
                sec.insert(r[i]);
            }
        }
        else if (r[i] > num1) {
            fir.erase(it1);
            fir.insert(r[i]);
        }
        else if (r[i] > num2) {
            sec.erase(it2);
            sec.insert(r[i]);
        }
    }

    ll ans = 0;

    for (it1 = fir.begin(); it1 != fir.end(); it1++) {
        ans += *it1;
    }

    for (it2 = sec.begin(); it2 != sec.end(); it2++) {
        ans += *it2;
    }

    cout << ans;
    */

    return 0;
}


Measured memory_bytes: 8048
N,K = map(int,input().split())
conv =""

def ten_to_K(N,K,conv):
  if N // K == 0:
    conv += str(N % K)
    return conv
  else:
    N = N // K
    conv += str(N % K)
    return ten_to_K(N,K,conv)

ans = ten_to_K(N,K,conv)
print(len(ans))
  

Measured memory_bytes: 2940
module Main where

import Data.Functor

main :: IO ()
main =  do
  { [a,b,c] <- getInts
  ; print $ length $ filter (c `divBy`) [a..b]
  }

divBy :: Int -> Int -> Bool
divBy x y = x `mod` y == 0

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 4004
x,y=map(int,input().split())
if y==0:
    print(x)
    exit(0)
s=list(map(int,input().split()))
res=100
mn=110
for n in range( 110):
    if n not in s:
        v=abs(x-n)
        if v<res:
            res=v
            mn=n

print(mn)

Measured memory_bytes: 61832
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		   int N=sc.nextInt();
                if(N%2==0){
                     System.out.print(N+" "+N+" "+N/2);
               }else if(N%4==3){
                     System.out.print((N+1)/4+" "+N*(N+1)/2+" "+N*(N+1)/2); 
               }else{
                     long A,B;long a=3*N/4;long b=1;
                     while(a<=3500){
                            while(b<=a){
                                    A=N*a*b;
                                    B=4*a*b-N*(a+b);
                                    if(A%B==0&&B>0){
                                              System.out.print(a+" "+b+" "+A/B);
                                              a=3501;b=3501;
                                   }b++;
                          }b=1;a++;
                   }
            }
	}
}

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

map<int, int> m;
int search(int n) {
    int cnt = 0;
    for (auto tmp : m) {
        if (tmp.second >= n) ++cnt;
    }
    return cnt;
}

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

    // n!の素因数分解
    for (int i = 1; i <= N; i++) {
        int t = i;

        for (int j = 2; j <= sqrt(t); j++) {
            if (t % j != 0) continue;

            int ext = 0;
            while (t % j == 0) {
                ++ext;
                t /= j;
            }
            m[j] += ext;
        }
        if (t != 1) m[t]++;
    }

    int res = search(74) + search(24) * (search(2) - 1) + search(14) * (search(4) - 1) + search(4) * (search(4) - 1) * (search(2) - 2) / 2;

    cout << res << endl;
}

Measured memory_bytes: 3660
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

boost::optional<std::vector<std::pair<int, int>>> run(int N, int K)
{
	auto possible_max = (N - 1) * (N - 2) / 2;
	if (possible_max < K)
	{
		return boost::none;
	}
	std::vector<std::set<int>> edges(N);
	for (auto i : boost::irange(0, N))
	{
		for (auto j : boost::irange(0, N))
		{
			if (i != j)
			{
				edges[i].emplace(j);
			}
		}
	}
	auto rng = boost::irange(1, N);
	while (K != 0)
	{
		auto i = *std::partition_point(rng.begin(), rng.end(), [&](int k)
			{
				return edges[k].size() == 1;
			});
		auto j = *std::next(edges[i].begin());
		edges[i].erase(j);
		edges[j].erase(i);
		--K;
	}
	std::vector<std::pair<int, int>> ret;
	for (int i : boost::irange(0, N))
	{
		for (auto k : edges[i])
		{
			if (i < k)
			{
				break;
			}
			ret.emplace_back(i + 1, k + 1);
		}
	}
	return ret;
}

void Main()
{
	int N, K;
	std::cin >> N >> K;
	auto ret = run(N, K);
	if (ret)
	{
		std::cout << ret->size() << std::endl;
		for (auto&& p : *ret)
		{
			std::cout << p.first << " " << p.second << std::endl;
		}
	}
	else
	{
		std::cout << -1 << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll abc(ll x)
{
  ll cnt_f=0,cnt_s=0;
  while(x)
  {
    ll dig=x%10;
    if(dig==4)cnt_f++;
    else cnt_s++;
    x/=10;
  }
  return (cnt_f==cnt_s);
}

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


ll n,m,c;cin>>n>>m>>c;
vl b(m);
ll cnt=0;
for(int i=0;i<m;i++)cin>>b[i];

for(int j=0;j<n;j++)
{
  ll temp,sum=c;
  for(int i=0;i<m;i++)
  {
    cin>>temp;
    sum+=b[i]*temp;

  }
if(sum>0)cnt++;
}

cout<<cnt<<"\n";

  return 0;



}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

using namespace std;
	
typedef long long ll;
typedef long double ld;

const ld PI = acos(-1.0);

int gcd(int a, int b)
{
	while (b != 0)
	{
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

const int MAXN = 3001;
const int MAXM = MAXN * 100;
int a[MAXN];
vector <int> pd[MAXN];
vector <int> as[MAXN];
int ps[MAXM];
int pc = 0;
bool w[MAXN];
bool wc[MAXN];
int q[MAXN], qb, qe;
int block[MAXN];
int mn[MAXN];

bool e[MAXN][MAXN];

int main()
{
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		//a[i] = rand() % 100 + 2;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			e[i][j] = (gcd(a[i], a[j]) > 1);
		}
		int na = a[i];
		for (int j = 2; j * j <= a[i]; j++)
		{
			if (na % j == 0)
			{
				while (na % j == 0) na /= j;
				pd[i].push_back(j);
				ps[pc++] = j;
			}
		}
		if (na != 1) pd[i].push_back(na), ps[pc++] = na;
	}
	sort(ps, ps + pc);
	pc = unique(ps, ps + pc) - ps;
	for (int i = 0; i < n; i++)
	{
		w[i] = false;
		for (int j = 0; j < pd[i].size(); j++)
		{
			int v = lower_bound(ps, ps + pc, pd[i][j]) -ps;
			pd[i][j] = v;
			as[v].push_back(i);
		}
	}
	int calc = 0;
	a[n] = 1000 * 1000 * 1000;
	for (int iter = 0; iter < n; iter++)
	{
		bool fnd = false;
		mn[iter] = n;
		qe = qb = 0;
		for (int i = 0; i < n; i++) wc[i] = w[i];
		for (int i = 0; i < pc; i++) ps[i] = 0;
		for (int i = 0; i < n; i++)
		{
			if ((!wc[i]) && (mn[block[i]] >= i)) q[qe++] = i, wc[i] = true;
			while (qb < qe)
			{
				int v = q[qb++];
				for (int j = 0; j < pd[v].size(); j++)
				{
					int u = pd[v][j];
					if (ps[u]) continue;
					ps[u] = 1;
					for (int l = 0; l < as[u].size(); l++)
					{
						int v2 = as[u][l];
						if (wc[v2]) continue;
						wc[v2] = true;
						q[qe++] = v2;
					}
				}
			}
			if ((qe + iter == n) && (mn[block[i]] >= i) && (!w[i]))
			{
				calc++;
				cout << a[i] << " ";
				for (int j = 0; j <= iter; j++) mn[j] = min(mn[j], i); 
				w[i] = true;
				for (int j = 0; j < n; j++)
				{
					if (e[i][j]) block[j] = iter + 1;
				}
				fnd= true;
				break;
			}
		}
		if (!fnd)
		{
			fnd = false;
			assert(fnd);
		}
	}
	assert(calc == n);
	return 0;
}




Measured memory_bytes: 6528
#include <iostream>

using namespace std;

long long int calc_num(long long int a_b, long long int a, long long int cod) {
    if(a_b%cod==0) return a_b/cod;
    else if(a%cod==0) return a_b/cod + 1;
    else {
        if(a%cod >= cod-(a_b%cod-1)) return a_b/cod + 1;
        return a_b/cod;
    }
}

long long int calc_lcm(long long int c, long long int d) {
    long long int x=c*d;
    if(c<d){
        long long int tmp = c;
        c = d;
        d = tmp;
    }
 

    long long int r = c % d;
    while(r!=0){
        c = d;
        d = r;
        r = c % d;
    }

    // cout << x/d << endl;

  return x/d;

}

int main() {
    long long int A, B, C, D;
    
    cin >> A >> B >> C >> D;

    long long int A_B = B-A+1;
    long long int c, d, cd;
    
    long long int CD = calc_lcm(C, D);
    
    c = calc_num(B-A+1, A, C);
    d = calc_num(B-A+1, A, D);
    cd = calc_num(B-A+1, A, CD);
    
    cout << B-A+1 - (c+d-cd) << endl;

    return 0;
    
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> cats(9);
    for (int i = 0; i < N; ++i) {
        int a_i;
        cin >> a_i;
        if (a_i >= 1 and a_i < 400) {
            cats[0]++;
        } else if (a_i >= 400 and a_i < 800) {
            cats[1]++;
        } else if (a_i >= 800 and a_i < 1200) {
            cats[2]++;
        } else if (a_i >= 1200 and a_i < 1600) {
            cats[3]++;
        } else if (a_i >= 1600 and a_i < 2000) {
            cats[4]++;
        } else if (a_i >= 2000 and a_i < 2400) {
            cats[5]++;
        } else if (a_i >= 2400 and a_i < 2800) {
            cats[6]++;
        } else if (a_i >= 2800 and a_i < 3200) {
            cats[7]++;
        } else if (a_i >= 3200) {
            cats[8]++;
        }
    }

    int mn_res = 0;
    int mx_res = 0;
    for (int i = 0; i < 8; ++i) {
        mn_res += (cats[i] > 0);
    }

    if (mn_res == 0 and cats[8] > 0) {
        mn_res = 1;
        mx_res = cats[8];
    } else {
        mx_res = mn_res + cats[8];
    }
    cout << mn_res << " " << mx_res << '\n';
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	
	for(int i=0;i<S.size();i++){
		if((i%2) && S[i]=='R'){
			out("No");
			return 0;
		}
		else if(!(i%2) && S[i]=='L'){
			out("No");
			return 0;
		}
	}
	
	out("Yes");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N=100005;

int n,m;
int a[N],b[N];
LL ans,cnt[N];

struct DSU
{
	int fa[N],sz[N];
	void init()
	{
		for(int i=1;i<=n;i++) fa[i]=i;
		for(int i=1;i<=n;i++) sz[i]=1;
	}
	int find(int x)
	{
		return fa[x]=(fa[x]==x?x:find(fa[x]));
	}
	void unite(int x,int y)
	{
		x=find(x); y=find(y);
		if(x==y) return;
		ans-=sz[x]*sz[y];
		sz[y]+=sz[x];
		fa[x]=y;
	}
}dsu;

int main()
{
	
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a[i]>>b[i];
	dsu.init();
	ans=(LL)n*(n-1)/2;
	for(int i=m;i>=1;i--)
	{
		cnt[i]=ans;
		dsu.unite(a[i],b[i]);
	}
	for(int i=1;i<=m;i++)
		cout<<cnt[i]<<'\n';
	
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, m, q;
    cin >> n >> m >> q;
    
    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));
    
    rep (m) {
        int l, r;
        cin >> l >> r;
        dp[l][r] += 1;
    }
    
    vector<vector<int>> sumdp(n+1, vector<int>(n+1, 0));
    repeat_from_to (l, 1, n) {
        repeat_from_to (r, 1, n) {
            sumdp[l][r] = sumdp[l][r-1] + dp[l][r];
        }
    }
    
    rep (q) {
        int a, b;
        cin >> a >> b;
        int ans = 0;
        repeat_from_to (l, a, n) {
            ans += sumdp[l][b];
        }
        cout << ans << endl;
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int nmax=100010;
int ary[nmax];

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

	ary[0]=1,ary[1]|=2;
	int cur=0;

	rep(loop,q){
		int a,b;
		cin >> a >> b;
		a--,b--;
		swap(ary[a],ary[b]);
		if(cur==a or cur==b) cur^=(a^b); 
		if(0<=cur-1) ary[cur-1]|=2;
		if(cur+1<n) ary[cur+1]|=2;
	}

	int ans=0;
	rep(i,n) ans+=(ary[i]>0);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 768
#!/usr/bin/env python

n, k = map(int, input().split())

# aは全探索
ans = 0 
for a in range(1, n+1):
    ra = a%k 
    rbc = k-ra
    if (2*rbc) % k == 0:
        ans += ((n-rbc)//k + 1)**2

print(ans)


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

int main() {
  int H, W;
  cin >> H >> W;
  string t1 = "", t2 = "", t3 = "";
  for (int i = 0; i < H + 1; i++) {
    string s;
    cin >> s;
    
    if (i==0) {
      for (int j = 0; j < W; j++) {
        t2 += ".";
        t3 = s;
      }
      t2 = "." + t2 + ".";
      t3 = "." + t3 + ".";
      continue;
    }
    t1 = t2;
    t2 = t3;
    if (i==H) {
      t3 = "";
      for (int j = 0; j < W; j++) {
        t3 += ".";
      }
      t3 = "." + t3 + ".";
    } else {
      t3 = "." + s + ".";
    }
    
    for (int j = 1; j < W+1; j++) {
      if (t2.at(j)=='#') {
        cout << "#";
        continue;
      }
      int c = 0;
      if (t1.at(j-1)=='#') {
        c++;
      }
      if (t1.at(j)=='#') {
        c++;
      }
      if (t1.at(j+1)=='#') {
        c++;
      }
      if (t2.at(j-1)=='#') {
        c++;
      }
      if (t2.at(j+1)=='#') {
        c++;
      }
      if (t3.at(j-1)=='#') {
        c++;
      }
      if (t3.at(j)=='#') {
        c++;
      }
      if (t3.at(j+1)=='#') {
        c++;
      }
      cout << c;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 100000;
 
int main(){
    int N,Q;
    int A[MAX],B[MAX],C[MAX];
    long long table[MAX + 1] = {0};
    long long sum = 0;
 
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
 
    cin >> Q;
    for(int i = 0;i < Q;i++){
        cin >> B[i] >> C[i];
    }
 
    for(int i = 0;i < N;i++){
        table[A[i]]++;
    }
 
    for(int i = 1;i <= MAX;i++){
        sum += table[i] * i;
    }
 
    for(int i = 0;i < Q;i++){
        sum -= table[B[i]] * B[i];
        sum -= table[C[i]] * C[i];
        
        table[C[i]] += table[B[i]];
        table[B[i]] = 0;
        sum += table[C[i]] * C[i];
        cout << sum << endl;
    }
 
    return 0;
}

Measured memory_bytes: 5076
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll mod=1e9+7;

int main(){
    string s,t;
    cin >> s >> t;
    ll n=s.length();
    ll cnt=0;
    rep(i,n){
        if(s[i]!=t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
} 


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

struct UnionFind{
	vector<int> par;
	vector<int> rank;
	UnionFind(int n) : par(n), rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
		} else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x] ++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}	
};

int main(){
	int n, k, l; cin >> n >> k >> l;
	auto road = UnionFind(n), rail = UnionFind(n);
	map<pi, int> d;
	rep(i,k){
		int p, q; cin >> p >> q;
		p--; q--;
		road.unite(p, q);
	}
	rep(i,l){
		int r, s; cin >> r >> s;
		r--; s--;
		rail.unite(r,s);
	}
	rep(i,n){
		pi p;
		p.first = road.find(i);
		p.second = rail.find(i);
		d[p] ++;
	}
	rep(i,n){
		pi p = make_pair(road.find(i), rail.find(i));
		cout << d[p];
		if(i == n-1) return 0;
		else cout << " ";
	}
}

Measured memory_bytes: 15104
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime


def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0: continue
        ex = 0

        while (n % i == 0):
            ex += 1
            n //= i
        res.append((i, ex))
    if n != 1: res.append((n, 1))
    return res

N,P = imn()

pf = prime_factorize(P)

ans = 1
for p in pf:
    for i in range(p[1]//N):
        ans *= p[0]
print(ans)


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

int main()
{
    int n;
    string s;
    cin>>s;
    int i,j;
    n=s.length();
    i=0;
    j=n-1;
    
    while(i<j && s[i]==s[j])
    {
        i++;
        j--;
    }
    
    if(i>=j)
    {
        i=0;
        j=(n-1)/2-1;
        
        while(i<j && s[i]==s[j])
        {
            i++;
            j--;
        }
        
        if(i>=j)
        {
            i=(n+3)/2-1;
            j=n-1;
            
            while(i<j && s[i]==s[j])
            {
                i++;
                j--;
            }   
            if(i>=j)
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
        else
            cout<<"No\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll K, S;
    cin >> K >> S;

    ll count = 0;
    FOR(x, 0, K+1){
        FOR(y, 0, K+1){
            ll z = S - x - y;
            if(0 <= z && z <= K){
                count++;
            }
        }
    }

    p(count);
    
    return 0;
}

Measured memory_bytes: 256