akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=310,MOD=998244353;

int dp[N][N][N];
int xxm[N][N][N];
int xmp[N][N][N];

#define get(arr)                    \
int get_##arr(int pos,int mov,int dif) \
{                                    \
    if(pos>=0&&mov>=0&&dif>=0)       \
        return arr[pos][mov][dif];   \
    else                             \
        return 0;                    \
}
get(dp)
get(xxm)
get(xmp)

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    int k;
    cin>>s>>k;
    k=min<int>(k,s.size());
    vector<int> v{0};
    int cur=0;
    for(char c:s)
        if(c=='0')
            v.push_back(cur),
            cur=0;
        else
            cur++;
    v.push_back(cur);
    int n=v.size()-1;
//    cout<<n<<"\n";
//    for(int i=1;i<=n;i++)
//        cout<<v[i]<<" ";
//    cout<<"\n";
    dp[0][0][0]=1;
    xxm[0][0][0]=1;
    xmp[0][0][0]=1;
    for(int pos=0;pos<=n;pos++)
        for(int mov=0;mov<=k;mov++)
            for(int dif=0;dif<=k;dif++)
            {
                dp[pos][mov][dif]=(get_dp(pos,mov,dif)+
                                   get_xxm(pos-1,mov,dif-1)+
                                   get_xmp(pos-1,mov-1,dif+1)-
                                   get_xmp(pos-1,mov-1-v[pos],dif+1+v[pos])+
                                   get_dp(pos-1,mov,dif))%MOD;
                xxm[pos][mov][dif]=(dp[pos][mov][dif]+get_xxm(pos,mov,dif-1))%MOD;
                xmp[pos][mov][dif]=(dp[pos][mov][dif]+get_xmp(pos,mov-1,dif+1))%MOD;
//                cout<<pos<<" "<<mov<<" "<<dif<<" -> "<<dp[pos][mov][dif]<<"\n";
            }
    int ans=0;
    for(int mov=0;mov<=k;mov++)
        ans=(ans+dp[n][mov][0])%MOD;
    cout<<(ans+MOD)%MOD;
}


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

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

  ll N; cin >> N;
  vector<string> S(N); for (ll i = 0; i < N; i++) cin >> S[i];
  sort(S.begin(), S.end());

  ll MAX = 0;
  string tempS = S[0];
  ll tempC = 1;
  for (ll i = 1; i < N; i++) {
    if (tempS != S[i]) {
      tempC = 1;
    } else {
      tempC++;
    }
    MAX = max(MAX, tempC);
    tempS = S[i];
  }

  tempS = S[0];
  tempC = 1;
  if (tempC == MAX) cout << tempS << '\n';
  for (ll i = 1; i < N; i++) {
    if (tempS != S[i]) {
      tempC = 1;
    } else {
      tempC++;
    }
    if (tempC == MAX) cout << S[i] << '\n';
    tempS = S[i];
  }
  return 0;
}

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

int main(){
    int n,m;
    cin >> n>>m;
    vector<int>a(m);
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    int ans =0;
    for(int i=0;i<m;i++)ans += a[i];
    ans = n-ans;
    if(ans <0){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '+') {
				ans++;
			} else {
				ans--;
			}
		}
		System.out.println(ans);
	}

}


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

int main() {
	int n;
	cin >> n;
	vector<int> V(n);
	for (int i = 0; i < n; i++) {
		cin >> V[i];
	}
	int sum = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j > i; j--) {
			if (V[j - 1] > V[j]) {
				swap(V[j], V[j - 1]);
				sum++;
				flag = 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << V[i];
		if (i == n - 1)
			cout << endl;
		else
			cout << " ";
	}
	cout << sum << endl;
}


Measured memory_bytes: 3120
def getval():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    c = list(map(int,input().split()))
    a.sort()
    b.sort()
    c.sort()
    return n,a,b,c 

