akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, r;
    cin >> n >> r;
    int ans = r;
    if(n < 10) ans = 100 * (10 - n) + r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
int main(void){
    int N,K,R,S,P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    int ans = 0;
    int times = N/K;
    for(int i = 0; i<N; i++){
        if(T[i]=='r'){
            ans+=P;
            
        }else if(T[i]=='s'){
            ans+=R;
            
        }else if(T[i]=='p'){
            ans+=S;
            
        }
        if(i+K<=N){
            if(T[i]==T[i+K]){
                T[i+K] = 'u';
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=1e5+100;
int n,k,a[N];
signed main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int ans=(n-k)/(k-1)+2;
	if ((n-k)%(k-1)==0) ans--;
	printf("%d\n",ans);
}

Measured memory_bytes: 4176
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1e5+5;
int n,du[N],q[N],hd,tl,del[N],dp[N],sum,ans;
char str[N];vector<int>E[N];
void dfs(int u,int f){
	if((du[u]&1)^(str[u]=='W'))++sum,dp[u]=2;
	for(int v:E[u])
		if(v!=f&&!del[v]){
			sum+=2;dfs(v,u);
			ans=max(ans,dp[u]+dp[v]);
			dp[u]=max(dp[u],dp[v]+((du[u]&1)^(str[u]=='W')?2:0));
		}
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<n;++i){
		scanf("%d%d",&x,&y);
		E[x].push_back(y);E[y].push_back(x);
		++du[x];++du[y];
	}
	scanf("%s",str+1);
	for(int i=1;i<=n;++i)
		if(du[i]<=1&&str[i]=='B')
			del[q[++tl]=i]=1;
	while(hd<=tl){
		int u=q[++hd];
		for(int v:E[u]){
			--du[v];
			if(!del[v]&&du[v]<=1&&str[v]=='B')
				del[q[++tl]=v]=1;
		}
	}
	int rt=1;while(del[rt])++rt;
	if(rt>n)return puts("0"),0;
	dfs(rt,0);
	printf("%d\n",sum-ans);
	return 0;
}


Measured memory_bytes: 13568
a,b,k=gets.chomp.split(" ").map { |e| e.to_i }

for i in 1..k do
  if i % 2 == 1
    if a % 2 == 1
      a -= 1
    end
    b += a/2
    a = a/2
  else
    if b % 2 == 1
      b -= 1
    end
    a += b/2
    b = b/2
  end
end

printf("%d %d\n",a,b)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
  vector<long long>vc;
 // vector<long long>dc;
  vector<long long>rr;
  map<long long ,long>st;
  long long a,b,c,d,i,j;
  cin>>a>>b;
  for(i=0;i<b;i++)
  {
      cin>>c>>d;
    //  vc.push_back(c);
     // dc.push_back(d);
      if(c==1)
      rr.push_back(d);

     if(d==a)
     st[c]++;

  }

   //for(i=0;i<rr.size();i++)
  //  cout<<rr[i]<<"*"<<endl;

   for(i=0;i<rr.size();i++)
  {
    if(st[rr[i]]!=0)
    {

        cout<<"POSSIBLE";
        return 0;

    }


  }

  cout<<"IMPOSSIBLE";



}


Measured memory_bytes: 13556
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;

  if(N==3) {
    cout << 2 << " " << 3 << " " << 25 << endl;
    return 0;
  }

  int S = 0;
  for(auto i=2; N && i<=30000; ++i) if((i%2)==0 || (i%3)==0) {
    if(N==2) {
      N=0;
      switch(S%6) {
        case 0:
          while((i%6)!=0 && (i%6)!=2 && (i%6)!=4) ++i;
          if((i%6)==0)      cout << i << " " << i+6;
          else if((i%6)==2) cout << i << " " << i+2;
          else              cout << i << " " << i+4;
          break;
        case 1:
          while((i%6)!=2 && (i%6)!=3) ++i;
          if((i%6)==2) cout << i << " " << i+1;
          else         cout << i << " " << i+5;
          break;
        case 2:
          while((i%6)!=0 && (i%6)!=4) ++i;
          if((i%6)==0) cout << i << " " << i+4;
          else         cout << i << " " << i+2;
          break;
        case 3:
          while((i%6)!=0 && (i%6)!=3) ++i;
          if((i%6)==0) cout << i << " " << i+3;
          else         cout << i << " " << i+3;
          break;
        case 4:
          while((i%6)!=0 && (i%6)!=2) ++i;
          if((i%6)==0) cout << i << " " << i+2;
          else         cout << i << " " << i+4;
          break;
        case 5:
          while((i%6)!=3 && (i%6)!=4) ++i;
          if((i%6)==3) cout << i << " " << i+1;
          else         cout << i << " " << i+5;
          break;
      }
    } else {
      --N;
      cout << i << " ";
      S += i;
    }
  }
  assert(N==0);

  cout<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n;
ll dp[110][4][4][4];//dp[i][j][k]:=i文字で最後がj,kのときの場合の数(0:A,1:T,2:C,3:G)
ll ck(int i,int j,int k,int l){
    bool flg = true;
    if(j==0 && k == 3 && l==2){
        flg = false;
    }else if(j==0 && k == 2 && l==3){
        flg = false;
    }else if(j==3 && k == 0 && l==2){
        flg = false;
    }else if(i==0&&k==3&&l==2){
        flg = false;
    }else if(i==0 && j==3 && l==2){
        flg =false;
    }
    return flg;
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,110)rep(j,4)rep(k,4)rep(l,4)dp[i][k][j][l]=0;
    ll ans = 0;
    rep(i,4)rep(j,4)rep(k,4){
        if(i==0 && j == 3 && k==2){
        }else if(i==0 && j == 2 && k==3){
        }else if(i==3 && j == 0 && k==2){
        }else{
            dp[3][i][j][k]=1;
        }
    }
    for(ll i=3;i<=n;i++){
        rep(j,4)rep(k,4)rep(l,4)rep(ll,4){
            if(ck(j,k,l,ll)){
                dp[i+1][k][l][ll] += dp[i][j][k][l];
                dp[i+1][k][l][ll] %= Mod;
            }
        }
    }
    rep(i,4)rep(j,4)rep(k,4){
        ans += dp[n][i][j][k];
        ans %= Mod;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define lint long long
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
#define P pair<int, int>
#define D pair<double, double>
#define DI pair<double, int>
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

lint n, a[100010], cnt;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (a[i] >= a[i + 1]) ++cnt;
	}
	cout << cnt << endl << n << endl;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define x first
#define y second
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const long long INF = 1e18;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
int n;
pi a[200005];

int dist(int x,int y) {return abs(a[x].x-a[y].x)+abs(a[x].y-a[y].y);}

int Find(int x) {
    int mx = x;
    for(int i = 1;i <= n;i++) {
        if(dist(i,x) >= dist(x,mx)) mx = i;
    }
    return dist(x,mx);
}

bool cmpx(pi x,pi y) {
    return x.x+x.y > y.x+y.y;
}

bool cmpx2(pi x,pi y) {
    return -x.x-x.y > -y.x-y.y;
}

bool cmpy(pi x,pi y) {
    return x.x-x.y > y.x-y.y;
}

bool cmpy2(pi x,pi y) {
    return -x.x+x.y > -y.x+y.y;
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++) cin >> a[i].x >> a[i].y;
    sort(a+1,a+n+1,cmpx);
    int ans = Find(1);
    sort(a+1,a+n+1,cmpx2);
    ans = max(ans,Find(1));
    sort(a+1,a+n+1,cmpx);
    ans = max(ans,Find(1));
    sort(a+1,a+n+1,cmpy2);
    ans = max(ans,Find(1));
    cout << ans;
}


