akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  const int N=1e6;
  
   vector<bool> primes(N,false);
   bool isprime(int n)
   {
     for(int i=2;i*i<=n;i++)
     {
       if(n%i==0)
        return false;
     }
     return true;
   }
   //Sieve of Erastothenes
   void sieve()
   {
     primes[2]=false;
     for(int i=2;i*i<=N;i++) //this is actual marking 
     {
        if(!primes[i])
        {
            for(ll j =i*2;j<=N;j+=i)
            {
                primes[j]=true;
            }
        }
     }
   }
   int gcd(int a , int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

  int32_t main()
  { 
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    IOS
    int n;
    cin >> n;
 
    vector<int> v(n);
    map<int,int> mp;
 
 
    for(int i = 0; i < n; i++)
    {
      cin >> v[i];
      mp[i+v[i]]++;
    }
 
    int ans =0;
 
    for(int i = 0; i< n; i++)
    {
      ans += mp[i-v[i]];
    }
 
    cout << ans;
 
 
 
 
 
    
    return 0;
}

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

using namespace std;

using ll = long long;

const int MAX_V = 10000;
const ll INF = 1000000000000000LL;

struct Edge {
    int to;
    ll cap;
    int rev;  //行き先、容量、逆辺
    Edge(int to, ll cap, int rev) : to(to), cap(cap), rev(rev) {}
};

vector<Edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

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

void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < G[v].size(); i++) {
            Edge& e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

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

ll max_flow(int s, int t) {
    ll flow = 0;
    while (true) {
        bfs(s);
        if (level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        ll f;
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll a;
        cin >> a;
        if (a > 0) {
            ans += a;
            add_edge(0, i, 0);
            add_edge(i, n + 1, a);
        } else {
            add_edge(0, i, -a);
            add_edge(i, n + 1, 0);
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = i * 2; j <= n; j += i) {
            add_edge(i, j, INF);
        }
    }

    ans -= max_flow(0, n + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, n, s);
    makev(a, n);
    VVI dp(n + 1, VI(s + 1));
    for(int i = 0; i < n; ++i){
        for(int w = 0; w < s; ++w){
            int q = dp[i][w];
            if (w == 0){
                q += i + 1;
            }
            int nw = w + a[i];
            if (nw <= s){
                dp[i + 1][nw] = (dp[i + 1][nw] + q) % 998244353;
            }
            dp[i + 1][w] = (dp[i + 1][w] + dp[i][w]) % 998244353;
        }
    }
    int ans = 0;
    for(int r = 1; r <= n; ++r){
        ans = (ans + dp[r][s] * (n - r + 1)) % 998244353;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
const long INF = 1000000000;
int main() {
    int n,k; cin >> n >> k;
    vector<long> h(n);
    for(int i = 0; i < n; i ++) cin >> h[i];
    vector<long> dp(n, INF);
    dp[0] = 0;
    for(int i = 1; i < n; i ++) {
        for(int j = 1; j <= min(i,k); j ++) {
            dp[i] = min(dp[i],abs(h[i]-h[i-j]) + dp[i-j]);
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4732
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cassert>
#include<deque>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
////////////////

int const N = 1e5 + 41;
int const INF = 1e9 + 41;

vector<int> e[N];
int w[N];
int n, m;
vector<int> ans, ans2;

void solve(){
	cin >> n >> m;
	fi(0, m){
		int a, b;
		cin >> a >> b;
		e[a].pb(b);
		e[b].pb(a);
	}
	int f = 1;
	while(f != -1){
		int nxt = -1;
		ans.pb(f);
		w[f] = 1;

		fi(0, sz(e[f])){
			int to = e[f][i];
			if(!w[to]){
				nxt = to;
				break;
			}
		}
		f = nxt;
	}

	int s = -1;
	fi(0, sz(e[1])){
		int to = e[1][i];
		if(!w[to]){
			s = to;
			break;
		}
	}
	if(s != -1){
		f = s;
		while(f != -1){
			int nxt = -1;
			ans2.pb(f);
			w[f] = 1;
			fi(0, sz(e[f])){
				int to = e[f][i];
				if(!w[to]){
					nxt = to;
					break;
				}
			}
			f = nxt;
		}
	}
	cout << sz(ans) + sz(ans2) << endl;
	for(int i=sz(ans2)-1;i>=0;--i){
		cout << ans2[i] << " ";
	}
	fi(0, sz(ans)){
		cout << ans[i] <<  " " ;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 7160
import Control.Applicative

main :: IO ()
main = do
    s <- words <$> getLine
    putStrLn $ show (solve s)

solve :: [String] -> Int 
solve s = if s !! 1 == "+"
          then read (s !! 0) + read (s !! 2) 
          else read (s !! 0) - read (s !! 2)

Measured memory_bytes: 508
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (a*n > b) {
      System.out.println(b);
    } else {
      System.out.println(a*n);
    }
  }

}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int n;

int get(int x) {
	int t = 0;
	while(x > 0) {
		t += (x % 10);
		x = x / 10;
	}
	return t;
}

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		if(n % get(n) == 0) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
#define fat 998244353 
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main()

{
    int t;
    cin>>t;
    if(t>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
import fractions
A,B,C,D = (int(i) for i in input().split())

# BまででCで割り切れる数
b1 = B // C
b2 = B // D
b3 = B // (C * D // fractions.gcd(C, D))

a1 = A // C
a2 = A // D
a3 = A // (C * D // fractions.gcd(C, D))

bb = B - b1 - b2 + b3
aa = A - a1 - a2 + a3

# Aが対象なら1を足す
if A % C != 0 and A % D != 0:
    print(bb-aa + 1)
else:
    print(bb-aa)

Measured memory_bytes: 63980
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<int> a(3);
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(a.begin(), a.end());
    
    int ans = 0;
    if ((a.at(2) + sum) % 2 == 0) {
        ans = (3 * a.at(2) - sum) / 2;
    } else {
        ans = (3 * (a.at(2) + 1) - sum) / 2;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys

    readline = sys.stdin.readline

    N, W = map(int, readline().split())
    v, w = [], []
    for _ in [0] * N:
        a, b = map(int, readline().split())
        v.append(a)
        w.append(b)

    dp = [[0] * (W + 1) for _ in [0] * (N + 1)]
    for i in range(N):
        for j in range(W + 1):
            if j < w[i]:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i])
    print(dp[N][W])


main()



Measured memory_bytes: 15692
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
ab=sorted(a+b)[::-1]
ans=0
for i in ab[:ab.index(max(a))]:
  h-=i
  ans+=1
  if h<=0:
    print(ans)
    exit()
ans+=(h+max(a)-1)//max(a)
print(ans)

Measured memory_bytes: 14504
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double a, b, h, m;
	cin>>a>>b>>h>>m;
	double angle=(h*30.0+m*0.5-m*6)*M_PI/180.0;
	//cout<<angle<<endl;
	double ans=a*a+b*b-2*a*b*cos(angle);
	ans=sqrt(ans);
	cout<<setprecision(20)<<ans;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};

int H, W, K;
char grid[801][801];
int sx, sy;
int dist[801][801];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  cin >> H >> W >> K;

  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      cin >> grid[i][j];
      if ( grid[i][j] == 'S' ) {
	sx = j; sy = i;
      }
    }
  }

  const int INF = 1e9;
  fill_n(*dist, 801*801, INF); 
  using Pii = pair<int, int>;
  using Pip = pair<int, Pii>;
  queue<Pip> Q;
  Q.push(Pip(0, Pii(sy, sx)));
  while ( !Q.empty() ) {
    Pip q = Q.front(); Q.pop();
    int d = q.first, y = q.second.first, x = q.second.second;

    if ( d > K ) continue;
    if ( dist[y][x] != INF ) continue;
    dist[y][x] = d;

    for ( int i = 0; i < 4; i++ ) {
      int ny = y+dy[i], nx = x+dx[i];
      if ( ny < 0 || ny >= H || nx < 0 || nx >= W || grid[ny][nx] == '#' ) continue;
      Q.push(Pip(d+1, Pii(ny, nx)));
    }
  }

  int ans = INF;
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      if ( dist[i][j] == INF ) continue;
      int add = min(min(i, H-i-1), min(j, W-j-1));
      if ( add == 0 ) ans = 1;
      else ans = min(ans, 2+(add-1)/K);
    }
  }

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


Measured memory_bytes: 6016
def m():
    H, W, K = map(int, input().split())
    G = [list(input()) for _ in range(H)]
    ans = 0
    for y in range(2 ** H):
        for x in range(2 ** W):
            y_mask = bin(y)[2:].zfill(H)
            x_mask = bin(x)[2:].zfill(W)
            black_cnt = 0
            for j in range(H):
                for i in range(W):
                    if y_mask[j] == '1':
                        continue
                    if x_mask[i] == '1':
                        continue
                    if G[j][i] == '#':
                        black_cnt += 1
            if black_cnt == K:
                ans += 1
    return ans


print(m())


Measured memory_bytes: 69076
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long d[2][8] = {
    {2, 10, 3, 9, 4, 8, 6, 12},
    {6, 2, 10, 3, 9, 4, 8, 12}
};

int main(){
    scanf("%ld", &n);
    if(n == 3){
        printf("2 5 63\n");
        return 0;
    }
    for(int i = 0; i < n; i++){
        printf("%ld ", d[n%2][i%8] + i / 8 * 12);
    }
    printf("\n");
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

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

        char[] s = sc.next().toCharArray();
        boolean result = true;
        for (int i = 0; i < s.length; i++) {
            if (i < a) {
                if (s[i] < '0' || s[i] > '9') {
                    result = false;
                }
            } else if (i == a){
                if (s[i] != '-') {
                    result = false;
                }
            } else {
                if (s[i] < '0' || s[i] > '9') {
                    result = false;
                }
            }
        }
        String ans;
        if (result) {
            ans = "Yes";
        } else {
            ans = "No";
        }


        System.out.println(ans);
    }

}


Measured memory_bytes: 23764
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if N >= M :
  print(0)
else:
  length = [0] * (M-1)
  for i in range(M-1):
    length[i] = (X[i+1]-X[i])
  length.sort()
  print(sum(length[:(M-N)]))

Measured memory_bytes: 13968
//© 2017 Jazengm/Zeng Xiangru, All Rights Reserved
#include<bits/stdc++.h>
using namespace std;

#define Re return
#define In inline
#define St static
#define Rg register
#define Op operator
#define Ct continue
#define inc(l, i, r) for(Rg int i=l; i<r; ++i)
#define dec(l, i, r) for(Rg int i=r; r>l; --i)
typedef long long ll;
typedef double db;

const int mxn = 3<<17;

int main()
{
    St int n, m;
    scanf("%d%d", &n, &m);
    St int c[mxn];
    inc(0, i, n)
    {
        St int l, r;
        scanf("%d%d", &l, &r), --l;
        for(Rg int i=1; i<=l;)
        {
            Rg int i_=min(l/(l/i), r/(r/i))+1;
            if(l/i!=r/i)
                ++c[i], --c[i_];
            i=i_;
        }
/*        for(Rg int i=1; i<=l;)
        {
            Rg int i_=r/(l/i+1), i__=l/(l/i)+1;
            if(i_>=i)
                ++c[i], --c[min(i_+1, i__)];
            i=i__;
        }*/
        ++c[l+1], --c[r+1];
    }
    Rg int ans=0;
    inc(1, i, m+1)
        printf("%d\n", ans+=c[i]);
    Re 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, a;
    cin >> n >> a;
    vector<ll> x(n);
    rep(i, 0, n) cin >> x[i];
    ll dp[60][60][2600];
    dp[0][0][0] = 1;
    rep(i, 0, n) rep(j, 0, n) rep(k, 0, 2600) {
        if (dp[i][j][k] == 0) continue;
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
        dp[i+1][j][k] += dp[i][j][k];
    }
    ll ans = 0;
    rep(j, 1, n+1) {
        ans += dp[n][j][j*a];
    }
    cout << ans << endl;
}

Measured memory_bytes: 63744
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int len = s.size();
    bool flag = true;
    bool is_odd = true;
    for(int i = 0; i<len; i++){
        if(is_odd == true){
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
                flag = false;
            }
            is_odd = false;
        }else if(is_odd == false){
            if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
                flag = false;
            }
            is_odd = true;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
a11,a12,a13=map(int, input().split())
a21,a22,a23=map(int, input().split())
a31,a32,a33=map(int, input().split())
a=[]
for i in [a11,a12,a13,a21,a22,a23,a31,a32,a33]:
    a.append(i)
    
ans="No"
b=[]
n=int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 0

for i in range(3):
    if a[i]==a[i+3] and a[i+3] ==a[i+6]:
        ans="Yes"

for i in range(3):
    if a[3*i] == a[3*i+1] and a[3*i+1] == a[3*i+2]:
        ans="Yes"

if a[0]==a[4] and a[4]==a[8]:
    ans="Yes"
elif a[2]==a[4] and a[4]==a[6]:
    ans="Yes"

print(ans)

Measured memory_bytes: 3064
/* 
 * Project: AtCoder Beginners Contest 178 C - Ubiquity
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/13
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

uint_fast64_t n;

uint_fast64_t powmod(uint_fast64_t x, uint_fast64_t y) {
    uint_fast64_t result = 1;
    for (uint_fast64_t i=0;i<y;i++) {
        result = result * x%1000000007;
    }
    return result;
}

void solve() {

    if (n < 2) {
        printf("%d\n", 0);
        return;
    }
    int_fast64_t result = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    result = result%1000000007;
    result = (result+1000000007)%1000000007;
    printf("%lu\n", result);
}

int main() {

    scanf("%ld", &n);

    solve();
}

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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

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

#define ll long long
#define oo INT_MAX

const int N = 1e3 + 5;
ll n , m , mod = 1e9 + 7;
ll dp[N][N];
char f[N][N];

/// dp[i][j] là số cách để tới ô i , j.

int main()
{
    //freopen("H.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    FOR(i , 1 , n)
        FOR(j , 1 , m)
            cin >> f[i][j];
    FOR(i , 1 , n)
        FOR(j , 1 , m)
            if(f[i][j] == '.')
            {
                if(i == 1 && j == 1)
                    dp[i][j] = 1;
                else
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
            }
    cout << dp[n][m] << "\n";
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <tuple>

using namespace std;
typedef long long ll;

// 素集合データ構造
struct UnionFind
{
  vector<ll> par;
  vector<ll> sizes;

  UnionFind(int n)
	: par(n)
	, sizes(n, 1LL)
  {
	for(int i = 0; i < n; i++)
	{ 
	   par[i] = i;
	}
  }

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

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

  int size(int x) {
    return sizes[find(x)];
  }
};

int main()
{
  int n;
  cin >> n;
  
  vector<pair<ll, ll>> xs;
  vector<pair<ll, ll>> ys;
  for(int i = 0; i < n; i++)
  {
	ll x, y;
	cin >> x >> y;
	xs.push_back(make_pair(x, i));
	ys.push_back(make_pair(y, i));
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  vector<tuple<ll, ll, ll>> edges;
  for(int i = 0; i < n - 1; i++)
  {
	ll diff = xs[i + 1].first - xs[i].first;
	edges.push_back(make_tuple(diff, xs[i].second, xs[i + 1].second));

	diff = ys[i + 1].first - ys[i].first;
	edges.push_back(make_tuple(diff, ys[i].second, ys[i + 1].second));
  }

  sort(edges.begin(), edges.end());
  
  UnionFind uf(n);
  int count = 0;
  ll ans = 0;
  int index = 0;
  while(index < edges.size() && count < n - 1)
  {
	ll diff, n1, n2;
	tie(diff, n1, n2) = edges[index];

	if(!uf.same(n1, n2))
	{
	  uf.unite(n1, n2);
	  count++;
	  ans += diff;
	}		
	index++;
  }
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 13024
import sys
from itertools import product

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


def resolve():
    S = input()
    n = len(S)
    res = 0
    for pattern in product([0, 1], repeat=n - 1):
        pattern = list(pattern) + [""]
        fomula = []
        for s, op in zip(S, pattern):
            fomula.append(s)
            fomula.append("+") if op == 1 else None

        fomula = "".join(fomula)
        res += eval(fomula)

    print(res)


if __name__ == '__main__':
    resolve()


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int N;
    cin >> N;
    vector<int> v(N);
    FOR(i, N)
        cin >> v[i];
    sort(v.begin(), v.end());

    ll sol = 0;
    FOR(i, N-2){
        int k = i+2;
        for(int j=i+1; j<N-1; j++){
            while(k < N && v[k] < v[i]+v[j])
                k++;
            sol += k-j-1;
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

int main()
{

	int n, k,x,ans=0;
	
	cin >> n >> k;
	for (int i = 0;i < n;i++) {
		cin >> x;
		if (x >= k) ans++;
	}
	cout << ans << endl;

		return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<cassert>
#include<algorithm>
#include<cassert>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

enum{UP=0,DOWN=1,NON=2};
const int N = 512;
const int M = 512;
const int mod = 10000;
//const int mod = 1000000;


//æ¡æ°,sum%M,æå¾ã®æ°å­,æ¬¡ã®æ°å­ãupãªã®ãdownãªã®ã,ä¸éã¨ä¸è´ãã¦ãããã©ããã
//ä½æ¡ç®ã¾ã§èª­ãã ããç¾å¨ã®%mã®å¤,åã®æå¾ã®æ¡ãup or down,ä¸éã¨ä¸è´
//500 * 500 * 10 ** 2 * 2
int dp[N][M][11][3][2];
int solve(const int n,int now,const int m,int val,int last,int st,bool match,const string &in){
  //cout <<"state " <<  now <<" "<< val <<" "<< last <<" " <<st <<" " << match << endl;
  if (now == n){
    return val == 0 && last != 10?1:0;
  }

  
  int &ret = dp[now][val][last][st][match];
  if (ret != -1)return ret;
  ret = 0;

  /*ãã®æ¡ããå§ã¾ãæ°ã*/
  if (last == 10){
    REP(i,1,10){
      bool nextMatch=false;
      if (now == 0 && i  > in[0]-'0')break;
      if (now == 0 && i == in[0]-'0')nextMatch = true;
      ret += solve(n,now+1,m,i%m,i,NON,nextMatch,in);
      ret %= mod;
    }
    ret += solve(n,now+1,m,0,10,NON,false,in);
    return ret;
  }

  REP(i,0,10){
    bool nextMatch=false;
    if (match && i > in[now]-'0')break;
    if (match && i == in[now] - '0')nextMatch = true;
    if (i == last)continue;
    if (st == UP   && i >= last)continue;  //i-1çªç®ã¨i-2çªç®ã«ã¤ãã¦i-2 < i-1 ãªã®ã§ãi-1 <= i ã¯è¨±ãããªã
    if (st == DOWN && i <= last)continue;//i-1çªç®ã¨i-2çªç®ã«ã¤ãã¦i-2 < i-1 ãªã®ã§ãi-1 <= i ã¯è¨±ãããªã
    int nextst;
    if (last < i)nextst = UP;
    if (last > i)nextst = DOWN;
    ret += solve(n,now+1,m,(i+val*10)%m,i,nextst,nextMatch,in);
    ret %= mod;
  }
  return ret;
}

int getVal(string in,int m){
  rep(i,N)rep(j,N)rep(k,11)rep(l,3)rep(n,2)dp[i][j][k][l][n] = -1;
  int ans = solve(in.size(),0,m,0,10,NON,true,in);
  return ans;
}

bool isZigzag(string &in){
  if (in.size() == 1)return true;
  if (in.size() == 2)return in[0] != in[1];
  REP(i,2,in.size()){
    if ((in[i-2] < in[i-1] && in[i-1] > in[i]) ||
	(in[i-2] > in[i-1] && in[i-1] < in[i]));
    else return false;
  }
  return true;
}

bool isModm(string &in,int m){
  int now = 0;
  rep(i,in.size()){
    now = now*10 + (in[i]-'0');
    now %= m;
  }
  return now == 0;
}

/*
  
 */
main(){
  /*b-a + isZigzagAndModm(am)*/
  string a,b;
  int m;
  while(cin>>a>>b>>m){
    int tmp = isZigzag(a) && isModm(a,m)?1:0;
    int tb = getVal(b,m),ta = getVal(a,m);
    //cout << tb <<" " << ta <<" " << tmp << endl;
    int ans = ((tb-ta+mod)%mod+tmp)%mod;
    cout << ans << endl;
  }
}
/*
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  
  3
  6
  9
  12
  15
  18


9 3
99 27
999 177
9999 1038
99999 6315
999999 8133
ans 1234567 247
 */

Measured memory_bytes: 0
N = int(input())
T, A = (int(x) for x in input().split())
H = list(map(int, input().split()))

ideal_hight = int((T - A) / 6 * 1000)

close_hight = 500000
close_hight_id = 0

for i in range(0, N):
    if abs(ideal_hight - H[i]) <= close_hight:
        close_hight = abs(ideal_hight - H[i])
        close_hight_id = i

print(close_hight_id + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
long de(long a,long x){
  if(a==-1) return 0;
  return a/x+1;
}
int main(){
  long a,b,x;cin>>a>>b>>x;
  cout<<de(b,x)-de(a-1,x)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), cp(n);
	rep(i, 0, n) {
		cin >> a[i];
		cp[i] = a[i];
	}
	DescSort(cp);
	rep(i, 0, n) {
		if (cp[0] == a[i]) cout << cp[1] << endl;
		else cout << cp[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
N = int(input())

total = 0

for i in range(N + 1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        total = total + i

print(total)

Measured memory_bytes: 9112
A,B,C = list(map(int, input().split()))
K = int(input())
res = 0

def check(A,B,C):
    if A < B and B < C:
        return 1
    else:
        return 0

def operation(A, B, C, K):
    res = 0
    if K == 0:
        return check(A,B,C)
    else:
        res = res + operation(A*2,B,C,K-1)
        res = res + operation(A,B*2,C,K-1)
        res = res + operation(A,B,C*2,K-1)
    return res

res = operation(A,B,C,K)

if res > 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9136
#include<cstdio>
#include<cctype>

int main() {
  char c;

  for(;;) {
    scanf("%c", &c);

    if( isalpha(c) ) {
      if( islower(c) ) {
	printf("%c", toupper(c));
      } else {
	printf("%c", tolower(c));
      }
    } else {
      printf("%c", c);
    }

    if(c == '\n') break;

  }
  
  return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());
        long[] A = new long[N];
        string[] input = Console.ReadLine().Split(' ');
        long min = long.MaxValue;
        long ans = 0;
        long minus = 0;
        for(long i = 0; i < N; i++)
        {
            A[i] = long.Parse(input[i]);
            if (min > Math.Abs(A[i])) { min = Math.Abs(A[i]); }
            if (A[i] < 0) { minus++; }
            ans += Math.Abs(A[i]);
        }
        if (minus % 2 == 1) ans -= 2 * min;
        Console.WriteLine(ans);
    }
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

ll calc(string s) {
    stack<ll> st;
    st.push(0);
    for (char c : s) {
        if (c == '+') {
            st.push(0);
        } else {
            int i = c - '0';
            st.top() *= 10;
            st.top() += i;
        }
    }

    ll ans = 0;
    while (!st.empty()) {
        ans += st.top();
        st.pop();
    }
    return ans;
}

int main() {
    string s;
    cin >> s;

    ll k;
    cin >> k;

    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c == 'a') continue;
        int m = 'z' - c;
        m++;
        if (k >= m) {
            k -= m;
            s[i] = 'a';
        }
    }

    ll b = s.back() - 'a';
    b += k;
    b %= 26;
    s.back() = 'a' + b;
    cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,s[5];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=4;i++){
        s[i]=n%10;
        n/=10;
    }
    if(s[1]==s[2] && s[1]==s[3]) cout << "Yes";
    else if(s[4]==s[2] && s[4]==s[3]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <cmath>

using namespace std;

int INF = 1'000'000;

int main() {
    int N, K;
    cin >> N >> K;

    int64_t cnt1 = 0, cnt2 = 0;
    for(int i=1;i<=N;i++){
        if( i % K == 0 )    cnt1++;
        if( K % 2 == 0 && i % K == K/2 )  cnt2++;
    }

    int64_t ans = (int64_t) round( pow(cnt1, 3) );
    if( K % 2 == 0 ) ans +=(int64_t) round( pow(cnt2, 3) );

    cout << ans << endl;
}

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

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {

            int K = int.Parse(Console.ReadLine());

            Queue<long> queue = new Queue<long>(Enumerable.Range(1, 9).Select(x => (long)x));

            for (int i = 1; i < K; i++)
            {
                var num = queue.Dequeue();
                //if (num % 10 != 0) queue.Enqueue(11 * num - 1);
                //queue.Enqueue(11 * num);
                //if (num % 10 != 9) queue.Enqueue(11 * num + 1);
                for (int j = -1; j <= 1; j++)
                {
                    var d = num % 10 + j;
                    if (d < 0 || d > 9)
                    {
                        continue;
                    }

                    queue.Enqueue(num * 10 + d);
                }
#if DEBUG
                //Console.WriteLine($"num: {num}");
                //Console.WriteLine($"queue: {string.Join(", ", queue)}");
#endif
            }

            Console.WriteLine(queue.Dequeue());
        }
    }
}


Measured memory_bytes: 14944
#include <stdio.h>
void merge(int *,int,int,int);
void mergesort(int*,int,int);
long long cnt=0;
int L[100002],R[100002];
int main(){
  int A[200000],i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergesort(A,0,n);
  printf("%ld\n",cnt);
  return 0;
}
void merge(int *a,int left,int mid,int right){
  int i,k,j,n1=mid-left,n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=2000000000;
  R[n2]=2000000000;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])a[k]=L[i++];
    else{
      a[k]=R[j++];
      cnt+=n1-i;
    }
  }
  return;
}
void mergesort(int *a,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(a,left,mid);
    mergesort(a,mid,right);
    merge(a,left,mid,right);
  }
  else return;
}


