akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    let D: Vec<usize> = sc.vec(K);
    let mut ans = INF;
    for pay in N..1000000 {
        let mut rem = pay;
        let mut d = HashSet::new();
        while rem != 0 {
            d.insert(rem % 10);
            rem /= 10;
        }
        let mut ok = true;
        for i in 0..K {
            if d.contains(&D[i]) {
                ok = false;
            }
        }
        if ok {
            ans = min(ans, pay);
        }
    }
    println!("{}", ans);
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);
const int MAX_M = (int)(1e2 + 5);

int n, m, x;
set<int> set_a;

int acc[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d %d", &n, &m, &x);

  for (int i = 1; i <= m; ++i) {
    int a;
    scanf("%d", &a);

    set_a.insert(a);
  }

  int fst = 0;

  for (int i = x; i <= n; ++i) {
    if (set_a.find(i) != set_a.end()) {
      fst += 1;
    }
  }

  int snd = 0;

  for (int i = x; i >= 0; --i) {
    if (set_a.find(i) != set_a.end()) {
      snd += 1;
    }
  }

  printf("%d\n", min(fst, snd));
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int n,count=0;double rad=M_PI/3;void segment(double x1,double y1,double x5,double y5,int count){double x2,y2,x3,y3,x4,y4;x2=(2*x1+x5)/3.0;y2=(2*y1+y5)/3.0;x4=(x1+2*x5)/3.0;y4=(y1+2*y5)/3.0;x3=x2+(x4-x2)*cos(rad)-(y4-y2)*sin(rad);y3=y2+(x4-x2)*sin(rad)+(y4-y2)*cos(rad);count++;if(count<n){segment(x1,y1,x2,y2,count);segment(x2,y2,x3,y3,count);segment(x3,y3,x4,y4,count);segment(x4,y4,x5,y5,count);}else{printf("%f %f\n",x2,y2);printf("%f %f\n",x3,y3);printf("%f %f\n",x4,y4);printf("%f %f\n",x5,y5);}}int main(){double x1=0.0,x2=100.0;scanf("%d",&n);printf("%f %f\n",x1,x1);if(n==0) printf("%f %f\n",x2,x1);else segment(x1,x1,x2,x1,count);return 0;}

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

template<class T>
T extgcd(T a,T b,T &x,T &y){
	T d = a;x = 1;y = 0;
	if(b != 0){
		d = extgcd(b,a % b,y,x);
		y -= (a / b) * x;
	}
	return d;
}

signed main(){
	int a,b,x,y;
	scanf("%d %d",&a,&b);
	extgcd(a,b,x,y);
	printf("%d %d\n",x,y);
}


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

using namespace std;

int main() {
	int n, k; scanf("%d %d", &n, &k);
	vector<int> arr(n);
	for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
	for (int i = 0, j = k; j < n; ++i, ++j) {
		if (arr[j] > arr[i]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>

int main(void)
{
	int a, b, c, t, S = 0, A = 0, C = 0, D = 0;

	for (;;) {
		scanf("%d %d %d\n", &a, &b, &c);
		if (a < b) {t = a; a = b; b = t;}
		if (a < c) {t = a; a = c; c = t;}
		if (a >= b + c) break;
		S++;
		if      (a * a <  b * b + c * c) A++;
		else if (a * a == b * b + c * c) C++;
		else if (a * a >  b * b + c * c) D++;
	}
	printf("%d %d %d %d\n", S, C, A, D);
}



Measured memory_bytes: 2096
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

	string s;
	cin >> s;
	for(int i = 1; i< s.length(); ++i)
	{
		if(s[i] != s[i-1])
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";


    return 0;
}

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

using namespace std;

namespace Tzh{
	
	const int maxn=10010;
	int head[maxn],ans[maxn],a[maxn],n,cnt,sum,tot;
	

	struct ed{
		int next,to;
	}e[maxn<<1];

	void add(int u,int v){
		e[++cnt]=(ed){head[u],v}; head[u]=cnt;
		e[++cnt]=(ed){head[v],u}; head[v]=cnt;
	}

	void dfs(int now,int f){
		ans[now]=a[++tot];
		for(int i=head[now];i;i=e[i].next){
			int tt=e[i].to; if(tt==f) continue;
			dfs(tt,now);
		}
	}

	void work(){
		scanf("%d",&n); int u,v;
		for(int i=1;i<n;i++) scanf("%d%d",&u,&v),add(u,v);
		for(int i=1;i<=n;i++) scanf("%d",a+i);
		sort(a+1,a+n+1,greater<int>());
		dfs(1,0); for(int i=2;i<=n;i++) sum+=a[i];
		printf("%d\n",sum);
		for(int i=1;i<=n;i++) printf("%d ",ans[i]);

		return ;
	}
}

int main(){
	Tzh::work();
	return 0;
}	

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d",a+b+c-MAX3(a,b,c));
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string>
using namespace std;
int main(){
	int i,k,h,w;
	scanf("%d%d",&h,&w);
	char kumo[w+1];
	 for(k=0;k<h;k++){
		scanf("%s",kumo);
	   string s(kumo);
	  for(i=0;i<w;i++){
		 if(s[i]=='c'){
			   printf("0");
		  }
		   else if(s[i]=='.'){
			   if(i==0){
				   printf("-1");
			   }
			   for(int j=i-1;j>=0;j--){
				   if(s[j]=='c'){
					   printf("%d",i-j);
					   break;
				   }
				   if(j==0){
					   printf("-1");
				   }
			   }
		   }
		 if(i!=(w-1)){
			 printf(" ");
		 }
	  }
	  
	  printf("\n");
	 }
	 return 0;
}

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

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,m;
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            n = temp[0];m=temp[1];
            var A = new int[n,m];
            var b = new int[m];
            var result = new int[n];

            for (int i = 0; i < n; i++)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (var j = 0; j < m; j++)
                {
                    A[i, j] = temp[j];
                }
            }
            for (var i = 0; i < m; i++)
                b[i] = int.Parse(Console.ReadLine()); 
            int ci=0;
            for(int i =0;i<n;i++)
            {
                for (var j = 0; j < m; j++)
                {
                    ci += A[i, j] * b[j];
                }
                result[i] = ci;
                ci = 0;
            }
            foreach (var c in result)
            {
                Console.WriteLine(c);
            }




        }
    }
}

