akhauriyash/Code-Regression huggingface dataset:
// AtCoder Beginner Contest 121 - Problem B: Can You Solve This? (https://atcoder.jp/contests/abc121/tasks/abc121_b)
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int N, M, C;
    cin >> N >> M >> C;

    vector<int> bs(M);

    for (int i = 0; i < M; ++i)
        cin >> bs[i];

    int ans = 0;

    while (N--)
    {
        vector<int> as(M);

        for (int i = 0; i < M; ++i)
            cin >> as[i];

        int sum = C;

        for (int i = 0; i < M; ++i)
            sum += as[i]*bs[i];

        ans += sum > 0 ? 1 : 0;
    }
 
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;cin >> n >> q;
    vector<pair<int,pair<int,int>>> p;
    vector<int> s(n),t(n),x(n),d(q);
    REP(i,n){
        cin >> s[i] >> t[i] >> x[i];
        p.push_back({s[i]-x[i],{0,i}});
        p.push_back({t[i]-x[i],{1,i}});
    }
    REP(i,q){
        cin >> d[i];
        p.push_back({d[i],{2,i}});
    }
    sort(ALL(p));
    vector<int> ans(q);
    multiset<int> st;
    for(auto t:p){
        int u=t.first,v=t.second.first,w=t.second.second;
        if(v==0){
            st.insert(x[w]);
        }
        if(v==1){
            st.erase(st.find(x[w]));
        }
        if(v==2){
            if(!st.size()){
                ans[w]=-1;
            }
            else{
                auto itr=st.begin();
                ans[w]=*itr;
            }
        }
    }
    REP(i,q){
        cout << ans[i] << endl;
    }
}

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