Measured memory_bytes: 3340
#include<cstdio>
using namespace std;
int n,sum;
int d[111];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&d[i]);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        if(i==j) continue;
        sum=sum+d[i]*d[j];
    }
    printf("%d\n",sum/2);
    return 0;
}



Measured memory_bytes: 128
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

ac = [0]*(N+1)
bc = [0]*(N+1)

ok = True
for i in range(N):
    ac[A[i]] += 1
    bc[B[i]] += 1

d = 0
for i in range(1, N+1):
    if (ac[i]+bc[i]) > N:
        ok = False
        break
    ac[i] += ac[i-1]
    bc[i] += bc[i-1]
    d = max(d, ac[i]-bc[i-1])

if ok:
    print("Yes")
    print(*[B[(i-d) % N] for i in range(N)])
else:
    print("No")


Measured memory_bytes: 131312
n, m, q = map(int, input().split())


A = []
B = []
C = []
D = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

import itertools
ANS = []
for i in list(itertools.combinations_with_replacement([i for i in range(1, m+1)], n)):
    L = list(i)
    t = 0
    for i in range(q):
        if L[B[i] - 1] - L[A[i] - 1] == C[i]:
            t += D[i]
    ANS.append(t)

print(max(ANS))

Measured memory_bytes: 85216
from collections import Counter

