akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct node{
  int x,y,z;
};

int main(){
  int n,m,i,j,k;
  long long x,y,z,ret=0,sum;
  vector<long long> v;
  cin >> n >> m;
  long long cake[n][3];
  for(i=0;i<n;i++){
    cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
  }
  for(i=0;i<8;i++){
    v.clear();
    for(j=0;j<n;j++){
      sum = 0;
      for(k=0;k<3;k++){
        if((i>>k)%2 == 0)sum+=cake[j][k];
        else sum-=cake[j][k];
      }
      v.push_back(sum);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    sum = 0;
    for(j=0;j<m;j++){
      sum+=v[j];
    }
    if(ret<sum)ret = sum;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;
public class Main {
    static void Roll(int[] a,int k,int b){
        a[0]=a[1];
        a[1]=a[k];
        a[k]=a[6];
        a[6]=a[b];
        a[b]=a[0];
    }
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] a = new int[7];
		for (int i = 1; i < 7; i++) {
			a[i] = scanner.nextInt();
		}

		char[] b = scanner.next().toCharArray();
		for (int i = 0; i < b.length; i++) {
		    if (b[i] == 'N') {
		        Roll(a,2,5);
		    }else if (b[i] == 'S') {
		        Roll(a,5,2);
		    }else if (b[i] == 'W') {
		        Roll(a,3,4);
		    }else{
		        Roll(a,4,3);
		    }
		}
		
		
		System.out.println(a[1]);
	}
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=30, M=(ll)1e6+10 ;
const int mod = 1e9+7 ;

// vl compute(string s){
//         vl has(s.length());
//         ll i;

//         for(i=0;i<s.length();i++){
//             if(i==0){
//                 has[i]=((s[i]-'a'+1))%mod;
//             }
//             else
//                 has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
//         }
//         return has;
// }

void print(ll n,ll a,ll b){
    ll i,j;
    string s="aeiou";
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cout << s[(i+j)%5];
        }
    }
}
int main(){
 ios_base::sync_with_stdio(0);
 ll n,k;
 cin >> n;
 ll a=n/100,b=n%100;
 if(a<=12 && b<=12 && a!=0 && b!=0)
  cout << "AMBIGUOUS\n";
 else if(a<=12 && a!=0)
  cout << "MMYY\n";
 else if(b<=12 && b!=0)
  cout << "YYMM\n";
 else
  cout << "NA\n";
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    double n, m;
    cin >> n >> m;
    double total = 0;
    vector<double> vec(n);
    for(int i = 0; i < n; i++){
        double x;
        cin >> x;
        total += x;
        vec[i] = x;
    }
    double min = total/(4*m); 
    int q = 0;
    for(double i:vec){
        if(i >= min )
        q++;
    }
    string ans = q >= m ? "Yes" : "No";
    cout << ans;
}









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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

