akhauriyash/Code-Regression huggingface dataset:
import sys
from itertools import product, chain
input = sys.stdin.readline


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


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    H, W, K = readnums()
    c = [readstr() for _ in range(H)]
    b = sum([x.count('#') for x in c])

    ans = 0
    for p in product([0, 1], repeat=H):
        ch = [c[i] for i, a in enumerate(p) if a]
        for q in product([0, 1], repeat=W):
            tmp = []
            for i, qq in enumerate(q):
                tmp.append([chw[i] for chw in ch if qq])
            tmp = list(chain.from_iterable(tmp))
            if tmp.count('#') == K:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  bool a = true;

  vector<char> fr, bk;

  rep(_, q) {
    int op;
    cin >> op;
    if (op == 1) {
      a = !a;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (a)
          fr.eb(c);
        else
          bk.eb(c);
      } else {
        if (a)
          bk.eb(c);
        else
          fr.eb(c);
      }
    }
  }

  if (a) {
    reverse(all(fr));
    rep(i, fr.size()) cout << fr[i];
    cout << s;
    rep(i, bk.size()) cout << bk[i];
    cout << endl;
  } else {
    reverse(all(bk));
    reverse(all(s));
    rep(i, bk.size()) cout << bk[i];
    cout << s;
    rep(i, fr.size()) cout << fr[i];
    cout << endl;
  }
}


Measured memory_bytes: 1024
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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


void solve(){
    int k,x;

    cin >> k >> x;

    vector<int>ans;
    int temp = x-1;

    for(int i = 0;i<k;i++){
        temp++;
        if(temp<=1000000)ans.push_back(temp);
        else break;
    }

    temp = x;
    for(int i = k-1;i>0;i--){
        temp--;
        if(temp>=-1000000)ans.push_back(temp);
    }

    sort(ans.begin(),ans.end());
    for(auto i:ans) cout << i << " ";
        cout << endl;
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }

    int size() {
        return n;
    }
};


