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


void solve(){

    string str;
    cin>>str;
    ll sum = 0;
    for(ll i=0; i<str.size(); ++i) sum += str[i] - '0';
    // cout<<sum<<endl;
    if(sum%9 != 0) cout<<"No"<<endl;
    else cout<<"Yes";

}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int q;
    q=1;
    // cin>>q;
    while(q--) solve();


    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define PB push_back
using LL = long long;
using namespace std;

const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
const double EPS = 1e-10;
const double PI = acos(-1.0);

signed main(){
     //cin.tie(0);
     //ios::sync_with_stdio(false);
     int A, B, C;

     cin >> A >> B >> C;

     if (A+B>=C) cout << "Yes" <<endl;
     else cout << "No" <<endl;

}


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

using Graph = vector<vector<int>>;

int main(){

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

    Graph G(N);
    for (int i = 0; i < M; ++i){

        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);

    }

    vector<int> michishirube(N);
    vector<int> dict(N,-1);//-1で未訪問を示す
    queue<int> que;

    dict[0] = 0;//始まりの部屋は発見した。0が発見済。
    que.push(0);//今から行きたい部屋をキューにプッシュ

    while(!que.empty()){//キューが空になるまで回す。
        int v = que.front();
        que.pop();//キューの最初から取り出してそれを消す

        for (int nv : G[v]){//部屋ｖから行けるとこをnvと名付けた。
            if (dict[nv] != -1)//もし発見済なら
            continue;//訪問しない（continueの力がわからん！！！！）
            dict[nv] = dict[v] + 1;
            michishirube[nv] = v;
            que.push(nv);


            }
        }

    
    cout << "Yes" << endl;
    for (int v = 0; v < N-1; ++v)
    cout << michishirube[v+1]+1 << endl;
    //辞書の１キーあたりを2つの数字をいれ、[0]を深さ、[1]を道標
    //
    //これたぶん出力できない。
}

Measured memory_bytes: 10640
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
    int a,b,c;
    cin >> a >> b >> c;
  priority_queue<int> p;
  p.push(a);
  p.push(b);
  p.push(c);
  	
  bool isAns=true;
  
  int w = p.top();
  p.pop();
  if (w!=7)isAns=false;
  
  w = p.top();
  p.pop();
  if (w!=5)isAns=false;
  
  w = p.top();
  p.pop();
  if (w!=5)isAns=false;

  	if (isAns==true){
      cout << "YES";
    }else{
      cout << "NO";
    }
    
    return 0;
}


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

const ll INF = 1LL << 60;

ll GCD(ll x, ll y) {
    return x ? GCD(y%x, x) : y;
}

