akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
string s1, s2;
ll n1, n2; cin>>s1>>s2;
n1=s1.length();
n2=s2.length();
ll i,j;
ll dp[n1+1][n2+1];
for(i=0;i<=n1;i++){
    for(j=0;j<=n2;j++){
        if(i==0||j==0){
            dp[i][j]=0;
        }
    }
}
for(i=1;i<=n1;i++){
    for(j=1;j<=n2;j++){
        if(s1[i-1]==s2[j-1]){
            dp[i][j]=dp[i-1][j-1]+1;
        }
        else{
            dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }
}
i=n1;
j=n2;
string s="";
while(i>0&&j>0){
if(dp[i][j]==dp[i-1][j-1]+1&&s1[i-1]==s2[j-1]){
    s+=s1[i-1];
    i--;
    j--;
}
else if(dp[i][j]==dp[i-1][j]){
    i--;
}
else{
    j--;
}
}
for(i=s.length()-1;i>=0;i--){
    cout<<s[i];
}
cout<<endl;

    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ll a,b,x,cnt=0;
  cin >> a >> b >> x;
  if(a==0){
    cnt = (b / x) + 1;
  }else{
    cnt = (b / x) - ((a-1) / x);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
  uint64_t k;
  cin >> k;
  if (k % 2 == 0) {
    cout << "-1" << endl;
    return 0;
  }

  int res = 1;
  int n = 1;
  int formula = 7;
  unordered_set<int> s;
  while (1) {
    int mod = formula % k;
    if (mod == 0) {
      cout << res << endl;
      break;
    }
    if (s.find(mod) != s.end()) {
      cout << "-1" << endl;
      break;
    }
    ++res;
    s.insert(mod);
    formula = mod * 10 + 7;
  }

  return 0;
}

Measured memory_bytes: 42596
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i], b[i] = [int(x) for x in input().split()]

tasks = sorted(list(zip(a, b)), key=lambda x: x[1])

is_okay = True
sum = 0
for i in range(N):
    sum += tasks[i][0]

    if sum > tasks[i][1]:
        is_okay = False
        break

print('Yes' if is_okay else 'No')


Measured memory_bytes: 36552
#include <iostream>
#include <string>

using namespace std;

int main(){
	string a,b;
	while(cin >> a >> b){
		if(a == "0" && b == "0") break;
		int hit=0,blow=0;
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i] == b[j]){
					if(i==j){
						hit++;
					}else{
						blow++;
					}
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long
#define il inline
const ll inf = 1e9;

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 2000100

int a = read(), b = read(), c = read();

int main() {
	if(a == b && b == c && a) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == ',') {
            cout << " ";
        } else {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;

namespace ConsoleApp23
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = line[0];
            var k = line[1];

            var length = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .Take(n)
                .OrderByDescending(c=>c)
                .Take(k)
                .Sum();


            Console.WriteLine(length.ToString());
        }
    }
}


Measured memory_bytes: 13396
W,H,N = map(int, input().split())
rec = [["W"]*(W) for _ in range(H)]

for _ in range(N):
    x,y,a = map(int, input().split())
    if a==1:
        for h in range(H):
            for w in range(W):
                if w<x:
                    rec[h][w]="B"
    elif a==2:
        for h in range(H):
            for w in range(W):
                if w>=x:
                    rec[h][w]="B"
    elif a==3:
        for h in range(H):
            for w in range(W):
                if h<y:
                    rec[h][w]="B"
    else:
        for h in range(H):
            for w in range(W):
                if h>=y:
                    rec[h][w]="B"
                    
ans = 0
for h in range(H):
    for w in range(W):
        if rec[h][w]=="W":
            ans += 1