input()
c = sorted(
    filter(lambda x: x[1] >= 2, Counter([int(i) for i in input().split()]).items()),
    key=lambda x: x[0], reverse=True)
a, b = 0,0
for i in c:
    key = i[0]
    count = i[1]
    if count >= 4 and not a and not b:
        a, b = key, key
        break
    if count >= 2:
        if not a:
            a = key
        else:
            b = key
            break
print(a*b)


Measured memory_bytes: 18592
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
#define ms(f,x) memset(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read; 
using namespace std;
const int N=2e6+11;
int n,k,tot,x;
int p[N],q[N],mx[N];
//p=q^(-1)
set<pii>s;
set<pii> :: iterator it;
priority_queue<int>heap;
int nxt[N],las[N],to[N],deg[N];
inline void add(int x,int y){
	nxt[++tot]=las[x];
	las[x]=tot;
	to[tot]=y;
	++deg[y];
}
inline void topsort(){
	rep(i,1,n)
		if(!deg[i])
			heap.push(-i);
	rep(i,1,n){
		int x=-heap.top();heap.pop();
		p[x]=i;
		go(x){
			--deg[to[e]];
			if(!deg[to[e]])
				heap.push(-to[e]); 
		} 
	}
}
#define lson k<<1,l,mid
#define rson k<<1|1,mid+1,r
inline void ins(int x,int p,int k=1,int l=1,int r=n){
	if(l==r){
		mx[k]=p;
		return ;
	}
	int mid=(l+r)>>1;
	x<=mid?ins(x,p,lson):ins(x,p,rson);
	mx[k]=max(mx[k<<1],mx[k<<1|1]);
}
inline int query(int x,int y,int k=1,int l=1,int r=n){
	if(x<=l&&r<=y)return mx[k];
	int mid=(l+r)>>1;
	int ans=0;
	if(x<=mid)ans=query(x,y,lson);
	if(mid<y)ans=max(ans,query(x,y,rson));
	return ans;
}
int main(){
	gii(n,k);
	rep(i,1,n){ 
		gi(p[i]);
		q[p[i]]=i;
	}
	//rep(i,1,n)printf("%d ",q[i]);puts("");
	rep(i,1,n){
		//printf("%d %d\n",i,q[i]);
		x=query(q[i],min(q[i]+k-1,n));
		if(x)add(q[x],q[i]);
		x=query(max(q[i]-k+1,1),q[i]);
		if(x)add(q[x],q[i]);
		//printf("%d\n",x);
		ins(q[i],i);
	}
	//rep(i,1,n)printf("%d ",deg[i]);puts("");
	topsort(); 
	rep(i,1,n)
		printf("%d\n",p[i]);
	return 0;
} 

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

