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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 1000005;

int fac[Maxn], inv[Maxn];
int n;
int res;

int Inv(int a)
{
	int p = mod - 2;
	int res = 1;
	while (p) {
		if (p & 1) res = ll(res) * a % mod;
		p >>= 1; a = ll(a) * a % mod;
	}
	return res;
}

int C(int n, int k)
{
	if (n < 0 || k < 0 || k > n) return 0;
	return ll(fac[n]) * inv[k] % mod * inv[n - k] % mod;
}

int main()
{
	fac[0] = inv[0] = 1;
	for (int i = 1; i < Maxn; i++) {
		fac[i] = ll(i) * fac[i - 1] % mod;
		inv[i] = Inv(fac[i]);
	}
	scanf("%d", &n);
	res = ll(n - 1) * fac[n - 1] % mod;
	for (int i = 1; i <= (n - 2) / 2; i++)
		res = (res - ll(fac[n - 1 - i]) * C(n - 2 - i, i) % mod * fac[i] % mod + mod) % mod;
	printf("%d\n", res);
	return 0;
}

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

using namespace std;

#define rep(i,m,n) for(long i=m;i<n;i++)


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

  
  long res=0;
 vector<long> b(n);
  rep(i,0,n-1) cin >> b[i];
  
  res+=b[0];
  rep(i,1,n-1) res+=min(b[i-1],b[i]);
  
  res+=b[n-2];

   cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), m = sc.nextInt();
		
		int nm = n + m;
		
		System.out.println(nm * (nm - 1) / 2 - n * m);
		
	}

}

Measured memory_bytes: 23892
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val b = (1..n).map { sc.nextInt() }


  var array = b.toIntArray()

  var ok = true
  val list = mutableListOf<Int>()
  while (array.size != 0) {
    var tmp = 0
    for ((i, bi) in array.withIndex()) {
      if (i+1 == bi) {
        tmp = bi
      }
    }
    if (tmp > 0) {
      list.add(tmp)
      val list2 = mutableListOf<Int>()
      for (i in 0 until array.size) {
        if (i+1 == tmp) continue
        val ai = array[i]
        list2.add(ai)
      }
      array = list2.toIntArray()
      
    } else {
      ok = false
    }
    if (!ok) {
      break
    }
  }

  if (ok) {
    val tmp = list.reversed().joinToString("\n")
    println(tmp)
  } else {
    println(-1)
  }

}


Measured memory_bytes: 38788
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    while(op!='?'){
        if(op=='+'){
            printf("%d\n",a+b);
            scanf("%d %c %d",&a,&op,&b);
        }else if(op=='-'){
            printf("%d\n",a-b);
            scanf("%d %c %d",&a,&op,&b);
        }else if(op=='*'){
            printf("%d\n",a*b);
            scanf("%d %c %d",&a,&op,&b);
        }else{
            printf("%d\n",a/b);
            scanf("%d %c %d",&a,&op,&b);
        }
    }
    return 0;
}



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

const int maxn = 103;

int main(){
	int n, m ,t[maxn], x, p;
	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> t[i];
	} 
	
	int sum = 0;
	for(int i = 1; i<=n ;i++){
		sum += t[i];
	}
	
	
	cin >> m;
	for(int i = 1; i<=m ;i++){
		cin >> p >> x;
		int tmp = sum;
		tmp -= t[p];
		tmp += x;
		cout << tmp << endl;
	}
	return 0;
}  

Measured memory_bytes: 3596
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
    int i, c;
    printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);
    
    if(T[u].p==NIL) printf("root, ");
    else if(T[u].l==NIL) printf("leaf, ");
    else printf("internal node, ");
    
    printf("[");
    for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
        if(i) printf(", ");
        printf("%d", c);
    }
    printf("]\n");
    
}

void calcDepth(int u, int p){
    D[u] = p;
    if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
    if(T[u].r!=NIL) calcDepth(T[u].r,p);
}

