akhauriyash/Code-Regression huggingface dataset:
# ans

N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
  cnt[i] += 1
Q = int(input())
S = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  diff = (C - B) * cnt[B]
  S += diff
  print(S)
  cnt[C] += cnt[B]
  cnt[B] = 0

Measured memory_bytes: 20880
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

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


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll n,k;
    cin>>n>>k;
    ll a[n];
    For(i,0,n)
    	cin>>a[i];
    sort(a,a+n);
    ll sm = 0;
    For(i,0,k)
    	sm += a[i];
    cout<<sm;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
from fractions import gcd

N = int(input())
A = np.array([input() for _ in range(N+1)], dtype=np.int64)[::-1]

# x^p-x で割り切れる必要がある
# p > Nのときは、a_Nの約数でなければならない
# a_Nの素因数および、N以下の素数をテストすればよい

U = int(10 ** 4.5 + 10)
is_prime = np.zeros(U+1, dtype = np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(U+1):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::2*p] = 0
primes = is_prime.nonzero()[0]

div = primes[A[N] % primes == 0]

cand = set(div)
x = abs(A[N])
for p in cand:
    while x % p == 0:
        x //= p
if x != 1:
    cand.add(x)

cand |= set(primes[primes <= N].tolist())
cand = sorted(cand)

def test(p):
    if A[0] % p != 0:
        return False
    # x^{p-1} - 1で割り切れるかどうか
    if p > N+10:
        return (A % p == 0).all()
    B = np.pad(A,[0,(-N-1)%(p-1)],'constant').reshape(-1,p-1).sum(axis = 0)
    return (B % p == 0).all()

answer = '\n'.join(str(p) for p in cand if test(p))
print(answer)

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