int main() {

    char a,b;

    cin >> a >> b;

    string ans = "";

    if(a == b){
        int n = a-'0';
        REP(i,n){
            ans += a;
        }
        cout << ans << endl;
    }else if(a > b){
        int n = a-'0';
        REP(i,n){
            ans += b;
        }
        cout << ans << endl;
    }else{
        int n = b-'0';
        REP(i,n){
            ans += a;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define M 8
#define F -1
#define N 1

int r[M],c[M],d1[2 * M -1],d2[2 * M - 1],x[M][M];

void initial(){
  int i;
  for(i = 0;i < M;i++){
    r[i] = F;
    c[i] = F;
  }
  for(i = 0;i < 2 * M - 1;i++){
    d1[i] = F;
    d2[i] = F;   
  }
}


void print(){
  int i,j;
  for(i = 0;i < M;i++){
    for(j = 0;j < M;j++){
      if(x[i][j]){
	if(r[i] != j)return;
      }
    }
  }
 for(i = 0;i < M;i++){
    for(j = 0;j < M;j++){
      if(r[i] == j){
      printf("Q");
      }else printf(".");
    }
    printf("\n");
 }
}

void recurse(int i){
  int j;
  if(i == M){
    print();
    return;
  }

  for(j = 0;j < M;j++){
    if(N == c[j]||N == d1[i + j]||N == d2[i - j + M - 1]) continue;
    r[i] = j;
    c[j] = d1[i + j] = d2[i - j + M - 1] = N;
    recurse(i + 1);
    c[j] = d1[i + j] = d2[i - j + M - 1] = F;
  }
}

int main(){
  int i,j,k,l,m,f = 0,t = 1;

  initial();

  for(i = 0;i < M;i++){
    for(j = 0;j < M;j++){
      x[i][j] = f;
    }
  }

  scanf("%d",&k);
  for(i = 0;i < k;i++){
    scanf("%d%d",&l,&m);
    x[l][m] = t;
  }

  recurse(0);

  return 0;
}
  



Measured memory_bytes: 2108
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

a, b, c = get_ints

if a + b + c >= 22
  puts 'bust'
else
  puts 'win'
end


Measured memory_bytes: 14360
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e3 + 7, MOD = 1e9 + 7;
int add(int a, int b) { if ((a += b) >= MOD) a -= MOD; return a; }
int mul(int a, int b) { return ll(a) * b % MOD; }
int qpow(int a, int b) { int r=1; for (;b;b>>=1) {if (b&1)r=mul(r,a);a=mul(a,a); } return r; }
int inv(int d) { return qpow(d, MOD - 2); }
int dp[N][N], C[N][N], n, a, b, c, d, g[N][N], ig[N][N], ii[N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  rep(i, 0, N) C[i][0] = 1;
  rep(i, 1, N) rep(j, 1, i + 1) C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
  rep(i, 0, N) {
  	g[i][0] = 1;
  	g[i][1] = i ? mul(g[i - 1][1], i) : 1;
  	rep(j, 2, N) g[i][j] = mul(g[i][j - 1], g[i][1]);
  	rep(j, 0, N) ig[i][j] = qpow(g[i][j], MOD - 2);
	}
	rep(i, 0, N) ii[i] = qpow(g[i][1], MOD - 2);
//rep(i, 0, 10) rep(j, 0, i + 1) cout << C[i][j] << " \n"[j == i];
	cin >> n >> a >> b >> c >> d;
	dp[a - 1][0] = 1;
	rep(i, a, b + 1) { 
		rep(j, 0, n + 1) {
			int &dij = dp[i][j];
			dij = dp[i - 1][j];
			rep(k, c, d + 1) {
				if (j - k * i < 0) break;
				dij = add(dij, mul(dp[i - 1][j - k * i], mul(C[j][k * i], mul(g[k * i][1], mul(ig[i][k], ii[k])))));
			}
		}
	}
	cout << dp[b][n];
	return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull usigned long long
#define two(n) 1<<n
#define l(v) (int)v.size()
#define p_b push_back
#define m_p make_pair
const int pi=acos(-1.0);
const int int_max=1e9;
const long long ll_max=1e18;
int main()
{
	int a;
	cin>>a;
	cout<<a*a*a;
	return 0;
}

Measured memory_bytes: 256
static MOD: usize = 1000000007;

fn solve(aa: Vec<String>) -> usize {
    let h = aa.len();
    let w = aa[0].len();

    let mut dp = vec![0; w];
    dp[w - 1] = 1;

    for y in (0..h).rev() {
        let cs = aa[y].chars().collect::<Vec<_>>();

        if cs[w - 1] == '#' {
            dp[w - 1] = 0;
        }

        for x in (0..w - 1).rev() {
            if cs[x] == '#' {
                dp[x] = 0;
                continue;
            }

            dp[x] += dp[x + 1];
            dp[x] %= MOD;
        }
    }

    dp[0]
}

#[test]

fn solve_test() {
    assert_eq!(solve(vec!["..".to_owned(), "..".to_owned()]), 2);
    assert_eq!(solve(vec![".#".to_owned(), "#.".to_owned()]), 0);
    assert_eq!(
        solve(vec![
            "..#..".to_owned(),
            ".....".to_owned(),
            "#...#".to_owned(),
            ".....".to_owned(),
            "..#..".to_owned()
        ]),
        24
    );
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (h, _w) = parse_line!(usize, usize);

    let aa = (0..h).map(|_| read_line!()).collect::<Vec<_>>();

    println!("{}", solve(aa));
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  vector<pair<int, int>> vec(1000, make_pair(0, 0));
  rep(i, 1000) {
    int n, x;
    int ans = 0;
    cin >> n >> x;  
    if (n == 0 && x == 0) break;
    reps(i, 1, n+1) reps(j, i+1, n+1)reps(k, j+1, n+1) {
      if (i + j + k == x) ans++;
    }
    cout << ans << endl;    
  }
  return 0;
}


Measured memory_bytes: 3100
object Main extends App {
  def checkWord(N: Int, words: List[String]): Unit = {
    if (N <= 0) println("Yes")
    else {
      val word = io.StdIn.readLine()
      if (words.isEmpty) checkWord(N - 1, word :: words)
      else if (words.contains(word)) {
        println("No")
      }
      else if (words.head.apply(words.head.length - 1) != word.head) {
        println("No")
      }
      else {
        checkWord(N - 1, word :: words)
      }
    }
  }

  val N = io.StdIn.readInt()
  val words = List[String]()
  checkWord(N, words)
}


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

int main(){
  int N;cin>>N;
  int count=0;
  count+=min(9,N);
  if(N>=100) count+=min(900,N-99);
  if(N>=10000) count+=min(90000,N-9999);
  cout<<count<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX




 
void solve()
{
    int n,m,k;
    cin >> n >> m >> k;
    string s[n];
    inp(s,n);
    int ans1 = INT_MAX;
    rep(i,0,(1<<(n-1))-1)
    {
        int p = 0;
        vector<pii> q;

        int ans = 0;
        rep(j,0,n-1)
        {
            if((i&(1<<j)) or j == n-1)
                q.pb({p, j}), p = j+1, ans++;
        }

        ans--;


        int c[q.size()] = {0};
        bool f1 = 1;
        for(int i=0; i<m; i++)
        {

            bool f = 1;
            int c1[q.size()] = {0};
            for(int j=0; j<q.size(); j++)
            {
                rep(k,q[j].fr,q[j].sc)
                    if(s[k][i]=='1')
                        c[j]++, c1[j]++;
                if(c[j]>k)
                    f = 0;
                if(c1[j]>k)
                    f1 = 0;

            }


            if(f==0)
            {
                i--;
                rep(i,0,q.size()-1)
                    c[i] = 0;
                ans++;
            }



            if(f1==0)
                break;
        }


        if(f1==0)
        {

            continue;
        }

        ans1  = min(ans, ans1);
    }

    cout << ans1 << endl;

}       


signed main()
{


  
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    int n,m;cin>>n>>m;
    vector<int> v[n+1];
    int tmp1,tmp2;
    rep(i,0,m){
        cin>>tmp1>>tmp2;
        v[tmp1].push_back(tmp2);
        v[tmp2].push_back(tmp1);
    }
    // rep(i,1,n+1){cout<<i<<" :";
    //     for(auto x: v[i])cout<<x<<" ";cout<<endl;
    // }
    queue<int> q;
    vector<bool> visited(n+1,0);
    vector<int>previous(n+1,0);
    q.push(1);
    visited[1]=1;
    previous[1]=0;
    while(!q.empty()){
      for(auto x: v[q.front()]){
        if(visited[x]==0){
            visited[x]=1;
            previous[x]=q.front();
            q.push(x);
        }
      }
      q.pop();
    }
    bool flag=1;
    rep(i,1,n+1){
        if(visited[i]==0){
            flag=0;
            break;
        }
        //cout<<visited[i]<<" "; 
    }
    if(flag){
        cout<<"Yes\n";
        rep(i,2,n+1)cout<<previous[i]<<endl;
    }
    else cout<<"No\n";
return 0;
}

Measured memory_bytes: 10260
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong()

  var ans = Int.MaxValue
  var i = 1L
  while (i * i <= n) {
    if (n % i == 0) {
      ans = ans.min(i.toString.length.max((n / i).toString.length))
    }
    i += 1
  }

  println(ans)
}


Measured memory_bytes: 55280
n,m = map(int, input().split())

a = []
for i in range(m):
    a.append(int(input()))

dp = []
for dpi in range(n):
    dp.append(0)

k = 0
a.append(0)
for j in range(n):
    if j+1 == a[k]:
        k += 1
        continue
    if j == 0:
        dp[j] = 1
    elif j == 1:
        dp[j] = dp[j-1] + 1
    elif j > 1:
        dp[j] = dp[j-1] + dp[j-2]

print(dp[n-1] % 1000000007)

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

int main() {
	string S;
	cin >> S;
	int compass[4] = {};
	for (int i = 0; i < (int)S.size(); i++) {
		if (S.at(i) == 'N') compass[0] = 1;
		if (S.at(i) == 'S') compass[1] = 1;
		if (S.at(i) == 'E') compass[2] = 1;
		if (S.at(i) == 'W') compass[3] = 1;
	}

	int flag = 0;
	if ((compass[0] == compass[1]) && (compass[2] == compass[3])) flag = 1;

	if (flag == 1) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a + b - x >= 0 && a <= x){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

class UnionFind{
public:
    int n;
    vector<int> v;

    UnionFind():n{0}{}
    UnionFind(int n_in):n{n_in}{
        v.assign(n,-1);
    }
    
    int find(int x){
        assert(0<=x && x<n);
        if(v[x]<0) return x;
        v[x]=find(v[x]);
        return v[x];
    }
    
    bool same(int a,int b){
        assert(0<=a && a<n);
        assert(0<=b && b<n);
        if(find(a)==find(b)) return true;
        return false;
    }
    
    int merge(int a,int b){
        assert(0<=a && a<n);
        assert(0<=b && b<n);
        int a_p=find(a),b_p=find(b);
        if(a_p==b_p) return a_p;
        if(a_p>b_p) swap(a_p,b_p);
        v[a_p]+=v[b_p]; v[b_p]=a_p;
        return a_p;
    }
    
    int size(int a){
        assert(0<=a && a<n);
        return -v[find(a)];
    }

    int group_cnt(){
        int res=0;
        for(auto p:v)if(p<0) res++;
        return res;
    }
};


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,q; cin>>n>>q;
    UnionFind uf(n);
    rep(_,q){
        int t,u,v; cin>>t>>u>>v;
        if(t==0){
            uf.merge(u,v);
        }
        else{
            printf("%d\n",(int)uf.same(u,v));
        }
    }
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans = 0;
  rep(i, 1, n + 1) {
    if (i <= k)
      ans += x;
    else
      ans += y;
  }
  cout << ans << endl;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef long long ll;

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

    string last = " ";
    int ans = 0;

    REP(i, n)
    {
        if (last.at(0) != s.at(i))
        {
            last = s[i];
            ans++;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 512
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 main() {
    input!(
        a: u32,
        b: u32,
    );
    let ans = if (a * b) % 2 == 0 {
        "Even"
    } else {
        "Odd"
    };
    println!("{}", ans);
}

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

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int C[512];
int S[512];
int F[512];


int main(){
    
    
    cin>>N;
    REP( i, N-1 ) cin>>C[i]>>S[i]>>F[i];
    
    REP( i, N ){
        int t = 0;
        FOR( j, i, N-1 ){
            if( t < S[j] ) t = S[j]+C[j];
            else{
                if( t % F[j] == 0 ) t += C[j];
                else{
                    t += C[j]+(F[j]-(t%F[j]));
                }
            }
        }
        cout<<t<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n, cnt = 0, i, j;
  scanf("%d", &n);
  int *dat;
  dat = (int *)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++)
    scanf("%d", &dat[i]);
  for(i = 0; i < n - 1; i++)
    for(j = n - 1; j > i; j--)
      if(dat[j - 1] > dat[j]){
	int tmp = dat[j - 1];
	dat[j - 1] = dat[j];
	dat[j] = tmp;
	cnt++;
      }
  printf("%d", dat[0]);
  for(i = 1; i < n; i++)
    printf(" %d", dat[i]);
  printf("\n%d\n", cnt);
  return 0;
}

Measured memory_bytes: 600
from collections import Counter

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

N, P = map(int, input().split())

prm = prime_factorize(P)
prm = Counter(prm)

rlt = 1
for k in prm:
  rlt *= k**(prm[k]//N)
    
print(rlt)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

// Gauss Jordan
using D = long double;
const D EPS = 1e-5;
template<class T> struct Matrix {
    vector<vector<T> > val;
    Matrix(int n, int m, T x = 0) : val(n, vector<T>(m, x)) {}
    void init(int n, int m, T x = 0) {val.assign(n, vector<T>(m, x));}
    size_t size() const {return val.size();}
    inline vector<T>& operator [] (int i) {return val[i];}
};

template<class T> int GaussJordan(Matrix<T> &A, bool is_extended = false) {
    int m = A.size(), n = A[0].size();
    int rank = 0;
    for (int col = 0; col < n; ++col) {
        if (is_extended && col == n-1) break;
        int pivot = -1;
        T ma = EPS;
        for (int row = rank; row < m; ++row) {
            if (abs(A[row][col]) > ma) {
                ma = abs(A[row][col]);
                pivot = row;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        auto fac = A[rank][col];
        for (int col2 = 0; col2 < n; ++col2) A[rank][col2] /= fac;
        for (int row = 0; row < m; ++row) {
            if (row != rank && abs(A[row][col]) > EPS) {
                auto fac = A[row][col];
                for (int col2 = 0; col2 < n; ++col2) {
                    A[row][col2] -= A[rank][col2] * fac;
                }
            }
        }
        ++rank;
    }
    return rank;
}

template<class T> vector<T> linear_equation(Matrix<T> A, vector<T> b) {
    int m = A.size(), n = A[0].size();
    Matrix<T> M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);
    vector<T> res;
    for (int row = rank; row < m; ++row) if (abs(M[row][n]) > EPS) return res;
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return res;
}




D pow(D a, int n) {
    D res = 1.0;
    for (int i = 0; i < n; ++i) res *= a;
    return res;
}

D func(const vector<D> &coef, int i) {
    D res = 0.0;
    for (int p = 0; p < coef.size(); ++p) res += coef[p] * pow(i, p);
    return res;
}

int main() {
    int d;
    while (cin >> d, d) {
        vector<D> v(d+3);
        for (int i = 0; i < d+3; ++i) cin >> v[i];

        int res = 0;
        for (int i = 0; i < d+3; ++i) {
            for (int j = i+1; j < d+3; ++j) {
                Matrix<D> A(d+1, d+1);
                vector<D> b(d+1);
                for (int k = 0, iter = 0; k < d+3; ++k) {
                    if (k == i || k == j) continue;
                    for (int p = 0; p < d+1; ++p) {
                        A[iter][p] = pow(k, p);
                        b[iter] = v[k];
                    }
                    ++iter;
                }
                vector<D> ans = linear_equation(A, b);
                if (ans.empty()) continue;
                D vi = func(ans, i), vj = func(ans, j);
                int num = 0;
                if (fabs(vi - v[i]) > EPS) res = i, ++num;
                if (fabs(vj - v[j]) > EPS) res = j, ++num;
                if (num == 1) goto end;
            }
        }
    end:
        cout << res << endl;
    }
}



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

int main()
{
    int Q, H, S, D;
    cin >> Q >> H >> S >> D;

    const int cost1 = min({4*Q, 2*H, S});
    const int cost2 = min({8*Q, 4*H, 2*S, D});

    long long N;
    cin >> N;

    cout << (N/2) * cost2 + (N%2) * cost1 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,j,k,a[n+1]={0},dp[n+1][n+1];
    memset(dp, 0LL, sizeof(dp));
    
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=2;i<=n;i++) a[i]+=a[i-1];
    
    for(i=n-1;i>=0;i--)
    {
        for(j=i+2;j<=n;j++)
        {
            dp[i][j]=1e18;
            for(k=i+1;k<j;k++)
            dp[i][j]=min(dp[i][j], dp[i][k]+dp[k][j]+a[j]-a[i]);
        }
    }
    
    cout<<dp[0][n];
    return 0;
}

Measured memory_bytes: 1536
int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&a[i]);
for(int i=2;i<=n;i++)ans[a[i]]++;
for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 3284
N = int(input())
S = input()
ok, ng = 0, N + 1
while abs(ok - ng) > 1:
    x = (ok + ng) // 2
    check = set()
    for i in range(N - x + 1):
        check.add(S[i: i + x])
        if S[i + x: i + 2 * x] in check:
            ok = x
            break
    else:
        ng = x

print(ok)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll V[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> V[i];
    }
    REP(i, N)
    {
        ll c;
        cin >> c;
        V[i] -= c;
    }
    sort(V, V + N, [](ll a, ll b) { return a > b; });
    ll sum = 0;
    REP(i, N)
    {
        if (V[i] < 0)
            break;
        sum += V[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String S = sc.next();
        sc.close();
        final int A = Integer.parseInt(S.substring(0, 1));
        final int B = Integer.parseInt(S.substring(1, 2));
        final int C = Integer.parseInt(S.substring(2, 3));
        final int D = Integer.parseInt(S.substring(3, 4));

        for (int i=8; i<Math.pow(2.0, 3.0)+8; i++) {
            int sum = A;
            StringBuilder sb = new StringBuilder("" + A);
            if ("1".equals(Integer.toBinaryString(i).substring(3, 4))) {
                sum += B;
                sb.append("+" + B);
            } else {
                sum -= B;
                sb.append("-" + B);
            }
            if ("1".equals(Integer.toBinaryString(i).substring(2, 3))) {
                sum += C;
                sb.append("+" + C);
            } else {
                sum -= C;
                sb.append("-" + C);
            }
            if ("1".equals(Integer.toBinaryString(i).substring(1, 2))) {
                sum += D;
                sb.append("+" + D);
            } else {
                sum -= D;
                sb.append("-" + D);
            }
            if (sum==7) {
                sb.append("=7");
                System.out.println(sb);
                return;
            }
        }
    }
}

Measured memory_bytes: 23124
//
//  main.cpp
//  qtSubstitute
//
//  Created by Happy on 17/09/18.
//  Copyright © 2018 Mayank Yadav. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;
int main(){
    int N;
    cin>>N;
    int data[N];
    for(int i=0;i<N;i++){
        cin>>data[i];
    }
    bool b=true;
    for(int i=N-1;i>0;i--){
        if(data[i]<data[i-1]){
            data[i-1]--;
            
        }
    }
//    cout<<endl;
//    for(int i=0;i<N;i++){
//        cout<<data[i]<<endl;
//    }
    for(int i=0;i<N-1;i++){
        if(data[i]>data[i+1]){
            b=false;
//            cout<<"bkpt at ";
//            cout<<i<<endl;
        }
    }
    
    if(b){
        cout<<"Yes";
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

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")
}

fn main() {
    let n: usize = read();
    let mut s = vec!['\0'; n];
    for i in 0..n {
        s[i] = read::<String>().chars().collect::<Vec<char>>()[0];
    }
    println!("{}", if s.contains(&'Y') { "Four" } else { "Three" })
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
std::vector<int> S;
std::vector<int> G[100010];
int N, M;
LL ans;
LL a[100010];
bool went[100010];
void dfs(int s, std::vector<int> &v) {
	v.push_back(a[s]);
	went[s] = true;
	for (auto u : G[s]) {
		if (!went[u])dfs(u, v);
	}
}
int main() {
	std::cin >> N >> M;
	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	for (int i = 0; i < M; i++) {
		int x, y;
		std::cin >> x >> y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}
	if (N - 1 == M) {
		std::cout << 0 << std::endl;
		return 0;
	}
	int need = (N - M - 1) * 2;
	if (N < need) {
		std::cout << "Impossible" << std::endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (!went[i]) {
			need--;
			std::vector<int> v;
			dfs(i, v);
			std::sort(v.begin(), v.end());
			ans += v[0];
			for (int i = 1; i < v.size(); i++)S.emplace_back(v[i]);
		}
	}
	std::sort(S.begin(), S.end());
	for (int i = 0; i < need; i++)ans += S[i];
	std::cout << ans << std::endl;
	return 0;
}

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

int main() {
	// your code goes here
	int a,b,c;
	cin >> a >> b >> c;
	if((a == b && a!=c)||(b == c && b!=a)||(a == c && a!=b))
	cout << "Yes\n";
	else
	{
	    cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int,input().split())
S = input()

count_list = [0]*(N+1)

for i in range(N):
    if S[i:i+2] == 'AC':
        count_list[i+1] = count_list[i] + 1
    else:
        count_list[i+1] = count_list[i]

for i in range(Q):
    l, r = map(int,input().split())
    print(count_list[r-1] - count_list[l-1])

Measured memory_bytes: 6188
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;

	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c && c == a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			if (a % 2 == 1 && b % 2 == 1) {
				System.out.println("Odd");
			} else {
				System.out.println("Even");
			}
		}
	}
}

Measured memory_bytes: 35588
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
 
     int n;
     cin>>n;
     int a[n+1],i;
     for(i=1;i<=n;++i)
        cin>>a[i];
        
     int cnt=0;
     for(i=1;i<=n;i+=2)
      {
          if(a[i]%2==1)
            cnt++;
      }
      
      cout<<cnt;
    
   
     return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  queue<char> a, b, c;
  for( int i = 0; i < A.size(); i++ ) a.push(A.at(i));
  for( int i = 0; i < B.size(); i++ ) b.push(B.at(i));
  for( int i = 0; i < C.size(); i++ ) c.push(C.at(i));
  
  char now = 'a';
  while( true ){
    if( now == 'a' ){
      if( a.empty() ){
        cout << "A" << endl;
        return 0;
      }
      now = a.front();
      a.pop();
    }else if( now == 'b' ){
      if( b.empty() ){
        cout << "B" << endl;
        return 0;
      }
      now = b.front();
      b.pop();
    }else if( now == 'c' ){
      if( c.empty() ){
        cout << "C" << endl;
        return 0;
      }
      now = c.front();
      c.pop();
    }
  }
            
}


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

int main(){
    char X,Y;
    cin >> X >> Y ;
    if(X > Y)cout << '>' << endl;
    else if(X < Y)cout << '<' << endl;
    else cout << '=' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n;
    scanf("%d", &n);
    lint s[n];
    rep(i, n) scanf("%lld", &s[i]);
    lint ans = 0;
    For(i, 1, n/2){
        lint tmp = 0;
        lint ttmp = 0;
        if((n-1)%i == 0){
            for(int j=0; j<n-1-j; j+=i){
                ttmp += s[j] + s[n-1-j];
                tmp = max(tmp, ttmp);
            }
        }
        else{
            for(int j=0; i<n-1-j; j+=i){
                ttmp += s[j] + s[n-1-j];
                tmp = max(tmp, ttmp);
            }
        }
        ans = max(ans, tmp);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
import Data.List (sort)

main = do
  [a,b,c] <- fmap (sort . map read . words) getLine
  print (solve a b c)


solve :: Int -> Int -> Int -> Int
solve a b c =
  (c-a)`div`2 + (c-b)`div`2 + extra
  where
    extra
      | odd (c-a) && odd (c-b) = 1
      | odd (c-a)              = 2
      | odd (c-b)              = 2
      | otherwise              = 0

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    int i, l;

    int count = 1;
    int curr = 0;
    int prev = 0;
    for(i = 0; i < n; i ++)
    {
    	cin >> l;
    	curr = prev + l;
    	if(curr <= x)
    	{
    		count ++;
    	}
    	prev = curr;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int h, w;
string s[12], t[12];
bool used[12];
map<string, int> mp;

bool is_anagram(string a, string b){
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    return a == b;
}

bool is_palindrome(string &a){
    rep(i, a.size()/2){
        if(a[i] != a[a.size()-1-i]) return false;
    }
    return true;
}

bool dfs(int cur){
    if(cur == h / 2){
        string u[w];
        rep(i, w)rep(j, h) u[i] += t[j][i];
        memset(used, false, sizeof(used));
        bool center = false;
        rep(i, w)if(!used[i]){
            string tmp = u[i];
            reverse(tmp.begin(), tmp.end());
            int id = -1;
            For(j, i+1, w)if(!used[j] && u[j] == tmp){
                id = j;
                break;
            }
            if(id < 0){
                if(w % 2 == 0 || center) return false;
                else{
                    center = true;
                    used[i] = true;
                }
            }
            else{
                used[i] = used[id] = true;
            }
        }
        return true;
    }
    else if(cur < 0){
        for(auto &p: mp){
            t[h/2] = p.fi;
            --p.se;
            if(dfs(0)) return true;
            ++p.se;
        }
    }
    else{
        for(auto &p: mp)if(p.se > 0){
            bool flag = false;
            for(auto &q: mp)if(q.se > 0 && is_anagram(p.fi, q.fi)){
                if(p.fi != q.fi || p.se >= 2){
                    --p.se; --q.se;
                    t[cur] = p.fi; t[h-1-cur] = q.fi;
                    if(dfs(cur + 1)) return true;
                    ++p.se; ++q.se;
                    flag = true;
                }
            }
            if(!flag) return false;
        }
    }
    return false;
}

int main(){
    scanf("%d%d", &h, &w);
    rep(i, h){
        cin >> s[i];
        ++mp[s[i]];
    }
    puts(dfs(h % 2 == 1 ? -1 : 0) ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,k,cnt=0;
	vector<int>v(10001);
	cin>>a>>b>>k;
	for(int i=1;i<10001;i++){
		if(a%i==0 && b%i==0){
			v.at(i)=i;
			cnt++;
		}
	}
	sort(v.begin(),v.end(),greater<int>());
	cout<<v.at(k-1)<<endl;
	return 0;
}



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

int main(){

int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
int s=a+b+c+d+e;
cout << 15-s << endl;


}

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

int main() {
  vector<int> x(5);
  cin >> x.at(0) >> x.at(1) >> x.at(2) >> x.at(3) >> x.at(4);

  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <vector>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  ll N;
  cin >> N;
  ll A[100010];
  ll B[100010];
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];
  ll sum=0;
  ll m;
  
  for(int i=N-1; i>=0; i--){
    m=0;
    while(A[i+1]>0 && B[i]>0){
      m=min(A[i+1], B[i]);
      A[i+1]-=m;
      B[i]-=m;
      sum+=m;
    }
    if(B[i]>0){
      m=0;
      while(A[i]>0 && B[i]>0){
        m=min(A[i], B[i]);
        A[i]-=m;
      	B[i]-=m;
      	sum+=m;
      } 
    }
  }
  
  cout << sum << endl;
}

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

template<class T>
struct culsum_2D {
  int h,w;
  vector<vector<T>> sum;
  culsum_2D(vector<vector<T>>const& a){
    h = a.size();
    w = a[0].size();
    sum.resize(h+1,vector<T>(w+1));
    for(int i=0;i<h;++i)
      for(int j=0;j<w;++j)
        sum[i+1][j+1] = a[i][j];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
        sum[i+1][j+1] += sum[i+1][j]+sum[i][j+1]-sum[i][j];
  }
  T get(int sy,int sx,int ty,int tx){
    assert(0<=sy&&0<=sx);
    assert(ty<=h&&tx<=w);
    return sum[ty][tx]-sum[ty][sx]-sum[sy][tx]+sum[sy][sx];
  }
};

//https://atcoder.jp/contests/abc159/tasks/abc159_e

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

signed main(){

  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  for(auto& si:s)cin>>si;

  vector<vector<int>> a(h,vector<int>(w));
  rep(i,h)rep(j,w){
    a[i][j] = (s[i][j]=='1');
  }
  culsum_2D<int> sum(a);

  int ans = 1<<28;
  for(int b=0;b<(1<<(h-1));++b){
    bitset<11> bit(b);
    vector<int> s;
    s.emplace_back(0);
    rep(i,h)if(bit[i])s.emplace_back(i+1);
    s.emplace_back(h);
    int res = bit.count();
    int px = 0;
    int n = s.size();
    for(int x=1;x<=w;++x){
      int tmp = 0;
      rep(i,n-1){
        tmp = max(tmp,sum.get(s[i],px,s[i+1],x));
      }
      if(tmp<=k)continue;
      if(abs(x-px)==1){
        res = 1<<28;
        break;
      }
      res++;
      px = x-1;
    }
    ans = min(ans,res);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
	static char s[4];
	int cnt;

	scanf("%s", s);
	cnt = 0;
	if (s[0] == 'o')
		cnt += 100;
	if (s[1] == 'o')
		cnt += 100;
	if (s[2] == 'o')
		cnt += 100;
	printf("%d\n", cnt + 700);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    long sum = 0;
    for (int i = 0; i <= n; i++) {
      if (i % 3 == 0 && i % 5 == 0) {
        continue;
      } else if (i % 3 == 0 ) {
        continue;
      } else if (i % 5 == 0) {
        continue;
      } else {
        sum += i;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 35856
n,*a=map(int,open(0).read().split())
for i in range(n-1):
    a[i+1]+=a[i]
j,k=0,2
m=1e18
for i in range(1,n-1):
    while abs(a[j]*2-a[i])>abs(a[j+1]*2-a[i]):
        j+=1
    while abs(a[k]*2-a[i]-a[n-1])>abs(a[k+1]*2-a[i]-a[n-1]):
        k+=1
    t=a[j],a[i]-a[j],a[k]-a[i],a[n-1]-a[k]
    m=min(m,max(t)-min(t))
print(m)

Measured memory_bytes: 24992
/*An anomaly, I'm Muhammad Ali
  'Cause I know one day I'm gonna be the*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define f first
#define s second
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int main()
{
	ll n; cin>>n;
	ll sum = 0;
	for(ll i  = 1 ; i <=n; i++)
		if(i%3&&i%5)
			sum+=i;
	cout<<sum<<endl;
  	return 0;
}

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

const ll LLINF = (1LL << 60);

struct Edge
{
	ll to, cost;
	Edge () {}
	Edge ( int to, int cost ) : to(to), cost(cost) {}
};

template < typename T >
struct Monoid
{
	T id;
	function < T(T, T) > op;
	Monoid ( T id, function < T(T, T) > op) : id(id), op(op) {}
};

template < typename T >
struct SegmentTree
{

	const Monoid < T > monoid;
	vector < T > dat;
	int size;

	SegmentTree(int n, Monoid < T > monoid) : monoid(monoid)
	{
		size = 1;
		while ( size < n ) {
			size *= 2;
		}
		dat.assign(size * 2 + 10, monoid.id);
	}

	void update(int k, T x)
	{
		k += size - 1;
		dat[k] = x;
		while ( k > 0 ) {
			k = (k - 1) / 2;
			dat[k] = monoid.op(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	
	void add(int k, T x)
	{
		update(k, monoid.op(x, dat[k + size - 1]));
	}

	T query(int a, int b)
	{
		return (query(a, b, 0, 0, size - 1));
	}

	T query(int a, int b, int k, int l, int r)
	{
		T vl, vr;
		if ( r < a || b < l ) return ( monoid.id );
		if ( a <= l && r <= b ) return ( dat[k] );
		vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		vr = query(a, b, k * 2 + 2, (l + r) / 2 + 1, r);
		return ( monoid.op(vl, vr) );
	}
};

int main()
{
	int N, M;
	vector < Edge > G[100005];

	cin >> N >> M;
	
	SegmentTree < ll > seg(N, Monoid < ll > (LLINF, [](ll a, ll b) { return (min(a, b)); } ));
	
	while ( M-- ) {
		ll L, R, C;
		cin >> L >> R >> C; --L, --R;
		G[L].emplace_back(R, C);
	}
	
	seg.update(0, 0);
	
	for ( int i = 0; i < N; i++ ) {
		for ( Edge &e : G[i] ) {
			ll cost = seg.query(i, N - 1);
			if ( cost != LLINF ) {
				cost += e.cost;
				seg.add(e.to, cost);
			}
		}
	}

	ll ans = seg.query(N - 1, N - 1);

	if ( ans == LLINF ) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
	
	return ( 0 );
}


Measured memory_bytes: 7680