akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

void solve(int n, int k, int m)
{
    vector<int> v(n);
    rep(i, n) v[i] = i + 1;
    int cur = m - 1;
    //cerr << v[cur] << endl;
    v.erase(v.begin() + cur);
    while (v.size() != 1)
    {
        cur = (cur + k - 1) % v.size();
        //cerr << v[cur] << endl;
        v.erase(v.begin() + cur);
    }
    cout << v[0] << endl;
}

int main()
{
    int n, k, m;
    while (cin >> n >> k >> m, n)
    {
        solve(n, k, m);
    }
    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
vector<int> g[maxn];
int maxl[maxn],secl[maxn],max_end[maxn],sec_end[maxn],head,tail,maxd=0;
int par[maxn];
bool cover[maxn];
void dfs(int u,int fa){
	maxl[u]=1;
	max_end[u]=u;
	secl[u]=0;
	sec_end[u]=-1;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		if(v==fa) continue;
		dfs(v,u);
		if(maxl[v]+1>=maxl[u]){
			secl[u]=maxl[u];
			sec_end[u]=max_end[u];
			maxl[u]=maxl[v]+1;
			max_end[u]=max_end[v];
		}else if(maxl[v]+1>secl[u]){
			secl[u]=maxl[v]+1;
			sec_end[u]=max_end[v];
		}
	}
	if(secl[u]>0 && maxl[u]+secl[u]-1>maxd){
		maxd=maxl[u]+secl[u]-1;
		head=max_end[u];
		tail=sec_end[u];
	}
	if(maxl[u]>maxd){
		maxd=maxl[u];
		head=max_end[u];
		tail=u;
	}
}
void dfs2(int u,int fa){
	par[u]=fa;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		if(v==fa) continue;
		dfs2(v,u);
	}
}
int ans1[maxn],ans2[maxn];
vector<int> body;
int main(){
	int n,u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,-1);
	dfs2(head,-1);
	for(int v=tail;v!=-1;v=par[v]){
		cover[v]=true;
		body.push_back(v);
	}
	bool no_sol=false;
	for(int i=1;i<=n;i++)
		if(par[i]!=-1 && !cover[par[i]])
			no_sol=true;
	if(no_sol) puts("-1"),exit(0);
	ans1[1]=1;
	int cnt=1;
	for(int i=1;i<(int)body.size()-1;i++){
		int u=body[i];
		int ch=0,cnt_tmp=cnt;
		for(int j=0;j<(int)g[u].size();j++){
			int v=g[u][j];
			if(!cover[v]) ch++,cnt++,ans1[cnt]=cnt+1;
		}
		cnt++;
		ans1[cnt]=cnt_tmp+1;
	}
	ans1[n]=n;

	reverse(body.begin(),body.end());
	ans2[1]=1;
	cnt=1;
	for(int i=1;i<(int)body.size()-1;i++){
		int u=body[i];
		int ch=0,cnt_tmp=cnt;
		for(int j=0;j<(int)g[u].size();j++){
			int v=g[u][j];
			if(!cover[v]) ch++,cnt++,ans2[cnt]=cnt+1;
		}
		cnt++;
		ans2[cnt]=cnt_tmp+1;
	}
	ans2[n]=n;
	int opt=1;
	for(int i=1;i<=n;i++)
		if(ans1[i]!=ans2[i]){
			opt=ans1[i]<ans2[i]?1:2;
			break;
		}
	if(opt==1){
		for(int i=1;i<=n;i++)
			printf("%d ",ans1[i]);
		puts("");
	}else{
		for(int i=1;i<=n;i++)
			printf("%d ",ans2[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 15864
#include <stdio.h>
#include <string.h>
int main(){
    char s[105];
    scanf("%s",s);
    int n;
    n=strlen(s);
    int i,j,ans=0;
    for(i=0;i<=n-1;i++){
        if(s[i]=='C'){
            for(j=i+1;j<=n-1;j++){
                if(s[j]=='F'){
                    ans=1;
                   
                    
                }
            }
           
        }
        
    }
        if(ans==1){
            printf("Yes");
        }else{
            printf("No");
        }
    
    return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          #define pb push_back
          #define ll long long
          #define ld long double

          int main()
          {
               tani_nachi_ke  

               int n,m;
               cin >> n >> m;
               if(n == m)
                    cout << "Yes\n";
               else
                    cout << "No\n";
               





         
               return 0;
          }

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private static int nowPrime = 1;
	private static ArrayList<Integer> array = new ArrayList<Integer>();

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		System.out.printf(n + ":");

		if(checkPrime(n)) {
			System.out.printf(" " + n);
		}
		else {
			while(n != 1) {
				setNextPrime();
				while(n % nowPrime == 0) {
					System.out.printf(" %d", nowPrime);

					n /= nowPrime;
				}
			}
		}
		System.out.println("");

		scan.close();
	}

	private static void setNextPrime() {
		while(true) {
			nowPrime++;
			if(checkNotMultiple(nowPrime)) {
				array.add(nowPrime);
				return;
			}
		}
	}

	private static boolean checkNotMultiple(int num) {
		for(int i = 0; i < array.size(); i++) {
			if(num % array.get(i) == 0) {
				return false;
			}
		}
		return true;
	}

	private static boolean checkPrime(int n) {
		for(int i = 2; i < Math.sqrt(n); i++) {
			if(n % i == 0) {
				return false;
			}
		}
		return true;
	}
}


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

using namespace std;

const int N = (1e5)+5, MOD = 1e9+7;
long long fac[N], invfac[N];

int ppow(int a, int b)
{
    if (b == 0) return 1;
    long long x = ppow(a, b/2);
    x = x * x % MOD;
    if (b % 2 == 1) {
        x = x * a % MOD;
    }
    return x;
}

int nCr(int n, int r)
{
    return 1ll * fac[n] * invfac[r] % MOD * invfac[n-r] % MOD;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    fac[0] = 1;
    for (int i = 1; i < N; ++i) {
        fac[i] = fac[i-1] * i % MOD;
    }
    for (int i = 0; i < N; ++i) {
        invfac[i] = ppow(fac[i], MOD-2);
    }
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    long long an = 0;
    for (int i = 0, j = n-1, x = n-1, y = k-1; x >= y; ++i, --j, --x) {
        an -= 1ll * a[i] * nCr(x, y);
        an %= MOD;
        an += 1ll * a[j] * nCr(x, y);
        an %= MOD;
    }
    an = (an + MOD) % MOD;
    cout << an << endl;
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pb push_back
#define endl '\n'
using namespace std;
const ll maxn = 2e6 + 5;
ll num[maxn],a,b,c,d,t,n,m,k,ans;
string str;
ll gcd(ll a,ll b){
    if(b == 0)
        return a;
    else
        return gcd(b,a % b);
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                ll t = gcd(i,j);
                ans += gcd(t,k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(X: int):
    # b が負
    for a in range(0, 101):
        for b in range(0, -101, -1):
            if a**5 - b**5 == X:
                print(a, b)
                exit()

    for a in range(0, 121):
        for b in range(0, 120):
            if a**5 - b**5 == X:
                print(a, b)
                exit()

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64840
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 a,b,c,k;
  cin >>a>>b>>c>>k;
  in6 ans = 0;
  if(k > a) ans += a;
  else ans += k;
  if(k > (a+b)) ans -= (k-a-b);
  cout << ans;
  hinata;
}

Measured memory_bytes: 3620
N, M, C = [int(s) for s in input().split(' ')]
Bs = [int(s) for s in input().split(' ')]
count = 0
for n in range(N):
    An =  [int(s) for s in input().split(' ')]
    ret = C
    for a, b in zip(An, Bs):
        ret += a * b
    if ret > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long;

int gcd(int x, int y){
    if(y != 0) return gcd(y, x % y);
    return x;
}

int main(void){
    int x, y;
    cin >> x >> y;
    cout << gcd(max(x, y), min(x, y)) << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(i=m;i<n;i++)
#define ms(l,n,s) memset(l,n,s)
#define m(l,n) (l*)malloc(n*sizeof(l))
typedef struct tree{
  int key;
  struct tree *left;
  struct tree *right;
}tree;
tree *getrootnode(tree*,int);
tree *insert(tree*,int);
void inorderprint(tree*);
void preorderprint(tree*);
int main(){
  int n,val;
  char command[7];
  tree *root=NULL;
  scanf("%d",&n);
  lpton(i,n){
    scanf("%s",command);
    if(!strcmp(command,"insert")){
      scanf("%d",&val);
      root=insert(root,val);
    }
    else{
      inorderprint(root);
      printf("\n");
      preorderprint(root);
    printf("\n");
    }
  }
  return 0;
}
tree *getnewnode(tree *root,int value){
  tree *origin=m(tree,1);
  origin->key=value;
  origin->left=origin->right=NULL;
  return origin;
}
tree *insert(tree *root,int v){
  if(root==NULL)root=getnewnode(root,v);
  else if(v<root->key)root->left=insert(root->left,v);
  else root->right=insert(root->right,v);
  return root;
}
void inorderprint(tree *rt){
  if(rt==NULL)return;
  inorderprint(rt->left);
  printf(" %d",rt->key);
  inorderprint(rt->right);
}
void preorderprint(tree *rt){
  if(rt==NULL)return;
  printf(" %d",rt->key);
  preorderprint(rt->left);
  preorderprint(rt->right);
}



Measured memory_bytes: 17328
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

struct Node{
	int v;
	
	Node(int v) : v(v) {}
	
	Node operator*(const Node r) const{
		return v < r.v ? *this : r;
	}
} e((1LL << 31) - 1);

struct SegmentTree{
	vector<Node> seg;
	int sz = 1;
	
	SegmentTree(int n){
		while(sz < n) sz *= 2;
		seg.assign(2 * sz, e);
	}
	
	void update(int k, Node x){
		k += sz - 1;
		seg[k] = x;
		while(k){
			k = (k - 1) / 2;
			seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
		}
	}
	
	Node get(int a, int b){
		return get(a, b, 0, 0, sz);
	}
	
	Node get(int a, int b, int k, int l, int r){
		if(b<=l||r<=a) return e;
		if(a<=l&&r<=b) return seg[k];
		
		return get(a, b, 2 * k + 1, l, (l + r) / 2) * get(a, b, 2 * k + 2, (l + r) / 2, r);
	}
};

int main(){
	int n,q; cin >> n >> q;
	SegmentTree seg(n);
	REP(i,0,q){
		int a,b,c; cin >> a >> b >> c;
		if(a == 0) seg.update(b, c);
		else if(a == 1) cout << seg.get(b, c + 1).v << endl;
	}
	
	return 0;
}



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

int main(){
	char ans[10];

	string s;	cin>>s;

	int now=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!='B'){
			ans[now]=s[i];
			now++;
		}else{
			if(now>0){
				ans[now-1]=' ';
				now--;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		if(Math.abs(a - c) <= d) {
			System.out.println("Yes");
		} else if(Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 23636
fn main() {
    let (n, k, v) = read();
    let ans = solve(v);
    write(ans);
}
 
fn read() -> (i32, i32, Vec<Vec<bool>>) {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let mut iter = l1.trim().split_whitespace();
    let n = iter.next().unwrap().parse::<i32>().unwrap();
    let k = iter.next().unwrap().parse::<i32>().unwrap();

    let mut v: Vec<Vec<bool>> = Vec::new();
    for i in 0..n {
        v.push(Vec::new());
        for j in 0..k {
            v[i as usize].push(false);
        }
    }

    for i in 0..k {
        let mut l1 = String::new();
        std::io::stdin().read_line(&mut l1).ok();
        let d = l1.trim().parse::<i32>().unwrap();

        let mut l2 = String::new();
        std::io::stdin().read_line(&mut l2).ok();
        let iter = l2.trim().split_whitespace();

        for j in iter {
            let j = j.trim().parse::<i32>().unwrap();
            v[j as usize - 1][i as usize] = true;
        }
    }

    (n, k, v)
}
 
fn write(x: i32) {
    println!("{}", x);
}
 
fn solve(v: Vec<Vec<bool>>) -> i32 {
    v.iter().filter(|&x| x.iter().all(|&x| !x)).count() as i32
}


Measured memory_bytes: 2140
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X=int(input())
i=0
while True:
  i+=1
  if is_prime(i) and i>=X:
    print(i)
    break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define eb push_back
#define mp make_pair
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dvg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const int INF=INT_MAX;
const ulli MOD=1e9+7;


	

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(30);
	
	
	int n;
	cin>>n;
	lli a[3];
	vector<lli> dp(3,0);
	vector<lli> ndp(3,0);
	forr(i,0,3)	cin>>a[i];
	
	dp[0]=a[0],dp[1]=a[1],dp[2]=a[2];
	
	forr(i,1,n)
	{
		forr(i,0,3)	cin>>a[i];
		ndp[0]=max(dp[1],dp[2])+a[0];
		ndp[1]=max(dp[0],dp[2])+a[1];
		ndp[2]=max(dp[1],dp[0])+a[2];
		dp=ndp;
	}
	
	lli maxi=INT_MIN;
	forr(i,0,3)
	{
		maxi=max(maxi,dp[i]);
	}
	cout<<maxi<<"\n";
	
	
		
		
		
	return 0;
	
}













Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a = n - 1;
	int b = m - 1;
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int k;

int x(int a) {
	rep(i, 0, k) {
		a *= 2;
	}
	return a;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cin >> k;
	int ans = 0;
	if (a >= b&&a >= c) {
		ans += b + c;
		ans += x(a);
	}
	else if (b >= a&&b >= c) {
		ans += a + c;
		ans += x(b);
	}
	else {
		ans += a + b;
		ans += x(c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

bool check(ll n){
    if(n <= 1) return false;
    rep(i,2,sqrt(n)+1){

        if(n % i == 0){
            ll temp = n;
            while(temp % i == 0){
                temp /= i;
            }

            if(temp == 1){
                return true;
            }
            else{
                return false;
            }
        }
    }

    return true;
}


signed main(){
    bool flag = false;
    ll n;
    cin >> n;

    vector<ll> vec;
    rep(i,1,sqrt(n)+1){
        if(n % i == 0){
            if(check(i)) vec.push_back(i);
            if(check(n/i) && i != n/i) vec.push_back(n/i);
        }
    }

    sort(vec.begin(),vec.end());
    bool is_used[(ll)vec.size()] = {false};


    ll cnt = 0;
    while(n > 1){
        ll z = 2;

        flag = true;
        rep(i,0,(ll)vec.size()){
            if(n >= vec[i] && n % vec[i] == 0 && !is_used[i]){
                z = vec[i];
                is_used[i] = true;
                cnt++;
                flag = false;
                break;
            }
        }

        if(flag) break;

        n /= z;
    }
    cout << cnt << endl;

    return 0;
}


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

const int inf = 1000*1000;
int n, k, c;

void fill(vector<int>& dp, string s) {
	int last = -inf;
	for(int i = 1; i <= n; i++) {
		if(s[i-1] == 'x') {
			dp[i] = dp[i-1];
		} else if(i - last > c) {
			dp[i] = 1 + dp[i-1];
			last = i;
		} else {
			dp[i] = dp[i-1];
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> k >> c;

	string s;
	cin >> s;
	vector<int> dp_pre(n+1), dp_suf(n+1);
	fill(dp_pre, s);
	reverse(s.begin(), s.end());
	fill(dp_suf, s);
	reverse(s.begin(), s.end());
	for(int i = 0; i < n; i++) {
		int L = i, R = n - i - 1;
		if(s[i] == 'o' && dp_pre[L] + dp_suf[R] < k) {
			cout << i + 1 << '\n';
		}
	}
}


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




typedef long long ll;
string S = "IOTJLSZ";
map<char, ll> A;
//-----------------------------------------------------------------
int main() {
	rep(i, 0, 7) {
		ll a; cin >> a;
		A[S[i]] = a;
	}

	ll ans = 0;

	ans = A['O'];

	ll a = 0, b = 0;

	if (0 < A['J'] && (0 < A['L'] && 0 < A['I'])) {
		a = 3 + ((A['J'] - 1) / 2 + (A['L'] - 1) / 2 + (A['I'] - 1) / 2) * 2;
	}

	b = (A['J'] / 2 + A['L'] / 2 + A['I'] / 2) * 2;

	ans += max(a, b);

	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()
mod=10**9+7
cnt=[[0]*13 for i in range(len(s))]
if s[0]=="?":
    for i in range(10):  
        cnt[0][i]+=1
else:
    cnt[0][int(s[0])]+=1
# print(cnt)
n=len(s)
for i in range(1,n):
    if s[i]=="?":
        now=-1
    else:
        now=int(s[i])
    if now==-1:
        for j in range(13):
            for k in range(10):
                cnt[i][(j*10+k)%13]+=cnt[i-1][j]
                cnt[i][(j*10+k)%13]%=mod
    else:
        for j in range(13):
            cnt[i][(j*10+now)%13]+=cnt[i-1][j]
            cnt[i][(j*10+now)%13]%=mod

# print(cnt)
print(cnt[n-1][5]%mod)

Measured memory_bytes: 61916
N = int(input())
A = list(map(int,input().split()))
A.reverse() #後ろから見る。

if A[0] != 2:
  print(-1)
  exit()
MIN = 2
MAX = 3
for i in range(1,N):
  nxt = A[i]
  if MAX < nxt:
    print(-1)
    exit() 
  #オッケーの最大値
  MAX = (MAX//nxt)*nxt #MAXは絶対前の数の倍数
  if MAX < MIN:
    print(-1)
    exit()
  #オッケーの最小値
  MIN = min(MAX,((MIN+nxt-1)//nxt)*nxt)

  #print(MIN,MAX)
 
  #最小値は変化なし。
  MAX = MAX+(nxt-1)
  #print(nxt,MIN,MAX)
print(MIN,MAX)


Measured memory_bytes: 85740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;
#define INF 1e9

int s[30][30];
int dp[30][30][4];
int c[4]; // straight, right, back, left, halt

struct state{
    int cost,y,x,dir;
};

bool operator>(const state &a, const state &b){
    return a.cost > b.cost;
}

//           →↓←↑
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int X,Y;

void dijkstra(){
    using P = state;
    priority_queue<P,vector<P>,greater<P>> qu;
    qu.push({dp[0][0][0] = 0, 0,0,0});
    while(qu.size()){
        P cur = qu.top(); qu.pop();
        int y = cur.y;
        int x = cur.x;
        int dir = cur.dir;
        if(y == Y-1 && x == X-1) return;
        if(dp[y][x][dir] < cur.cost) continue;
        rep(i,4){
            int nd = (dir+i)%4;
            int ny = y + dy[nd];
            int nx = x + dx[nd];
            int cost = (i==s[y][x] ? 0 : c[i]);
            if(ny<0 || nx<0 || nx>=X || ny>=Y) continue;
            if( dp[ny][nx][nd] > dp[y][x][dir] + cost){
                dp[ny][nx][nd] = dp[y][x][dir] + cost;
                qu.push({dp[ny][nx][nd],ny,nx,nd});
            }
        }
    }
}

int main(void){
    while(cin>>X>>Y, X|Y){
        rep(y,30)rep(x,30)rep(i,4){
            dp[y][x][i] = INF;
        }
        rep(y,Y) rep(x,X) cin>>s[y][x];
        rep(i,4) cin>>c[i];
        dijkstra();
        int res = INF;
        rep(i,4){
            res = min(res, dp[Y-1][X-1][i]);
        }
        cout<<res<<endl;
    }
    return 0;
}



Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
vector<ll>to[200005];
ll ans[200005] = {};
int main() {
	int n, q;
	cin >> n >> q;
	int a, b;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int p, x;
	for (int i = 0; i < q; i++) {
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	
	ll sum = 0;
	queue<ll>que;
	vector<ll>dist(n, inf);
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for (int id : to[v]) {
			if (dist[id] != inf)continue;
			dist[id] = dist[v] + 1;
			ans[id] += ans[v];
			que.push(id);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i]<<" ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 19440
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

void dfs(ll node, ll prev_node, const vector<vector<ll>>& tree, vector<vector<ll>>& results) {
	for (ll i = 0; i < tree[node].size(); ++i) dfs(tree[node][i], node, tree, results);
	if (prev_node < 0) return;
	if (results[node].size() % 2LL != 0LL) results[node].emplace_back(prev_node);
	else results[prev_node].emplace_back(node);
}

int solve() {
	ll n, m;
	cin >> n >> m;

	if (m % 2LL != 0LL) {
		cout << -1 << endl;
		return 0;
	}

	vector<vector<ll>> edges(n);
	ll a, b;
	for (ll i = 0; i < m; ++i) {
		cin >> a >> b;
		--a, --b;
		edges[a].emplace_back(b);
		edges[b].emplace_back(a);
	}

	vector<vector<ll>> results(n);
	vector<vector<ll>> tree(n);

	set<pair<ll, ll>> checked;
	vector<bool> visited(n, false);
	queue<ll> queue;
	queue.push(0);
	visited[0] = true;
	while (!queue.empty()) {
		ll node = queue.front();
		queue.pop();
		for (ll i = 0; i < edges[node].size(); ++i) {
			ll next_node = edges[node][i];

			if (checked.count(make_pair(node, next_node)) > 0 || checked.count(make_pair(next_node, node)) > 0) continue;
			checked.insert(make_pair(node, next_node));
			checked.insert(make_pair(next_node, node));

			if (visited[next_node]) results[node].emplace_back(next_node);
			else {
				tree[node].emplace_back(next_node);
				queue.push(next_node);
				visited[next_node] = true;
			}
		}
	}

	dfs(0, -1, tree, results);
	for (ll i = 0; i < n; ++i) {
		for (ll j = 0; j < results[i].size();++j) {
			cout << i + 1 << " " << results[i][j] + 1 << endl;
		}
	}

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 31104
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n+10,0);
    for(int i=1;i<n;i++){
        int b;
        cin>>b;
        a[b]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<"\n";
    }
    return(0);
}

Measured memory_bytes: 3992
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: usize,
        b: usize
    };

    let res = if a <= 9 && b <= 9 {
        (a * b) as isize
    } else {
        -1
    };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> resultList = new List<int>();

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "-1 -1 -1 -1 -1 -1")
                {
                    break;
                }
                int[] inputArray = input.Split(' ').Select(s => int.Parse(s)).ToArray();

                DateTime dt1 = new DateTime(inputArray[0], inputArray[1], inputArray[2]);
                DateTime dt2 = new DateTime(inputArray[3], inputArray[4], inputArray[5]);

                resultList.Add((dt2 - dt1).Days);

            }

            foreach (int n in resultList)
            {
                Console.WriteLine(n);
            }

        }
    }
}

Measured memory_bytes: 5916
long n, k;

long fun(long n, long x){
	if (n == 0)return (x <= 0 ? 0 : 1);
	long p = (1LL << n) - 1;
	if (x <= 2*p)return fun(n - 1, x - 1);
	return p + 1 + fun(n - 1, x - 1 - 2*p);
}

int main(){
	scanf("%ld%ld",&n,&k);
	printf("%ld\n",fun(n, k));
}


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


int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int cnt = 0;
	while (B <= A) {
		B *= 2;
		++cnt;
	}
	while (C <= B) {
		C *= 2;
		++cnt;
	}

	if (cnt <= K)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3120
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 1e6 + 10;
int a[N], n;
char s[N];
int main() {
	scanf("%d%s", &n, s); n --;
	for(int i = 0; i <= n; i ++) {
		a[i] = s[i] - '0' - 1;
	}
	int ans = 0;
	for(int i = 0; i <= n; i ++) {
		if((n & i) == i) ans ^= a[i] & 1;
	}
	if(ans == 1) puts("1");
	else {
		for(int i = 0; i <= n; i ++) {
			if(a[i] == 1) { puts("0"); return 0; }
			a[i] >>= 1;
		}
		ans = 0;
		for(int i = 0; i <= n; i ++) {
			if((n & i) == i) ans ^= a[i] & 1;
		}
		printf("%d\n", ans ? 2 : 0);
	}
	return 0;
}

Measured memory_bytes: 4992
import sys
i = 0
H = []
W = []
while(1):
    tmp = [int(x) for x in input().split()]
    H.append(tmp[0])
    W.append(tmp[1])
    if(H[i]==0 and W[i]==0):
        break
    i+=1
for u in range(i):
        for s in range(H[u]):
            if(s==0 or s==H[u]-1):
                for t in range(W[u]):
                    sys.stdout.write('#')
                print("")
            else:
                for t in range(W[u]):
                    if(t==0 or t==W[u]-1):
                        sys.stdout.write("#")
                    else:
                        sys.stdout.write(".")
                print("")
        print("")


Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n == 1) cout << '0';
    else
    {
        int a[n];
        long long s = 0;
        cin >> a[0];
        for (int i = 1; i < n; i++) 
        {
            cin >> a[i];
            if (a[i - 1] > a[i])
            {
                s += a[i - 1] - a[i];
                a[i] = a[i - 1];
            }
        }
        cout << s;
    }
}

Measured memory_bytes: 4408
#include <iostream>

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    if (n==m)
        for (int i=0;i<n;i++)   cout << n;
    else if (n>m)
        for (int i=0;i<n;i++)   cout << m;
    else    for (int i=0;i<m;i++)   cout << n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	string s;
	while (cin >> s)
	{
		if (s == "0") break;
		queue<string> que;
		que.push(s);
		map<string,int> t;
		t[s] = 0;
		while (!que.empty())
		{
			string tmp = que.front();
			que.pop();
			bool f = true;
			REP(i, tmp.size())
			{
				if (tmp[i] != tmp[0]) f = false;
			}
			if (f)
			{
				cout << t[tmp] << endl;
				goto end;
			}
			REP(i, tmp.size() - 1)
			{
				if (tmp[i] != tmp[i + 1])
				{
					char a = 'r' + 'g' + 'b' - tmp[i] - tmp[i + 1];
					string tmps = tmp;
					tmps[i] = tmps[i + 1] = a;
					if (t.find(tmps) == t.end())
					{
						t[tmps] = t[tmp] + 1;
						que.push(tmps);
					}
				}
			}
		}
		cout << "NA" << endl;
	end:;
	}
	return 0;
}

Measured memory_bytes: 2880
package main

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

const maxBuf = 200100

var debug = false

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	if debug {
		testFile, _ := os.Open("./test/sample-1.in")
		sc = bufio.NewScanner(testFile)
	}
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

/* #### main #### */
func main() {
	N := readInt()
	M := readInt()
	C := readInt()

	A := make([][]int, N)
	B := make([]int, M)

	var ans int

	for i := 0; i < M; i++ {
		B[i] = readInt()
	}
	for i := 0; i < N; i++ {
		sum := 0
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			A[i][j] = readInt()
			sum += A[i][j] * B[j]
		}
		if sum+C > 0 {
			ans++
		}

	}

	fmt.Println(ans)
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (U == S) A--;
	if (U == T) B--;
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX], color[MAX];

  for(int i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
        u=i;
        minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
        if(d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i]==INFTY?-1:d[i]) << endl;
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j] = INFTY;
    }
  }

  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      M[u][v] = c;
    }
  }
  dijkstra();
  return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a, b, c;
    scanf("%ld%ld%ld", &a, &b, &c);

    if(c>=a && c<=b) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	ll n, k;
	cin >> n >> k;
	vector<ll> H(n);
	for (int i = 0; i < n; ++i)
		cin >> H[i];
	sort(rall(H));
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (k)
			--k;
		else
			ans += H[i];
	}
	cout << ans << endl;
}



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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  string z;
  cin >> z;
  int res = 0;
  R(i,SZ(z)){
    res += z[i] - '0';
  }
  cout << max(res, (SZ(z) - 1) * 9 + z[0] - '1') << "\n";
}