int main(){
  string s;
  cin>>s;
  bool a=true;
    if(s.at(0)==s.at(1)){
      a=false;
    }
    else if(s.at(1)==s.at(2)){
      a=false;
    }
    else if(s.at(2)==s.at(3)){
      a=false;
    }

  if(a==false){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,W;
    cin >> n >> W;
    vector<vector<ll>>dp(n+1,vector<ll>(1e5+10,MOD));
    dp[0][0]=0;
    vector<ll>w(n),v(n);
    for(ll i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<1e5+5;j++){
            if(j>=v[i]){
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
            else {
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    ll ans;
    for(ll i=1e5+4;i>=0;i--){
        if(dp[n][i]<=W){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 83248
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.MathContext;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      double x1 = sc.nextDouble();
      double y1 = sc.nextDouble();      
      double x2 = sc.nextDouble();
      double y2 = sc.nextDouble();
      double x = x1 - x2;
      double xx = x * x;
      double y = y1 - y2;
      double yy = y * y;
      double kai2 = xx + yy;
      double kai = Math.sqrt(kai2);
      System.out.println(kai);
    }
}


Measured memory_bytes: 28100
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
const ll LONG_INF = 1e18 + 10;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        string s;
        cin >> s;
        int ans = 0;
        if(s.find("R") != string :: npos)
                ans = 1;
        if(s.find("RR") != string :: npos)
                ans = 2;
        if(s.find("RRR") != string :: npos)
                ans = 3;
        cout << ans << '\n';
}


Measured memory_bytes: 3640
def even_relation(edges)
  neighbors = Hash.new { |h, k| h[k] = [] }
  costs = Hash.new { |h, k| h[k] = {} }

  edges.each do |edge|
    v, u, w = edge
    v -= 1
    u -= 1

    neighbors[v] << u
    neighbors[u] << v

    costs[v][u] = w
    costs[u][v] = w
  end

  colors = [0]
  queue = [0]

  until queue.empty?
    v = queue.shift

    neighbors[v].each do |u|
      next if colors[u]

      colors[u] = (colors[v] + costs[v][u]) % 2
      queue << u
    end
  end

  colors
end

edges = []
(gets.to_i - 1).times do
  edges << gets.split.map(&:to_i)
end

puts even_relation(edges)


Measured memory_bytes: 57852
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


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

if n%2==1:
    print('No')
elif s[int(n/2):] == s[:int(n/2)]:
    print('Yes')
else:
    print('No')





Measured memory_bytes: 3064
/*  ex7_3
    B30095    */
#include <stdio.h>
#include <stdlib.h>

void print_compressed(char ** grid, int rows, int cols);

int main(void){
    int rows, cols, isRowEmpty, isColEmpty, i, j;
    char ** grid;
    
    scanf("%d %d", &rows, &cols);
    
    // memory allocation
    grid = (char **)malloc(rows * sizeof(char *));
    if(grid == NULL){
        fprintf(stderr, "memory allocation error");
        return -1;
    }

    for(i = 0; i < rows; i++){
        grid[i] = (char *)malloc(cols * sizeof(char));
        if(grid[i] == NULL){
            fprintf(stderr, "memory allocation error");
            return -1;
        }
    }

    // input grid
    for(i = 0; i < rows; i++){
        for(j = 0; j < cols; j++){
            scanf(" %c", &(grid[i][j]));
        }
    }

    print_compressed(grid, rows, cols);

    // memory deallocation
    for(i = 0; i < rows; i++){
        free(grid[i]);
    }
    free(grid);

    return 0;
}


void print_compressed(char ** grid, int rows, int cols){
    int isRowEmpty, isColEmpty, i, j;

    // substitue empty rows with whitespaces
    for(i = 0; i < rows; i ++){
        isRowEmpty = 1;
        
        // check if the row is empty
        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') {
                isRowEmpty = 0;
            }
        }

        // fill in empty rows with whitespaces
        if(isRowEmpty){
            for(j = 0; j < cols; j++){
                grid[i][j] = ' ';
            }
        }
    }

    // substitue empty columns with whitespaces
    for(j = 0; j < cols; j ++){
        isColEmpty = 1;
        
        // check if the column is empty
        for(i = 0; i < rows; i++){
            if(grid[i][j] == '#') {
                isColEmpty = 0;
            }
        }

        // fill in empty columns with whitespaces
        if(isColEmpty){
            for(i = 0; i < rows; i++){
                grid[i][j] = ' ';
            }
        }
    }


    // print compressed result
    for(i = 0; i < rows; i++){
        isRowEmpty = 1;

        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') isRowEmpty = 0;
            if(grid[i][j] != ' ') printf("%c", grid[i][j]);
            
        }

        if(!isRowEmpty) printf("\n");  // new line should not be printed when the row is empty
    }
}

Measured memory_bytes: 1676
#include<stdio.h>
char f[6][6],s[6],i,j,a,y,x,p,b;int main(){for(;i<9;++i,b=!b){scanf("%s",s);for(j=4+b;j--;)a=s[j]-48,f[i/2][j]|=a<<1+b,f[i/2+b][j+!b]|=a<<3-b*3;}do{while(!((f[y][x]>>(p=(p+1)%4))&1));putchar("URDL"[p]);x+=p?2-p:0;y+=3-p?p-1:0;p=(p+2)%4;}while(y|x|**f==6&p==3);return!puts("");}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int     unsigned long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    int n,ans=1;
    cin>>n;
    vector<int> ar(n);
    for(auto &i:ar)
        cin>>i;
    sort(ar.begin(),ar.end());
    const int MAX=1e18;
    for(int i=0;i<n;i++)
    {
        if(ar[i]==0)
        {
            cout<<"0";
            return ;
        }
        int temp=MAX/ar[i];
        if(ans>temp)
        {
            cout<<"-1";
            return;
        }
        ans*=ar[i];
    }
    cout<<ans;
}
int32_t main()
{
    //clock_t tStart = clock();
    // #ifndef ONLINE_JUDGE
    // _READ
    // #endif
    _FAST    
    int t;
    t=1;
    while(t--)
        solve();
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/


Measured memory_bytes: 3988
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    long long int n,i,c=0;
    cin>>n;
    long long int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a, a+n);
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i])
            c++;
    }
    if(c==2||c==0)
        cout<<"YES";
    else
        cout<<"NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