long long n;
long long in[7];
int main()
{
	std::cin >> n;
	for (int i = 0; i < 5; ++i)
		std::cin >> in[i];

	long long ans = 0;
	long long carry = inf;
	for (int i = 0; i < 5; ++i)
		carry = std::min(carry, in[i]);

	std::cout << (n + carry - 1) / carry + 4 << std::endl;
	return 0;
}


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

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

    int i = 0;
    int q = 0;
    while(N >= q){
        i ++;
        q = pow(K,i);
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#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>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  ll a, b; cin >> a >> b; int end=-1, begin;
  rep(i, 61){
    if(((1LL<<(60-i)) & a) && ((1LL<<(60-i)) & b)){
      a-=(ll)pow(2, 60-i); b-=(ll)pow(2, 60-i); continue;
    }
    else if(!((1LL<<(60-i)) & a) && !((1LL<<(60-i)) & b)){
      continue;
    }
    else break;
  }
  if(a==0 && b==0){
    cout << 1 << endl; return 0;
  }
  //cout << a << " " << b << endl;
  //rep(i, 61){
    //if((1LL<<(60-i)) & a) cout << 1;
    //else cout << 0;
  //}
  //cout << endl;
  //rep(i, 61){
    //if((1LL<<(60-i)) & b) cout << 1;
    //else cout << 0;
  //}
  //cout << endl;
  rep(i, 61){
    if((1LL<<(60-i)) & b){
      begin = 60-i;
      for(int j=begin-1; j>=0; j--){
        if((1LL<<j) & b){
          end = j; break;
        }
      }
      if(end!=-1) break;
    }
  }
  ll ans = 0;
  ans+= ((ll)pow(2, begin) + (ll)pow(2, end+1));
  //cout << pow(2, end+1) << "2の" << endl;
  //cout << (ll)pow(2, begin) << " " << a << endl;
  //cout << (ll)pow(2, begin) - a << endl;
  //cout << ans << " " << a <<  endl;
  //cout << ans-a << "toriaezu" << endl;
    ll tmp = a;
    rep(i, end+1){
      tmp/=2;
    }
   //cout << begin << " " << end << endl;
    //cout << tmp << endl;
    //cout << (ll)pow(2, begin-end-1)-tmp-1 << endl;
    //cout << begin << " " << end << endl;
    //cout << ans-a << "doudoudou" << endl;
    ans+=((ll)pow(2, begin-end-1)-tmp-1)*(ll)pow(2, end+1);
    //cout << ((ll)pow(2, begin-end-1)-tmp-1)*(ll)pow(2, end+1) << endl;
    //cout << ans-a << "douakana" << endl;
    //cout << end+1 << endl;
    if(tmp!=0){
      ll tmpb = 0;
      rep(i, end+1){
        if((1LL<<i) & a) tmpb+=(ll)pow(2, i);
      }
      //cout << begin << " " << end << endl;
      //rep(i, 61){
        //if((1LL<<(60-i)) & tmpb) cout << 1;
        //else cout << 0;
      //}
      //cout << endl;
      //cout << end+1 << endl;
      //cout << (ll)pow(2, end+1) << endl;
      //cout << ans-a << "kakunin" << endl;
      ans+=(ll)pow(2, end+1) - (ll)tmpb;
      //cout << (ll)pow(2, end+1) - tmpb << endl;
    }
  //cout << ans << " " << a << endl;
  ans-=a;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll r, g, b;
    cin >> r >> g >> b;
    if ((10 * g + b) % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

ll f(ll x) { return x * (x + 1) / 2; }

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

    ll ans = 0;
    rep(i, n) ans += f(n - i);

    rep(i, n - 1) {
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (n + 1 - v);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int p[20];
int main() {
    int n;
    cin >> n;
    rep(i, n){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 2; i < n; i++){
        int q[3];
        q[0] = p[i -2];
        q[1] = p[i -1];
        q[2] = p[i];
        sort(q, q+ 3);
        if(q[1] == p[i-1]){
          ans++;
        }

    }
    cout << ans << endl;

}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

dai = max([a,b,c,d,e])
shou = min([a,b,c,d,e])

if (dai - shou) <= k:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n;
int t[4001],a[4001];
int b[4001];
int f[2001][2001];
int bit[4001];
inline void Add(int p,int x){for(;p<=n+n;p+=p&-p)bit[p]+=x;}
inline int Qur(int p){int A=0;for(;p;p-=p&-p)A+=bit[p];return A;}

int main(){ char s[3];
	scanf("%d",&n);
	F(i,1,n+n) scanf("%s%d",s,a+i), t[i]=*s=='B', b[t[i]*n+a[i]]=i;
	f[0][0]=0;
	F(i,0,n){
		memset(bit,0,sizeof bit);
		F(j,1,n+n) Add(j,1);
		F(j,1,i) Add(b[j],-1);
		F(j,i?0:1,n){
			if(j) Add(b[n+j],-1);
			f[i][j]=INF;
			if(i) f[i][j]=min(f[i][j],f[i-1][j]+Qur(b[i]));
			if(j) f[i][j]=min(f[i][j],f[i][j-1]+Qur(b[n+j]));
		}
	} printf("%d",f[n][n]);
	return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
int main(void){
    // Here your code !
    int a,b;
    scanf("%d %d",&a,&b);
    int p = a + b;
    if(p < 24)printf("%d\n",a+b);
    else if(p>=24)printf("%d\n",p-24);    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int main() {
#ifdef LOCAL
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string a, b;
    cin >> a >> b;
    char ans[sz(a) + sz(b)];
    memset(ans, '.', sizeof ans);
    for (int i = 1; i <= max(sz(a), sz(b)); i++) {
        ans[2 * i - 2] = a[i - 1];
        ans[2 * i - 1] = b[i - 1];
    }
    for (auto x : ans) cout << x;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  input=sys.stdin.buffer.readline
  h,w=map(int,input().split())
  s=[c>>3for _ in range(h)for c in input()]
  dp=[10001]*h*(w+1)
  dp[0]=5-s[0]
  for i in range(h):
    for j in range(w):
      k=i*(w+1)+j
      dpk=dp[k]
      sk=s[k]
      l=k+1
      t=dpk+(sk^s[l])
      if dp[l]>t:dp[l]=t
      if i+1<h:
        l=k-~w
        t=dpk+(sk^s[l])
        if dp[l]>t:dp[l]=t
  print(dp[-2]+1>>1)
main()

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int p[30];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b;i++)scanf("%d",p+i);
	int ret=0;
	for(int i=0;i<a;i++){
		int tmp=c;
		for(int j=0;j<b;j++){
			int s;scanf("%d",&s);
			tmp+=s*p[j];
		}
		if(tmp>0)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
using System.Linq;
using System;
using System.IO;

class Program
{
  static void Main(string[] args) =>
    new Program().solve();

  private void solve()
  {
    var n = int.Parse(Console.ReadLine());
    var ans = Console.ReadLine().Split(' ')
      .Select(s => counter(cnt:0, n:int.Parse(s))).Min();
      
    Console.WriteLine(ans);
  }

  private int counter(int cnt, int n)
  {
    if((n & 1) == 1) return cnt;
    else return counter(++cnt, n >> 1);
  }
}

Measured memory_bytes: 11348
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct Edge {
  int t,next;
  Edge() {}
  Edge(int a,int b):t(a),next(b) {}
};

Edge e[100005];
int head[100005];

int f[100005],now[100005];

void dfs(int x) {
  for(int i=head[x];i;i=e[i].next) dfs(e[i].t);
  int cnt=0;
  for(int i=head[x];i;i=e[i].next) now[++cnt]=f[e[i].t];
  sort(now+1,now+cnt+1);
  for(int i=1;i<=cnt;i++) f[x]=max(f[x],now[i]+(cnt-i+1));
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=2;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	e[i]=Edge(i,head[x]);
  	head[x]=i;
  }
  dfs(1);
  printf("%d\n",f[1]);
  return 0;
}

Measured memory_bytes: 6400
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main() {
	int n = 0;
	string x;
	n = 0;
	cin >> x;
	for (int i = 0; i < 4; i++) {
		if (x[i] == '+')
			n++;
		else
			n--;
	}
	cout << n << '\n';
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
CSF = tuple(tuple(map(int, input().split())) for _ in range(N - 1))

ans = [0] * N
for i in range(N):
    time = 0
    for j in range(i, N - 1):
        c, s, f = CSF[j]
        d = max(0, time - s)
        ride = (d + f - 1) // f
        time = s + ride * f + c
    ans[i] = time

print(*ans, sep="\n")

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
string S;
int counter = 0;
int counterCapital = 0;
int counterC = 0;

int main()
{
    cin >> S;
    if (S[0] == 'A')
        counter++;
    for (int i = 0; i < S.size(); i++)
    {
        if (isupper(S[i]))
            counterCapital++;
    }
    
    for (int i = 2; i < S.size()-1; i++)
    {
        if (S[i] == 'C')
            counterC++;
        
    }
    if (counterC ==1 && counter == 1&& counterCapital==2)
    {
        cout << "AC  \n";
    }
       
    else 
    {
        cout << "WA \n";

    }
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

d_o = defaultdict(int)
d_e = defaultdict(int)

for i in range(N):
    if i % 2:
        d_o[A[i]] += 1
    else:
        d_e[A[i]] += 1

l_d = sorted(list(d_o.items()), key=lambda x:x[1], reverse=True)
l_e = sorted(list(d_e.items()), key=lambda x:x[1], reverse=True)

if l_d[0][0] != l_e[0][0]:
    print(N - l_d[0][1] - l_e[0][1])
elif len(l_d) == len(l_e) == 1:
        print(N - max(l_d[0][1], l_e[0][1]))
elif len(l_d) == 1:
        ans = min(N - l_d[0][1] - l_e[1][1], N - l_e[0][1])
        print(ans)
elif len(l_e) == 1:
        ans = min(N - l_d[1][1] - l_e[0][1], N - l_d[0][1])
        print(ans)
else:
    ans = min(N-l_d[1][1]-l_e[0][1], N-l_d[0][1]-l_e[1][1])
    print(ans)

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

int main(void){
    int n; cin >> n;
    long long power=1;
    int mod=pow(10,9)+7;

    for(int i=1; i<=n; i++) power=(power*i)%mod;

    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    //a[i][j] := i + 1日目の活動。jは
    //0:A
    //1:B
    //2:C
    vvll a(N, vll(3));
    rep(i, N) cin >> a[i][0] >> a[i][1] >> a[i][2];

    //dp[i][j] := i日目に活動jを行ったときのi日目までの幸福度の総和の最大値
    vvll dp(N + 1, vll(3, -INF));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    rep(i, N)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                //次の日は作業j以外を行う。
                if (k == j) continue;

                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll ans = dp[N][0];
    chmax(ans, dp[N][1]);
    chmax(ans, dp[N][2]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11264
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限



def resolve():
    global g1
    global g2
    X,Y=(int(i) for i in input().split())
    if (2*X-Y)%3!=0 or 2*X-Y <0:
        print(0)
        return 
    if (2*Y-X)%3!=0 or 2*Y-X <0:
        print(0)
        return 
    a=(2*X-Y)//3
    b=(2*Y-X)//3

    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, a+b + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    print(cmb(a+b,a,mod))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 118764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans=0;
  rep(i,101) {
    if(a<=i&&i<b&&c<=i&&i<d) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        double answer = 0;
        for (int i=1;i<=n;i++){
            long instance = i;
            int count = 0;
            while (true){
                if (instance>=k) break;
                instance *= 2;
                count++;
            }
            answer += Math.pow(0.5,count)/n;
        }
        System.out.println(answer);
    }
}


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

int main(){
  int N;cin>>N;
  string W[N];for(int i=0;i<N;i++)cin>>W[i];
  int s=1,t=1;
  for(int i=0;i<N-1;i++){
    if(W[i][W[i].length()-1]!=W[i+1][0]){
      s=0;
      break;
    }
  }
  for(int i=1;i<N;i++){
    for(int j=0;j<i;j++){
      if(W[i]==W[j]){
        t=0;
        break;
      }
    }
  }
  if(s==t==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'a')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=5100;
//const ll Mod=1000000007;



ll dp[maxn];

int main()
{
    sync;
    int n;
    ll p,ans=0;
    cin>>n>>p;
    dp[0]=1;
    for(int i=1;i<n;i++)
    {
        for(int k=min(i,n-i+1),j=k;j<n;j++)
        {
            dp[j]=(dp[j]+dp[j-k])%p;
        }
    }
    for(int i=0;i<n;i++)
        ans=(ans+1ll*(n-i)*dp[i]%p)%p;
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,n) for(int i=a;i<(n);++i)
int main(){
	int n;long a,b;scanf("%d %ld %ld",&n,&a,&b);
	vector<int> x(n);long ans=0;
	scanf("%d",&x[0]);
	FOR(i,1,n){
		scanf("%d",&x[i]);
		long diff=x[i]-x[i-1];
		ans+=((a*diff>b)?b:a*diff);
	}
	printf("%ld\n",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=min((a), (b))

const int MOD=1000000007;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	ll ans;
	ans= k%2==0 ? a-b : b-a;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <utility>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int i = 0; i < n; i++)
    {
        vector<int> new_dp(3,0);
        vector<int> points(3);
        for(int j = 0; j < 3; j++)
            cin >> points[j];
        for(int k = 0; k < 3; k++)
        {
            for(int l = 0; l < 3; l++)
            {
                if(k != l)
                {
                    new_dp[l] = max(new_dp[l], dp[k]+points[l]);
                   // cout << new_dp[l]<<endl;
                }
            }
        }
        dp = new_dp;
    }
   /* for(int r = 0; r < 3; r++)
    {
        cout << dp[r]<<" ";
    }*/
    int m = dp[0];
    for(int o = 1; o < 3; o++)
    {
        m = max(m, dp[o]);
    }
    cout << m;
}

Measured memory_bytes: 256
#include <cstdio>  
#include <iostream>  
#include <cstring>  
#include <string>  
#include <cmath>  
#include <algorithm>  
#include <cstdlib>  
#include <utility>  
#include <map>  
#include <stack>  
#include <set>  
#include <vector>  
#include <queue>  
#include <deque>  
#include <sstream>  
#include <bitset>
#include<bits/stdc++.h>      
using namespace std;
int a[4][4];
int main(){
    for(int i = 1; i<= 3;i++) {
        for(int j = 1;j <= 3;j ++) {
            cin>>a[i][j];
        }
    }
    for(int k = -1000;k <= 1000;k++) {
        int a2,a3,b1,b2,b3;
        int a1 = k;
        b1 = a[1][1] - k;
        b2 = a[1][2] - k;
        b3 = a[1][3] - k;
        a2 = a[2][1] - b1;
        a3 = a[3][1] - b1;
        bool flg = false;
        if(a[2][2] != a2 + b2) flg = true;
        if(a[2][3] != a2 + b3) flg = true;
        if(a[3][2] != a3 + b2) flg = true;
        if(a[3][3] != a3 + b3) flg = true;
        if(!flg) {
            cout<<"Yes"<<endl;
			return 0;
        }

    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int as[N];
  int c = 0;
  for (int i = 0; i < N; i++) {
    cin >> as[i];
  }
  for (int i = 0; i < N; i++) {
    if ((i + 1) % 2 != 0 && as[i] % 2 != 0) {
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3628
ODD_OK = ['R', 'U', 'D']
EVEN_OK = ['L', 'U', 'D']

dance = gets.chop

odd_dance = dance.each_char.select.with_index { |_, i| i.even? }.uniq
even_dance = dance.each_char.select.with_index { |_, i| i.odd? }.uniq

if (odd_dance - ODD_OK).empty? && (even_dance - EVEN_OK).empty?
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
n=int(input())
import math
fac=math.factorial(n)
mod=10**9+7
ans=[0]*(n+1)
ans[0]=ans[1]=1
i=2
while i*i<=n:
    j=2
    while i*j<=n and ans[i]==0:
        ans[i*j]=1
        j+=1
    i+=1
v=[]
for i in range(n+1):
    if ans[i]==0:
        v.append(i)
total=1
count=0
for i in v:
    while fac%i==0:
        count+=1
        fac//=i
    total*=count+1
    count=0
print(total%mod)


Measured memory_bytes: 3064
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  long A, B, C; readf("%d %d %d\n", &A, &B, &C);
  long answer;

  void plusAB() { answer++; A++; B++; }
  void plusAC() { answer++; A++; C++; }
  void plusBC() { answer++; B++; C++; }

  long solve() {
    if (A%2 == B%2 && A%2 != C%2) plusAB;
    if (A%2 == C%2 && B%2 != C%2) plusAC;
    if (B%2 == C%2 && A%2 != C%2) plusBC;

    auto max = [A, B, C].reduce!(max);
    answer += (max - A) / 2;
    answer += (max - B) / 2;
    answer += (max - C) / 2;

    return answer;
  }

  solve().writeln;
}


Measured memory_bytes: 372
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int main() {
    int length, time_slot;
    queue<pair<string, int> > process;
    cin >> length >> time_slot;
    for (int i = 0; i < length; ++i) {
        string name;
        int time;
        cin >> name >> time;
        process.push(make_pair(name, time));
    }   

    int total_time = 0;

    while (!process.empty()) {
        pair<string, int> cur = process.front();
        process.pop();
        string name = cur.first;
        int left_time = cur.second;
        total_time += min(time_slot, left_time);
        if (left_time <= time_slot) {
            cout << name << " " << total_time << endl;
        } else {
            cur.second -= time_slot;
            process.push(cur);
        }   
    }   
    

    return 0;
}

Measured memory_bytes: 6168
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << 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...); }

int main()
{
	fio;
	int p, q, r;
	cin >> p >> q >> r;
	int s = p + q + r;
	int m = max(p, max(q, r));
	int ans = s - m;
	cout << ans << endl;
	return 0;
}

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

int N, S, K;
int A[1 << 18];

int main() {
	cin >> N >> K >> S;
	for (int i = 1; i <= K; i++) A[i] = S;
	for (int i = K + 1; i <= N; i++) {
		if (S == 1000000000) A[i] = 1;
		else A[i] = S + 1;
	} 

	for (int i = 1; i <= N; i++) {
		if (i >= 2) cout << " ";
		cout << A[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
import java.util.*; 
import java.io.*;

class Main {

  public static String StringPeriods(String str) {
    boolean flag = false;
    String ans = "";
    for(int i=0;i<str.length();i++){
      String temp = str;
      String substr = str.substring(0,i);
      temp = temp.replaceAll(substr, "");
      if(temp.equals("")) {
    	  flag = true;
    	  ans = substr;
    	  break;
      }
    }
    if(flag) {
    	str = ans;
    }else {
    	str = "-1";
    }
    // code goes here  
    return str;
  }

  public static void main (String[] args) {  
    // keep this function call here     
    Scanner sc = new Scanner(System.in);
    String S= sc.next();
    boolean flag = true;
    char[] c = S.toCharArray();
    int N=c.length;
    for(int i=0;i<N;i++) {
    	if(c[i]!=c[N-i-1]) {
    		flag = false;
    	}
    }
    c = S.substring(0,(S.length()-1)/2).toCharArray();
    N=c.length;
    for(int i=0;i<N;i++) {
    	if(c[i]!=c[N-i-1]) {
    		flag = false;
    	}
    }
    c = S.substring((S.length()+3-1)/2).toCharArray();
    N=c.length;
    for(int i=0;i<N;i++) {
    	if(c[i]!=c[N-i-1]) {
    		flag = false;
    	}
    }
   
    if(flag) {
    	System.out.println("Yes");
    	
    }else {
    	System.out.println("No");
    }
  }

}

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

int main(){
   int N, M;
   std::cin >> N >> M;
   std::vector<std::pair<long long, long long> > AB(N);
   long long A, B;
   for(int i=0; i<N; ++i){
      std::cin >> A >> B;
      AB[i] = std::make_pair(A,B);
   }
   std::sort(AB.begin(),AB.end());
   
   long long sum = 0;
   long long n = 0;
   for(int i=0; i<N; ++i){
      if(M-n>AB[i].second){
	 sum += AB[i].first * AB[i].second;
	 n += AB[i].second;
      }else{
	 std::cout << sum + AB[i].first*(M-n) << std::endl;
	 return 0;
      }
   }
   return -1;

}	


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

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

  char a[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w;j++){
      cin>>a[i][j];
    }
  }

  for(int i = 0; i < w+2; i++){
    cout<<'#';
  }
  
  cout<<endl;
  for(int i = 0; i < h; i++){
    cout<<'#';
    for(int j = 0; j < w; j++){
      cout<<a[i][j];
    }
    cout<<'#'<<endl;
  }
  for(int i = 0; i < w+2; i++){
    cout<<'#';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
a = []
b = []
a = gets.chomp.split("").map(&:to_i)
b = gets.chomp.split("").map(&:to_i)
#p a
#p b
if a.length > b.length
  puts "GREATER"
  exit
elsif b.length > a.length
  puts "LESS"
  exit
else
  for i in 0..a.length - 1
    if a[i] > b[i]
      puts "GREATER"
      exit
    elsif b[i] > a[i]
      puts "LESS"
      exit
    end
  end
end
puts "EQUAL"

Measured memory_bytes: 1788
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
int a,b;
main()
{
    while(cin>>a>>b,a+b)
    {
        pair<int,char>p[5];
        p[0].first=a+b;
        for(int i=0;i<5;i++)p[i].second='A'+i;
        for(int i=1;i<5;i++)
        {
            cin>>a>>b;
            p[i].first=a+b;
        }
        sort(p,p+5);
        cout<<p[4].second<<" "<<p[4].first<<endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second

const int INF = 1e9+5;


int main() {
	int n, w;
	cin >> n >> w;
	vector<int> we(n), v(n);
	forn(i, n) cin >> we[i] >> v[i];
	vector<vector<ll>> dp(n+1, vector<ll>(w+1));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= w; j++){
			if(j-we[i-1] >= 0)
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-we[i-1]]+v[i-1]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	ll ans = 0;
	forn(i, w+1)
		ans = max(ans, dp[n][i]);
	cout << ans << endl;
	return 0;

}



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

using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n;
char s[maxn];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	
	int pre = -1, ans = -1;
	for (int i = 1; i <= n; i++)
	{
		if (pre != s[i]) ans++, pre = s[i];
	}
		
	printf("%d\n", ans);
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char a[1005][1005];
int v[1005][1005];
int dis[1005][1005];
int sx,sy;
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
struct Node{
	int x,y;
};
queue<Node>q;
inline int calc(int x,int y){
	int res=x-1;
	res=min(res,y-1);
	res=min(res,n-x);
	res=min(res,m-y);
	return res;
}
int main(){
	memset(dis,0x3f3f3f3f,sizeof(dis));
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
			if(a[i][j]=='S'){
				q.push((Node){i,j});
				dis[i][j]=0;
			} 
		}
	while(!q.empty()){
		int x=q.front().x;
		int y=q.front().y;
		q.pop();
		v[x][y]=1;
		for(int i=0;i<4;i++){
			int xx=x+dx[i];
			int yy=y+dy[i];
			if(v[xx][yy]) continue;
			if(xx<1||xx>n||yy<1||yy>m) continue;
			if(a[xx][yy]=='#') continue;
			if(dis[xx][yy]>dis[x][y]+1){
				dis[xx][yy]=dis[x][y]+1;
				q.push((Node){xx,yy});
			}
		}
	}
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(dis[i][j]<=k){
				ans=min(ans,1+(calc(i,j)+k-1)/k);
			}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	forn(i, n) {
		int x;
		cin >> x;
		if(x >= k) cnt++;
	}
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 3624
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char


main :: IO ()
main = getLine >>= print . solve
solve :: String -> Int
solve s = length . filter id $ zipWith (/=) (take m s) (reverse s)
  where
    n = length s
    m = n `div` 2 + if even n then 0 else 1


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const int MAXN = 200005;
ll v[MAXN], w[MAXN], x[MAXN], y[MAXN];
ll fac[MAXN], invfac[MAXN];
ll inv[MAXN];
ll binom(ll a, ll b) {
	if (b < 0) return 0;
	if (b > a) return 0;
	return (((fac[a] * invfac[b]) % MOD) * invfac[a - b]) % MOD;
}
ll modex(ll a, ll p, ll m = MOD) {
	if (!p) return 1;
	if (p & 1) return a * modex(a, p - 1, m) % m;
	ll v = modex(a, p >> 1, m);
	return v * v % m;
}
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i % MOD;
	invfac[MAXN - 1] = modex(fac[MAXN - 1], MOD - 2);
	for (int i = MAXN - 2; i >= 0; --i)
		invfac[i] = invfac[i + 1] * (i + 1) % MOD;
	for (int i = 1; i < MAXN; ++i)
		inv[i] = invfac[i] * fac[i - 1] % MOD;
	int B, W;
	scanf("%d%d", &B, &W);
	ll half = (MOD + 1) / 2;
	ll p = 1;
	ll ws = 0, bs = 0;
	for (int i = 1; i <= B + W; ++i) {
		ll ans = (ws + (1 - ws - bs) * half) % MOD;
		if (ans < 0) ans += MOD;
		printf("%lld\n", ans);
		p = p * half % MOD;
		ws = (ws + binom(i - 1, W - 1) * p) % MOD;
		bs = (bs + binom(i - 1, B - 1) * p) % MOD;
	}
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int ans = 0;
  REP(i, 4){
    if(s[i] == '+') ans++;
    if(s[i] == '-') ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    rep(i, N - 1) {
        vector<int> ans;
        rep(j, i + 1, N) {
            int lv = 1;
            int a = j - i;
            while(a % 2 == 0) {
                a /= 2;
                lv++;
            }
            ans.pb(lv);
        }
        voutput(ans);
    }
    
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;	

int main() {
	int P,Q,R;
	cin>>P>>Q>>R;
	int ans = P+Q;
	ans = min(ans, Q+R);
	ans = min(ans, P+R);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

for i in range(1000):
    string = str(i)
    if len(string) != N:
        continue
    flag = True
    for j in range(M):
        if string[S[j] - 1] == str(C[j]):
            None
        else:
            flag = False
            break
    if flag:
        print(i)
        sys.exit(0)
print("-1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, x;
	scanf("%d", &n);
	scanf("%d", &x);
	int y = ilogb(x);
	vector<pair<long long, int>> all;
	if ((1 << y) == x) all.push_back({y, y}); else all.push_back({y + 1LL, y + 1});
	for (int i = 2; i <= n; ++ i) {
		scanf("%d", &x);
		y = ilogb(x);
		vector<int> l, r, m;
		vector<pair<long long, int>> bll;
		if ((1 << y) == x) {
			l.push_back(y);
			r.push_back(y);
			m.push_back(y);
		}
		else {
			l.push_back(y);
			r.push_back(y + 1);
			m.push_back(y + 1);
			l.push_back(y + 1);
			r.push_back(y);
			m.push_back(y + 1);
		}
		for (int i = 0; i < (int) l.size(); ++ i) {
			long long res = 1e18;
			for (auto p : all) {
				long long tot = p.first + m[i] - min(l[i], p.second);
				res = min(res, tot);
			}
			bll.push_back({res, r[i]});
		}
		all.swap(bll);
	}
	long long ans = 1e18;
	for (auto p : all) ans = min(ans, p.first);
	printf("%lld\n", ans);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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

    if(D == 0){
        if(N == 100)cout << 101 << endl;
        else cout << N << endl;
    }
    else if(D == 1){
        if(N == 100){
            cout << 10100 << endl;
        }
        else{
            cout << 100 * N << endl;
        }
    }
    else{
        if(N == 100)cout << 1010000 << endl;
        else cout << 10000 * N << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {
	while(1) {
		int h,w; cin >> h >> w;
		if (h + w == 0) break;
		int diag = h * h + w * w;

		
		int answ = 150;
		int ansh = 0;
		int min_diag = 150 * 150 * 2;

		for (int i = 1; i <= 150; i++) {
			for (int j = i + 1; j <= 150; j++) {
				int d = i * i + j * j;
				if (diag < d or (diag == d and h < i)) {
					if (d < min_diag) {
						min_diag = d;
						ansh = i;
						answ = j;
					}
				}
			}
		}
		cout << ansh << " " << answ << endl;
	}

	return 0;
}



Measured memory_bytes: 3064
import math
s=int(input())
if s!=2:
  if s%2==0:
    s+=1
def prime(x):
  if x==2:
    return True
  else:
    for i in range(3,int(math.sqrt(s))+1,2):
      if s%i==0:
        return False
    return True

while True:
  if prime(s):
    print(s)
    break
  s+=2

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> a >> b;
    cout << a*b << el;
    return 0;
}


Measured memory_bytes: 3636