akhauriyash/Code-Regression huggingface dataset:
import math

def IsP(n):
    s = int(math.ceil(math.sqrt(x)))
    if(n<=1):
        return 0
    elif(n==2):
        return 1
    else:
        for i in range(2,s+1):
            if(n%i == 0):
                return 0
        return 1

x = int(input())

while(IsP(x)==0):
    x +=1
print(x)


Measured memory_bytes: 38384
import queue

d = input().split(" ")

num = int(d[0])          # num of input data
threshold = int(d[1])

input_data = []
for i in range(num):
    input_data.append(input())

total_time = 0

# put all data in queue
q = queue.Queue()
for data in input_data:
    q.put(data)

while not q.empty():
    p = q.get().split(" ")
    p_name = p[0]
    p_time = int(p[1])

    # processing is not completed
    if p_time > threshold:   # 
        q.put(p_name + " " + str(p_time - threshold))
        total_time += threshold
    # processing is completed
    else:
        total_time += p_time
        print(p_name + " " + str(total_time))




Measured memory_bytes: 11852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n,m;
  cin >> n >> m;
  vi x(m);
  rep(i,m) cin >> x[i];
  sort(ALL(x));
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  vi y(m-1);
  rep(i,m-1){
    y[i] = x[i+1] - x[i];
  }
  sort(ALL(y));
  ll ans  = 0;
  rep(i,m-n){
    ans += y[i];
  }
  cout << ans << endl;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll N=50;
    ll c[N];memset(c,0,sizeof(c));
    rep(i,0,n-1){
        rep(j,0,N-1){
            if((a[i]>>(N-1-j))&1)c[j]++;
        }
    }
    //rep(i,0,N-1)cout<<c[i]<<" ";cout<<endl;
    ll dp[N][2];memset(dp,-1,sizeof(dp));
    dp[0][1]=0;
    rep(i,1,N-1){
        ll p=1ll<<(N-1-i);
        if((k>>(N-1-i))&1){
            if(dp[i-1][1]>=0)dp[i][1]=dp[i-1][1]+(n-c[i])*p;//Xとして1使う
        }else{
            if(dp[i-1][1]>=0)dp[i][1]=dp[i-1][1]+c[i]*p;//Xとして1使わない
        }
        if((k>>(N-1-i))&1){
            if(dp[i-1][0]>=0)dp[i][0]=dp[i-1][0]+max(c[i],(n-c[i]))*p;
            if(dp[i-1][1]>=0)Max(dp[i][0],dp[i-1][1]+c[i]*p);
        }else{
            if(dp[i-1][0]>=0)dp[i][0]=dp[i-1][0]+max(c[i],(n-c[i]))*p;
        }
        Max(dp[i][1],dp[i][0]);
    }
    /*
    rep(j,0,1){
        rep(i,0,N-1)cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    */
    cout<<dp[N-1][1]<<endl;
    return 0;
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i, n)cin >> t[i];
    sort(all(t));
    ll ans = 0, ok = -1, num = 0;
    rep(i, n){
        if(t[i] > ok || num >= c){
            ans++;
            ok = t[i] + k;
            num = 0;
        }
        num++;
    }
    cout << ans << endl;
}      

Measured memory_bytes: 1024
object Main {
  var mul_limit = 12000
  var depth_limit = 7
  def dfs(p: Int, q: Int, depth: Int, sub: Int, mul: Int): Int = {
    p match {
      case 0 => return 1
      case _ =>
        var ret = 0
        for(i <- (sub to mul_limit).takeWhile(x => mul * x <= mul_limit &&
          (depth_limit - depth) * q >= p * x) if p * i >= q) {
          ret += dfs(p * i - q, q * i, depth + 1, i, mul * i)
        }
        return ret
    }
  }
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var p, q = sc.nextInt
    mul_limit = sc.nextInt
    depth_limit = sc.nextInt
    while(p != 0) {
      println(dfs(p, q, 0, 1, 1))
      p = sc.nextInt
      q = sc.nextInt
      mul_limit = sc.nextInt
      depth_limit = sc.nextInt
    }
  }
}