Measured memory_bytes: 764
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
int arr[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    LL n;
    while(cin>>n) {
        LL ans=0;
        if(n<7) {
            ans=1;
        } else if(n<=11) {
            ans=2;
        } else {
            ans=n/11*2;
            if(n%11==0)ans+=0;
            else if(n%11<=6)ans+=1;
            else ans+=2;
        }
        cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcd(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

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

    int m = 0;
    int sum = 0;
    rep(i, 0, n)
    {
        cin >> p[i];
        m = max(m, p[i]);
        sum += p[i];
    }
    cout << sum - m / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	long long x; cin >> x;
	if (x < 7) {
		cout << 1 << endl;
		return 0;
	}
	else if (x < 11) {
		cout << 2 << endl;
		return 0;
	}
	long long ans = 0;
	ans = x / 11 * 2;
	ans += !(x % 11 == 0);
	ans += (x % 11 > 6);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;

string S;
int len;
bool ans = true;

int main() {
	cin >> S;
	len = (int)(S.length());
	if (len % 2 == 0) {
		for (int i = 0; i < len / 2; i++) {
			if (S[2 * i] == 'L') {
				ans = false;
			}
			if (S[2 * i + 1] == 'R') {
				ans = false;
			}
		}
	}
	else {
		for (int i = 0; i < len / 2; i++) {
			if (S[2 * i] == 'L') {
				ans = false;
			}
			if (S[2 * i + 1] == 'R') {
				ans = false;
			}
		}
		if (S[len - 1] == 'L') {
			ans = false;
		}
	}
	
	if (ans)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <utility>
#include <vector>
#include <stdio.h>
#include <numeric>
#include <array>

using namespace std;

#define REP(i,from,to) for( long long int i = (from); i < (to); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template <typename ELEMENT_TYPE>
struct _setfillw {
    ELEMENT_TYPE c;
    std::streamsize w;
    _setfillw(ELEMENT_TYPE c, std::streamsize w) : w(w), c(c) {}
};

template <typename ELEMENT_TYPE>
inline _setfillw<ELEMENT_TYPE> setfillw(ELEMENT_TYPE c, std::streamsize w) {
    return _setfillw<ELEMENT_TYPE>(c, w);
}

template <typename ELEMENT_TYPE>
inline std::ostream& operator << (std::ostream& os, const _setfillw<ELEMENT_TYPE>& manip)
{
    return os << std::setw(manip.w) << std::setfill(manip.c);
}

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll MOD=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
  LIN(n)
  for( ll i = 0; i * i <= n; i++ ){
    if( i * i <= n && ( i + 1 ) * ( i + 1 ) > n ){
      puta( i * i );
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int or = n;
		int total = 0;
		while (n > 0) {
			total += n % 10;
			n /= 10;
		}
		if (or % total == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


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

int main() {

	int n, a, b;
	cin >> n >> a >> b;

	int planA = n * a;
	int planB = b;
	if (planA < planB) {
		cout << planA << endl;
	}
	else {
		cout << planB << endl;
	}
}


Measured memory_bytes: 256
red=[]
blue=[]
n=int(input())
for i in range(n):
    red.append(str(input()))

m=int(input())
for i in range(m):
    blue.append(str(input()))

red_set=set(red)
ans = 0

for s in red_set:
    ans = max(ans,red.count(s)-blue.count(s))


print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


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; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll N;
    vector<ll> A, B;
    cin >> N;
    rep(i, 0, N + 1){
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }
    rep(i, 0, N){
        ll temp;
        cin >> temp;
        B.push_back(temp);
    }
    ll cnt = 0;
    rep(i, 0, N){
        if (A[i] >= B[i]){
            cnt += B[i];
        }
        else{
            cnt += A[i];
            B[i] -= A[i];
            if (A[i + 1] >= B[i]){
                cnt += B[i];
                A[i + 1] -= B[i];
            }
            else{
                cnt += A[i + 1];
                A[i + 1] = 0;
            }
        }
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2548
<?php

list($s) = explode(' ', trim(fgets(STDIN)));

if ($s !== strrev($s)) {
    echo 'No';
    exit;
}

$n = strlen($s);

$s_sub1 = substr($s, 0, (($n - 1) / 2));
if ($s_sub1 !== strrev($s_sub1)) {
    echo 'No';
    exit;
}

$s_sub2 = substr($s, (($n + 3) / 2) - 1);
if ($s_sub2 !== strrev($s_sub2)) {
    echo 'No';
    exit;
}

echo 'Yes';


Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[][] s = new int[m][10];
        for (int i = 0; i < m; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                s[i][j] = sc.nextInt();
            }
        }
        boolean[] is0 = new boolean[m];
        for (int i = 0; i < m; i++) {
            is0[i] = sc.nextInt() == 0;
        }

        int ans = 0;
        for (int switches = 0; switches < (1 << n); switches++) {//suicchizentansaku
            boolean flag = true;
            boolean[] isOn = new boolean[n];
            for (int i = 0; i < n; i++) {
                isOn[i] = ((switches >> i) & 1) == 1;
            }

            for (int i = 0; i < m; i++) {//denkyugoto

                int on = 0;
                for (int k : s[i]) {
                    if (k == 0) break;
                    if (isOn[k - 1]) on++;
                }
                if (is0[i] != (on % 2 == 0)) {
                    flag = false;
                }

            }

            if (flag) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long

using namespace std;

bool arr[300000];

int main() {
	int t;
	string s;
	ll n, x=0, ans = 0;
	cin >> t >> s;
	for(int i = 0; i < t; i++) {
		if(s.at(i) == 'R') {
			arr[i] = true;
			x++;
		}
		else arr[i] = false;
	}
	for(int i = 0; i < x; i++) {
		if(s.at(i) == 'W') ans++;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3948
package main 

import (
        "fmt"
        "sort"
)

func main () {
        var n, p, an int
        f := []int{}
        fmt.Scan(&n)
        for i := 0 ; i < n ; i++ {
                fmt.Scan(&p)
                f = append (f, p)
        }
        sort.Sort(sort.IntSlice(f))
        for i:= 0 ; i < n ; i++{
                if i == n - 1 {
                        k :=f[i] / 2
                        an += k
                }  else {
                        k :=f[i]
                        an += k
                }
        }
        fmt.Println(an)
}


Measured memory_bytes: 512