Measured memory_bytes: 5196
N = int(input())
A = list(map(int, input().split()))
X = [0]
for i in range(N - 1):
    X.append(A[i + 1] - X[i])

a = (A[0] - X[-1]) // 2

hoge = [(X[i] + (-1) ** i * a) * 2 for i in range(N)]
hoge = hoge[-1:] + hoge[:-1]

for i in range(N):
    print(hoge[i], end=" ")


Measured memory_bytes: 17420
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), l = sc.nextInt();
        String[] s = new String[n];

        for (int i = 0; i < n; i++)s[i]=sc.next();

        Arrays.sort(s);
        String ans=s[0];
        for(int i=1;i<n;i++)ans += s[i];
        System.out.println(ans);
    }
}


Measured memory_bytes: 26836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int n;
vector<int> y;
int dfs(int i,int j,int k){
    if(y[j]==1){
        int res=k+i;
        return res;
    }
    int buf=i/y[j];
    int res=1e+7;
    int tmp=(y[j]%9==0)? 9:6;
    rep(l,min(buf+1,tmp)){
        int buf2=l*y[j];
        int r=dfs(i-buf2,j+1,k+l);
        chmin(res,r);
    }
    return res;
}
int main(void){
    int n;cin>>n;
    priority_queue<int> que;
    int tmp=9;
    while(tmp<=n){
        que.push(tmp);
        tmp*=9;
    }
    tmp=6;
    while(tmp<=n){
        que.push(tmp);
        tmp*=6;
    }
    while(que.size()){
        int x=que.top();que.pop();
        y.push_back(x);
    }
    y.push_back(1);
    int res=dfs(n,0,0);
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  unsigned n, m;
  std::cin >> n >> m;
  unsigned long long num = 0;
  unsigned long long cost = 0;
  unsigned long long ans = 0;
  std::vector<std::pair<unsigned, unsigned>> a(n);
  std::vector<std::pair<unsigned, unsigned>> x(n);
  std::vector<std::pair<unsigned, unsigned>> y(n);
  std::cin >> a[0].second;
  for (unsigned i = 1; i < n; ++i) {
    std::cin >> a[i].second;
    a[i].first = a[i - 1].second;
    x[i].first = a[i].first;
    x[i].second = i;
    y[i].first = a[i].second;
    y[i].second = i;
    if (a[i].first > a[i].second) {
      cost += m - a[i].first;
      ++num;
      ans += m - a[i].first + a[i].second;
    } else {
      ans += a[i].second - a[i].first;
    }
  }
  std::sort(x.begin() + 1, x.end(),
            [](std::pair<unsigned, unsigned> i, std::pair<unsigned, unsigned> j) -> bool {
              return i.first < j.first;
            });
  std::sort(y.begin() + 1, y.end(),
            [](std::pair<unsigned, unsigned> i, std::pair<unsigned, unsigned> j) -> bool {
              return i.first < j.first;
            });
  auto px = x.begin() + 1;
  auto py = y.begin() + 1;
  std::vector<unsigned long long> costv(m + 1);
  for (unsigned i = 1; i <= m; ++i) {
    costv[i] = cost;
    cost += num;
    while (py < y.end() && py->first == i) {
      if (a[py->second].first < a[py->second].second) {
        cost -= a[py->second].second - a[py->second].first;
      } else {
        cost -= m + a[py->second].second - a[py->second].first;
      }
      --num;
      ++py;
    }
    while (px < x.end() && px->first == i) {
      ++num;
      ++px;
    }
  }
  auto hoge = ans;
  for (unsigned i = 1; i < m + 1; ++i) {
    hoge = std::min(hoge, ans - costv[i]);
  }
  std::cout << hoge;
  return 0;
}

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

