akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

/**
 * A_
 */
public class Main {

    public static void main(String[] args) {
        run();
    }

    public static void run() {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        //node set
        Node[] node = new Node[n];
        boolean[] root = new boolean[n];

        Arrays.fill(root, true);

        for(int i=0; i<n; i++) {

            int id = sc.nextInt();
            int k = sc.nextInt();
            int[] c = new int[k];

            for(int j=0; j<k; j++) {

                c[j] = sc.nextInt();
                root[c[j]] = false;

            }

            node[id] = new Node(c);

        }

        for(int i=0; i<n; i++) {

            if(root[i]) {
                make(node, i, -1, 0);
            }

        }

        export(node, n);
        sc.close();

    }

    public static void make(Node[] nodes, int id, int parent, int depth) {

        StringBuilder sb = new StringBuilder();

        sb.append("node ").append(id).append(": parent = ").append(parent).append(", depth = ").append(depth).append(", ");
        if(parent == -1) {
            sb.append("root");
        } else if(nodes[id].c.length == 0) {
            sb.append("leaf");
        } else {
            sb.append("internal node");
        }
        sb.append(", [");
        for(int i=0; i < nodes[id].c.length; i++) {

            sb.append(nodes[id].c[i]);
            if(i != nodes[id].c.length-1) {
                sb.append(", ");
            }
            make(nodes, nodes[id].c[i], id, depth+1);

        }
        sb.append("]");
        nodes[id].tree = sb.toString();

    }

    public static void export(Node[] node, int n) {

        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n; i++) {
            sb.append(node[i].tree).append("\n");
        }
        System.out.print(sb);

    }

}

class Node {

    public int[] c;
    public String tree; //retain tree information
    public Node(int[] c) {
        this.c = c;
    }

}


Measured memory_bytes: 159916
N = int(input())
a = map(int, input().split())

cnt = {}
for x in a:
    if x not in cnt:
        cnt[x] = 0
    cnt[x] += 1

# print(cnt)
ans = 0
for k, v in cnt.items():
    if k == v:
        continue
    if k < v:
        ans += v - k
    else:
        ans += v

print(ans)


Measured memory_bytes: 66088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
 