int main() {
	int ans(0);
	int b[] = { 0,1,0,-1 };
	int a[] = { 1,0,-1,0 };
	int INF = 1001001001;
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	rep(i, h) {
		cin >> s[i];
	}
	rep(si, h) {
		rep(sj, w) {
			vector<vector<int>>dict(h, vector<int>(w, INF));
			queue<P>q;
			if (s[si][sj] == '#') {
				continue;
			}
			auto upgrade = [&](int i, int j, int x) {
				if (dict[i][j] == INF) {
					dict[i][j] = x;
					q.push(P(i, j));
				}
				else {
					return;
				}

			};
			upgrade(si, sj, 0);
			while (q.empty()==false) {
				int i = q.front().first;
				int j = q.front().second;
				q.pop();
				rep(dir, 4) {
					int ni = i + a[dir];
					int nj = j + b[dir];
					if (ni < 0 || ni >= h || nj < 0 || nj >= w) {
						continue;
					}
					if (s[ni][nj] == '#') {
						continue;
					}
					upgrade(ni, nj, dict[i][j] + 1);
				}
			}
			rep(i, h) {
				rep(j, w) {
					if (dict[i][j] == INF)continue;
					ans = max(ans, dict[i][j]);
				}
			}

		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<long long> acc(n + 1);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
    auto binary_search = [&](long long ok, long long ng, auto check) {
        while (abs(ng - ok) > 1) {
            long long mid = (ng + ok) / 2;
            (check(mid) ? ok : ng) = mid;
        }
        return ok;
    };
    long long mi = INF;
    for (int mid = 1; mid < n - 1; mid++) {
        int left = binary_search(0, mid, [&](long long k) {
            return acc[k] - acc[0] <= acc[mid] - acc[k];
        });
        int right = binary_search(mid, n, [&](long long k) {
            return acc[k] - acc[mid] <= acc[n] - acc[k];
        });
        for (int l: {left, left + 1}) for (int r: {right, right + 1}) {
            long long P = acc[l] - acc[0], Q = acc[mid] - acc[l];
            long long R = acc[r] - acc[mid], S = acc[n] - acc[r];
            mi = min(mi, max({P, Q, R, S}) - min({P, Q, R, S}));
        }
    }
    cout << mi << endl;
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B, C;
    cin >> A >> B >> C;

    if ((A >= C && B <= C) || (A <= C && B >= C)) {
        Yes;
    } else {
        No;
    }
    return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}


//cout << setprecision(123)<<ans;
//a=atoi(S.c_str());
//S=to_string(a);
//int &a=b;
int main(){
  int X;
  cin>>X;
  int N=X/100;
  
  int a=(X-100*N)/5;
  int b=(X-100*N-5*a)/4;
  int c=(X-100*N-5*a-4*b)/3;
  int d=(X-100*N-5*a-4*b-3*c)/2;
  int e=X-100*N-5*a-4*b-3*c-2*d;

  if(a+b+c+d+e<=N)cout<<1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char route[100000];
	int a, b;
	int i;
	
	for (i = 0; i < 100000; i++){
		route[i] = 0;
	}
	while (scanf("%d%d", &a, &b) != EOF){
		if (a + b != 0){
			route[a]++;
			route[b]++;
		}
		
		else {
			a = 0;
			for (i = 0; i < 101; i++){
				if (route[i] % 2 == 1){
					a++;
				}
			}
			
			if (a == 2){
				printf("OK\n");
			}
			else {
				printf("NG\n");
			}
			for (i = 0; i < 100000; i++){
			route[i] = 0;
			}
		}
		
	}
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    int x[n], y[m];
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < m; i++) cin >> y[i];
    int z = X + 1;
    int e = Y;
    string ans = "War";
    for (; z <= e; z++) {
        bool scout = true;
        for (int i = 0; i < n; i++) {
            if (x[i] >= z) scout = false;
        }
        for (int i = 0; i < m; i++) {
            if (y[i] < z) scout = false;
        }
        if (scout) ans = "No War";
    }
    cout << ans << endl;
}

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

// main
int main(){
    string s; cin >> s;
    int a_idx = s.find("A");
    int z_idx = s.rfind("Z");
    cout << (s.substr(a_idx, z_idx-a_idx+1)).size() << "\n";
    return 0;
}

Measured memory_bytes: 772
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int in, count = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		if(in != i + 1)count++;
	}
	if(count <= 2)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)



int main(){
	cout << "square1001" << endl;
}



