akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int s = 0;
pair<int,int> from[SIZE], to[SIZE];

int getPos(int x){
  for(int i=s-1;i>=0;i--)
    if(from[i].first <= x && x<=from[i].second)
      x = (x - to[i].first) % (from[i].first - to[i].first) + to[i].first;
  return x;
}

int main(){
  int n, a, b, q;
  int x[SIZE], y[SIZE], h[SIZE];
  char c[SIZE];


  scanf("%d%d%d%d",&n,&a,&b,&q);

  for(int i=0;i<a;i++){
    scanf("%d %c",x+i, c+i);
    x[i]--;
  }
  
  for(int i=0;i<=b;i++){
    if(i < b)
      scanf("%d%d",y+i, h+i);
    else
      y[i] = n+1;
    
    if(i>0){
      if(h[i-1] != 0){
        from[s] = {y[i-1]-1, y[i]-2};
        to[s] = {h[i-1]-1, h[i-1] + y[i]-y[i-1] - 2};
        s++;
      }
    }
  }
  
  unordered_map<int,char> dic;

  for(int i=0;i<a;i++){
    dic[getPos(x[i])] = c[i];
  }

  char ansStr[SIZE] = {};
  
  for(int i=0;i<q;i++){
    int z;
    char ans = '?';
    scanf("%d",&z);
    z = getPos(z-1);

    if(dic.find(z) != dic.end())
      ans = dic[z];
    
    ansStr[i] = ans;
  }

  printf("%s\n",ansStr);
  
  return 0;
}



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

#define FOR(i,n,m) for(int i = (n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define nax 100009

typedef vector<int> vi;

int main(){
	int n, dp[nax];
	cin>>n;
	vi v(n);
	REP(i,n) cin>>v[i];

	memset(dp,100000000,sizeof dp);
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);

	FOR(i,2,n){
		dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]),
				dp[i-2] + abs(v[i]-v[i-2]));
	}

	cout<<dp[n-1];

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[2048];
	int i, c;
	
	while (1){
		fgets(str, 2048, stdin);
		
		if (strncmp(str, "END OF INPUT", 12) == 0){
			break;
		}
		
		i = 0;
		c = 0;
		while (1){
			if (str[i] == ' '){
				printf("%d", c);
				c = 0;
			}
			else if (str[i] == '\0'){
				printf("%d\n", c - 1);
				break;
			}
			else {
				c++;
			}
			i++;
		}
	}
	
	return (0);
}

Measured memory_bytes: 520
import fractions

n=int(input())
a=list(map(int, input().split()))
ans=[0]*n
left=[0]*n
right=[0]*n
max_=0

for i in range(n):
  if i==0:
    left[i]=a[0]
  else:
    left[i]=fractions.gcd(left[i-1],a[i])
for i in range(n-1,-1,-1):
  if i==n-1:
    right[i]=a[n-1]
  else:
    right[i]=fractions.gcd(right[i+1],a[i])
for i in range(n):
  if i==0:
    ans=right[1]
  elif i==n-1:
    ans=left[n-2]
  else:
    ans=fractions.gcd(left[i-1],right[i+1])
  if ans>max_:
    max_=ans
    
print(max_)

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
3^9を全て試す
*/

ll n;

bool is_753(ll x){
	bool ans=true;
	ll cnt[3]={};
	while(x>0){
		ll c=-1;
		if(x%10==3)c=0;
		if(x%10==5)c=1;
		if(x%10==7)c=2;
		if(c==-1){
			ans=false;
			break;
		}
		cnt[c]++;
		x/=10;
	}
	if(cnt[0]<=0 || cnt[1]<=0 || cnt[2]<=0)ans=false;
	return ans;
}

ll f(ll x){
	if(n<x)return 0;
	ll ans=f(x*10+3)+f(x*10+5)+f(x*10+7);
	if(is_753(x))ans++;
	return ans;
}