typedef long long ll;

// 浮動小数点として受け取った数に何か操作をすると基本的に誤差が発生する。

int main() {
  ll a;
  double b;
  cin >> a >> b;
  // 小数 -> 整数に変換する。
  ll t = b * 100 + 0.5;
  ll ans = (a * t) / 100;
  cout << ans << endl;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int k,n;
int main()
{
	cin>>k;
	for(int i=1;i<=k+1;++i)
	{
		n=(10*n+7)%k;
		if(!n)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1; 
	return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

auto func (string s){
    /*
        mappingし直す
     
    */
    map<char,char> mp;
    string ret = "";
    char ch = 'a';
    rep(i,s.size()){
        if(mp.count(s[i])==0){
            ret+=ch;
            mp[s[i]] = ch;
            ch++;
        }else{
            ret+=mp[s[i]];
        }
    }
    return ret;
}

int main(){
    string s,t;
    cin >> s >> t;
    if(func(s) == func(t))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 1552
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << !(a == c) << endl;
  return 0;
}

Measured memory_bytes: 256
my $a=<>;
chomp($a);
if ($a=~/A/||$a=~/B/||$a=~/C/||$a=~/D/||$a=~/E/||$a=~/F/||$a=~/G/||$a=~/H/||$a=~/I/||$a=~/J/||$a=~/K/||$a=~/L/||$a=~/M/||$a=~/N/||$a=~/O/||$a=~/P/||$a=~/Q/||$a=~/R/||$a=~/S/||$a=~/T/||$a=~/U/||$a=~/V/||$a=~/W/||$a=~/X/||$a=~/Y/||$a=~/Z/){print "A";}else{print"a";}

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

int main(){
    string S;
    cin >> S;
    int bucket[26] = {0};
    string alpha = "abcdefghijklmnopqrstuvwxyz";

    for(int i = 0; i < S.length(); ++i){
        bucket[S[i] - 'a'] += 1;
    }

    for(int i = 0; i < 26; ++i){

        if(bucket[i] == 0){
            cout << alpha[i] << endl;
            return 0;
        }
    }

    cout << "None" << endl;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m;
    ll ans =0;
	cin >> n>>m;
    long a[n];
    long b[n];
    vector<pair<long, long>> pairs(n);
    bool end = false;
    for(int i=0;i<n;i++){
     cin >> a[i];
     cin >> b[i];
     pairs[i] = make_pair(a[i], b[i]);
    }
    sort(pairs.begin(), pairs.end());
    
    int now = 0;
    priority_queue<int> c;
    for(int i=1;i<m+1;i++){
     if(c.size()<n){
      for(int j=now;j<n;j++){
        if(pairs[j].first>i){
          break;
        }
        c.push(pairs[j].second);
        now=j+1;
      } 
     }
     if(c.size()>0){
      ans+=c.top();
      c.pop();
     }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);
    }
    sort(l.begin(), l.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l.at(i) + l.at(j) > l.at(k)) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 5010
using namespace std;

int n,k,dp[20][N],num[N],ans;

void sol(int l,int r,int now)
{
    if(l==r)
    {
        int i;
        for(i=max(0,k-num[l]); i<k; i++)
        {
            if(dp[now][i]) break;
        }
        if(i<k) ans++;
        return;
    }
    int i,j,mid=((l+r)>>1);
    for(i=0;i<k;i++) dp[now+1][i]=dp[now][i];
    for(j=l; j<=mid; j++)
    {
        for(i=k-1; i>=num[j]; i--)
        {
            dp[now+1][i]|=dp[now+1][i-num[j]];
        }
    }
    sol(mid+1,r,now+1);
    for(i=0;i<k;i++) dp[now+1][i]=dp[now][i];
    for(j=mid+1;j<=r;j++)
    {
        for(i=k-1;i>=num[j];i--)
        {
            dp[now+1][i]|=dp[now+1][i-num[j]];
        }
    }
    sol(l,mid,now+1);
}

int main()
{
    int i,j;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&num[i]);
    }
    dp[0][0]=1;
    sol(1,n,0);
    cout<<n-ans;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=605;
int n;
string s;
ll dp[N][N];//number maximum number of 1 that can be picked if j 0s is picked among the first i
ll c[N][N];
ll dp2[3][N][N];
int main(){
	ios::sync_with_stdio(false);
	cin >> s;n=s.size();s='?'+s;
	if(n==1){
		cout << "1\n";
		return 0;
	}
	for(int i=0; i<=2*n ;i++){
		for(int j=0; j<=2*n ;j++){
			dp[i][j]=-1e9;
			dp2[0][i][j]=-1e9;
			dp2[1][i][j]=-1e9;
			dp2[2][i][j]=-1e9;
		}
		dp[i][0]=0;
		c[i][0]=1;
		for(int j=1; j<=i ;j++){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	}
	dp2[0][0][0]=0;
	dp[0][0]=0;
	for(int i=1; i<=n ;i++){
		int c=i%3;
		int p=(c+2)%3;
		int q=(c+1)%3;
		for(int j=0; j<=i ;j++){
			for(int k=0; k<=i ;k++){
				dp2[c][j][k]=-1e9;
			}
		}
		for(int j=0; j<=i ;j++){
			for(int k=0; k<=i ;k++){
				if(i>=2 && j>=1) dp2[c][j][k]=max(dp2[c][j][k],dp2[q][j-1][k]);//aa->power
				if(i>=2 && (s[i-1]=='1' || s[i]=='1')) dp2[c][j][k]=max(dp2[c][j][k],dp2[q][j][k]+1);//ab,ba->void
				if(i>=2 && (s[i-1]=='0' || s[i]=='0') && k>=1) dp2[c][j][k]=max(dp2[c][j][k],dp2[q][j][k-1]);//ab,ba->void
				if(s[i]=='1') dp2[c][j][k]=max(dp2[c][j][k],dp2[p][j+1][k]+1);
				if(s[i]=='0' && k>=1) dp2[c][j][k]=max(dp2[c][j][k],dp2[p][j+1][k-1]);
				dp[i][k]=max(dp[i][k],dp2[c][j][k]);
			}
		}
	}
	for(int i=1; i<=n ;i++){
		for(int j=0; j<=i-2 ;j++){
			bool hv0=false;
			bool hv1=false;
			for(int k=j+1; k<=i ;k++){
				if(s[k]=='0') hv0=true;
				if(s[k]=='1') hv1=true;
			}
			for(int k=0; k<=i ;k++){
				if(hv1) dp[i][k]=max(dp[i][k],dp[j][k]+1);
				if(hv0 && k!=0) dp[i][k]=max(dp[i][k],dp[j][k-1]);
			}
		}
	}
	ll ans=0;
	for(int i=n; i>=1 ;i--){
		int c0=0,c1=0;
		for(int j=n; j>=i ;j--){
			if(s[j]=='0') c1++;
			else c0++;
		}
		for(int j=0; j<=i ;j++){
			for(int k=0; k<=dp[i][j] ;k++){
				if(c0==0 && j!=0) continue;
				if(c1==0 && k!=0) continue;
				ll w1=1,w2=1;
				if(j!=0) w1=c[j+c0-1][c0-1];
				if(k!=0) w2=c[k+c1-1][c1-1];
				ans=(ans+w1*w2)%mod;
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 17836
N = gets.to_i
A = 2.times.map { gets.split.map(&:to_i) }

max = 0
for i in 1..N do
  sum = 0
  for j in 1..(N-i+1) do
    sum += A[0][j-1]
  end
  for k in (N-i+1)..N do
    sum += A[1][k-1]
  end
  max = sum if sum > max
end

puts max

Measured memory_bytes: 1788
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
static const int MAX_N = 100;
static const int MAX_M = 100;
stack<char> ans;
vector<char> v(4);
int main()
{
  std::vector<int> v(5);
  REP(i,5) cin >> v.at(i);
  int k;
  cin >> k;
  bool flag =0;
  REP(i,4){
    FOR(j,i+1,5){
      if(abs(v.at(i)-v.at(j))>k){
        flag =1;
        break;
      }
    }
  }
  if(flag){
    cout << ":("<<endl;
  }else{
    cout << "Yay!"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    int l = lcm(360,X);
    cout << l/X << "\n";
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

tuple<vector<int>, vector<int>> BFS(const vector<vector<Edge>>& graph, int s) {
  int n = graph.size();

  deque<int> queue;
  queue.push_back(s);
  vector<int> ds(n, INT_MAX);
  vector<int> ps(n, -1);
  ds[s] = 0;
  while (!queue.empty()) {
    int v = queue.front();
    queue.pop_front();
    for (const auto& e : graph[v]) {
      if (ds[e.to] < INT_MAX) continue;
      ds[e.to] = ds[v] + 1;
      ps[e.to] = v;
      queue.push_back(e.to);
    }
  }
  return {ds, ps};
}

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

  int n, m;
  cin >> n >> m;
  auto graph = ReadUndirectedGraph(n, m, true);
  auto [ds, ps] = BFS(graph, 0);
  cout << "Yes" << endl;
  for (int v = 1; v < n; v++) {
    cout << ps[v] + 1 << "\n";
  }
}

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

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

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

int w,h;
int field[20][20];
int ans,sx,sy;

void dfs(int x, int y, int cnt){
  int tx,ty;
  int *p;
  if( cnt>=ans ) return;
  
#if DEB
  printf("(%d,%d)  cnt:%d\n",x,y,cnt);
  rep(i,h){
    rep(j,w){
      printf("%d ",field[i][j]);
    }
    puts("");
  }
#endif

  rep(k,4){
    tx = x;
    ty = y;
    if( tx<0 || ty<0 || tx>=w || ty>=h ||
	field[ty+dy[k]][tx+dx[k]]==1 )continue;
    for(;;){
      tx += dx[k];
      ty += dy[k];
      if( tx<0 || ty<0 || tx>=w || ty>=h ) break;
      p = &field[ty][tx];
      if( *p==1 ){
	*p = 0;
	dfs(tx-dx[k], ty-dy[k], cnt+1);
	*p = 1;
	break;
      }else if( *p==3 ){
	ans = cnt+1;
	return;
      }
    }
  }
}

int main(){
  while(scanf("%d%d",&w,&h),w|h){
    ans = 11;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
      }
    }
    dfs(sx,sy,0);
    printf("%d\n",ans==11?-1:ans);
  }
  return 0;
}

Measured memory_bytes: 0
def resolve():
    '''
    code here
    '''
    a,b = [int(item) for item in input().split()]

    if a > 0:
        print('Positive')
    else:
        if a <= 0 and 0 <= b:
            print('Zero')
        else:
            cnt = b - a + 1

            if cnt % 2 == 0:
                print('Positive')
            else:
                print('Negative')

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9080
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,k;cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> dp(n,1e+9);
  dp[0] = 0;
  rep(i,n){
    rep1(j,k){
      if( i + j >= n) break;
      dp[i+j] = min( dp[i+j] , dp[i] + abs(h[i] - h[i+j]) );
    }
  }
  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//long a[100001],w[100001];

int main() {
	// your code goes here

    long n,wt;
    cin>>n>>wt;
    long a[n],w[n];
    for(int i=0;i<n;i++) 
    {cin>>w[i];
    cin>>a[i]; }
    long dp[n+1][wt+1];
    
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=wt;j++)
        {
            if(i==0||j==0) {dp[i][j]=0; }
            else {
               // cout<<i<<" "<<j<<endl;
             if(w[i-1]>j) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],a[i-1]+dp[i-1][j-w[i-1]]);
            }
           // cout<<dp[i][j]<<" "<<endl;
            
            
        }
    }
    cout<<dp[n][wt]<<endl;
	return 0;
}


Measured memory_bytes: 82484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(ll i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll l,r; cin >> l >> r;
	ll mx = min(l+2019,r);
	ll ans = 2019;
	rep2(i,l,mx)rep2(j,i+1,mx+1){
		ll amari = (i*j)%2019;
		ans = min(ans,amari);
	}
	out(ans);
}




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

int main() {
    int N, W;
    cin >> N >> W;
    map<int, int, greater<int> > mp;
    mp[0] = 0;
    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;
        for (auto p: mp) {
            if (p.first + w <= W)
                mp[p.first + w] = max(mp[p.first + w], mp[p.first] + v);
        }
    }
    int ans = 0;
    for (auto p: mp) {
        ans = max(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
using namespace std;
int n, q, com, x, y; int group[10000]; vector<int> f[10000];
int main() {
	scanf("%d%d", &n, &q);
	for(int i = 0; i < n; i++) group[i] = i, f[i].push_back(i);
	for(int i = 0; i < q; i++) {
		scanf("%d%d%d", &com, &x, &y);
		if(com == 0) {
			if(group[x] == group[y]) continue;
			x = group[x], y = group[y];
			if(f[y].size() > f[x].size()) swap(x, y);
			for(int j = f[y].size() - 1; j >= 0; j--) {
				group[f[y][j]] = group[x];
				f[x].push_back(f[y][j]);
				f[y].pop_back();
			}
		}
		else printf("%d\n", (group[x] == group[y] ? 1 : 0));
	}
	return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll dp[100], d, co;
P a, b;
int main() {
	ll x, y;
	cin >> x >> y;
	a = b = P(0, 0);
	dp[0] = dp[1] = 1;
	REP(i, 80)dp[i + 2] = dp[i + 1] + dp[i];
	REPO(i, 90) {
		if (a.first <= x and b.first >= x and a.second <= y and b.second >= y) {
			cout << co + 1 << endl;
			return 0;
		}
		co = (co + 1) % 3;
		if (d == 0) a = P(a.first + dp[i - 1], a.second), b = P(b.first + dp[i], b.second + dp[i] - dp[i - 1]);
		if (d == 1) a = P(a.first - dp[i] + dp[i - 1], a.second + dp[i - 1]), b = P(b.first, b.second + dp[i]);
		if (d == 2) a = P(a.first - dp[i], a.second - dp[i] + dp[i - 1]), b = P(b.first - dp[i - 1], b.second);
		if (d == 3) a = P(a.first, a.second - dp[i]), b = P(b.first + dp[i] - dp[i - 1], b.second - dp[i - 1]);
		d = (d + 1) % 4;
		//cout << a.first << " " << a.second << " " << b.first << " " << b.second << endl;
  	}
}



Measured memory_bytes: 3120
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long X, long long Y){
 cout << X + Y/2 << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
def add_num(n):
    str_n = str(n)
    lower = int(str_n[-1])
    upper = int(str_n[0])
    digit_num = len(str_n)
    ret_val = 0
    if lower == 0:
        return 0
    if digit_num == 1:
        return 1
    elif digit_num == 2:
        if upper < lower:
            return 0
        if upper == lower:
            ret_val += 1
        for d in range(digit_num-1):
            add_val = (10**d) * 2
            ret_val += add_val
        return ret_val

    if upper <= lower:
        for d in range(digit_num-2):
            add_val = (10**d) * 2
            ret_val += add_val
        if upper == lower:
            ret_val += 1
    else:
        for d in range(digit_num-1):
            add_val = (10**d) * 2
            ret_val += add_val
    if upper == lower:
        ret_val += 2
        # print(str_n[1:-1])
        ret_val += int(str_n[1:-1])*2
    return ret_val


def main():
    N = int(input())
    ans = 0
    for n in range(1, N+1):
        # print(n, add_num(n))
        ans += add_num(n)
    print(ans)


if __name__ == "__main__":
    main()
    add_num(11)


Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
           int n;
           cin >>n;

    vector<double> vec(n);
    for (int i = 0; i < n; i++) {
        cin>> vec.at(i);
    }
     
    double ave=0;
  for(int i=0;i<n;i++){
  ave += vec[i];
  }
  ave = ave / n;
  double k=10000;
  bool A=false;
  int c=0;
  for(int i=0;i<n;i++){
   
 if(k <= abs(ave - vec[i]) ){
    continue;
    }
    
    if(k >  abs(ave - vec[i])){
  k=min(abs(ave - vec [i]),k);
      c=i;
      
    }
  }
  cout <<c<<endl;
}


Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

string s[4] = { "AC","WA","TLE","RE" };
void solve() {
	int n; cin >> n;
	int cnt[4] = {};
	rep(i, n) {
		string t; cin >> t;
		rep(j, 4) {
			if (t == s[j])cnt[j]++;
		}
	}
	rep(j, 4) {
		cout << s[j] << " x " << cnt[j] << "\n";
	}
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 20048
A,B,K=map(int, input().split())
jjj=0
def func(num):
    global A,B,jjj
    if num==0:
        if A%2==1:
            A-=1
        tmp=A//2
        A-=tmp
        B+=tmp
        jjj=1
    elif num==1:
        if B%2==1:
            B-=1
        tmp=B//2
        B-=tmp
        A+=tmp
        jjj=0
for i in range(K):
    func(jjj)
print(A,B)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

//modの値の確認をすること
int main(){
    double a,b,h,m,torad = pi / 180;
    cin >> a >> b >> h >> m;
    double hx = a * sin((h * 30.0 + m * 0.5) * torad),hy = a * cos((h * 30.0 + m * 0.5) * torad),mx = b * sin(m * 6.0 * torad),my = b * cos(m * 6.0 * torad);
    printf("%.12f",sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my)));
    return 0;
}


Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n;
	ll sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		if(i % 3 && i % 5) 
		sum += i;
	}
	cout << sum;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int R = scanner.nextInt();

		// R = X - 100(10-N)
		// X = R + (100(10-N))
		int result = N<10 ? R + 100*(10-N) : R;
		System.out.println(result);


	}

}


