akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D


if __name__ == '__main__':
    n = int(input())
    x = [2]

    for i in range(2, 2000 + 1):
        if all(i % j != 0 for j in x):
            x.append(i)

    # https://www.youtube.com/watch?v=geZKa28g93o
    primes = [xi for xi in x if (xi % 5 == 1) and (xi >= 10)]
    print(' '.join(map(str, primes[:n])))


Measured memory_bytes: 2940
import math
def main():

    n = int(input())
    counter = 0
    for a in range(1,int(math.sqrt(n))+2):
        for b in range(a,n//a+1):
            c = n - a*b
            #print(a,b,c,c >= 1)
            if c <= 0:
                continue
            if a==b:
                counter += 1
            else:
                counter += 2
    print(counter)



if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  if(n%2==0)cout<<n<<endl;
  else cout<<n*2<<endl;
  
  return 0;
}


Measured memory_bytes: 256
k = int(input())

print(50)
l = [i for i in range(50)]

for i in range(50):
    l[i] += k//50
a = k%50
for i in range(a):
    for j in range(50):
        if i == j:
            l[j] += 50
        else:
            l[j] -= 1
print(*l)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
#define MOD(x) ((x) >= mod ? (x) - mod : (x))
using namespace std;
const int maxn = 310, inf = 1e9 + 233, mod = 998244353;
int n;
int a[maxn], f[maxn][maxn * maxn], g[maxn][maxn * maxn];

template <typename T>
inline void read(T &k)
{
    int f = 1; k = 0; char c = getchar();
    while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
    while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
    k *= f;
}

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

int main()
{
    read(n); int sum = 0;
    for (int i = 1; i <= n; i++) read(a[i]), sum += a[i];

    f[1][0] = 1; g[1][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= 90000; j++)
        {
            if (f[i][j])
            {
                f[i + 1][j] = (f[i + 1][j] + 2ll * f[i][j]) % mod;
                if (j + a[i] <= 90000) f[i + 1][j + a[i]] = MOD(f[i + 1][j + a[i]] + f[i][j]);
            }
            if (g[i][j])
            {
                g[i + 1][j] = MOD(g[i + 1][j] + g[i][j]);
                if (j + a[i] <= 90000) g[i + 1][j + a[i]] = MOD(g[i + 1][j + a[i]] + g[i][j]);
            }
        }
    }

    // printf("%d %d\n", f[n + 1][2] - 2 * g[n + 1][2], f[n + 1][3] - 2 * g[n + 1][3]);

    int ans = (power(3, n) - power(2, n) * 3ll + 3) % mod;
    ans = MOD(ans + mod);
    // printf("%d\n", ans);
    int mx = ((sum + 1) >> 1);
    for (int i = mx; i < sum; i++) ans = (ans - 3ll * (f[n + 1][i] - 2ll * g[n + 1][i]) % mod + mod) % mod;
    printf("%d\n", ans);
}

Measured memory_bytes: 227584
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;