int main(void){
	cin>>n;
	cout<<f(0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint X;
    cin >> X;
    lint N=100;
    int ans=0;
    while(N<X){
        N=N*1.01;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
from collections import defaultdict

#素数リスト
def prime_list(n=10**6+1):
    res = []
    tmp = [1 for _ in range(n)]
    tmp[0] = 0
    tmp[1] = 0
    i = 2
    while i < len(tmp):
        j = i*2
        while tmp[i] == 1 and j < len(tmp):
            tmp[j] = 0
            j += i
        i += 1

    for i, j in enumerate(tmp):
        if j:
            res.append(i)

    return res
prime_number = prime_list()

def prime_fact(n):
    primes = []
    for i in prime_number:
        tmp = 0
        while n % i == 0:
            tmp += 1
            n //= i
        if tmp != 0:
            primes.append([i, tmp])
        if i * i > n:
            break

    if n != 1:
        primes.append([n, 1])
    return primes

n, m = map(int, input().split())
a = list(map(int, input().split()))

so = defaultdict(int)

two = []
for i in a:
    if i % 2 != 0:
        print(0)
        exit()

    primes = prime_fact(i)
    for k, v in primes:
        if k == 2:
            if len(two) != 0 and two[-1] != v:
                print(0)
                exit()
            two.append(v)
        so[k] = max(so[k], v)

tmp = 1
for i, j in so.items():
    tmp *= i ** j
    if tmp > 2 * m:
        print(0)
        exit()

tmp //= 2
# print(tmp)
ans = m // tmp

if ans % 2 == 0:
    ans //= 2
else:
    ans //=2
    ans += 1

print(ans)



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

fn main() {
    input! {
        l: isize
    };

    let mut v = 1;
    let mut w = 1;
    let mut w_sum = 0;
    let mut res = Vec::new();
    while w_sum + w < l {
        w_sum += w;
        res.push((v, v + 1, 0));
        res.push((v, v + 1, w));
        v += 1;
        w *= 2;
    }
    let mut rest_edges = l - 2.pow(v - 1);
    let mut max_l = l - 1;
    for u in (1..v).rev() {
        let edges = if u == 1 { 1 } else { 2.pow(u - 1) };
        while edges <= rest_edges {
            let w = max_l - if u == 1 { 0 } else { 2.pow(u - 1) - 1 };
            res.push((u, v, w));
            max_l = w - 1;
            rest_edges -= edges;
        }
    }
    println!("{} {}", v, res.len());
    for (u, v, w) in res {
        println!("{} {} {}", u, v, w);
    }
}


Measured memory_bytes: 2200
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int R;
  in(R);
  out(2.0*R*M_PI);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main(){
	int n,m;
	while(cin >> n >> m,n){
		int p[1000],sum = 0;
		for(int i = 0;i < n;i++) cin >> p[i];
		sort(p,p + n,greater<int>());
		for(int i = 0;i < n;i++){
			if(i % m != m - 1) sum += p[i];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N, M, Q;
vector<Int> A, B, C, D;

Int dfs(vector<Int> &num, Int pre){

  if((Int)num.size() == N){
    Int score = 0;
    for(Int i=0;i<Q;i++){
      if(num[B[i] - 1] - num[A[i] - 1] == C[i]) score += D[i];
    }
    return score;
  }

  Int res = 0;
  for(Int i = pre;i<=M;i++){
    num.push_back(i);
    Max(res, dfs(num, i));
    num.pop_back();
  }
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>N>>M>>Q;
  A.resize(Q);
  B.resize(Q);
  C.resize(Q);
  D.resize(Q);
  for(Int i=0;i<Q;i++) cin>>A[i]>>B[i]>>C[i]>>D[i];

  vector<Int> num;
  Int ans = dfs(num, 1);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3664
//二次元累積和
#include<vector>
#include<iostream>
#include<string>
using namespace std;
int J[1001][1001];
int O[1001][1001];
char str[1001][1001];
//Iの数は全体からJ,Oを引いて求める方針
int main()
{
	int M, N, K;//Mは縦の長さ　Nは横の長さ　Kはクエリの数
	cin >> M >> N >> K;
	for (int i = 0; i < M; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> str[i][j];
		}
	}//str[M][N]で惑星の情報を持った
	for (int i = 0; i < M; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (str[i][j] == 'J')
			{
				J[i + 1][j + 1]++;
			}
			if (str[i][j] == 'O')
			{
				O[i + 1][j + 1]++;
			}
		}
	}
	//二次元累積和の横の部分
	for (int i = 0; i <= M; i++)
	{
		int p = 0;
		int q = 0;
		for (int j = 0; j <= N; j++)
		{
			p = p + J[i][j];
			J[i][j] = p;
			q = q + O[i][j];
			O[i][j] = q;
		}
	}
	//二次元累積和の縦の部分
	for (int j = 0; j <= N; j++)
	{
		int p = 0;
		int q = 0;
		for (int i = 0; i <= M; i++)
		{
			p = p + J[i][j];
			J[i][j] = p;
			q = q + O[i][j];
			O[i][j] = q;
		}
	}
	for (int i = 0; i < K; i++)
	{
		int a, b, c, d;//調べる領域を指定する座標
		cin >> a >> b >> c >> d;
		int j = J[c][d] - J[a - 1][d] - J[c][b - 1] + J[a - 1][b - 1];
		int o = O[c][d] - O[a - 1][d] - O[c][b - 1] + O[a - 1][b - 1];
		cout << j <<" "<< o <<" " << (c - a + 1)*(d - b + 1) - j - o << endl;
	}
	return 0;
}


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

void call(int n){
	for(int i=1;i<=n;i++){
		if(i % 3 == 0)
			cout << ' ' << i;
		else {
			int x=i;
			while (x>0){
				if(x % 10 == 3){
					cout << ' ' << i;
					x=0;
				} else
					x /= 10;
			}
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}



int main() {
    ll res = 0;
    string S;
    cin >> S;
    int n = S.length();
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = S[i] - '0';
    }
    for (int s = 0; s < (1 << (n-1)); s++) {
        ll tmp = a[0];
        for (int i = 0; i < n-1; i++) { 
            if (1<<i & s) {
                res += tmp;
                tmp = a[i+1];
            } else {
                tmp = tmp * 10 + a[i+1];
            }
        }
        res += tmp;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int n = 0;
  cin >> A >> B;
  int i;
  for(i=A;i<=B;i++){
  	if(i/10000 == i%10 && (i/1000)%10 == (i/10)%10){
    n++;
    }
  }
  cout << n <<endl;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
int32_t main()
{ 
  IOS

  

  int x;
  cin >> x;
  cout << 1 - x << endl;
    
    
} 



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

#define BIT(X,i) ((X>>i)&1)
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 1e9;

int main(){
  int h, w, K, ans = INF;
  cin >> h >> w >> K;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  rep(bit,1<<(h-1)) {
    vector<int> v;
    rep(i,h-1) if (BIT(bit,i)) v.push_back(i);
    int res = v.size(), n = res+1;
    vector<int> cnt(n,0), tmp(n,0);
    rep(x,w){
      int pos = 0;
      rep(y,h) {
        tmp[pos] += s[y][x] - '0';
        if (pos < n-1 and y == v[pos]) pos++;
      }
      rep(j,n) if (tmp[j] > K) res = INF;
      bool f = 1;
      rep(j,n) if (cnt[j]+tmp[j] > K) f = 0;
      rep(j,n) cnt[j] = cnt[j]*f + tmp[j], tmp[j] = 0;
      res += !f;
    }
    if (res < ans) ans = res;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,c1,c2,c3,c4;
    cin>>n;
    c4=n%10;
    c3=n%100/10;
    c2=n%1000/100;
    c1=n/1000;
    if(((c1==c2)&&(c2==c3)) || ((c2==c3)&&(c3==c4)))
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hh = IntArray(n)
    repeat(n) {
        hh[it] = Integer.parseInt(readLine()!!)
    }
    hh.sort()

    var min = Int.MAX_VALUE

    for (i in 0..n-k) {
        val diff = hh[i+k-1] - hh[i]
        if (diff < min) min = diff
    }

    println(min)
}

Measured memory_bytes: 43548
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
string StringChanger(int);
string StringChanger(int n){
  stringstream ss;
  ss << n;
  return ss.str();
}
int main(){
  int q,maxy;
  string str;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> str;
    int cnt = 0;
    while(str.size()!=1){
      int maxy = 0;
      for(int j=0,l=str.size();j<l;j++){
        string sub1 = str.substr(0,j);
        string sub2 = str.substr(j);
        maxy = max(maxy,atoi(sub1.c_str())*atoi(sub2.c_str()));
      }
      str = StringChanger(maxy);
      cnt++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1240
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
acc = [0]

for Ai in A:
    acc.append(acc[-1]+Ai)

r = 0
xor = 0
ans = 0

for l in range(N):
    while r<N and xor^A[r]==acc[r+1]-acc[l]:
        xor ^= A[r]
        r += 1
    
    ans += r-l
    
    if l==r:
        r += 1
    else:
        xor ^= A[l]

print(ans)

Measured memory_bytes: 81356
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
dic=[0 for i in range(9)]
for i in range(n):
    if lis[i]//400>=8:
        dic[8]+=1
    else:
        if dic[lis[i]//400]==0:
            dic[lis[i]//400]=1
        
#print(dic)
#print(sum(dic[0:8]))
if sum(dic[0:8])==0:
    mn=1
    mx=dic[-1]
else:
    mn=sum(dic[0:8])
    mx=sum(dic[0:8])+dic[-1]
print(mn,mx)

Measured memory_bytes: 3444
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=200005;
int a[MAXN],n,X;
LL S[MAXN];
int main()
{
	n=read();X=read();
	LL ans=0;
	for(int i=1;i<=n;i++)a[i]=read(),ans+=5LL*a[i]+2*X,S[i]=a[i]+S[i-1];
	for(int k=1;k<=n;k++)
	{
		LL sum=1LL*X*(n+k);if(sum>=ans)continue;
		for(int j=n,id=1;j>=1;j-=k,++id)
		{
			int pr=max(0,j-k);
			sum+=(2LL*id+1)*(S[j]-S[pr]);
			if(id==1)sum+=2LL*(S[j]-S[pr]);
			if(sum>=ans)break;
		}chkmin(ans,sum);
	}pr2(ans);
	return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#define LL long long
#define N 100100
#define M 1010
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
LL gcd(LL a,LL b){
	return b == 0 ? a : gcd(b,a % b);
}
LL lcm(LL a,LL b){
	return a / gcd(a,b) * b;
}
int main(){
	int n;
	cin >> n;
	LL ans = 1;
	FOR(i,1,n){
		LL x;
		cin >> x;
		ans = lcm(ans,x);
	}
	cout << ans << endl;
}

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

int main(){
  int a, b, N, s, f;
  int flag = 0;
  cin >> a >> b >> N;
  for (int i=0; i<N; i++){
    cin >> s >> f;
    if (!flag && a < f && b > s)
      flag = 1;
  }
  cout << flag << endl;
  return 0;
}

Measured memory_bytes: 3100
//abc048_a.cpp
//Fri Oct 19 22:43:51 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	cout << "A" << b[0] << "C" <<  endl;
}

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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<pair<int, PA> , vector<pair<int, PA> >, greater<pair<int, PA> > >PQG;

int N, a[200010], L[200010], R[200010];

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    stack<int> Ls;
    for(int i = 0; i < N; i++){
        while(Ls.size() && a[Ls.top()] > a[i]){
            Ls.pop();
        }
        if(Ls.size()){
            L[i] = Ls.top();
        }
        else{
            L[i] = -1;
        }
        Ls.push(i);
    }
    stack<int> Rs;
    for(int i = N - 1; i >= 0; i--){
        while(Rs.size() && a[Rs.top()] > a[i]){
            Rs.pop();
        }
        if(Rs.size()){
            R[i] = Rs.top();
        }
        else{
            R[i] = N;
        }
        Rs.push(i);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += a[i] * (R[i] - i) * (i - L[i]);
    }
    cout << ans << endl;

    return 0;
}
/*



*/


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int INF = 1e9;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll s; cin>>s;
	cout<<0<<' '<<0<<' ';
	cout<<((s+INF-1)/INF)<<' '<<1<<' ';
	cout<<((s+INF-1)/INF)*INF-s<<' '<<INF<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
long long n, nums[201000], sums, sumx, ans;
int main(){
	scanf("%lld", &n);
	for( int i = 1; i <= n; ++i )
		scanf("%lld", &nums[i]);
	long long r = 0;
	for( long long l = 1; l <= n; ++l ){
		while( r+1 <= n && sums+nums[r+1] == (sumx^nums[r+1]) ){
			++r;
			sums += nums[r];
			sumx ^= nums[r];
		}
		ans += r-l+1;
		sums -= nums[l];
		sumx ^= nums[l];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5392
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N,K,Q;
cin >> N >> K >> Q;
vector<ll int > A(Q);
map < ll int,ll int >counter;

rep(i,Q){
	cin >> A[i];
	counter[A[i]-1] += 1;
}

rep(i,N){
	if(K - Q + counter[i] >0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}














	return 0;

}



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

int arr[1000];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 2*n; i++)
        scanf("%d", &arr[i]);
    sort(arr, arr+2*n);

    int ans = 0;
    for (int i = 0; i < 2*n; i+=2)
        ans += arr[i];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=190,p=1000000007,inv3=(p+1)/3;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,m,f[2][N][N][N],g[2][N][N][N];
char a[N][N];
bool check(int ans,int i,int j,int l,int r){
	int t=max(f[ans&1][i][l][r]+1,i);
	if (t>j || f[ans&1][t][l][r]>=j) return true;
	t=max(g[ans&1][l][i][j]+1,l);
	if (t>r || g[ans&1][t][i][j]>=r) return true;
	return false;
}
int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++) scanf(" %s",a[i]+1);
	for (int i=n;i;i--)
	for (int l=1;l<=m;l++)
	for (int r=l;(r<=m)&&(a[i][l]==a[i][r]);r++)
		f[0][i][l][r]=(a[i][l]==a[i+1][l]) ? max(i,f[0][i+1][l][r]) : i;
	for (int i=m;i;i--)
	for (int l=1;l<=n;l++)
	for (int r=l;(r<=n)&&(a[l][i]==a[r][i]);r++)
		g[0][i][l][r]=(a[l][i]==a[l][i+1]) ? max(i,g[0][i+1][l][r]) : i;
	int ans;
	for (ans=0;f[ans&1][1][1][m]<n;ans++){
		for (int i=1;i<=n;i++)
		for (int l=1;l<=m;l++)
		for (int r=l;r<=m;r++){
			int cur=max(f[ans&1][i][l][r],i-1),k;
			for (k=0;(cur+(1<<k)<=n)&&check(ans,i,cur+(1<<k),l,r);k++);
			for (k--;k>=0;k--) if ((cur+(1<<k)<=n)&&check(ans,i,cur+(1<<k),l,r)) cur+=1<<k;
			f[(ans+1)&1][i][l][r]=cur;
		}
		for (int i=1;i<=m;i++)
		for (int l=1;l<=n;l++)
		for (int r=l;r<=n;r++){
			int cur=max(g[ans&1][i][l][r],i-1),k;
			for (k=0;(cur+(1<<k)<=m)&&check(ans,l,r,i,cur+(1<<k));k++);
			for (k--;k>=0;k--) if ((cur+(1<<k)<=m)&&check(ans,l,r,i,cur+(1<<k))) cur+=1<<k;
			g[(ans+1)&1][i][l][r]=cur;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 106752
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Fri Dec 28 15:40:52 2018
//
package main

import "fmt"

// max ...
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)

	for i := A; i < A+K && i <= B; i++ {
		fmt.Println(i)
	}
	for i := max(K+A, B-K+1); i <= B; i++ {
		fmt.Println(i)
	}
}


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


int main(){
  int A, B;
  cin >> A >> B;
  
  if(A == 1 && B == 2){
     cout << 3 << endl;
  }
  else if(A == 2 && B == 1){
    cout << 3 << endl;
  }
  else if(A == 1 && B == 3){
    cout << 2 << endl;
  }
  else if(A == 3 && B == 1){
    cout << 2 << endl;
  }
  else if(A == 2 && B == 3){
    cout << 1 << endl;
  }
  else if(A == 3 && B == 2){
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

A, B, C, K = MII_split()

if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    c = K - A - B
    print(A - c)

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        vector<int> a(3); cin >> a;
        sort(all(a));
        int ans = 0;
        while (sz(set<int>(all(a))) > 1) {
                if (a[0] + 1 <= a[2] && a[1] + 1 <= a[2]) {
                        a[0]++;
                        a[1]++;
                } else if (a[0] + 2 <= a[2]) a[0] += 2;
                else break;
                ans++;
        }

        if ((sz(set<int>(all(a))) > 1)) ans += 2;


        cout << ans << '\n';
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static long solve(int[] A) {
        long absSum = Arrays.stream(A).map(Math::abs).asLongStream().sum();

        if (Arrays.stream(A).filter(x -> x < 0).count() % 2 == 0) {
            return absSum;
        }

        return absSum - Arrays.stream(A).map(Math::abs).min().getAsInt() * 2;
    }
}

Measured memory_bytes: 59684
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++) arr[i] = sc.nextInt();

      long xor = arr[0];
      for(int i = 1; i < n; i++)
        xor = xor ^ arr[i];
      System.out.println(xor == 0 ? "Yes" : "No");
  }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

struct dice{
    ll x, y, z;
};

dice roll(dice d, ll dir){
    ll x = d.x, y = d.y, z = d.z;
    if(dir == 0) d.x = y, d.y = 7 - x;
    if(dir == 1) d.x = z, d.z = 7 - x;
    if(dir == 2) d.x = 7 - y, d.y = x;
    if(dir == 3) d.x = 7 - z, d.z = x;
    return d;
}

typedef pair<int,int> pos;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int main(){
   int h,w; scanf("%d%d",&h,&w);
   string s[110]; rep(i,0,h)cin>>s[i];
   queue<pair<pos,dice>> que; que.push({{0,0},{6,2,3}});
   bool used[110][110]={}; used[0][0]=1;
   while(!que.empty()){
      auto p=que.front(); que.pop();
      pos xy=p.first; dice d=p.second;
      if(s[xy.first][xy.second]!=(d.x+'0'))continue;
      if(xy.first==h-1&&xy.second==w-1){puts("YES"); return 0;}
      rep(i,0,4){
         int nx=xy.first+dx[i],ny=xy.second+dy[i];
         if(nx<0||nx>=h||ny<0||ny>=w||used[nx][ny])continue;
         que.push({{nx,ny},roll(d,i)}); used[nx][ny]=1;
      }
   } puts("NO");
   return 0;
}


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

bool ck(long long x,long long ps)
{
    return (bool)(x & (1<<ps));
}

long long ara[36],tra[200004][34],pw[33];

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=1,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,char>mp,nq,qr; string str,ttr,ntr;


        pw[0]=1;

        for(i=1;i<=31;i++){ pw[i]=pw[i-1]*2;  }

        scanf("%lld",&n);

        for(i=1;i<=n;i++)
        {
            scanf("%lld",&a);

            for(j=0;j<=31;j++)
            {
                if(ck(a,j)==true)
                {
                    tra[i][j]=1;  ara[j]++;
                }

            }


        }

        for(i=1;i<=n;i++)
        {
            ans=0;

            for(j=0;j<=31;j++)
            {
                sc=ara[j];

                if(tra[i][j]==1)
                {
                    sc=ara[j]-1;

                }

                if(sc>0 && sc%2==1){  ans=ans+pw[j];  }

            }

            printf("%lld ",ans);

        }




        return 0;

}





Measured memory_bytes: 56824
# coding: utf-8

num = int(input())
sumnum = []


for i in range(1, num+1):
    if i % 3 == 0:
        ifThree = True
    else:
        ifThree = False
        
    if i % 5 == 0:
        ifFive = True
    else:
        ifFive = False
    
    if (ifThree == False and ifFive == False):
        sumnum.append(i)

print(sum(sumnum))

Measured memory_bytes: 29992
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	if N%2 == 0 {
		fmt.Fprintln(wtr, N)
	} else {
		fmt.Fprintln(wtr, N*2)
	}

	wtr.Flush()
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmax(x, y) (x > (y) ? x : x = (y))
#define chmin(x, y) (x < (y) ? x : x = (y))
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = INT32_MAX / 2;
const int MAX = 1e5 + 10;

int N, A, B;

int main()
{
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(A + B - N, 0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に

int main()
{
    int N, M;
    cin >> N >> M;
    VI s(M), c(M);
    rep(i,M){
        cin >> s.at(i) >> c.at(i);
    }
    rep(i,1000){
        string d=to_string(i);
        if(d.size()!=N) continue;
        bool ok=true;
        rep(j,M){
            if(ctoi(d.at(s.at(j)-1))!=c.at(j)) ok=false;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 27
#endif

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)(v.size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ar array
#define forn(i, n) for(int i = 0; i < n ; ++i)
#define for1(i, n) for(int i = 1; i <=n ; ++i)
#define ford(i, n) for(int i = n-1; i>= 0;--i)
#define UNQ(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mem(X,val) memset(X, val, sizeof((X)))

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>>  vvi ;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi ;

const db PI = acos(-1);
const ll mod = 1e9+7;
template <class T>void smax(T& x,T y){ if(x<y)x=y;}
template <class T>void smin(T& x,T y){ if(x>y)x=y;}
template<typename T1, typename T2> T1 powz(T1 A, T2 B);
/***************************************************main code**************************************************************/
const int MXN=1e6+5;
const ll INF = 9e18+200;
const int inf = 1e9+100;
const int mxn = 2e5+20;


void test_case()
{		
	int h,w; cin >> h >> w;
	char grid[h][w];
	forn(i, h) forn(j, w) cin >> grid[i][j];
//	forn(i, h) forn(j, w) cout<< grid[i][j]<<" \n"[j==w-1];
//	exit(0);
	vector<vi> dp(h+1, vi(w+1,0));
	dp[0][0] = 1;
	forn(i, h+1)
		forn(j, w+1) {
			if(i> 0 && grid[i][j] == '.' && grid[i-1][j]=='.')
				(dp[i][j] += dp[i-1][j]) %= mod;
			if(j> 0 && grid[i][j] == '.' && grid[i][j-1]=='.')
				(dp[i][j] += dp[i][j-1]) %= mod;
		}
	//forn(i, h)
	//	forn(j, w)
	//		cout<<dp[i][j]<<" \n"[j==w-1];
		
	cout << dp[h-1][w-1];
						     
}
/*************----------------------------******************/
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef VIJY_DEFINE
    freopen("input.txt","r",stdin);
#endif
//  freopen("output.txt","w",stdout);
    int Tests = 1;
//  cin >> Tests;
    
    for(int tc = 1; tc <= Tests; ++tc){
        //cout <<"Case #"<<tc<<": ";
        test_case();
        cout<<'\n';
    }
#ifdef VIJY_DEFINE
    cerr << "Time elapsed: "<< 1.0*clock() / CLOCKS_PER_SEC <<"s.\n";
#endif   
}
template<typename T1, typename T2>
T1 powz(T1 X,T2 B)
{
    ll A = X;
    ll res=1;
        A%=mod; 
        assert(B>=0); 
    for( ; B ; B>>=1){
        if(B&1)res=res*A%mod;
        A= A*A%mod;
    }
    return res;
}


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

int main() {
	int n=0;
	string S;
	cin >> S;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'R')n++;
	}
	if (S[1] == 'S' && n > 0)cout << "1"<<endl;
	else cout << n << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int x,y,z;
    while(1){
      cin>>x>>y>>z;
      if(x==0&&y==0&&z==0) return 0;
      int n;
      cin>>n;
      int a[10000];
      for(int i=0;i<n;i++){
        cin>>a[i];
      }
      double b[3];
      b[0]=sqrt(x*x+y*y);
      b[1]=sqrt(z*z+y*y);
      b[2]=sqrt(x*x+z*z);
      sort(b,b+3);
      double min=b[0];
      for(int i=0;i<n;i++){
          if((double)a[i]>(0.5*min)) cout<<"OK"<<endl;
          else cout<<"NA"<<endl;
      }
    }       
}

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

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

  static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int N = in.nextInt();
      int K = in.nextInt();
      int[] res = new int[N];

      Arrays.fill(res, 0);

      for (int i = 0; i < K; i++) {
        int di = in.nextInt();

        for (int j = 0; j < di; j++) {
          int A = in.nextInt();
          res[A - 1] += 1;
        }
      }

      int count = 0;
      for (int r : res) {
        if (r == 0) count += 1;
      }

      out.print(count);
    }

  }
}



Measured memory_bytes: 46424
def main():
    N = int(input())
    A = tuple(map(int, input().split(' ')))

    B = [0] * N
    for i in range(N - 1):
        B[A[i] - 1] += 1

    for i in range(N):
        print(B[i])

if __name__ == '__main__':
    main()


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

int calc(char rsp, int rock, int scissors, int paper){
  if(rsp == 'r')
    return paper;
  if(rsp == 's')
    return rock;
  if(rsp == 'p')
    return scissors;
}

int main(){
  int N, K, R, S, P; cin >> N >> K >> R >> S >> P;
  string T; cin >> T;
  
  int ans = 0;
  for(int i=0; i<K; i++){
    bool flag = false;
    ans += calc(T.at(i),R,S,P);

    for(int j=i+K; j<N; j+=K){
      if(T.at(j) != T.at(j-K)){
        ans += calc(T.at(j),R,S,P);
        flag = false;
      }else{
        if(flag == true){
          ans += calc(T.at(j),R,S,P);
          flag = false;
        }else{
          flag = true;
        }
      }
    }
  
  }
  cout << ans << endl;
}

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

int main() {
    long long h, w;
    cin >> h >> w;

    long long odd = (w / 2) + (w & 1);

    if(h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << ((h / 2) * w) + ((h & 1) * odd) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500005
#define pi pair<char,int>
#define mk make_pair
using namespace std;
vector<pi>G[N];
char s[N],s1[N],pre1[N];
int n,kk,left1,right1,pre[N],nxt[N],dis[N],q[N],head[N],nx[N][27];
inline void link(int x,int y,char z){G[x].push_back(mk(z,y));}
inline void bfs(){
	q[left1=1]=0;right1=1;
	dis[0]=0;memset(dis,0,sizeof(dis));
	while (left1<=right1){
		int u=q[left1++];
		for (int i=0;i<(int)G[u].size();i++){
			int v=G[u][i].second;
			if (dis[v]) continue;
			dis[v]=dis[u]+1;
			q[++right1]=v;
			pre[v]=u;pre1[v]=G[u][i].first;
		}
	}
}
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	for (int i=1;i<=26;i++) nxt[i]=n+1;
	for (int i=n;~i;i--){
		for (int j=1;j<=26;j++) nx[i][j]=nxt[j];
		if(!i)break;nxt[s[i]-'a'+1]=i;
	}
	for (int i=0;i<=n;i++)
		for (int j=1;j<=26;j++) link(i,nx[i][j],'a'+j-1);
	for (int i=0;i<=n;i++) sort(G[i].begin(),G[i].end());
	bfs();
	int cnt=dis[n+1];
	for (int i=n+1;i;i=pre[i]) s1[cnt--]=pre1[i];
	for (int i=1;i<=dis[n+1];i++) printf("%c",s1[i]);
	return 0;
}

Measured memory_bytes: 98304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll l,x[225816],y[225816],z[225816];

int main(void){
	int n,i,p;
	ll ans,tmp;
	cin >> l >> n;
	x[0] = 0ll;
	y[0] = 0ll;
	x[n+1] = l;
	z[n+1] = 0ll;
	for(i=1; i<=n; ++i){
		cin >> x[i];
	}
	for(i=1; i<=n; ++i){
		y[i] = y[i-1] + x[i];
	}
	for(i=n; i>=1; --i){
		z[i] = z[i+1] + (l-x[i]);
	}
	ans = max(l-x[1],x[n]);
	for(i=1; i<=n; ++i){
		p = i+(n-i)/2;
		tmp = y[p]+z[p+1]-y[i-1];
		tmp *= 2;
		if((n-i)%2){
			tmp -= (l-x[p+1]);
		}else{
			tmp -= x[p];
		}
		ans = max(tmp,ans);
		p = i-(i-1)/2;
		tmp = z[p]+y[p-1]-z[i+1];
		tmp *= 2;
		if((i-1)%2){
			tmp -= x[p-1];
		}else{
			tmp -= (l-x[p]);
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, M;
    cin >> N >> M;
    
    vector<vector<int>> vec(M);

    rep(i, M){
        int k;
        cin >> k;
        vec[i].resize(k);
        rep(j, k){
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }

    vector<int> p(M);
    rep(i, M)
        cin >> p[i];

    int ans = 0;
    rep(i, (1 << N)){
        bool ok = true;
        rep(j, M){
            int c = 0;
            for(int id: vec[j])
                if((i >> id) & 1)
                    c++;
            if(c % 2 != p[j])
                ok = false;
        }
        if(ok)
            ans++;
    }

    cout << ans << endl;
	
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int in[3], ans;
    for (int i = 0; i < 3; i++)
    {
        cin >> in[i];
    }
    sort(in, in + 3, greater<int>());
    ans = 10 * in[0] + in[1] + in[2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256