Measured memory_bytes: 3068
h,w = map(int,input().split())

s = ["."*(w+2)]
for _ in range(h):
    s.append("."+input()+".")
s.append("."*(w+2))

li = [[0 for j in range(w)]for i in range(h)]

h += 2
w += 2

for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j] == "#":
            li[i-1][j-1] = "#"
            continue
        point = 0
        x = [-1,0,1]
        y = [-1,0,1]
        for nx in x:
            for ny in y:
                if nx == 0 and ny == 0:
                    continue
                if s[i+nx][j+ny] == "#":
                    point += 1
        li[i-1][j-1] = point

for i in li:
    print(''.join(map(str,i)))

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#include <cassert>
#include <numeric>
#define ll long long

using namespace std;

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

int main() {

  int K;
  cin >> K;
  int ans = 0;

  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        int ab = gcd(a, b);
        int abc = gcd(ab, c);
        ans += abc;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a, b, k;
  cin >> a >> b >> k;

  REP (i, k) {
    if (i % 2 == 0) {
      b += a / 2;
      a /= 2;
    } else {
      a += b / 2;
      b /= 2;
    }
  }

  cout << a << " " << b << endl;
}


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

void solve() {
  int N; cin >> N;
  string str; cin >> str;

  string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string res = "";
  for (size_t i = 0; i < str.size(); ++i) {
    for(int j = 0; j < 26; ++j) {
      if (str[i] == alphabet[j]) res += alphabet[j+N];
    }
  }
  cout << res << endl;
}

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

Measured memory_bytes: 256
main = interact $ show.solve.map read.words

solve :: [Int] -> Int
solve [a,b,c,d] = length [(x,y,z)|x <- (l a), y <- (l b), z <- (l c), culc x y z == d]
  where
    l s=[x|x <-[0..50], x <= s] 
    culc x y z = 500*x + 100*y + 50*z

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;