def main(n,a,b,c):
    def bs(arr,key):
        lo = 0
        hi = len(arr)-1
        while lo<=hi:
            idx = (lo+hi)//2
            if arr[idx]>=key:
                hi = idx-1
            else:
                lo = idx+1
        return hi

    arrb = []
    arrc = []
    for i in b:
        arrb.append(bs(a,i)+1)
    for i in c:
        arrc.append(bs(b,i)+1)
    for i in range(1,n):
        arrb[i] += arrb[i-1]
    ans = 0
    for i in arrc:
        if i!=0:
            ans += arrb[i-1]
    print(ans)

if __name__=="__main__":
    n,a,b,c = getval()
    main(n,a,b,c)

Measured memory_bytes: 99780
#include <bits/stdc++.h>
using namespace std;
int main(){
  string w;
  cin>>w;
  bool ans=true;
  for(int i=0;i<26;i++){
    int count=0;
    for(int j=0;j<w.size();j++){
      if(i+'a'==w.at(j)) count++;
    }
    if(count%2==1) ans=false;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int D, G;
//vector<int> p(D), c(D);
vector<int> p(20), c(20);

int ans = 1e9;

void rec(int sum, int counter, int i, vector<bool> D_bool) {
  if (i == D) {
    if (sum >= G) {
      ans = min(ans, counter);
    }
    else {
      rrep(j,D-1) {
        if (D_bool.at(j)) 
          continue;
        else {
          for (int l = 0; l < p.at(j)-1 && sum < G; l++) {
            sum += 100*(j+1);
            counter++;
          }
          if (sum >= G) {
            ans = min(ans,counter);
            break;
          }
        }
        if (sum >= G) break;
      }
    }
  }
  else {
    D_bool.at(i) = false;
    rec(sum, counter, i+1, D_bool);
    
    D_bool.at(i) = true;
    rep(j,p[i]) {
      sum += 100*(i+1);
      counter++;
    }
    sum += c.at(i);
    rec(sum, counter, i+1, D_bool);
  }
}

int main() {
  cin >> D >> G;
  rep(i,D) cin >> p.at(i) >> c.at(i);
  
  vector<bool> vec_bool(D, false);
  
  rec(0,0,0,vec_bool);
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;
  
bool is_pali(string s){
  string t(s.rbegin(),s.rend());
  return s == t;
}


int main(){
  string s;
  cin >> s;
  int n = s.size();
  if (is_pali(s) && is_pali(s.substr(0,(n-1)/2)) && is_pali(s.substr((n+1)/2))){
      cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

class Solution:
    def main(self):
        N = int(input())
        A = []
        for i in range(N):
            a = list(map(lambda x: int(x)-1, input().split())) + [-1]
            A.append(a)

        hashmap = defaultdict(set)
        for i in range(N):
            hashmap[A[i][0]].add(i)

        # print(hashmap)

        cnt = 0
        old_cnt = 0
        checklist = set(range(N))

        for day in range(1, N*(N-1)+1):
            cands = set()
            for i in checklist:
                if i in hashmap and A[i][0] in hashmap[i]:
                    if i < A[i][0]:
                        cands.add((i, A[i][0]))
                    else:
                        cands.add((A[i][0], i))

            for x, y in cands:
                # print(x, y)
                hashmap[y].remove(x)
                hashmap[x].remove(y)
                hashmap[A[x][1]].add(x)
                hashmap[A[y][1]].add(y)
                A[x].pop(0)
                A[y].pop(0)
                cnt += 1

            if cnt == N*(N-1)//2:
                print(day)
                break
            elif cnt == old_cnt:
                print(-1)
                break
            else:
                old_cnt = cnt
                checklist = set().union(*cands)
                # print(cands)
                # print(checklist)


if __name__ == '__main__':
    Solution().main()


Measured memory_bytes: 71388
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

using namespace std;

typedef long long ll;

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

	int ans = b - a;

	if (b == 1) {
		cout << 0 << endl;
	}
	else if (ans <= 0) {
		cout << 1 << endl;
	}
	else {
		ans = ceil(ans / (a - 1.0)) + 1;
		cout << ans << endl;
	}
}

int main(void)
{
	solver_main();
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  ll n;cin>>n;ll m;cin>>m;
  vvl dp(1010,vl(1<<12));
  rep(i,m+1){
    rep(j,1LL<<n)dp[i][j]=INF;
  }
  dp[0][0]=0;
  for(ll i=1;i<=m;i++){
    ll a,b;cin>>a>>b;
    vl vec(b);
    rep(j,b){
      cin>>vec[j];vec[j]--;
    }
    rep(j,1LL<<n){
      dp[i][j]=min(dp[i-1][j],dp[i][j]);
      ll part=j;
      for(auto x:vec){
        if(!(part&(1LL<<x)))part^=1<<x;
        dp[i][part]=min(dp[i][part],dp[i][j]+a);
      }
    }
  }
  if(dp[m][(1LL<<n)-1]>=INF)cout<<-1<<endl;
  else cout<<dp[m][(1LL<<n)-1]<<endl;
  /*rep(i,m+1){
    rep(j,1LL<<n)cout<<dp[i][j]<<" ";
    cout<<endl;
    cout<<endl;
  }*/
}

Measured memory_bytes: 32768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << N-K+1 << endl;
  
  return 0;
}



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

#define ll  int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first 
#define ss second
#define pb push_back
#define watch(xxx) cerr<<(#xxx)<<" is "<<xxx<<"\n";

#define N 10000002

int a[N]; 
long long s[N];


int main(){

int n; scanf("%d",&n);
cout<<n+n*n+n*n*n;


	return 0;
}


Measured memory_bytes: 3760
package main

import "fmt"

func main() {
	var R int
	fmt.Scan(&R)
	var ans string
	if R < 1200 {
		ans = "ABC"
	} else if R < 2800 {
		ans = "ARC"
	} else {
		ans = "AGC"
	}
	fmt.Println(ans)
}


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

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


signed main(){
	string S;cin>>S;
	int W=0,ans=0;
	rep(i,len(S)){
		if(S[i]=='W'){
			ans+=i-W;
			W++;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  int t[n];
  rep(i, n) {
    cin >> t[i];
  }

  int m; cin >> m;
  int p[m], x[m], ans[m];
  rep(i, m) {
    cin >> p[i] >> x[i];
    int sum=0;
    rep(j, n) {
      if (j==(p[i]-1)) {
        sum+=x[i];
      } else {
        sum+=t[j];
      }
    }
    ans[i] = sum;
  }

  rep(i, m) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i) {
		scanf("%d",&x);
		if(x!=i) ++ans;
	}
	if(ans<=2) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N];
int main() {
	int n;
	scanf("%s", s);
	int ans = 0;
	n = strlen(s);
	for (int i = 1; i < n; ++ i) {
		if (s[i] != s[i - 1]) ans ++;
	}
	printf("%d\n", ans);
}



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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A, B;
  cin >> A >> B;
  int ans = 0;
  bool can = false;
  for (int i = 1; i <= 2000; i++)
  {
    if ((int)(i * 0.08) == A && (int)(i * 0.1) == B)
    {
      ans = i;
      can = true;
      break;
    }
  }
  if (can)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

case = int(input())
l = [""] * case
for i in range(case):
  l[i] = input()

c = collections.Counter(l)

values, counts = zip(*c.most_common())
cnt = 0
str_list = []
for i in range(len(counts)):
  if cnt < counts[i]:
    cnt = counts[i]
    str_list.append(values[i])
  elif cnt == counts[i]:
    str_list.append(values[i])
  else:
    break

str_list = sorted(str_list)
for tar_str in str_list:
  print(tar_str)

Measured memory_bytes: 59492
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc2(m,n);
	fu(i,0,n-1){
		sc(A[i]);
	}
	fu(i,0,n-1){
		mxz(ans,(A[(i+1)%n]-A[i]+m)%m);
	}
	pr(m-ans);
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int N=5;

int main(){
  int an[5],k,i;
  for(i=0;i<N;i++) cin>>an[i];
  cin>>k;
  bool flag=0;
  for(int j=0;j<N-1;j++){
  	for(i=j+1;i<N;i++){
    	if(an[i]-an[j]>k){
      		flag=1;
      		break;
    	}
  	}
    if(flag) break;
  }
  if(flag) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << '[';
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len-1) s << ", ";
  }
  s << ']';
  return s;
}
struct aaa{
  aaa(){
    // comment this out when you use scanf or printf
    // cin.tie(0); ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
  };
}fastio;
int main(){
  
  string s;
  ll k;
  cin >> s >> k;
  string ss = s+'#';
  ll n = s.size();
  vector<int> x;
  int cnt = 1;
  for(int i = 0; i < n; ++i){
    if(ss[i] == ss[i+1]) ++cnt;
    else {x.emplace_back(cnt); cnt = 1;}
  }
  ll mid = 0;
  for(int i = 1; i < x.size()-1; ++i){
    mid += x[i]/2;
  }
  ll ans = x.front()/2 + x.back()/2 + mid*k;
  if(s.front() == s.back()){
    ans += (x.front()+x.back())/2*(k-1);
  }
  else{
    ans += (x.front()/2 + x.back()/2)*(k-1);
  }
  if(x.size() == 1){
    cout << k*n/2 << endl; 
  }
  else{
  	cout << ans << endl;
  }
  //cerr << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdlib.h>
#include <dirent.h>
using namespace std;
#define sp << " " << 
typedef vector<int> vi;
typedef vector<long int> vli;
typedef vector<long long int> vlli;
typedef long int li;
typedef long long int lli;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<lli,lli> > vplli;
typedef unordered_map<int,int> ump;


int largest(vector<vector<int>> &adjList, vector<int> &memo, int source){
    if(memo[source]!=-1){
        return memo[source];
    }
    int ans=-1;

    for(int val : adjList[source]){
        ans = max(ans,largest(adjList, memo, val));
    } 
    memo[source]=ans+1;
    return ans+1;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> adjList(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        adjList[a-1].push_back(b-1);
    }

    vector<int> memo(n,-1);
    int maxi=0;

    for(int i=0;i<n;i++){
        maxi = max(maxi, largest(adjList, memo, i));
    }
    cout << maxi << endl;

    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<cmath>
using namespace std;
int a[110];
int main()
{
	int n,d,x;
	cin>>n>>d>>x;
	int count=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		int j=0;
		while(j*a[i]+1<=d)
		{
			count++;
			j++;
		}
	}
	count+=x;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
n,w=map(int,input().split())
items=[[0,0]]
for i in range(n):
  items.append(list(map(int,input().split())))
c=[[0 for i in range(w+1)]for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,w+1):
    if items[i][1]<=j:
      if items[i][0]+c[i-1][j-items[i][1]]>c[i-1][j]: 
        c[i][j]=items[i][0]+c[i-1][j-items[i][1]]
      else:
        c[i][j]=c[i-1][j]
    else:
      c[i][j]=c[i-1][j]
print(c[n][w])


Measured memory_bytes: 25956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            string s = Console.ReadLine();
            if(s.Length % 2 == 1) { s = s.Substring(0, s.Length - 1); }
            else { s = s.Substring(0, s.Length - 2); }
            int n = s.Length;
            for(int i=0;i<n;i+=2)
            {
                string a = s.Substring(0, s.Length / 2);
                string b = s.Substring(s.Length / 2, s.Length / 2);
                if( a == b)
                {
                    Console.WriteLine(s.Length);
                    return;
                }
                else
                {
                    s = s.Substring(0, s.Length - 2);
                }
            }
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

void solve(long long A, long long B, long long T){
    cout << (T / A) * B << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long T;
    scanf("%lld",&T);
    solve(A, B, T);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll H, W;
    cin >> H >> W;
    if (W % 3 == 0 || H % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = min(W, H);
    FOR(i, 1, H) {
        ll s1 = i * W;
        ll w = W / 2;
        ll s2 = (H - i) * w;
        ll s3 = (H - i) * (W - w);
        ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
    }
    FOR(i, 1, W) {
        ll s1 = i * H;
        ll h = H / 2;
        ll s2 = (W - i) * h;
        ll s3 = (W - i) * (H - h);
        ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 10000;

int main(){
    
    int n,x,y;
    cin>>n>>x>>y;
    --x,--y;
    vector<int> d(n-1);

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int t = min(abs(j-i), abs(i-x)+1+abs(y-j));
            d[t-1]++;
        }
    }
    for(int i : d) cout<<i<<"\n";
}



Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	c *= 2;
	int ans = 1 << 30;
	rep(i, 0, max(x, y) + 1) {
		ans = min(ans, c * i + a * max(0, x - i) + b * max(0, y - i));
	}
	printf("%d\n", ans);
	return 0;
}

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

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

	vector<vector<char>> c(h + 2, vector<char>(w + 2));

	for (int i = 0; i <= h + 1 ; i++) {
		for (int j = 0; j <= w + 1; j++) {
			if (1 <= i && i <= h && 1 <= j && j <= w) {
				cin >> c[i][j];
			}
			else {
				c[i][j] = '#';
			}
		}
	}
	
	for (int i = 0; i <= h + 1 ; i++) {
		for (int j = 0; j <= w + 1; j++) {
			cout << c[i][j];
		}
		cout << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if (S.length() == 2) {
			System.out.println(S);
		} else {
			System.out.println((new StringBuffer(S)).reverse());
		}

		return;
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,c[maxn],t[maxn];
ll dp[maxn],calc[maxn];
void init(){
	scanf("%d",&n);
	int top=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		if(c[i]!=c[i-1]) t[++top]=c[i];
	}
	dp[0]=1ll;
	for(int i=1;i<=top;i++){
		calc[t[i]]=(calc[t[i]]+dp[i-1])%mod;
		dp[i]=calc[t[i]];
	}
	printf("%lld",dp[top]);
}
int main(){
	init();
	
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;

    if(s.substr(0,7)=="keyence" || s.substr(s.size()-7,7)=="keyence"){
        cout << "YES" << endl;
        return 0;
    }

    bool ans=false;
    string str="keyence";
    for(int i=1;i<7;i++){
        if(s.substr(0,i)==str.substr(0,i) && s.substr(s.size()-7+i,7-i)==str.substr(i)){
            ans=true;
            break;
        }
    }

    if(ans)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
int main() {
	int N;
	cin >> N;
	vector<long> A(N);
	vector<ll> B(N+1);
	vector<ll> C(N + 1);
	ll ans = 0;
	

	rep(i, N + 1) {
		B[i] = 0;
		C[i] = 0;
	}
	rep(i, N) {
		cin >> A[i];
		B[A[i]]++;
	}
	rep(i, N+1) {
		C[i]=B[i]*(B[i]-1)/2;
		ans += C[i];
	}
	rep(i, N) {
		cout << ans - C[A[i]] + (B[A[i]] - 1)*(B[A[i]] - 2)/2 <<endl;
	}

}

Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int r;
	cin >> r;
	cout << r * r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d[]={5,7,5,7,7},i,j,t,k;
  while(cin>>n,n){
    string s[41];
    for(i=0;i<n;i++)cin>>s[i];
    for(i=0,k=0;k!=5;i++)
      for(j=i,t=s[i].size(),k=0;k!=5;t+=s[++j].size())
	if(t==d[k])k++,t=0;
	else if(t>d[k])break;
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	sum := make([]int, 24)
	sum[0] = 2
	for i := 0; i < n; i++ {
		d := getNextInt(scanner)
		sum[d]++
		sum[(24-d)%24]++
	}

	fmt.Fprintln(writer, solve(sum))

	writer.Flush()
}

func solve(sum []int) int {
	index := make([]int, 0)
	for i := 0; i <= 12; i++ {
		if sum[i] > 2 {
			return 0
		}
		if sum[i] == 1 {
			index = append(index, i)
		}
	}

	l := len(index)
	max := 0
	for i := 0; i < 1<<uint(l); i++ {
		for ii := 0; ii < l; ii++ {
			sum[index[ii]] = 1 & (i >> uint(ii))
			sum[24-index[ii]] = 1 - sum[index[ii]]
		}
		min := 23
		zeros := 0
		for ii := 1; ii <= 24; ii++ {
			if ii < 24 && sum[ii] == 0 {
				zeros++
				continue
			}
			if min > zeros {
				min = zeros + 1
			}
			zeros = 0
		}
		if max < min {
			max = min
		}
	}

	return max
}


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

ll l[51], p[51];

ll eat_patty(ll n, ll x) {
  if ( n == 0 )         { return 1; }
  if ( x == 1 )         { return 0; }
  if ( x <= 1+l[n-1] )  { return eat_patty(n-1, x-1); }
  if ( x == 2+l[n-1] )  { return p[n-1] + 1; }
  if ( x <= 2+2*l[n-1]) { return p[n-1] + 1 + eat_patty(n-1, x-2-l[n-1]); }
  return p[n];
}

int main() {
  ll n, x;
  cin >> n >> x;
  l[0] = 1;
  p[0] = 1;
  for ( ll i = 1; i <= n; i++ ) {
    l[i] = l[i-1]*2 + 3;
    p[i] = p[i-1]*2 + 1;
  }

  cout << eat_patty(n, x) << endl;
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0;i<n;i++)cin >> d[i];
	sort(d.begin(),d.end());
	cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
H, W = map(int, input().split())
box = []
for i in range(H):
    A = input()
    if not "#" in A:
        continue
    box.append(A)
box_t = []
for i in range(W):
    X = ""
    for j in range(len(box)):
        X += box[j][i]
    if not "#" in X:
        continue
    box_t.append(X)
for i in range(len(box_t[0])):
    for j in range(len(box_t)):
        print(box_t[j][i], end="")
    if i == len(box_t[0]) - 1:
        break
    print()

Measured memory_bytes: 4468
#include <stdio.h>

int main(void){
	char line[102];  /* 最大 100 文字 + 改行文字 + ナル文字 */

	char bracket[2][2] = {{'(', ')'}, {'[', ']'}};
	int stack[100];
	int index;

	int i, j;

	while (fgets(line, 102, stdin) != NULL){
		if (line[0] == '.') break;  /* 終了 */

		index = 0;  /* 初期化 */

		/* 判定 */
		for (i = 0; i < 100 && line[i] != '.'; i++){
			/* 2 種類の括弧それぞれについて判定する */
			for (j = 0; j < 2; j++){
				if (line[i] == bracket[j][0]){
					/* 左括弧 */
					stack[index] = j;  /* 現在どの種の括弧の中にいるかをスタックで記憶する */
					index++;
				}else if (line[i] == bracket[j][1]){
					/* 右括弧 */
					index--;
					if (index < 0 || j != stack[index]){
						/* 括弧のバランスが破綻している */
						index = -1;
						break;
					}
				}
			}
			if (j < 2) break;
		}

		/* 出力 */
		if (index == 0){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}

    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int n,i;
    n=s.length();
    int fl=0;
    for (i=0;i<n/2;i++)
    {
        if (s[i]!=s[n-i-1])
        {
            fl=1;
            break;
        }
    }
    for (i=0;i<n/4;i++)
    {
        if (s[i]!=s[n/2-i-1])
        {
            fl=1;
            break;
        }
    }
    if (!fl)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
format :: Int -> Int -> String
format i j = show i ++ " " ++ show j

solve (s:ss:[]) i j
  | s == ss = format i j
  | otherwise = format (-1) (-1)
solve (s:ss:sss) i j
  | s == ss = format i j
  | s == head sss = format i $ j + 1
  | otherwise = solve (ss:sss) (i + 1) (j + 1)

main = do
  s <- getLine
  putStrLn $ solve s 1 2


Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N,A,B;
    cin>>N>>A>>B;
    if(N>A*B || N<A+B-1) {
        cout<<-1<<endl;
        return 0;
    }
    vector<int> a(A);
    a[0]=B;
    int m=N-B;
    REPF(i,1,A) {
        a[i]=(N-B)/(A-1);
        m-=a[i];
    }
    REPF(i,1,m+1) {
        a[i]++;
    }
    vector<int> ans;
    int k=1;
    REP(i,A) {
        vector<int> tmp(a[i]);
        REP(j,a[i]) {
            tmp[j]=k++;
        }
        reverse(ALL(tmp));
        ans.insert(end(ans),ALL(tmp));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 7536
n = int(input())
while (n!=0):
    wlist = []
    for i in range(n):
        wlist.append(str(input()))
    ufr = {"u":1 ,"f":2, "r":3}
    up = 1
    for w in wlist:
        tmp = 0
        if (w == "North"):
            tmp = ufr["u"]
            ufr["u"] = ufr["f"]
            ufr["f"] = 7-tmp
        elif (w == "East"):
            tmp = ufr["r"]
            ufr["r"] = ufr["u"]
            ufr["u"] = 7-tmp
        elif (w == "West"):
            tmp = ufr["u"]
            ufr["u"] = ufr["r"]
            ufr["r"] = 7-tmp
        elif (w=="South"):
            tmp = ufr["f"]
            ufr["f"] = ufr["u"]
            ufr["u"] = 7-tmp
        elif (w=="Right"):
            tmp = ufr["f"]
            ufr["f"] = ufr["r"]
            ufr["r"] = 7-tmp
        else:
            tmp = ufr["r"]
            ufr["r"] = ufr["f"]
            ufr["f"] = 7-tmp
        up += ufr["u"]  
    print(up)   
    n=int(input())


Measured memory_bytes: 5720
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,s,td;
int main()
{
cin>>n;
td=n;
while(td>=15)td-=15,s++;
cout<<n*800-s*200<<endl;
return 0;
}

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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int arr[n+1] ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i] ;
	int ans = 0 ;
	for(int i = 1 ; i <= n-1 ; ++i)
	{
		if(arr[i] == i)
		{
			ans++ ;
			swap(arr[i] , arr[i+1]) ;
		}
	}
	if(arr[n] == n)
		ans++ ;
	return cout<<ans<<"\n" , 0 ;
}

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

int main() {
  string s;
  cin >> s;
  int l = s.size();
  
  bool ok = true;
  if(l == 3){
    if(s.at(0) != s.at(2)) ok = false;
  }
  for(int i = 0; i < (l - 1) / 2; i++){
    char c = s.at(i);
    if(c != s.at(l - 1 - i)) ok = false;
  }
  for(int i = 0; i < (l - 1) / 4; i++){
    char c = s.at(i);
    if(c != s.at(l - 1 - i) || c != s.at((l - 1) / 2 + 1 + i) || c != s.at((l - 1) / 2 - 1 - i)){
      ok = false;
    }
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> V(H+2);

    string s="";
    for(int i=0;i<W+2;i++){
        s += '#';
    }

    cout << s << endl;
    
    for(int j=1;j<H+1;j++){
        cin >> V.at(j);
        V.at(j) = '#' + V.at(j) + '#';
        cout << V.at(j) << endl;
    }

    cout << s << endl;

    



}


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

"""
・再帰検索を各辺1回通れば良くした版
"""

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

def upd_dpth(children, depth):
    for i in children:
        nodes[i][1] = depth+1 
        upd_dpth(nodes[i][2], depth+1)

N = INT()

# node: [parent, depth, children]
nodes = [[-1, 0, []] for i in range(N)]

for i in range(N):
    node = LIST()
    # 子の記録
    nodes[node[0]][2].extend(node[2:])
    # 親の更新
    for j in nodes[node[0]][2]:
        nodes[j][0] = node[0]

for i in range(N):
    # 深さの更新
    if nodes[i][0] == -1:
        # 深さを引数に持てばルートから1回回るだけで終わる
        upd_dpth(nodes[i][2], 0)

for i in range(N):
    parent, depth, children = nodes[i]
    if parent == -1:
        _type = 'root'
    elif len(children) == 0:
        _type = 'leaf'
    else:
        _type = 'internal node'
    print('node {node}: parent = {parent}, depth = {depth}, {type}, {children}'.format(
        node=i, parent=parent, depth=depth, type=_type, children=children))



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

int main() {
  int n;
  cin >>n;
  vector<int> v1(n+1,0);
  vector<int> v2(n,0);
  rep(i,n){
    cin >> v1.at(i);
  }
  rep(i,n){
    cin >>v2.at(i);
  }
  reverse(v2.begin(),v2.end());
  int sum1=0,sum2 = 0;
  rep(i,n){
    sum1 += v1.at(i);
  }
  int maxnum=0,num=sum1;
  rep(i,n){
    num = num - v1.at(n-i) + v2.at(i);
    maxnum = max(maxnum,num);
  }
  cout << maxnum << endl;
}

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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	int A, B; cin >> A ;
	B = 3 * pow(A, 2);
	cout << B << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import numpy as np

mod = 10 ** 9 + 7

def question():
    n = int(input())

    a = [0] * (n+1)
    a[1] = 1
    a[2] = 4
    a[3] = 16

    t = [0] * (n+1)
    t[1] = 1
    t[2] = 4
    t[3] = 16

    c = [0] * (n+1)
    c[1] = 1
    c[2] = 4
    c[3] = 14

    g = [0] * (n+1)
    g[1] = 1
    g[2] = 4
    g[3] = 15

    for i in range(3, n):
        a[i + 1] = a[i] + t[i] + c[i] + g[i]
        t[i + 1] = a[i] + t[i] + c[i] + g[i]
        c[i + 1] = a[i] + t[i] + c[i] + g[i] - (a[i-1] + 3 * a[i-2] + g[i-1])
        g[i + 1] = a[i] + t[i] + c[i] + g[i] - (a[i-1] - g[i-2])

        #a[i+1] = a[i+1] % mod
        #t[i+1] = t[i+1] % mod
        #c[i+1] = c[i+1] % mod
        #g[i+1] = g[i+1] % mod

    print((a[n]+t[n]+c[n]+g[n]) % mod)


question()


Measured memory_bytes: 12528
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    cout << 2*N - 1 << endl;

    auto mx = max_element(a.begin(), a.end());
    auto mn = min_element(a.begin(), a.end());
    if(abs(*mx) >= abs(*mn)) {
        int d = mx - a.begin() + 1;
        for(int i=1; i<=N; i++) {
            cout << d << ' ' << i << endl;
        }
        for(int i=2; i<=N; i++) {
            cout << i-1 << ' ' << i << endl;
        }
    } else {
        int d = mn - a.begin() + 1;
        for(int i=1; i<=N; i++) {
            cout << d << ' ' << i << endl;
        }
        for(int i=N-1; i; i--) {
            cout << i+1 << ' ' << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n,i,flg,c;
    char *str;
    scanf("%d",&n);
    str = (char*)malloc(sizeof(char)*(n+1));
    scanf("%s",str);
    flg = -1;c=0;
    for(i=0;i<n;i++){
        if(str[i]=='O'){
            if(flg==1){
                c++;
                flg = -1;
            }else{
                flg = 0;
            }
        }else{
            if(flg==0){
                c++;
                flg = -1;
            }else{
                flg = 1;
            }
        }
    }
    printf("%d\n",c);
    free(str);
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
    long double a,b,x;
   cin>>a>>b>>x;
   x=x/a;
    long double angle=0;
    long double PI =atan(1)*4;
   if(2*x<a*b)
   {
       long double c=2*x/b;
       angle=atan(c/b);
   }
   else
   {
        long double z=a*b-x;
        long double c=2*z/a;
       angle=PI/2-atan(c/a);
   }
    cout << setprecision(20) << 90 - angle * 180 /PI << endl;
return 0;
}



Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {

  val Array(s, t) = readLine().split(" ")
  val Array(a, b) = readLine().split(" ").map(_.toInt)
  val u = readLine()

  if (u == s)
    println(s"${a - 1} ${b}")
  else
    println(s"${a} ${b - 1}")
}


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

using namespace std;


int main(){

int H,R,x;

cin>>H>>R;

if(H>=0)x=1;
if(H<0&&H+R==0)x=0;
if(H<0&&H+R<0)x=-1;

cout<<x<<endl;

return 0;
}


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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int ans = c-(a-b);
    if(ans<0) ans = 0; 
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
int main() {
	int n, m,k;
	cin >> n >> m >> k;
	for (int geko = 0;geko < 2;++geko) {
		for (int i = 0;i <= n;++i) {
			int now = k - i*m;
			for (int q = 0;q <= m;++q) {
				int changed = q * (n - 2*i);
				if (now == changed) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256