akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

class LCA {
private:
    int n,ln;
    vector<vector<int> > parent;
    vector< vector<int> > G;
public:
    vector<int> depth;
    
    LCA(int _n) : n(_n), depth(_n){
        ln=0;
        while(n>(1<<ln)) ln++;
        parent = vector<vector<int> >(ln, vector<int>(n));
        G.resize(_n+10);
    }
    
    void dfs(int v, int p, int d){
        parent[0][v]=p;
        depth[v]=d;
        for(int i=0;i<G[v].size();i++) if(G[v][i]!=p) dfs(G[v][i], v, d+1);
    }
    
    int dist(int a, int b){
        int par=getParent(a,b);
        return depth[a]+depth[b]-depth[par]*2;
    }
    
    void init(int root){
        dfs(root, -1, 0);
        for(int k=0; k+1<ln; k++){
            for(int v=0; v<n; v++){
                if(parent[k][v] < 0) parent[k+1][v] = -1;
                else parent[k+1][v] = parent[k][parent[k][v]];
            }
        }
    }
    
    void add_edge(int a, int b){
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    int getParent(int u, int v){
        if(depth[u] > depth[v]) swap(u,v);
        for(int k=0; k<ln; k++){
            if((depth[v]-depth[u])>>k & 1) v = parent[k][v];
        }
        if(u==v) return u;
        
        for(int k=ln-1; k>=0; k--){
            if(parent[k][u] != parent[k][v]){
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};


int main(){
    
    int n; cin>>n;
    
    LCA inst(100010);
    REP(i,n){
        int k; cin>>k;
        REP(j,k){
            int t; cin>>t;
            inst.add_edge(i,t);
        }
    }
    
    inst.init(0);
    
    int q; cin>>q;
    REP(i,q){
        int a,b; cin>>a>>b;
        cout<<inst.getParent(a,b)<<endl;
    }
   
    
    return 0;
}

Measured memory_bytes: 18060
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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

    vector<int> ans(N+1);
    ans[N] = 0;

    for(int i = N;i >= 1;--i){
        int tmp = 0;
        for(int j = 1;j*i <= N;++j){
            tmp += ans[j*i];
        }
        tmp %= 2;
        if(tmp == a[i])ans[i] = 0;
        else ans[i] = 1;
    }
    int ct = 0;
    rep(i,N+1)if(ans[i])ct++;
    cout << ct << endl;
    int ct2 = 0;
    for(int i = 1;i <= N;++i){
        if(ct2 <= ct && ans[i]){
            cout << i << " ";
            ct2++;
        }
    }
}



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

int main() {
    int X;
    cin >> X;
    int res=1;
    for (int b=2; b<=X; b++) {
        int c=b;
        while (true) {
            c = c*b;
            if (c<=X) {
                res = max(res, c);
            }
            else break;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int x, y;
    cin >> x >> y;
   	if((y % 4 == 0 || (y % 4) % 2 == 0) || (y % 2) == 0) {
   		int min = ((y - (y % 4)) / 4) + ((y % 4) / 2);
   		int max = y / 2;
   		debug_out(min, max, x);
   		if(x <= max and x >= min) cout << "Yes" << endl;
   		else cout << "No" << endl;
   	} else cout << "No" << endl;
}
  
int32_t main() {
 
    FAST;

  
    
    Panda();

    return 0; 
} 


Measured memory_bytes: 3700
n=int(input())
a=list(map(int,input().split()))
b_2=0
b_4=0
b_0=0
for i in a:
    if i%4==0:
        b_4+=1
    elif i%2==0:
        b_2+=1
    else:
        b_0+=1
if b_2==0:
    if b_0<=b_4+1:
        print("Yes")
    else:
        print("No")
else:
    if b_0<=b_4:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15020
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    string ans = "APPROVED";
    rep(i, N) {
        if(A.at(i) % 2 == 0 && A.at(i) % 3 !=  0 && A.at(i) % 5 != 0) {
            ans = "DENIED";
        }
    }

    cout << ans << endl;

    return 0;
}


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

// DATA TYPES
typedef long long ll;
#define double long double
//

// CONTAINERS
#define vec vector
#define pb push_back
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)x.size()
#define mp make_pair
#define ii pair<int, int>
#define F first
#define S second
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &L, const std::pair<T,U> &R) {
  return {L.first + R.first, L.second + R.second};
}
//

// LOOP
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
//

// BIT
#define bitcount(n) __builtin_popcountll(n)
//

// DEBUG
#define format(x) << #x << ": " << (x)
#define com << ", "
#define ndl << "\n"
#define debug1(x) cerr format(x) ndl;
#define debug2(x, y) cerr format(x) com format(y) ndl;
#define debug3(x, y, z) cerr format(x) com format(y) com format(z) ndl;
void debug_out() { cerr << "\n"; }
template <typename H, typename... T> 
void debug_out(H h, T... t) { cerr << " " << (h); debug_out(t...); }
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
// 

// CONSTANTS
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
//

// NUMERICAL OPERATIONS
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

int norm(int a) {
  return ((a % MOD) + MOD) % MOD;
}

int mul(int a, int b) {
  return int(a * 1LL * b % MOD);
}

int binPow(int a, int k) {
  int ans = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
  }
  return ans;
}

// If I need to find (x / a) % MOD, I need to use this function:
//    (x / a) % MOD = (x * inv(a)) % MOD
int inv(int a) {
  int b = binPow(a, MOD - 2);
  assert(mul(a, b) == 1);
  return b;
}
//

// Init variables here
const int N = 1e6 + 7;

void init() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);

}