int main() {
    ll N, X;
    cin >> N >> X;
    ll x[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    if (N == 1) {
        cout << abs(X-x[0]) << endl;
    }

    else {
        ll D = INF;
        for (int i = 1; i < N; i++) {
            D = min(GCD(abs(X-x[i]), abs(X-x[0])), D);
        }
        cout << D << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
int fp(int n, int p) {
    int ans = 1, c = n;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int mdiv(int a, int b) {
    return mod(a * fp(b, MOD - 2));
}   
struct F {
    int a, b;
    F (int a_, int b_) {
        a = a_; b = b_;
    }   
    F () {}
    F operator +(F p) {
        return {mod(a * p.b + p.a * b), mod(b * p.b)};
    }   
    F operator -(F p) {
        return {mod(a * p.b - p.a * b), mod(b * p.b)};
    }   
    F operator *(F p) {
        return {mod(a * p.a), mod(b * p.b)};
    }   
    F operator /(F p) {
        return {mod(a * p.b), mod(b * p.a)};
    }   
    F operator *(int p) {
        return {mod(a * p), b};
    }   
    F operator /(int p) {
        return {a, mod(b * p)};
    }   
};  
int f[N];
void prec() {
    f[0] = 1;
    for (int i = 1; i < N; ++i) {
        f[i] = mod(f[i - 1] * i);
    }   
}   
F C(int n, int k) {
    if (n < k) return {0, 1};
    else return {f[n], mod(f[k] * f[n - k])};
}   
int B, W;
F all_black[N], all_white[N];
F one_black(int h) {
    int del = B - 1;
    return C(h, del) / fp(2, h);
}   
F one_white(int h) {
    int del = W - 1;
    return C(h, del) / fp(2, h);
}   
void print(F p) {
    cout << "F " << p.a << ' ' << p.b << '\n';
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    prec();
    cin >> B >> W;
    all_white[0] = all_black[0] = {0, 1};
    for (int i = 1; i < W + B; ++i) {
        all_white[i] = all_white[i - 1] + one_black(i - 1) / 2;
        all_black[i] = all_black[i - 1] + one_white(i - 1) / 2;
    }   
    for (int i = 0; i < W + B; ++i) {
        if (!all_white[i].a && !all_black[i].a) {
            cout << mdiv(1, 2) << '\n';
        }   
        else {
            F ans = {0, 1};
            ans = ans + all_black[i];
            ans = ans + (F(1, 1) - all_white[i] - all_black[i]) / 2;

            #ifdef HOME
            print(ans);
            #endif

            cout << mdiv(ans.a, ans.b) << '\n';
        }   
    }   
}   

Measured memory_bytes: 10112
#include <iostream>
#include <algorithm>
#include <bitset>
#include <string>
#include <fstream>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_map>
using namespace std;

#define ll long long

int main()
{
	ll x;
	cin >> x;
	
	ll sum = (x / 500) * 1000;
	x -= (x / 500) * 500;
	sum += (x / 5) * 5;
	
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
ll ncd(ll n,ll d){
    ll x = 1,y=1;
    for(int i=0;i<d;i++){
        x = x*(n-i)%mod;
        y = y*(i+1)%mod;
    }
    return x*modpow(y,mod-2,mod)%mod;
}
int main() {    
    srand(time(NULL));
    for(int j=0;j<14;j++){
    for(int i=0;i<26;i++){
        cout<<i+1<<endl;
    }
    }
    for(int i=0;i<1;i++){

          cout<<rand()%26+1<<endl;  
    }
}
    



Measured memory_bytes: 3596
using System;

namespace MyProgram{
    class AtCoder{
        public static void Main(string[] args){
            long X = long.Parse(Console.ReadLine());
            while(true){
                if(isPrime(X))break;
                X++;
            }
            Console.WriteLine(X);
        }
        static bool isPrime(long X){
            for(var i=2;i*i<=X;i++){
                if(X%i==0){
                    return false;
                }
            }
            return true;
        }
    }
}

Measured memory_bytes: 13140
while gets
  n, r = $_.split.map(&:to_i)
  a = gets.split.map(&:to_i)
  deck_a = (n/2...n).to_a
  deck_b = (0...n/2).to_a
  deck_c = Array.new
  r.times do
    deck_c.clear
    c = a.shift
    while !(deck_a.empty? && deck_b.empty?)
      deck_c += deck_a.shift(c)
      deck_c += deck_b.shift(c)
    end
    deck_a = deck_c[n/2,n]
    deck_b = deck_c[0,n/2]
  end
  p deck_c.pop
end

Measured memory_bytes: 9628
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    vector<ll> A(5);
    FOR(i, 0, 5){
        cin >> A.at(i);
    }

    ll K;
    cin >> K;

    ll diff = A[4] - A[0];
    if(diff>K){
        p(":(");
    }else{
        p("Yay!");
    }
    
    return 0;
}

Measured memory_bytes: 256
// 双方向連結リスト 正解の実装
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node
{
    int key;
    Node *next, *prev;
};

Node *nil;

Node *listSearch(int key)
{
    // 番兵の次の要素から検索する
    Node *cur = nil->next;

    while( cur != nil && cur->key != key )
    {
        cur = cur->next;
    }

    return cur;
}

void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList()
{
    Node *cur = nil->next;
    int isf = 0;

    while( 1 )
    {
        if( cur == nil )
        {
            // リストが一周した時
            break;
        }

        if( isf++ > 0 )
        {
            printf(" ");
        }

        printf("%d", cur->key);

        cur = cur->next;
    }

    printf("\n");
}

void deleteNode(Node *t)
{
    if( t == nil )
    {
        // tが番兵の場合は処理しない
        return ;
    }

    t->prev->next = t->next;
    t->next->prev = t->prev;

    free(t);
}

void deleteFirst()
{
    deleteNode(nil->next);
}

void deleteLast()
{
    deleteNode(nil->prev);
}

void deleteKey(int key)
{
    // 検索したノードを削除
    deleteNode(listSearch(key));
}

void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;

    // 番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main()
{
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;

    scanf("%d", &n);

    init();

    for( i = 0; i < n; i++ )
    {
        scanf("%s%d", com, &key);

        if( com[0] == 'i' )
        {
            insert(key);
            np++;
            size++;
        }
        else if( com[0] == 'd' )
        {
            if( strlen(com) > 6 )
            {
                if( com[6] == 'F' )
                {
                    deleteFirst();
                }
                else if( com[6] == 'L' )
                {
                    deleteLast();
                }
            }
            else
            {
                deleteKey(key);
                nd++;
            }

            size--;
        }
    }

    printList();

    return 0;
}



Measured memory_bytes: 33844
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
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 print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;} //最大公約数
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll T;
    cin >> T;
    while(T--) {
        ll A,B,C,D;
        cin >> A >> B >> C >> D;
        if(A < B){
            print("No");
        }else if(B > D){
            print("No");
        }else if(C >= B-1){
            print("Yes");
        }else{
            // C+1=2, B-1=
            // C+1 <= (A + kD) mod B <= B-1
            // C+1-A <= kD mod B <= B-A-1
            ll L = ((C - A + 1) % B + B) % B;
            ll R = ((B - A - 1) % B + B) % B;
            if(L <= R){
                ll v = gcd(B, D);
                if(R / v == L / v && L % v != 0){
                    print("Yes");
                }else{
                    print("No");
                }

            }else{
                // k=0の時、つまりAがこれを満たす
                print("No");
            }
        }
    }
}

Measured memory_bytes: 256
class SCC:
  '''
  SCC class with non-recursive DFS.
  '''
  def __init__(self,N):
    self.N = N
    self.G1 = [[] for _ in range(N)]
    self.G2 = [[] for _ in range(N)]
  
  def add_edge(self,a,b):
    self.G1[a].append(b)
    self.G2[b].append(a)
    
  def scc(self):
    self.seen = [0]*self.N
    self.postorder=[-1]*self.N
    self.order = 0
    for i in range(self.N):
      if self.seen[i]:continue
      self._dfs(i)

    self.seen = [0]*self.N
    scclist = []
    for i in self._argsort(self.postorder,reverse=True):
      if self.seen[i]:continue
      cc = self._dfs2(i)
      scclist.append(cc)
    
    return scclist
    
  def _argsort(self,arr,reverse=False):
    shift = self.N.bit_length()+2
    tmp = sorted([arr[i]<<shift | i for i in range(len(arr))],reverse=reverse)
    mask = (1<<shift) - 1
    return [tmp[i] & mask for i in range(len(arr))]
  
  def _dfs(self,v0):
    todo = [~v0, v0]
    while todo:
      v = todo.pop()
      if v >= 0:
        self.seen[v] = 1
        for next_v in self.G1[v]:
          if self.seen[next_v]: continue
          todo.append(~next_v)
          todo.append(next_v)
      else:
        if self.postorder[~v] == -1:
          self.postorder[~v] = self.order
          self.order += 1
    return
  
  def _dfs2(self,v):
    todo = [v]
    self.seen[v] = 1
    cc = [v]
    while todo:
      v = todo.pop()
      for next_v in self.G2[v]:
        if self.seen[next_v]: continue
        self.seen[next_v] = 1
        todo.append(next_v)
        cc.append(next_v)
    return cc

def main():
  N,M = map(int,input().split())
  sc = SCC(N)
  for i in range(M):
    a,b=map(int,input().split())
    sc.add_edge(a,b)
  scclist = sc.scc()
  print(len(scclist))
  for cc in scclist:
    print(len(cc),*cc)
    
if __name__=="__main__":
  main()

Measured memory_bytes: 219336
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const int INF=99999999;
char s[55][55];
int d[55][55];
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
queue<pair<int,int> > q;


int main(){
    int h,w,num=0;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
            if(s[i][j]=='.') num++;
            d[i][j]=INF;
        }
    }
    q.push(make_pair(0,0));
    d[0][0]=0;
    while(q.size()){
        pair<int,int> p=q.front(); q.pop();
        if(p.first==w-1 && p.second==h-1){
            break;
        }
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(nx>=0 && nx<w && ny>=0 && ny<h && d[ny][nx]==INF && s[ny][nx]=='.'){
                q.push(make_pair(nx,ny));
                d[ny][nx]=d[p.second][p.first]+1;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            //cout<<d[i][j]<<" ";
        }
        //cout<<endl<<endl;
    }

    if(d[h-1][w-1]==INF){
        cout<<-1<<endl;
    }else{
        cout<<num-d[h-1][w-1]-1<<endl;
    }
}

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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct UnionFind
{
  vector<int> data;
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }  
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }  
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] < data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
};