print(ans)
# print(rec)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n;
int a[100005];
int main()
{
	read(n);
	for(int i=0;i<n;i++)
		read(a[i]);
	sort(a,a+n);
	int kv=-1;
	int rv=-1;
	int mxx=a[n-1];
	for(int i=0;i<n-1;i++)
	{
		int nn=min(a[i],mxx-a[i]);
		if(nn>kv)
		{
			kv=nn;
			rv=a[i];
		}
	}
	printf("%d %d\n",a[n-1],rv);
	return 0;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   vector<int> p {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int K;
   cin >> K;
   cout << p.at(K - 1) << endl;

 }


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

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

    vector<int> a(n + 1);
    a[0] = 0;
    rep(i, n)
    {
        cin >> a[i + 1];
    }

    vector<int> b(n + 1);
    b[0] = 0;
    rep(i, n)
    {
        if (a[i + 1] > a[b[i]]) {
            b[i + 1] = i + 1;
        } else {
            b[i + 1] = b[i];
        }
    }

    vector<int> c(a);
    sort(c.begin(), c.end());

    vector<int64_t> d(n + 2);
    rirep(i, n + 1)
    {
        if (i == n + 1) {
            d[i] = 0;
        } else {
            d[i] = d[i + 1] + c[i];
        }
    }

    vector<int64_t> result(n + 1, 0);
    int i = b[n];
    while (i != 0) {
        int oldi = i;
        i = b[oldi - 1];

        int oldj = upper_bound(c.begin(), c.end(), a[oldi]) - c.begin();
        int j = upper_bound(c.begin(), c.end(), a[i]) - c.begin();

        int64_t oldp = d[oldj] - (int64_t)(n + 1 - oldj) * a[oldi];
        int64_t p = d[j] - (int64_t)(n + 1 - j) * a[i];

        result[oldi] = p - oldp;
    }

    rep(i, n)
    {
        cout << result[i + 1] << endl;
    }

    return 0;
}

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