int main(){
    ll x;
    cin>>x;
    ll t=100;
    int c=0;
    while(t<x){
        c++;
        t+=t/100;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3604
N, M = map(int, input().split())
H = list(map(int, input().split()))

s = set(range(1, N+1))

def check_good(A,B):
    if H[A-1] > H[B-1]:
        return B
        
    else:
        return A

A_B = [list(map(int, input().split())) for _ in range(M)]
[s.difference_update([check_good(*x)]) for x in A_B]
[s.difference_update([check_good(*reversed(x))]) for x in A_B]

print(len(s))

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void comInit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    reps(i, MAX, 2)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(ll n,ll k)
{
    if (n < k || n < 0 || k < 0)
    {
        return 0;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
comInit();
int n,p;
cin>>n>>p;
vector<int>a(n);
int odd=0,even=0;
rep(i,n){
    cin>>a[i];
    if(a[i]%2==0){
        even++;
    }
    else{
        odd++;
    }
}
ll ans=0;
rep(i,odd+1){
    if(p==0){
        if(i%2==0){
            ans+=comb(odd,i);
        }
    }
    else{
        if(i%2!=0){
            ans+=comb(odd,i);
        }
    }
}
ans*=pow(2,even);

cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 119808
#include <stdio.h>

int sum_of_digits(int n) {
    int sum = 0;

    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main(int argc, char *argv[]) {
    int n;
    int sum;

    scanf("%d", &n);

    int s = sum_of_digits(n);

    if (n % s == 0) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n, m;
    cin >> n >> m;
    if(n == 1 || m == 1) cout << "1";
    else cout << (n*m + 1)/2;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_N = 22;
int N, M;
struct _data{double L, a, b;} data[MAX_N];

inline int nextCombination(int comb)
{
  int x = comb & -comb, y = comb + x;
  return (((comb & ~y) / x) >> 1) | y;
}

//?????¨??????n???????????????m??????????????????????????????

inline double calc(const _data& x, const _data& y)
{
  return (x.L-y.L) * (x.L-y.L) + (x.a-y.a) * (x.a-y.a) + (x.b-y.b) * (x.b-y.b);
}

int main()
{
  cin >> N >> M;
  rep(i, N) cin >> data[i].L >> data[i].a >> data[i].b;

  if(M == 0.0){
    puts("0");
    return 0;
  }

  double res = 0.0;
  for(int comb = (1 << M) - 1; comb < (1 << N); comb = nextCombination(comb)){
    vi vec;
    rep(i, N) if(comb & (1 << i)) vec.pb(i);
    double sum = 0.0;
    rep(i, vec.size()) rep(j, i) sum += calc(data[vec[i]], data[vec[j]]);
    maxup(res, sum);
  }

  printf("%.15f\n", res);

  return 0;
}

Measured memory_bytes: 1256
N,K=map(int,input().split())

#お菓子を持っていない人のリスト
#初期値は全員
not_hoyu_list=[x+1 for x in range(N)]

#お菓子の種類Kでループ
for i in range(K):
    num_d=int(input())
    hoyulist=list(map(int,input().split()))

    for j in hoyulist:
        if j in not_hoyu_list:
            not_hoyu_list.remove(j)

print(len(not_hoyu_list))




Measured memory_bytes: 9008
#include <iostream>
using namespace std;
int main(){
    int s[26]={0};
    char ch;
    while(cin>>ch){
        if('A'<=ch&&ch<='Z')ch=tolower(ch);
        if('a'<=ch&&ch<='z')s[ch-'a']++;
    }
    for(int i=0;i<=25;i++){
        char cha='a'+i;
        cout<<cha<<' '<<':'<<' '<<s[i]<<endl;
    }return 0;
}


Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int idx;
		int A, B;
		ArrayList<Integer> bList;
		HashMap<Integer, ArrayList<Integer>> bMap = new HashMap<Integer, ArrayList<Integer>>();
		for (idx = 0; idx < N; idx++) {
			A = Integer.parseInt(sc.next());
			B = Integer.parseInt(sc.next());
			bList = bMap.get(A);
			if (bList == null) {
				bList = new ArrayList<Integer>();
				bMap.put(A, bList);
			}
			bList.add(B);
		}

		int maxval;
		long sum = 0;
		ArrayList<Integer> valList = new ArrayList<Integer>();
		for (idx = 1; idx <= M; idx++) {
			// idx日目のリスト追加してソートする
			bList = bMap.get(idx);
			if (bList != null) {
				valList.addAll(bMap.get(idx));
				Collections.sort(valList);
			}
			if (valList.size() > 0) {
				maxval = valList.remove(valList.size() - 1);
				sum += maxval;
			}

		}

		System.out.println(sum);

	}

}


Measured memory_bytes: 102900
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int inline fun(int n){
    int ans=0;
    while(n){
        n/=10;
        ans++;
    }
    return ans&1;
}
int main()
{
    int n;
    cin >> n;
    int res=0;
    for(int i=1;i<=n;i++)
        res+=fun(i);
    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int Ns = 110;
pair<int, int> a[Ns];
int w[Ns], w_id[Ns];
int n, m, ans, i, k, totw, j;


void dfs(int x, int ww, int v)
{
    if (v > ans) ans = v;
	if (x > totw) return;
	
	int i, t=min(w_id[x + 1] - 1, w_id[x] + ww / w[x] - 1);
	for (i = t; i >= w_id[x]; i--)
	   v += a[i].second;
	ww -= (t - w_id[x] + 1) * w[x];
	for (i = t; i >= w_id[x]; i--)
	   {
	       dfs(x + 1, ww, v);
	       v -= a[i].second;
	       ww += w[x];
	   }
	dfs(x + 1, ww, v);
}

int main()
{
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) scanf("%d%d", &a[i].first, &a[i].second);
	sort(a+1, a+n+1);
	for (i = n >> 1; i >= 1; i--) swap(a[i], a[n - i + 1]);
	a[n + 1].first = -1;
	i = 1;
	while (i <= n)
	{
	    w_id[++totw] = i;
	    w[totw] = a[i].first;
	    j = i;
	    while (a[j + 1].first == a[i].first) j++;
	    i = j + 1;
    }
    w_id[totw + 1] = n + 1;
	dfs(1, m, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

const int N = 200005;

int root[N], hang[N];

int get(int i) {
  if (i == root[i]) return root[i];
  else return root[i] = get(root[i]);
}

void join(int u, int v) {
  u = get(u); v = get(v);
  if (u == v) return;
  if (hang[u] < hang[v]) {
    hang[u] += hang[v];
    root[v] = u;
  } else {
    hang[v] += hang[u];
    root[u] = v;
  }
}

void MAIN() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    root[i] = i;
    hang[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    join(u, v);
  }
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    if (i == root[i]) {
      ans = max(ans, hang[i]);
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 6772
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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 INF = 1LL << 60;


int main(void){
  ll n;
  cin >> n;
  vector<char> ans;

  while(n>0){
    n -= 1;
    ans.push_back('a'+n%26);
    n /=26;
  }
  reverse(ans.begin(), ans.end());

  rep(i,ans.size()){
  cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3644
n=int(input())
a=list(map(int,input().split()))
is_even=True if n%2==0 else False
dic={}
for i in range(n):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic[a[i]]=1
if is_even:
    for m in dic.values():
        if m!=2:
            print(0)
            exit()
    else:
        print((2**(n//2))%1000000007)
else:
    if a.count(0)!=1:
        print(0)
        exit()
    else:
        dic[0]=2
        for m in dic.values():
            if m!=2:
                print(0)
                exit()
        else:
            print(2**(n//2)%1000000007)

Measured memory_bytes: 14436
s=input()
n=len(s)
for i in reversed(range(n-1)):
    if i%2:
        l=s[:i//2+1]
        r=s[i//2+1:i+1]
        ok=True
        for j in range(i//2+1):
            if l[j]!=r[j]:
                ok=False
        if ok:
            print(i+1)
            exit()

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

#define MAX 100001

int par[MAX];
int rank[MAX];

void init_union_find() {
  for(int i=0; i<MAX; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

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

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

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

int main() {
  
  int n, q;
  int com, x, y;
  
  init_union_find();
  cin >> n >> q;
  for(int i=0; i<q; i++) {
    cin >> com >> x >> y;
    if(com == 0) unite(x, y);
    else {
      cout << same(x, y) << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    vector<string> v;
    string s;
    long k;
    cin >> s;
    cin >> k;
    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == c) {
                for (int j = i; j < s.size() && j - i < 5; j++) {
                    v.push_back(s.substr(i, j - i + 1));
                }
            }
        }
    }
    
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[k-1] << endl;
}


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

using str = string;
using ss = stringstream;

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

    int a,b;
    cin>>a>>b;

    str s;
    cin>>s;

    bool ans=s.size()==a+b+1;

    for(int i=0;i<s.size();i++)
    {
        if(i==a)ans &= s[i]=='-';
        else ans &= s[i]!='-';
    }

    puts(ans?"Yes":"No");

    return 0;
}


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

int main() {
    double R;
    cin >> R;
    cout << 2 * R * M_PI << endl;
    return 0;
}


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

using namespace std;

int main(){
    string S,T;
    cin >> S;
    cin >> T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

#define MAX_V 4444
vector<int> v[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int a,int b){
	v[a].PB(b);
	v[b].PB(a);
}

bool matchdfs(int a){
	used[a] = true;
	for(int i = 0;i < v[a].size();i++)	{
		int u = v[a][i],w = match[u];
		if(w < 0 || !used[w] && matchdfs(w)){
			match[u] = a;
			match[a] = u;
			return true;
		}
	}
	return false;
}

//二部マッチング
int two_matching_max(int l){
	int res = 0;
	memset(match,-1,sizeof(match));
	REP(v,l){
		if(match[v] < 0){
			memset(used,0,sizeof(used));
			if(matchdfs(v))res++;
		}
	}
	return res;
}

vector<int> prime;
#define HOGE 111111
bool isp[HOGE];
void f(){
	REP(i,HOGE)isp[i] = true;
	isp[0] = isp[1] = false;
	for(int i = 2;i < HOGE;i++){
		if(isp[i]){
			prime.PB(i);
			for(int j = i;j < HOGE;j+=i)isp[j] = false;
		}
	}
}

int gcd(int a,int b){
	if(a < b)swap(a,b);
	if(b == 0)return a;
	return gcd(b,a%b);
}
	
#define HALF 1000
int main(){
	int n,m;
	while(cin >> m >> n,n|m){
		REP(i,MAX_V)v[i].clear();
		vector<ll> a(m);REP(i,m)cin >> a[i];
		vector<ll> b(n);REP(i,n)cin >> b[i];
		REP(i,m){
			REP(j,n){
				if(gcd(a[i],b[j]) > 1)add_edge(i,j+1000);
			}
		}
		cout << two_matching_max(MAX_V) << endl;
	}
		
	return 0;
}



Measured memory_bytes: 5208
#include<stdio.h>
#include<math.h>

int main() {
  int N, D;
  double X, Y;
  int i;
  int cnt=0;

  scanf("%d %d", &N, &D);
  //printf("%d %d", N, D);
  for(i=0; i< N; i++) {
    scanf("%lf %lf", &X, &Y);
    if (D >= sqrt(X*X + Y*Y)) cnt++;
  }

  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 2176
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]
dic =Counter(a)

li=[]

for i,j in dic.items():
    if j>=2:
        li.append(i)
    if j>=4:
        li.append(i)
li.sort()


if len(li)>=2:
    print(li[-1]*li[-2])
else:
    print(0)

Measured memory_bytes: 18600
// 不同答案的代表元，是指定串在最终串按“贪心寻找subseq最小字典序”的位置集合。
// 所以全部匹配上之前每个slot是25（不能与预期下一个匹配字相同），之后每个slot是26
#include<bits/stdc++.h>
using namespace std;

#define ran 2002002

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
	int rev(int x) {return pw(x, mod-2);}
};
modular_arithmetic ma;

int k;
char s[ran];
int len;

int pw25[ran], pw26[ran];
int fac[ran], rfac[ran];

int c(int n, int m) {
	//printf("- %d %d %d %d %d\n", n, m, fac[n], rfac[m], rfac[n-m]);
	return ma.mul(fac[n], ma.mul(rfac[m], rfac[n-m]));
}

int main() {
	scanf("%d%s", &k, s);
	len = strlen(s);
	
	pw25[0] = pw26[0] = fac[0] = 1;
	for(int i=1;i<k+len;i++) {
		pw25[i] = ma.mul(pw25[i-1], 25);
		pw26[i] = ma.mul(pw26[i-1], 26);
		fac[i] = ma.mul(fac[i-1], i);
	}
	rfac[k+len-1] = ma.rev(fac[k+len-1]);
	for(int i=k+len-2;i>=0;i--)
		rfac[i] = ma.mul(rfac[i+1], i+1);
	
	int ans = 0;
	for(int i=0;i<=k;i++) {
		//printf("%d %d %d %d\n", i, pw25[i], pw26[k-i], c(len-1+i, len-1));
		int x = ma.mul(ma.mul(pw25[i], pw26[k-i]), c(len-1+i, len-1));
		ans = ma.add(ans, x);
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 35952
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


int h, w, tc, p[8][8];
bool m[8][8];
void _mark(int x, int y, int c)
{
	m[y][x] = true;
	for (int i = 0; i < 4; ++i)
	{
		int tx = x + dx[i], ty = y + dy[i];
		if (valid_pos(tx, ty, w, h) && !m[ty][tx] && p[ty][tx] == c)
			_mark(tx, ty, c);
	}
}
void mark(int c) { CL(m, 0); _mark(0, 0, c); }
void change(int c)
{
	mark(p[0][0]);
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			if (m[y][x])
				p[y][x] = c;
}
int count()
{
	mark(tc);
	int res = 0;
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			if (m[y][x])
				++res;
	return res;
}
int dfs(int depth)
{
	if (depth == 5)
		return count();
	else
	{
		int res = 0;
		for (int c = 1; c <= 6; ++c)
		{
			if (c != p[0][0] && (depth != 4 || c == tc))
			{
				int _p[8][8];
				memcpy(_p, p, sizeof(p));

				change(c);
				max_swap(res, dfs(depth + 1));

				memcpy(p, _p, sizeof(_p));
			}
		}
		return res;
	}
}
int main()
{
	ios::sync_with_stdio(false);

	while (cin >> h >> w >> tc, h)
	{
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				cin >> p[y][x];
		cout << dfs(0) << endl;
	}
}

Measured memory_bytes: 0
import sys
InputData=[]
for line in sys.stdin:
    InputData.append(int(line))

for i in range(len(InputData)):
    in1 = InputData[i]
    h = in1 / 3600
    m = (in1 / 60) - (h * 60)
    y = in1 - (h * 3600) - (m * 60)
    print(str(h) + ":" + str(m) + ":" +str(y))

Measured memory_bytes: 6456
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	N = str(S())

	if N[-1] == '2' or N[-1] =='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
		print('hon')
	elif N[-1] == '0' or N[-1]=='1' or N[-1]=='6' or N[-1]=='8':
		print('pon')
	else:
		print('bon')


if __name__ == '__main__':
	solve()


Measured memory_bytes: 9980
def digit_sum(x):
    total = 0
    while x > 0:
        total += x % 10
        x //= 10
    return total


def is_harshad(x):
    return (x % digit_sum(x) == 0)

n = int(input())
if is_harshad(n):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
	int i, n;
	scanf("%d", &n);
	int a[n];
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(i = n - 1; i >= 0; i--){
		printf("%d", a[i]);
		if(i != 0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	string blue[n];
	for(int i=0;i<n;i++)
		cin>>blue[i];
	
	int m;
	cin>>m;
	string red[m];
	for(int i=0;i<m;i++)
		cin>>red[i];
	
	int ans=0;
	
	for(int i=0;i<n;i++)
	{
		string word=blue[i];
		int count=0;
		
		for(int j=0;j<n;j++)
			if(blue[j]==word) count++;
		for(int j=0;j<m;j++)
			if(red[j]==word) count--;
		
		ans=max(ans,count);
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int64_t X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<int64_t> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	vector<int64_t> D;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			int64_t n = A[i] + B[j];
			D.push_back(n);
		}
	}
	sort(D.begin(), D.end());
	reverse(D.begin(), D.end());

	vector<int64_t> E;
	int64_t k = min(K, (int64_t)D.size());
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < Z; j++) {
			int64_t n = D[i] + C[j];
			E.push_back(n);
		}
	}
	sort(E.begin(), E.end());
	reverse(E.begin(), E.end());

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

Measured memory_bytes: 44116
s = input()
temp = 0
max = 0

for i in range(len(s)):
    if ('A' in s[i]) :
        temp += 1
    elif ('C' in s[i]) :
        temp += 1
    elif ('G' in s[i]) :
        temp += 1
    elif ('T' in s[i]) :
        temp += 1
    else : temp = 0

    if temp > max :
        max = temp

print(max)


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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
ll n,w;
vector<pair<ll,ll> > v;
ll dp[105][100005];

ll fill(ll s, ll we)
{
	if (we < 0)
		return -1e18;
	if (s < 0)
		return 0;
	if (dp[s][we] != -1)
		return dp[s][we];

	ll fi,se;
	fi = fill(s - 1, we - v[s].first);
	se = fill(s - 1, we); 
	dp[s][we] = max(fi + v[s].second, se);
	return dp[s][we];
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin >> n >> w;
	ll x,y;
	for(int i = 0; i < n; i++)
	{
		cin >> x >> y;
		v.push_back(make_pair(x, y));
	}
	cout << fill(n-1,w) << endl;
	return 0;
}

Measured memory_bytes: 82304
# (x - y) (x^4 + x^3 y + x^2 y^2 + x y^3 + y^4)
import math


def check(x, y):
    # a - b == x
    # a = x
    # b = 0
    # (x ^ 4 + x ^ 3 y + x ^ 2 y ^ 2 + x y ^ 3 + y ^ 4) == y
    for i in range(x):
        a = x - i
        b = i
        if a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4 == y:
            print(a, b)
            exit()


X = int(input())

# for i in range(1, math.ceil(X ** 0.5)):
#     if X % i == 0:
#         # i * X//i
#         check(i, X // i)

for b in range(-2*math.ceil(X ** 0.2) - 3, math.ceil(X ** 0.2) + 3):
    sig = 1
    if b ** 5 + X < 0:
        sig = -1
    a = sig * int(abs(b ** 5 + X) ** 0.2)
    if a**5 - b**5 == X:
        print(int(a), b)
        exit()

raise

Measured memory_bytes: 9464