akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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 (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[100000];

int main(){
  ll N,M,A,B;
  cin >> N >> M;
  rep(i,M){
    cin >> A  >> B ;
    C[A-1]++;
    C[B-1]++;
  }
  rep(i,N){
    cout << C[i]  << endl;
  }
}

Measured memory_bytes: 256
s = gets.to_s.chomp
t = gets.to_s.chomp

n_s = s.size
n_t = t.size

candidates = []
( n_s - n_t + 1 ).times do |i|

  s_sub = s[i, n_t]
  flag = true
  n_t.times do |j|
    next if s_sub[j] == t[j] || s_sub[j] == '?'
    flag = false
    break
  end
  
  if flag
    candidate = s[0...i] + t + s[i+n_t..-1]
    candidates << candidate.tr("?", "a")
  end
end

if candidates.empty?
  puts "UNRESTORABLE"
else
  puts candidates.sort.first
end

Measured memory_bytes: 1788
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long int A,B,C,K;
  cin>>A>>B>>C>>K;
  long long int ans=0;
  if(K<=A)ans=K;
  else if(K<=A+B)ans=A;
  else ans=2*A+B-K;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,m;
    cin>>n>>m;
    if(abs(n-m)>=2){
        cout<<0<<endl;
        return 0;
    }
    int ans=1;
    for(int i=1;i<=n;i++){
        ans=ans*i;
        ans=ans%mod;
    }
    for(int i=1;i<=m;i++){
        ans=ans*i;
        ans=ans%mod;
    }
    if(n==m){
        ans=ans*2;
        ans=ans%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
open Batteries

let solve line =
  Text.nsplit line @@ Text.of_string " "
  |> List.fold_left (fun ret s -> Text.append_char (Text.get s 0) ret) Text.empty

let () =
  Text.read_line IO.stdin
  |> solve
  |> Text.to_string
  |> print_endline


Measured memory_bytes: 1152
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = sc.nextInt();
    int en = sc.nextInt();

    if (500 * count >= en) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    LL sum = 0;
    REP(i,0,n) sum += a[i];
    VI fs;
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            fs.pb(i);
            if (i * i != sum) fs.pb(sum/i);
        }
    }
    sort(all(fs));
    reverse(all(fs));
    //REP(i,0,fs.size()) cout << fs[i] << endl;
    //return;
    for (auto &&v: fs) {
        sort(all(a), [&v](auto &l, auto &r) {
            return l % v < r % v;
        });
        VLL lo(n+1), up(n+1);
        REP(i,0,n) lo[i+1] = lo[i] + a[i] % v;
        RREP(i,0,n) up[i] = up[i+1] + (v - a[i] % v);
        //dump(v);
        REP(i,0,n+1) {
            LL sum = 0;
            LL cnt = 0;
            sum = up[i] - lo[i];
            cnt = up[i] + lo[i];
            /*
            REP(j,0,n) {
                if (j < i) {
                    sum -= (a[j] % v);
                    cnt += (a[j] % v);
                }
                else {
                    sum += (v - a[j] % v);
                    cnt += (v - a[j] % v);
                }
            }
            */
            //dump(sum);
            if (sum != 0) continue;
            if (cnt / 2 > k) continue;
            cout << v << endl;
            return;
        }
    }
}

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

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