int main(){
	double a,b,c;
	double x,y;
	double s;
	while(cin>>x>>y,y!=0){
	a=x/2;
	b=y;
	c=sqrt(a*a+b*b);
	s=x*x+4*x*c/2;
	printf("%.9f\n",s);
	}
	

}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main(){
  int n[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int k;
  cin>>k;
  cout<<n[k-1]<<endl;
  return 0;
}


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

using namespace std;

typedef pair<int, int> ii;

long long c = 0;

multiset<ii> s;

long long ans[100005];

long long left1 = 0;
long long right1 = 0;

multiset<ii>::iterator median;

void insert1(ii x){
	if(s.empty()){
		s.insert(x);
		median = s.begin();
	}else if(s.size() % 2 == 1){
		if(x > (*median)){
			s.insert(x);
			right1 += x.first;
		}else{
			s.insert(x);
			left1 += x.first;
			right1 += (*median).first;
			median --;
			left1 -= (*median).first;
		}
	}else{
		if(x > (*median)){
			s.insert(x);
			right1 += x.first;
			left1 += (*median).first;
			median ++;
			right1 -= (*median).first;
		}else{
			s.insert(x);
			left1 += x.first;
		}
	}
}

int main(){
	int Q;
	scanf("%d", &Q);
	
	int n = 0;
	for(int i = 0; i < Q; i ++){
		int op;
		scanf("%d", &op);
		
		if(op == 2){
			long long numLeft = max((n-1)/2, 0);
			long long numRight = n/2;
			//printf("debug: %lld %lld %lld\n", left1, right1);
			printf("%d %lld\n", (*median).first, (numLeft*(*median).first-left1) + (right1-numRight*(*median).first) + c);
			continue;
		}else{
			int a, b;
			scanf("%d%d", &a, &b);
			c += b;
			insert1(ii(a, i));
			n ++;
		}
	}
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
long long sum[90];
int main()
{
    sum[0] = 2;
    sum[1] = 1;
    int n;
    cin >> n;
    for(int i = 2;i <= n;i++)
        sum[i] = sum[i-1] + sum[i-2];
    cout << sum[n];

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var N int
	fmt.Scan(&N)
	var s, t string
	fmt.Scan(&s, &t)
	maxd := 0
	for i := 1; i <= N; i++ { // sの末尾i文字とtの先頭i文字で最大何文字一致するか？
		if s[len(s)-i:len(s)] == t[:i] {
			maxd = max(maxd, i)
		}
	}
	fmt.Println(2*N - maxd)
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    // Your code here!
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    if ((C + B - 1) / B > (A + D - 1) / D)
        printf("No");
    else
        printf("Yes");
    return (0); 
}


Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main() {
    int N,K;
    cin >> N >> K;

    vector <int> h(N);
    REP(i,N)
    {
        cin >> h[i];
    }

    vector <ll> dp(N+1, INF);
    dp[0] = 0;

    for(int i = 1; i < N; ++i)
    {
        for(int j = 1; j <= K; ++j)
        {
            if(i-j < 0)continue;
            dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]));
        }
    }
    ll res = dp[N-1];

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 1408
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

int main()
{
    int N;
    cin >> N;
    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);
    REP(i, N) cin >> t[i] >> x[i] >> y[i];
    int pt = 0;
    int px = 0;
    int py = 0;
    REP(i, N)
    {
        int ct = t[i];
        int cx = x[i];
        int cy = y[i];
        int dt = ct - pt;
        int dp = abs(cx - px) + abs(cy - py);
        bool ok = (dp <= dt) && (((dt - dp) % 2) == 0);
        if (!ok)
        {
            cout << "No" << endl;
            return 0;
        }
        pt = ct;
        px = cx;
        py = cy;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
void fastio()
{					
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}


void solve()
{
	ll int n,k;
	cin>>n>>k;
	ll int a[n],i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];

	}
	ll int dp[n];
	dp[0]=0;
	for(i=1;i<n;i++)
	{
		ll int mi=1e18;
		for(int j=1;j<=k;j++)
		{
			
			ll int op1= (j>i)?1e10:abs(a[i]-a[i-j])+dp[i-j];
			// cout<<op1<<endl;
			mi=min(mi,op1);
		}
		dp[i]=mi;
	}
	cout<<dp[n-1]<<endl;

	
}
int  main()
{
	fastio();
	ll int t;
	t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	
	

	
}




Measured memory_bytes: 5180
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<vector<int>>edge(n);
    rep(i,n-1){
        int s,t; cin >> s >> t;
        edge[--s].push_back(--t);
        edge[t].push_back(s);
    }
    vector<bool>visit(n,false);
    vector<bool>ispath(n,false);
    function<bool(int)> dfs = [&](int v){
        visit[v] = true;
        bool flag = (v == n-1);
        for(auto nv : edge[v]){
            if(visit[nv])continue;
            if(dfs(nv))flag = true;
        }
        return ispath[v] = flag;
    };
    dfs(0);
    // all vertex was checked.
    int margin = accumulate(all(ispath),0LL) - 2;
    margin = margin / 2 + margin % 2;
    vector<int>grid(n,-1);
    function<int(int,int)>cntup = [&](int v, int atrb){
        int res = 1;
        grid[v] = atrb;
        for(auto nv : edge[v]){
            if(grid[nv] != -1)continue;
            if(ispath[nv] == false or atrb == 1) res += cntup(nv,atrb);
            else if(ispath[nv] and margin > 0 )--margin,res += cntup(nv,atrb);
        }
        return res;
    };
    int f = cntup(0,0), s = cntup(n-1,1);
    assert(f + s == n);
    cout << (f > s ? "Fennec" : "Snuke") << endl;
}