int main(){
    string s;
    cin >> s;
    //keyence?
    string t = "keyence";
    bool flag = false;
    for(int i=0; i<s.size()-6; i++){
        string sub = s.substr(i, 7);
        if(t == sub){
            string head = s.substr(0, i);
            string tail = s.substr(i+7, s.size()-7);
            if(head == "" && tail != "") flag = true;
            else if(head != "" && tail == "") flag = true;
            else if(head == "" && head == "") flag = true;
        }
    }
    if(flag){
        cout << "YES" << endl;
        return 0;
    }

    for(int i=1; i<7; i++){
        //cout << t.substr(0, i) << " " << t.substr(i, 7) << endl;
        string head = t.substr(0, i);
        string tail = t.substr(i, 7);
        string H = s.substr(0, i);
        string T = s.substr(s.size()-tail.size(), tail.size());
        if(head == H && tail == T){
            cout << "YES" << endl;
            return 0;
        }
        //cout << H << " " << T << endl;
    }
//keyABCDence
    cout << "NO" << endl;

}

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n, m;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    long double ans = 0;
    rep2(i, 1, 10000) {
        long double tmp =  i * (100 * (n - m) + 1900 * m) * pow(1.0 - pow(0.5, m), i - 1) * pow(0.5, m);
        ans += tmp;
    }
    cout << ans << endl;

}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
   int t=1;
  // cin>>t;
   while(t--)
   {
    int n,k,i,x,con=0,ans=0;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='W')
        ans++;
    }
    x=ans;
    for(i=n-1,con=0;con<ans;con++,i--)
    {
        if(s[i]=='W')
        x--;
    }
    cout<<x<<endl;
   }
}


Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    int v=0,t=0;
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(i==0) continue;
        if(h[i-1]>=h[i]) t++;
        if(h[i-1]<h[i]||i==n-1){
            v=max(v,t);
            t=0;
        }
    }

    cout<<v<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SZ = 1e5 + 100;