Measured memory_bytes: 20256
function Main(input) {
	var inputdata = input.split("\n");
	if(inputdata[0]<3200){
	    console.log("red");
	}else{
	    console.log(inputdata[1]);
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#pragma comment(linker, "/STACK:512000000")
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
//    assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
    cout.sync_with_stdio(0);
    cin.tie(0);
#endif
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        solve(true);
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    auto end = clock();

    usleep(10000);
    print_stats(end - start);
    usleep(10000);
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

//#define int li
//const int mod = 1000000007;

struct Node {
    int min;
    int sum;
};

Node merge(const Node& q, const Node& w) {
    Node res = {min(q.min, w.min), q.sum + w.sum};
    return res;
}

const int INF = (int)1e9;

struct SegTree {
    int shift;
    vector<Node> tree;
    SegTree(int n) {
        shift = 1;
        while (shift < n) {
            shift *= 2;
        }
        tree.assign(2 * shift, {INF, 0});
    }
    Node get_res(int l, int r) {
        l += shift;
        r += shift;
        Node res = {INF, 0};
        while (l < r) {
            if (l & 1) {
                res = merge(res, tree[l++]);
                continue;
            }
            if (r & 1) {
                res = merge(res, tree[--r]);
                continue;
            }
            l /= 2;
            r /= 2;
        }
        return res;
    }
    void update(int v, int val) {
        v += shift;
        tree[v] = {v - shift, val};
        v /= 2;
        while (v) {
            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
            v /= 2;
        }
    }
};

void solve(__attribute__((unused)) bool read) {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> xs;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        xs.push_back(i - a[i]);
    }
    sort(all(xs));
    xs.erase(unique(all(xs)), xs.end());
    SegTree tree(xs.size());
    if (xs[0] < 0) {
        cout << "-1\n";
        return;
    }
    li res = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i]) {
            int id = lower_bound(all(xs), i - a[i]) - xs.begin();
            tree.update(id, 1);
        }
        int id = lower_bound(all(xs), i) - xs.begin();
        auto cur_node = tree.get_res(0, id);
        if (cur_node.min < xs.size() && i - xs[cur_node.min] > a[i]) {
            cout << "-1\n";
            return;
        }
        res += cur_node.sum;
    }
    cout << res << "\n";
}

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

char moji(int number);

int main()
{
  std::string s;
  int number=0;

  std::cin >> s;


  number = s.length();
  if (number-2 < 10){
    s[1] = moji(number-2);
    s[2] = s[number-1];
    s[3] = '\0';
  }else {
    int tennumber = (number-2) / 10;
    s[1] = moji(tennumber);
    s[3] = s[number-1];
    number = number-2;
    number %=  10;
    s[2] = moji(number);
    s[4] = '\0';
  }
  



  for (int i=0; s[i] != '\0'; ++i){
    std::cout << s[i];
  }
    std::cout << std::endl;



  return 0;
}

char moji(int number)
{
  char test;

  switch (number){
    case 0: test='0'; break;
    case 1: test='1'; break;
    case 2: test='2'; break;
    case 3: test='3'; break;
    case 4: test='4'; break;
    case 5: test='5'; break;
    case 6: test='6'; break;
    case 7: test='7'; break;
    case 8: test='8'; break;
    case 9: test='9'; break;
  }

  return test;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(1, N):
  if A[i-1] > A[i]:
    ans += A[i-1] - A[i]
    A[i] = A[i-1]
print(ans)

Measured memory_bytes: 94184
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 vector<long long int> v;
 for(int i=0;i<n;i++)
 {
     long long int x;
     cin>>x;
     v.push_back(x);
 }
 long long int ans=0;
 for(int i=1;i<n;i++)
 {
     if(v[i-1]>v[i])
     {
         ans+=v[i-1]-v[i];
         v[i]=v[i-1];
     }
 }
 
 cout<<ans;
 return 0;
}