Measured memory_bytes: 14336
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var tmp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var A = tmp[0];
        var B = tmp[1];

        var array = new int[3] { A + B, A - B, A * B };

        Console.WriteLine(array.Max());
    }
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


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



    string s,ans;
    cin>>s;
    reverse(all(s));
    int n = s[0]-'0';
    if(n==2||n==4||n==5||n==7||n==9)
        ans="hon";
    else if(n==0||n==1||n==6||n==8)
        ans="pon";
    else
        ans = "bon";
    cout<<ans;






    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll n,m,v,p,A[200001],B[200001];
    cin>>n>>m>>v>>p;
    rep(i,n) cin>>A[i];
    sort(A,A+n,greater<ll>());
    if(v<=p){
        ll ans;
        rep(i,n) if(A[p-1]<=A[i]+m) ans=i+1;
        cout<<ans;
    }
    else{
        rep(i,n) B[i]=0;
        B[p-1]=A[p-1];
        rep(i,n) if(i>=p) B[i]=B[i-1]+A[i];
        ll ans=p;
        rep(i,n) if(i>=p&&A[p-1]<=A[i]+m&&(A[i]+m)*(i-p+1)-B[i-1]>=m*(v-(p-1)-(n-i))) ans=i+1;
        cout<<ans;
    }
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 305;
const Int MAX2 = MAX*2;
signed ex[MAX2][MAX2];
signed dp1[MAX2+2][MAX2+2];
signed dp2[MAX2+2][MAX2+2];
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  memset(ex,0,sizeof(ex));
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(s[i][j]!='#') continue;
      vp.emplace_back(1+i+j,1+i-j+w);
      ex[1+i+j][1+i-j+w]=1;      
    }
  }
  
  auto ch=
    [&](Int i,Int j)->Int{
      if(i<0||i>=MAX2) return 0;
      if(j<0||j>=MAX2) return 0;
      return ex[i][j];
    };
  
  memset(dp1,0,sizeof(dp1));
  memset(dp2,0,sizeof(dp2));
  Int ans=0;
  
  const Int LIM = h+w;
  for(Int k=1;k<=LIM;k++){
    for(Int i=0;i<MAX2;i++){
      for(Int j=0;j<MAX2;j++){
        dp1[i][j+1]=dp1[i][j]+(ex[i][j]&&ch(i,j-k));
        dp2[j][i+1]=dp2[j][i]+(ex[i][j]&&ch(i-k,j));
      }
    }
    for(P p:vp){
      Int i,j;
      tie(i,j)=p;
      
      if(i-k>=0) ans+=dp1[i-k][min(MAX2-1,j+k+1)]-dp1[i-k][j];
      if(j-k>=0) ans+=dp2[j-k][min(MAX2-1,i+k+1)]-dp2[j-k][i];
      
      if(i+k<MAX2) ans+=dp1[i+k][min(MAX2-1,j+k+1)]-dp1[i+k][j];
      if(j+k<MAX2) ans+=dp2[j+k][min(MAX2-1,i+k+1)]-dp2[j+k][i];
    }            
  }

  //cout<<ans<<endl;
  for(P p:vp){
    Int i,j;
    tie(i,j)=p;
    for(Int k=1;k<=LIM;k++){
      if(ch(i+k,j)&&ch(i,j+k)) ans--;
      if(ch(i+k,j)&&ch(i,j-k)) ans--;
      if(ch(i-k,j)&&ch(i,j+k)) ans--;
      if(ch(i-k,j)&&ch(i,j-k)) ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6388
import sys
from collections import defaultdict

n, *lst = sys.stdin.read().split()
n = int(n)
c = defaultdict(int)
for i in lst:
  tmpi = ''.join(sorted(i))
  c[tmpi] += 1
res = 0
for key in c:
  res += c[key] * (c[key] - 1) // 2
print(res)

Measured memory_bytes: 26760
import heapq
def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d
import sys
input = sys.stdin.readline
n =int(input())

edge = [[] for i in range(n)]
#edge[i] : [weght,to]
for i in range(n-1):
    a, b, c = map(int,input().split())
    a, b = a-1, b-1
    edge[a].append([c,b])
    edge[b].append([c,a]) 
q, k = map(int, input().split())
k = k-1
d = dijkstra_heap(k)
for i in range(q):
  x, y = map(int, input().split())
  x, y = x-1, y-1
  print(d[x]+d[y])

Measured memory_bytes: 55932
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}

int main(){
  ll n,k;string s;cin>>n>>k>>s;
  ll cnt=0,ans=0;
  vp q;
  rep(i,0,n-1){
    cnt++;
    if(s[i]=='0'&&s[i+1]=='1'){q.push_back(make_pair(cnt,0));cnt=0;}
    if(s[i]=='1'&&s[i+1]=='0'){q.push_back(make_pair(cnt,1));cnt=0;}
  }
  if(s[n-1]=='0'){q.push_back(make_pair(cnt+1,0));}
  else q.push_back(make_pair(cnt+1,1));
  ll m=q.size();vll sum(m+1,0);
  rep(i,0,m){
    sum[i+1]=sum[i]+q[i].first;
  }
  rep(i,0,m){
    if(q[i].second){
      ans=max(ans,sum[min(m,i+2*k+1)]-sum[i]);
    }
    else ans=max(ans,sum[min(m,i+2*k)]-sum[i]);
  }
  cout<<ans<<endl;
}



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


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool fl = true;
    while(a > 0 and c > 0){
        if(fl){
            fl = !fl;
            c -= b;
        }else{
            fl = !fl;
            a -= d;
        }

    }
    if(a > 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int num[3],k;
  int ans = 0;
  cin >>num[0]>>num[1]>>num[2];
  cin >>k;

  sort(num,num+3);

  for(int i=0;i<k;i++){
    num[2] = num[2]*2;
  }
  for(int i=0;i<3;i++){
    ans += num[i];
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  vector<int> P(N);
  rep(i,N) cin >> P[i];
  sort(P.begin(), P.end());
  int ans = 0;
  rep(i,K) ans += P[i];
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 110
using namespace std;
int n,a[12][szxb]={0};
int main()
{
	int total=0,t;
	scanf("%d",&n);
	for(register int i=1;i<=2;i++)
	{
		for(register int j=1;j<=n;j++)
		{
			scanf("%d",&t);
			a[i][j]=(a[i][j-1]+t);
		}
	}
	for(register int i=1;i<=n;i++)
	{
		total=(max(total,(a[1][i]+a[2][n]-a[2][i-1])));
	}
	printf("%d",total);
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
s = input()
mod = 10**9 + 7
n = len(s)
dp = [[0] * 13 for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    if s[i] != "?":
        for j in range(13):
            dp[i+1][(10 * j + int(s[i])) % 13] += dp[i][j]

    else:
        for j in range(13):
            for k in range(10):
                dp[i+1][(10 * j+k) % 13] += dp[i][j]
                dp[i+1][(10 * j+k) % 13] %= mod


print(dp[n][5])

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

using namespace std;

typedef long long LL;

LL gcd ( LL a, LL b )
{
	return (b ? gcd(b, a % b) : a);
}
LL lcm ( LL a, LL b )
{
	return a * b / gcd(a, b);
}

int main () {
	LL n, m;
	string s, t;

	while (cin >> n >> m) {
		cin >> s;
		cin >> t;
		
		LL l = lcm(n, m), l_n = l / n, l_m = l / m;
		LL x = lcm(l_n, l_m);
		LL i = 0;
		bool exists = true;
		while (i * x < l) {
			exists &= s[i * x / l_n] == t[i * x / l_m];
			i++;
		}
		if (!exists) {
			l = -1;
		}
		cout << l << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
bool is_prime(const unsigned n){
  switch(n){
  case 0: // fall-through
  case 1: return false;
  case 2: // fall-through
  case 3: return true;
  } // n > 3 が保証された
  if(n % 2 == 0) return false;
  if(n % 3 == 0) return false;
  if(n % 6 != 1 && n % 6 != 5) return false;
  for(unsigned i=5; i*i<=n; i+=6){
    if(n % i     == 0) return false; // 6n-1
    if(n % (i+2) == 0) return false; // 6n+1
  }
  return true;
}
int main() {
  int X;
  cin >> X;
  while(!is_prime(X)) X++;
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();

		if (U.equals(S)) {
			System.out.println((A - 1) + " " + B);
		} else {
			System.out.println(A + " " + (B - 1));
		}
	}

}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

const int MAX_N = 100005;
vector<int> prime(MAX_N, -1);
unordered_set<int> num;
vector<int> ans(MAX_N, 0);

bool is_prime(long long n) {
    if (n < 2) return prime[n] = 0;
    if (n == 2) return prime[n] = 1;
    if (n % 2 == 0) return prime[n] = 0;
    if (prime[n] != -1) return prime[n];
    for (long long i = 3; i*i <= n; i += 2){
        if (n % i == 0) {
            return prime[n] = 0;
        }
    }
    return prime[n] = 1;
}

void make_ans() {
    for (int i = 1; i <= 1e5; i += 2) {
        if (is_prime(i) && is_prime((i+1)/2)) {
            num.insert(i);
        }
    }
    for (int i = 1; i <= 1e5; ++i) {
        ans[i] = ans[i-1];
        if (num.count(i)) ans[i] += 1;
    }
}

void solve() {
    int l, r;
    cin >> l >> r;
    int res = ans[r] - ans[l];
    if (num.count(l)) res += 1;
    cout << res << endl;
}

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

    make_ans();
    int q;
    cin >> q; 
    rep(i, q) solve();
}

Measured memory_bytes: 1408
//TDPC E-数 https://tdpc.contest.atcoder.jp/tasks/tdpc_number
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;
int a[100010];
int arr[100010];
int main(void)
{
    int N; cin >> N;
    bool ok = false;
    int idx=0;
    for(int i=1;;++i){
        if(i*(i+1)/2>100000) break;
        if(i*(i+1)/2==N){
            ok = true;
            idx=i;
            break;
        }
    }
    if(!ok) {
        cout << "No" << endl;
        return 0;
    }
    
    vector<vector<int>> ans(idx+1);
    cout << "Yes" << endl;
    cout << idx+1 << endl;
    
    int cnt=1;
    for(int i=0; i<idx+1; ++i){
        for(int j=i+1; j<idx+1; ++j){
            ans[i].push_back(cnt);
            ans[j].push_back(cnt);
            cnt++;
        }
    }
    for(int i=0; i<idx+1; ++i){
        cout << idx;
        for(int j=0; j<idx; ++j){
            if(j+1) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

int main()
{
    int n, m, k, _a;
    cin >> n >> m;
    int a[m+1] = {0};
    for(int i = 0; i < n; ++i){
        cin >> k;
        for(int j = 0; j < k; ++j){
            cin >> _a;
            a[_a]++;
        }
    }
    
    int c = 0;
    for(int i = 0; i < m+1; ++i){
        if(a[i] == n) c++;
    }

    cout << c << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n, m;

int main(){
    I(n,m);
    if(n == m) cout << "Draw" << endl;
    else if(n < m){
        if(n == 1) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    } else{
        if(m == 1) cout << "Bob" << endl;
        else cout << "Alice" << endl;
    }
}
































Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

int N;
string s;
int x[30];
int tmp[30];

int main(){
  cin >> N;
  fill(x, x+30, 100);
  for(int i = 0; i < N; i++){
    cin >> s;
    fill(tmp, tmp+30, 0);
    for(int j = 0; j < s.length(); j++){
      tmp[s[j]-'a']++;
    }
    for(int j = 0; j < 30; j++){
      x[j] = min(x[j], tmp[j]);
    }
  }
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < x[i]; j++){
      printf("%c", 'a'+i);
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;
  vector<string> s(n);
  REP(i,n) cin >> s[i];

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

  vector<string> ret;
  int max = 0;
  int cnt = 1;

  string ss = s[0];
  FOR(i,1,n){
    if(ss == s[i]) cnt++;
    else {
      ss = s[i];
      if(cnt > max) {
        max = cnt;
      }
      cnt = 1;
    }
  }
  if(cnt > max) {
    max = cnt;
  }

  ss = s[0];
  cnt = 1;
  FOR(i,1,n){
    if(ss == s[i]) cnt++;
    else{
      if(cnt == max){
        ret.push_back(ss);
      }
      ss = s[i];
      cnt = 1;
    }
  }
  if(cnt == max){
    ret.push_back(ss);
  }

  REP(i,ret.size()) cout << ret[i] << endl;

  return 0;
}

Measured memory_bytes: 14576
#include<bits/stdc++.h>
using namespace std;
int n;
vector<double>arr(3001);
double dp[3001][3001];
double solve(int i , int x) // i - no of items // x - heads 
{
    if(x == 0)
      return 1;
    if(i == 0)
      return 0;

    if(dp[i][x] > -0.1)
      return dp[i][x];

    return dp[i][x] = arr[i]*solve(i-1,x-1)+(1-arr[i])*solve(i-1,x);  
}
signed main(void)
{
      cin>>n;
      memset(dp, -1 ,sizeof dp);
      for(int  i = 1;i<=n;i++)
          cin>>arr[i];

      cout<<fixed<<setprecision(10)<<solve(n,(n+1)/2)<<endl;  


}

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

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){return Integer.parseInt(s.next());	}

	public static void main(String[] $){
		int n=gInt();
		int[]a=new int[n];
		for(int i=0;i<n;++i)
			a[i]=gInt();
		for(int i=0;i<32;++i) {
			int b=1<<i;
			if(Arrays.stream(a)
					.anyMatch(o->o%b!=0)) {
				System.out.println(i-1);
				return;
			}
		}
	}
}

Measured memory_bytes: 26964
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <unordered_map>
#include <queue>

using namespace std;

const int maxN = 2e5 + 10, modP = 1e9 + 7;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define PINT pair < int, int >
#define NUM_SET_BIT __builtin_popcountll
#define BIT(x, i) ((x >> i) & 1)

int n, p;

int main() {
    cin >> n >> p;
    LL odd = 0, even = 1;
    FORU(i, 1, n) {
        int x;
        scanf("%d", &x);
        if (x % 2) odd += even, even = odd;
        else even *= 2, odd *= 2;
    }
    if (p) cout << odd;
    else cout << even;
}


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

int main() {
	int h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	int hPts = 0, kPts = 0;
	hPts += h1 * a + h2 * b;
	kPts += k1 * a + k2 * b;
	hPts += (h1 / 10) * c + (h2 / 20) * d;
	kPts += (k1 / 10) * c + (k2 / 20) * d;
	if (hPts > kPts) cout << "hiroshi\n";
	else if (hPts == kPts) cout << "even\n";
	else cout << "kenjiro\n";
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	cout << (S.at(2) == S.at(3) && S.at(4) == S.at(5) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
          int n,m,k;
          cin>>n>>m>>k;
          for(int i=0;i<=n;i++)
                    for(int j=0;j<=m;j++)
                    {
                              int can=i*j+(n-i)*(m-j);
                              if(can==k || n*m-can==k)
                              {
                                        cout<<"Yes";
                                        return 0;
                              }

                    }
          cout<<"No";
}


Measured memory_bytes: 256
from collections import defaultdict
H,W,M=map(int, input().split())

hs=[0]*H
ws=[0]*W
D=defaultdict(int)
for i in range(M):
    h,w=map(int, input().split())
    hs[h-1]+=1
    ws[w-1]+=1
    D[(h-1,w-1)]+=1


hmax=max(hs)
wmax=max(ws)
Hs=[]
Ws=[]
for h in range(H):
    if hmax==hs[h]:
        Hs.append(h)

for w in range(W):
    if wmax==ws[w]:
        Ws.append(w)

for h in Hs:
    for w in Ws:
        if D[h,w]==0:
            print(hmax+wmax)
            exit()

print(hmax+wmax-1)


Measured memory_bytes: 203272
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


S = sys.stdin.readline().rstrip()

if S[0] == "S":
    print("Cloudy")
elif S[0] == "C":
    print("Rainy")
else:
    print("Sunny")

Measured memory_bytes: 66156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  int n;
  while(cin>>n,n){
    int a[100001],b[100001];
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
    }
    ll ansa=0,ansb=0;
    for(int i=0;i<n;i++){
      if(a[i]>b[i])ansa+=a[i]+b[i];
      else if(a[i]==b[i])ansa+=a[i],ansb+=b[i];
      else ansb+=a[i]+b[i];
    }
    cout<<ansa<<" "<<ansb<<endl;
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


ll n, ans = 1000000000002;
double tmp;

int main() {

	cin >> n;

	tmp = (int)(sqrt(n));



	for (ll i = 1; i <= tmp; i++) {
		if (n % i == 0) {
			ans = min(ans, (n / i) + i - 2);
		}
	}

	if (ans == 1000000000002)ans = n - 1;

	cout << ans << endl;

	return 0;
}


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

int sum_of_digit (int n){
 int sum=0;
  while (n>0){
   sum +=n%10;
    n/=10;
  }
  return sum;
}

int main() {
int  N;
    cin >> N ;
  if (N%sum_of_digit (N)==0){
    cout << "Yes" << endl;  
  }
  else cout << "No" << endl;
}



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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < s.length(); i++){
    char num = s[i];
  	ans += num - 48;
  }
  cout << (atoi(s.c_str()) % ans == 0 ? "Yes" : "No") << endl;
}

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

int main() {
	int n, x;
	while (cin >> n >> x, n) {
		int res = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					res += (i + k + j) == x;
				}
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

ll n,m,seg[300000];
void segstart(void){
    for(int i=0;i<300000;i++){
        seg[i]=(1LL<<31)-1;
    }
    //memset(seg,0,sizeof(seg));
    for(ll i=1;;i*=2){
        if(n<=i){m=i;break;}
    }
    m--;n+=m;

    //for(ll i=m;i<n;i++)cin>>seg[i];
    for(int i=m-1;i>=0;i--){
        seg[i]=min(seg[2*i+1],seg[2*i+2]);
    }

}
void update(ll a,ll b){
    a+=m;seg[a]=b;
    while(a){
        a=(a-1)/2;
        seg[a]=min(seg[2*a+1],seg[2*a+2]);
    }
}
ll ans(ll a,ll b){
    ll ret=1e18;a+=m;b+=m;
    while(1){
        if(a==b){
            ret=min(ret,seg[a]);
            break;
        }
        if(b==a+1){
            ret=min(ret,seg[a]);
            ret=min(ret,seg[b]);
            break;
        }
        if(a%2)a/=2;
        else{
            ret=min(ret,seg[a]);
            a/=2;
        }
        if(b%2){
            ret=min(ret,seg[b]);
            b/=2;b--;
        }
        else{b/=2;b--;}
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q,a,b,c;
    cin>>n>>q;
    segstart();
    for(int i=0;i<q;i++){
        cin>>c>>a>>b;
        if(c) cout << ans(a,b) <<endl;
        else update(a,b);
    }
    return 0;
}



Measured memory_bytes: 5540
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int N,M;
Graph G;
vector<int> color;

bool dfs(int v){
  int c = color[v];
  bool ok = true;
  for (int nv : G[v]){
    if (color[nv] == c) return false;
    if (color[nv] != -1) continue;
    color[nv] = 1 - c;
    ok &= dfs(nv);
  }
  return ok;
}

int main() {
  cin >>N >>M;
  G.assign(N, vector<int>());
  rep(i, M){
    int a,b; cin >>a >>b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  color.assign(N, -1);
  color[0] = 0;
  bool ok = dfs(0); // 二部グラフかどうか
  ll black = 0, white = 0;
  rep(i, N){
    if (color[i] == 0) white++;
    else black++;
  }
  ll res;
  if (ok){
    // 二部グラフなら辺の数は(0の数)*(1の数)になる
    res = black * white;
  }else{
    // 二部グラフでないなら任意の頂点間に辺が存在する
    res = (ll)N * (ll)(N-1) / 2LL;
  }
  cout <<res - M <<endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    cin >> n;
    
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll money = 1000;
    rep(i, n-1) {
        if(a[i] < a[i+1]) {
            money = (money/a[i])*a[i+1] + money%a[i];
        }
    }
    
    out(money);
    re0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


string s;

void solve()
{
    cin >> s;
    auto start = s.begin();
    auto end = prev(s.end());
    while(*start != 'A') start = next(start);
    while(*end != 'Z') end = prev(end);


    cout << distance(start, end) + 1 << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,a=300,sum=0,zero=0;
    cin>>n>>l;
    for(int i=1; i<=n; i++)
    {
        a=min(abs(i+l-1),a);
        if(a==0)
            zero++;
        sum+=(i+l-1);
    }
    if(zero!=0)
        cout<<sum<<endl;
    else if(zero==0&&sum>=0)
        cout<<sum-a<<endl;
    else
        cout<<sum+a<<endl;

}


Measured memory_bytes: 256
import itertools

a = int(input())

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ab = [[i,a//i] for i in md(a)]
abc = [sum(ab[i]) for i in range(len(ab))]

print(min(abc)-2)

Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <map>
using namespace std;

using ll = long long;

const ll MOD = 1000 * 1000 * 1000 + 7;

int main() {
    int N;
    cin >> N;

    vector<int> A(N);
    map<int, int> counter;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        counter[A[i]]++;
    }

    ll ans = 1;
    for (int i = N - 1; i >= 0; i -= 2) {
        if ((i == 0 && counter[i] != 1) || (i != 0 && counter[i] != 2)) {
            cout << 0 << endl;
            return 0;
        }
        ans *= counter[i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
h,w,k=map(int,input().split())
c=[]
for i in range(h):
    c.append(list(input()))
z=0
for i in range(h):
    for j in range(w):
        if c[i][j]=='#':
            z+=1
ans=0
for i in range(1<<h):
    for j in range(1<<w):
        tmp=0
        for ii in range(h):
            for jj in range(w):
                if (i&(1<<ii) or j&(1<<jj)) and c[ii][jj]=='#':
                    tmp+=1
        if tmp+k==z:
            ans+=1
print(ans)


Measured memory_bytes: 9136
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int N, M;
        cin >> N >> M;
        priority_queue<Int> pq;
        for (int i = 0; i < N; ++i) {
            Int val;
            cin >> val;
            pq.push(val);
        }

        for (int i = 0; i < M; ++i) {
            Int top = pq.top();
            pq.pop();

            Int nval = top / 2;
            pq.push(nval);
        }

        Int ans = 0;
        while (!pq.empty()) {
            Int top = pq.top();
            pq.pop();
            ans += top;
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 1000005

int n;
map<vector<int>, int > M;

int main()
{
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);

	vector<int> V;
	Rep(i, 3){
		int x;
		cin >> x;
		V.pb(x);
	}
	sort(all(V));
	M[V] = 1;
	int res = 0;

	while(1){
		bool ok = true;
		Rep(i, 3) if(V[i] & 1){
			ok = false;
		}

		if(!ok) break;
		res++;
		int x = V[0] / 2;
		int y = V[1] / 2;
		int z = V[2] / 2;

		vector<int> temp;
		temp.pb(x + y);
		temp.pb(y + z);
		temp.pb(x + z);
		sort(all(temp));
		if(M[temp]){
			cout << -1 << endl;
			return 0;
		}
		M[temp] = 1;
		V = temp;
	}
	cout << res << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;

  string S ,s;
 for(int i = 0; i < N; i++){
 cin >> S;
  
  if(S != "Y" ){
    s = "Three";
  }
  
  else{
    s = "Four";
    break;
  }
 }
  cout << s << endl;
}
   
 

Measured memory_bytes: 3636