Measured memory_bytes: 21972
import sys
 
mode = 0
for line in sys.stdin:
    if mode == 0:
        n = int(line.strip('\n'))
        if n == 0: break
        mode = 1
    elif mode == 1:
        x = [float(i) for i in line.strip('\n').split()]
        ave = sum(x) / n
        std = (sum([(i-ave)**2 for i in x])/n)**0.5
        print std
        mode = 0

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

int main() {
  int a, b;

  cin >> a >> b;
  
  if ((a % 2) == 1 &&  (b % 2) == 1 ){
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = [0] * (N)

for i in range(1, N):
    if i > 1:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
    else:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])

print(dp[-1])

Measured memory_bytes: 13980
int main(void)
{
        int A;
        int P;
        int s;
        int pi=0;
        int i;

        scanf("%d %d",&A,&P);

        s=(A*3+P);

        for(i=0;s>=0;i++){
                if((s-2)>=0){
                        pi++;
                }
                s-=2;
        }
        printf("%d\n",pi);

        return 0;
}


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

using std::pair;
const int N = 1e6 + 5;
int n, tot, a[N]; 
char s[N];

int main()
{
	scanf("%d%s", &n, s);
	--n;
	for (int i = 0; i <= n; ++i)
		a[i] = s[i] - '0' - 1;
	for (int i = 0; i <= n; ++i)
		if ((n & i) == i)
			tot = tot + a[i] & 1;
	if (tot)
		puts("1");
	else
	{
		bool flag = false;
		for (int i = 0; i <= n; ++i)
			if (a[i] == 1)
			{
				puts("0");
				flag = true;
				break ;
			}
		if (!flag)
		{
			tot = 0;
			for (int i = 0; i <= n; ++i)
				if ((n & i) == i)
					tot = tot + (a[i] >> 1) & 1;
			printf("%d\n", tot << 1);
		}
	}
}