Measured memory_bytes: 5360
h, w = map(int, input().split())
s = [[] for i in range(h)]
for i in range(h):
    s[i] = input()
s2 = [[False for j in range(w)] for i in range(h)]

ssum = 0
ssum2 = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            # print(i, j, s[i][j])
            if 0 < i:
                # print(s[i-1][j])
                if s[i-1][j] == "#":
                    s2[i][j] = True
            if i < h-1:
                # print(s[i+1][j])
                if s[i+1][j] == "#":
                    s2[i][j] = True
            if 0 < j:
                # print(s[i][j-1])
                if s[i][j-1] == "#":
                    s2[i][j] = True
            if j < w-1:
                # print(s[i][j+1])
                if s[i][j+1] == "#":
                    s2[i][j] = True
            if s2[i][j]:
                ssum2 += 1
            ssum += 1
if ssum == ssum2:
    print('Yes')
else:
    print('No')


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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


  int n;
  cin >> n;

  vii p;
  rep(i,0,n) {
    ll x, l;
    cin >> x >> l;
    p.emplace_back(x+l, x-l);
  }

  sort(all(p));

  ll lst = -100000000000;
  ll ans = 0;
  rep(i,0,n) {
    if (p[i].snd >= lst) {
      lst = p[i].fst;
      ++ans;
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n;cin >> n;
    pair<int, int> ary[n];
    rep(i,n)
    {
        int tmp; cin >> tmp;
        ary[i] = make_pair(tmp, i);
    }
    sort(ary, ary+n);
    rep(i,n)
    {
        cout << ary[i].second+1;
        if (i!=n-1) cout << " ";
    }
    cout << endl;


}


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

const int mod = (int)1e9+7;

template<typename T> struct combination {
    int MAX;
    vector<T> f;
    vector<vector<T>> dp;
    combination(int _n) {
        MAX = _n;
        f.resize(MAX + 1, 0);
        for (int i = 0; i <= MAX; i++) {
            if (i == 0) f[i] = 1;
            else f[i] = i * f[i-1] % mod;
        }
        dp.resize(MAX + 1, vector<T>(MAX + 1, 0));
    }
    T power(int m, int n) { // m^n
        if (n == 0) return 1;
        if (n % 2 == 1) return m * power(m, n-1) % mod;
        T r = power(m, n/2);
        return r * r % mod;
    }
    T inv(int a, int b) { // a / b % mod
        return a * power(b, mod-2) % mod;
    }
    T fact(int n) { // n!
        return f[n];
    }
    T perm(int n, int r) { // nPr
        if (n < r) return 0;
        return inv(fact(n), fact(n-r));
    }
    T comb(int n, int r) { // nCr
        if (n < r) return 0;
        return inv(perm(n, r), fact(r));
    }
    T pie(int n, int k) { // 包除原理
        T s = 0;
        for (int i = 0; i < k; i++) {
            s += power(-1, i) * comb(k, i) * power(k-i, n);
            s %= mod;
            if (s < 0) s += mod;
        }
        return s;
    }
    T part(int n, int k) { // 分割数
        if (n < 0) return 0;
        if (n == 0 || k == 1) return dp[n][k] = 1;
        if (dp[n][k] != 0) return dp[n][k];
        return dp[n][k] = (part(n, k-1) + part(n-k, k)) % mod;
    }
    T stir(int n, int k) { // スターリング数
        if (n < k || (n > 0 && k == 0)) return 0;
        if (n == k || k == 1) return dp[n][k] = 1;
        if (dp[n][k] != 0) return dp[n][k];
        return dp[n][k] = (stir(n-1, k-1) + k * stir(n-1, k)) % mod;
    }
    T bell(int n, int k) { // ベル数
        T s = 0;
        for (int i = 0; i <= k; i++) {
            s += stir(n, i);
            s %= mod;
        }
        return s;
    }
};

int main() {
    ll n;
    cin >> n;
    combination<ll> c(0);
    ll r = c.power(10, n);
    r -= c.power(9, n) * 2;
    r %= mod;
    r += c.power(8, n);
    r %= mod;
    if (r < 0) r += mod;
    cout << r << endl;
}

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[4][14]={{}};
    char mark;
    int num;
    
    for(int i = 0; i < n; i++)
    {
        cin>>mark>>num; 
        switch(mark)
        {
            case 'S': 
                p[0][num] = 1;
                break;
            case 'H':
                p[1][num] = 1;
                break; 
            case 'C': 
                p[2][num] = 1;
                break;
            case 'D': 
                p[3][num] = 1;
                break;
        }
    }
    const char m[] = {'S', 'H', 'C', 'D'};

    for(int j = 0; j < 4; j++)
    {
        for(num = 1; num <= 13; num++)
        {
            if(!p[j][num])
            {
                cout<<m[j]<<" "<<num<<endl;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3096
#include<cstdio>
#include<vector>
using namespace std;
int main(){
    for(;;){
        int n,m;
        scanf("%d%d",&n,&m);
        if(n==0&&m==0) break;
        vector<bool> ismyfr(n+1,false);
        vector<vector<int> > frs(m,vector<int>(2));
        for(int i=0;i<m;i++){
            scanf("%d%d",&frs[i][0],&frs[i][1]);
            if(frs[i][0]==1) ismyfr[frs[i][1]]=true;
            else if(frs[i][1]==1) ismyfr[frs[i][0]]=true;
        }
        vector<bool> ismyfrfr(ismyfr);
        for(int i=1;i<=n;i++){
            if(ismyfr[i]){
                for(int j=0;j<m;j++){
                    if(frs[j][0]==i) ismyfrfr[frs[j][1]]=true;
                    else if(frs[j][1]==i)ismyfrfr[frs[j][0]]=true;
                }
            }
        }
        int ret=0;
        for(int i=2;i<=n;i++)if(ismyfrfr[i])ret++;
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 0
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift();
var ary=arr.shift().split("");
var dp=[];
for(var i=0;i<=n;i++){
   dp[i]={};
   dp[i]["--I"]=0;
   dp[i]["-O-"]=0;
   dp[i]["J--"]=0;
   dp[i]["-OI"]=0;
   dp[i]["J-I"]=0;
   dp[i]["JO-"]=0;
   dp[i]["JOI"]=0;
}
dp[0]["J--"]=1;
var key=["--I","-O-","J--","-OI","J-I","JO-","JOI"];
for(var i=1;i<=n;i++){
   var joi=ary[i-1];
   for(var j=0;j<key.length;j++){
      var B=key[j];
      for(var k=0;k<key.length;k++){
          var A=key[k];
          if(A.indexOf(joi)==-1)continue;
          var flag=false;
          for(var p=0;p<3;p++){
             if(A[p]!="-" && A[p]==B[p])flag=true;
          }
          if(flag==false)continue;
          dp[i][A]+=dp[i-1][B]%10007;
      }
   }
}
var sum=0;
for(var k in dp[n]){
   sum+=dp[n][k];
}
console.log(sum%10007);

Measured memory_bytes: 17556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner s = new Scanner(System.in);

		while(s.hasNext()){
			
			int n = s.nextInt();
			int count = 0;
			for(int a=0;a<10;a++)			{
				for(int b =0;b<10;b++){
					for (int c = 0; c < 10 ;c++){
						for(int d =0;d<10;d++){
							if(a+b+c+d==n)
								count++;
						}
					}
				}
			}

			System.out.println(count);

		}
	}
}

Measured memory_bytes: 26580
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;

	cout << N * N * N << endl;;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define reps(X,Y,Z) for(int X = (Y); X <= (Z); ++(X))
#define rep(X,Y) reps(X,0, (ll)Y-1)

const ll INF = 1e16;

ll w[4096];
ll dp[4096][4096];
ll asum[4096];
int amk[4096][4096];

int main(){
  int n;
  cin >> n;
  rep(i,n) cin >> w[i];
  fill(dp[0], dp[0]+4096*4096, INF);
  
  rep(i,n){
    dp[i][i+1] = 0;
    amk[i][i+1] = i;
    asum[i+1] = asum[i] + w[i];
  }

  reps(d,2,n){
    rep(i,n){
      ll m = INF;
      reps(k, amk[i][i+d-1], amk[i+1][i+d]){
        ll sum = dp[i][k] + dp[k][i+d] + asum[i+d] - asum[i];
        if( m > sum){
          m = sum;
          amk[i][i+d] = k;
        }
      }
      dp[i][i+d] = m;
    }
  }
  
  cout << dp[0][n] << endl;
}

Measured memory_bytes: 186100
<?php

$n = trim(fgets(STDIN));

$ans = 0;
for($i=0; $i<strlen($n); $i++){
    $ans += substr($n, $i, 1);
}

if($ans%9==0) {
    echo "Yes" . PHP_EOL;
} else {
    echo "No" . PHP_EOL;
}

Measured memory_bytes: 16528
A,B,K =  map(int,input().split())
C=[]


N = min(A,B)

for i in range(N):
    if A % (i+1) == 0:
        if B % (i+1) ==0:
            C.append(i+1)

N = len(C)
print(int(C[N-K]))

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n=5,s=2,e=3,w=4,t=1,b=6;
	int y,z;
	int p=1;
	char sn[10];
	while(1){
		cin>>y;
		if(y==0){
			break;
		}

		for(int i=0;i<y;i++){
			cin>>sn;
			if(sn[0]=='N'){
				z=t;
				t=s;
				s=b;
				b=n;
				n=z;
				p=p+t;
			}
		else if(sn[0]=='S'){
			z=t;
			t=n;
			n=b;
			b=s;
			s=z;
			p=p+t;
		}
		else if(sn[0]=='E'){
			z=t;
			t=w;
			w=b;
			b=e;
			e=z;
			p=p+t;
		}
		else if(sn[0]=='W'){
			z=t;
			t=e;
			e=b;
			b=w;
			w=z;
			p=p+t;
		}
			else if(sn[0]=='R'){
				z=s;
				s=e;
				e=n;
				n=w;
				w=z;
				p=p+t;
			}
			else if(sn[0]=='L'){
				z=s;
				s=w;
				w=n;
				n=e;
				e=z;
				p=p+t;
			}

		}
		cout<<p<<endl;
		n=5,s=2,e=3,w=4,t=1,b=6;
		p=1;
	}

	return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main() {
  using LL = long long;
  const LL MOD = 1e9+7;
  int N, M;
  cin >> N >> M;
  vector<LL> S(N), T(M);
  for(auto v: {&S, &T}) for(auto& i: *v) cin >> i;
  vector<vector<LL>> dp(N+1, vector<LL>(M+1));
  for(auto i=1; i<=N; ++i) for(auto j=1; j<=M; ++j) {
    dp[i][j] += dp[i-1][j] + dp[i][j-1];
    dp[i][j] += (S[i-1]==T[j-1] ? 1 : -dp[i-1][j-1]);
    (dp[i][j] += MOD) %= MOD;
  }
  cout << (1 + dp[N][M]) % MOD << endl;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//入力
		int N = sc.nextInt();

		ArrayList<Long> LucasArray = new ArrayList<Long>();

		LucasArray.add((long)2);
		LucasArray.add((long)1);
		if (N > 1) {
			for (int i = 0; i < N; i++) {
				Long tmp = LucasArray.get(i) + LucasArray.get(i+1);
				LucasArray.add(tmp);
			}
		}
			System.out.print(LucasArray.get(N));
	}
}

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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 100005;
const int M = 1000000000;

pair2<int> seg[maxn];
int leftmnR[maxn], leftmxL[maxn], rightmnR[maxn], rightmxL[maxn];
int n;
int answer;

void solve1(int L, int R)
{
	for (int i = 0; i < n; i++)
	{
		answer = max(answer, seg[i].se - seg[i].fi + 1 + max(0, R - L + 1));
	}
}

void solve2(int L, int R)
{
	leftmxL[0] = 1;
	leftmnR[0] = M;
	for (int i = 0; i < n; i++)
	{
		leftmxL[i + 1] = max(leftmxL[i], seg[i].fi);
		leftmnR[i + 1] = min(leftmnR[i], seg[i].se);
	}
	rightmxL[n] = 1;
	rightmnR[n] = M;
	for (int i = n - 1; i >= 0; i--)
	{
		rightmxL[i] = max(rightmxL[i + 1], seg[i].fi);
		rightmnR[i] = min(rightmnR[i + 1], seg[i].se);
	}
	for (int i = 0; i < n - 1; i++)
	{
		answer = max(answer, max(0, leftmnR[i + 1] - leftmxL[i + 1] + 1) + max(0, rightmnR[i + 1] - rightmxL[i + 1] + 1));
	}
}

int main()
{
	scanf("%d", &n);
	int mxL = 1;
	int mnR = M;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &seg[i].fi, &seg[i].se);
		mxL = max(mxL, seg[i].fi);
		mnR = min(mnR, seg[i].se);
	}
	sort(seg, seg + n);
	answer = 0;
	solve1(mxL, mnR);
	solve2(mxL, mnR);
	cout << answer << endl;
    return 0;
}


Measured memory_bytes: 2560
import heapq as q

def main():
	n,m = map(int, input().split())
	ab = []
	for _ in range(n):
		ab += [list(map(int,input().split()))]
	ab.sort(key=lambda x:x[0])
	hq = []
	index = 0
	ans = 0
	for i in range(1,m+1):
		while True:
			if index == n:
				break
			if ab[index][0] > i:
				break
			q.heappush(hq, -ab[index][1])
			index += 1
		if hq == []:
			continue
		ans += -1*q.heappop(hq)
	print(ans)

main()
	

Measured memory_bytes: 31928
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int n;
    cin >> n;
    lli a[100005] = {};
    lli b;
    rep(i, n)
    {
        cin >> b;
        while (b % 2 == 0) {
            b /= 2;
            a[i]++;
        }
    }
    sort(a, a + n);
    int l = 0, r = n - 1;
    vector<lli> c;
    rep(i, n)
    {
        if (i % 2) {
            c.push_back(a[r]);
            r--;
        } else {
            c.push_back(a[l]);
            l++;
        }
    }
    rep(i, n - 1)
    {
        if (c[i] + c[i + 1] < 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define N 1234
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
int h[N][N];
int n, m;
void Constr(int U, int D, int L, int R) {
	if (U == D && L == R)	return h[U][L] = 1, void();
	int m1 = (U + D)>>1, m2 = (L + R) >> 1;
	Constr(U, m1 - 1, L, m2 - 1);
	Constr(U, m1 - 1, m2 + 1, R);
	Constr(m1 + 1, D, L, m2 - 1);
	Constr(m1 + 1, D, m2 + 1, R);
	h[m1][m2] = 1;
}
int main() {
	read(n), read(m);
	n = (1 << n) - 1, m = (1 << m) - 1;
	int mx = max(n, m);
	Constr(1, mx, 1, mx);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			printf("%d", h[i][j]);
		}
		putchar('\n');
	}
	return 0;
}


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


int main() {

    /*
     * */
    int A, B;
    cin >> A >> B;

    rep(i,1000000){
        if(i*8/100 == A && i*10/100 == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4005,M=1000000;
signed main(void){
	int n;
	bool flag;
	int id[N],sum[N];
	map<int,int> Map; 
	ios::sync_with_stdio(false);
	while(cin>>n&&n){
		Map.clear();
		flag=true;
		memset(sum,0,sizeof(sum));
		for(int i=1,x,y;i<=n;i++){
			cin>>id[i]>>x>>y;
			if(!Map[id[i]])
				Map[id[i]]=i;
			sum[Map[id[i]]]+=x*y;
		}
		for(int i=1;i<=n;i++)
			if(sum[i]>=M){
				flag=false;
				cout<<id[i]<<endl;
			}
		if(flag)
			cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 1308
def atc_089b(input_value: str) -> str:
    N = input_value[0]
    Si = input_value[1]
    colors = ["P" in Si, "W" in Si, "G" in Si, "Y" in Si]
    if colors.count(True) == 3:
        return "Three"
    elif colors.count(True) == 4:
        return "Four"
    else:
        return "other"

N_input = input()
Si_input = input()
print(atc_089b([N_input, Si_input]))


Measured memory_bytes: 9036
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;

int main(){
	char a[5];
	int N;
	for(int i = 1;i <= 4;i++){

		scanf("%c",&a[i]);
	}
	if((a[1] == a[2] && a[2] == a[3])||(a[2] == a[3] && a[3] == a[4]))
		printf("Yes\n");
		else			
			printf("No\n");
}
	


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

if a[0] != 0:
    print(0)
    exit()

a.sort()
b = set(a[1:])
if 0 in b:
    print(0)
    exit()

num = max(b) - min(b) + 1
if num != len(b):
    print(0)
    exit()

count_pre = 1
count_now = 1
ans = 1
for i in range(1, n-1):
    if a[i] == a[i+1]:
        count_now += 1
    else:
        ans *= (count_pre ** count_now)
        ans %= 998244353
        count_pre = count_now
        count_now = 1
ans *= (count_pre ** count_now)
ans %= 998244353

print(ans)

Measured memory_bytes: 16252
n = int(input())

A = list(map(int, input().split()))

B = []
C = []
for i in range(n):
    if len(C) == 0 or len(C) == 1:
        C.append(A[i])
    else:
        if C[-2] <= C[-1] and C[-1] < A[i]:
            C.append(A[i])
        elif C[-2] >= C[-1] and C[-1] > A[i]:
            C.append(A[i])
        elif (C[-2] <= C[-1] and C[-1] > A[i]) or (C[-2] >= C[-1] and C[-1] < A[i]):
            B.append(C)
            C = []
            C.append(A[i])
if len(C) >= 1:
    B.append(C)
print(len(B))

Measured memory_bytes: 63384
#include <stdio.h>
#define N 100

int main(){
  int A[N];
  int num, i, temp;
  int count = 0, flag = 1;

  scanf("%d", &num);
  
  for(i = 0; i < num; i++){
    scanf("%d", &A[i]);
  }

  while(flag == 1){
    flag = 0;
    for(i = num-1; i > 0; i--){
      if(A[i] < A[i-1]){
	temp = A[i];
	A[i] = A[i-1];
	A[i-1] = temp;

	flag = 1;
	count++;
      }
    }
  }
  for(i = 0; i < num-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[num-1]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2124
(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((a (read))
         (b (read)))
    (println (max (+ a b) (- a b) (* a b)))))

#-swank (main)






Measured memory_bytes: 5216
while True:
    n = input()

    if n =='-':
        break
    m = int(input())

    for i in range(0,m):
        s = int(input())
        n=n[s:]+n[:s]
        # print(m)
        # print(n[s:len(n)])
        # print(n[0:s])
    print(n)




Measured memory_bytes: 5592
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{

    int x,y;
    int ans = 0;

    cin >> x >> y;
    if((x % y) == 0) ans = -1;
    else ans = x;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
d = [0]*k
a = [0]*k
s = []
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int,input().split()))
    s.extend(a[i])
d = set(s)
print(n-len(d))

Measured memory_bytes: 9372
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sc scanf
#define pr printf

#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sqr(x) ((x) * (x))

#define sci(n) sc("%d", &n);
#define sci2(n, m) sc("%d%d", &n, &m);
#define scl(n) sc("%I64d", &n);
#define scl2(n, m) sc("%I64d%I64d", &n, &m);

#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1000000000;

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

	ll jv = 0;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			int son = 0;
			while (n % i == 0)
				n /= i, son++;

			for (int k = 1; son - k >= 0; k++)
				jv++, son -= k;

			// jv++;
		}
	}
	// xatop(jv);

	if (n > 1) jv++;

	cout << jv << endl;

	return 0;
}


Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut x: i64 = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    a.sort();
    let mut ans = 0;
    for i in 0..n {
        if x >= a[i] {
            x -= a[i];
            ans = i + 1;
        }
    }
    if x > 0 && ans == n {
        ans -= 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;

int main() {
  int x;
  cin >> x;
  for(int i = 1; i <= x; i++) {
    if(100*i <= x & x <= 105*i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  int maxh=-1,ans=0;
  rep(i,n){
    int h;
    cin>>h;
    if(maxh<=h){
      ans++;
      maxh=h;
    }
  }
  cout<<ans<<endl;
}


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

#define MOD 998244353

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

typedef long long int64;

int main(void){
    int N;
    scanf("%d",&N);
    int A[N];
    int gcdr[N];
    int gcdl[N];
    int GCD[N+1];
    int max=0;
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    gcdl[0]=A[0];
    for(int i=0;i<N-1;i++){
        gcdl[i+1]=gcd(gcdl[i],A[i+1]);
    }
    gcdr[N-1]=A[N-1];
    for(int i=N-2;i>=0;i--){
        gcdr[i]=gcd(gcdr[i+1],A[i]);
    }
    GCD[0]=gcdl[N-1];
    GCD[1]=gcdr[1];
    for(int i=2;i<=N-1;i++){
        GCD[i]=gcd(gcdl[i-2],gcdr[i]);
    }
    GCD[N]=gcdl[N-2];
    for(int i=0;i<=N;i++){
        max=MAX(max,GCD[i]);
    }

    printf("%d",max);
    
    return 0;
}

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

using namespace std;

#define endl "\n"

typedef unsigned long long ull;
typedef double lf;
typedef long double llf;
typedef long long ll;

int main()
{
    char x;
    cin >> x;
    if (x >= 'a' && x <= 'z')
    	cout << "a" << endl;
    else 
    	cout << "A" << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String x = sc.next();
            if(x.equals("0")){
                break;
            }
            int len = x.length();
            char[] number = new char[len];
            for(int i = 0; i < len; i++){
                number[i] = x.charAt(i);
            }
            int Sum = 0;
            for(int i = 0; i < len; i++){
                Sum = Sum + (number[i] - '0');
            }
            System.out.println(Sum);
        }
    }
}


Measured memory_bytes: 26248
#include <iostream>

using namespace std;

int main(){
  char S[16] = {0};
  char S2[17] = "CODEFESTIVAL2016";
  int ans = 0;

  for(int i = 0;i < 16;i++){
    cin >> S[i];
    if(S[i] != S2[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL N, A;
LL safe_mul(LL x, LL y) {
    if (x == 0 || y == 0) return 0;
    if (N / y < x) return N;
    return x*y;
}

bool ok(LL mid, LL s) {
    LL q = mid / s;
    LL r = mid % s;
    LL m = 1;
    REP (i, s) {
	if (i < r) m = safe_mul(m, q+1);
	else m = safe_mul(m, q);
    }
    return m >= N;
}

void MAIN() {
    scanf("%lld%lld", &N, &A);

    LL ans = N;

    REP (i, 60) {
	if (ans <= A*i) break;
	LL lo = 0;
	LL hi = ans - A*i;
	if (!ok(hi, i+1)) continue;
	while (hi - lo > 1) {
	    LL mid = (hi + lo) / 2;
	    (ok(mid, i+1)? hi: lo) = mid;
	}

	amin(ans, hi + A*i);
    }
    
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main()
{  
  int n;
  cin >> n;
  vector<int> a(n);
  long ans=0;
  for(int i=0;i<n;++i){
    cin >> a.at(i);
    if(i%2==0){
      ans+=a.at(i);
    }else{
      ans-=a.at(i);
    }
  }
  
  cout << ans << " ";
  for(int i=0;i<n-1;++i){
    ans=a.at(i)*2-ans;
    cout << ans << " ";
  }
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

  vector<int> roll(char opp,vector<int>  DICE)
  {
    vector<int> rolled(6,0);

    if(opp =='W')
    {
      rolled[0] = DICE[2];
      rolled[1] = DICE[1];
      rolled[2] = DICE[5];
      rolled[3] = DICE[0];
      rolled[4] = DICE[4];
      rolled[5] = DICE[3];
    }
    else if( opp == 'S')
    {
      rolled[0] = DICE[4];
      rolled[1] = DICE[0];
      rolled[2] = DICE[2];
      rolled[3] = DICE[3];
      rolled[4] = DICE[5];
      rolled[5] = DICE[1];
    }
    else if(opp == 'N')
    {
      rolled[0] = DICE[1];
      rolled[1] = DICE[5];
      rolled[2] = DICE[2];
      rolled[3] = DICE[3];
      rolled[4] = DICE[0];
      rolled[5] = DICE[4];
    }

    else if(opp == 'E')
    {
      rolled[0] = DICE[3];
      rolled[1] = DICE[1];
      rolled[2] = DICE[0];
      rolled[3] = DICE[5];
      rolled[4] = DICE[4];
      rolled[5] = DICE[2];
    }
    else if(opp == 'R')
    {
      rolled[0] = DICE[0];
      rolled[1] = DICE[2];
      rolled[2] = DICE[4];
      rolled[3] = DICE[1];
      rolled[4] = DICE[3];
      rolled[5] = DICE[5];     
    }
    else
    {
      cout<<"XXX"<<endl;
    }
    

    return rolled;
    

  }

  bool Q_check(vector<int> DICE,int TOP,int FRONT)
  {
    if((DICE[0] == TOP)&&(DICE[1] ==FRONT))
    {
      cout<<DICE[2]<<endl;
      return 1;
    }

    return 0;
  }

  void Q(vector<int> DICE,int TOP,int FRONT)
  {
    bool check = 0;

    for (int q = 0; q < 4; q++)
    {
     for (int i = 0; i < 4; i++)
    {
      DICE = roll('R',DICE);
      check = Q_check(DICE,TOP,FRONT);
      if(check == 1) return;
    }

    DICE = roll('N',DICE);     
    }
    
    for (int q = 0; q < 4; q++)
    {
     for (int i = 0; i < 4; i++)
    {
      DICE = roll('R',DICE);
      check = Q_check(DICE,TOP,FRONT);
      if(check == 1) return;
    }

    DICE = roll('E',DICE);     
    }

  
  }

void solve(void)
{ 

  vector<int> DICE (6,0);

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

  int M;
  cin>>M;

  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    Q(DICE,A,B);
  }
  
  
  


  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

li a[100100];
li n;



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

	li res = n;
	rep(i, n - 1) {
		if (s[i] != s[i + 1]) {
			res = min(res, max(i + 1, n - i - 1));
		}
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,c,d,n;
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);
	c=min(a*4,min(b*2,c));
	ll ans=0;
	if(2*c>d){
		ans+=n/2*d;
		n%=2;
	}
	printf("%lld\n",ans+n*c);
}

Measured memory_bytes: 128
n = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if abs(prev_x - x) + abs(prev_y - y) > abs(prev_t - t) or (
            abs(prev_x - x) + abs(prev_y - y) + abs(prev_t - t)) % 2:
        print('No')
        exit()
    prev_t, prev_x, prev_y = t, x, y
print('Yes')


Measured memory_bytes: 3060
n = int(input())
s = input()
tb1 = [0]*n
tb2 = [0]*n
for i in range(1,n):
  if s[i-1]=='E':
    tb1[i] = tb1[i-1]+1
  else:
    tb1[i] = tb1[i-1]
for i in range(n-2,-1,-1):
  if s[i+1]=='W':
    tb2[i] = tb2[i+1]+1
  else:
    tb2[i] = tb2[i+1]    
tb = [k+l for k,l in zip(tb1,tb2)]
print(n-max(tb)-1)

Measured memory_bytes: 35572
class UnionFind(n: Int) {
    val v = Array(n) {
        -1
    }

    fun unite(a: Int, b: Int) {
        val ar = find(a)
        val br = find(b)
        if (ar == br) {
            return
        }
        if (v[ar] > v[br]) {
            v[br] += v[ar]
            v[ar] = br
        } else {
            v[ar] += v[br]
            v[br] = ar
        }
    }

    fun find(i: Int): Int {
        if (v[i] < 0) {
            return i
        }
        v[i] = find(v[i])
        return v[i]
    }

    fun same(a: Int, b: Int): Boolean {
        return find(a) == find(b)
    }

    fun size(i: Int): Int {
        return -v[find(i)]
    }
}

fun main(args: Array<String>) {
    val (n, m, k) = readLine()?.split(" ")?.map(String::toInt) ?: return

    val friends = Array(n) { 0 }
    val blocks = hashMapOf<Int, MutableList<Int>>()
    val unionFind = UnionFind(n)

    repeat(m) {
        val (a, b) = readLine()?.split(" ")?.map { it.toInt() - 1 } ?: return
        friends[a]++
        friends[b]++
        unionFind.unite(a, b)
    }
    repeat(k) {
        val (a, b) = readLine()?.split(" ")?.map { it.toInt() - 1 } ?: return
        blocks[a]?.add(b) ?: run {
            blocks[a] = mutableListOf(b)
        }
        blocks[b]?.add(a) ?: run {
            blocks[b] = mutableListOf(a)
        }
    }
    val output = friends.mapIndexed { i, v ->
        unionFind.size(i) - v - 1 - (blocks[i]?.sumBy {
            if (unionFind.same(i, it)) {
                1
            } else {
                0
            }
        } ?: 0)
    }.joinToString(" ")
    println(output)
}


Measured memory_bytes: 100196
import math
d = list(map(int, input().split()))
N = d[0]
K = d[1]
X = 10**9 + 7
def combinations(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

for i in range(1, K+1):
  count = 0
  if N-K < i-1:
    print(0)
  else:
    count = combinations(K-1, i-1)*combinations(N-K+1, i)
    print(count % X)

Measured memory_bytes: 3316