int main(){
  ll x,y;
  cin >> x >> y;
  if((y%2==0)&&(x*2<=y)&&(x*4>=y)){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

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

typedef long long ll;
#define rep1(i, n) for(int i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(int i = 0; i <=(ll)(n); i++)


int main(){
    int h,w;
    cin >> h >> w;
    int a[h+1][w+1];
    int b[h+1][w+1];
    rep1(i, h){ rep1(j,w){cin >> a[i][j];}}    
    rep1(i, h){ rep1(j,w){cin >> b[i][j];}}
    int nary = max(h,w);
    bool dp[nary*h+w+1][160*80+1];
    rep1(i, h){ rep1(j,w){ rep0(k,160*80){dp[i*nary+j][k] = false;}}}
    
    int diff = abs(a[1][1] - b[1][1]);
    dp[1*nary+1][diff] = true;

    rep1(i, h){
        rep1(j, w){
            if(i == 1 && j == 1) continue;
            diff = abs(a[i][j] - b[i][j]);
            if(i == 1){ //左からのみ参照
                rep0(k, 160*80){
                    if(dp[i*nary+(j-1)][k]){
                        dp[i*nary+j][k+diff] = true;
                        dp[i*nary+j][abs(k-diff)] = true;    
                    }
                }
            }else if(j == 1){ //上からのみ参照
                rep0(k, 160*80){
                    if(dp[(i-1)*nary+j][k]){
                        dp[i*nary+j][k+diff] = true;
                        dp[i*nary+j][abs(k-diff)] = true;    
                    }
                }
            }else{ //左と上から参照
                rep0(k, 160*80){
                    if(dp[i*nary+(j-1)][k]){
                        dp[i*nary+j][k+diff] = true;
                        dp[i*nary+j][abs(k-diff)] = true;    
                    }
                }
                rep0(k, 160*80){
                    if(dp[(i-1)*nary+j][k]){
                        dp[i*nary+j][k+diff] = true;
                        dp[i*nary+j][abs(k-diff)] = true;    
                    }
                }
            } 
        }
    }
    int min_diff = 10000000;
    rep0(k, 160*80){
        if(dp[h*nary+w][k]){
            min_diff = min(k, min_diff); 
        }
    }
    cout << min_diff << endl;
    return 0;
}

Measured memory_bytes: 83260
import           Data.List  (intersect)
import           Data.Maybe (fromMaybe, listToMaybe)

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  print $ solve a b

solve :: Int -> Int -> Int
solve a b = fromMaybe (-1) . listToMaybe $ intersect xs ys
  where xs = prices 8 a
        ys = prices 10 b

prices :: Int -> Int -> [Int]
prices t a = [x .. y]
  where x = (a * 100 + t - 1) `div` t
        y = ((a + 1) * 100 - 1) `div` t


Measured memory_bytes: 508
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    long long N,K;
    scanf("%lld%lld",&N,&K);
    
    long long min=0;
    long long minn=0;
    min=N%K;
    minn=K-min;
    (min<=minn)?printf("%lld",min):printf("%lld",minn);
}


Measured memory_bytes: 1728
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

long long prim(const WGraph &G) {
    int n = (int)G.size();
    std::vector<bool> used(n, false);
    long long res = 0;
    using P = std::pair<long long, int>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    used.at(0) = true;
    for (auto e : G.at(0)) {
        que.push(std::make_pair(e.second, e.first));
    }
    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (used.at(v)) {
            continue;
        }
        used.at(v) = true;
        res += p.first;
        for (auto e : G.at(v)) {
            if (!used.at(e.first)) {
                que.push(std::make_pair(e.second, e.first));
            }
        }
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<ll, int>> x(n), y(n);
    for (int i=0; i<n; i++) {
        cin >> x.at(i).first >> y.at(i).first;
        x.at(i).second = y.at(i).second = i;
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    WGraph G(n);
    for (int i=0; i<n-1; i++) {
        G.at(x.at(i).second).push_back({x.at(i+1).second, abs(x.at(i).first - x.at(i+1).first)});
        G.at(x.at(i+1).second).push_back({x.at(i).second, abs(x.at(i).first - x.at(i+1).first)});
        G.at(y.at(i).second).push_back({y.at(i+1).second, abs(y.at(i).first - y.at(i+1).first)});
        G.at(y.at(i+1).second).push_back({y.at(i).second, abs(y.at(i).first - y.at(i+1).first)});
    }

    cout << prim(G) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 16500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
char s[maxn];
vector<int>ans;
int f(int x)
{
    int cnt=0;
    while(x)
    {
        x%=__builtin_popcount(x);
        cnt++;
    }
    return cnt+1;
}
ll power(ll base,ll n,ll m)
{
    ll r=1;
    while(n)
    {
        if(n&1) r=r*base%m;
        base=base*base%m;
        n/=2;
    }
    return r;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cin>>(s+1);
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='1')
            sum++;
    }
    ll sum1=0;
    ll sum0=0;
    reverse(s+1,s+1+n);
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='1')
        {
            sum0+=power(2,i-1,sum+1);
            sum0%=(sum+1);
            if(sum-1==0)
                continue;
            sum1+=power(2,i-1,sum-1);
            sum1%=(sum-1);

        }
    }
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='1')
        {
            if(sum-1==0)
            {
                ans.pb(0);
                continue;
            }
            ll temp=sum1-power(2,i-1,sum-1);
            temp=(temp+sum-1)%(sum-1);
            ans.pb(f(temp));
        }
        else
        {
            ll temp=sum0+power(2,i-1,sum+1);
            temp%=sum+1;
            ans.pb(f(temp));
        }
    }
    reverse(ans.begin(),ans.end());
    for(auto &v:ans)
        cout<<v<<'\n';









}


Measured memory_bytes: 4440
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())

    cnt=0
    for i in range(1,n+1,2):
        if len(make_divisors(i))==8:
            cnt+=1

    print(cnt)

def make_divisors(n):
    if n==1:
        divisors=[1]
        return divisors
    else:
        divisors=[]
        for i in range(1,n):
            if i*i>n:
                break
            if n%i==0:
                divisors.append(i)
                if i!=n//i:
                    divisors.append(n//i)

        #divisors.sort()
        return divisors

if __name__=="__main__":
    main()

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K <= A+B) cout << min(A, K) << endl;
  else cout << A - (K - A - B) << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