// Biconnected Components (lowlink)
struct BICC
{
  UnionFind uf;
  vector< vector<int> > graph, tree;
  vector<Pi> edges;
  vector<bool> vis;
  vector<int> ord, low, cmp;
  vector<int> articulation;
  vector<Pi> bridge;
  BICC(int sz):uf(sz), graph(sz), vis(sz, false), ord(sz), low(sz), cmp(sz){}
  void add_edge(int u, int v)
  {
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
    edges.emplace_back(minmax(u, v));
  }
  void dfs(int u, int p, int& k)
  {
    vis[u] = true;
    
    ord[u] = low[u] = k++;

    bool is_articulation = false;
    int cnt = 0;
    
    for(auto v : graph[u]) {
      if(!vis[v]) {
	cnt++;
	dfs(v, u, k);
	low[u] = min(low[u], low[v]);
	if(~p && ord[u] <= low[v]) is_articulation = true;
	if(ord[u] < low[v]) bridge.emplace_back(minmax(u, v));
	else uf.unite(u, v);
      } else if(v != p) {
	low[u] = min(low[u], ord[v]);
      }
    }
    
    if(p == -1 && cnt > 1) is_articulation = true;
    if(is_articulation) articulation.push_back(u);
  }
  void compose()
  {
    int k = 0;
    dfs(0, -1, k);

    int num = 0;
    vector<int> conn(graph.size());
    for(int i = 0; i < graph.size(); i++) {
      if(i == uf.find(i)) conn[i] = num++;
    }

    tree.resize(num);
    for(int i = 0; i < graph.size(); i++) {
      cmp[i] = conn[uf.find(i)];
    }
    for(auto e : edges) {
      int x = cmp[e.first], y = cmp[e.second];
      if(x == y) continue;
      tree[x].emplace_back(y);
      tree[y].emplace_back(x);
    }
  }
};