ll n;
vector<vector<ll>> gr;
vector<pair<ll, ll>> vec;

ll sub[SZ], dp[SZ];
map<ll, ll> m;

int main()
{
	fastInp;

	cin >> n;

	vec.resize(n);
	for (auto &cur : vec) cin >> cur.first;
	for (int i = 0; i < n; i++) {
		sub[i] = 1;
		vec[i].second = i;
		m[vec[i].first] = vec[i].second;
	}

	sort(vec.rbegin(), vec.rend());

	vector<pair<ll, ll>> edges;
	for (int i = 0; i < vec.size() - 1; i++) {
		ll par = vec[i].first + sub[vec[i].second] - (n - sub[vec[i].second]);
		if (m.find(par) == m.end() || m[par] == vec[i].second) {
			cout << "-1";
			return 0;
		}

		sub[m[par]] += sub[vec[i].second];
		dp[m[par]] += sub[vec[i].second] + dp[vec[i].second];
		edges.push_back({ vec[i].second, m[par] });
	}

	if (dp[vec.back().second] != vec.back().first) {
		cout << "-1";
		return 0;
	}
	for (auto cur : edges) {
		cout << cur.first + 1 << " " << cur.second + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 14344
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n+1),b(n+1,0);
  for (int i = 1; i < n+1; i++) cin >> a[i];

  for (int i = n; i >= 1; i--) {
    //int cnt = 0;
    int cnt = a[i];
    int j = 1;
    while(i*j <= n){
      cnt += b[i*j];
      j++;
    }
    //if(cnt%2 != a[i]%2) b[i] = 1;
    if(cnt%2 == 1) b[i] = 1;
  }
  int m = 0;
  rep(i, n+1) m += b[i];
  std::cout << m << '\n';
  for (int i = 1; i < n+1; i++) {
    if(b[i] == 1) std::cout << i << '\n';
  }
}


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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	cin >> x >> n;
	set<ll>s;
	rep(i, x, x + n + 1, 1) {
		s.insert(i);
	}
	rep(i, x - n, x , 1) {
		s.insert(i);
	}

	while (n--) {
		cin >> t;
		if (s.count(t))	s.erase(t);
	}

	ll dif = infl, ans = x - n;

	for (auto zx : s) {
		if (abs(x - zx) < dif) {
			ans = zx;
			dif = abs(zx - x);
		}
	}


	ce(ans)
}


Measured memory_bytes: 3672
#include<cstdio>
#include<cmath>
int main(){
  int n;
  while(scanf("%d",&n) && n){
    int s[1000]={},sum=0;
    for(int i=0;i<n;i++){
      scanf("%d",&s[i]);
      sum += s[i];
    }
    double m = (double)sum / (double)n,ssum=0;
    for(int i=0;i<n;i++) ssum += pow((s[i]-m),2);
    printf("%.7f\n",sqrt(ssum/(double)n));
  }
}



Measured memory_bytes: 2736