int main(){
	int N, K;
	cin >> N >> K;
	int p = N*(N+1)/2;
	long long a[N], b[p];
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	int noa = 0;
	for(int i=0; i<N; i++){
		long long sum = 0;
		for(int j=i; j<N; j++){
			sum += a[j];
			b[noa] = sum;
			noa++;
		}
	}
	long long ans = 0;
	for(int i=40; i>=0; i--){
		int count = 0;
		for(int j=0; j<p; j++){
			if(b[j] & (1ll<<i)){
				count++;
			}
		}
		if(count >= K){
			ans |= (1ll<<i);
			for(int j=0; j<p; j++){
				if(!(b[j] & (1ll<<i))){
					b[j] = 0;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	x := nextInt()
	for i := x - n + 1; i < x+n; i++ {
		fmt.Print(i)
		if i < x+n-1 {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
import heapq 
n = int(input())
li = []
heapq.heapify(li)
for i in range(n):
    a,b = map(int,input().split())
    heapq.heappush(li,(b,a))
t = 0
while li:
    b,a = heapq.heappop(li)
    t+=a
    if t>b:
        print('No');exit()
print('Yes')


Measured memory_bytes: 28768
import java.util.Scanner; 

class Main{

 public static void main(String[] args){

 Scanner scan = new Scanner(System.in);
   int FLG = 0;
   for (int N = scan.nextInt(); N > 0; N = N/10){
   if (N%10 == 7){
    FLG = 1;
     break;
   }
    }
  if (FLG == 0){  
  System.out.println("No");
  }
  
   else{
  System.out.println("Yes");
   }
 }
}

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

int main() {
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    h = min(h, 2*q);//500ml
    s = min(s, 2*h);//1l
    d = min(d, 2*s);//2l
    ll ans = (ll)(n/2)*d + (n%2)*s;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>

#define m 1046527

void insert(char []);
int getkey(char []);
int getChar(char);
int find(char []);
int h1(int key){return key%m;}
int h2(int key){return 1+(key%(m-1));}

char H[m][14];

int main(){
    int n,i;
    char com[7],str[14];

    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s%s",com,str);
        
        if(com[0]=='i')insert(str);
        else if(com[0]=='f'){            
            if(find(str))printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


void insert(char str[]){
    int key,p,i;

    key=getkey(str);

    for(i=0;;i++){
        p=(h1(key)+i*h2(key))%m;
    
        if(strcmp(H[p],str)==0)return;
        else if(strlen(H[p])==0){
        strcpy(H[p],str);
        return;
        }   
    }
}


int find(char str[]){
    int key,p,i;

    key=getkey(str);

    for(i=0;;i++){
        p=(h1(key)+i*h2(key))%m;
    
        if(strcmp(H[p],str)==0)return 1;
        else if(strlen(H[p])==0)return 0;
    }
}


int getkey(char str[]){
    int p=1,i,key=0;

    for(i=0;str[i]!='\0';i++){
        key+=getChar(str[i])*p;
        p*=5;
    }
    return key;
}


int getChar(char c){
    
    if(c=='A')return 1;
    else if (c=='C')return 2;
    else if (c=='G')return 3;
    else if (c=='T')return 4;
    else return 0;
}


Measured memory_bytes: 16876
solver::Int -> Int -> Int -> String
solver a b c = if b <= c then "YES" else if or (map (\ x ->(mod (x*a) b) == c) [1..b]) then "YES" else "NO"

main::IO()
main=do
  dat<-getLine
  let a:b:c:[] = map read (words dat)::[Int]
  putStr (solver a b c)
  putStr "\n"


Measured memory_bytes: 508
#include <stdio.h>

int main(int argc, const char * argv[]) {

    int d;
    int r;
    double f;
    int a;
    int b;
    
    scanf("%d %d", &a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %lf\n",d,r,f);
    
    return 0;
}

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

using namespace std;

#define ll long long

const int N=1e6+5,MOD=1e9+7;

int n,freq[N],a[N],k,tc,x,m,l,r,sum,u,v;

ll ans;

char s[N];

int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        ll curr=0;
        ll l=0,r=0;
        for(int j=0;j<n;j++){
            if (a[i]>a[j]){
                if (j>i)
                    r++;
                else
                    l++;
            }
        }
        ll p=((ll)k*(k+1))/2 % MOD;
        r=(r * p) % MOD;
        p=((ll)k*(k-1)/2)%MOD;
        l=(l * p)%MOD;
        ans=(ans+l+r)%MOD;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repd(a,b,c) for(int a=c;a>=b;a--)
/*******************************/
#define pi pair<int,int> 
#define vi vector<int>
#define vb vector<bool>
#define vp vector<pi>
#define vvi vector<vi>
#define vvp vector<vp>
/****************************/
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
//#define mp make_pair
#define pbb pop_back
/****************************************/
const int N = 5e5+100;
const int mod=1e9+7;
const int inf=1e18;
/****************************************/
vvp g;
vb vis;
vi dis,p,pp;
map<pair<pi,int>,int> mp;
int power(int a,int b)
{
  int ans=1;
  while(b)
  {
    if(b&1)ans*=a;
    a*=a;
    b/=2;
  }
  return ans;
}
// void dijkstra(int s,int n)
// {
//   dis.assign(n+1,inf);
//   p.assign(n+1,-1);
//   dis[s]=0;
//  // vis[s]=true;
//   priority_queue<pi,vp,greater<pi>> pq;
//   pq.push({dis[s],s});
//   while(!pq.empty())
//   {
//     int u = pq.top().S;
//     pq.pop();
//     if(vis[u])continue;
//     vis[u]=true;
//     int par=dis[u];
//     for(auto it:g[u])
//     {
//       int to = it.F;
//       int len = it.S;
//       if((mp[{{p[u],u},to}]))continue;
//       if(par+len<dis[to])
//       {
//         dis[to]=par+len;
//         p[to]=u;
//         pq.push({dis[to],to});
//       }
//     }
//   }

// }
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--)
    {
          int n;
          cin>>n;
          int sum=0;
          rep(i,1,n+1)
          {
            if(i%3==0||i%5==0||i%15==0)continue;
            else sum+=i;
          }
          cout<<sum<<"\n";




    }
  
    
    
               

                

     

        
        
      
      
      
    
    

    
    
}

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

int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> v(N);

    for (int i = 0; i < N; i++)
    {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    if (x < v.at(0))
    {
        cout << 0;
    }
    else
    {
        for (int i = 0; i < N && x >= v.at(i); i++)
        {
            cnt++;
            x -= v.at(i);
        }

        if (cnt == N && x > 0)
            cnt--;

        cout << cnt;
    }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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;
  }

  // for prime mod
  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;
  }
};

const int MAX = 1000005;

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

int lcm (int a, int b) {
  return a * b / gcd(a, b);
}

//エラトステネスのふるい
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1): n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (int i = 2; i <= n; i++) {
      if (f[i]) continue; //印がなければ素数扱い
      primes.push_back(i);
      for (int j = i; j <= n; j += i) {
        f[j] = i; //iの倍数のところに印をつけていく
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  //ｘを素因数分解する関数
  // return -> 素因数
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res; //大きい順で素因数がvectorに格納されて出てくる
  }

  //各素因数が何乗されているかをpair typeで返す
  vector<P> factorPower(int x) {
    vector<int> factors = factorList(x);
    if (factors.size() == 0) return {};
    vector<P> res(1, P(factors[0], 0));
    for (int p : factors) {
      if (res.back().first == p) {
        res.back().second ++;
      }
      else {
        res.emplace_back(p, 1);
      }
    }
      return res;
    }
  };

  int main() {
    Sieve sieve(1e6);
    int n;
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; i++) cin >> a[i];

    map<int, int> mp;
    for (int i = 0; i < n; i++){
      auto f = sieve.factorPower(a[i]);
      for (auto p : f) {
        mp[p.first] = max(mp[p.first], p.second);
        //各数の素因数の累乗のうち、最大乗されているものをすべてかければ最大公倍数になる
        //よって各素数の最大累乗だけmapに格納する
      }
    }

    mint lcm = 1;
    for (auto p: mp) {
      rep(i, p.second) { lcm *= p.first; } //最大公約数がでる
    }

    mint ans;
    rep(i, n) {
      mint b = lcm / a[i];
      ans += b;
    }

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


Measured memory_bytes: 4984
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

pair<int,int> gcd(int a,int b,int cnt){
	if(b==0)
		return make_pair(a,cnt);
	else
		return gcd(b,a%b,cnt+1);
}

int main(){

	int x,y;
	while(cin>>x>>y&&!(x==0&&y==0)){
		if(y>x){
			swap(x,y);
		}
		pair<int,int> p=gcd(x,y,0);
		cout<<p.first<<" "<<p.second<<endl;
	}

	return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, t, a[200002], result;
  cin >> n >> t;
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n - 1) {
    result += min(t, a[i + 1] - a[i]);
  }
  result += t;
  cout << result << endl;
}

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

#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

ll x[maxn];

int main() {
    ll n, res = INF, g = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> x[i];
    for (int i = 1; i <= 100; i++) {
        g = 0;
        for (int j = 1; j <= n; j++) g += (x[j] - i) * (x[j] - i);
        res = min(res, g);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 200100;
vector<int>g[maxn];
ll n, mod, dp[maxn];

void firstdfs(int node, int p) {
    dp[node] = 1LL;
    for(int i:g[node]) {
        if(i != p) {
            firstdfs(i, node);
            dp[node] *= (dp[i] + 1) % mod;
            dp[node] %= mod;
        }
    }
}

void seconddfs(int node, int p, ll carry = 1LL) {
    vector<ll>pref(g[node].size()+3), suff(g[node].size()+3);
    vector<ll>dps;
    vector<int>v;
    for(int i:g[node]) {
        if(i != p) {
            dps.pb(dp[i]);
            v.pb(i);
        }
    }

    dp[node] *= (carry) %mod;
    dp[node] %= mod;


    if(v.size() == 0) return;

    pref[0] = 1LL;
    for(int i=0;i<dps.size();i++) {
        if(i > 0) pref[i] = pref[i-1];
        pref[i] *= (dps[i] + 1)%mod;
        pref[i] %= mod;
    }
    suff[dps.size()-1] = 1LL;
    suff[dps.size()] = 1LL;
    for(int i=dps.size()-1;i>=0;i--) {
        if(i < dps.size()-1) suff[i] = suff[i+1];
        suff[i] *= (dps[i] + 1)%mod;
        suff[i] %= mod;
    }

    if(node == 1) carry = 1LL;

    for(int i=0;i<dps.size();i++) {
        ll ncarry = carry;
        if(i == 0) {
            ncarry *= suff[i+1];
            ncarry %= mod;
        }
        else {
            ncarry *= pref[i-1];
            ncarry %= mod;
            ncarry *= suff[i+1];
            ncarry %= mod;
        }
        seconddfs(v[i], node, ncarry+1);
    }
}

int main() {
    cin>>n>>mod;
    int u, v;
    for(int i=0;i<n-1;i++) {
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    firstdfs(1, -1);

    seconddfs(1, -1);

    for(int i=1;i<=n;i++) {
        cout<<dp[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 32640
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int h, w;
  cin >> h >> w;
  svec a(h);
  REP(i, h) cin >> a[i];

  svec ans;
  REP(i, a.size()) {
    bool isBlank = true;
    REP(j, a[i].size()) {
      if (a[i][j] == '#') {
        isBlank = false;
      }
    }
    if (isBlank) {
      a.erase(a.begin() + i);
      i--;
    }
  }
  REP(i, a[0].size()) {
    bool isBlank = true;
    REP(j, a.size()) {
      if (a[j][i] == '#') {
        isBlank = false;
      }
    }
    if (isBlank) {
      REP(j, a.size()) { a[j].erase(a[j].begin() + i); }
      i--;
    }
  }
  REP(i, a.size()) print(a[i]);
  return 0;
}

Measured memory_bytes: 256
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

int inputs[10][10];

int main() {


	int N;
	cin >> N;


	for (int i = 1; i <= N; i++) {
		string S = to_string(i);
		int first = S[0] - '0';
		int last =  S[S.size() - 1] - '0';
		inputs[first][last]++;
	}

	int count = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			count += inputs[i][j] * inputs[j][i];
		}
	}

	cout << count << endl;

/*
	N以下の整数の組(A,B)であって
	Aの末尾の桁=Bの先頭の桁
	Bの末尾の桁=Aの先頭の桁
を満たす(A,B)の組の数

N：2×10^5


A=iとしたときに、条件を満たすBがいくつあるか？
を数え上げてゆく

dp[i]:A=i未満で、条件を満たすBがいくつあるか？

Aが与えられたとき、Bの先頭と末尾の数字は１意に決まる
N未満の数字でその間に、自由な桁が何桁あるか？がポイントとなる

上記条件を満たす、最大のBを求めると良い

 if		i_endとNの先頭の桁が同じ数字の時　maxB=Nの一番下の桁をi_firstにした数字
 else	i_endとi_firstの間を9で埋めたNよりも１桁低い数字

 
 */


	return 0;
}



Measured memory_bytes: 384
# -*- coding: utf-8 -*-

K = int(input())
S = len(input())

mod = 10**9+7
N = K+S

# mod上の逆元の計算
inverse = [0, 1]
for i in range(2, N+1):
    inverse.append((-inverse[mod%i]*(mod//i))%mod)

# 階乗とその逆元の計算
factorial = [1, 1]
factorial_inv = [1, 1]
for i in range(2, N+1):
    factorial.append((factorial[-1]*i)%mod)
    factorial_inv.append((factorial_inv[-1]*inverse[i])%mod)

answer = 0
pow = -1
for i in range(K+1):
    if pow == -1:
        pow = 1
    else:
        pow = (pow*25)%mod
    answer = (answer+pow*factorial[N]*factorial_inv[i]*factorial_inv[N-i])%mod
print(answer)

Measured memory_bytes: 193812
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
vector<int> ans;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if (a+b-1>n)
    {
        puts("-1");
        return 0;
    }
    int cnt=0;
    n-=a;
    int i;
    for (i=0;i<a;i++)
    {
        int j;
        if (cnt+b-1<=n)
        {
            for (j=0;j<b;j++)
            {
                ans.push_back(cnt+b-j+i);
            }
            cnt+=b-1;
        }
        else
        {
            for (j=0;j<=n-cnt;j++)
            {
                ans.push_back(n-j+i+1);
            }
            cnt=n;
        }
    }
    if ((int)ans.size()<n+a)
    {
        puts("-1");
        return 0;
    }
    for (i=0;i<n+a;i++)
    {
        printf("%d ",ans[i]);
    }
    return 0;
} 


Measured memory_bytes: 3440
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		long x = Long.parseLong(st.nextToken());
 		long k = Long.parseLong(st.nextToken());
 		long d = Long.parseLong(st.nextToken());
 		
	 	if (sign(x) == -1 && k <= (0-x)/d)
	 		out.println(Math.abs(x+k*d));
	 	else if (sign(x) == 1 && k <= x/d)
	 		out.println(Math.abs(x-k*d));
	 	else{
	 		if (k%2 == 0)
	 			out.println(Math.min(Math.abs((x%(2*d)+2*d)%(2*d)), Math.abs((x%(2*d)+(2*d))%(2*d)-2*d)));
	 		else{
	 			out.println(Math.abs((x%(2*d)+(2*d))%(2*d)-d));
	 		}
	 	}

 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
	public static int sign(long j){
		if (j < 0)
			return -1;
		else if (j > 0)
			return 1;
		else
			return 0;
	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25372
import collections

N = int(input())
W = []
for i in range(N):
    W.append(input())

#if W.most_common()[0][1] == 1:
def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
c=0

if is_unique2(W)==True:
    for i in range(N-1):
        a = W[i]
        b = W[i+1]
#        print(a[len(a)-1])
#        print(b[0])
        if a[len(a)-1] == b[0]:
            c+=1
    if c == N-1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
if(a<1200){System.out.println("ABC");}else if(a<2800){System.out.println("ARC");}else{System.out.println("AGC");}

	}}

Measured memory_bytes: 23380
n, k = map(int, input().split())
c = list(map(int, input().split()))
ans = float('Inf')
for i in range(n-k+1):
  l, r = c[i], c[i+k-1]
  ans = min(abs(l) + abs(r-l), abs(r) + abs(r-l), ans)

print(ans)

Measured memory_bytes: 14392
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}


int main(){
    int a=in(),b=in();
    cout<<max(2*a-1,max(2*b-1,a+b))<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],ev[M],od[M];

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

	ll f=0,s=0,ans=0,i,j,k,n,mn;

	cin >> n;
	for(i=1;i<=n;++i)
		cin >> ar[i];

	if(n%2 == 0)
	{
		for(i=1;i<=n;i+=2)
			f += ar[i];
		ans = f;
		for(i=n-1;i>=1;i-=2)
		{
			f = f-ar[i]+ar[i+1];
			ans = max(f,ans);
		}
		cout << ans << "\n";
		return 0;
	}
	else if(n == 3)
	{
		cout << max({ar[1],ar[2],ar[3]}) << "\n";
		return 0;
	}

	for(i=1;i<=n-2;i+=2)
		f += ar[i];
	s = ans = f;
	// cout << ans << "\n";
	for(i=n-2;i>=1;i-=2)
	{
		f = f-ar[i]+ar[i+1];
		ans = max(f,ans);
	}
	// cout << ans << "\n";	
	f = s;
	for(i=n-2;i>=1;i-=2)
	{
		f = f-ar[i]+ar[i+2];
		ans = max(f,ans);
	}
	// cout << ans << "\n";
	f = s+ar[n];	

	od[1] = ar[1];
	for(i=2;i<=n;++i)
	{
		if(i%2)
		{
			od[i] = od[i-2]+ar[i];
			ev[i] = ev[i-1];
		}
		else
		{
			ev[i] = ev[i-2]+ar[i];
			od[i] = od[i-1];
		}
	}

	mn = 1e18;
	for(i=2;i<=n;i+=2)
	{
		mn = min(mn,ev[i-1]-od[i-2]);
		ans = max(ans,f+ev[i]-od[i+1]-mn);
	}

	cout << ans << "\n";
	return 0;
}




	

Measured memory_bytes: 8264
//abc164_a.cpp
//Sun Apr 26 20:56:40 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	int s,w;
	cin >> s >> w;

	if (w>=s){
		cout << "unsafe" << endl;
	}else {
		cout << "safe" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dp[111][111];
int mat[111][2];

int solve(int l, int r){
    if(l + 1 >= r) return 0;
    if(dp[l][r]) return dp[l][r];

    int mi = INF;
    for(int i=l+1;i<r;++i){
        chmin(mi, solve(l, i) + solve(i, r) + mat[l][0] * mat[i][0] * mat[r-1][1]);
    }
    return dp[l][r] = mi;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    REP(i,n) cin >> mat[i][0] >> mat[i][1];
    cout << solve(0,n) << endl;
}


Measured memory_bytes: 3212
from statistics import mean
def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = mean(a)
    x = 10**6
    ans = -1
    for i in reversed(range(n)):
        if abs(a[i] - m) <= x:
            ans = i
            x = abs(a[i] - m)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5660
//MinMax+DP
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 410
#define mod 998244353
int dp[N][N],v[N],r[N],n,c[N][N],su,p[N];
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&v[i],&r[i]),su+=v[i];
	dp[0][0]=1;
	for(int i=0;i<=400;i++)c[i][0]=c[i][i]=1;
	for(int i=1;i<=400;i++)
	for(int j=1;j<i;j++)
	c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	for(int i=1;i<=n;i++)
	{
		p[0]=1;
		for(int j=1;j<=r[i];j++)p[j]=1ll*p[j-1]*v[i]%mod;
		for(int j=400-v[i];j>=0;j--)
		for(int k=400-r[i];k>=0;k--)
		if(dp[j][k])
		for(int l=0;l<r[i];l++)
		dp[j+v[i]][k+l]=(dp[j+v[i]][k+l]+1ll*dp[j][k]*c[k+l][l]%mod*p[l]%mod*(mod-1))%mod;
	}
	int as=0;
	for(int i=1;i<=400;i++)
	for(int j=0;j<=400;j++)
	as=(as+1ll*dp[i][j]*pw(pw(i,mod-2),j+1)%mod*su)%mod;
	printf("%d\n",mod-as);
}

Measured memory_bytes: 1408
w, h, n = map(int, input().split())
origin = [0, 0]
wh = [w, h]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        origin[0] = max(x, origin[0])
    if a == 2:
        wh[0] = min(x, wh[0])
    if a == 3:
        origin[1] = max(y, origin[1])
    if a == 4:
        wh[1] = min(y, wh[1])
print(max(0, wh[0]-origin[0])*max(0, wh[1]-origin[1]))


Measured memory_bytes: 3064
#include <stdio.h>

int max(int a, int b){ return a > b ? a : b; }
int min(int a, int b){ return a < b ? a : b; }
int main(){
	int N, M, X, Y;
	int x, ma = -100;
	int y, mi = 100;
	int i;

	scanf("%d %d %d %d", &N, &M, &X, &Y);
	for(i = 0; i < N; i++){
		scanf("%d", &x);
		ma = max(ma, x);
	}

	for(i = 0; i < M; i++){
		scanf("%d", &y);
		mi = min(mi, y);
	}

	for(i = ma + 1; i <= mi; i++){
		if(i > X && i <= Y){
			printf("No War\n");
			return 0;
		}
	}
	printf("War\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){

  long long a,b;
  scanf("%lld %lld",&a,&b);
  if(b==1) printf("%lld\n",a*(a-1)/2);
  else printf("%lld\n",(a-b+3)*(a-b)/2+b-2);
  return 0;

}

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> W;
  Vec(P,pint,N,pint(0,0));
  rep(i,0,N)cin >> P[i].first >> P[i].second;
  DV(dp,lli,N+1,W+1,0);//DP[i番目まで見た][sum of weight]
  rep(i,1,N+1)rep(j,0,W+1){
    if(j+P[i-1].first<=W)dp[i][j+P[i-1].first]=max(dp[i-1][j+P[i-1].first],dp[i-1][j]+P[i-1].second);
    dp[i][j]=max(dp[i][j],dp[i-1][j]);
  }
  rep(i,0,W+1)chmax(sum,dp[N][i]);
  Out(sum);
}

Measured memory_bytes: 80256
#include <iostream>
using namespace std;
int main(void)
{
    int a, b, c, k;
    int ans = 0;
    cin >> a >> b >> c >> k;
    if(k > a)
    {
        k -= a;
        ans += a;
        if (k > b)
        {
            k -= b;
            ans -= k;
        }
    }
    else ans = k;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;

  int a = A + B;
  int b = A - B;
  if (a > b) {
    int c = A * B;
    cout << max(a, c);
  } else {
    int c = A * B;
    cout << max(b, c);
  }

  return 0;
}


Measured memory_bytes: 256
I=->{gets.split.map &:to_i}
N,Q=I[]
A=[1,c=1,1,*[0]*(N-2),1]
Q.times{
	a,b=I[]
	A[a],A[b]=A[b],A[a]
	c=c==a ?b :c==b ?a :c
	A[c-1]=A[c+1]=1
}
p A.reduce(:+)-2

Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int N;
    cin >> N;
    map<pii,int> M;
    
    rep(i,N+1){
        int a,b;
        a = i%10;
        if(a == 0) continue;
        
        b = i;
        while (b/10 > 0) b /= 10;
        
        M[{b,a}]++;
    }
    
    ll ans = 0;
    for (auto p : M) {
        ans += (ll)p.se*(ll)M[{p.fi.se,p.fi.fi}];
    }
    
    cout << ans << endl;
    
    

    return 0;
}


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

string s;
int ans;

int main(){
  cin >> s;
  char icolor = s.at(0);
  for(int i = 0; i < s.size()-1; i++){
    if(icolor == s.at(i+1)){
      ans++;
      if(icolor == '0') s.at(i+1) = '1';
      else s.at(i+1) = '0';
    }
    icolor = s.at(i+1);
  }
  cout << ans << endl;
}

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

int main()
{
  	string o, e;
  	cin>>o>>e;
  	for(int i = 0; i < max(o.length(), e.length()); i++)
    {
    	if(i >= e.length() && i < o.length())
          	cout<<o[i];
      	else if(i >= o.length() && i < e.length())
          	cout<<e[i];
      	else
        	cout<<o[i]<<e[i];  
    } 	
  	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int n,a,b,ans=0;
cin >> n >> a >> b;
for(int i=0;i<n;i++){
   int aa,bb;
   cin >> aa >> bb;
   if(aa>=a&&bb>=b)ans++;
}
cout << ans << endl;
 }


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
expects = nums.map { |n| (1 + n) / 2.0 }
first_expected = expects[0...k].inject(:+)
array = [first_expected]
(0...n - k).each do |i|
  first_expected -= expects[i]
  first_expected += expects[i + k]
  array << first_expected
end
puts array.max


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

int main() {
    int n, mx=0;
    int arr[110000];
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> arr[i];
        mx = max(arr[i], mx);
    }
    int med = mx * 10;
    int half_mx = mx / 2;
    for(int i=0; i<n; i++){
        if(arr[i] != mx && abs(arr[i]-half_mx) < abs(med-half_mx)) {
            med = arr[i];
        }
    }
    cout << mx << " " << med << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
  
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, i;
        long min, max;
        long sum = 0;
        n = sc.nextInt();
        long[] a = new long[n];

        for(i = 0; i < a.length; i++){
            a[i] = sc.nextLong();
            sum += a[i];
        }

        min = a[0];
        max = a[0];

        for(i = 0; i < a.length; i++){
            min = Math.min(min, a[i]);
            max = Math.max(max, a[i]);
        }
        System.out.println(min + " " + max + " " + sum);
        sc.close();
    }
}




Measured memory_bytes: 41648
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
    n: usize,
    s: [String; n]
    }
    let k = vec!["AC","WA","TLE","RE"];
    let mut count = HashMap::new();
    for &j in &k {
        count.entry(j).and_modify(|e| *e += 1).or_insert(0);
    }
    for i in 0..n {
        count.entry(&s[i]).and_modify(|e| *e += 1).or_insert(0);
    }
    for &i in &k {
        println!("{} x {}", i, count[i]);
    }
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 200004;
const int MOD =998244353
 ;
const int INV2 = (MOD+1)/2;
int k,x,y;


     signed main(){
          int h,w;
          cin>>h>>w;
          string a[h],b[h],c[h];
          for(int i=0;i<h;i++)cin>>a[i];
          for(int i=0;i<h;i++){
               if(i%2){
                    for(int j=0;j<w-1;j++)b[i].push_back('#');
                    b[i].push_back('.');
               }else{
                    b[i].push_back('#');
                     for(int j=0;j<w-1;j++)b[i].push_back('.');
               }
          }
          for(int i=0;i<h;i++){
               if(i%2){
                    for(int j=0;j<w-1;j++)c[i].push_back('.');
                    c[i].push_back('#');
               }else{
                    c[i].push_back('.');
                     for(int j=0;j<w-1;j++)c[i].push_back('#');
               }
          }
          for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(b[i][j]=='.'&&a[i][j]=='#')b[i][j]='#';
           for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(c[i][j]=='.'&&a[i][j]=='#')c[i][j]='#';
           for(int i=0;i<h;i++)cout<<b[i]<<endl;
           cout<<endl;
           for(int i=0;i<h;i++)cout<<c[i]<<endl;




}


        


Measured memory_bytes: 1536
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

# m = a[i]の最小公倍数-1
lcm = 1
for i in range(n):
    lcm *= a[i] // gcd(lcm, a[i])

m = lcm - 1
ans = 0
for i in range(n):
    ans += m % a[i]

print(ans)

Measured memory_bytes: 5344
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

int main(void) {

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

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split();
            var X = int.Parse(strs[0]);
            var Y = int.Parse(strs[1]);

            Console.WriteLine(X + Y / 2);
        }
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

int N,M,V,P;
int A[111111];

bool check(int x){
    if(N-x<=P)return true;
    int num=0;
    int ri=(N-(x+1+P-1));
    int vo=max(0ll,V-(x+1+P-1));
    int sum=0;
    for(int i=x+1;i<=x+ri;i++){
        if(A[x]+M<A[i])return false;
        sum+=min(M,A[x]+M-A[i]);
    }
    if(sum>=vo*M)return true;
    return false;
}

signed main(){
    cin>>N>>M>>V>>P;
    rep(i,N)cin>>A[i];
    sort(A,A+N);

    int lb=-1,ub=N-1;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))ub=mid;
        else lb=mid;
    }

    cout<<N-ub<<endl;
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> P(N);
    for(int i=0;i<N;i++){
      cin >> P[i].first >> P[i].second;
    }
  sort(P.begin(),P.end());
  int64_t cost=0;
  int count = 0;
    for(int j=0;j<N;j++){
      for(int k=0;k<P[j].second;k++){
        count++;
        if(count <M+1){
        cost+=P[j].first;
        }else{
          break;
        }
      }
    }
  
  cout << cost << endl;


}