int main()
{
  int V, E; cin >> V >> E;
  BICC bicc(V);
  while(E--) {
    int s, t;
    cin >> s >> t;
    bicc.add_edge(s, t);
  }
  bicc.compose();
  sort(all(bicc.articulation));
  rep(i, bicc.articulation.size()) cout << bicc.articulation[i] << endl;
  return 0;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int N;
string S;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;
	cin >> S;

	if(N%2!=0) {
		cout << "No"<<endl;
		return 0;
	}
	FOR(n,N/2) {
		if(S[n]!=S[n+N/2]) {
			cout << "No"<<endl;
			return 0;
		}	
	}

	cout << "Yes"<<endl;

	return 0;
}




Measured memory_bytes: 256
/*
  Contest 101
  B - Digit Sums
  Rakesh Kumar --> 24/09/2020
 */

#include <bits/stdc++.h>

using ll = long long int;

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

    ll n = 0;
    std::cin >> n;
    int digit_sum = 0;
    for (char c : std::to_string(n))
        digit_sum += c - '0';
    if (n % digit_sum)
        std::cout << "No" << std::endl;
    else
        std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 3796
#include <iostream>

int main() {
    int K;
    int N;
    scanf("%d %d",&K,&N);
    int A[N+1];
    int max = 0;

    for(int i = 0; i < N; ++i){
        scanf("%d",&A[i]);
    }
    A[N] = A[0] + K;

    for(int i = 1; i <= N; ++i){
        if(A[i]-A[i-1] >= max){
            max = A[i]-A[i-1];
        }
    }

    printf("%d",K-max);


    return 0;
}

