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

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

typedef complex<double>P;

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

const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_BACK=2;
const int ONLINE_FRONT=-2;
const int ON_SEGMENT=0;

inline double dot(const P &a, const P &b){return (conj(a) * b).real();}
inline double cross(const P &a, const P &b){return (conj(a) * b).imag();}

double toRad(double a){return a/180.0*PI;}
double toDeg(double a){return a*180.0/PI;}
P rotate(P p,double d){
    return P(p.real()*cos(d)-p.imag()*sin(d),p.real()*sin(d)+p.imag()*cos(d));
}

P getP(){
    double x,y;
    scanf("%lf%lf",&x,&y);
    return P(x,y);
}

int ccw(P p0,P p1,P p2){
    P a=p1-p0;
    P b=p2-p0;
    if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(cross(a,b)<-EPS)return CLOCKWISE;
    if(dot(a,b)<-EPS)return ONLINE_BACK;
    if(norm(a)<norm(b))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool ok(P from,P to,double w,double a,double d){
    if(abs(to-from)>a)return false;

    d=toRad(d);
    w=toRad(w);

    double left=w+d/2;
    double right=w-d/2;
    P vh=to-from;
    P vl=a*P(cos(left),sin(left));
    P vr=a*P(cos(right),sin(right));

    return (cross(vr,vh)>-EPS)&&(cross(vh,vl)>-EPS);
}

int H,R;
vector<P>h;

int U,M,S;
double du,dm,ds;
vector<P>u,m,s;
void solve(){
    h.resize(H);
    rep(i,H)h[i]=getP();

    scanf("%d%d%d",&U,&M,&S);
    scanf("%lf%lf%lf",&du,&dm,&ds);

    u.resize(U);
    m.resize(M);
    s.resize(S);
    rep(i,U)u[i]=getP();
    rep(i,M)m[i]=getP();
    rep(i,S)s[i]=getP();

    int cnt[100]={0};

    while(R--){
        double w,a;
        scanf("%lf%lf",&w,&a);
        rep(i,H){
            bool f=false;
            if(ok(P(0,0),h[i],w,a,du))f=true;
            rep(j,U)if(ok(u[j],h[i],w,a,du))f=false;
            rep(j,M)if(ok(m[j],h[i],w,a,dm))f=false;
            rep(j,S)if(ok(s[j],h[i],w,a,ds))f=false;
            if(f)cnt[i]++;
        }
    }

    int ma=*max_element(cnt,cnt+H);
    if(ma==0){
        puts("NA");
        return;
    }

    bool f=false;
    rep(i,H){
        if(cnt[i]!=ma)continue;
        if(f)printf(" ");
        else f=true;
        printf("%d",i+1);
    }
    puts("");
}

int main(){
    while(scanf("%d%d",&H,&R),H||R)solve();
    return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>

int main() {
	long n,k;
	scanf("%ld%ld",&n,&k);
	if(n<=k){
	    if(k-n>n)
	        printf("%ld\n",n);
	    else
	        printf("%ld\n",k-n);
	}
	else{
	    n=n%k;
	    if(k-n>n)
	        printf("%ld\n",n);
	    else
	        printf("%ld\n",k-n);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
w = []

for i in range(n):
    w.append(input())

ans = True

for i in range(1, n):
    if w.count(w[i]) > 1 or w[i-1][-1] != w[i][0]:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  bool flag = false;
  REP(i, 2){
    if(S[i] != S[i+1]) flag = true;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 1e5+50;

int n, m;

char s[N];
int a[N], b[N];
bool vis[N];
void solve() {

    cin >> n >> m;
    // for (int i=0; i<n; ++i) {
    //     s[i] = i + 'A';
    // }
    // set<int> S;
    int lim = n-2;
    if (n % 2 == 0)
        lim -= 1;
    int l = 0, r = (n+1)/2, x = (n-1)/2;
    for (int i=0; i<m; ++i) {
        if (i % 2 == 0) {
            printf("%d %d\n", l+1, l+x+1);
            ++l;
            --x;
        } else {
            printf("%d %d\n", r+1, r+x+1);
            ++r;
            --x;
        }
    }
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 3752
#include<iostream>

using namespace std;

int main()
{
	int high[10];
	for(int ix = 0;ix != 10;++ix)
		cin >> high[ix];

	int index = 0;
	for(int jx = 0;jx != 3;++jx){
		for(int ix = 0;ix != 10;++ix)
			if(high[index] <= high[ix])
				index = ix;
		cout <<high[index]<<endl;
		high[index] = 0;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
  ll a, b, x;
  cin >> a >> b >> x;

	cout << (b / x) - (a / x) + ((a % x == 0) ? 1 : 0) << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

ll N;
vector<vector<ll>> G(111111);
vector<ll> color(111111, INF);
void dfs(ll V)
{
  for (auto v : G.at(V))
  {
    if (abs(color.at(v)) <= abs(color.at(V)) + 1)
      continue;

    color.at(v) = color.at(V) + ((color.at(V) > 0) ? 1 : -1);
    dfs(v);
  }
}

int main()
{
  cin >> N;
  for (ll i = 0; i < N - 1; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  color.at(0) = 1;
  dfs(0);
  color.at(N - 1) = -1;
  dfs(N - 1);

  ll B = 0, W = 0;
  for (ll i = 0; i < N; i++)
  {
    if (color.at(i) > 0)
      B++;
    else
      W++;
  }

  cout << ((B > W) ? "Fennec" : "Snuke") << endl;
  //cerr << B << " " << W << endl;
}

Measured memory_bytes: 11520
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let mut s: Vec<Vec<char>> = Vec::new();
    for _i in 0..3 {
        let t: String = sc.read();
        s.push(to_chars(t));
    }
    if s[0][s[0].len() - 1] == s[1][0] && s[1][s[1].len() - 1] == s[2][0] {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    bool a[26];
    while(cin>>s){
        memset(a,false,sizeof(a));
        for(int i=0;i<s.size();++i)
            a[s[i]-'a']=true;
        int i;
        for(i=0;i<26;++i){
            if(a[i]==false) {
                printf("%c\n",i+'a');
                break;
            }
        }
        if(i==26)puts("None");

    }
    return 0;
}


Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = [0] + LIST()

A = list(accumulate(A))
dic = Counter(A)

ans = 0
for x in dic.values():
	ans += x*(x-1)//2

print(ans)

Measured memory_bytes: 37764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   vector<int> a(n);
   int ans = 0;
   f(i,0,n){
      cin >> a[i];
      if(a[i] >= k) ans++;
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 1024
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n, e, t;
    cin >> n >> e >> t;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    
    x.push_back(e);
    vector<ll> dp(n + 1, INF);
    dp[n] = 0;
    vector<ll> mn(n + 1, INF);
    per(i, n) {
        int idx = upper_bound(all(x), x[i] + t / 2) - x.begin();
        if (idx == n + 1) {
            dp[i] = t + e - x[i];
        } else {
            chmin(dp[i], t + x[idx] - x[i] + dp[idx]);
            chmin(dp[i], mn[idx] - 3 * x[i]);
        }
        mn[i] = min(mn[i + 1], dp[i + 1] + 2 * x[i] + x[i + 1]);
    }
    
    cout << dp[0] + x[0] << "\n";
}


Measured memory_bytes: 5440
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n;
  double m;
  cin >> n;
  if(n % 2 == 0){
    m = n / 2;
  }
  else{
    m = n / 2 + 1;
  }
  double a = m / n;
  cout << setprecision(10) << a << "\n";
}

Measured memory_bytes: 3784
local S, T = io.read("l","l")
S={string.byte(S,1,#S)}
T={string.byte(T,1,#T)}
local origin = {}
local result = {}
for i=1,#S do
    if origin[T[i]] == nil then
        origin[T[i]] = S[i];
    end
    if result[S[i]] == nil then
        result[S[i]] = T[i];
    end
    if origin[T[i]] ~= S[i] or result[S[i]] ~= T[i] then
        print("No")
        return
    end
end
print("Yes")


Measured memory_bytes: 10044
n,m=gets.split.map(&:to_i)
l=[nil]
n.times do
  l << []
end
ab=[]
m.times do
  a,b=gets.split.map(&:to_i)
  l[a] << b
  l[b] << a
  ab << [a,b]
end
c=0
ab.each do |a,b|
  l[a].delete(b)
  l[b].delete(a)
  s=[a]
  v=[0]*(n+1)
  while s!=[]
    z=[]
    s.each do |ss|
      l[ss].each do |lss|
        if v[lss]==0
          v[lss]=1
          z << lss
        end
      end
    end
    s=z.dup
  end
  c+=1 if v[b]==0
  l[a] << b
  l[b] << a
end
puts c


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

using namespace std;

int n, A, B, C, D;

char ch[400010];

int main() {
	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	scanf("%s", ch + 1);
	if(C < D) {
		for(int i = B + 1; i < D; i++)
			if(ch[i - 1] == '#' && ch[i] == '#') {
				puts("No");
				return 0;
			}
		for(int i = A + 1; i < C; i++)
			if(ch[i - 1] == '#' && ch[i] == '#') {
				puts("No");
				return 0;
			}
		puts("Yes");
		return 0;
	} else {
		int flag = 0;
		for(int i = B; i <= D; i++)
			if(ch[i - 1] == '#' && ch[i] == '#') {
				puts("No");
				return 0;
			} else if(ch[i - 1] == '.' && ch[i] == '.' && ch[i + 1] == '.') flag = 1;
		if(!flag) {
			puts("No");
			return 0;
		}
		for(int i = A + 1; i < C; i++)
			if(ch[i - 1] == '#' && ch[i] == '#') {
				puts("No");
				return 0;
			}
		puts("Yes");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>


int main(void)
{
	int S;
    int h,m,s;
   scanf("%d", &S);
   
    h = S/3600;
    m = (S-h*3600)/60;
    s = S-h*3600-m*60;

    printf("%d:%d:%d\n" , h, m, s);
    
   return 0;

}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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; }

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


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

typedef long long ll;

int main() {
    ll n,k;
    cin>>n>>k;
    int arr[n];
    for(int i = 0; i<n; i++){
        cin>>arr[i];
    }
    int dp[n+1] = {0};
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i = 2; i<n; i++){
        int j = i-1;
        int min_cost = INT_MAX;
        while(j>=0 && j>=i-k){
            min_cost = min(min_cost, (abs(arr[i]-arr[j]) + dp[j]));
            j--;
        }
        dp[i] = min_cost;
        // cout<<dp[i]<<" ";
    }
    // cout<<endl;
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4376
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n, m;
ll dp[8000];

int main(){
  cin >> n >> m;
  dp[0] = 1;
  rep(i, 3) rrep(j, 1, m + 1) rep(k, 1, min<int>(j, n) + 1){
    dp[j] += dp[j - k];
  }
  cout << dp[m] << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,i;
    long long a[100000],sum=1;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << "0";
            return 0;
        }
    }
    for(i=0;i<n;i++){
        if(a[i]<=1000000000000000000/sum) sum*=a[i];
        else{
            cout << "-1";
            return 0;
        }
    }
    cout << sum;
}

Measured memory_bytes: 4380
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<mint> v(n+1, 0), left(n+2, 0), right(n+2, 0);
    rep(i,n+1){
        v[i] = i;
        left[i+1] = left[i] + v[i];
    }
    for(int i = n; i >= 0; --i){
        right[n-i+1] = right[n-i] + v[i];
    }
    mint ans = 0;
    for(int i = k; i <= n+1; i++){
        mint add = right[i] - left[i] + 1;
        ans += add;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 7876
def main():
    N = int( input())
    A = list( map( int, input().split()))
    ans = "APPROVED"
    for a in A:
        if a%2 == 0:
            if a%3 == 0 or a%5 == 0:
                continue
            else:
                ans = "DENIED"
                break
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
 
using namespace std;
 
int main(){
    int r,c,sum,total_sum = 0;
    scanf("%d %d",&r,&c);
    int table[r+1][c+1];
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            table[i][j] = 0;
        }
    }
 
    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            scanf("%d",&table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }
}


Measured memory_bytes: 2704
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=55,MOD=1000000007;

int N,A[MAXN*2];
int dp[MAXN][MAXN*2][MAXN*2];

int main()
{
    scanf("%d",&N);
    for(int i=1;i<=2*N-1;i++)
        scanf("%d",&A[i]);
    sort(A+1,A+2*N);

    dp[N][1][0]=1;
    for(int i=N-1;i>=1;i--)
    {
        int al=(A[i]!=A[i+1]),ar=(A[2*N-i]!=A[2*N-i-1]);
        for(int l=0;l<=2*N-1;l++)
            for(int r=0;l+r<=2*N-1;r++)
                if(dp[i+1][l][r])
                {
                    for(int k=1;k<=l+al;k++)
                        (dp[i][l+al-k+1][r+ar+(k!=1)]+=dp[i+1][l][r])%=MOD;
                    for(int k=1;k<=r+ar;k++)
                        (dp[i][l+al+1][r+ar-k]+=dp[i+1][l][r])%=MOD;
                }
    }

    int ans=0;
    for(int l=0;l<=2*N-1;l++)
        for(int r=0;l+r<=2*N-1;r++)
            (ans+=dp[1][l][r])%=MOD;
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 1408
from sys import setrecursionlimit


def encode(i, j):
    if i < j:
        i, j = j, i
    return i * (i - 1) // 2 + j + 1


def dfs(v):
    if visited[v] == 2:
        return dp[v]
    visited[v] = 1
    for nv in g[v]:
        if visited[nv] == 1:
            print(-1)
            exit()
        dp[v] = max(dp[v], dfs(nv) + 1)
    visited[v] = 2
    return dp[v]


setrecursionlimit(10 ** 6)
N = int(input())
GAMES_CNT = N * (N - 1) // 2
g = [[] for _ in range(GAMES_CNT + 1)]
for i in range(N):
    orig = 0
    for j in map(lambda x: int(x) - 1, input().split()):
        dest = encode(i, j)
        g[orig].append(dest)
        orig = dest
dp = [0] * (GAMES_CNT + 1)
visited = [0] * (GAMES_CNT + 1)
print(dfs(0))


Measured memory_bytes: 176488
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, k = MI()
    ans = 0
    ttl = n * (n + 1) / 2

    for i in range(k, n + 2):
        min_i = i * (i - 1) / 2
        max_i = ttl - (n - i) * (n - i + 1) / 2
        ans += (max_i - min_i + 1) % (10 ** 9 + 7)
        ans %= 10 ** 9 + 7

    print(int(ans))


main()


Measured memory_bytes: 66336
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n;
	string s;
	
	cin >> n;
	
	int ac = 0, wa = 0, tle = 0, re = 0;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC") {
			ac++;
		}
		if (s == "WA") {
			wa++;
		}
		if (s == "TLE") { 
			tle++;
		}
		if (s == "RE") {
			re++;
		}
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#define ll long long
#define MN 100000
#define mod 1000000007
using namespace std;
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,g[MN+5],f[MN+5],s[MN+5];
ll a[MN+5],A,B;
int main()
{
	n=read();A=read();B=read();if(A>B) swap(A,B);
	a[0]=-5e18;s[0]=f[0]=1;
	for(int i=1;i<=n;++i) a[i]=read();a[++n]=5e18;
	for(int i=1;i+2<=n;++i) if(a[i+2]-a[i]<A) return 0*puts("0");
	for(int i=2;i<=n;++i) g[i]=a[i-1]-a[i-2]<A?i-2:g[i-1]; 
	for(int i=1,j=0;i<=n;++i)
	{
		while(j+1<i&&a[i]-a[j+1]>=B) ++j;
		int k=g[i];
		f[i]=j<k?0:(s[j]-s[k-1]+mod)%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	printf("%d\n",f[n]);
	return 0;
}



Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define form for(int j=0;j<m;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast;
	//string al = "abcdefghijklmnopqrstuvwxyz";
	string s;
	cin >> s;
	vector<char> b1;
	vector<char> b2;
	vector<char> e1;
	vector<char> e2;
	int cnt = 1;
	int t;
	cin >> t;
	int z, z1;
	char c;
	while (t--)
	{
		cin >> z;
		if (z == 1) cnt++;
		else
		{
			cin >> z1 >> c;
			if (z1 == 1)
			{
				if (cnt % 2 == 0)
				{
					b2.pb(c);
					e1.pb(c);
				}
				else
				{
					b1.pb(c);
					e2.pb(c);
				}
			}
			else
			{
				if (cnt % 2 == 0)
				{
					e2.pb(c);
					b1.pb(c);
				}
				else
				{
					e1.pb(c);
					b2.pb(c);
				}
			}
		}
	}
	if (cnt % 2 == 0)
	{
		for (int i = b2.size() - 1; i >= 0;i--) cout << b2[i];
		reverse(all(s));
		cout << s;
		for (auto x : e2) cout << x;
	}
	else
	{
		for (int i = b1.size() - 1; i >= 0; i--) cout << b1[i];
		cout << s;
		for (auto x : e1) cout << x;
	}
	return 0;



}

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

int main(){
  string s; cin >> s;
  char c[110]; 
  for(int i=0;i<s.size();i++){
    c[i]=s.at(i);}
  cout << c[0] << flush;
  cout << s.size()-2 << flush;
  cout << c[s.size()-1] << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 int compare(int a,int b)
 {
   return a>b;    
 }

 int main()
 {
   int num;
   int arr[3];
   cin>>num;
   while(num--)
   {
     for(int i=0;i<3;i++) cin>>arr[i];
     sort(arr,arr+3);
     if(pow(arr[0],2)+pow(arr[1],2)==pow(arr[2],2)) cout<<"YES"<<endl;
     else cout<<"NO"<<endl;              
   }
   //while(1);      
   return 0;    
 }
 

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

int main(){
  long N, A, B;
  cin >> N >> A >> B;
  long blue;
  blue = N/(A+B) * A;
  if(N%(A+B) >= A){
    blue += A;
  }else if(N%(A+B) < A){
    blue += N%(A+B);
  }
  cout << blue << endl;
  return 0;
}

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

int main(){
  int a, f, min=1000000;
  long long n;
  cin >> n;
  
  for( a=1; a<=sqrt(n); a++ ){
    if( n%a==0 ){
      if( a > n/a ){
        f = floor(log10(a)+1);
      }else{
        f = floor(log10(n/a)+1);
      }
      if( f < min ){
        min = f;
      }
    }
  }
  cout << f << endl;
}

Measured memory_bytes: 512
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){
    SCIN(a);SCIN(b);
    a+=b;
    int ans=stoi(a);
    bool flag=false;
    REP(i,1000){
        if(i*i==ans)flag=true;
    }

    Yes(flag);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793

int main() {
	int n,m;
	cin >> n >> m;
	vector<string>a(n), b(m);
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++)cin >> b[i];
	for (int i = 0; i + m -1 < a[0].size(); i++) {
		for (int j = 0; j + m -1 < n; j++) {
			bool flag = true;
			for (int k = 0; k < b[0].size(); k++) {
				for (int l = 0; l < m; l++) {
					if (a[i + k][j + l] != b[k][l]) {
						flag = false;
						break;
					}
				}
			}
			if (flag) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int a[] = new int[n]; 
       for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
            System.out.println("DENIED");
            return;
        }
       }
       System.out.println("APPROVED");
    }
}

Measured memory_bytes: 24532
#include<bits/stdc++.h>
 
using namespace std;
int main(){
  int n;
  long long m = 1000000007;
  long long p = 1;
 
  cin >> n;
  for(int i=1;i<=n;i++){
    p = p * (i % m) % m;
  }
  cout << p <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int h, n;
int dp[1002][10002];
pair<int, int> p[1002];

int rek(int x, int y) {
	if (y <= 0) return 0;
	if (x >= n) return 1e9;

	int &ret = dp[x][y];
	if (ret != -1) return ret;
	ret = rek(x+1, y);
	ret = min(ret, rek(x, y-p[x].X)+p[x].Y);
	
	return ret;
}

int main () {

	cin >> h >> n;
	for (int i = 0; i < n; i++) cin >> p[i].X >> p[i].Y;
	memset(dp, -1, sizeof dp);
	cout << rek(0, h);

	return 0;
}

Measured memory_bytes: 39936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	int a, b, c; cin >> a >> b >> c;
	if(a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int,input().split()))
a_list.sort(reverse=True)
Alice = 0
Bob = 0

for i in range(0,len(a_list) + 1,2):
    if i < len(a_list):
        Alice = Alice + a_list[i]
    else:
        break

for j in range(1,len(a_list) + 1,2):
    if j < len(a_list):
        Bob = Bob + a_list[j]
    else:
        break

diff = Alice - Bob

print(diff)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long 
#define pb push_back
int main(){	
	fast;
		ll n; cin>>n;
		if(n%2==0) cout<<n/2;
		else cout<<(n/2)+1;
		}	
	
	
	
		
		
	
	
		
	
	 	
	 	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int   
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	     
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a;
    itn b=0;
    cin>>a;
    for(int i=0;i<(a.size()+1)/2;i++){
	if(a[i]!=a[a.size()-1-i]) b++;
    }
    cout<<b<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int i,j,k,n,t;
int a[5];
double memo[310][310][310];

double dp(int a,int b, int c){

    if(memo[a][b][c] != 0){
        return memo[a][b][c];
    }
    double res = (double)n/(double)(a+b+c);

    if(a+b+c==0){
        return 0;
    }
    if(a>0){
        res += dp(a-1,b,c)* (double)a/(a+b+c);
    }
    
    if(b>0){
        res += dp(a+1,b-1,c)* (double)b/(a+b+c);
    }
    
    if(c>0){
        res += dp(a,b+1,c-1)* (double)c/(a+b+c);
    }
    return memo[a][b][c] = res;
}

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

    cin >> n;
    for(i=0;i<n;i++) {
        cin >> t;
        a[t]++;
    }

    cout << setprecision(16) << dp(a[1],a[2],a[3]) << endl;
}

Measured memory_bytes: 225536
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>dp(N+1);
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        int min_ = dp[i - 1], pos = 1;
        int a = 1;
        while (1) {
            if (min_ > dp[i - a]) {
                min_ = dp[i - a];
                pos = a;
            }
            if (a * 6 <= i)a *= 6;
            else break;
        }
        a = 1;
        while (1) {
            if (min_ > dp[i - a]) {
                min_ = dp[i - a];
                pos = a;
            }
            if (a * 9 <= i)a *= 9;
            else break;
        }
        dp[i] = dp[i - pos] + 1;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main() {
    int a,b,c,k,j;
    scanf("%d %d %d",&a,&b,&c);
    k = a;
    a = b;
    b = k;
    j = c;
    c = a;
    a = j;
    printf("%d %d %d",a,b,c);
    return 0;
}

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

const long long MOD = 1e9+7;

char S[1000005];
long long fact[2000005];
long long inv[2000005];
long long invFact[2000005];
long long pow25[2000005];
long long pow26[2000005];

long long ncr(int n, int r){
    return (fact[n]*invFact[n-r]%MOD)*invFact[r]%MOD;
}

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

    scanf(" %s", S);
    int N = strlen(S);

    fact[0] = fact[1] = 1;
    inv[1] = 1;
    invFact[0] = invFact[1] = 1;
    for(int i = 2; i <= N+K; i++){
        inv[i] = (MOD-MOD/i)*inv[MOD%i] % MOD;
        fact[i] = fact[i-1]*i%MOD;
        invFact[i] = invFact[i-1]*inv[i]%MOD;
    }

    pow25[0] = pow26[0] = 1;
    for(int i = 1; i <= K; i ++){
        pow25[i] = pow25[i-1]*25%MOD;
        pow26[i] = pow26[i-1]*26%MOD;
    }

    long long ans = 0;
    for(int i = 0; i <= K; i ++){
        ans += (ncr(i+N-1, N-1)*pow25[i]%MOD) * pow26[K-i]%MOD;
    }

    ans %= MOD;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 67272
#include<cstdio>
int A[2000005];
int C[10005];
int B[2000005];
void CountingSort(int A[], int B[], int n)
{
    int k = 0;
    for(int i=0; i<n; i++)
    {
        if(k < A[i]) k = A[i];
        C[A[i]]++;
    }
    for(int i=1; i<=k; i++)
    {
        C[i] = C[i] + C[i-1];
    }
    for(int i =n-1; i>=0; i--)
    {
        B[C[A[i]]-1]= A[i];
        C[A[i]] --;
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &A[i]);
    CountingSort(A,B,n);
    //printf("%d",C[A[n-1]]);
    for(int i=0; i<n; i++)
    {
        if(i) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 18276
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string a, b;
  cin >> a >> b;
  string s = a+b;
  int n = stoi(s);
  double m = sqrt(n);
  if (floor(m) == ceil(m)) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1,N+1):
  w, v = map(int,input().split())
  for j in range(0,W+1):
    if (j-w) >=0:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)
    else:
      dp[i][j] = dp[i-1][j]
  #print(dp)
  
  
ans = dp[N][W]
print(ans)

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

long long MOD=1000000007;

long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	int N;
	cin >> N;
	long long ans=MODpow(10LL,N);
	ans-=MODpow(9LL,N)-MOD;
	ans%=MOD;
	ans-=MODpow(9LL,N)-MOD;
	ans%=MOD;
	ans+=MODpow(8LL,N);
	ans%=MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int n,m,ans;
string blue[101],red[101];
int found[101];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(register int i=1;i<=n;i++)cin>>blue[i];
	cin>>m;
	for(register int i=1;i<=m;i++)cin>>red[i];
	for(register int i=1;i<=n;i++){
		if(found[i])continue;
		register int earn=0;
		for(register int j=1;j<=n;j++){
			if(blue[i]==blue[j]){
				found[j]=1;
				earn++;
			}
		}
		for(register int j=1;j<=m;j++){
			if(blue[i]==red[j])earn--;
		}
		
		if(earn>ans)ans=earn;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int num;
int ans=0;
void rec(string s, int seven, int five, int three){
    if(seven+five+three>9)return;
    if(s.size()>0 && seven>0 && five>0 && three >0){
        if(stoi(s)<=num)ans++;
    }
    string list[3] ={"7","5","3"};
    rec(list[0]+s,seven+1,five,three);
    rec(list[1]+s,seven,five+1,three);
    rec(list[2]+s,seven,five,three+1);
    return;
}

void solve(long long N){
    num=N;
    rec("",0,0,0);
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int n, cnt;
bool chk[100005];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int T; scanf("%d",&T);
		if(chk[T]) cnt++;
		chk[T] = true;
	}
	printf("%d",n-cnt-(cnt%2));
}


Measured memory_bytes: 512
#include <stdio.h>
#include<stdlib.h>


int main(void){
    int N,A;
    scanf("%d %d",&N,&A);
    long long int kotaekazu[51][2501]={}; //ある枚数使って合計がある数である個数
    kotaekazu[0][0]=1;
    int kari;
    for(int i=0;i<N;i++){
        scanf("%d",&kari);
        for(int j=N-1;j>=0;j--){
            for(int k=49*N;k>=0;k--){
                kotaekazu[j+1][k+kari]+=kotaekazu[j][k];
            }
        }
    }
    long long int ans=0;
    for(int i=1;i<=N;i++)ans+=kotaekazu[i][A*i];
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1152
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.IntSet as IS


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

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    n <- readLn :: IO Int
    s <- sort <$> replicateM n getLine
    let g = group s
    let mx = maximum (map length $ g)
    let rr = filter ((==mx).length) g
    putStr $ unlines $ map head rr



Measured memory_bytes: 176124
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i=2; i*i<=n; i++) {
    while (n%i==0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n!=1) ret[n] = 1;
  return ret;
}


int main() {
  ll N, P, ans = 1;
  cin >> N >> P;
  map<ll, int> memo = prime_factor(P);
  for (auto p: memo) {
    auto key = p.first;
    auto value = p.second;
    value /= N;
    ans *= pow(key, value);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    if ((g * 10 + b) % 4 == 0) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b,c,n,cnt;
    scanf("%d %d %d",&a,&b,&c);
    cnt=0;
    for(n=a; n<=b; n++){
        if(c%n==0){
            cnt++;
           
       
        }
        
    }
     printf("%d\n",cnt);
     
    return 0;
}



Measured memory_bytes: 2104