Measured memory_bytes: 1024
# n個の要素を0~N-1で管理
class UnionFind():
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属するかどうかを返す
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を返す
    def group_count(self):
        return len(self.roots())

    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    # ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す (print()での表示用)
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():
    N = int(input())
    X = []
    Y = []
    # 町のナンバーも付ける
    for i in range(N):
        x, y = map(int, input().split())
        X.append((i, x))
        Y.append((i, y))

    # 短い距離にある街をつなげば良いのでソートする
    X.sort(key=lambda x: x[1])
    Y.sort(key=lambda x: x[1])

    # コストを計算しグラフを作成
    G = []
    for i in range(1, N):
        a, x1 = X[i - 1]
        b, x2 = X[i]
        G.append((a,b,x2-x1))
        a, y1 = Y[i - 1]
        b, y2 = Y[i]
        G.append((a, b, y2 - y1))

    # クラシカル法で最小全域木
    ans = 0
    uf = UnionFind(N)
    G.sort(key=lambda x: x[2])
    for a, b, w in G:
        if not uf.is_same(a, b):
            uf.union(a, b)
            ans += w
    print(ans)

if __name__ == "__main__":
    resolve()

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int acc[300010];
  int n,ans;
  
  cin >> n;
  acc[0] = 0;
  for (int i=0; i<n; i++){
    char c;
    cin >> c;
    acc[i+1] = acc[i]+ (c=='E'?1:0);
  }
  ans = n;
  for (int i=1; i<=n; i++){
    int t;
    t = i-1-acc[i-1]; // west of a leader
    t += acc[n]-acc[i]; // east of a leader
    ans = MIN(ans, t);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
    int a,b,c;
    int i = 0;
    int counter = 0;
    
    scanf( "%d%d%d", &a, &b, &c );
    for( i = 0;i <= c; ++i ){
        if ( i >= a && i <= b && c % i == 0 ){ 
            counter++;
        }
    }
    printf( "%d\n",counter );
    return 0;
}

Measured memory_bytes: 1860
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    cnt = []
    apnd = cnt.append
    for i in A:
        if i & 1:
            print(0)
            return
        else:
            j = 0
            x = i
            while 1:
                x = x // 2
                j += 1
                if x & 1:
                    apnd(j)
                    break
    print(min(cnt))

main()


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define push push_back
#define pop pop_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

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

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    int N, Q;
    ll a[100000], x[500];

    cin >> N >> Q;
    rep(i, N) {
        cin >> a[i];
    }
    rep(i, Q) {
        cin >> x[i];
    }

    rep(i, Q) {
        ll ans = 0;
        ll lim = x[i];
        // 2重ループベースのしゃくとり [left, right)
        int right = 0;
        ll sum = 0;
        rep(left, N) {
            while(right < N && (sum+a[right] <= lim)) {
                sum += a[right];
                // if (sum <= lim) {
                //     right++;
                //     // cout << left+1 << " " << right+1 << endl; 
                // } else break;
                right++;
            }

            ans += right - left;
            // cout << left + 1 << " " << right + 1 << endl;

            if (right == left)
                right++; // 追いついたらrightを進める
            else
                sum -= a[left];
        }
        cout << ans << endl;
    }


    return 0;
}



Measured memory_bytes: 3972