int main(){
    string N; cin >> N;
 
    rep(i,3){
        if(N[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
const double &eps = 1e-4;


int main()
{
    cin.sync_with_stdio(0);

    LD A, B;
    cin >> A >> B;

    cout << LL(A * B + eps);
}

Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  lint res=0;
  rep1(i,n-1){
    if(a[i]<a[i-1]){
      res+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 4832
/*
    @uthor: Amit Kumar
    user --> CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"

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

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
        ll k;
        cin>>k;
        string word;
        cin>>word;
        if(word.size()<=k) cout<<word;
        else {
            string temp = word.substr(0,k);
            cout<<temp<<"...";
        }
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	double v = 0;

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(fscanf(fp, "%lf", &v) != EOF){
#else
	while(scanf("%lf", &v) != EOF){
#endif
		double y = 4.9 * pow(v / 9.8, 2.0);
		int N = (int)std::ceil(y / 5.0 + 1.0);

		std::cout << N << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 3200
def submit():
    n, k = map(int, input().split())
    s = input()

    dlist = []
    dlist.append([s[0], 1])
    for c in s[1:]:
        if c == dlist[-1][0]:
            dlist[-1][1] += 1
        else:
            dlist.append([c, 1])

    curr = 0
    for i in range(1, len(dlist), 2):
        if curr < k:
            if dlist[i][0] == 'R':
                dlist[i][0] = 'L'
            else:
                dlist[i][0] = 'R'
            curr += 1

    unhappy = 0
    for i in range(len(dlist) - 1):
        if dlist[i][0] == 'R' and dlist[i + 1][0] == 'L':
            unhappy += 2
    if dlist[0][0] == 'L':
        unhappy += 1
    
    if dlist[-1][0] == 'R':
        unhappy += 1

    print(n - unhappy)

submit()
        

Measured memory_bytes: 13428
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  long long ga,sa,ba,gb,sb,bb;
  cin>>ga>>sa>>ba;
  cin>>gb>>sb>>bb;
  
  int max_n = 5000+1;
  int max_x = 5000*5000+1;
  long long dp[max_n];
  //Aでどんぐりをどんぐりと金属が混ざったものに変え、Bでどんぐりと金属が混ざったものをどんぐりのみにする。
  for(long long i=0;i<=n;i++){
    dp[i] = i;//とくに取引を行わない場合
    if(i-ga>=0){
      dp[i] = max(dp[i],dp[i-ga]+gb);
    }
    if(i-sa>=0){
      dp[i] = max(dp[i],dp[i-sa]+sb);
    }
    if(i-ba>=0){
      dp[i] = max(dp[i],dp[i-ba]+bb);
    }
  }
  
  long long dp2[max_x];
  //Bでどんぐりをどんぐりと金属が混ざったものに変え、Aでどんぐりと金属が混ざったものをどんぐりのみにする。
  for(long long i=0;i<=dp[n];i++){
    dp2[i] = i;//とくに取引を行わない場合
    if(i-gb>=0){
      dp2[i] = max(dp2[i],dp2[i-gb]+ga);
    }
    if(i-sb>=0){
      dp2[i] = max(dp2[i],dp2[i-sb]+sa);
    }
    if(i-bb>=0){
      dp2[i] = max(dp2[i],dp2[i-bb]+ba);
    }
  }
  
  long long ans;
  ans = dp2[dp[n]];
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 195584
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_cols<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let upper_cols = read_cols::<i32>();
    let lower_cols = read_cols::<i32>();

    assert_eq!(n, upper_cols.len());
    assert_eq!(n, lower_cols.len());

    let lower_sum: i32 = lower_cols.iter().sum::<i32>();

    let m = upper_cols
        .iter()
        .zip((0..1).chain(lower_cols.into_iter()))
        .map(|(u, l)| u - l)
        .scan(lower_sum, |s, diff| {
            *s += diff;
            Some(*s)
        })
        .max()
        .unwrap();

    println!("{}", m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
   ll N;
   cin>>N;
   ll Ans=N+100;
   rep(i, N+1){
       ll Cou=0;
       ll T=i;
       while(T>0){
           Cou+=T%6;
           T/=6;
       }
       T=N-i;
       while(T>0){
           Cou+=T%9;
           T/=9;
       }
       Ans=min(Ans, Cou);
   }
   cout<<Ans<<endl;
   return 0;
}



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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, ans = 1; cin >> n; int pre[n+2]={}, pos[n+2]={}, a[n+1];

    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        pre[i] = __gcd(pre[i-1], a[i]);
    }

    for(int i = n; i >= 1; i--) pos[i] = __gcd(pos[i+1], a[i]);

    for(int i = 1; i <= n; i++) ans = max(ans, __gcd(pre[i-1], pos[i+1]));

    cout << ans;
}

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

int main()
{
  string s;
  int a, b;
  while(true)
  {
    for(int i = 0; i < 3; i++)
    {
      a = b = 0;
      cin >> s;
      if(s[0] == '0')
        return 0;

      for(int j = 1; j < s.length(); j++)
      {
        if(s[j] == 'A')
          a++;
        else
          b++;
      }
      if(a > b)
        a++;
      else
        b++;
      cout << a << " " << b << endl;
    }
  }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define vd vector<double>
#define all(a) a.begin(),a.end()
using namespace std;

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

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()

count = 0
for i in range(N):
  if A[i] == B[i] and B[i] == C[i]:
    continue
  elif A[i] == B[i]:
    count += 1
  elif B[i] == C[i]:
    count += 1
  elif C[i] == A[i]:
    count += 1
  else:
    count += 2
    
print(count)

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


int main() {
    string s;
    cin >> s;
    int length = s.size();
    long long ans = 0;
    for (int t = 0; t < (1 << (length - 1)); ++t) {
        long long num = s[0] - '0';
        for (int i = 0; i < length - 1; ++i) {
            if (t & (1 << i)) {
                ans += num;
                num = 0;
            }
            num = num * 10 + s[i+1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using C = array<int, 9>;

int main() {
	for (int n {in()}; n; n--) {
		C t;
		array<C, 3> d {};
		for (int &i: t)
			i = in() - 1;
		for (int i: t) {
			char c = gcu();
			d[c == 'R' ? 0 : c == 'B' ? 1 : 2][i]++;
			gcu();
		}
		outl([&] {
			for (auto &i: d)
				for (int j: range(9)) {
					auto o {begin(i) + j};
					if (!*o)
						continue;
					if (j < 7 && *o && o[1] && o[2]) {
						int m {min({*o, o[1], o[2]})};
						*o -= m, o[1] -= m, o[2] -= m;
					}
					if (*o %= 3)
						return 0;
				}
			return 1;}());
	}
}


Measured memory_bytes: 2472
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  int n;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  int ans=0;
  FOR(n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      i+=2;
      ans++;
    }
  }
  PRN(ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main() {
	int n, m, lm = 0, rm = 1000000000;
	cin >> n >> m;
	for(int i = 0; i < m; ++i) {
		int l, r;
		cin >> l >> r;
		lm = max(lm, l);
		rm = min(rm, r);
	}
	int ans = 0;
	bool a = 0;
	for(int i = 0;i<=n; ++i) {
		if(lm <= i && i <= rm)
			++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,m,x,y,num[100010],par[100010];
vector <pii> v;
vector <LL> ans;

LL FIND(LL pos)
{
	if(par[pos]!=pos) par[pos]=FIND(par[pos]);
	return par[pos];
}

void UNION(LL pos1,LL pos2)
{
	num[FIND(pos2)]+=num[FIND(pos1)];
	par[FIND(pos1)]=FIND(pos2);
}

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		scanf("%lld%lld",&x,&y);
		v.pb({x,y});
	}
	reverse(v.begin(),v.end());
	rep(i,100005) par[i]=i,num[i]=1;
	ans.pb(n*(n-1)/2);
	LL cnt=ans[0];
	rep(i,m-1)
	{
		if(FIND(v[i].fi)!=FIND(v[i].se))
		{
			//cout<<i<<endl;
			//cout<<v[i].fi<<' '<<FIND(v[i].fi)<<endl<<v[i].se<<' '<<FIND(v[i].se)<<endl;
			//cout<<num[FIND(v[i].fi)]<<' '<<num[FIND(v[i].se)]<<'p'<<endl;
			cnt-=num[FIND(v[i].fi)]*num[FIND(v[i].se)];
			UNION(v[i].fi,v[i].se);
			//cout<<v[i].fi<<' '<<FIND(v[i].fi)<<endl<<v[i].se<<' '<<FIND(v[i].se)<<endl;
		}
		ans.pb(cnt);
	}
	reverse(ans.begin(),ans.end());
	rep(i,m) printf("%lld\n",ans[i]);
	rt0;
}

Measured memory_bytes: 4596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int W, K;
  vi w(10), k(10);
  rep(i, 10) scanf("%d", &w[i]);
  rep(i, 10) scanf("%d", &k[i]);

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

  W = w[0] + w[1] + w[2];
  K = k[0] + k[1]  +k[2];
  printf("%d %d\n", W, K);
  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main(void){
	int s,m,h;
	scanf("%d\n",&s);
	h=s/3600;
	m=(s-h*3600)/60;
	s=s-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 2696
def solve_sub(x, y, area):
    stack = []
    stack.append((x, y))

    move = [(x, y) for x in range(-1, 2) for y in range(-1, 2) if not (x == 0 and y == 0)]

    while len(stack) != 0:
        now = stack.pop()
        x = now[0]
        y = now[1]
        area[y][x] = 0

        for dire in move:
            if 0 <= x + dire[0] < w and 0 <= y + dire[1] < h and area[y + dire[1]][x + dire[0]] == 1:
                stack.append((x + dire[0], y + dire[1]))
                area[y + dire[1]][x + dire[0]] = 2


def solve(area):
    ans = 0
    for y in range(h):
        for x in range(w):
            if area[y][x] == 1:
                ans += 1
                solve_sub(x, y, area)

    print ans

if __name__ ==  "__main__":
    while True:
        w, h = map(int, raw_input().split())
        if w == 0 and h == 0:
            break

        area = []
        for y in range(h):
            area.append(map(int, raw_input().split()))

        solve(area)

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

typedef long long ll;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
int fact[N], ifact[N];
int rt[N];
int c[N], w[N];
int mn[N];
int n, x, y;

int Find(int x){ return rt[x] == -1 ? x : rt[x] = Find(rt[x]);}

void Union(int u, int v)
{
    u = Find(u);
    v = Find(v);
    if (u == v) return ;
    rt[u] = v;
}

map<int, int> cnt[N];

void init()
{
    fact[0] = 1;
    for (int i=1; i<N; ++i) fact[i] = (ll)fact[i-1] * i % MOD;
    ifact[0] = ifact[1] = 1;
    for (int i=2; i<N; ++i) ifact[i] = ((ll)MOD-MOD/i) * ifact[MOD%i] % MOD;
    for (int i=1; i<N; ++i) ifact[i] = (ll)ifact[i-1] * ifact[i] % MOD;

    memset(rt, -1, sizeof(rt));
}

int main()
{
    init();
    scanf("%d%d%d", &n, &x, &y);
    for (int i=1; i<=n; ++i) scanf("%d%d", c+i, w+i);
    for (int i=1; i<=n; ++i) if (!mn[c[i]] || w[mn[c[i]]] > w[i]) mn[c[i]] = i;
    for (int i=1; i<=n; ++i) if (w[i] + w[mn[c[i]]] <= x) Union(i, mn[c[i]]);
    int p = min_element(w+1, w+n+1)-w, q = 0;
    for (int i=1; i<=n; ++i) if (c[i] != c[p] && (!q || w[q] > w[i])) q = i;
    for (int i=1; i<=n; ++i)
        {
            if (c[i] != c[p] && w[i] + w[p] <= y) Union(i, p);
            if (c[i] != c[q] && w[i] + w[q] <= y) Union(i, q);
        }
    for (int i=1; i<=n; ++i) ++cnt[Find(i)][c[i]];
    int ans = 1;
    //???
    for (int i=1; i<=n; ++i)
        {
            int sum = 0, cur = 1;
            for (auto it: cnt[i])
                {
                    sum += it.second;
                    cur = (ll)cur * ifact[it.second] % MOD;
                }
            cur = (ll)cur * fact[sum] % MOD;
            ans = (ll)ans * cur % MOD;
        }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 23680
#!/usr/bin/env python3

def main():
    s = int(input())

    ft = [False] * 1001010
    ft[s] = True
    n = s
    i = 1
    while True:
        i += 1
        if n % 2 == 0:
            n //= 2
        else:
            n = 3 * n + 1
        if ft[n]:
            break
        ft[n] = True

    print(i)


if __name__ == '__main__':
    main()



Measured memory_bytes: 10868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int chairLength  = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		System.out.println((chairLength - z) / (y + z));
	}

}


Measured memory_bytes: 22612
# https://atcoder.jp/contests/abc144/tasks/abc144_b

N = int(input())

ans = "No"

if N == 1:
   ans = "Yes"

for i in range(2,10):
   #割り切れるなら
   if N % i == 0:
      waru = N / i
      # 割った値が9以下なら
      if 9 >= waru:
         ans = "Yes"

print(ans)

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

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007

using namespace std;

bool cmp(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second > right.second;
}

int main() {
    double ans=0;
    int n;
    cin >> n;
    vector<pair<double,double>> x(n);
    rep0(i,n){
        cin >> x[i].first >> x[i].second;
    }

    rep0(i,n)rep0(j,n)ans+=sqrt(pow(x[i].first-x[j].first,2) + pow(x[i].second-x[j].second,2));

    printf("%lf\n",ans/pow(n,1));
   //if(getchar()=='\n'&& getchar()=='\n') return 0;
}

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

bool cmp(char a,char b)
{
	return a>b;
} 

int main()
{
	string a,b;
	cin>>a>>b;
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),cmp);
	
	if(a<b)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
	   
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = []
ord = [-1 for i in range(n+1)]
v = 1
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]
c = len(s)-ord[v]
l = ord[v]
if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])

Measured memory_bytes: 32384
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let r: usize = scan(tokens);
    println!("{}", r * r);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double K = 0, G = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 0) {G++;}
    else {K++;}
  }
  cout << K / (K + G);
}

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

int main(){
  vector<vector<char>> vv(3,vector<char> (3));
  for(auto& v : vv){
    for(auto& x : v)
      cin >> x;
  }
  for(auto i=0;i<3;++i)
    cout << vv.at(i).at(i);
  cout << endl;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] arr = new char[h][w];
    long[][] dp = new long[h+1][w+1];
    int MOD = (int)1e9 + 7;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<h; i++) arr[i] = sc.next().toCharArray();

        dp[1][1] = 1;

        for (int i=1; i<=h; i++) {
            for (int j=1; j<=w; j++) {
                if (arr[i-1][j-1] == '#') continue;
                if (i == 1 && j == 1) continue;
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= MOD;
            }
        }

        System.out.println(dp[h][w]);

    }

}



Measured memory_bytes: 63532
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
string s;
int dp[100005][13];
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
int main(){
	cin>>s;
	dp[0][0]=1;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<13;j++){
			if(s[i]=='?'){
				for(int nxt=0;nxt<10;nxt++)add(dp[i+1][(j*10+nxt)%13],dp[i][j]);
			}else{
				add(dp[i+1][(j*10+s[i]-'0')%13],dp[i][j]);
			}
		}
	}
	cout<<dp[(int)s.size()][5]<<endl;
	return 0;
}

Measured memory_bytes: 5504
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	isPrime := Sieve(1299709)
	for {
		k := io.NextInt()
		if k == 0 {
			break
		}
		ans := 0
		if !isPrime[k] {
			p, n := k-1, k+1
			for !isPrime[p] || !isPrime[n] {
				if !isPrime[p] {
					p--
				}
				if !isPrime[n] {
					n++
				}
			}
			ans = n - p
		}
		io.Println(ans)
	}
}

func Sieve(x int) []bool {
	flags := make([]bool, x+1)
	for i := 2; i <= x; i++ {
		flags[i] = true
	}
	for i := 2; i <= int(math.Sqrt(float64(x))); i++ {
		if !flags[i] {
			continue
		}
		for j := i * i; j <= x; j += i {
			flags[j] = false
		}
	}
	return flags
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (ll i = 0; i < n; i++)
#define REPR(i,n) for (ll i = n-1; i >= 0; i--)
#define FOR(i,m,n) for (ll i = m; i < n; i++)
#define FORE(x,xs) for (auto& x : xs)
#define ALL(x) x.begin(), x.end()

const int MAX = 1e5+10;
const int MOD = 1e9+7;
const int HALF = MOD/2 + 1;

ll fac[MAX<<2];  // fac[n] = n!
ll finv[MAX<<2]; // (fac[n] * finv[n]) % MOD = 1
ll inv[MAX<<2];  // (n * inv[n]) % MOD = 1

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX<<2) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int B, W;

int main() {
    init();
    cin >> B >> W;
    ll b = 0, w = 0, h = HALF;
    REP (i, B+W) {
        cout << 1ll * (MOD + 1 - b + w) * HALF % MOD << "\n";
        (b += nCk(i, B-1) * h) %= MOD;
        (w += nCk(i, W-1) * h) %= MOD;
        (h *= HALF) %= MOD;
    }
}

Measured memory_bytes: 11520
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL A, B, N; cin >> A >> B >> N;
  LL x = 0;
  if (N < B) x = N;
  else       x = B - 1;

  cout << (A*x)/B << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if((ll)a*b <= 0) {
        cout << "Zero" << endl;
        return 0;
    }
    else {
       if(1 <= a) {
           cout << "Positive" << endl;
           return 0;
       } 
       else {
           int n = b-a+1;
           if(n%2 == 0) {
               cout << "Positive" << endl;
               return 0;
           }
           else {
               cout << "Negative" << endl;
               return 0;
           }
       }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#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>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;



void solve() {
	int A, B; cin >> A >> B;
	REP(i, 1e6) {
		if (i * 8 / 100 == A && i * 10 / 100 == B) {
			print(i); return;
		}
	}
	print(-1);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n,m;
    cin>>n>>m;
    if(n==1 && m==1){cout<<1<<endl;}
    else if(n==1){cout<<m-2<<endl;}
    else if(m==1){cout<<n-2<<endl;}
    else{cout<<(n-2)*(m-2)<<endl;}
    
    
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using P = std::pair<int, int>;
using ll = long long ;
template<class T> inline void chmax(T& a, T b) {if(a < b) a = b; }
template<class T> inline void chmin(T& a, T b) {if(a > b) a = b; }

int main(){
	ll N, D;
	std::cin >> N >> D;
	ll res = 0;
	D = D * D;
	rep(i, N){
		ll x, y;
		std::cin >> x >> y;
		if(x*x + y*y <= D){
			res++;
		}
	}
	std::cout << res << std::endl;
	return 0;
}

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

int main(){
	string snt;
	int c;

	string temp = "@+-*~";
	string w = "peach";

	getline(cin, snt);

	while ((c = snt.find("peach")) != -1){
		for (int i = c; i < c + 5; ++i){
			snt[i] = temp[i - c];
		}
	}

	while ((c = snt.find("apple")) != -1){
		for (int i = c; i < c + 5; ++i){
			snt[i] = w[i-c];
		}
	}
	w = "apple";

	while ((c = snt.find(temp)) != -1){
		for (int i = c; i < c + 5; ++i){
			snt[i] = w[i - c];
		}
	}


	cout << snt << endl;

	return 0;
}

Measured memory_bytes: 1184
/*
AizuOnline A0258
Title Kitchen Garden
@kankichi573
13/8/25 1/6 WA
*/
#include <stdio.h>
int n;
int h0,h1,h2,h3,h4,hd;  // at least nae 5 hon
#define tousa4(x,y,z,w) ((((x)-(y))==((y)-(z))) && (((x)-(y))==((z)-(w))))
#define tousa5(x,y,z,v,w) ((tousa4(x,y,z,v)) && (((x)-(y))==((v)-(w))))
//
main()
{
        int i;


        
        while(EOF!=scanf("%d",&n) && n)
        {
                i=5;
                scanf("%d %d %d %d %d",&h0,&h1,&h2,&h3,&h4);

                if(tousa5(h0,h1,h2,h3,h4))
                        goto CHECK6TH;                        

                if(tousa4(h1,h2,h3,h4))
                {
                        printf("%d\n",h0);
                        goto DISCARD;
                }
                if(tousa4(h0,h2,h3,h4))
                {
                        printf("%d\n",h1);
                        goto DISCARD;
                }
                if(tousa4(h0,h1,h3,h4))
                {
                        printf("%d\n",h2);
                        goto DISCARD;
                }
                if(tousa4(h0,h1,h2,h4))
                {
                        printf("%d\n",h3);
                        goto DISCARD;
                }
                if(tousa4(h0,h1,h2,h3))
                {
                        printf("%d\n",h4);
                        goto DISCARD;
                }
        CHECK6TH:
                for(i=5;i<n+1;i++)
                {
                        h0=h1;h1=h2;h2=h3;h3=h4;scanf("%d",&h4);
                        if(tousa5(h0,h1,h2,h3,h4))
                                continue;
                        else //saigo ni read sita dat ga zassou!
                        {
                                printf("%d\n",h4);
                                i++;
                                break;
                        }
                }
        DISCARD: // nokori wa yomisute
                for(;i<n+1;i++)
                {
                        scanf("%d",&hd);
#ifdef DEBUG
                        printf("%d discard\n",hd);
#endif
                }
                /*never reach*/
        }
        return(0);
}

Measured memory_bytes: 600
s = input()

a = ['R', 'U', 'D']
b = ['L', 'U', 'D']
flag = True

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in a:
            flag = False
    else:
        if s[i] not in b:
            flag = False

print('Yes') if flag else print('No')


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

# -*- coding: utf-8 -*-


from sys import stdin
import itertools
import time


############################################

import numpy as np
# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
K = int(temp[1])

data = []
write = stdin.readline().split()
for a in write:
    data.append(int(a))

steps = min(N, K)

# A.. 左から取る数
# B.. 右から取る数

An = range(K+1)

max = 0

for A in An:
    for B in range(steps-A+1):       
        small = K - A - B
#        print("A:",A,"B:",B,"small:",small)
        left = data[0:A]
        right = []
        if not B==0:
            right = data[-B:]
        left.extend(right)
        left = sorted(left)
#        print(left)
        # remove stuff
        for k in range(small):
#            print(k)
            try:
                if left[k] <= 0:
                    left[k] = 0
            except:
                continue
        
        add = sum(left)
#        print(add)
        if max < add:
            max = add
print(max)

Measured memory_bytes: 14292
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    if (n%2==0){
        printf("%f",0.50000);
    }else{
        float m = n;
        printf("%f",(m+1)/(2*m));
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
vi p, rk;
int numset;
void init(int n){
    numset = n;
    for (int i = 0; i < n; i++){
        p.push_back(i);
        rk.push_back(0);
    }
}
int findset(int x){
    return p[x] == x ? x : p[x] = findset(p[x]);
}
void unionset(int x, int y){
    x = findset(x), y = findset(y);
    if (x == y) return;
    numset--;
    if (rk[x] < rk[y]) p[x] = y;
    else{
        p[y] = x;
        if (rk[x] == rk[y]) rk[x]++;
    }
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    init(n-k+1);
    int a[n];
    int ct = 1;
    int last = -1;
    deque<ii> mn;
    deque<ii> mx;
    for (int i = 0; i < n; i++){
        if (mn.size() && mn[0].second < i-k) mn.pop_front();
        if (mx.size() && mx[0].second < i-k) mx.pop_front();
        scanf("%d",&a[i]);
        while (mn.size() && mn[mn.size()-1].first > a[i]) mn.pop_back();
        while (mx.size() && mx[mx.size()-1].first < a[i]) mx.pop_back();
        mn.push_back(ii(a[i],i));
        mx.push_back(ii(a[i],i));
        if (i && a[i] > a[i-1]) {
            ct++;
            if (ct >= k) {
                if (last != -1) unionset(i-k+1,last);
                last = i-k+1;
            }
        }
        else ct = 1;
        if (i >= k && mn[0].first == a[i-k] && mx[0].first == a[i]) {
            unionset(i-k,i-k+1);
        }
    }
    printf("%d",numset);
}


Measured memory_bytes: 2796
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int A, B, result;

  scanf("%d", &A);
  scanf("%d", &B);

  int Aestimate = 0;
  int Bestimate = 0;
  int price = 1;
  while (Aestimate < A + 1 && Bestimate < B + 1) {
    Aestimate = price * 0.08;
    Bestimate = price * 0.1;
    if (Aestimate == A && Bestimate == B) {
      result = price;
      printf("%d\n", result);

      return 0;
    }
    price++;
  }
  result = -1;
  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    mi = (0, -1)
    for i in range(N):
        mi = max(mi, (A[i-1] + A[i], i, A[i-1], A[i]))


    s = min(mi[2], mi[3])*2

    si = mi[1]
    while True:
        ans = [0] * N
        ans[si] = s
        a = A[:]
        a[si-1] -= s//2
        a[si] -= s//2
        for i in range(1, N):
            ans[(si+i)%N] = a[(si+i-1)%N] * 2
            a[(si+i) % N] -= a[(si+i-1) % N]
            a[(si+i-1) % N] = 0
        
        if a[(si+i) % N] == 0:
            break
        s += a[(si+i) % N]
        if s < 0:
            break

    return ' '.join(map(str, ans))


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 103008
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

struct PrimeNumbers {

    vector<bool> sieve;
    vector<long long> prime;

    PrimeNumbers (int n) : sieve(n+1,true) {
        sieve[0] = sieve[1] = false;
        for (long long i = 2; i < sieve.size(); i++) {
            if (sieve[i]) {
                prime.push_back(i);
                for (long long j = i * i; j < sieve.size(); j += i) {
                    sieve[j] = false;
                }
            }
        }
    }

    bool isPrime(long long n) {
        return sieve[n];
    }

    int size(void) {
        return (int) prime.size();
    }

    long long  operator [] (int n) {
        return  prime[n];
    }

};

template <class T> struct FenwickTree {

    vector < T > node;
    FenwickTree (int n) : node(n, 0) {}

    void add(int idx, T val) {
        for (int i = idx; i < node.size(); i |= i + 1) {
            node[i] += val;
        }
    }

    void update(int idx, T val) {
        add(idx, -sum(idx, idx + 1));
        add(idx, val);
    }

    T sum(int idx) {
        T ret = 0;
        for (int i = idx - 1; i >= 0; i = (i & (i + 1)) - 1) {
            ret += node[i];
        }
        return ret;
    }

    T sum(int l, int r) {
        return sum(r) - sum(l);
    }

};

int main() {

	PrimeNumbers p(100010);
	FenwickTree < int > inst(100010);

	for (int i = 1; i <= 100000; i++) {
		if (p.isPrime(i) && p.isPrime((i + 1) / 2)) {
			inst.add(i, 1);
		}
	}

	int Q; cin >> Q;
	REP(i,Q) {
		int l,r;
		cin >> l >> r;
		cout << inst.sum(l, r + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        char[]c=sc.next().toCharArray();
        int ans=1;
        boolean flag=false;
        String s=c[0]+"";
        for(int i=1;i<c.length;i++){
            if(s.length()==1){
                String po=c[i]+"";
                if(s.equals(po)){
                    if(i==c.length-1){
                        ans--;
                    }
                    else{
                    i++;
                    po+=c[i];
                        
                    }
                }
                s=po;
            }
            else{
                s=c[i]+"";
            }
            ans++;
        }
        System.out.println(ans);
    }
}


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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
  cout << 1 << endl;
  else if (a == b || b == c || c == a)
  cout << 2 << endl;
  else
  {
    cout << 3 << endl;
  }
  
  
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(){
	int r,c,sum,total_sum = 0;
	scanf("%d %d",&r,&c);
	int table[r+1][c+1];

	for(int i = 0; i < r+1; i++)
		for(int j = 0; j < c+1; j++) table[i][j] = 0;

	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			scanf("%d",&table[i][j]);
			sum += table[i][j];
			table[r][j] += table[i][j];
		}
		table[i][c] = sum;
		total_sum += sum;
	}
	table[r][c] = total_sum;

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",table[i][j]);
		}
		printf("%d\n",table[i][c]);
	}
}



Measured memory_bytes: 2036