akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	set<char> se;
	for(int i=0; i<s.size(); i++) se.insert(s[i]);
	vector< vector<int> > v;
	set<char>::iterator itr = se.begin();
	v.resize(se.size());
	int j;
	for(int i=0; i<se.size(); i++){
		j=0;
		for(int k=0; k<s.size(); k++){
			if(s[k]==(*itr)){
//cout << j << " ";
				v[i].push_back(j);
				j=0;
			}
			else if(k == s.size()-1){
//cout << j << " ";
				v[i].push_back(j+1);
				j=0;
			}
			else{
				j+=1;
			}
		}
//cout << endl;
		++itr;
	}
	int a[se.size()];
	for(int k=0; k<se.size(); k++){
		j=v[k][0];
		for(int l=0; l<v[k].size(); l++){
			j=max(j, v[k][l]);
		}
		a[k]=j;
	}
	j=a[0];
	for(int i=0; i<se.size(); i++){
		j=min(j, a[i]);
	}

	cout << j << endl;

	return 0;
}

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

using namespace std;

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

	vector<int> A(N + 1, 0);
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A[tmp]++;
	}

	sort(A.begin(), A.end(), greater<int>());

	int ans = 0;
	for (int i = K; i <= N; i++) {
		ans += A[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	ll N;
  	cin>>N;
  	
  
  	cout<<N+N*N+N*N*N<<endl;
}

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

int solve(int n,int m){
    vector<string> pat(n);
    for(int i=0;i<n;i++) cin>>pat[i];
    string tar;
    for(int i=0;i<m;i++){
        string buf;
        cin>>buf;
        tar+=buf;
    }
    m=tar.size();
    vector<vector<int>> isJumpable(m,vector<int>(n,0));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(i+pat[j].size()>m) continue;
            isJumpable[i][j]=(pat[j]==tar.substr(i,pat[j].size()));
        }
    }
    int len=accumulate(pat.begin(),pat.end(),0,[](int lhs,string rhs){return lhs+rhs.size();});
    int res=0;
    for(int i=0;i+len<=m;i++){
        vector<vector<int>> dp(len+1);
        dp[0].push_back(0);
        vector<int> used(1<<n);
        for(int j=0;j<len;j++){
            for(auto st:dp[j]){
                if(used[st]) continue;
                used[st]=true;
                for(int k=0;k<n;k++){
                    if((st>>k)&1) continue;
                    if(isJumpable[i+j][k]){
                        dp[j+pat[k].size()].push_back(st|(1<<k));
                    }
                }                
            }
            dp[j].clear();
        }
        if(!dp[len].empty()) res++;
    }
    return res;
}
int main(){
    int n,m;
    while(cin>>n>>m,n){
        cout<<solve(n,m)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

typedef long long ll;

ll gcd(ll x, ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}

vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for (ll i=2;i*i <= n; i++){
        if (n%i != 0) continue;
        res.emplace_back(i,0); // push_back(pair(i,0))と同じ
        while (n%i == 0){
            n /=i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n,1); // push_back(pair(n,1))と同じ
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;

    return 0;
}

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

def calc(a, t):
    ans = 0
    p_flag = t < 0
    t += a
    if p_flag:
        if t < 0:
            ans = 1 - t
            t = 1
    else:
        if t >= 0:
            ans = 1 + t
            t = -1
    if t == 0:
        ans += 1
        if p_flag:
            t = 1
        else:
            t = -1

    return ans, t

ans_p = 0
t_p = 0
ans_m = 0
t_m = 0
if A[0] > 0:
    ans_p = 0
    t_p = A[0]
    ans_m = A[0]+1
    t_m = -1
elif A[0] < 0:
    ans_p = -A[0]+1
    t_p = 1
    ans_m = 0
    t_m = A[0]
else:
    ans_p = 1
    t_p = 1
    ans_m = 1
    t_m = -1

for i in range(1, N):
    a, t_p = calc(A[i], t_p)
    ans_p += a
    a, t_m = calc(A[i], t_m)
    ans_m += a

print(min(ans_p, ans_m))


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

int main() {
    static const double pi = 3.141592653589793238462643383279;
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double kakudo = (h * (pi/6) + m * (pi/360)) - m * (pi/30);
    double x = sqrt((a * a) + (b * b) - (2 * a * b * cos(kakudo)));
    cout << fixed << setprecision(30) << x << endl; 
    return 0;
}

Measured memory_bytes: 4288
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int cnt[1000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string S;
    int K;
    cin >> S >> K;
    ll ans = 0;
    int N = S.size();
    cnt[0] = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != '0'){
            cnt[i+1] = cnt[i]+1;
        }else{
            cnt[i+1] = cnt[i];
        }
    }
    if(K == 1){
        for(int i = 0; i < S.size(); i++){
            int c = S[i]-'0';
            if(i == 0){
                ans += c;
            }else{
                ans += 9;
            }
        }
    }
    if(K == 2){
        for(int i = 0; i < S.size(); i++){
            for(int j = i+1; j < S.size(); j++){
                int c = S[i]-'0';
                int d = S[j]-'0';
                if(cnt[i] == 0){
                    if(cnt[j] == 1){
                        if(c != 0) ans += 9*(c-1)+d;
                    }else{
                        ans += 9*c;
                    }
                }else{
                    ans += 9*9;
                }
            }
        }
    }
    if(K == 3){
        for(int i = 0; i < S.size(); i++){
            for(int j = i+1; j < S.size(); j++){
                for(int k = j+1; k < S.size(); k++){
                    int c = S[i]-'0';
                    int d = S[j]-'0';
                    int e = S[k]-'0';
                    if(cnt[i] == 0){
                        if(cnt[j] == 1){
                            if(cnt[k] == 2){
                                ans += (e);
                                if(d != 0) ans += 9*(d-1);
                                if(c != 0) ans += (c-1)*9*9;
                            }else{
                                ans += 9*(d);
                                if(c != 0) ans += (c-1)*9*9;
                            }
                        }else{
                            ans += c*9*9;
                        }
                    }else{
                        ans += 9*9*9;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    char ans = '1';
    REP(i,k) {
        if(s[i] != '1') {
            ans = s[i];
            break;
        }
    }
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
# B問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  cnt=0
  for i in range(1,n-1):
    a,b,c=[l[i-1],l[i],l[i+1]]

    if b!=min(a,b,c) and b!=max(a,b,c):
      cnt+=1

  return cnt

print(main())


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset ((a), v, sizeof (a))

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ii> vii;

const int MAX = 100005;

int n;
int freq[MAX];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x; scanf ("%d", &x);
		++freq[x];
	}

	int ans = 0;
	for (int i = 0; i <= MAX - 5; ++i) {
		ans = max (ans, freq[i] + freq[i + 1] + (i == 0 ? 0 : freq[i - 1]));
	}

	printf ("%d\n", ans);
	return 0;
}

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

int main() {
  int N;
  int d[110];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d[i];
  
  int num[110] = {0};
  for (int i = 0; i< N; i++) {
  	++num[d[i]];
  }
  
  int res = 0;
  for (int i = 1; i <= 100; i++){
  	if (num[i]) {
    	res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	ll n, m, ans,zero=0;
	cin >> n >> m;
	ans = min(n,m/2);
	m -= n*2;
	ans += max(zero, m / 4);
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	bool ans = 1;
	int n, t[2], x[2], y[2];
	cin >> n;
	t[0] = 0; x[0] = 0; y[0] = 0;
	FOR(i, n) {
		cin >> t[1] >> x[1] >> y[1];
		if (ans) {
			int td = t[1] - t[0], d = abs(x[0] - x[1]) + abs(y[0] - y[1]);
			if (td < d || td % 2 != d % 2)ans = 0;
			t[0] = t[1]; x[0] = x[1]; y[0] = y[1];
		}
	}

	if(ans)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<utility>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
#define N 200
#define W 2000


using namespace std;


int dp[W][N];


int main(void){
	
	
	int n,m;
	while(scanf("%d %d", &n, &m),n+m){
		vector<int> mx[200];
		vector<int> ms[200];
		vector<int> mi[200];
		
		int ki, x, d, in = 0;
		rep(i,W)rep(j,N) dp[i][j] = 1000000000;
	
		m++;
		
		rep(i, n){
			scanf("%d", &ki);
			
			rep(j, ki){
				scanf("%d %d", &x, &d);
				mx[i+1].push_back(x);
				ms[i+1].push_back(d);
				mi[i+1].push_back(in);
				in++;
			}
		}
		
		
		rep(i,mx[1].size())dp[mi[1][i]][0] = 0;
		
		if(m > 0)rep(i,mx[2].size())dp[mi[2][i]][1] = 0;
		
		reps(i,1,n){
			rep(j,mx[i].size()){
	//			printf("---x:%d v:%d in:%d---\n", mx[i][j], ms[i][j], mi[i][j]);
				rep(k, mx[i+1].size()){
					rep(l, m){
						dp[mi[i+1][k]][l] = min(dp[mi[i+1][k]][l], 
												dp[mi[i][j]][l] + (abs(mx[i+1][k] - mx[i][j]) * (ms[i+1][k] + ms[i][j])));
					}
				}
				
				rep(k, mx[i+2].size()){
					rep(l, m-1){
						dp[mi[i+2][k]][l+1] = min(dp[mi[i+2][k]][l+1],
												  dp[mi[i][j]][l] + (abs(mx[i+2][k] - mx[i][j]) * (ms[i+2][k] + ms[i][j])));
					}
				}			
			}
		}
		
		int ans = 2000000000;
		
		rep(i,mx[n].size()){
			rep(j,m){
				ans = min(ans, dp[mi[n][i]][j]);
			}
		}
		rep(i,mx[n-1].size()){
			rep(j,m-1){
				ans = min(ans, dp[mi[n-1][i]][j]);
			}
		}
		
		printf("%d\n", ans);
	}
	return 0;
}

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

using ll = long long;

int main() {
    int N;
    ll ans = 0;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    priority_queue<vector<int>> q;
    rep(i, N) {
        cin >> B[i];
        q.push({B[i], i});
    }
    while (!q.empty()) {
        auto t = q.top();
        q.pop();
        if (t[0] <= A[t[1]]) continue;
        int d = B[(t[1] - 1 + N) % N] + B[(t[1] + 1) % N];
        int r = (t[0] - max(A[t[1]], d) + d - 1) / d;
        t[0] -= d * r;
        ans += r;
        if (t[0] < A[t[1]] || r == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (t[0] > A[t[1]]) {
            q.push({t[0], t[1]});
        }
        B[t[1]] = t[0];
    }
    rep(i, N) {
        if (A[i] != B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    /*
    9817 1108 6890 4343 8704
    0005
                        4356
              1439
                        0008
                    2896
                    1449
                       2
               329
          774
          440
          106
               221
               113
                5
           96
           86
           76
           66
           56
           46
           36
           26
           16
            6
                            1
    */
}

Measured memory_bytes: 14892
#include<bits/stdc++.h>
using namespace std;
long long a[100005];
long long sum[100005];
int vis[100005];
int main()
{
    memset(sum,0,sizeof(sum));
    memset(vis,0,sizeof(vis));
    int n;
    int m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        long long tmp;
        scanf("%lld",&tmp);
        vis[tmp]=1;
    }
    sum[0]=1;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==1) sum[i]=0;
        else
        {
            if(i==1) sum[1]=1;
            else
            sum[i]=(sum[i-1]+sum[i-2])%1000000007;
        }
        //cout<<i<<" "<<sum[i]<<endl;
    }
    printf("%lld\n",sum[n]);
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b,c;
string s[1100][1100];
signed main()
{
	cin>>a>>b;
	cout<<a-b+1;
}

Measured memory_bytes: 9728
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int A = sc.nextInt();//1
      int B = sc.nextInt();//0
      int C = sc.nextInt();//-1
      int K = sc.nextInt();//選択された枚数
      
      //Aの枚数で足りるとき
      if(A>=K){
       System.out.print(K);
      }
      //AとBの枚数で足りるとき
      else if((A+B)>=K && K>A){
       System.out.print(A);
      }   
      //Cの枚数で足りるとき
      else {
       System.out.print(A-(K-A-B));
      }
    }
}

Measured memory_bytes: 35740
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
double print_double(double d){printf("%.11f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N,C,c;
  cin >> N >> C;
  vector<vector<int>> D(C,vector<int> (C)),cnt(3,vector<int> (C,0));
  rep(i,C)rep(j,C) cin >> D[i][j];
  rep(i,N)rep(j,N) {
    cin >> c;
    c--;
    auto t = (i+j)%3;
    cnt[t][c]++;
  }

  ll ans = LONG_LONG_MAX,t;
  rep(i,C)rep(j,C)rep(k,C){
    if (i==j||j==k||k==i) continue;
    t = 0;
    rep(ii,C) t+=cnt[0][ii]*D[ii][i];
    rep(ij,C) t+=cnt[1][ij]*D[ij][j];
    rep(ik,C) t+=cnt[2][ik]*D[ik][k];
    chmin(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <vector>
#define ll long long
#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 pb push_back
#define vec vector<int>
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
int n,m;
vector<vector<int>> dist;
vec ans,ma;
void func(int v,int d,int c){
    if(ans[v]==0)ans[v]=c;
    if(d==0||ma[v]>=d)return;
    ma[v]=d;
    REP(x,dist[v]){
        if(ans[x]==0)ans[x]=c;
        func(x,d-1,c);
    }
}
int main(){
    n=in();
    m=in();
    dist=vector<vector<int>>(n,vector<int>());
    rep(i,m){
        int x=in()-1;
        int y=in()-1;
        dist[x].pb(y);
        dist[y].pb(x);
    }
    int q=in();
    vec v(q),d(q),c(q);
    rep3(i,q-1,0){
        v[i]=in()-1;
        d[i]=in();
        c[i]=in();
    }
    ans=vec(n);
    ma=vec(n);
    rep(i,q)func(v[i],d[i],c[i]);
    rep(i,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 8440
k = 'keyence'
a = input()
b = a.split(k)
if k in a:
    if all(b):
        print('NO')
    else:
        print('YES')
else:
    for i in range(1,7):
        if k[:i] == a[:i] and k[i-7:] == a[i-7:]:
            print('YES')
            break
    else:
        print('NO')

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc161/tasks/abc161_f

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const ll N_MAX = 1e12;

ll N;

int count(ll k) {
  ll n = N;
  if (n % k == 1) return 1 + (k * k + 1 < n);
  while (n % k == 0) n /= k;
  return n % k == 1;
}

int main() {
  cin >> N;

  int ans = 0;
  for (ll k = 2; k * k <= N; k++) ans += count(k);
  ans += 1 + (N > 2);

  cout << ans << endl;
}


Measured memory_bytes: 3628
object Main extends App {
  val nd =  scala.io.StdIn.readLine()
  val ndArray = nd.split(" ").map(_.toLong).toSeq
  val n = ndArray(0)
  val d = ndArray(1)

  val dMulti = d * d
  var count = 0

  (1L to n).foreach { _ =>
    val xy =  scala.io.StdIn.readLine()
    val xyArray = xy.split(" ").map(_.toLong).toSeq
    val x = xyArray(0)
    val y = xyArray(1)

    val xMulti = x * x
    val yMulti = y * y

    if ((xMulti + yMulti) <= dMulti) {
      count = count + 1
    }
  }

  println(count)
}

Measured memory_bytes: 58088
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut s = read::<String>().chars().collect::<VecDeque<_>>();
    let mut reversed = false;
    let mut q = read::<usize>();
    let mut queries = vec![];
    for i in 0..q {
        queries.push(read_vec::<String>());
    }
    for query in queries {
        if query[0] == "1" {
            reversed = !reversed;
        } else {
            let ch = query[2].chars().next().unwrap();
            if (query[1] == "1") ^ (reversed) {
                s.push_front(ch);
            } else {
                s.push_back(ch);
            }
        }
    }
    let mut s = s.into_iter().collect::<Vec<_>>();
    if reversed {
        s.reverse();
    }
    for ch in s {
        print!("{}", ch);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, W;
int value[110], weight[110];
int dp[110][10010];

int main() {
   cin >> N >> W;
   rep (i, 0, N) {
      cin >> value[i] >> weight[i];
   }
   rep (i, 0, W+1) {
      dp[0][i] = 0;
   }
   rep (i, 0, N) {
      rep (w, 0, W+1) {
         if (w >= weight[i]) {
            dp[i+1][w] = 
               max(dp[i][w-weight[i]] + value[i], dp[i][w]);
         } else {
            dp[i+1][w] = dp[i][w];
         }
      }
   }
   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7036
import java.util.Scanner;

class Main {

    static int[][] cost = new int[10][10];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int height = sc.nextInt(), width = sc.nextInt();
        int[][] num = new int[height][width];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                cost[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                num[i][j] = sc.nextInt();
            }
        }

        long actual[] = new long[10];

        long sum = 0;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if (num[i][j] == 1 || num[i][j] == -1) {
                    continue;
                } else if (actual[num[i][j]] != 0) {
                    sum += actual[num[i][j]];
                } else {
                    boolean[] visit = new boolean[10];
                    actual[num[i][j]] = search(num[i][j], 0, visit, cost[num[i][j]][1]);
                    sum += actual[num[i][j]];
                }
            }
        }
        System.out.println(sum);
    }

    private static long search(int num, long sum, boolean[] v, long direct) {
        boolean[] visit = new boolean[10];
        for (int i = 0; i < 10; i++) {
            visit[i] = v[i];
        }
        visit[num] = true;
        if (num == 1 || sum >= direct) {
            return sum;
        }
        long min = direct;
        for (int i = 0; i < 10; i++) {
            if (visit[i]) {
                continue;
            }
            long c = search(i, sum + cost[num][i], visit, direct);
            if (c < min) {
                min = c;
            }
        }
        return min;
    }
}


Measured memory_bytes: 48136
#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>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 200005;
const int MM = 998244353;

int N;
int dp[MX][3][3][3][3];
int dp2[MX][3][3][3];

void add(int &x, int y){ x = (x+y >= MM? x+y-MM : x+y); }

bool chk(int a, int b, int c, int A, int B, int C){
	int v = ((a-A)%3 + 3) % 3;
	return (A+v)%3 == a%3 && (B+v)%3 == b%3 && (C+v)%3 == c%3;
}

int main()
{
	int A = 0, B = 0, C = 0, c1 = 0, c2 = 1;
	string S;
	cin >> S;
	for(char c : S){
		A += c == 'a';
		B += c == 'b';
		C += c == 'c';
	}
	for(int i = 0; i+1 < S.size(); i++){
		if(S[i] != S[i+1]) c1 = 1;
		if(S[i] == S[i+1]) c2 = 0;
	}
	if(!c1) return !printf("1\n");
	if(A == 1 && B == 1 && C == 1) return !printf("3\n");
	dp2[0][1][0][0] = 1;
	dp2[0][0][1][0] = 1;
	dp2[0][0][0][1] = 1;
	dp[0][1][0][0][0] = 1;
	dp[0][0][1][0][1] = 1;
	dp[0][0][0][1][2] = 1;
	for(int i = 1; i < S.size(); i++){
		for(int a = 0; a < 3; a++){
			for(int b = 0; b < 3; b++){
				for(int c = 0; c < 3; c++){
					add(dp2[i][a][b][c], dp2[i-1][(a+2)%3][b][c]);
					add(dp2[i][a][b][c], dp2[i-1][a][(b+2)%3][c]);
					add(dp2[i][a][b][c], dp2[i-1][a][b][(c+2)%3]);

					for(int p = 0; p < 3; p++){
						if(p != 0) add(dp[i][a][b][c][0], dp[i-1][(a+2)%3][b][c][p]);
						if(p != 1) add(dp[i][a][b][c][1], dp[i-1][a][(b+2)%3][c][p]);
						if(p != 2) add(dp[i][a][b][c][2], dp[i-1][a][b][(c+2)%3][p]);
					}
				}
			}
		}
	}
	int N = S.size()-1;
	for(int a = 0; a < 3; a++){
		for(int b = 0; b < 3; b++){
			for(int c = 0; c < 3; c++){
				for(int p = 0; p < 3; p++){
					add(dp2[N][a][b][c], MM-dp[N][a][b][c][p]);
				}
			}
		}
	}
	int ans = c2;
	for(int a = 0; a < 3; a++){
		for(int b = 0; b < 3; b++){
			for(int c = 0; c < 3; c++){
				if(chk(a, b, c, A, B, C)) add(ans, dp2[N][a][b][c]);
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 84996
N = int(input())
P = [list(map(int,input().split())) for i in range(N)]

from itertools import permutations, combinations,combinations_with_replacement,product

arr = list(permutations(P))

ans = 0

for p in arr:
    l = 0
    for (x1, y1), (x2, y2) in zip (p, p[1:]):
        l += ((x1-x2)**2 + (y1-y2)**2)**0.5
    ans += l

print(ans/len(arr))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;




int main(){
    LL N;
    cin >> N;
    LL t=0,p=N;
    while(p){
        t+=p%10;
        p/=10;
    }
    if(N%t) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std; 
int main(){
    int r;
    cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r >= 1200 & r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def rec(h,w)
  h.times do |x|
    w.times do |y|
      if x == 0 || x == h - 1 || y == 0 || y == w - 1
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
end

while true
  h, w = gets.chomp.split.map(&:to_i)
  break if w == 0 && h == 0
  rec(h, w)
  puts ""
end



Measured memory_bytes: 6864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int h[110] = {0};

int main(){
    int n; cin >> n;
    rep(i,n){
        cin >> h[i];
    }

    int ans = 0;
    int active = 0;
    rep(i,n){
        if(active >= h[i]){
            active = h[i];
        } else {
            ans += h[i] - active;
            active = h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mian(){
	int n,k;
	cin>>n>>k;
	int h[n+1];
	for(int i=1;i<=n;++i)
		cin>>h[i];
	int a,b;
	bool ok[n+1];
	for(int i=1;i<=n;++i)
		ok[i]=true;
	while(k--){
		cin>>a>>b;
		if(h[a]>h[b])
			ok[b]=false;
		else if(h[b]>h[a])
			ok[a]=false;
		else
			ok[a]=ok[b]=false;
	}
	int tot=0;
	for(int i=1;i<=n;++i)
		tot+=ok[i];
	cout<<tot<<endl;
	return 0;
}
signed main(){
	int t=1;
//	cin>>t;
	while(t--)
		mian();
	return 0;
}

Measured memory_bytes: 4432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath> 
using namespace std;
int a[10005],ans;
bool vis[100005];
inline int get()
{
	char c;
	int x=0,p=1;
	c=getchar();
	while (c<'0'||c>'9') {if (c=='-') p=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*p;
}
int main()
{
	int n,x,y;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		for (int j=x;j<=y;j++)
		    if(!vis[j]) ans++,vis[j]=1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 384
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a,b;
    cin >> a >> b;

    cout << (a*(a-1) + b*(b-1))/2 << endl;
    return 0;
}


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

int main() {
  int Ans = 1e9;  // 回答：
  // string Ans = "Yes";  // 回答：
  int N; cin >> N; // 参加人数
  vector<int> X(N);    // 所在座標
  rep(i,N) { cin >> X.at(i); }
  sort(X.begin(),X.end());

  int tmp_A;  // 総移動距離
  for(int i = X.at(0);i <= X.at(N-1); i++ ){
    if(debug) {cout << "A - i:" << i << endl;}
    tmp_A = 0;
    rep(j,N){
    if(debug) {cout << "B - i:" << i << " j:" << j  << " X(j):" << X.at(j) << endl;}
      tmp_A += pow((i - X.at(j)),2);
    }
    Ans = min(Ans,tmp_A);
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,a=0,b=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='A'){
      a++;
    }else if(s[i]=='B'){
      b++;
    }
  }
  if(a>0 && b>0){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}


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

int main(){

	int n, b, f, r, v;
	int A[5][4][11] = {0};

	cin >> n;

	for(int i = 0; i < n; i++ ){
		cin >> b >> f >> r >> v;
		A[b][f][r] = A[b][f][r] + v; 
		//	ここから入居者数の条件 0以下の場合と9以上の場合
		if(A[b][f][r] > 9) A[b][f][r] = 9;
		if(A[b][f][r] < 0) A[b][f][r] = 0;
	}

	for(int i = 1; i <= 4; i++){
		for(int j = 1; j <= 3; j++){
			for(int k = 1; k <=10; k++){
				cout << " " << A[i][j][k];
			}
			cout << endl;
		}
		if(i < 4)cout << "####################" << endl;
	}
	

	return 0;
}


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




int main() {
  string a;
  cin>>a;
  int k=0;
  if(a.at(0)=='7'){k=1;}
if(a.at(1)=='7'){k=1;}
  if(a.at(2)=='7'){k=1;}
if(k==0){cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}

}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <algorithm>
#include <math.h>

using namespace std;

#define dump(x) cout << (x) << endl;
typedef long long Int;

Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    Int a, b, c;
    cin >> a >> b >> c;
    Int res = 0;
    Int tmp = min(b, c);
    b -= tmp;
    c -= tmp;
    res += tmp*2;
    if (c == 0) res += b;
    else if (b == 0) {
        res += min(a, c);
        if (a < c) res++;
    }
    dump(res);
    return 0;
}  

Measured memory_bytes: 256
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//* vamsicool007    You are never wrong to do the right thing    vamsicool007 *
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const int N=200005;
vector<int>vis(N);
vector<vector<int>>adj(N);
void dfs(int v){vis[v]=1;for(auto i:adj[v]){if(!vis[i]){dfs(i);}}return;}
bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
int root(int a[],int i){while(a[i]!=i){a[i]=a[a[i]];i=a[i];}return i;}
void unionn(int a[],int i,int j){int root_i=root(a,i);int root_j=root(a,j);a[root_i]=root_j;return;}

signed main()
{
    flash;
    //fun();
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int n=s.size();
        int f=0;
        for(int i=0;i<n/2;i++)
        {
        	if(s[i]!=s[n-i-1])
        		{f=1;break;}
        }
        if(!f)
        {
        	int m=(n-1)/2;
        	int f1=0;
        	for(int i=0;i<(n-1)/4;i++)
        	{
        		if(s[i]!=s[m-1-i])
        			{f1=1;break;}
        	}
        	int j=(n+3)/2;
        	int k=(2*n+3)/4;
        	int f2=0;
        	for(int i=j;i<k;i++)
        	{
        		if(s[i]!=s[k-i-1])
        			{f2=1;break;}
        	}
        	if(!f1&&!f2)
        		cout<<"Yes";
        	else
        		cout<<"No";
        }
        else
        	cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define int long long int
using namespace std;

int32_t main() {
    
    double n;
    cin >> n;
    
    double x=(n/1.08),y=((n+1)/1.08);
    
    for(int i=(int)x-5;i<=(int)y+5;i++) {
        if((int)(i*1.08)==n){
        cout << i;
        return 0;
        }
    }
    cout << ":(";
    
    return 0;
}

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

using namespace std;

int n;
vector<int> v;

void swap(int &a, int &b){
	int tmp = a;
	a = b;
	b = tmp;
}

int SelectionSort(){
    if(n == 1) return 0;
	int cnt = 0, minv;
	int num;
	for(int i=0;i < n;++i){
		minv = 100;
		for(int j=i+1;j < n;++j){
			if(v[j] < minv){
				num = j;
				minv = v[j];
			}
		}
		if(v[i] > v[num]){
			swap(v[i], v[num]);
			cnt++;
		}
	}
	return cnt;
}

int main(){
	cin >> n;
	int vin;
	for(int i=0; i<n; ++i){
		cin >> vin;
		v.push_back(vin);
	}

	int ans = SelectionSort();
	for(int k=0;k < n;++k){
		cout << v[k];
		if(k != n-1) cout << " ";
	}
	cout <<endl;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3164
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;




int main() {

string S;
cin>>S;
int table[12];
table[0]=1;

rep2(i,1,12){
table[i]=(table[i-1]*10)%13;
}
ll dp[S.size()][13];
rep(i,S.size()){
  rep(j,13){
    dp[i][j]=0;
  }
}
if(S[S.size()-1]=='?'){
  rep(i,10){
    dp[0][i]=1;
  }

}
else{
rep(i,13){
if(i==S[S.size()-1]-'0'){
dp[0][i]=1;
}

}
}


rep2(i,1,S.size()){
if(S[S.size()-i-1]=='?'){
  rep(j,10){
    rep(k,13){
      dp[i][(table[i%12]*j+k)%13]+=dp[i-1][k];
      dp[i][(table[i%12]*j+k)%13]%=mod;
      
      
    }
    
  }
}
else{
  rep(k,13){
    dp[i][(table[i%12]*(S[S.size()-i-1]-'0')+k)%13]+=dp[i-1][k];
    dp[i][(table[i%12]*(S[S.size()-i-1]-'0')+k)%13]%=mod;
  }
}
}

cout<<dp[S.size()-1][5]<<endl;
return 0;
}

Measured memory_bytes: 13896
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=3100;
ll r,c,tk,mat[maxn][maxn], dp[maxn][maxn][5];
int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif
    memset(mat,0,sizeof(mat));
    memset(dp,0,sizeof(dp));
    cin>>r>>c>>tk;
    for(int i=0; i<tk; ++i){
        ll u,v,w;
        cin>>u>>v>>w;
        mat[u][v]=w;
    }
    dp[1][1][0]=0;
    dp[1][1][1]=mat[1][1];
    for(int i=1; i<=r; ++i){
        for(int j=1; j<=c; ++j){
            for(int k=0; k<=3; ++k){
                if(i+1<=r) {
                    dp[i+1][j][0]=max(dp[i+1][j][0], dp[i][j][k]);
                    if(mat[i+1][j]>0) dp[i+1][j][1]=max(dp[i+1][j][1], dp[i][j][k]+mat[i+1][j]);
                }
                if(j+1<=c){
                    dp[i][j+1][k]=max(dp[i][j+1][k], dp[i][j][k]);
                    if(k+1<=3 && mat[i][j+1]>0) dp[i][j+1][k+1]=max(dp[i][j+1][k+1], dp[i][j][k]+mat[i][j+1]);
                }
            }
        }
    }
    cout<<max({dp[r][c][0], dp[r][c][1], dp[r][c][2], dp[r][c][3]})<<'\n';
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 454104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
	
typedef long long v;
typedef long long b;

static const int MAX = 200000;


int main() {
	int n;
	bool s=true;
	cin >> n;
	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == "Y") {
			cout << "Four";
			s = false;
			break;
		}
		else {
			continue;
		}

	}
	if (s) {
		cout << "Three";
	}
	return 0;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


template<typename Monoid,typename OperatorMonoid,typename F,typename G,typename H>
struct Segtree{
	int size=1;
	vector<Monoid>dat;
	vector<OperatorMonoid>lazy;
	const F f;
	const G g;
	const H h;
	Monoid M;
	OperatorMonoid OM;
	void set(int a,Monoid x){
		dat[a+size-1]=x;
	}
	void init(){
		for(int i=size-2;i>=0;i--){
			dat[i]=f(dat[i*2+1],dat[i*2+2]);
		}
	}
	void eval(int k,int l,int r){
		if(lazy[k]!=OM){
			dat[k]=g(dat[k],lazy[k],(r-l));
			if(r-l>1){
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			lazy[k]=OM;
		}
	}
	void update(int a,int b,OperatorMonoid M,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=h(lazy[k],M);
			eval(k,l,r);
			return;
		}
		update(a,b,M,k*2+1,l,(l+r)/2);
		update(a,b,M,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return M;
		if(a<=l&&r<=b)return dat[k];
		Monoid lv=query(a,b,k*2+1,l,(l+r)/2);
		Monoid rv=query(a,b,k*2+2,(l+r)/2,r);
		return f(lv,rv);
	}
	Segtree(int x,F f,G g,H h,Monoid M,OperatorMonoid OM)
	:f(f),g(g),h(h),M(M),OM(OM){
		while(size<x)size*=2;
		dat.resize(size*2-1,M);
		lazy.resize(size*2-1,OM);
	}
};

int N,M;
vector<P>v[200005];
signed main(){
	cin>>N>>M;
	auto f=[](int a,int b){return max(a,b);};
	auto g=[](int a,int b,int sz){return a+b;};
	auto h=[](int a,int b){return a+b;};
	Segtree<int,int,decltype(f),decltype(g),decltype(h)>segtree(N,f,g,h,0,0);
	rep(i,M){
		int l,r,m;cin>>l>>r>>m;l--;r--;
		v[r].pb({l,m});
	}
	rep(i,N){
		segtree.update(i,i+1,max(0ll,segtree.query(0,i)));
		for(P j:v[i]){
			segtree.update(j.first,i+1,j.second);
		}
	}
	cout<<max(0ll,segtree.query(0,segtree.size))<<endl;
}


Measured memory_bytes: 22456