int correct[N];

void solve() {
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  int a;
  FOR(i, 0, q) {
    scanf("%d", &a);
    correct[a - 1]++;
  }
  int score;
  FOR(i, 0, n) {
    score = k - (q - correct[i]);
    //debug1(score);
    printf(score <= 0 ? "No\n" : "Yes\n");
  }
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  //ios_base::sync_with_stdio(false); cin.tie();
  //auto beginProgram = chrono::steady_clock::now();
  //int t; scanf("%d", &t); while (t--) 
  {
    init();
    solve();
  }
  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<algorithm>
#define MN 2100001
using namespace std;

int n,m,a[MN],x,y,fa[MN],s[MN],d[MN]; 
vector<int> v[MN];
void dfs(int x,int f){
	fa[x]=f;s[x]=1;
	for (int i=0;i<v[x].size();i++)
	if (v[x][i]!=f){
		d[v[x][i]]=d[x]+1;
		dfs(v[x][i],x);
		s[x]+=s[v[x][i]];
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);v[y].push_back(x);
	}
	dfs(1,0);
	x=n;y=d[x]-(d[x]-1>>1);
	while (d[x]!=y) x=fa[x];
	if (n-s[x]>s[x]) puts("Fennec");else puts("Snuke");
}

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

int main() {
	long long N, M; cin >> N >> M;
	long long E = M, maxn = 0;
	for (long long i = 1; i * i <= E; i++) {
		if (E%i != 0) continue;
		if (M / N >= i) maxn = max(maxn, i);
		if (M / N >= (E / i)) maxn = max(maxn, E / i);
	}
	cout << maxn << endl;
	return 0;
}

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

	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		int lectcnt=0;
		int diacnt=0;
		while(str!=null){
			String[] lengthstr=str.split(",");
			int[] length=new int[3];
			for(int i=0;i<3;i++)
				length[i]=Integer.parseInt(lengthstr[i]);
			if(Math.pow(length[0], 2)+Math.pow(length[1],2)==Math.pow(length[2],2))
				lectcnt++;
			if(length[0]==length[1])
				diacnt++;
			str=br.readLine();
		}
		System.out.println(lectcnt);
		System.out.println(diacnt);
	}

}

Measured memory_bytes: 23988
import sys
sys.setrecursionlimit(10**7)
class Scc:
    def __init__(self, Edge):
        self.Edge = Edge
        self.N = len(Edge)
        self.Edgeinv = [[] for _ in range(self.N)]
    
    def decomposition(self):
        for i in range(self.N):
            for e in Edge[i]:
                self.Edgeinv[e].append(i)
        
        self.order = []
        self.used = set()
        for i in range(self.N):
            if i not in self.used:
                self.dfs1(i)
        
        self.res = [None]*self.N
        self.cnt = -1
        
        self.used = set()
        for v in self.order[::-1]:
            if v not in self.used:
                self.cnt += 1
                self.dfs2(v)
         
        n = self.cnt + 1
        components = [[] for _ in range(n)]
        for i in range(self.N):
            components[self.res[i]].append(i)
         
        cEdge = [[] for _ in range(n)]
        cset = set()
        for i in range(self.N):
            for e in Edge[i]:
                if self.res[i] != self.res[e] and self.res[i] + self.N*self.res[e] not in cset:
                    cset.add(self.res[i] + self.N*self.res[e])
                    cEdge[self.res[i]].append(self.res[e])
         
        return self.res, components, cEdge
    
    def dfs1(self, v):
        self.used.add(v)
        for vf in self.Edge[v]:
            if vf not in self.used:
                self.used.add(vf)
                self.dfs1(vf)
        self.order.append(v)
    
    def dfs2(self, v):
        self.used.add(v)
        self.res[v] = self.cnt
        stack = [v]
        while stack:
            vn = stack.pop()
            for vf in self.Edgeinv[vn]:
                if vf not in self.used:
                    self.used.add(vf)
                    self.res[vf] = self.cnt
                    stack.append(vf)
        