const int M = 1'000'000'007;
int n, xyz[3], xyz_sum;
bool can(int d, int i) {
    bool ans = true;
    int sum = 0, j = 0;
    while(d > 0 and ans) {
        sum += __builtin_ffs(d);
        ans &= sum <= xyz[j];
        if(sum == xyz[j]) {
            sum = 0;
            j++;
        }
        d >>= __builtin_ffs(d);
    }
    return ans and (j == 2 and sum + i == xyz[j]);
}
int sum(int d) {
    return d ? 32 - __builtin_clz(d) : 0;
}
int push_back(int d, int i) {
    return d | (1 << (i - 1 + sum(d)));
}
const int N = 40, XYZ = 17;
ll mem[N + 1][1 << (XYZ + 1)][2];
ll C(int n, int d, bool has_xyz) {
    ll& ans = mem[n][d][has_xyz];
    if(ans == -1) {
        if(n == 0) {
            ans = has_xyz;
        } else if(has_xyz) {
            ans = 10 * C(n - 1, d, true) % M;
        } else {
            ans = 0;
            for(int i = 1; i <= 10; i++) {
                while(d > 0 and sum(d) + i > xyz_sum) {
                    d >>= __builtin_ffs(d);
                }
                ans = (ans + C(n - 1, push_back(d, i), can(d, i))) % M;
            }
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> xyz[0] >> xyz[1] >> xyz[2];
    xyz_sum = accumulate(begin(xyz), end(xyz), 0);
    memset(mem, -1, sizeof mem);
    cout << C(n, 0, 0) << endl;
    return 0;
}


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

struct Card {
    char suit;
    char value;
};

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >  i; j--) {
            if (A[j].value < A[j - 1].value) {
                Card temp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = temp;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    int minj;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i + 1; j < N; j++) {
            if (A[j].value < A[minj].value) {
                minj = j;
            }
        }
        if (minj != i) {
            Card temp = A[minj];
            A[minj] = A[i];
            A[i] = temp;
        }
    }
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    return true;
}

int main(int argc, char const *argv[])
{
    struct Card C1[100];
    struct Card C2[100];
    int N;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i].suit = C1[i].suit;
        C2[i].value = C1[i].value;
    }

    bubble(C1, N);
    selection(C2, N);

    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << C1[i].suit << C1[i].value;
    }
    cout << endl;
    cout << "Stable" << endl;
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << C2[i].suit << C2[i].value;
    }
    cout << endl;
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3072
a,b,c,d,e,f=map(int,open(0).read().split());g,h=(c-e)*a,(d-f)*b
if g>0:g,h=-g,-h
i=g+h
if i<0:print(0)
elif i==0:print("infinity")
else:print(2*(-g//i)+[0,1][int(bool(-g%i))])

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

bool isPalindrome(string target) {
  string s = target;
  reverse(s.begin(), s.end());
  return s == target;
}

int main() {
  string s;
  cin >> s;
  if (!isPalindrome(s)) {
    cout << "No" << endl;
    return 0;
  }
  string ss = s.substr(0, (s.length() - 1) / 2);
  if (!isPalindrome(ss)) {
    cout << "No" << endl;
    return 0;
  }
  ss = s.substr((s.length() + 3 - 1) / 2, s.length());
  if (!isPalindrome(ss)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for _ in range(q)]
dic={}
for i in range(n):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic[a[i]]=1
s=sum(a)
for i in range(q):
    b,c=bc[i]
    if b not in dic:
        print(s)
        continue
    else:
        print(s+(c-b)*dic[b])
        s+=(c-b)*dic[b]
        if c not in dic:
            dic[c]=dic[b]
        else:
            dic[c]+=dic[b]
        dic[b]=0

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> A(N);
    for(auto& i : A){
        cin >> i;
        --i %= K;
    }
    for(unsigned long i = 1; i < N; ++i)(A[i] += A[i - 1]) %= K;
    vector<pair<unsigned long, unsigned long>> t(N);
    for(unsigned long i = 0; i < N; ++i)t[i] = {A[i], i + 1};
    t.emplace_back(0, 0);
    sort(t.begin(), t.end());
    unsigned long ans{0};
    for(unsigned long l{0}, r{0}; l <= N; ++l){
        while(r <= N && (t[r].first - t[l].first) % K == 0 && t[l].second + K > t[r].second)++r;
        ans += r - l - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9984
n = gets.chomp.to_i

b = []
n.times do |i|
  b[i] = []
  a = gets.chomp.to_i
  a.times do
    x, y = gets.chomp.split.map(&:to_i)
    b[i].push([x, y])
  end
end

ans = 0
['o', 'x'].repeated_permutation(n) do |a|
  flag = false
  b.each_with_index do |c, index|
    c.each do |x, y|
      if a[index] == 'o'
        if y == 1
          if a[x-1] == 'o'
          else
            flag = true
            break
          end
        else
          if a[x-1] == 'x'
          else
            flag = true
            break
          end
        end
      end
    end
    break if flag
  end
  next if flag
  tmp = a.count('o')
  ans = tmp if tmp > ans
end
p ans


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n;
      if(n==2)cin>>a>>b,Cout(a+b);
      else Cout("Hello World");
    
       
return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Fibonacci());
        }

        static long Fibonacci()
        {
            var n = long.Parse(Console.ReadLine());
            var A = new long[n + 1];
            A[0] = 1;
            A[1] = 1;

            for (var i = 2; i <= n; i++)
            {
                A[i] = A[i - 1] + A[i - 2];
            }

            return A[n];
        }
    }
}