int main(){
	int a,b;
	while(std::cin >> a >> b){
		if(a == 0 && b == 0){
			break;
		}
		std::vector< std::vector<int> > intersection(a, std::vector<int>(b, 1));
		int n;
		std::cin >> n;
		int close_a, close_b;
		for(int i = 0; i < n; ++i){
			std::cin >> close_a >> close_b;
			intersection[close_a - 1][close_b - 1] = 0;
			//工事が(1,i)にある時
			if(close_a == 1) {
				for(int i = (close_b - 1); i < b; ++i){
					intersection[close_a - 1][i] = 0;
				}
			}
			//工事が(i,1)にある時
			if(close_b == 1) {
				for(int i = (close_a - 1); i < a; ++i){
					intersection[i][close_b - 1] = 0;
				}
			}
		}
		for(int i = 1; i < a; ++i){
			for(int j = 1; j < b; ++j){
				if(intersection[i][j] != 0){
					intersection[i][j] = intersection[i - 1][j] + intersection[i][j - 1];
				}
			}
		}
		std::cout << intersection[a - 1][b - 1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1216
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    # N, K = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]

    aa = []
    t = A[0]
    start = A[0]
    for ai in A[1:]:
        if t <= ai:
            t = ai
            if start is None:
                start = ai
            continue
        aa.append(
            (start, t)
        )
        t = ai
        start = ai
    if start is not None:
        aa.append((start, A[-1]))

    m = 1000
    for a, b in aa:
        if a is None:
            continue
        c = m // a
        m += (b - a) * c
    print(m)


if __name__ == "__main__":
    main()



Measured memory_bytes: 68444
def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))

    S = sum(A)
    divisors = make_divisors(S)
    
    for d in divisors:
        R = list(map(lambda x: x % d, A))
        R = [r for r in R if r != 0]
        R.sort()
        cnt_m, cnt_p = 0, 0
        for r in R:
            if cnt_m <= K - r:
                cnt_m += r
            else:
                cnt_p += d - r
        if cnt_m <= K and cnt_p <= K:
            print(d)
            exit()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

if __name__ == "__main__":
    main()

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

int main ()
{

int a;
int b;
int c;
cin >> a>>b>>c;

if (a==5&&b==5&&c==7){
    cout << "YES ";
}
else if (a==5&&b==7&&c==5){
    cout << "YES";
}
else if (a==7&&b==5&&c==5){
    cout << "YES";
}
else {
    cout << "NO";
}

return 0;
}


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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int h, a;
    cin >> h >> a;
    if (h%a==0)
    {
        cout << h/a << endl;
    }else
    {
        cout << h/a +1<< endl;
    }
    
    
}

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

typedef long long ll;

int main() {
    ll N, M, d;
    cin >> N >> M;
    vector<ll> a(M), b(M), c(M, 0);
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            cin >> d;
            c[i] += 1 << (d - 1);
        }
    }
    vector<vector<ll>> dp(M + 1, vector<ll>(1 << N, 1e18));
    dp[0][0] = 0;
    rep(i, M) {
        rep(j, 1 << N) {
            dp[i + 1][j] = dp[i][j];
        }
        rep(j, 1 << N) {
            dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    if (dp[M][(1 << N) - 1] == 1e18) {
        cout << "-1\n";
    } else {
        cout << dp[M][(1 << N) - 1] << "\n";
    }
    /*
    rep(i, M + 1) {
        rep(j, 1 << N) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    */
}

Measured memory_bytes: 32384
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    a <- readLn
    print $ a + a^2 + a^3



Measured memory_bytes: 3932
N = int(input())
i = 0
while True:
    a = list((int(x)for x in input().split()))
    a.sort()
    i += 1
    if a[0]**2 + a[1]**2 == a[2]** 2:
        print("YES")
    else:
        print("NO")
    if i == N:
        break


Measured memory_bytes: 5604
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define SZ(x) ((int)(x).size())
#define int ll
#define el '\n'
template<class T> bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long long ll; typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<pii>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n,k;
char a,b;
cin>>n>>k>>a;
int ans=0, x=0, y=0;
char f=a;
for(int i=1;i<n;++i){
	cin>>b;
	if(a==b) ++ans;
	if(a!=b) a<b?++x:++y; 
	//DDD(i,a,b);
	a=b;
}
int mn=min({x,y,k});
ans+=2*mn;
x-=mn, y-=mn, k-=mn;
//DD(x,y);
if(x!=0){
	int m=(f=='L')+(a=='R');
	ans+=min({m,x,k});
} else if(y!=0){
	int m=(f=='R')+(a=='L');
	ans+=min({m,y,k});
}
cout<<ans<<el;

return 0;
}


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

const int MAXN = 200000;
int N, maximum = 0;
map<string, int> mp;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
        maximum = max(maximum, mp[s]);
    }
    for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
    {
        if ((*it).second == maximum)
        {
            cout << (*it).first << endl;
        }
    }
    
    // system("pause");
}

Measured memory_bytes: 17664
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

string s,no1,no2,ans;
int l1,l2;
int solve(int);