Measured memory_bytes: 5120
N, K = map(int, input().split())
A_ans = [1 for i in range(N)]
for i in range(K):
    d = int(input())
    if d > 1 :
        A = list(map(int, input().split()))
        for j in range(len(A)):
            if A_ans[A[j]-1] == 1 :
                A_ans[A[j]-1] = 0
    else:
        A = int(input())
        if A_ans[A-1] == 1 :
            A_ans[A-1] = 0

print(sum(A_ans))
 


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

using namespace std;
string s;
long dem[30], a[30][100050];
int main(){
cin>>s;
for(int i=0;i<s.length();i++)
{
    if(s[i]==s[i+1]) {cout<<i+1<<" "<<i+2;  return 0;}
    else if(s[i]==s[i+2]) {cout<<i+1<<" "<<i+3; return 0;}

}
cout<<"-1 -1";
return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	long long times=x/d;
	long long tmp=times*d;
	if (k<times){
		cout<<x-k*d<<endl;
	}else {
		if (tmp==x){
			if ((k-times)%2==0){
				cout<<0<<endl;
			}else {
				cout<<d<<endl;
			}
		}else{
			k-=times;
			x-=times*d;
			long long minn=abs(x-d);
			if (k%2ll==1ll) cout<<minn<<endl;
			else cout<<x<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3644
//Bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll weight[105],value[105];
ll dp[105][100005];
int main()
{
    ll n,W;
    scanf("%lld %lld",&n,&W);
    for(ll i=1;i<=n;i++){
        ll w,v;
        scanf("%lld %lld",&weight[i],&value[i]);
    }
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=100000;j++){
            dp[i][j]=1e18;
        }
    }
    for(ll i=1;i<=n;i++) dp[i][value[i]]=weight[i];
    for(ll i=2;i<=n;i++){
        for(ll j=0;j<=100000;j++){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j>=value[i]){
                dp[i][j]=min(dp[i][j],dp[i-1][j-value[i]]+weight[i]);
            }
        }
    }
    ll ans;
    for(ll i=100000;i>=0;i--){
        if(dp[n][i]<=W){
            ans=i;
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 79360
import bisect

N = int(input())
Ls = list(map(int, input().strip().split()))

Ls.sort()

total = 0
#print(Ls)
for i in range(N):
	a = Ls[i]
	for j in range(i + 1, N):
		b = Ls[j]
		c_min = b - a + 1
		c_max = a + b - 1
		l = bisect.bisect_left(Ls, c_min, lo = j + 1)
		if l != N:
			r = bisect.bisect_right(Ls, c_max, lo = j + 1)
			if r:
				r = r - 1
				if r >= l:
					total += r - l + 1
#					print(a, b, c_min, c_max, l, r)
print(total)


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

#define DICE_SIZE 6

using namespace std;

class Dice {
	private:
		int number[DICE_SIZE];
		int work_space[DICE_SIZE];

		void reset_number(int, int, int, int, int, int);

	public:
		Dice(int *);
		void turn(char);
		int peek_top();
};

Dice::Dice(int *number) {
	for (int i = 0; i < DICE_SIZE; i++) {
		this->number[i] = number[i];
	}
}

void Dice::turn(char direction) {
	for (int i = 0; i < DICE_SIZE; i++) work_space[i] = number[i];

	switch (direction) {
		case 'N':
			reset_number(work_space[1], work_space[5], work_space[2], work_space[3], work_space[0], work_space[4]);
			break;			
		case 'E':
			reset_number(work_space[3], work_space[1], work_space[0], work_space[5], work_space[4], work_space[2]);
			break;
		case 'S':
			reset_number(work_space[4], work_space[0], work_space[2], work_space[3], work_space[5], work_space[1]);
			break;
		case 'W':
			reset_number(work_space[2], work_space[1], work_space[5], work_space[0], work_space[4], work_space[3]);
			break;
	}
}

int Dice::peek_top() {
	return number[0];
}

void Dice::reset_number(int num0, int num1, int num2, int num3, int num4, int num5) {
	number[0] = num0;
	number[1] = num1;
	number[2] = num2;
	number[3] = num3;
	number[4] = num4;
	number[5] = num5;
}

int main() {
	int number[DICE_SIZE];
	for (int i = 0; i < DICE_SIZE; i++) cin >> number[i];

	Dice *dice = new Dice(number);

	string query;
	cin >> query;

	for (int i = 0; i < query.size(); i++) dice->turn(query[i]);

	cout << dice->peek_top() << endl;

	return 0;
}



Measured memory_bytes: 3188
import Data.List
main=interact$show.(\[n,x]->f n x).map read.words
f 0 1 = 1
f _ 1 = 0
f n x
    | x == t = (2^(n+1))-1
    | x == t-1 = (2^(n+1))-1
    | x == m = 2^n
    | x < m = f (n-1) (x-1)
    | otherwise = (2^n) + f (n-1) (x-m)
    where
        t = (2^(n+2))-3
        m = (t `div` 2) + 1


Measured memory_bytes: 508
n,m = (int(i) for i in input().split())
a,b=[0 for i in range(m)],[0 for i in range(m)]
g = [[0 for i in range(n)] for j in range(n)]
ans = 0

def dfs(v,visited):
    if visited[v]:
        return
    visited[v] = True 
    for i in range(n):
        if g[v][i]:
            dfs(i,visited)

for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
for i in range(m):
    g[a[i]][b[i]],g[b[i]][a[i]] = True,True 

for i in range(m):
    visited = [False for i in range(n)]
    g[a[i]][b[i]], g[b[i]][a[i]] = False,False 

    dfs(0,visited)

    if not all(visited):
        ans += 1

    g[a[i]][b[i]], g[b[i]][a[i]] = True, True 
print(ans)


Measured memory_bytes: 42348
#include<bits/stdc++.h>
using namespace std;
#define int long long
int bfs(int x)
{
    // Create a queue and enqueue 'i' to it
    queue<int> q;
    q.push(1);
    q.push(2);
    q.push(3);
    q.push(4);
    q.push(5);
    q.push(6);
    q.push(7);
    q.push(8);
    q.push(9);

    int cnt=0;
int  num;
    // Do BFS starting from i
    while (!q.empty()) {
        num = q.front();
        q.pop();
        cnt++;

   if(cnt==x)
      break;

            int last_dig = num % 10;

            // If last digit is 0, append next digit only

            if (last_dig == 0)
                { q.push(num*10+last_dig);
                     q.push((num * 10) + (last_dig + 1));
                }

            // If last digit is 9, append previous digit only
            else if (last_dig == 9)
                {
                q.push((num * 10) + (last_dig - 1));
                 q.push(num*10+last_dig);
                }

            // If last digit is neighter 0 nor 9, append both
            // previous and next digits
            else {
                q.push((num * 10) + (last_dig - 1));
                q.push(num*10+last_dig);
                q.push((num * 10) + (last_dig + 1));

            }
        }

        return num;
    }

main()
{
 int k;
 cin>>k;
    cout<<bfs(k);
}


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

map<int,int> c,p;

int main(void){
	while(1){
		string s;
		getline(cin,s);
		if(s=="") break;
		int a,b;
		sscanf(s.c_str(),"%d,%d",&a,&b);
		c[a]++;
	}
	while(1){
		string s;
		getline(cin,s);
		if(cin.eof()) break;
		int a,b;
		sscanf(s.c_str(),"%d,%d",&a,&b);
		p[a]++;
	}
	for(auto &i:c){
		if(p.find(i.first)!=p.end())
			cout << i.first <<" " << p[i.first]+c[i.first] << endl;
	}
	return 0;
}

Measured memory_bytes: 1240