int main(){
    int i, j, k;
    int n;
    int id, sib, child;
    int root = NIL;
    scanf("%d", &n);
    for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for(i=0; i<n; i++){
        scanf("%d %d", &id, &k);
        for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
            scanf("%d", &child);
            T[child].p = id;
            if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
            else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
            sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
        }
    }
    
    //根を求める (find the root)
    for(i=0; i<n; i++){
        if(T[i].p == -1) root = i;
    }
    
    //それぞれのノードの深さを求める (find depth of each node)
    calcDepth(root, 0);
    
    //出力 (output)
    for(i=0; i<n; i++) print(i);
    
    return 0;
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int n,s;
  cin>>n>>s;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }

  vector<lint> dp(s+1,0);
  dp[0]=1;
  rep(k,n){
    rep_rev(t,s+1,0){
      if(t-a[k]<0) dp[t]=dp[t]*2;
      else dp[t]=dp[t]*2+dp[t-a[k]];
      dp[t]%=mod;
    }
  }

  return dp[s];
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, m;
	string s;
	cin >> n >> m;
	rep(i, m + 2) {
		cout << '#';
	}
	cout << endl;
	rep(i, n) {
		cin >> s;
		cout << '#' << s << '#'<< endl;
	}
	rep(i, m + 2) {
		cout << '#';
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template<typename T>
struct RMQ {
    int L;
    vector<T> data;
    const T MAX;
    RMQ(int N, T MAX) : MAX(MAX) {
        L = 1;
        while (L < N) L <<= 1;
        data.assign(L * 2, MAX);
    }
    void update(int i, T x) {
        i += L;
        data[i] = x;
        i >>= 1;
        while (i > 0) {
            data[i] = min(data[i * 2], data[i * 2 + 1]);
            i >>= 1;
        }
    }
    int query(int l, int r, int k, int sl, int sr) {
        if (sr <= l || r <= sl) return MAX;
        if (l <= sl && sr <= r) return data[k];
        T dl = query(l, r, k * 2, sl, (sl + sr) / 2);
        T dr = query(l, r, k * 2 + 1, (sl + sr) / 2, sr);
        return min(dl, dr);
    }
    // min of [l, r)
    int query(int l, int r) { return query(l, r, 1, 0, L); }
    T operator[](const int &k) const {
        return data[k + L];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    RMQ<int> rmq(n, (1<<30) - 1 + (1<<30));
    vector<int> ans;
    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (!com) {
            rmq.update(x, y);
        } else {
            ans.push_back(rmq.query(x, y + 1));
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 4284
a11,a12,a13,a21,a22,a23,a31,a32,a33,n,*b=map(int, open(0).read().split())
b=set(b)
if {a11,a12,a13}<=b or {a21,a22,a23}<=b or {a31,a32,a33}<=b or {a11,a21,a31}<=b or {a12,a22,a32}<=b or {a13,a23,a33}<=b or {a11,a22,a33}<=b or{a13,a22,a31}<=b:
  print('Yes')
else:
  print('No')

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int c=A+K-1;
  int d=B-K+1;
  for(int i=A;i<=B;i++){
    if(i<=c || d<=i){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#![allow(unused_mut, non_snake_case, unused_imports, dead_code)]

use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::swap;
use std::collections::{HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

fn main() {
    input!(T:f32,X:f32);
    println!("{:.10}",T/X);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int x, y; cin >> x >> y;
    int div1 = y / 2;
    int div2 = y / 4;
    rep(i, x + 1)
    {
        int tmp = 2 * i + 4 * (x - i);
        if (tmp == y)
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	int l,r,d;
    cin >> l >> r >> d;
    int ct = 0;
    for(int i=l; i<=r; i++){
        if(i%d == 0){
            ct++;
        }
    }
    cout << ct << endl;
}

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

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;

    if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
        if (a >= b && a >= c) {
            cout << b * c << endl;
        } else if (b >= c && b >= a) {
            cout << c * a << endl; 
        } else if (c >= a && c >= b) {
            cout << a * b << endl; 
        }
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	int mcd(int a,int b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		

int main(){
	lli N,K,i,j;
	lli a,b;
	double  p,q;
	cin>>p>>q;
	a=p/(0.08);
	b=q/(0.1);
	a=max(a,b);
	if(a!=p/(0.08)&&a!=q/(0.1))a+=1;
	if(lli(a*(0.08))==p&&lli(a*(0.1))==q){
		cout<<a;
	}
	else cout<<"-1";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (x == 0 && y == 0)break;
            if(x > y){
                System.out.println(y + " " + x);
            }else if (x <= y) {
                System.out.println(x + " " + y);
            }
            
        }
    }
}


Measured memory_bytes: 36416
#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(i64)(n); ++i)           // 0 to n-1
#define REPD(i, n)    for (i64 i=(i64)(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}




void Main() {
    i32 n;
    cin >> n;
    VI ans(n, 0);
    for (i32 i = 1; i * i <= n; ++i) {
        for (i32 j = 1; j * j <= n; ++j) {
            for (i32 k = 1; k * k <= n; ++k) {
                i32 val = i * i + j * j + k * k + i * j + j * k + k * i;
                if (1 <= val && val <= n) ++ans.at(val - 1);
            }
        }
    }
    printvec(ans, "\n", "\n");
}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 3608
def solve():
    n, *a_l = map(int, open(0).read().split())
    l, r = 0, sum(a_l)
    d = r - l
    for i in range(n):
        l += a_l[i]
        r -= a_l[i]
        if d > abs(l - r):
            d = abs(l - r)
    
    print(d)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 25124
import java.util.*;

public class Main{
        
        static int n;
        static int m;
        static int q;

        static int[] a;
        static int[] b;
        static int[] c;
        static int[] d;
    
        static long max;

        static void dfs(int i, List<Integer> list)  {
            
            if(!list.isEmpty() && list.get(list.size() - 1) > m){
                return;
            }

            if(i == n){
                long temp = 0;
                //System.out.println(list.toString());
                for(int j=0; j<q; j++){
                    if(list.get(b[j] - 1) - list.get(a[j] - 1) == c[j]){
                        temp += d[j];
                    }
                }
                if(temp > max){
                    max = temp;
                }
                return;
            }

            int j = 1;
            if(!list.isEmpty()) {
                j = list.get(list.size() - 1);
            }
            for(; j <= m ; j++) {
                List<Integer> newList = new ArrayList<>();
                newList.addAll(list);
                newList.add(j);
                dfs(i + 1, newList);
            }
        }
    public static void main(String[] args) throws Exception{

        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();

        a = new int[q];
        b = new int[q];
        c = new int[q];
        d = new int[q];

        for(int i=0; i<q; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        dfs(0, new ArrayList<Integer>());
        System.out.println(max);
    }
}

Measured memory_bytes: 55948
s = input()
odd = s[::2]
even = s[1::2]
ans = 'Yes'
R = ['R','U','D']
L = ['L','U','D']
for i in odd:
    if i not in R:
        ans = 'No'
for i in even:
    if i not in L:
        ans = 'No'
print(ans)


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        long bigInteger = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            boolean[] brokenStairs = new boolean[n + 1];
            Arrays.fill(brokenStairs, true);
            for (int i = 0; i < m; i++) {
                int broken = in.nextInt();
                brokenStairs[broken] = false;
            }

            long[] dp = new long[n + 1];
            dp[0] = 1;
            for (int now = 0; now < n; now++) {
                for (int next = now + 1; next <= Math.min(n, now + 2); next++) {
                    if (brokenStairs[next]) {
                        dp[next] += dp[now];
                        dp[next] = dp[next] % bigInteger;
                    }
                }
            }
            out.println(dp[n]);
        }

    }
}



Measured memory_bytes: 50432
def main():
    from collections import deque

    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    already_black = sum(row.count('#') for row in s)

    dq = deque()
    dq.append((0, 0))

    dist = [[-1] * W for _ in range(H)]
    dist[0][0] = 1

    while dq:
        r, c = dq.popleft()
        if r == H - 1 and c == W - 1:
            break
        if r > 0 and s[r - 1][c] == '.' and not (~dist[r - 1][c] and dist[r - 1][c] <= dist[r][c] + 1):
            dist[r - 1][c] = dist[r][c] + 1
            dq.append((r - 1, c))
        if c > 0 and s[r][c - 1] == '.' and not (~dist[r][c - 1] and dist[r][c - 1] <= dist[r][c] + 1):
            dist[r][c - 1] = dist[r][c] + 1
            dq.append((r, c - 1))
        if r < H - 1 and s[r + 1][c] == '.' and not (~dist[r + 1][c] and dist[r + 1][c] <= dist[r][c] + 1):
            dist[r + 1][c] = dist[r][c] + 1
            dq.append((r + 1, c))
        if c < W - 1 and s[r][c + 1] == '.' and not (~dist[r][c + 1] and dist[r][c + 1] <= dist[r][c] + 1):
            dist[r][c + 1] = dist[r][c] + 1
            dq.append((r, c + 1))

    if ~dist[H - 1][W - 1]:
        ans = H * W - (dist[H - 1][W - 1] + already_black)
    else:
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

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

	vector<multiset<int>> IMOS(M + 3);
	vector<int> A(N);
	int asum = 0;
	rep(i, 0, N)
	{
		cin >> A[i];
		A[i]--;
		if (i > 0)
		{
			if (A[i] < A[i - 1])
			{
				asum += M - 1 - A[i - 1] + A[i] + 1;
			}
			else
			{
				asum += A[i] - A[i - 1];
			}

			if ((A[i - 1] + 1) % M == A[i])continue;

			int ta = (A[i - 1] + 2) % M;

			IMOS[ta].insert(1);

			if (A[i] < ta)
			{
				IMOS[0].insert(M - 1 - ta + 2);
				IMOS[A[i] + 1].insert(-(M - 1 - ta + 1 + A[i] + 2));
				//cout << "a" << endl;
			}
			else
			{
				IMOS[A[i] + 1].insert(-(A[i] - ta + 2));
				//cout << "b" << endl;
			}
		}
	}

	int ans = 0;
	int sum = 0;
	int cnt = 0;
	rep(i, 0, M)
	{
		for (auto v : IMOS[i])
		{
			sum += v;
			if (v > 0)cnt++;
			else cnt--;
		}
		chmax(ans, sum);
		sum += cnt;
	}

	ans = asum - ans;

	cout << ans << endl;

	return 0;
}

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

#define forn(i,x,y) for(int i = x; i<y; i++)
int h[100001], N, K;
long long memo[100001];


long long solve(int atual, long long custo){
	if(atual >= N-1) return custo;
	if(memo[atual] != -1) return memo[atual] + custo;

	long long pula = LLONG_MAX;

	forn(i,atual+1,atual+K+1){
		if(i >= N) break;
		pula = min(pula, solve(i, custo + abs(h[i] - h[atual])));
	}


	memo[atual] = pula - custo;
	return pula;

}

int main(){
	ios::sync_with_stdio(false);
	cin >> N >> K;
	forn(i,0,N) cin >> h[i];
	memset(memo, -1, sizeof(memo));

	cout << solve(0, 0) << '\n';
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int H, W, N;
  cin >> H >> W >> N;
  int mx = max(H, W);
  cout << (N+mx-1) / mx << endl;
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    string s,t;
    cin >> s >> t;
    ll sn = s.size();
    ll tn = t.size();

    if (sn < tn){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    vector<string> x;

    for (ll i = 0; i <= sn-tn; i++){
        bool p = true;
        string c = s;
        for (ll j = 0; j < tn; j++){
            if (s[i+j] != t[j] && s[i+j] != '?'){
                p = false;
                break;
            }
            else{
                c[i+j] = t[j];
            }
        }

        if (p){
            x.push_back(c);
        }
    }

    /*for (auto a : x){
        cout << a << endl;
    }*/

    if (x.size() == 0){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (auto &a : x){
        rep(i,sn){
            if (a[i] == '?'){
                a[i] = 'a';
            }
        }
    }

    sort(x.begin(), x.end());

    cout << x[0] << endl;

}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    vector< int > a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector< vector< ll > > dp(3000, vector< ll > (3000));
    for (int l = n - 1; l >= 0; l--) {
        for (int r = l; r < n; r++) {
            if (l == r) dp[l][r] = (ll) a[l];
            else dp[l][r] = max((ll) a[l] - dp[l + 1][r], (ll) a[r] - dp[l][r - 1]);
        }
    }
    cout << dp[0][n - 1] << "\n";
}

Measured memory_bytes: 73688
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  int a,b,c,d=0,e=0,g=0,h;
  cin>>a>>b;
  vector<int> f(a);
  for(int i=0;i<a;i++){
    cin>>c;
    d=max(c,d);
    cin>>c;
    f.at(i)=c;
  }
  sort(f.begin(),f.end());
  reverse(f.begin(),f.end());
  for(int i=a-1;i>=0;i--){
    if(f.at(i)<d)
      f.pop_back();
    else
      break;
  }
  a=f.size();
  for(int i=0;i<a;i++)
    e+=f.at(i);
  if(e>=b){
    d=0;
    for(int i=0;i<a;i++){
      d+=f.at(i);
      if(d>=b){
        cout<<i+1<<endl;
        break;
      }
    }
  }
  else{
    for(int i=0;i<a;i++)
      g+=f.at(i);
    h=a + $(b-g,d);
    cout<< h <<endl;
  }
}


Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))

    x = [i - h for i, h in enumerate(a, 1)]
    y = [i + h for i, h in enumerate(a, 1)]

    from collections import Counter
    c = Counter(y)

    ans = 0
    for i, p in enumerate(x):
        ans += c[p]
        if y[i] == p:
            ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 138512
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        long t = 0, a = 0;
        long x = 1, y = 1;
        long s = 0;
        for (long i = 0; i < n; i++)
        {
            string[] cin = Console.ReadLine().Split();
            t = long.Parse(cin[0]);
            a = long.Parse(cin[1]);
            //while (s * t < x || s * a < y)
            //{
            //    s++;
            //}
            s = Math.Max((x - 1) / t + 1, (y - 1) / a + 1);
            //if (s * t < x || s * a < y) s++;
            x = s * t;
            y = s * a;
            s = 0;
        }
        Console.WriteLine(x + y);
    }
}


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