Measured memory_bytes: 15976
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a, b;
    cin >> a >> b;
    cout << (a * b) - a - b + 1 << endl;
    return 0;
}








Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int np = n;
    int s = 0, k = 0, j = 1, d;
    while (n >= j) {
        k++;
        j *= 10;
    }
    j /= 10;
    for (int i = 0; i < k; i++) {
        s += n / j;
        n -= (n / j) * j;
        j /= 10;
    }
    if (np % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
//#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)   int x; cin>>x; while(x--)

const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}


int32_t main()
{
	very_fast();
	//no_of_test(x)
	{
		int a[5];
		int sum = 0;
		for (int i = 0; i < 5; i++)
		{
			cin >> a[i];
			sum += a[i];
		}
		cout << 15 - sum << endl;

	}
	return 0;
}





Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pdd pair<db,db>

using namespace std;

typedef long long ll;
typedef double db;

const int N = 1e5+10,M=1e4+10,MOD = 1e9+7;

int fa[N*2],fb[2*N];
int ans[N*2];

void init(int n){
    for(int i=0;i<=n;i++)
        fa[i]=fb[i]=i;
}

int finda(int x){
    if(fa[x]!=x)fa[x]=finda(fa[x]);
    return fa[x];
}
int findb(int x){
    if(fb[x]!=x)fb[x]=findb(fb[x]);
    return fb[x];
}