V, E = map(int, input().split())
Edge = [[] for _ in range(V)]
for _ in range(E):
    a, b = map(int, sys.stdin.readline().split())
    Edge[a].append(b)

G = Scc(Edge)
R, _, _ = G.decomposition()
Q = int(input())
for _ in range(Q):
    a, b = map(int, sys.stdin.readline().split())
    if R[a] == R[b]:
        sys.stdout.write('1\n')
    else:
        sys.stdout.write('0\n')



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

int main(void){
	char str[25],temp;
	int i,len;

	scanf("%s",str);
	len=strlen(str);

	for(i=0;i<=(len-1)/2;i++){
		temp=str[i];
		str[i]=str[len-1-i];
		str[len-1-i]=temp;
	}

	printf("%s\n",str);

	return 0;
}

Measured memory_bytes: 524
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> ans;
    ll v = (N + A-1) / A;
    if(B >= v && B <= N-A+1){
        ll diff = B - v;
        ll amari = N % A;
        ll cnt = 0;
        ll cur = 1;
        while(diff > 0){
            if(cur % A != amari){
                cur++;
                diff--;
            }else{
                cur++;
            }
        }
        diff = cur-1;
        // if(A != 1){
        //     ll t2 = diff / (A-1);
        //     diff = t2 * A + diff % (A-1);
        // }
        rep(i,0,v){
            rep(j,0,A){
                ll val = (N - (i+1)*A + 1) + j;
                if(val > diff) ans.push_back(val);
            }
        }
        rrep(i,diff,1) ans.push_back(i);
        printa(ans, N);
    }else{
        print(-1);
    }


}

