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

using namespace std;

int const maxn = 1e5 + 5;
int used[maxn][4], inf = 1e9;
vector < int > g[maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, u, v, s, t;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> u >> v;
        g[u].push_back(v);
    }
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= 3; ++j) used[i][j] = inf;
    cin >> s >> t;
    used[s][1] = 0;
    vector < pair < int, int > > Q = {{s, 1}};
    int head = 0;
    while (head < (int)Q.size()) {
        v = Q[head].first;
        int pos = Q[head++].second, d = used[v][pos];
        if (pos == 3) pos = 1;
        else pos++;
        for (auto u : g[v]) {
            if (used[u][pos] == inf) {
                used[u][pos] = d + 1;
                Q.push_back({u, pos});
            }
        }
    }
    if (used[t][1] == inf) cout << -1;
    else cout << used[t][1] / 3;
    return 0;
}



Measured memory_bytes: 12784
/* ABC133-C.c
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, *dam, water, i;

    water = 0;

    scanf( "%d" , &number);

    dam = malloc(sizeof(int) * number);

    for(i=0; i < number; i++){

        scanf( "%d" , dam+i);

        if(i%2==0){ /* 交互に足したり引いたりすると、山1の水の量になる */
            
            water += *(dam+i);

        }else{

            water -= *(dam+i);

        }

    }

    printf( "%d" , water); /* 山1の降雨量 */

    for(i=1; i < number; i++){

        water = *(dam+i-1) * 2 - water; /* 連立方程式の通り */

        printf( " %d" , water); /* 山i+1の降雨量 */

    }

    printf( "\n" );

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,X,Y;scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
    int ans=2e9;
    for(int i=0;i<=max(X,Y)*2;i++){
        int now=C*i;
        now+=A*max(0,(X-i/2))+B*max(0,(Y-i/2));
        ans=min(ans,now);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
	color[u]=GRAY;
	d[u]=++tt;
	for(int v = 0;v<n;v++){
		if(M[u][v]==0) continue;
		if(color[v]==WHITE){
			dfs_visit(v);
		}
	}
	color[u]=BLACK;
	f[u]=++tt;
}