int main(){
  while(cin >> s){

    //分割しよう
    no1 = s.substr(0,s.find('+'));
    no2 = s.substr(s.find('+')+1,s.find('=')-s.find('+')-1);
    ans = s.substr(s.find('=')+1);

    l1=no1.size(),l2=no2.size();
    if(l1<l2)swap(l1,l2),swap(no1,no2);
    bool ok=false;
    for(int i=0;i<10;i++){
      if(solve(i)==1){
	cout<<i<<endl;
	ok=true;
	break;
      }
    }
    if(!ok)cout<<"NA"<<endl;
  }
}

int solve(int x){
  string cno1=no1,cno2=no2,cans=ans;

  // Xを数に置き換えよう
  for(int i=0;i<l1;i++)if(cno1[i]=='X')cno1[i]=x+'0';
  for(int i=0;i<l2;i++)if(cno2[i]=='X')cno2[i]=x+'0';
  for(int i=0,l=ans.size();i<l;i++)if(ans[i]=='X')cans[i]=x+'0';

  //足し算しよう
  for(int i=l1-1,j=l2-1;i>=0;i--,j--){
    if(j>=0) cno1[i]+=cno2[j]-'0';
    if(cno1[i]>'9'){
      cno1[i]-=10;
      if(i==0)cno1="1"+cno1;
      else cno1[i-1]++;
    }
  }

  //等しかったら1,不等だったら0を返そう
  return (cno1==cans ? 1 : 0);
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14 
#define MAX_V (1100)

struct edge{int to, cap, rev; };

vector <edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t)return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
} 

int gcd(int a, int b){
	return (b == 0 ? a : gcd(b, a % b));
}

signed main(){
    int m ,n;
    while(cin >> m >> n, n){
        int b[m], r[n];
        rep(i, MAX_V){
            G[i].clear();
            used[i] = false;
        }
        rep(i, m)
            cin >> b[i];
        rep(i, n)
            cin >> r[i];
        rep(i, m)rep(j, n)
            if(gcd(b[i], r[j]) != 1)
                add_edge(i, j + m, 1);
        rep(i, m)
            add_edge(n + m, i, 1);
        rep(i, n)
            add_edge(m + i, n + m + 1, 1);
        cout << max_flow(n + m, m + n + 1) << endl;
    }
}

Measured memory_bytes: 9436
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

    neg = 0
    m = INF
    for i in range(N):
        if A[i] < 0:
            neg += 1
            A[i] = - A[i]
        m = min(m, A[i])

    if 0 in A:
        print(sum(A))
    else:
        print(sum(A) - (2 * m)*(neg % 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 21148
#include <stdio.h>
int noa(){
	char s[32];
	int a=0,b=0,c=0;
	scanf("%s\n", s);
	for(int i =0;i<strlen(s);i++){
	   // printf("%c[%d][%d][%d]\n",s[i],a,b,c );
		if(s[i] == 'a'){
			a++;
			continue;
		}
		if(s[i] == 'b'){
			b++;
			continue;
		}
		if(s[i] == 'c'){
			c++;
			continue;
		}
	}
	if(a == b && b == c){
		printf("%s\n","Yes" );
		return 0;
	}else{
		printf("%s\n","No" );
		return 0;
	}
}
int nob(){
	// A  以上 B 以下の整数の中で、小さい方から K 番目以内であるか、大きい方から K 番目以内である
	// A B K
	int A,B,K;
	int i2;
	scanf("%d %d %d\n",&A,&B,&K );
// 	printf("%d %d %d\n",A,B,K );
// 	i2 = A;
	for(int i=A;i<=B;i++){
		if(i < A+K && i <= B){
			//小さい方からK番目(A~K)
			printf("%d\n", i);
			continue;
		}
		if(i > B-K && i<= B){
			//大きい方からK番目(A~K)
			printf("%d\n", i);
// 			i2 = i;
			continue;
		}
	}
}

int main(void){
	// Your code here!
	nob();
	return 0;

}


Measured memory_bytes: 128
import java.util.*;

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

    Scanner sc = new Scanner(System.in);
    //整数の入力
    String str = sc.next();


    //前方から順番に文字が切り替わる回数をカウントする
    int len = str.length();
    int cnt = 0;

    for(int i=0; i<len-1; i++){
      char before = str.charAt(i);
      char after = str.charAt(i+1);

      if(before != after)cnt++;
    }

    System.out.println(cnt);


  }
}