const int MAXN = 5e5;
int N;
vector<int> adj[MAXN];
int par[MAXN];

void dfs_par(int cur, int prv = 0) {
	par[cur] = prv;
	if (prv != 0) {
		for (auto it = adj[cur].begin(); true; it++) {
			if (*it == prv) {
				adj[cur].erase(it);
				break;
			}
		}
	}

	for (int nxt : adj[cur]) {
		assert(nxt != prv);
		dfs_par(nxt, cur);
	}
}

int dfs_cnt(int cur, int top) {
	if (cur > top) {
		return 0;
	}
	int res = 1;
	for (int nxt : adj[cur]) {
		res += dfs_cnt(nxt, top);
	}
	return res;
}

int C[MAXN];

// v is answer, assuming you're <= top
void solve(int cur, int top = 0, int v = 0) {
	cerr << "Solve\n";
	cerr << cur << ' ' << top << ' ' << v << '\n';
	if (cur > top) {
		C[cur] = v;
		for (int nxt : adj[cur]) {
			C[cur] += dfs_cnt(nxt, top);
		}
		for (int nxt : adj[cur]) {
			solve(nxt, cur, C[cur] + dfs_cnt(nxt, cur) - dfs_cnt(nxt, top) + 1);
		}
	} else {
		C[cur] = v-1;
		for (int nxt : adj[cur]) {
			solve(nxt, top, v);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs_par(1);
	solve(1);
	for (int i = 2; i <= N; i++) {
		cout << C[i] << " \n"[i==N];
	}

	return 0;
}


Measured memory_bytes: 41088
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b == c*d){
      cout<<a*b<<endl;
  }else if(a*b >c*d){
      cout<<a*b<<endl;
  }else{
      cout<<c*d<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
x = n//500
n -= x*500
print(x*1000 + (n//5)*5)

Measured memory_bytes: 63980
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
	long long n;
	long long x;
	cin >> n >> x;
	long long y = n-x;
	long long ans = 0;
	while (y!=0) {
		long long bigger = (x>y)?x:y;
		long long smaller = (x>y)?y:x;
		ans += 3*smaller*(bigger/smaller);
		x = smaller;
		y = bigger % smaller;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def count(n):
    sum = 0
    l = [int(x) for x in list(str(n))]
    for i in l:
      sum += i 
    return sum 
  
N,A,B = map(int,input().split())
i = 1
counter = 0
while i <= N:
  if A <= count(i) <= B:
    counter += i
  i += 1
print(counter)

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  map<ll, ll> m;
  rep(i, 0, N) { m[a[i]]++; }

  ll ans = 0;
  for (auto p : m) {
    if (p.first == p.second) continue;
    if (p.first > p.second) {
      ans += p.second;
      continue;
    }

    ans += p.second - p.first;
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 7040
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    ll ans = 0;
    string st = "MARCH";
    vector<ll> v(5);
    rep(i, n) {
      string s;  cin >> s;
      rep(j, 5) {
        if (s[0] == st[j]) {
          v[j]++;
        }
      }
    }
    rep(i, 5) {
      FOR(j, i + 1, 5) {
        FOR(k, j + 1, 5) {
          ans += v[i] * v[j] * v[k];
        }
      }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), D = ip[0], N = ip[1];
	switch(D) {
		case 0:
			if(N == 100) writeln(101);
			else writeln(N);
			break;
		case 1:
			if(N == 100) writeln(10100);
			else writeln(N*100);
			break;
		case 2:
			if(N == 100) writeln(1010000);
			else writeln(N*10000);
			break;
		default: break;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecvec vector<vector<int>>
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;


int main(){
  int n,m,ans=0;
  cin>>n>>m;
  vec a(n);
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      s--;
      a[s] |= 1<<i;
    }
  }
  int p=0;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    p |=x<<i;
  }
  for(int s=0;s<(1<<n);s++){
    int t=0;
    for(int i=0;i<n;i++){
      if(s>>i&1){
        t^=a[i];
      }
    }
    if(t==p){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[213456], uiop[213456];
signed main() {
	int n = 0, a = 0, b = 0, c = 0, d = 0, e = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'k' && s[h + 1] == 'e' && s[h + 2] == 'y' && s[h + 3] == 'e' && s[h + 4] == 'n' && s[h + 5] == 'c' && s[h + 6] == 'e') {
			if (h == 0 || h + 6 == s.size() - 1) { cout << "YES" << endl; return 0; ; }
		}
		if (s[h] == 'k') { 
			if(h==0)n++; 
		}
		if (s[h] == 'e' && s[h + 1] == 'y' && s[h + 2] == 'e' && s[h + 3] == 'n' && s[h + 4] == 'c' && s[h + 5] == 'e') {
			if (n != 0 && h + 5 == s.size() - 1) { cout << "YES" << endl; return 0; }
		}
		if (s[h] == 'k' && s[h + 1] == 'e') { if (h == 0)a++; }
		if (s[h] == 'y' && s[h + 1] == 'e' && s[h + 2] == 'n' && s[h + 3] == 'c' && s[h + 4] == 'e') {
			if (a != 0 && h + 4 == s.size() - 1) { cout << "YES" << endl; return 0; }
		}
		if (s[h] == 'k' && s[h + 1] == 'e' && s[h + 2] == 'y') { if (h == 0)b++; }
		if (s[h] == 'e' && s[h + 1] == 'n' && s[h + 2] == 'c' && s[h + 3] == 'e') {
			if (b != 0 && h + 3 == s.size() - 1) { cout << "YES" << endl; return 0; }
		}
		if (s[h] == 'k' && s[h + 1] == 'e' && s[h + 2] == 'y' && s[h + 3] == 'e') { if (h == 0)c++; }
		if (s[h] == 'n' && s[h + 1] == 'c' && s[h + 2] == 'e') {
			if (c != 0 && h + 2 == s.size() - 1) { cout << "YES" << endl; return 0; }
		}
		if (s[h] == 'k' && s[h + 1] == 'e' && s[h + 2] == 'y' && s[h + 3] == 'e' && s[h + 4] == 'n') { if (h == 0)d++; }
		if (s[h] == 'c' && s[h + 1] == 'e') {
			if (d != 0 && h + 1 == s.size() - 1) { cout << "YES" << endl; return 0; }
		}
		if (s[h] == 'k' && s[h + 1] == 'e' && s[h + 2] == 'y' && s[h + 3] == 'e' && s[h + 4] == 'n' && s[h + 5] == 'c') { if (h == 0)e++; }
		if (s[h] == 'e') {
			if (e != 0 && h == s.size() - 1) { cout << "YES" << endl; return 0; }
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);		
		int n = sc.nextInt();
		
		if(n<1000) {
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}
	}

}


Measured memory_bytes: 21844
#include<stdio.h>

int main(){
	int j,ninzu,data[101],avg[256],max,min,sum,i,ten;
	j=0;
	
	while(1){scanf("%d",&ninzu);

	if(ninzu==0) break;
	
	for(i=0; i<ninzu; i++){
		scanf("%d",&ten);
		data[i]=ten;
	}

	max=min=data[0];
	for(i=0; i<ninzu; i++){
		if(max<data[i]) max=data[i];
		if(min>data[i]) min=data[i];
	}

	sum=0;
	for(i=0; i<ninzu; i++){
		sum=sum+data[i];
	}
	sum=sum-max-min;
	
	avg[j]=sum/(ninzu-2);
	j++;
	}

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


Measured memory_bytes: 2056
s = int(input())

c = [0 for _ in range(1000001)]
c[s] = 1
for m in range(2, 1000001):
    s = s // 2 if s % 2 == 0 else 3 * s + 1
    if c[s] == 1:
        print(m)
        break
    else:
        c[s] = 1


Measured memory_bytes: 10952
k = gets.chomp.to_i

sum = 0

(1..k).each do |a|
    sum = sum + a
    (a+1..k).each do |b|
        ab = a.gcd(b)
        sum = sum + ab * 6
        (b+1..k).each do |c|
            abc = ab.gcd(c)
            sum = sum + abc * 6
        end
    end
end

puts sum


Measured memory_bytes: 14328
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;				# strictモード
use warnings;			# 警告有効

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $in = <>;chomp $in;
	my $n = $in;
	$in = <>;chomp $in;
	my @a = split(/ /, $in);

	my $cnt = 0;

	foreach (@a){
		my $i = $_;
		while (($i & 1) == 0){
			$i >>= 1;
			$cnt++;
		}
	}

	print $cnt, "\n";

	return 0;
}

#----- 実行 -----#
exit( main() );




Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();
        String last = line.substring(line.length() -1 , line.length());
        if ("s".equals(last)) {
            System.out.println(line + "es");
        } else {
            System.out.println(line + "s");
        }
    }
}


Measured memory_bytes: 38588
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static int SelectionSort(int[] A, int N)
        {
            int count = 0;
            for (int i = 0; i < N -1; i++)
            {
                int min = i;
                for (int j = i; j < N; j++)
                {
                    if (A[j] < A[min])
                    {
                        min = j;
                    }
                }
                if (i != min)
                {
                    int temp = A[i];
                    A[i] = A[min];
                    A[min] = temp;
                    count++;
                }
            }

            return count;            
        }

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();
            var result = SelectionSort(A, N);
            Console.WriteLine(string.Join(" ", A));
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int T = 0;
        int K = 0;
        for(;;)
        {
            if(C<=0)
            {
                T++;
                break;
            }
            if(A<=0)
            {
                K++;
                break;
            }
            A = A - D;
            K++;
            C = C - B;
            T++;
        }
        if(T>K)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, T, A;
		N = sc.nextInt();
		T = sc.nextInt();
		A = sc.nextInt();
		int H[] = new int[N];
		double max = 99999;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
			double t = T - H[i] * 0.006;
			if (max > Math.abs(A - t)) {
				;
				max = Math.abs(A - t);
				ans = i + 1;
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996