Measured memory_bytes: 6384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
int N_MAX = 100001;
int p=1000000007;
int main()
{
  int n,k,a,b,i,ii,c;
  long long res;
  int u[N_MAX];
  vector<int> v[N_MAX];
  stack<int> s;
  cin >> n >> k;
  for(i=0;i<n-1;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  fill(u+1,u+n+1,0);
  c=v[1].size();
  res=k;
  for(ii=0;ii<c;ii++){
    res*=k-1-ii;
    res=res%p;
    s.push(v[1][ii]);
  }
  u[1]=1;
  while(!s.empty()){
    i=s.top(); s.pop();
    c=v[i].size()-1;
    for(ii=0;ii<c;ii++){
      res*=k-2-ii;
      res=res%p;
      if(u[v[i][ii]]==0)
        s.push(v[i][ii]);
    }
    if(u[v[i][c]]==0)
      s.push(v[i][c]);
    u[i]=1;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} 
char ch[100]; int n, len = 1e9, c[100]; string s[100];
inline int ask (string str){
	if (str.size() > 128) return 1e9;
	cout << '?' << ' ' << str << '\n';
	fflush(stdout); int ans = 0; read (ans); return ans;
}
inline string merge (string a, string b) {
	int i = 0, j = 0, la = a.size(), lb = b.size();
	string res = string (); 
	while (i < la && j < lb) {
		string tmp = res + a[i];
		for (int k = j; k < lb; ++k) tmp += b[k];
		res += (ask (tmp) + tmp.size() == len) ? a[i++] : b[j++];
	} while (i < la) res += a[i++]; while (j < lb) res += b[j++];
	return res;
}
signed main() {
	for (int i = 0; i < 10; ++i) ch[++n] = '0' + i;
	for (int i = 0; i < 26; ++i) ch[++n] = 'a' + i;
	for (int i = 0; i < 26; ++i) ch[++n] = 'A' + i;
	//查询单个字符，得出串的长度 
	for (int i = 1; i <= n; ++i) {
		s[i] += ch[i]; len = min (len, (c[i] = ask (s[i]) + 1));
	}
	//找出每个字符出现次数
	for (int i = 1; i <= n; ++i)
		if (c[i] != len) s[i] = string ();
		else while (ask (s[i] + ch[i]) + s[i].size() + 1 == len) s[i] += ch[i];
	//合并得出答案 
	while (1) {
		for (int i = 1; i <= n; ++i)
			for (int j = i + 1; j <= n; ++j)
				if (s[i].size() > s[j].size()) swap (s[i], s[j]);
		int l = 1; while (!s[l].size()) ++l;
		if (l == n) break;
		s[l + 1] = merge (s[l], s[l + 1]); s[l] = string ();
	} cout << '!' << ' ' << s[n] << '\n'; fflush (stdout);
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int n,k;
    	cin>>n>>k;
    	long long a[n];
    	for(int i=0;i<n;i++)
    	cin>>a[i];long long dp[n],mi;dp[0]=0;
    	for(int i=1;i<n;i++)
    	{
    	    mi=10000000000;
    	    for(int j=i-1;j>=0&&j>=i-k;j--)
    	    {
    	        mi=min(mi,dp[j]+abs(a[j]-a[i]));
    	    }dp[i]=mi;
    	}cout<<dp[n-1]<<endl;
    	return 0;
    }

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    int ans = 1;
    for (int i = 0; i < N - 1; i++)
    {
        if (a.at(i) != a.at(i + 1))
            ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef pair<long long,long long> pll;
typedef long long ll;
const int inf   = 1<<30-1;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

vector<int> v[100001],a;
bool used[100001];
void dfs(int x){
  rep(i,v[x].size()){
    if(!used[v[x][i]]){
      used[v[x][i]]=true;
      a.push_back(v[x][i]);
      dfs(v[x][i]);
      break;
      }
    }
  }

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,n)used[i+1]=false;
  int l,r;
  rep(i,m){
    cin>>l>>r;
    v[l].push_back(r);
    v[r].push_back(l);
    }
  used[1]=true;
  dfs(1);
  reverse(a.begin(),a.end());
  a.push_back(1);
  dfs(1);
  cout<<a.size()<<endl;
  rep(i,a.size())
    cout<<a[i]<<" ";
  cout<<endl;
  return 0;
  
  
  }


Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool isok(string s){
    int l = s.size();
    rep(i, l/2){
        if(s[i] != s[l-1-i]) return false;
    }
    return true;
}

int main(){
    string s; cin >> s;
    int n = s.size();
    bool ans = true;
    if(!isok(s)) {
        ans = false;
    }
    string z = s.substr(0, (n-1)/2);
    string k = s.substr((n+1)/2);
    if(!isok(z) || !isok(k)){
        ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <string> v;
string s;
vector<int> ans;
int men[51] = {0};
int main(){
  int n, p;

  cin >> n >> p;
  while((n != 0)&&(p != 0)){
    int men[51] = {0};
    int s =(int)ans.size();
    int z = p;
    while(true){
      for (int i = 0;i<n;i++){
        if(z == 0){
          z += men[i];
          men[i] = 0;
        }else{
        men[i]++;
        z--;
      }
        if(men[i] == p){
          ans.push_back(i);
          break;
        }
      }
      if(s != (int)ans.size())break;
    }
      cin >> n >> p;
  }
  for (int i = 0;i<(int)ans.size();i++){
    cout << ans[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3000
import java.util.Scanner;
/**
 * ABC129 B
 *
 */
public class Main {

    public static void main(String[] args) {
        int N = 0;
        int[] W = null;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            W = new int[N];
            for(int i = 0; i<N; i++){
                W[i] = sc.nextInt();
            }

        }
        //全体の和
        int Sum =0;
        for(int i : W){
            Sum += i;
        }

        //差が最小添え字（暫定）
        int T = 0;
        //差（暫定） (いったんsumで初期化)
        int d = Sum;
        //添え字までの合計
        int sumT = 0;
        for(int i = 0;i < N;i++){
            sumT += W[i];
            //絶対値計算
            int temp = 0;
            if((Sum -sumT)>sumT){
                temp = (Sum -sumT) -sumT;
            }else{
                temp = sumT - (Sum -sumT);
            }
            //これまでの差分より小さい場合
            if(d>temp){
                //更新する
                d = temp;
                T = i +1;
            }
        }
        System.out.println(d);


    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


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

    lli sum = 0;
    repA(i, 1, K){
        repA(j, 1, K){
            int t = gcd(i, j);
            repA(k, 1, K){
                // cout << sum << endl;
                sum += gcd(t, k);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3644
x,y = map(int,input().split())

def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y)

def gcd(x,y):
    if x < y:
        x,y= swap(x,y)

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x)

gcd(x,y)



Measured memory_bytes: 5600
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {              
     Scanner sc = new Scanner(System.in);                
     
     long x = sc.nextLong();
     
     long a = x/11;          
     
     long count = a*2;
     
     if(x%11 > 6){
         count += 2;
     }else if(x%11 > 0){
         count++;
     }
     
     System.out.println(count);          
     
  }          
}

Measured memory_bytes: 22612
// #define NDEBUG

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,bmi,bmi2,lzcnt")
#endif

#include <bits/extc++.h>
#include <x86intrin.h>

#define ALL(c) begin(c), end(c)
#ifndef DUMP
#define DUMP(...) void(0)
#endif

using namespace std;

struct rep {
  struct iterator {
    int i;
    iterator& operator++() { return ++i, *this; }
    int operator*() const { return i; }
    friend bool operator!=(iterator a, iterator b) { return a.i != b.i; }
  };
  int l, r;
  rep(int _l, int _r) : l(min(_l, _r)), r(_r) {}
  rep(int n) : rep(0, n) {}
  iterator begin() const { return {l}; }
  iterator end() const { return {r}; }
};
struct per {
  struct iterator {
    int i;
    iterator& operator++() { return --i, *this; }
    int operator*() const { return i; }
    friend bool operator!=(iterator a, iterator b) { return a.i != b.i; }
  };
  int l, r;
  per(int _l, int _r) : l(min(_l, _r)), r(_r) {}
  per(int n) : per(0, n) {}
  iterator begin() const { return {r - 1}; }
  iterator end() const { return {l - 1}; }
};
template <class T>
constexpr T inf = numeric_limits<T>::max() / 2;
auto chmin = [](auto&& a, auto b) { return b < a ? a = b, true : false; };
auto chmax = [](auto&& a, auto b) { return a < b ? a = b, true : false; };
auto sz = [](auto&& c) -> int { return size(forward<decltype(c)>(c)); };
template <class F>
struct y_combinator : F {
  y_combinator(F f) : F(f) {}
  template <class... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (auto&& e : a) cin >> e, --e;

  vector dp(n, vector(n, -inf<int>));
  vector max_dp(n, -inf<int>);
  int offset = 0;

  vector<array<int, 3>> v;
  auto lazy_update = [&](int p, int q, int val) -> void {
    v.push_back({p, q, val});
  };
  auto push_all = [&]() -> void {
    while (sz(v)) {
      auto [p, q, val] = v.back();
      chmax(dp[p][q], val);
      chmax(dp[q][p], val);
      chmax(max_dp[p], val);
      chmax(max_dp[q], val);
      v.pop_back();
    }
  };

  lazy_update(a[0], a[1], 0);
  push_all();

  for (int i : rep(n - 1)) {
    sort(begin(a) + (i * 3 + 2), begin(a) + (i * 3 + 5));
    int x = a[i * 3 + 2];
    int y = a[i * 3 + 3];
    int z = a[i * 3 + 4];
    if (x == z) {
      ++offset;
      continue;
    }
    if (x == y) {
      for (int p : rep(n)) lazy_update(p, z, dp[p][y] + 1);
    }
    if (y == z) {
      for (int p : rep(n)) lazy_update(p, x, dp[p][y] + 1);
    }
    for (int e : {x, y, z}) {
      for (int p : rep(n)) lazy_update(p, e, max_dp[p]);
    }
    auto max_all = *max_element(ALL(max_dp));
    lazy_update(x, y, max_all);
    lazy_update(x, z, max_all);
    lazy_update(y, z, max_all);
    lazy_update(y, z, dp[x][x] + 1);
    lazy_update(x, z, dp[y][y] + 1);
    lazy_update(x, y, dp[z][z] + 1);
    push_all();
  }

  int res = -inf<int>;
  for (int p : rep(n))
    for (int q : rep(n))
      chmax(res, offset + dp[p][q] + (p == q and q == a.back()));
  cout << res << '\n';
}


Measured memory_bytes: 19476
#include <vector>
#include <stack>
#include <iostream>
#include <bitset>

using namespace std;

#define MAX_N 200000
#define MAX_M 200000

int N, M, K;
int64_t A[MAX_N+1], a[MAX_N+1];
int64_t B[MAX_M+1], b[MAX_M+1];

void input() {
    a[0]=0;
    b[0]=0;
    A[0]=0;
    B[0]=0;
    cin >> N >> M >> K;
    for (int i=0;i<N;i++) {
        cin>>A[i+1];
        a[i+1]=A[i+1]+a[i];
    }
    for (int i=0;i<M;i++) {
        cin>>B[i+1];
        b[i+1]=B[i+1]+b[i];
    }
}

void solve() {
    //A[0]~A[i]の和a[i]
    //B[0]~B[j]の和b[i]
    //a[i]+b[j]<=K min? の条件下でi+jを最大とする。
    int ans = 0;
    int j = M;
    for (int i=0;i<N+1;i++){
        if (a[i]>K){
            break;
        }
        while (b[j] > K-a[i]){
            j--;
        }
        ans = max(ans,i+j);
    }
    cout << ans << endl;
}

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 9368
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    double n, m, d;
    cin >> n >> m >> d;

    cout << fixed;

    if (d == 0) {
        cout << fixed << setprecision(10) << (m-1) / n << endl;
    } else {
        cout << fixed << setprecision(10) << (2 * (n-d) * (m-1)) / n / n << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int n;
vector<ll> a(200000);
vector<ll> s(200001); // iまでの累積和
const int MOD = 1e9 + 7;

int main() {
  cin >> n;
  s[0] = 0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    s[i+1] = (s[i] + a[i]) % MOD;
  }
  
  long long ans = 0;
  for (int i = 0; i < n-1; i++) {
    ans += (a[i] * (s[n] - s[i+1] + MOD)) % MOD;
  }
  
  cout << ans % MOD;
}

Measured memory_bytes: 5824
#include <bits/stdc++.h>
	
using namespace std;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

template<class F, class S> ostream& operator<<(ostream& os, pair<F, S> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
 
template<class T> ostream& operator<<(ostream& os, set<T> &v) {
	os << "(";
	for(auto &i : v) cout << i << ",";
	os << ")";
	return os;
}
 
template<class T> ostream& operator<<(ostream& os, vector<T> &v) {
	os << "(";
	if(v.size()) os << v[0];
	for(int i = 1; i < v.size(); ++i) os << "," << v[i];
	os << ")";
	return os;
}

/*----------------------------------------------------------------------------*/

int main (){
	// FAST_IO();

	int n;
	cin >> n;

	cout << n/3 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = na()
for ai in a:
    if ai % 2 == 0 and ai % 3 != 0 and ai % 5 != 0:
        print("DENIED")
        quit()
print("APPROVED")

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

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<vector<char>> v(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      char c; cin >> c;
      v[i][j] = c;
    }
  }
  int ans = 0;
  rep(s, 1<<h) {
    rep(t, 1<<w) {
      int cnt = 0;
      rep(i, h) {
        rep(j, w) {
          if (s & 1 << i) continue;
          if (t & 1 << j) continue;
          if (v[i][j] == '#')
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
   }
   cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
n = int(input())
A = [int(i) for i in input().split()]
B = [A[0]]
for i in range(n - 2):
    if (B[-1] <= A[i + 1] <= A[i + 2]) | (B[-1] >= A[i + 1] >= A[i + 2]):
        continue
    else:
        B.append(A[i + 1])
if B[-1] < A[-1]:
    B.append(A[-1])
if len(B) > 1:
    if B[0] > B[1]:
        B = B[1:]
if len(B) % 2 == 1:
    B = B[:-1]
money = 1000
now = 0
for i in range(len(B) - 1):
    if B[i] < B[i + 1]:
        now += money // B[i]
        money -= (money // B[i]) * B[i]
    else:
        money += now * B[i]
        now = 0
if len(B) > 0:
    money += now * B[-1]    
print(money)

Measured memory_bytes: 9204
'use strict';
function main(input) {
  input = input.split(" ");
  const K = Number(input[0]);
  const X = Number(input[1]);
  let rtn = [];
  for(let i=0; i<K; i++){
  	rtn.push(X + i);
  }
  for(let i=1; i<K; i++){
  	rtn.unshift(X - i);
  }
  console.log(rtn.join(" "));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 23348
import java.io.*;

public class Main {

	private static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while (null != (str = in.readLine())) {//入力の終わりまで
			doit(Integer.parseInt(str));
		}
	}

	private static void doit(int n) {
		count = 0;
		for (int i = 1; i <= n; i++) {
			if(isPrime(i))count++;
		}
		System.out.println(count);
	}

	private static boolean isPrime(int n) {//素数判定メソッド
		if (n < 2)
			return false;
		else if (n == 2)
			return true;

		if (n % 2 == 0)
			return false;

		for (int i = 3; i <= n / i; i += 2)
			if (n % i == 0)
				return false;
		return true;
	}
}

Measured memory_bytes: 18720
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

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


	ll N = 0, K = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') N = N * 10 + c - '0';
	while ((c = getchar_unlocked()) >= '0') K = K * 10 + c - '0';

	int A[200001];
	int D2[200001];
	rep1(i, N) A[i] = getint();

	int d = 0;
	int p = 1;
	while (A[p] > 0) {
		D2[d] = p;
		int tugi = A[p];
		A[p] = -d++;
		p = tugi;
	}
	if (K > -A[p]) {
		ll k = K + A[p];
		k %= d + A[p];
		K = -A[p] + k;
	}
	printf("%d", D2[K]);

	Would you please return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define flood(arr, char, size) for (int i=0; i<size; i++) arr[i] = char
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 1e5 + 2;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    int n, m;
    cin >> n >> m;
    int occ[n];
    flood(occ, 0, n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        occ[--a]++;
        occ[--b]++;
    }
    for (int i=0; i<n; i++) cout << occ[i] << "\n";
    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  int i;
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll add_a = 0;
  ll add_b = 0;
  rep(i,n-1)
  {
    if(a[i] == b[i]) continue;
    else if(a[i] > b[i])
    {
      if(add_b+b[i] >= a[i])
      {
        add_b -= (a[i]-b[i]);
      }
      else
      {
        b[i] += add_b;
        add_b = 0;
        add_a += (a[i]-b[i])*2;
      }
    }
    else
    {
      if(add_a >= b[i]-a[i])
      {
        add_a -= (b[i]-a[i]);
        if((b[i]-a[i])%2 == 1)
        {
          add_a--;
          if(add_b > 0)
          {
            add_b--;
          }
          else
          {
            add_a += 2;
          }
        }
      }
      else
      {
        a[i] += add_a;
        add_a = 0;
        ll dis = abs(a[i]-b[i]);
        if(dis%2 == 1)
        {
          add_b += (dis+1)/2;
          add_b--;
        }
        else
        {
          add_b += dis/2;
        }
      }
    }
  }
  if(a[n-1]+add_a <= b[n-1]+add_b) cout << "Yes" << endl;
  else cout << "No" << endl;

}



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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t =  a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int bit_counter(int x) {
  if (x == 0) return 0;
  return bit_counter(x >> 1) + (x&1);
}


int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll x = min(N, B-1);
  ll result = (x * A) / B;
  print(result);
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

int main() {
    ll ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;

    ll K = 0;
    K += ai / 2 * 2;
    K += aj / 2 * 2;
    K += al / 2 * 2;
    if (ai > 0 && aj > 0 && al > 0) {
        if ((ai % 2) + (aj % 2) + (al % 2) == 3) {
            K += 3;
        } else if ((ai % 2) + (aj % 2) + (al % 2) == 2) {
            K += 3;
            K -= 2;
        }
    }

    K += ao;
    cout << K << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
      if(line.equals("SSS")) {
            System.out.println("0");
      } else if (line.equals("RRR")) {
            System.out.println("3");
      } else if (line.equals("SRR")) {
            System.out.println("2");
      } else if (line.equals("RRS")) {
            System.out.println("2");
      } else{
            System.out.println("1");
      }
    }
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    string s;
    int k;
    cin >> k >> s;
    if(s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        string t = s.substr(0, k) + "...";
         cout << t << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main()
{
  char a[100];
  scanf("%s", a);
  if(a[0]=='S')
  printf("Cloudy\n");
  else if(a[0]=='C')
    printf("Rainy\n");
  else if(a[0]=='R')
    printf("Sunny\n");
  return 0;
}


Measured memory_bytes: 128
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

// -----------------------------------------------------------------------------

void solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

// -----------------------------------------------------------------------------

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    // preprocess();
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}


Measured memory_bytes: 256
n,m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
  ans += 1
  for key,j in enumerate(s):
    on = 0
    for k in j[1:]:  
      if ((i >> (k-1)) & 1):
        on += 1
    if (on % 2) != p[key]:
      ans -= 1
      break
      
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }
    vector<int> A(M);
    vector<int> B(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A.at(i) >> B.at(i);
    }

    vector<int> ans(N);

    for (int i = 0; i < M; i++)
    {
        if (H.at(A.at(i)-1) > H.at(B.at(i)-1))
        {
            ans.at(B.at(i)-1) = 1;
        }

        else if (H.at(A.at(i)-1) < H.at(B.at(i)-1))
        {
            ans.at(A.at(i)-1) = 1;
        }

        else
        {
            ans.at(A.at(i)-1) = 1;
            ans.at(B.at(i)-1) = 1;
        }
    
    }

    int an = 0;
    for (int i = 0; i < N; i++)
    {
        if (ans.at(i) == 0)
        {
            an ++;
        }
        
    }

    cout << an;
    
    

    
    
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int d = n % 10;
		int c = (n % 100) / 10;
		int b = (n % 1000) / 100;
		int a = n / 1000;

		String x, y, z;

		loop: for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 2; k++) {
					int ans = a;
					if (i == 0) {
						ans += b;
						x = "+";
					} else {
						ans -= b;
						x = "-";
					}

					if (j == 0) {
						ans += c;
						y = "+";
					} else {
						ans -= c;
						y = "-";
					}

					if (k == 0) {
						ans += d;
						z = "+";
					} else {
						ans -= d;
						z = "-";
					}

					if (ans == 7) {
						System.out.println(a + x + b + y + c + z + d + "=7");
						break loop;
					}
				}
			}
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

/*-----------------------------------------------------------------------------
定義
-------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF			2e9
#define MOD			1e9+7
#define MIN(a, b)	((a) < (b) ? a : b)
#define MAX(a, b)	((a) > (b) ? a : b)
#define IsOdd(x)	(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)	(!IsOdd((x)))					/* 偶数 */

typedef long long int QWORD;
typedef long long int ll;

/*-----------------------------------------------------------------------------
処理
-------------------------------------------------------------------------------*/
int main()
{
	int i;
	int N, K;

	cin >> N >> K;

	double sum = 0;
	for (i = 1; i <= N; i++) {
		int val = i;
		double kakuritsu = 1;
		while (val < K) {
			val *= 2;
			kakuritsu *= 0.5;
		}
		sum += kakuritsu / N;
	}

	printf("%.15lf", sum);
//	cout << sum << endl;

	return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
LL ans1,ans2;
LL a,b,c,d,e,f;
double nong;
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
	if (a<=b) ans1=a*100;
	else ans1=b*100;
	for (LL a1=0;a1<=30;a1+=a)
	    for (LL b1=0;b1<=30;b1+=a)
	    {
	    	LL wa=a1*100+b1*100;
	    	for (LL i=0;i<=3000;i+=c)
	    	    for (LL j=0;j<=3000;j+=d)
	    	    {
	    	    	LL su=i+j;
	    	    	if (su+wa>f) continue;
	    	    	if (su>(a1+b1)*e) continue;
	    	    	if (nong*(su+wa)<(100.0)*su) 
	    	    	{
	    	    		nong=(su*100.0)/(su+wa);
	    	    		ans1=su+wa;
	    	    		ans2=su;
	    	    	}
	    	    }
	    }
	printf("%lld %lld",ans1,ans2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X,A,B;
  cin >> X >> A >> B;
  if(B-A<=0)
    cout << "delicious" << endl;
  else if(B-A<=X)
    cout << "safe" << endl;
  else if(B-A>X)
    cout << "dangerous" << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
lis = []
ans = 1000000000000000000

for _ in range(n):
  lis.append(int(input()))

lis.sort()

for i in range(n):
  if i+k-1 >= len(lis):
    break
  else:
    mi = abs(lis[i] - lis[i+k-1])
    ans = min(ans, mi)

print(ans)

Measured memory_bytes: 13376
N,S,*A = map(int, open(0).read().split())
dp = [[0] * (S+1) for _ in range(N+1)]
dp[0][0] = 1
appeared = set([0])
for i in range(1,N+1):
    temp = A[i-1]
    ts = set()
    for x in appeared:
        dp[i][x] += (dp[i-1][x]*2) % 998244353
        if temp + x <= S:
            dp[i][temp+x] += dp[i-1][x]
            if temp + x not in appeared:
                ts.add(temp+x)
    appeared |= ts
print(dp[N][S]%998244353)

Measured memory_bytes: 139204
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        double x = Math.PI;
        Scanner scan = new Scanner(System.in);
        double r = scan.nextDouble();
        if(0 < r && r < 10000){
            double length = 2 * r * x;
            double area = r * r * x;
            System.out.println(BigDecimal.valueOf(area).toPlainString() + " " + length);
        }

    }
}




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

int main()
{
  char N;
  bool ans = false;

  for (int i = 0; i < 3; i++)
  {
    cin >> N;
    if (N == '7')
      ans = true;
  }

  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3564