Measured memory_bytes: 12772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        //double n = in.nextDouble();
        //out.println(n * n * n / 27);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] cnt = new int[n + 1];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            cnt[a[i]]++;
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) if (cnt[i] > 0) {
            ans += 1L * cnt[i] * (cnt[i] - 1) / 2;
        }
        for (int i = 0; i < n; i++) {
            out.println(ans - cnt[a[i]] + 1);
        }
    }



}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 51316
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>;


using namespace std;



int main() {
    string W, T;
    int count = 0;
    cin >> W;
    cin >> T;
    while (T != "END_OF_TEXT") {
        for (int i = 0; i < W.size(); i++) {
            if ('A' <= T[i] && T[i] <= 'Z') {
                T[i] += 32;
            }
        }
        if (W == T) {
            count++;
        }
        cin >> T;

    }

    
    cout << count << endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define fori(a,n) for(int i=a,i<n;i++)
#define MX 1000007
using namespace std;

int main()
{
    int a,b,c,d;

    cin>>a>>b>>c>>d;

    cout<<min(a,b)+min(c,d)<<endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin >> s;
    if (s[2] == s[3] and s[4]==s[5])
        cout << "Yes\n";
    else
    {
        cout <<  "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int64 A, B, C, K; cin >> A >> B >> C >> K;

    int64 ans = 0;
    if (A >= K) {
        cout << K << endl;
        exit(0);
    } else {
        K -= A;
        ans += A;
    }

    if (B >= K) {
        cout << ans << endl;
        exit(0);
    } else {
        K -= B;
    }

    cout << ans - K << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n;
  cin >> n;
  pii ans(-1,0);
  REP(i,n) {
    int a,b;
    cin >> a >> b;
    chmax(ans, pii(b,-a));
  }
  printf("%d %d\n", -ans.second, ans.first);
}

Measured memory_bytes: 1136
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
string s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    string ans;
    cin>>n>>s;
    Vi v(n+1,-1);
    rep(i,2){
        rep(j,2){
            v[0] = i;
            v[1] = j;
            v.resize(n+1,-1);
            for(ll k = 1;k<n;k++){
                if(v[k]==0){
                    if(s[k]=='o'){
                        v[k+1] = v[k-1];
                    }else{
                        v[k+1] = (v[k-1]+1)%2;
                    }
                }else{//ookami
                    if(s[k]=='x'){
                        v[k+1] = v[k-1];
                    }else{
                        v[k+1] = (v[k-1]+1)%2;
                    }
                }
            }
            if(v[0]!=v[n])continue;
            if(v[0]==0){
                if(s[0]=='o'){
                    if(v[1]!=v[n-1])continue;
                }else{
                    if(v[1]==v[n-1])continue;
                }
            }else{
                if(s[0]=='o'){
                    if(v[1]==v[n-1])continue;
                }else{
                    if(v[1]!=v[n-1])continue;
                }
            }

            rep(i,n){
                if(v[i]==0)ans.pb('S');
                else ans.pb('W');
            }
            print(ans);
            return 0;
        }
    }
    print(-1);
    return 0;
}

Measured memory_bytes: 1488
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(x: usize);
    let mut n = 100;
    let mut count = 0;
    while n < x {
        n += n / 100;
        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 2172
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let m:usize = sc.read();
    let _d:usize = sc.read();
    let n:usize = sc.read();
    let _e:usize = sc.read();
    if m != n{
        println!("1");
    }else{
        println!("0");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long a = in.scanInt();
            long b = in.scanInt();
            long c = in.scanInt();
            long x = in.scanInt();
            long y = in.scanInt();
            long ans = 0;
            if (x <= y) {
                if (2 * c <= a + b) ans += (2 * c * x);
                else ans += ((a + b) * x);
                if (2 * c <= b) ans += (2 * c * (y - x));
                else ans += (b * (y - x));
            } else {
                if (2 * c <= a + b) ans += (2 * c * y);
                else ans += ((a + b) * y);
                if (2 * c <= a) ans += (2 * c * (x - y));
                else ans += (a * (x - y));
            }
            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

using namespace std;
const int maxn=1e5+100;
int h[maxn];
int main()
{
    int n;
    memset(h,0,sizeof(h));
    cin>>n;
    int i,x;
    for (i=1;i<=n;i++){
      scanf("%d",&x);
      x++;
      h[x-1]++;h[x]++;h[x+1]++;
    }
    int ans=0;
    for (i=0;i<maxn;i++) ans=max(ans,h[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import copy

n = int(input())
check = True
a = input().split()

a = [(x[0], int(x[1])) for x in a]
b = copy.deepcopy(a)

#Bubble Sort
flag = True
i = 0
while flag:
    flag = False

    for j in range(n-1, i, -1):
        if a[j][1] < a[j-1][1]:
            tmp = a[j]
            a[j] = a[j-1]
            a[j-1] = tmp
            flag = True

    i += 1

#Selection sort
for i in range(0, n):
    minj = i
    for j in range(i, n):
        if b[j][1] < b[minj][1]:
            minj = j
   
    if i != minj:
        tmp = b[i]
        b[i] = b[minj]
        b[minj] = tmp


for i in range(len(a)):
    if i!=len(a)-1:
        print(a[i][0], end="")
        print(a[i][1], end=" ")
    else:
        print(a[i][0], end="")
        print(a[i][1], end="")
print()
print("Stable")

for i in range(len(b)):
    if i!=len(b)-1:
        print(b[i][0], end="")
        print(b[i][1], end=" ")
    else:
        print(b[i][0], end="")
        print(b[i][1], end="")

print()

for i in range(len(b)):
    if a[i][0] != b[i][0]:
        print("Not stable")
        check = False
        break
if check:
    print("Stable")


Measured memory_bytes: 6348
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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 (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    string S;
    cin >> S;
    S="ABC"+S;
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m; if (n>m) swap(n,m);
	if (n==1&&m==1) cout<<"1";
	else if (n==1) cout<<m-2;
	else cout<<(n-2)*(m-2);
	return 0;
}

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


int main() {

    ll n;
    cin >> n;
    for (ll i = n; i > 0; --i) {
        int x = sqrt(i);
        if (x * x == i) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
class DisjointSets
{
public:
    DisjointSets(const int v) : parent(v), rank(v, 0) { iota(parent.begin(), parent.end(), 0); }
    bool same(const int a, const int b) { return find(a) == find(b); }
    int find(const int a) { return parent[a] == a ? a : parent[a] = find(parent[a]); }
    void unite(int a, int b)
    {
        a = find(a), b = find(b);
        if (a == b) { return; }
        if (rank[a] < rank[b]) { swap(a, b); }
        rank[a] += rank[b], parent[b] = a;
    }

private:
    vector<int> parent, rank;
};
int main()
{
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<char> v(M);
    vector<int> u(M);
    int maximum = 1;
    for (int i = 0; i < M; i++, maximum *= 3) { cin >> v[i] >> u[i]; }
    map<char, int> mp;
    for (int i = 0; i < M; i++) { mp[v[i]] = i; }
    ll ans = 0;
    for (int i = 0; i < maximum; i++) {
        int num = i;
        vector<string> st(M);
        using Set = bitset<10>;
        vector<Set> cand;
        for (int i = 0; i < M; i++, num /= 3) {
            const int c = num % 3;
            if (c == 0) {
                st[i].push_back('a' + cand.size()), cand.push_back(Set((1 << min(u[i] + 1, 10)) - 1));
            } else if (c == 1) {
                st[i].push_back('a' + cand.size()), u[i] >= 20 ? cand.push_back(Set((1 << (u[i] / 10)) - 2)) : cand.push_back(Set(0));
                st[i].push_back('a' + cand.size()), cand.push_back(Set((1 << 10) - 1));
            } else {
                st[i].push_back('a' + cand.size()), u[i] >= 10 ? cand.push_back(Set(1 << (u[i] / 10))) : cand.push_back(Set(0));
                st[i].push_back('a' + cand.size()), cand.push_back(Set((1 << (1 + u[i] % 10)) - 1));
            }
        }
        for (int i = 0; i < 10; i++) { cand.push_back(Set(1 << i)); }
        string s;
        for (const char c : S) {
            if (isdigit(c)) {
                s.push_back(c);
            } else {
                s += st[mp[c]];
            }
        }
        const int l = cand.size();
        auto enc = [&](const char c) { return isdigit(c) ? l - 10 + c - '0' : c - 'a'; };
        DisjointSets uf(l);
        for (int i = 0; i < s.size() / 2; i++) { uf.unite(enc(s[i]), enc(s[s.size() - i - 1])); }
        vector<Set> v(l, Set((1 << 10) - 1));
        vector<bool> used(l, false);
        for (int i = 0; i < l; i++) { used[uf.find(i)] = true, v[uf.find(i)] &= cand[i]; }
        ll sub = 1;
        for (int i = 0; i < l; i++) { (sub *= not used[i] ? 1 : v[i].count()) %= MOD; }
        (ans += sub) %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3228
''' ===============================
    -- @uthor : Kaleab Asfaw
    -- Handle : kaleabasfaw2010
    -- Bio    : High-School Student
    ==============================='''

# Fast IO
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = "x" in file.mode or "r" not in file.mode; self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b: break
            ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0; return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b"\n") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1; return self.buffer.readline()
    def flush(self):
        if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode("ascii")); self.read = lambda: self.buffer.read().decode("ascii"); self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip("\r\n")
# Others
# from math import floor, ceil, gcd
# from decimal import Decimal as d
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def rest(i):
	if i == 1: return [0, 2]
	elif i == 2: return [0, 1]
	else: return [1, 2]

def solve(n, lst):
	dp = arr2D(n+1, 3,-1)
	for i in range(1, n+1):
		for j in range(3):
			if dp[i-1][j] == -1:
				dp[i][j] = lst[i-1][j]
			else:
				for k in rest(j):
					dp[i][j] = max(dp[i-1][k] + lst[i-1][j], dp[i-1][k] + lst[i-1][j], dp[i][j])
	return max(dp[n])



n = int(input())
lst = []
for i in range(n):
	lst.append(list(map(int, input().split())))
print(solve(n, lst))

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

int main()
{
ll n ;
cin >> n ;
vector<ll> v(n,0);
rep(i,110)rep(j,110)rep(k,110){
  if((i+1)*(i+1)+(j+1)*(j+1)+(k+1)*(k+1)+(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)<=n){
    v[(i+1)*(i+1)+(j+1)*(j+1)+(k+1)*(k+1)+(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)-1]++;
  }
}

for(auto an:v)cout << an << endl;
return 0;
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    a,b = map(str,input().split())

    num = int(a+b)
    if math.sqrt(num) - int(math.sqrt(num)) == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[2] == N[3]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

char chan[2][1024];
char str[100000024];

int main()
{
	int n, m;
	int i, j;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%s %s", &chan[0][i], &chan[1][i]);
			//printf("chan[0][%d]=%c\n", i, chan[0][i]);
			//printf("chan[1][%d]=%c\n", i, chan[1][i]);
		}
		
		scanf("%d", &m);
		
		for (i = 0; i < m; i++){
			scanf("%s", &str[i]);
			for (j = 0; j < n; j++){
				if (str[i] == chan[0][j]){
					str[i] = chan[1][j];
					break;
				}
			}
			//printf("str[%d]=%c\n", i, str[i]);
		}
		
		str[i] = '\0';
		
		printf("%s\n", str);
	}
	
	return (0);
}

Measured memory_bytes: 1120
def main():
    n = int(input())
    a = sorted(list(map(int,input().split())))
    dp = [-1 for i in range(a[-1])]
    for i in range(n):
        if dp[a[i]-1]==-1:
            dp[a[i]-1]=1
            for j in range(2,a[-1]//a[i]+1):
                dp[a[i]*j-1]=0
        elif dp[a[i]-1]==1:
            dp[a[i]-1]=0
    ans = 0
    for i in range(len(dp)):
        if dp[i]==1:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 32252