int main()
{
    int n,k,l;
    while(~scanf("%d%d%d",&n,&k,&l)){
        init(n);
        for(int i=0;i<k;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            int fx=finda(x),fy=finda(y);
            if(fx!=fy)fa[fx]=fy;
        }
        for(int i=0;i<l;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            int fx=findb(x),fy=findb(y);
            if(fx!=fy)fb[fx]=fy;
        }
        map<int,pii> m1;
        map<pii,int> m2;
        for(int i=1;i<=n;i++){
            int xa=finda(i),xb=findb(i);
           //cout<<xa<<" "<<xb<<endl;
            m1[i]=mp(xa,xb);
            m2[mp(xa,xb)]++;
           // cout<<"("<<m1[i].x<<","<<m1[i].y<<") "<<m2[mp(xa,xb)]<<endl<<endl;
        }

        for(int i=1;i<=n;i++){
            ans[i]=m2[m1[i]];
        }
        for(int i=1;i<=n;i++)
            cout<<ans[i]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 26368
#include <queue>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <stack>
#include <algorithm>
#define MIN(x,y) ((x)<(y)?(x) : (y))
#define MAX(x,y) ((x)>(y)?(x) : (y))
#include <stdlib.h>
#include <time.h>
#include <sstream>
#define mem(a,b) memset(a,b,sizeof(a))
#include <string>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
const ll INF=1e9;
/*坚持不懈，无懈可击*/
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    int z=B/A;
    if(z<=C) printf("%d\n",z);
    else printf("%d\n",C);
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
  
  ld n;
  cin>>n;
  ld sum=0;
  for(int i=0;i<n;i++){
    ld a;
    cin>>a;
    sum+=1.0/a;
  }

  cout<<1.0/sum<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define fr first
#define sc second
#define ll long long int
#define bit(idx) idx&(-idx)
#define bin(x, a) bitset<a>(x)
#define all(A) A.begin(), A.end()
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

const int MAXN = 2e5 + 5;

vector<int> G[MAXN];

int main(){
	ios_base::sync_with_stdio(NULL); cin.tie(); cout.tie();
    int n, m; cin >> n >> m;
    vector<int> A;
    A.pb(-1);
    for(int i = 0; i < n; i ++){
        int x; cin >> x;
        A.pb(x);
    }
    bool av[MAXN] = {0};
    for(int i = 0; i< m; i ++){
        int u, v; cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
        av[u] = 1;
        av[v] = 1;
    }
    ll ans = 0;
    for(int u = 1; u <= n; u ++){
        bool good = 1;
        if(G[u].empty()){
            ++ ans;
            continue;
        }
        for(auto v : G[u]){
            if(A[v] >= A[u]){
                good = 0;
            }
        }
        if(good) ++ ans;
    }
    cout << ans << endl;
}
/**

*/



Measured memory_bytes: 11148
import sys
readline = sys.stdin.readline

import itertools

#DEBUG = True
DEBUG = False

N = int(readline())

class Interactive:
    def __init__(self):
        self.ques_cnt = 0
        self.create_data()
        
    def create_data(self):
        import random
        A = ['B']*N + ['R']*N
        random.shuffle(A)
        self.A = [None] + A
        
    def resp_ques(self, *args):
        self.ques_cnt += 1
        assert len(args) == N
        from collections import Counter
        A = self.A
        selected = [A[i] for i in args]
        counter = Counter(selected)
        resp = 'Red' if counter['R'] > counter['B'] else 'Blue'
        return resp
    
    def resp_ans(self, *args):
        if len(args) != 1 or not isinstance(args[0], str):
            raise ValueError('Answer must be a string')
        if list(args[0]) == self.A[1:]:
            print('AC!')
            print('num of questions:', self.ques_cnt)
        else:
            print('WA!')
            
if DEBUG:
    interactive = Interactive()
    
def question(*args):
    print('?', *args, flush=True)
    if DEBUG:
        resp = interactive.resp_ques(*args)
        print(resp)
        return resp
    else:
        return readline()
    
def answer(*args):
    print('!', *args, flush=True)
    if DEBUG:
        interactive.resp_ans(*args)
    else:
        exit()

def make_LR_range(L,R):
    return itertools.chain(range(1,L+1), range(N+N-R+1, N+N+1))

def f(L):
    return question(*make_LR_range(L, N-L)).rstrip()

# f(L) != f(R)
L = 0
R = N
cL = f(L)
while L + 1 < R:
    x = (L + R) // 2
    if cL == f(x):
        L = x
    else:
        R = x

inv = {'B':'R', 'R':'B'}

C = [None] * (N+N+1)
C[L+1] = inv[cL[0]]
C[L+N+1] = cL[0]

A = list(range(1,L+1)) + list(range(L+N+2,N+N+1))
B = list(range(L+2,L+N+1))
for b in B:
    resp = question(b, *A)
    C[b] = resp[0]
for a in A:
    resp = question(a, *B)
    C[a] = resp[0]

answer(''.join(C[1:]))

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a+3, greater<int>());
	cout<<a[0]*10+a[1]+a[2]<<endl;
	return 0;
}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 100009
#define inf 999999999999
using namespace std;