Measured memory_bytes: 261948
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  ll n, m, ans = 1; cin >> n >> m;
  for(ll i = 1; i <= sqrt(m) + 2; i++){
    if(m % i == 0){
      if(m / i >= n) ans = max(ans, i);
      if(i >= n) ans = max(ans, m / i);
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vd a;

int main(){
	cin>>n;
	a=vd(n);
	for(auto &i:a) cin>>i;
	sort(a.begin(),a.end());
	double res=a[0];
	for(int i=1;i<n;i++) res=(res+a[i])/2;
	cout<<syosu(9)<<res<<endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

int main(){

	int n, k;cin >> n >> k;
	vector<P> v;
	REP(i,n){
		int a;cin >> a;
		v.EB(a, i);
	}

	vector<int> ans;

	int pre = -1;
	int late;
	REP(i,k+1){
		sort(ALL(v),greater<P>());
		REP(j,n){
			if(v[j].SE != pre){
				ans.PB(v[j].SE);
				late = v[j].SE;
				v[j].FI--;
			}
		}
		pre = late;
	}

	REP(i,n)if(v[i].FI < 0){
		cout << -1 << endl;
		return 0;
	}

	cout << ans.size() << endl;
	REP(i,ans.size())cout << ans[i] + 1 << " ";cout << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
flag = False
num = 0
while True:
    for i in range(len(li)):
        if li[i]%2 == 0:
            li[i] = li[i]//2
            if i == n-1:   
                flag = True
                num += 1
        else:
            print(num)
            exit()

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  int a,b,c,t;
  scanf("%d%d",&a,&b);
  if(a>b){
    t=a;
    a=b;
    b=t;  }
    c=b/a;
   // printf("%d%d",a,b);
    if(c>=2)
        printf(":(");
    else printf("Yay!");


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }



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

	int n; cin >> n;
	string s; cin >> s;

	map<char, int> left, right;

	for(int i=0; i<n; ++i) ++right[s[i]];
	int ans = 0;

	for(int i=0; i<n; ++i){
		++left[s[i]];
		--right[s[i]];

		int tmp = 0;
		for(char c='a'; c<='z'; ++c) if(left[c]>0 && right[c]>0) ++tmp;
		chmax(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}


int main() {
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[i + n / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
class UF{
public:
  int o[200100];
  int u[200100];
  UF(int n){
    for(int i=0;i<n;i++){
      o[i]=-1;
      u[i]=i;
    }
  }
  int root(int s){
    while(o[s]>=0)
      s=o[s];
    return u[s];
  }
  void merge(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    o[x]+=o[y];
    o[y]=x;
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int main(){
  int n;
  while(cin>>n,n){
    UF uni(26);
    int alfaf[26]={};
    int alfae[26]={};
    for(int i=0;i<n;i++){
      string str;cin>>str;
      if((str[0]!=str[str.size()-1])){
	uni.merge(str[0]-'a',str[str.size()-1]-'a');
	alfaf[str[0]-'a']++;
	alfae[str[str.size()-1]-'a']++;
      }
    }
    int flag=0;
    for(int i=0;i<26;i++){
      if(uni.o[i]<0&&uni.o[i]!=-1)
	flag++;
    }
    bool flag2=true;
    for(int i=0;i<26;i++){
      if(alfaf[i]!=alfae[i]){
	flag2=false;
	//cout<<alfaf[i]<<" "<<alfae[i]<<endl;
	break;
      }
    }
    if(flag<2&&flag2==true)
      cout<<"OK"<<endl;
    else
      cout<<"NG"<<endl;
  }
  return 0;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}
 int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;
int A[222222];

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];
	int X=0;
	rep(i,N)X^=A[i];

	rep(i,N){
		if(i)cout<<" ";
		cout<<(A[i]^X);
	}
	cout<<endl;
    return 0;
}


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

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

    int n;
    vector<char> s;
    while(N>0){
        int n=N%26;
        if(n==0) n=26;
        s.push_back(char('a'+n-1));
        N=(N-1)/26;
        if(N==0) break;
    }

    rep(i, s.size()) cout<<s[s.size()-i-1];

    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

type item struct {
	index int
	A     int
	B     int
}

type priorityQueue []*item

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i].B > pq[j].B
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *priorityQueue) Push(x interface{}) {
	item := x.(*item)
	item.index = len(*pq)
	*pq = append(*pq, item)
}

func (pq *priorityQueue) Pop() interface{} {
	n := len(*pq)
	item := (*pq)[n-1]
	item.index = -1
	*pq = (*pq)[0 : n-1]
	return item
}

func main() {
	input := bufio.NewReader(os.Stdin)

	var N, M int
	fmt.Fscanf(input, "%d %d\n", &N, &M)
	A := make([]int, N)
	B := make([]int, N)
	for n := 0; n < N; n++ {
		fmt.Fscanf(input, "%d %d\n", &A[n], &B[n])
	}

	m := make([][]int, M+1)
	for i := range m {
		m[i] = make([]int, 0)
	}
	for n := 0; n < N; n++ {
		if A[n] <= M {
			m[A[n]] = append(m[A[n]], n)
		}
	}

	pq := make(priorityQueue, 0)
	heap.Init(&pq)
	var ans int
	for i := 1; i <= M; i++ {
		for _, n := range m[i] {
			item := &item{
				A: A[n],
				B: B[n],
			}
			heap.Push(&pq, item)
			heap.Fix(&pq, item.index)
		}
		if pq.Len() > 0 {
			x := heap.Pop(&pq)
			item := x.(*item)
			ans += item.B
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 12800
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


s = IS()
if s.count('N') > 0 and s.count('S') == 0 or \
        s.count('N') == 0 and s.count('S') > 0 or \
        s.count('E') > 0 and s.count('W') == 0 or \
        s.count('E') == 0 and s.count('W') > 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 68204
#include<bits/stdc++.h>
using namespace std;
/*Sawal nahi hone wala phir bhi kar lo ek try*/
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
const long long mod = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;


ll powMod(ll x,ll y)            {ll p=1; while(y){if(y%2){p=(p*x)%mod;} y/=2; x=(x*x)%mod;} return p;}
ll invMod(ll x)                 {return powMod(x,mod-2);}
ll gcd(ll a, ll b)              {return b == 0 ? a : gcd(b, a % b);}
ll nCr(ll n, ll r)              { if(n<r)return 0;ll nfac = 1;ll dfac = 1;for(ll i=n-r+1;i<=n;i++){nfac = (nfac*i)%mod;}for(ll i=1;i<=r;i++){dfac = (dfac*invMod(i))%mod;}return (nfac*dfac)%mod;}

int solve()
{
    int s,w;
    cin>>s>>w;
    if(s>w)
    {
        cout<<"safe";
    }
        else
        {
            cout<<"unsafe";
        }
        
   return 0;    
}

int main()
{
    fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

Measured memory_bytes: 3648
def A(x):
    mod=1000000007
    return(x%mod)
    
def B(a,b,mod):
    if b==1:
        return a
    elif b%2==0:
        a_2=A(a**2)
        b_2=b//2
        return A(B(a_2,b_2,mod))
    else:
        a_2=A(a**2)
        b_2=(b-1)//2
        return A(B(a_2,b_2,mod)*a)
        
mod=1000000007
m,n=map(int,input().split())

print(B(m,n,mod))


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

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; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  char C;
  cin>>C;
  C++;
  cout<<C<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <map>

int main(){
  int A, B;
  scanf("%d", &A);
  scanf("%d", &B);
  if (A<10 && B<10){
    printf("%d\n",A*B);
  } else {
    printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 256
N,M,Q = map(int,input().split())
num = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    l,r = list(map(int,input().split()))
    l -= 1
    r -= 1
    num[l][r] += 1

for i in range(N-1,0,-1):
    for j in range(N):
        num[i-1][j] += num[i][j]
for i in range(N):
    for j in range(N-1):
        num[i][j+1] += num[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(num[p-1][q-1])

Measured memory_bytes: 9584
mod=10**9+7
n, m = map(int, input().split())
ai={}

for i in range(m):
    ai.setdefault(int(input()), 0)
#print(ai)

dp={}
for i in range(n+1):
    dp.setdefault(i, 0)

dp[0]=1
if 1 in ai:
    dp[1]=0
else:
    dp[1]=1

for i in range(2,n+1):
    if i in ai:
        continue
    dp[i]=(dp[i-1]+dp[i-2])%mod

#print(dp)
print(dp[n])


Measured memory_bytes: 27360
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    ll n,k,q; cin>>n>>k>>q;
    int a[q];
    rep(i,q){
        cin >> a[i];
        a[i]--;
    }
    
    int b[n]; rep(i,n) b[i] = k-q;
    rep(i,q) b[a[i]]++;

    rep(i,n){
        if(b[i]>0) cout << "Yes" << ln;
        else cout << "No" << ln;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n, a, b; cin >> n >> a >> b;
  if (n == 1 && a != b || a > b) {
    cout << 0 << '\n';
    return 0;
  }
  cout << (b - a) * (n - 2) + 1 << '\n';
  return 0;
}


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




int H, W, K;
string A[808];
//-----------------------------------------------------------------
int vis[808][808];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
void bfs(int sx, int sy) {
    queue<int> que;

    vis[sy][sx] = 1;
    que.push(sy * 1010 + sx);
    rep(k, 0, K) {
        queue<int> nque;
        while (!que.empty()) {
            int q = que.front(); que.pop();
            int y = q / 1010, x = q % 1010;

            rep(i, 0, 4) {
                int xx = x + dx[i];
                int yy = y + dy[i];
                if (xx < 0 || W <= xx) continue;
                if (yy < 0 || H <= yy) continue;
                if (A[yy][xx] == '#') continue;
                if (vis[yy][xx]) continue;

                vis[yy][xx] = 1;
                nque.push(yy * 1010 + xx);
            }
        }
        swap(nque, que);
    }
}
//-----------------------------------------------------------------
int main() {
    cin >> H >> W >> K;
    rep(y, 0, H) cin >> A[y];

    int sx, sy;
    rep(y, 0, H) rep(x, 0, W) if (A[y][x] == 'S') sx = x, sy = y;

    if (sx == 0 || sx == W - 1 || sy == 0 || sy == H - 1) {
        printf("0\n");
        return 0;
    }

    bfs(sx, sy);

    int ans = 1010101010;
    rep(y, 0, H) rep(x, 0, W) if (vis[y][x]) {
        int up = y;
        int down = H - 1 - y;
        int left = x;
        int right = W - 1 - x;

        int d = min(min(up, down), min(left, right));
        if (d == 0) ans = 1;

        int a = d / K;
        if (d % K) a++;
        ans = min(ans, a + 1);
    }
    cout << ans << endl;
}

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

int main() {
   int h, a;
   cin >> h >> a;

    int i = 1;
   while(true) {
       if (h <= i * a) break;
       i++;
   }
   cout << i << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<functional>
#include<cassert>
using namespace std;


string n;
int a[4];
bool dfs(int i, int ans) {
	if (i == 4 && ans == 7) { 
		return true; 
	}
	if (i == 4) {
		return false;
	}

	if (dfs(i + 1, ans + n[i] - '0') == true) { 
		a[i] = 1;
		return true;
	}
	if (dfs(i + 1, ans - n[i] + '0') == true) {
		a[i] = 0;
		return true;
	}

	return false;
}

int main(void) {
	cin >> n;
	if (dfs(0, 0)) {
		for (int i = 0; i < 4; i++) {
			if (i == 3) {
				cout << n[i]<<"=7";
				break;
			}
			if (a[i+1] == 1) {
				cout << n[i]<< '+' ;
			}
			else {
				cout << n[i] << '-';
			}
		}
	}
	else {
		cout << "false";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll N, H, W;
	cin >> N >> H >> W;

	vll A(N), B(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
	}



	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (A[i] >= H && B[i] >= W)
		{
			ans++;
		}


	}

	cout << ans << endl;





}





Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
// clang-format on

main {
  int a, b;
  cin >> a >> b;
  cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, _, w) = scan!(i64, i64, i64);
    let arr = scan!(i64;;);
    let last = arr.last().unwrap();
    if n == 1 {
        println!("{}", (last - w).abs());
        return;
    }

    let last_prev = arr[arr.len() - 2];

    println!(
        "{}",
        vec![(last - w).abs(), (last_prev - last).abs()]
            .iter()
            .max()
            .unwrap()
    )
}


Measured memory_bytes: 4352
def Z_algorithm(S):
    l=len(S)
    A=[0]*l
    A[0]=l
    i=1; j=0
    while i<l:
        while i+j<l and S[j]==S[i+j]:
            j+=1
        if not j:
            i+=1
            continue
        A[i]=j
        k=1
        while l-i>k<j-A[k]:
            A[i+k]=A[k]
            k+=1
        i+=k; j-=k
    return A

def main():
    n=int(input())
    S=input()
    ans=0
    for i in range(1,n):
        s=S[:i]
        t=S[i:]
        l=len(t)
        T=t+'-'+s
        Z=Z_algorithm(T)
        #print(i,l,T,Z,ans)
        ans=max(ans,max(Z[l:]))
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 61532
#include <bits/stdc++.h>
using namespace std;
char s[100002];
int dp[100002];
int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        if(i >= 5){
            if(s[i-4] == 'd' && s[i-3] == 'r' && s[i-2] == 'e' && s[i-1] == 'a' && s[i] == 'm'){
                dp[i] |= dp[i-5];
            }
            if(s[i-4] == 'e' && s[i-3] == 'r' && s[i-2] == 'a' && s[i-1] == 's' && s[i] == 'e'){
                dp[i] |= dp[i-5];
            }
        }
        if(i >= 6){
            if(s[i-5] == 'e' && s[i-4] == 'r' && s[i-3] == 'a' && s[i-2] == 's' && s[i-1] == 'e' && s[i] == 'r'){
                dp[i] |= dp[i-6];
            }   
        }
        if(i >= 7){
            if(s[i-6] == 'd' && s[i-5] == 'r' && s[i-4] == 'e' && s[i-3] == 'a' && s[i-2] == 'm' && s[i-1] == 'e' && s[i] == 'r'){
                dp[i] |= dp[i-7];
            }   
        }
    }
    if(dp[n]) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n;cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  sort(a.begin(),a.end());
  int l=-1,r=n;
  while(r>l+1){
    int m=(l+r)/2;
    long long s=0;
    for(int i=0;i<=m;++i){
      s+=a[i];
    }
    bool ok=true;
    for(int i=m+1;i<n;++i){
      if(a[i]>2*s)ok=false;
      s+=a[i];
    }
    if(ok)r=m;
    else l=m;
  }
  cout<<n-r<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;i++)
const ll N=5e5+10;
static ll dat[N];
void init(){
    rep(0,i,N)dat[i]=0;
}
void add(ll i,ll x){
    for(;i<N;i+=i&-i)dat[i]+=x;
}
ll sum(ll i){
    ll res=0;
    for(;i>0;i-=i&-i)res+=dat[i];
    return res;
}
ll rangesum(ll l,ll r){
    return sum(r)-sum(l-1);
}
static ll n,q,c[N],ans[N],a[N];
static vector<ll>ql[N],qid[N];
int main(void){
    cin>>n>>q;
    rep(1,i,n+1)cin>>c[i];
    rep(0,i,q){
        ll l,r;
        cin>>l>>r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }
    init();
    rep(0,i,N)a[i]=0;
    rep(1,i,n+1){
        if(a[c[i]]>0)add(a[c[i]],-1);
        add(i,+1);
        a[c[i]]=i;
        rep(0,j,ql[i].size()){
            ans[qid[i][j]]=rangesum(ql[i][j],i);
        }
    }
    rep(0,i,q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 62692
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

// [ith_digit][bound][no_of_non_zero_digits]
// [100][2][100] * 10
const int maxn = 100+5;
int dp[maxn][2][maxn],n,k;
string s;
int solve(int i,int bnd,int cnt){
	if( i == n )return cnt == k;
	int &ans = dp[i][bnd][cnt];
	if( ans != -1 )return ans;
	ans = 0;
	if(bnd){
		for(int d=0;d<s[i]-'0';d++){
			ans+=solve(i+1,0,cnt+(d!=0));
		}
		ans+=solve(i+1,1,cnt+(s[i]-'0'!=0));
	}else{
		for(int d=0;d<10;d++){
			ans+=solve(i+1,0,cnt+(d!=0));
		}
	}
	return ans;
}
int32_t main(){
	IOS
	memset(dp,-1,sizeof(dp));
	cin>>s>>k;n=s.length();
	cout<<solve(0,1,0);
	
 }
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 3800
N = int(input())
lis = [i for i in range(2,N+1) if i%2 == 1]
ans2=0
check =0
for one in lis:
    Prime = []
    count=[]
    t = 0
    ans1 =1
    for k in range(2,one+1):
        while(one % k)==0:
            one //= k
            if(k in Prime):
                count[Prime.index(k)]+=1
            else:
                Prime.append(k)
                count.append(1)
                t +=1
    for j in range(0,t):
        ans1 *= (count[j] + 1)
    if(ans1 == 8):
        ans2 +=1
print(ans2)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    ll A, B;
    cin >> A >> B;
    cout << A / __gcd(A, B) * B << endl;
}

Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Red or Blue
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  int rn = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R') rn++;

  if (rn * 2 > n) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;

const int MAX_N = 100005;
const double eps = 1e-9;

typedef long long i64;

int N, A[MAX_N], B[MAX_N], C[MAX_N], id[MAX_N];

bool cmp(int x, int y) {
  //return 1.0 * A[x] / B[x] < 1.0 * A[y] / B[y];
  int flag = 1;
  if (B[x] < 0) flag = -flag;
  if (B[y] < 0) flag = -flag;
  return 1LL * flag * A[x] * B[y] < 1LL * flag * A[y] * B[x];
}

double P[MAX_N];

bool cmp2(int x, int y) {
  return P[x] < P[y];
}

int val[MAX_N], sum[MAX_N], idx[MAX_N];

void update(int x, int v) {
  for (; x <= N; x += x & -x)
    sum[x] += v;
}

int ask(int x) {
  int res = 0;
  for (; x; x -= x & -x)
    res += sum[x];
  return res;
}

i64 calc(double mid) {
  
  for (int i = 1; i <= N; ++i) {
    P[i] = (C[id[i]] - mid * A[id[i]]) / B[id[i]];
    idx[i] = i;
  }

  sort(idx + 1, idx + N + 1, cmp2);
  
  memset(sum, 0, sizeof sum);
  i64 num = 0;
  
  for (int i = 1; i <= N; ++i) {
    num += ask(N - idx[i] + 1);
    update(N - idx[i] + 1, 1);
  }

  return num;
}

double work() {
  double l = -300000000, r = 300000000;
  
  for (int i = 1; i <= N; ++i)
    id[i] = i;
  sort(id + 1, id + N + 1, cmp);

  i64 tot = 1LL * N * (N - 1) / 2;

  for (int i = 0; i <= 70; ++i) {
    double mid = (l + r) / 2;
    if (calc(mid) * 2 < tot) l = mid;
    else r = mid;
  }
  return l;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d%d%d", &A[i], &B[i], &C[i]);

  double X = work();

  for (int i = 1; i <= N; ++i)
    swap(A[i], B[i]);
  double Y = work();

  printf("%.10lf %.10lf\n", X, Y);
  
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i + 1 == p[i]) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long
int main()
{
    ll int n;
    cin>>n;
    vector<ll int> v[n+1];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            int l;
            cin>>l;
            v[i].push_back(l);
        }
    }
    for(int i=n-2;i>=0;i--)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                v[i][0]+=max(v[i+1][1],v[i+1][2]);
            }
            else if(j==2)
            {
                v[i][2]+=max(v[i+1][1],v[i+1][0]);
            }
            else
               v[i][1]+=max(v[i+1][0],v[i+1][2]);
        }
    }

      ll int miny=INT_MIN;
        for(int j=0;j<3;j++)
        {
            if(v[0][j] > miny)
            miny=v[0][j];
        }
        cout<<miny<<endl;
        //cout<<endl;


}


Measured memory_bytes: 7296
h, w, k = map(int,input().split())
c = []
for i in range(h):
    r = []
    s = input()
    for j in s:
        if j == '.':
            r.append(0)
        else:
            r.append(1)
    c.append(r)

ans = 0

from copy import deepcopy
import numpy as np

for b in range(2**(h+w)):
    m = deepcopy(c)
    key = bin(b)[2:].zfill(h+w)
    for row in range(h):
        if key[:h][row] == '1':
            for col in range(w):
                m[row][col] = 0
    for col in range(w):
        if key[h:][col] == '1':
            for row in range(h):
                m[row][col] = 0
    if np.sum(m) == k:
        ans += 1

print(ans)

Measured memory_bytes: 27276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}

signed  main(){
	int t=1;
	//cin>>t;
	while(t--) {
		int n,k;
		cin>>n>>k;
		vi h(n);
		int ct=0;
		rep(i,n) cin>>h[i];
		rep(i,n) {
			if(h[i]>=k) ct++;
		}
		cout<<ct<<endl;	

	}
	return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define mid  ((l+r)>>1)
using namespace std;
const int maxn = 500005;
int a[maxn];
struct node{
    int num;
    int l,r;
}seg[maxn*80];
int root[maxn];
int cnt ;
void build(int &now,int l,int r){
    now=++cnt;
    seg[now].num=0;
    if(l==r)
        return ;
    build(seg[now].l,l,mid);
    build(seg[now].r,mid+1,r);
}
void upd(int &now,int pre,int l,int r,int pos,int val){
    now = ++cnt;
    seg[now]=seg[pre];
    seg[now].num+=val;
    if(l==r)
        return;
    if(pos<=mid)
        upd(seg[now].l,seg[pre].l,l,mid,pos,val);
    else
        upd(seg[now].r,seg[pre].r,mid+1,r,pos,val);
}
int query(int now,int l,int r,int L,int R){
    if(L<=l&&R>=r){
        return seg[now].num;
    }
    int ans= 0 ;
    if(mid>=L)
        ans+=query(seg[now].l,l,mid,L,R);
    if(mid<R)
        ans+=query(seg[now].r,mid+1,r,L,R);
    return ans;
}
map<int,int>mm;
int tmp;
int main(){
    cnt = 0 ;
    int n,q;
    scanf("%d%d",&n,&q);
    build(root[0],1,n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(mm[a[i]]){
            upd(root[i],root[i-1],1,n,mm[a[i]],-1);
            upd(root[i],root[i],1,n,i,1);
        }
        else{
            upd(root[i],root[i-1],1,n,i,1);
        }
        mm[a[i]]=i;
    }
    while(q--){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",query(root[r],1,n,l,r));
    }
}


Measured memory_bytes: 253408
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<cstdint>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
int main(){
      ll a,b;
      ll x;
      cin>>a>>b>>x;
      a=((a+x-1)/x)*x;
      b=(b/x)*x;
      cout<<((b-a)/x)+1<<endl;
      return 0;
}

Measured memory_bytes: 256
N,M,R = map(int,input().split())
R = list(map(int,input().split()))
dp = [[float("INF")]*(N+1) for _ in range(N+1)]
for i in range(N+1):
    dp[i][i] = 0

for _ in range(M):
    a,b,c = map(int,input().split())
    dp[a][b] = c
    dp[b][a] = c

for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            dp[j][k] = min(dp[j][k],dp[j][i]+dp[i][k])

candidate = []
def dfs (r,cost,path=set()):
    path.add(r)
    if len(path) == len(R):
        candidate.append(cost)
    else:
        for nx in R:
            if nx not in path:
                dfs(nx,cost+dp[r][nx],path)
    path.remove(r)

for r in R:
    dfs(r,0)
print(min(candidate))



Measured memory_bytes: 73360
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, m; cin >> n >> m;
	n--, m--;
	cout << n*m << endl;
}

Measured memory_bytes: 256
#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)++)
ll INF = 1LL << 50;

void solve(long long N, long long T, long long A, std::vector<long long> H){
    vector<double> a(N);
    rep(i, N){
        a[i] = T - 0.006*H[i];
    }
    double best = INF;
    ll ans;
    rep(i, N){
        if(abs(a[i] - A)< best){
            ans = i;
            best = abs(a[i] - A);
        }
    }
    cout << ans + 1 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, T, A, std::move(H));
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------
int n, q;

vector<vector<int>> g;


ll ans[200100] = {0};

ll l[200100] = {0};

ll counter = 0;

void dfs(int now){
    counter += l[now];
    for(int i = 0; i < g[now].size(); i++){
        int next = g[now][i];
        dfs(next);
    }
    ans[now] += counter;
    counter -= l[now];
}

int main(void){
    
    cin >> n >> q;

    g.resize(n);

    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
    }

    vector<ll> p(q), x(q);
    for(int i = 0; i < q; i++){
        cin >> p[i] >> x[i];
        p[i]--;
        l[p[i]] += x[i];
    }

    dfs(0);
    
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
}

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


int main(){
    int n,m,ans=1e9,a,sum;
    cin>>n>>m;
    int d[m][m],c[3][m];
    rep(i,3)rep(j,m)c[i][j]=0;
    rep(i,m)rep(j,m)cin>>d[i][j];
    rep(i,n)rep(j,n){
        cin>>a;
        c[(i+j)%3][a-1]++;
    }
    rep(i,m)rep(j,m)rep(k,m){
        if(i==j||j==k||k==i)
            continue;
        sum=0;
        rep(l,m)
            sum+=d[l][i]*c[0][l];
        rep(l,m)
            sum+=d[l][j]*c[1][l];
        rep(l,m)
            sum+=d[l][k]*c[2][l];
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256