void dfs(){
	for(int u=0;u<n;u++) color[u] = WHITE;
	tt=0;
	for(int u=0;u<n;u++) if(color[u]==WHITE) dfs_visit(u);
	for(int u =0;u<n;u++) printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main(){
	int u,v,k;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		u--;
		for(int j=0;j<k;j++){
			scanf("%d",&v);
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
	return 0;
}


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

using namespace std;

#define ll long long

int main(void){

    int n,k;
    cin>>n>>k;

    ll ans = k;

    for(int i=0;i<n-1;i++)ans*=(k-1);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys
MOD = 998244353


def main():
    n, *d = map(int, sys.stdin.buffer.read().split())
    e = [0]*n
    for i in d:
        e[i] += 1
    ans = e[0]
    for i in d[1:]:
        ans = ans*e[i-1] % MOD
    print(ans)


if __name__ == '__main__':
    main()


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

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

  bool g = false;
  bool w = false;
  bool y = false;
  bool p = false;

  bool four = false;

  for (int i = 0; i < n; i++) {
    string color;
    cin >> color;

    if (color == "W")
      w = true;
    else if (color == "G")
      g = true;
    else if (color == "Y")
      y = true;
    else if (color == "P")
      p = true;

    if (g + w + y + p == 4) {
      cout << "Four" << endl;
      four = true;
      break;
    }
  }

  if (four == false)
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 998244353
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] <<" "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;



int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

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

   vector<pair<int,int>>possible;
   sort(a,a+k);
   stack<pair<int,int>> s; 
  
   
    s.push(a[0]); 
  
    for (int i = 1 ; i < k; i++) 
    { 
        // get interval from stack top 
        auto top = s.top(); 
  
        // if current interval is not overlapping with stack top, 
        // push it to the stack 
        if (top.second < a[i].first) 
            s.push(a[i]); 
  
        else if (top.second < a[i].second) 
        { 
            top.second = a[i].second; 
            s.pop(); 
            s.push(top); 
        } 
    } 

    while(s.empty() == false){
      int x1 = s.top().first;
      int x2 = s.top().second;
      possible.push_back({x1,x2});
      s.pop();
    }

    int dp[n+1] = {0};

    dp[0]  = 0;
    dp[1] = 1;
    int temp = 0;
    for(int i = 2;  i<=n ; i++){
      for(auto p : possible){
        int s = i-p.second-1;
        int e = i-p.first;
        if(s>=1){
          temp = ((temp - dp[s] +mod))%mod;
        }
        if(e>=1)
        temp = (temp+dp[e])%mod;
      }
      dp[i] = temp%mod;
    }

    cout << dp[n];

}


Measured memory_bytes: 5216
#include <cstdio>
#include <cstdlib>

using namespace std;

const int mod = 998244353;

class inverse {
    public:
    inverse(int n, int mod);
    ~inverse();
    long long get_inv(int x);
    long long get_fact(int x);
    long long get_invfact(int x);
    long long get_comb(int x, int y);
    
    private:
    int mod;
    long long* inv;
    long long* fact;
    long long* invfact;
};

inverse::inverse(int n, int mod) : mod(mod) {
    inv = (long long *)malloc(sizeof(long long) * (n + 1));
    fact = (long long *)malloc(sizeof(long long) * (n + 1));
    invfact = (long long *)malloc(sizeof(long long) * (n + 1));
    inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invfact[i] = invfact[i - 1] * inv[i] % mod;
}

inverse::~inverse() {
    free(inv);
    free(fact);
    free(invfact);
}

long long inverse::get_inv(int x) {
    return inv[x];
}

long long inverse::get_fact(int x) {
    return fact[x];
}

long long inverse::get_invfact(int x) {
    return invfact[x];
}

long long inverse::get_comb(int x, int y) {
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
}

int main() {
    int n, m, i;
    long long ans;
    inverse inv(3000000, mod);
    
    scanf("%d %d", &n, &m);
    
    ans = inv.get_comb(m * 3 + n - 1, n - 1);
    
    for (i = m * 2 + 1; i <= m * 3; i++) {
        ans -= inv.get_comb(m * 3 - i + n - 2, n - 2) * n % mod;
        if (ans < 0) ans += mod;
    }
    
    for (i = m + 1; i <= m * 3 && i <= n; i++) {
        if ((m * 3 - i) % 2 == 1) continue;
        
        ans -= inv.get_comb((m * 3 - i) / 2 + n - 1, n - 1) * inv.get_comb(n, i) % mod;
        if (ans < 0) ans += mod;
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x=0,y=0,m=0;
    cin>>a>>b;
    int n=b;
    while(b>0)
    {
       b/=10;
       a=a*10 ;
    }
    m=a+n;
    x=sqrt(m);
    y=x*x;
    if(y==m)
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;l;end
cldd(x,y)=y==0?10^18:fld(x,y)+1


function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap |> sort
	nc = bsearch(a,0)
	b = Int[]
	for i in 1:nc
		push!(b,a[i])
	end
	c = Int[]
	for i in nc+1:n
		push!(c,a[i])
	end
	if nc*(n-nc)>=k
		l = b[1]*c[n-nc]-1
		r = 1
		while r-l>1
			m = (l+r)>>1
			s = 0
			for i in 1:nc
				s += n-nc-bsearch(c,cld(-m,-b[i]))
			end
			if s>=k
				r = m
			else
				l = m
			end
		end
		println(r)
	else		
		l = -1
		r = max(a[n]*a[n-1],a[1]*a[2])+1
		b = sort(Int[-b[i] for i in 1:nc])
		while r-l>1
			m = (l+r)>>1
			s = 0
			for i in 1:nc
				t = bsearch(b,cldd(m,b[i]))
				s += min(t,i-1)
			end
			for i in 1:n-nc
				t = bsearch(c,cldd(m,c[i]))
				s += min(t,i-1)
			end
			if s+nc*(n-nc)>=k
				r = m
			else
				l = m
			end
		end
		println(r)
	end
end

main()

Measured memory_bytes: 134564
#include<stdio.h>
int main(void){
  int N,D[100][2],count=0,max=0;
  
  scanf("%d",&N);
  
  for(int i=0; i<N; i++){
    scanf("%d %d", &D[N][0], &D[N][1]);
    if(D[N][0] == D[N][1]){
      count++;
      if(count>max)
        max=count;
    }
    else
      count=0;
  }
  
  if(max>=3)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int h, w, n, k = 0;
    cin >> h >> w >> n;
    int arr[n], ans[h][w];
    for(int i = 0;i < n;++i)
        cin >> arr[i];
    bool shuf = 1;
    for(int i = 0;i < h;++i)
    {
        if(shuf)
        {
            for(int j = 0;j < w;++j)
            {
                k += (!arr[k]);
                ans[i][j] = k + 1;
                --arr[k];
            }
        }
        else
        {
            for(int j = w - 1;j >= 0;--j)
            {
                k += (!arr[k]);
                ans[i][j] = k + 1;
                --arr[k];
            }
        }
        shuf = !shuf;
    }
    for(int i = 0;i < h;++i)
    {
        for(int j = 0;j < w;++j)
            cout << ans[i][j] << ' ';
        cout << '\n';
    }
    return 0;
}


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

struct Problem {
public:
	UL N, S;
	UL A[3000];
	static const ULL M = 998244353;
	ULL dp[3001][3001] = {};
	static const ULL i2 = 998244353 / 2 + 1;

	void Solve() {
		scanf("%u%u", &N, &S);
		rep(i, N) scanf("%u", A + i);
		dp[0][0] = 1;
		rep(i, N) {
			rep(j, S + 1) dp[i + 1][j] = dp[i][j];
			for (UL j = A[i]; j <= S; j++) {
				dp[i + 1][j] += dp[i][j - A[i]] * i2;
				dp[i + 1][j] %= M;
			}
		}
		ULL mul = 1;
		rep(i, N) mul = mul * 2 % M;
		ULL ans = dp[N][S] * mul % M;
		cout << ans << endl;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


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

int n, m;
int s[10][10];
int p[10];

bool check_lump(int number, int s1, int s2, int s3, int s4, int s5, int s6, int s7, int s8, int s9, int s10) {

	if ((s[number][0] * s1 + s[number][1] * s2 + s[number][2] * s3 + s[number][3] * s4
		+ s[number][4] * s5 + s[number][5] * s6 + s[number][6] * s7 + s[number][7] * s8
		+ s[number][8] * s9 + s[number][9] * s10) % 2 == p[number]) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int count = 0;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			s[i][j] = 0;
		}
	}

	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int temp;
			cin >> temp;
			s[i][temp - 1] = 1;
		}
	}

	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	for (int s1 = 0; s1 <= 1; s1++) {
		for (int s2 = 0; s2 <= 1; s2++) {
			for (int s3 = 0; s3 <= 1; s3++) {
				for (int s4 = 0; s4 <= 1; s4++) {
					for (int s5 = 0; s5 <= 1; s5++) {
						for (int s6 = 0; s6 <= 1; s6++) {
							for (int s7 = 0; s7 <= 1; s7++) {
								for (int s8 = 0; s8 <= 1; s8++) {
									for (int s9 = 0; s9 <= 1; s9++) {
										for (int s10 = 0; s10 <= 1; s10++) {
											bool check = true;

											for (int i = 0; i < m; i++) {
												if (check_lump(i, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) == false) {
													check = false;
													break;
												}
											}

											if (check) {
												count++;
											}

										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	int div = 1;

	for (int i = 0; i < 10 - n; i++) {
		div *= 2;
	}

	cout << count / div << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for _ in range(H)]

import sys
dd = [(1,0),(-1,0),(0,1),(0,-1)]
for h in range(H):
    for w in range(W):
        if S[h][w]=="#":
            chk = False
            for (dw,dh) in dd:
                if 0<=h+dh<H and 0<=w+dw<W:
                    if S[h+dh][w+dw]=="#":
                        chk = True
                        break
            if not chk:
                print("No")
                sys.exit()

print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int main()
{
  int H, W, i, j;
  cin >> H >> W;
  string pic;
  
  rep(i,W+2){cout<<'#';}
  cout << endl;
  
  rep(j,H)
  {
    cin >> pic;
    cout << '#' << pic << '#' << endl;
  }
  
  rep(i,W+2){cout<<'#';}
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1001][1001];
string s,t;
int n,m,a,ans;
int main(){
  cin>>a;
  for(int b=0;b<a;b++){
    cin>>s>>t;
    for(int i=0;i<=1000;i++)
      for(int j=0;j<=1000;j++)
	dp[i][j]=0;
    m=s.size();
    n=t.size();
    ans=0;
    for(int i=1;i<=m;i++){
      for(int j=1;j<=n;j++){
	if(s[i-1]==t[j-1]){
	  dp[i][j]=dp[i-1][j-1]+1;
	}else{
	  dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
      }
    }  
    cout<<dp[m][n]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7108
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
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;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

signed main()
{
   int N, S; cin >> N >> S;
   V<int> a(N);
   REP(i, N) {
      cin >> a[i];
   }

   int l = 0, r = 0, s = 0;
   int ans = INF;
   for (;;) {
      while (r < N && s < S) {
         s += a[r++];
      }
      if (s < S) break;
      chmin(ans, r - l);
      s -= a[l++];
   }
   cout << (ans == INF ? 0 : ans) << endl;

   return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;cin>>s;
    char odd[3]={'R','U','D'},even[3]={'L','U','D'};
    for(int i=1;i<=s.size();i++){
        char t=s[i-1];
        bool jud=false;
        if(i%2!=0){
            for(int j=0;j<3;j++){
                if(odd[j]==t){
                    jud=true;
                    break;
                }
            }
        }
        else{
            for(int j=0;j<3;j++){
                if(even[j]==t){
                    jud=true;
                    break;
                }
            }
        }
        if(!jud){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val s = scanner.next()
    var count = 1
    var check = true
    for(item in s){
        if(count % 2 !== 0 && (item != 'R' && item != 'U' && item != 'D')) check = false
        else if(count % 2 === 0 && (item != 'L' && item != 'U' && item != 'D')) check = false
        if(!check) {
            println("No")
            return
        }
      count++
    }
    println("Yes")
}

Measured memory_bytes: 31388
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main() {
  ll N,K;
  cin>>N>>K;
  cout << min(N, ((K-N)%K +K)%K) << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

card = np.array([list(map(int, input().split())) for i in range(3)])

n = int(input())

number = [int(input()) for i in range(n)]

hit = np.vectorize(lambda x: x in number)(card)

row = hit.all(axis=0).any()
col = hit.all(axis=1).any()

diag1 = hit[0][0] and hit[1][1] and hit[2][2]
diag2 = hit[0][2] and hit[1][1] and hit[2][0]

print('Yes' if row or col or diag1 or diag2 else 'No')

Measured memory_bytes: 12488
#include <iostream>
#include <string>

using namespace std;

string solve(const string &S)
{
	for (int i = 0; i < S.size(); ++i) {
		if (i % 2 == 0) {
			if (string("RUD").find(S[i]) == string::npos) {
				return "No";
			}
		}
		else {
			if (string("LUD").find(S[i]) == string::npos) {
				return "No";
			}
		}
	}
	return "Yes";
}

int main()
{
	string S;
	cin >> S;
	cout << solve(S) << endl;
}


Measured memory_bytes: 256
function Main(input) {
    var result;
    const N = parseInt(input[0])
    const S = input[1]
    const K = parseInt(input[2])-1
    
    const target = S.charAt(K);
    var ret = "";
    for(var i = 0; i < N; i++){
        ret += S.charAt(i) == target ? target : "*";
    }
    console.log(ret);
}

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int P;
int add(int a,int b)
{
	return (a+b>=P)?(a+b-P):(a+b);
}
int mul(int a,int b)
{
	return 1LL * a * b % P;
}
int fpow(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=mul(res,a);
		a=mul(a,a);
		b>>=1;
	}
	return res;
}
char a[10],b[10];
int main()
{
	scanf("%s%s",a,b);
	int s=0;
	for(int i=0;i<3;++i)
		s+=(a[i]==b[i]);
	cout<<s;
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(a, b, c);
    a -= c;
    cout << a / (b+c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n, m;
char s[1001];
char t[1001];
int dp[1001][1001];

int main(){
	scanf("%s%s", s, t);
	n = strlen(s);
	m = strlen(t);

	rep(i, n + 1){
		dp[i][0] = i;
	}
	rep(i, m + 1){
		dp[0][i] = i;
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m ; ++j){
			dp[i][j] = min(dp[i - 1][j - 1] + (s[i - 1] != t[j - 1]), min(dp[i][j - 1], dp[i - 1][j]) + 1);
		}
	}
	printf("%d\n", dp[n][m]);
	return 0;
}

Measured memory_bytes: 4880
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();   
        int[] num = new int[N];
        for(int i=0;i<N;i++)
            num[i] = sc.nextInt();
        for(int i=0;i<N;i++){
            System.out.print(num[i]);
            if(i!=N-1)
                System.out.print(" ");
        }
        System.out.println();
        for(int i=1;i<=N-1;i++){
            for(int j=i;j>0;j--){
                if(num[j-1]>num[j]){
                    int tmp = num[j-1];
                    num[j-1]=num[j];
                    num[j]=tmp;
                }
                else break;
            }
            for(int k=0;k<N;k++){
            System.out.print(num[k]);
            if(k!=N-1)
            System.out.print(" ");
            }
            System.out.println();
 
        }
    }
}


Measured memory_bytes: 34100
s = input() + "."
comp = []

cur = s[0]
streak = 0
count = 0

for i in range(len(s)):
    if s[i] == cur:
        streak += 1
    else:
        if (len(comp) == 0):
            if cur == ">":
                count += streak*(streak+1)//2
            elif i == (len(s) - 1):
                count += streak*(streak+1)//2
        elif cur == ">":
            prevStreak = comp[-1][1]
            count += (prevStreak*(prevStreak+1) + streak*(streak+1)) // 2
            count -= min(streak, prevStreak)
        elif i == (len(s) - 1):
            if cur == "<":
                count += streak*(streak+1)//2

        comp.append((cur, streak))
        streak = 1
        cur = s[i]

print(count)

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

using namespace std;

bool isKaibun(string s, int begin, int end){
    bool flag = true;
    while(begin < end){
        if(s[begin] == s[end]){

        }else{
            flag = false;
            break;
        }
        begin ++;
        end --;
    }
    return flag;
}

int main(void){
    string S;
    cin >> S;
    int n = S.length();
    if(isKaibun(S, 0, n-1) && isKaibun(S, 0 , (n-1) / 2 - 1) && isKaibun(S, (n + 3) / 2 - 1, n - 1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

int main(){
	ll A,B,C;cin>>A>>B>>C;
	ll ans=0;
	if(A%2==B%2&&B%2!=C%2){
		A++;
		B++;
		ans++;
	}
	if(A%2!=B%2&&B%2==C%2){
		C++;
		B++;
		ans++;
	}
	if(A%2==C%2&&B%2!=C%2){
		C++;
		A++;
		ans++;
	}
	//cout<<A<<" "<<B<<" "<<C<<endl;
	ll ma=max(A,max(B,C));
	ans+=(ma-A)/2;
	ans+=(ma-B)/2;
	ans+=(ma-C)/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,k;
  cin >> n >> k;
  
  vector<ll>p(n),c(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,n) cin >> c[i];
  ll ans = *max_element(c.begin(),c.end());
  rep(i,n){
    vector<ll> num;
    int now = i;
    do{
      now = p[now];
      num.push_back(c[now]);
    }while(now != i);
    
    int sz=num.size();
    rep(j,sz-1)num[j+1]+=num[j];
    
    if(k<=sz){
      rep(j,k) ans=max(ans,num[j]);
    }
    else{
      if(num[sz-1] <=0 ){
        rep(j,sz)ans=max(ans,num[j]);
      }
      else{
        ans=max(ans,num[sz-1]*(k/sz));
        rep(j,k%sz)ans=max(ans,num[sz-1]*(k/sz)+num[j]);
        if(k/sz>0){
          rep(j,sz)ans=max(ans,num[sz-1]*(k/sz-1)+num[j]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(){
    ll N;cin>>N;
    string ans;
    while(N>0){
        if(N%26>0)ans.push_back(N%26-1+'a');
        else{ans.push_back('z');N--;}
        N/=26;
    }
    reverse(ans.begin(), ans.end());
    co(ans);
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
	int i,n,pm,pj,pe;
	double avg,emav;
	char type;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d%d%d",&pm,&pe,&pj);
			avg = (pm+pe+pj) / 3.0;
			emav = (pm+pe) / 2.0;
			if(pm==100.0||pe==100.0||pj==100.0||emav>=90.0||avg>=80.0) type = 'A';
			else if(avg>=70.0) type = 'B';
			else if(avg>=50.0&&(pe>=80.0||pm>=80.0)) type = 'B';
			else type = 'C';
			printf("%c\n",type);
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
// ⊂_ヽ
// 　 ＼＼ 
// 　　 ＼(´･_･`) Hello World!!
// 　　　 >　⌒ヽ
// 　　　/ 　 へ＼
// 　　 /　　/　＼＼
// 　　 ﾚ　ノ　　 ヽ_つ
// 　　/　/
// 　 /　/|
// 　(　(ヽ
// 　|　|、＼
// 　| 丿 ＼ ⌒)
// 　| |　　) /
// ノ )　　Lﾉ
// (_／

// 😥😥😥
// 🤔🤔🤔
// 🤗🤗🤗
// 🥳🥳🥳

/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int r; cin >> r;
  cout << 3 * r * r << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MAXN = 2e5 + 5;

int n, k;
long long int ans;
int arr[MAXN];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }
    k = n - k;
    std::sort(arr + 1, arr + n + 1);
    for (int i = 1; i <= k; ++i) {
        ans += arr[i];
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

int main()
{
	string s;
	cin>>s;
	for(ll i=0;i<s.length();i++)
	{
		if(s[i]=='?')
		{
			s[i]='D';
			// if(i+1<s.length() && s[i+1] == 'D')
			// 	s[i]='P';
			// else if(i+1<s.length() && s[i+1] == '?')
			// {
			// 	s[i]='P';
			// 	s[i+1]='D';
			// 	i++;
			// }
			// else if(i-1>=0 && s[i-1]=='P')
			// 	s[i]='D';
			// else
			// 	s[i]='D';
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, A, B;
	cin >> N;
	priority_queue<pair<int, int>, vector<pair<int, int>>,  greater<pair<int, int>>> a;
	for (int i = 0; i < N; ++i) {
		cin >> A >> B;
		a.emplace(A, 1);
		a.emplace(1 + B, -1);
	}
	vector<pair<int, int>> b;
	b.emplace_back(a.top().first, a.top().second);
	a.pop();
	while (!a.empty()) {
		if (a.top().first == b.back().first) b.back().second += a.top().second;
		else b.emplace_back(a.top().first, a.top().second + b.back().second);
		a.pop();
	}
	cout << max_element(b.begin(), b.end(), [](pair<int, int>& a, pair<int, int>& b) { return a.second < b.second; })->second << endl;
}


Measured memory_bytes: 7552
from sys import stdin, stdout
from collections import defaultdict, deque

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def main():
	n = int(rl())
	A = deque((int(x) for x in rll()))
	A.appendleft(0)
	store = defaultdict(lambda: 0)
	#j - i = A[j] + A[i]
	#-(A[i] + i) = A[j] - j
	ans = 0
	for i in range(1, n+1):
		val = A[i] - i 
		ans += store[val]
		store[-(A[i] + i)] += 1
	stdout.write(str(ans));stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 134620
#include<stdio.h>
#include <string.h>
#include<iostream>
using namespace std;

int main()
{
    int x[5];


    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
    }


    for (int i = 0; i < 5; i++)
    {
        if(x[i]==0)
            printf("%d",i+1);

    }

    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	if (s[0] == 'R') {
		if (s[1] == 'R') {
			if (s[2] == 'R')cnt = 3;
			else cnt = 2;
		}
		else cnt = 1;
	}
	else {
		if (s[1] == 'R') {
			if (s[2] == 'R')cnt = 2;
			else cnt = 1;
		}
		else {
			if (s[1] == 'R' && s[2] == 'R') {
				cnt = 2;
			}
			else if (s[1] == 'R' || s[2] == 'R') {
				cnt = 1;
			}
		}
	}
	cout << cnt << endl;
	

	return 0;
}

Measured memory_bytes: 3588
#include <iostream> // cin, cout
#include <algorithm> // sort
#include <vector> // vector
#include <cstdio> // printf
#include <cmath> // M_PI
#include <numeric> // accumulate
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

long long sum(vector<long long> v) {
	long long ans = 0;
	rep(i, v.size())
		ans += v.at(i);
	return (ans);
}

int		main(void)
{
	int n;
	cin >> n;
	vector<long long> v(n);
	rep(i, n)
		cin >> v.at(i);
	cout << *min_element(v.begin(), v.end()) << " ";
	cout << *max_element(v.begin(), v.end()) << " ";
	cout << sum(v) << endl;
	return (0);
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a,a+n);

  ll sum = 0, rec = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum > x) {
      rec = i;
      break;
    }
    if(sum == x) {
        rec=i+1;
        break;
    }
    if (sum < x && i == n - 1) {
      rec = i;
    }
  }

  cout << rec << endl;
}

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

int n,buf,s;

int main(){
    cin >> n;
    buf = n;
    while(buf != 0){
        s = s + buf % 10;
        buf = buf / 10;
    }
    if(n % s == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def q2():
    N, K = (int(i) for i in input().split())
    ans = [True]*N

    for i in range(K):
        d = int(input())
        A = [int(i) for i in input().split()]
        for a in A:
            ans[a-1] = False

    print(ans.count(True))


if __name__ == '__main__':
    q2()


Measured memory_bytes: 9148
#include <iostream>

using namespace std;

int
main ()
{

  string s;
  cin >> s;
  if (s == "Sunny")
    {
      cout << "Cloudy";
    }
  else if (s == "Cloudy")
    {
      cout << "Rainy";
    }
  else if (s == "Rainy")
    {
    cout << "Sunny";}
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    sc.close();
    int[] cnt = new int[n];
    
    for (int i=0; i<n; i++) cnt[i]=0;
    
    for (int x=1; x<=(int)Math.sqrt((int)n); x++) {
      for (int y=1; y<=(int)Math.sqrt((int)n); y++) {
        for (int z=1; z<=(int)Math.sqrt((int)n); z++) {
          int ans = x*x+y*y+z*z+x*y+x*z+y*z;
          if (ans <= n) cnt[ans-1]++;
        }
      }
    }
    
    for (int i=0; i<n; i++)
      System.out.println(cnt[i]);
  }
}

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

int main(){
    int n; cin>>n;
    n %=1000;
    if(n!=0){
        cout << 1000 - n << endl;
}else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int R, G, B, n;
	cin >> R >> G >> B >> n;
	int ans = 0;
	for(int r = 0; r*R <= n; r++){
		for(int g = 0; g*G <= n; g++){
			int bB = n - r*R - g*G;
			if(0 <= bB && bB <= n && bB % B == 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define lint long long
#define P pair<int, int>

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

    int A[N];

    map<int, int> cnt;

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

    int ans = 0;

    for(auto e : cnt){
        ans += (e.second % 2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    string S;
    cin >> N >> S;
    map<char, ll> m;
    for(auto c: S) m[c]++;
    ll ans=1;
    for(auto x: m){
        ans *= (x.second + 1);
        ans %= mod;
    }
    cout << ans-1;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

const int cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int > origin, std::pair< char, int > another )
{
    return origin.second > another.second;
}

int main()
{
    int a,b,c,d;
    std::cin>> a;
    std::cin>> b;
    std::cin>> c;

    if( a < b )
    {
        d = b;
    }
    else
    {
        d = a;
    }

    a = c / d;

    if( c % d != 0 )
    {
        a += 1;
    }

    std::cout<< a;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
#define nl (next_num<lint>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
const int N=100010;
lint x[N],ans[N];
int perm[N],lst[N];
bool vis[N];
int main(){
	int n=ni;
	lint sum=0;
	for(int i=1;i<=n;i++){
		sum+=x[i]=nl-sum,perm[i]=i;
	}
	int tot=ni;
	lint K=nl;
	for(int x;tot--;x=ni,swap(perm[x],perm[x+1]));
	for(int i=1;i<=n;i++){
		int ls=0;
		for(int j=i;!vis[j];lst[ls++]=j,vis[j]=true,j=perm[j]);
		for(int j=0;j<ls;j++){
			ans[lst[j]]=x[lst[(K+j)%ls]];
		}
	}
	for(int i=1;i<=n;i++){
		printf("%lld.0\n",ans[i]+=ans[i-1]);
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int main() {
	int a[4], b[4];
	
	a[0] = -1;
	cin >> a[0];
	
	while (a[0] != -1) {
		cin >> a[1] >> a[2] >> a[3];
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		
		int hit = 0;
		int bite = 0;
		
		for (int i = 0; i < 4; i++) {
			if (a[i] == b[i]) hit++;
		}
		
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i == j) continue;
				
				if (a[i] == b[j]) {
					bite++;
					break;
				}
			}
		}
		
		cout << hit << " " << bite << endl;
		
		a[0] = -1;
		cin >> a[0];
	}
	
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;

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

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
		int n = scan.nextInt();
		int r = scan.nextInt();
        
        out.println(n >= 10 ? r : r + (100 * (10 - n)));
        out.close();
        
    }
}

Measured memory_bytes: 35764
#include<stdio.h>

int main()
{
    int n,b,r,sum=0;
    scanf("%d",&n);
    b=n;
    while(n>0)
    {
        r=n%10;
        sum=sum*10+r;
        n=n/10;
    }

    if(sum==b)
    printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
//arc073_d.cpp
//Tue Jul  9 19:17:26 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

int main(){
	ll n,W;
	cin >> n >> W;

	vector<P> wv;
	for (int i=0;i<n;i++){
		ll w,v;
		cin >> w >> v;
		wv.push_back(make_pair(w,v));
	}

	ll baseweight = wv[0].first;
	ll weightnum[4];
	fill(weightnum,weightnum+4,0);
	sort(wv.begin(),wv.end(),greater<P>());
	for (int i=0;i<n;i++){
		weightnum[wv[i].first-baseweight]++;
	}

	ll ans = 0;
	for (int i=0;i<=weightnum[0];i++){
		for (int j=0;j<=weightnum[1];j++){
			for (int k=0;k<=weightnum[2];k++){
				for (int l=0;l<=weightnum[3];l++){
					ll tempval = 0;
					ll tempnum[4];
					tempnum[0] = i;
					tempnum[1] = j;
					tempnum[2] = k;
					tempnum[3] = l;
					ll tempweight = 0;
					for (int m=0;m<n;m++){
						if (wv[m].first==baseweight && tempnum[0]>0){
							tempval += wv[m].second;
							tempweight += wv[m].first;
							tempnum[0]--;
						}else if (wv[m].first==baseweight+1 && tempnum[1]>0){
							tempval += wv[m].second;
							tempweight += wv[m].first;
							tempnum[1]--;
						}else if (wv[m].first==baseweight+2 && tempnum[2]>0){
							tempval += wv[m].second;
							tempweight += wv[m].first;
							tempnum[2]--;
						}else if (wv[m].first==baseweight+3 && tempnum[3]>0){
							tempval += wv[m].second;
							tempweight += wv[m].first;
							tempnum[3]--;
						}
					}
					if (ans < tempval && tempweight<=W){
						ans = tempval;
					}
//					cout << i << " " << j << " " << k << " " << l << " " << tempval << endl;
				}
			}
		}
	}
	cout << ans << endl;

}

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

int main( void ) {
    
    string str;
    cin >> str;
    
    int p1 = -1, p2 = -1;
    for( int i = 0; i < str.length(); i ++ ) {
        if( str[i] == 'A' && p1 == -1 )
            p1 = i;
        if( str[i] == 'Z' )
            p2 = i;
    }
    
    cout << p2 - p1 + 1;
    return 0;
}

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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    int n = s.size();

    bool ok = true;
    int j = n-1;
    for (int i=0; i<j; ++i) {
        //cout << "i: " << i << " j: "<< j << " si: " << s[i] << " sj: " <<  s[j] << endl;
        if (s[i]!=s[j]) ok = false;
        --j;
    }

    j = ((n-1)/2)-1;
    for (int i=0; i<j; ++i) {
        //cout << "i: " << i << " j: "<< j << " si: " << s[i] << " sj: " <<  s[j] << endl;
        if (s[i]!=s[j]) ok = false;
        --j;
    }
    j = (n+3)/2-1;
    for (int i=n-1; i>j; --i) {
        //cout << "i: " << i << " j: "<< j << " si: " << s[i] << " sj: " <<  s[j] << endl;
        if (s[i]!=s[j]) ok = false;
        ++j;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}











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

int main()
{
	int N;
	cin>>N;
	for(int i=0; i<N; i++){
		int x,y,b,p,sum1=0,sum2=0;
		cin>>x>>y>>b>>p;
		sum1=x*b + y*p;
		if(b<5)
			b=5;
		if(p<2)
			p=2;
		sum2=(x*b + y*p)*0.8;

		if(sum2<sum1)
			cout<<sum2<<endl;
		else
			cout<<sum1<<endl;
	}
	
	return 0;
}
		

Measured memory_bytes: 1160
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define M_PI 3.14159265358979323846
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
      ll n;
      cin>>n;
      std::vector<ll> g[n+1];
      rep(i,2,n+1)
      {
        ll x;
        cin>>x;
        g[x].pb(i);
      }
      rep(i,1,n+1) cout<<sz(g[i])<<endl;

    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }


Measured memory_bytes: 14512