ll dp1[10009];
ll dp2[10006];
char s[25];

int num[105];

int main()
{
    int n,m,x,y;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)break;
        for(int i=0; i<n; i++)
            scanf("%d",&num[i]);
        sort(num,num+n);
        for(int i=1;i<=10000;i++)dp2[i]=-inf;
        dp2[0]=0;
        memset(dp1,0,sizeof dp1);
        scanf("%d",&m);
        bool flag=0;
        for(int i=0; i<m; i++)
        {
            scanf("%s",s);
            scanf("%d",&x);
            scanf("%s",s);
            scanf("%d",&y);
            if(x==0&&y>0)flag=1;
//        printf("%d %d\n",x,y);
            if(s[0]=='S')
            {
                for(int j=x; j<=10000; j++)
                    dp1[j]=max(dp1[j],dp1[j-x]+y);//single
            }
            else
            {
                for(int j=x; j<=10000; j++)
                    dp2[j]=max(dp2[j],dp2[j-x]+y);//all
            }
        }
        if(flag)
        {
            puts("0");
            continue;
        }
        ll ans=1ll<<60,sum;
        for(int i=0; i<10001; i++)
        {
//            sum=lower_bound(dp2,dp2+10000,num[i])-dp2;
//            ll tmp=sum;
            if(dp2[i]<0)continue;
            sum=i;
//        printf("%d\n",tmp);
            for(int j=0; j<n; j++)
            {
                sum+=lower_bound(dp1,dp1+10000,num[j]-dp2[i])-dp1;
            }
            ans=min(ans,sum);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1220
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
int n,m;
vector<int> graph[100010];
int dp[100010];
bool color[100010];
int add[100010];

int rec(int v){
    if(dp[v]!=-1)return dp[v];

    int res=0;
    for(auto nv:graph[v]){
        chmax(res,rec(nv)+1);
        
    }
    return dp[v]=res;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ! llか? 统一类型 memset()! ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
	cin>>n>>m;;
    map<int,int>map1;
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        x--;y--;
        graph[x].pb(y);
        map1[y]++;
    }
    int ans=0;
    memset(dp,-1,sizeof(dp));
    for(int v=0;v<n;v++){
        chmax(ans,rec(v));
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

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


int main(){
    int n;
    long long int a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    b=abs(b-a);
    long long int l=-(n-1)*d;
    long long int ll=l;
    long long int r=-(n-1)*c;
    bool isok=false;
    while(r<=(n-1)*d){
        if(ll<=b && b<=r ){
            isok=true;
        }
        l+=d+c;
        if(r<l){
            ll=l;            
        }
        r+=d+c;
    }
    cout<<(isok?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int A, B, x;
	scanf("%d %d %d", &x, &A, &B);
	
	int keA = 0;
	int keB = 0;
	
	keA += x - A;
	keB += x - B;
	
	if(keA < 0){
		keA *=-1;
	} 
	if(keB < 0){
		keB*=-1;
	}
	
	if(keA > keB) {
		printf("B\n");
	} 
	if(keB > keA) {
		printf("A\n");
	}
	
	return 0;
}

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



vector<ll> dist;
vector<ll>g[200005];


void dfs(ll v,ll p, ll d){
  dist[v]=d;
  for(ll to:g[v]){
    if (to==p)continue;
    dfs(to,v,d+1);
  }
}

int main(){
  ll n,u,v;
  cin>>n>>u>>v;
  u--;v--;
  rep(i,n-1){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    g[a1].push_back(b1);
    g[b1].push_back(a1);
  }
  vector<ll> dist1,dist2;
  dist=vector<ll>(n);
  dfs(u,-1,0);
  dist1=dist;
  dist=vector<ll>(n);
  dfs(v,-1,0);
  dist2=dist;
  ll ml=0;
  rep(i,n){
    if (dist1[i]<dist2[i]){
      ml=max(ml,dist2[i]);
  //    cout<<dist1[i]<<" "<<dist2[i]<<endl;
  //    cout<<ml<<"i"<<i<<endl;
    }
  }
  cout<<ml-1;

}


Measured memory_bytes: 14448
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N; cin >> N;

    set<int> D;
    REP(i, N) 
    {
        int n;
        cin >> n;
        D.insert(n);
    }
    cout << D.size()<< endl;

    
  
    return 0;
}



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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    REP(i, m) cin >> c[i];
    sort(all(c));

    vector<vector<int>> dp(m+5, vector<int>(50005, INF));
    REP(i, m+5) dp[i][0] = 0;
    REP(i, m) {
        REP(j, n+1) {
            if(j - c[i] >= 0) {
                dp[i+1][j] = min({dp[i][j-c[i]] + 1, dp[i+1][j-c[i]] + 1, dp[i][j]});
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
//    REP(i, m) {
//        REP(j, n+1) {
//            cout << (dp[i+1][j] == INF ? -1 : dp[i+1][j]) << " \n"[j == n];
//        }
//    }
    cout << dp[m][n] << endl;

}


Measured memory_bytes: 7968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = M_PI;

int main() {
    double A, B, H, M; cin >> A >> B >> H >> M; 
    double theta = abs(PI * H / 6 + PI * M / 6 / 60 - PI * M / 30);
    double x = sqrt(A * A + B * B - 2 * A * B * cos(theta));
    printf("%.10lf\n", x);
    return 0;
}

Measured memory_bytes: 4228
#!/usr/bin/env python3
import sys
from itertools import chain
# import numpy as np
# from itertools import combinations as comb
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(X: int):
    m = 100
    for y in range(1, 3761):
        m += m // 100
        if m >= X:
            return y
    return 3761


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # X = map(int, input().split())
    # X = input().strip()
    X = int(next(tokens))  # type: int
    answer = solve(X)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  int n;
  cin>>n;
  int ans = (n + 1)/2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
# C - 高橋君とカード / Tak and Cards

#import numpy as np
import math

N, A = map(int, input().split())
x = list(map(int, input().split()))

# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数
def partial_sum(a,A):
    n = len(a)
    dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数
    dp[0][0] = 1
    
    for i in range(n):
        for j in range(A+1):
            if j >= a[i]:
                dp[i+1][j] = dp[i][j-a[i]] + dp[i][j]
            else:
                dp[i+1][j] = dp[i][j]
                
    return dp[n][A]

x_diff = [a - A for a in x] # ここから合計0になるように取る。負の数列についてpartial_sumが動かないことに注意
x_diff_negative = [-a for a in x_diff if a < 0]
x_diff_positive = [a for a in x_diff if a > 0]

ans = 0
for i in range(1, min(sum(x_diff_negative), sum(x_diff_positive)) + 1):
    ans += partial_sum(x_diff_negative,i) * partial_sum(x_diff_positive,i) 

# 0の選び方
n_pattern_0 = 0
n_0 = x_diff.count(0)
if n_0 > 0:
    for i in range(1, n_0+1):
        n_pattern_0 += math.factorial(n_0) // (math.factorial(n_0-i) * math.factorial(i))

# ここまで数えた全てのパターンそれぞれについて、x_diff中の0をいくつか含めた別パターンがある
# 0単体で選ぶ方法もある
ans += (ans+1) * n_pattern_0
    
print(ans)

Measured memory_bytes: 41196
<?php
$input = explode(" ", trim(fgets(STDIN)));
$W = (int)$input[0];
$H = (int)$input[1];
$x = (int)$input[2];
$y = (int)$input[3];
$r = (int)$input[4];

// はみ出しチェック
if (($x - $r) < 0) {
    echo "No".PHP_EOL;
} elseif (($x + $r) > $W) {
    echo "No".PHP_EOL;
} elseif (($y - $r) < 0) {
    echo "No".PHP_EOL;
} elseif (($y + $r) > $H) {
    echo "No".PHP_EOL;
} else {
    echo "Yes".PHP_EOL;
}
?>


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,n1,n2;
    cin>>n;
    n1=n%1000;
    n2=(n/10)*10;
    if(n1%111==0||n2%111==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596