int A(){
    char Word[256];
    scanf("%s",&Word);
    if(Word[2]==Word[3] && Word[4] == Word[5]){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

int B(){
    long long int money;
    scanf("%lld",&money);
    long long int happy1000;
    long long int happy5;
    happy1000 = money /500 ;
    happy5 = (money % 500) / 5;

    printf("%lld",happy1000*1000+happy5*5);
    return 0;
}


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

int main() {
    long n, m;
    cin >> n >> m;

    pair<long, long> ab[n];

    for (int i = 0; i < n; i++) {
        cin >> ab[i].first;
        cin >> ab[i].second;
    }

    sort(ab, ab + n);

    long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += min(ab[i].second, m) * ab[i].first;
        m -= ab[i].second;

        if (m <= 0) {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



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

    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> operation(m);
    //vector<vector<ll>> graph(n);

    vector<bool> reachable(n, false);
    vector<ll> numOfBalls(n, 1);

    for (int i = 0; i < m; i++)
    {
        cin >> operation[i].first;
        operation[i].first--;
        cin >> operation[i].second;
        operation[i].second--;
    }

    reachable[0] = true;
    for (auto o : operation) {
        numOfBalls[o.first]--;
        numOfBalls[o.second]++;
        if (reachable[o.first]) {
            reachable[o.second] = true;
        }
        if (numOfBalls[o.first] == 0ll) {
            reachable[o.first] = false;
        }
    }

    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (reachable[i]) {
            sum++;
        }
    }

    cout << sum << "\n";

    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
int main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "Yes" << endl;
        return 0;
    }
    vector<ll> h(n);
    rep(i, n){
        cin >> h[i];
    }

    h[0]--;
    for(int i = 1; i < n; i++){
        if(h[i-1] < h[i])
            h[i]--;
        else if(h[i-1] > h[i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false


signed main(void){
    int R;
    cin >> R;
    double Ans = 2*R;
    Ans *= PI;
    printf("%.8f\n",Ans);
    
    return 0;
}



Measured memory_bytes: 3748
#include<stdio.h>
int main(void)
{
	int a,b,H,W;
	char c,map[100][101];
	for(;;)
	{
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)
			return 0;
		for(a=0;a<H;a++)
			scanf("%s",map[a]);
		for(a=0,b=0;;)
		{
			c=map[a][b];
			map[a][b]='L';
			if(c=='L')
			{
				printf("LOOP\n");
				break;
			}
			else if(c=='>')
				b++;
			else if(c=='<')
				b--;
			else if(c=='^')
				a--;
			else if(c=='v')
				a++;
			else
			{
				printf("%d %d\n",b,a);
				break;
			}
		}
	}
}

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

int main()
{

    int n,m,x,y,i,r=0,c;
     int g[150]={0};
    cin>>n>>m;
    int a[m],b[m];
     for(i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];

    }
    for(i=0;i<m;i++)
    {
        g[a[i]]++;
        g[b[i]]++;

    }
    for(i=1;i<=n;i++)
    {
          cout<<g[i]<<endl;

    }


    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X, Y; cin >> X >> Y;
    bool flag = false;
    rep(c, X + 1){
        ll t = X - c;
        if (2 * c + 4 * t == Y){flag = true;}
    }
    string ans = flag ? "Yes" : "No";
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;
ll n, a, b;
vector<ll> h;
bool check(ll m){
	ll cnt = 0;
	for(int i=0; i<n; i++){
		if(h[i] - m*b > 0){
			cnt += (h[i] - m*b) / (a-b)+((h[i]-m*b)%(a-b)!=0);
		}
	}
	return cnt <= m;
}
 
int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	cin >> n >> a >> b;
 
	ll ma = 0;
	for(int i=0; i<n; i++){
		ll t;
		cin >> t;
		h.pb(t);
		ma = max(ma, t);
	}
 
	ll l = 0;
	ll r = ma/b + 1;
 
	while(r-l > 1){
		ll m = (l + r)/2;
		if(check(m)){
			r = m;
		}else{
			l = m;
		}
	}
 
	cout << r << endl;
	
	return 0;
}

Measured memory_bytes: 1400
N, K = map(int,input().split())
A = list(map(int,input().split()))
B = [0];BB=[0]
S = set([]);S.add(0)
now = 0
Flag = False
loop_start = -1
if K <= 2*pow(10,5)+10:
  for i in range(K):
    nxt = A[now]-1
    BB.append(nxt)
    now = nxt
  #print(BB)
  print(BB[K]+1)
  exit()
for i in range(N*2):
  nxt = A[now]-1
  #print(now,nxt)
  if nxt in S:
    if Flag:
      if nxt == loop_start:
        #print(nxt,i)
        loop_cycle = i-loop_num
        break
    else:
      loop_start = nxt
      loop_num = i
      B.append(nxt)
      #print(loop_num,loop_start,B)
      Flag = True
  else:
    B.append(nxt);S.add(nxt)
  now = nxt
loop_num += 1-loop_cycle
#print(B,loop_start,loop_cycle,loop_num)
loc = (K-loop_num)%loop_cycle+loop_num
#print(loc)
#print(len(B))
print(B[loc]+1)

Measured memory_bytes: 121776
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

const int mod = 100000;

int h, w;

// dp[y][x][??´??????????????£??????][?¨????????????§??????]
int dp[102][102][2][2];

signed main()
{
    while (cin >> h >> w, h) {
        memset(dp, 0, sizeof dp);

        dp[0][1][0][1] = 1;
        dp[1][0][0][0] = 1;

        rep(i, h) rep(j, w) {
            if (j - 1 >= 0) {
                dp[i][j][0][1] += dp[i][j - 1][0][1] + dp[i][j - 1][1][1];
                dp[i][j][0][1] %= mod;
                dp[i][j][1][1] += dp[i][j - 1][0][0];
                dp[i][j][1][1] %= mod;
            }

            if (i - 1 >= 0) {
                dp[i][j][0][0] += dp[i - 1][j][0][0] + dp[i - 1][j][1][0];
                dp[i][j][0][0] %= mod;
                dp[i][j][1][0] += dp[i - 1][j][0][1];
                dp[i][j][1][0] %= mod;
            }
        }

        int ans = 0;

        rep(i, 2) rep(j, 2) {
            ans += dp[h - 1][w - 1][i][j];
            ans %= mod;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3128
num = int(input())
dice_ = [0 for i in range(num)]
dice = [0 for i in range(num)]
rdice = [0 for i in range(num)]
ndice_ = [0 for i in range(num)]
ndice = [0 for i in range(num)]
nrdice = [0 for i in range(num)]
dice_norm = [0 for i in range(num)]
varif = [0 for i in range(num)]
varif_child = [0 for i in range(6)]

def cross(a,b):
	return((a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]))

for n in range(num):
	dice_[n] = [int(i) for i in input().split()]
	
	dice[n] = {
		(0,0,1):dice_[n][0],
		(0,-1,0):dice_[n][1],
		(1,0,0):dice_[n][2],
		(-1,0,0):dice_[n][3],
		(0,1,0):dice_[n][4],
		(0,0,-1):dice_[n][5]
	}

for n in range(num):
	dice_keys = [i for i in dice[n].keys()]
	for count,min_ in enumerate(dice_keys):
		opposing = tuple([-i for i in min_])
		sides = list(set(dice_keys) - set([opposing,min_]))
		one = sides[0]
		two = cross(min_, one)
		three = cross(min_, two)
		four = cross(min_, three)
		varif_child[count] = min([1*dice[n][min_] + 10*dice[n][on] + 100*dice[n][tw] + 1000*dice[n][th] + 10000*dice[n][fo] + 100000*dice[n][opposing] for on,tw,th,fo in [[one,two,three,four],[four,one,two,three],[three,four,one,two],[two,three,four,one]]])
	varif[n] = min(varif_child)

if len(list(set(varif))) == num:
	print("Yes")
else:
	print('No')


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

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

    vector<int> a(N);

    rep(i, N) {
        cin >> a.at(i);
    }

    int button = 1;
    rep(i, N) {
        button = a.at(button - 1);
        if (button == 2) {
            cout << i + 1 << endl;
            break;
        }
        if (i == N - 1) {
            cout << -1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int n,m;
    cin >> n >> m;
    vector<int> a(n),b(m);
    frr(i,n) cin >> a[i];
    frr(i,m) cin >> b[i];
    int lim = max(n,m)+1;
    int dp[lim][lim];
    frr(i,lim) dp[i][0] = dp[0][i] = 1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            dp[i][j] = mod(dp[i-1][j] + dp[i][j-1] - (a[i-1]==b[j-1] ? 0 : dp[i-1][j-1]),M);
    cout << dp[n][m] << endl;
}

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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  int res = 0;

  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i) {
      if(A[i] % 2 != 0) exist_odd = true;
    }
    if (exist_odd) break;

    for (int i = 0; i < N; ++i) {
    A[i] /= 2;
    }
    ++res;
  }
  cout << res << endl;
}




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

int main() {
    ll N,K;
    ll A[100000];
    std::cin >> N>>K;
    ll where_one=0;
    for (int i = 0; i < N; i++) {
        cin >>A[i];
        if(A[i]==1){
            where_one=i;
        }
    }
    
    ll res=N;
    for (int i = 0; i < K; i++) {
        ll tmp_res=1;
        if(where_one-i>0){
            tmp_res+=(where_one-i)/(K-1);
            if((where_one-i)%(K-1)!=0){
                tmp_res++;
            }
        }
        if(N-where_one-K+i>0){
            tmp_res+=(N-where_one-K+i)/(K-1);
            if((N-where_one-K+i)%(K-1)!=0){
                tmp_res++;
            }
        }
        res=min(res,tmp_res);
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 640
import numpy as np
h,w = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
#print(ar)
l = np.zeros((h,w),dtype=int)
r = np.zeros((h,w),dtype=int)
u = np.zeros((h,w),dtype=int)
d = np.zeros((h,w),dtype=int)

for i in range(h):
  u[i] = (u[i-1]+1)*ar[i]
  #print(u)
  d[-i-1] = (d[-i]+1)*ar[-i-1]
  #print(d)
  
for j in range(w):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  #print(l)
  r[:,-j-1] = (r[:,-j]+1)*ar[:,-j-1]
  #print(r)
print(np.max(u+d+l+r)-3)

Measured memory_bytes: 219792
#include <stdio.h>

int main(void)
{

    int i, j, k,  n, b, f, r, v;
    int a[4][3][10];

    for(k = 0; k < 4; k++)
        for(i = 0; i < 3; i++)
            for(j = 0; j < 10; j++)
            a[k][i][j] = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b - 1][f - 1][r - 1] += v;
    }

    for(i = 0; i < 3; i++) {
        for(j = 0; j < 10; j++)
            printf(" %d", a[0][i][j]);
        printf("\n");
    }

    printf("####################\n");

    for(i = 0; i < 3; i++) {
        for(j = 0; j < 10; j++)
            printf(" %d", a[1][i][j]);
        printf("\n");
    }

    printf("####################\n");

    for(i = 0; i < 3; i++) {
        for(j = 0; j < 10; j++)
            printf(" %d", a[2][i][j]);
        printf("\n");
    }

    printf("####################\n");

    for(i = 0; i < 3; i++) {
        for(j = 0; j < 10; j++)
            printf(" %d", a[3][i][j]);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 612
n = int(input())
r = [[0, 0]] * n
b = [[0, 0]] * n
f = [[0 for i in range(0, 2 * n + 2)] for j in range(0, 2 * n + 2)]
     
for i in range(0, n):
    r[i] = [int(i) for i in input().split(" ")]
for i in range(0, n):
    b[i] = [int(i) for i in input().split(" ")]
     
for i in range(0, n):
    f[0][2 * i + 1] = 1
    f[2 * i + 2][2 * n + 1] = 1
    for j in range(0, n):
        if r[i][0] < b[j][0] and r[i][1] < b[j][1]:
            f[2 * i + 1][2 * j + 2] = 1
    
d = [-1] * (2 * n + 2)
def trav(i):
    global f
    global n
    global d
    if i == 2 * n + 1:
        return True
    else:
        for j in range(0, 2 * n + 2):
            if d[j] < 0 and f[i][j] > 0:
                d[j] = i
                if trav(j):
                    return True
        return False
    
c = 0
while True:
    d = [-1] * (2 * n + 2)
    t = trav(0)
    if t:
        k = 2 * n + 1
        m = 100**2
        k = 2 * n + 1
        while k > 0:
            f[d[k]][k] -= 1
            f[k][d[k]] += 1
            k = d[k]
        c += 1
    else:
        break

print(c)

Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int main()
{
    int N, ans = 0;
    cin >> N;
    int point[110];
    for(int i = 0; i < N; i++)  cin >> point[i];
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            ans += point[i] * point[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

  int len = S.size();
  int half = (len - 1) / 2;
  string s = S;
  reverse(s.begin(), s.end());

  bool can = true;

  if(S != s){
    can = false;
  }
  else if (S.substr(0, half) != s.substr(len - half, half)){
    can = false;
  }
  else if(S.substr(len - half, half) != s.substr(0, half)){
    can = false;
  }
  
  if(can) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

int n,m,x,y;
vii gragh;
/*FUNCs=================================================*/
vi dp;
// Node"u"から有向辺を辿れるNode辿っていき、道中 DPtable にメモしていく感じ
// ↑の動きを繰り返すことでいけるとこ全部のNodeの中で一番遠い場所までの距離がわかる
// "辿ったところはメモしていた値を使う"という"メモ化"の部分は一番最初のところ
int rec(int u) {
    if(dp[u] != -1) return dp[u];
    int res = 0;
    for(auto v : gragh[u]) {
        chmax(res, rec(v) + 1);
    }
    dp[u] = res;  // メモ
    return res;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    cin >> n >> m;
    gragh.resize(n+1);
    for(int i = 0; i < m; ++i) {
        cin >> x >> y;
        gragh[0].emplace_back(x);
        gragh[x].emplace_back(y);
    }

    dp.resize(n+1, -1);
    int res = rec(0) - 1;

    cout << res << '\n';
}

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld=long double;
 
int main(){
    int n;
    cin>>n;
    int o=0;
    for(int i=1;i<=n;i++){
        if(i%2!=0)
        o++;
    }
    ld k=(float)o/n;
    cout<<fixed<<setprecision(10)<<k;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void print(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i == 0)
			printf("%d", A[i]);
		else
			printf(" %d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j;
	int v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print(A, N);
	}
}

int main() {
	int A[1000];
	int N;
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	print(A, N);
	insertionSort(A, N);
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 1e5+1;
int n,v[N];

int main(){
    scanf("%d",&n);
    for(int i = 0; i<n; ++i)scanf("%d",v+i);
    sort(v,v+n);
    priority_queue<double, vector<double>, greater<double> > q;
    for(int i = 0; i<n; ++i)q.push(v[i]);
    vector<double>vec;
    while(!q.empty()){
        double x = q.top();
        q.pop();
        if(!q.size()){cout << x ; break;}
              double y = q.top();
              q.pop();
              q.push((x+y)/2.0);
    }
}


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

int main() {
  string a,b; cin>>a>>b;  
  int flag=2;
  if(a.size()>b.size()) flag=0;
  if(a.size()<b.size()) flag=1;
  if(a.size()==b.size()){
    for(int i=0;i<a.size();i++){
      if(a[i]>b[i]){
        flag=0;
        break;
      }
      if(a[i]<b[i]){
        flag=1;
        break;
      }
      if(a[i]==b[i]){
        continue;
      }
    }
  }
  if(flag==0) cout<<"GREATER"<<endl;
  if(flag==1) cout<<"LESS"<<endl;
  if(flag==2) cout<<"EQUAL"<<endl;
}

    
  


Measured memory_bytes: 256
#include <iostream>                                           
#include <cmath>                                              
#include <cstdio>                                             
using namespace std;                                          
                                                              
int main() {                                                  
  int n;                                                      
  double x1, y1, x2, y2, x3, y3;                              
  double x, y, r;                                             
  double a1, a2, b1, b2, c1, c2;                              
                                                              
  cin >> n;                                                   
  while (n--) {                                               
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;                  
                                                              
    a1 = 2*(x2-x1);                                           
    b1 = 2*(y2-y1);                                           
    c1 = x1*x1-x2*x2+y1*y1-y2*y2;                             
                                                              
    a2 = 2*(x3-x1);                                           
    b2 = 2*(y3-y1);                                           
    c2 = x1*x1-x3*x3+y1*y1-y3*y3;                             
                                                              
    x = (b1*c2-b2*c1)/(a1*b2-a2*b1);                          
    y = (c1*a2-c2*a1)/(a1*b2-a2*b1);                          
                                                              
    r = hypot(x-x1,y-y1);                                     
                                                              
    printf("%.3f %.3f %.3f\n", x, y, r);                      
  }                                                           
                                                              
  return 0;                                                   
}                    

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
long long n,k;
 
int main(){
  cin>>n>>k;
  long long r=0;
  if (k==0)r=n*n;
  else
  for(long long b=k+1;b<=n;b++){
    r+=(b-k)*(n/b)+(n%b-k+1 >= 0 ? n%b-k+1 : 0);
  }
  cout<<r;
  return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var after = S.Replace("ABC", "");
            var diff = S.Length-after.Length;
            Console.WriteLine(diff/3);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
A_list = list(map(int,input().split()))

score =  {}
for i,A in enumerate(A_list):
    score[A] = i + 1 

score_sorted = dict(sorted(score.items(), key=lambda x:x[0]))
result = "" 
for A, i in score_sorted.items():
    result += str(i) + " "
print(result)

Measured memory_bytes: 35932
#include<iostream>
#include<string>
using namespace std;
int main() {
	int i, j, count = 0;
	string str, str1;
	cin >> str >> str1;
	str = str + str;
	for (i = 0; i < str.size(); i++) {
		for (j = 0; j < str1.size(); j++) {
			if (str[i + j] == str1[j]) {
				count++;
			}
			else {
				count = 0;
				break;
			}
		}
		if (str1.size() == count) {
			cout << "Yes" << endl;
			break;
		}
	}
	if (str1.size() != count) {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,i=0,j,c=0,n,d[100010];
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> d[i];
    }
    sort(d,d+n);
    cout << d[n/2]-d[n/2-1] << endl;
                                    
    return 0;

}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__

void chmax(ll &x, ll y) { if (x < y) x = y; }

int main() {
    ll N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N) {
        cin >> A[i];
    }

    const int DIGIT_MAX = 50;

    vector<vector<ll>> dp(DIGIT_MAX + 1, vector<ll>(2, -1));
    dp[0][0] = 0;

    for (int d = 0; d < DIGIT_MAX; d++) {
        ll mask = 1LL<<(DIGIT_MAX - 1 - d);

        ll num = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] & mask) num++;
        }

        ll cost0 = mask * num;
        ll cost1 = mask * (N - num);

        if (dp[d][0] != -1) {
            if (K & mask) {
                chmax(dp[d + 1][0], dp[d][0] + cost1);
            } else {
                chmax(dp[d + 1][0], dp[d][0] + cost0);
            }
        }

        if (dp[d][0] != -1) {
            if (K & mask) {
                chmax(dp[d + 1][1], dp[d][0] + cost0);
            }
        }

        if (dp[d][1] != -1) {
            chmax(dp[d + 1][1], dp[d][1] + max(cost0, cost1));
        }
    }
    cout << max(dp[DIGIT_MAX][0], dp[DIGIT_MAX][1]) << endl;
}

Measured memory_bytes: 4048