akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int odd=0;
    vector<llong> a(n,0);
    REP(i,n) {cin>>a[i];
    if(a[i]%2!=0) ++odd;}
    string ans="NO";
    if(odd%2==0) ans="YES";
    cout<<ans<<endl;


    return  0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r(i,n) for(long long i = 0; i<n; i++)
typedef long long ll;
using namespace std;

int main() {
  ll n,sum=0,count=0,ansmin=1e9;
  cin >> n;
  vector<ll> v(n);
  r(i,n){
    cin >> v[i];
    if(abs(v[i])<ansmin)ansmin=abs(v[i]);
    if(v[i]<0){
      count++;
      sum-=v[i];
    }
    else sum+=v[i];
  }
  if(count%2==0)cout<<sum<<endl;
  else cout<<sum-ansmin*2<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    long mod = 1000000007;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] num = new int[N + 1];
        for (int i = 1; i <= N; i++)
        {
            num[i] = i;
        }

        long ans = 1;
        for (int t = 2; t <= N; t++)
        {
            int tmp = 0;
            for (int i = 1; i <= N; i++)
            {
                while(num[i] % t == 0)
                {
                    num[i] /= t;
                    tmp++;
                }
            }
            ans *= tmp + 1;
            ans %= mod;
        }
        Console.WriteLine(ans);
    }


        
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}
 

Measured memory_bytes: 11220
#include <stdio.h>

#define MAX 101
#define INF 100000
int main(){
  int i,j,n,min,k=1,minNode,sum=0;
  int a[MAX][MAX],x[MAX],g[MAX];

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&a[i][j]);
    }
  }


  x[0] = 0;
  g[0] = 1;
  for(i=1 ; i<n ; i++){
    g[i] = 0;
  }

  while(1){
    min = INF;

    for(i=0 ; i<k ; i++){
      for(j=0 ; j<n ; j++){
	if(min > a[x[i]][j] && a[x[i]][j]!= -1 && g[j] != 1){
	  min = a[x[i]][j];
	  minNode = j;
	}
      }
    }

    if(k!=n){
      x[k] = minNode;
      g[minNode] = 1;
      k++;
      sum += min;
    }
    else{
      break;
    }

  }

  printf("%d\n",sum);

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string s;
	cin >> s;
	ll res = 0;
	REP(i, s.length()-2) {
		ll v = (s[i]-'0') * 100 + (s[i+1]-'0') * 10 + s[i+2]-'0';
		if (abs(v - 753) < abs(res - 753)) res = v;
	}
	cout << abs(res - 753) << endl;
	return 0;
}


Measured memory_bytes: 3620
import math
import fractions

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

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

#a = list(map(int, input().split()))

s,t = list(map(str, input().split()))
a,b = list(map(int, input().split()))
u = input()

if(s==u):
    print(a-1,b)
else:
    print(a,b-1)

















Measured memory_bytes: 64876
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, M; cin >> N >> M;
  vector<int> S(N), T(M);
  for (auto& s : S) {
    cin >> s;
  }
  for (auto& t : T) {
    cin >> t;
  }

  vector<vector<cpp_int>> dp(N, vector<cpp_int>(M));
  vector<vector<cpp_int>> sum(N, vector<cpp_int>(M));

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      auto i0 = i - 1;
      auto j0 = j - 1;
      if (S[i] == T[j]) {
        dp[i][j] += (i0 >= 0 && j0 >= 0) ? sum[i0][j0] : 0;
        dp[i][j] += 1;
        dp[i][j] %= MOD;
      }
      if (i0 >= 0) { sum[i][j] += sum[i0][j]; sum[i][j] %= MOD; }
      if (j0 >= 0) { sum[i][j] += sum[i][j0]; sum[i][j] %= MOD; }
      if (i0 >= 0 && j0 >= 0) { sum[i][j] -= sum[i0][j0]; sum[i][j] = (sum[i][j] + MOD) % MOD; }
      sum[i][j] += dp[i][j];
      sum[i][j] %= MOD;
    }
  }
  cpp_int ans = sum[N-1][M-1] + 1;
  ans %= MOD;
  cout << ans.str() << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main() {
	long n,m;
	cin>>n>>m;
	long h[n];
	for(long i=1;i<=n;i++) {
		cin>>h[i];
	}
	map<long,vector<long>> paths;
	long a,b;
	//set<long> s;
	for(long i=0;i<m;i++) {
		cin>>a>>b;
		paths[a].push_back(b);
		paths[b].push_back(a);
	}
	long counter=0,indCount=0;
	for(long i=1;i<=n;i++) {
		indCount=0;
		vector<long> vert=paths[i];
		long size=0;
		for(long j:vert) {
			if(i!=j)
				size++;
			// if height is more
			if(h[i]>h[j]) {
				indCount++;
			}
		}
		if(indCount==(long)vert.size() || size==0) {
			// cout<<node1<<" ";
			counter++;
		}
	}
	// counter+=n-s.size();
	cout<<counter<<endl;
	return 0;
}



Measured memory_bytes: 15692
# next_permutationで解く
import itertools
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)

# 次の状態に遷移できるかどうかをしてbreakせず最後まで行けたらansをインクリメントする
ans = 0
for x in itertools.permutations(range(N)):
    now = 0
    if x[0] == 0:
        # 始点ノードが0のもののみ試す
        for e in x[1:]:
            if e not in graph[now]:
                break
            now = e
        else:
            ans += 1
print(ans)


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
             String spl[] = line.split(" ");
             int a= Integer.parseInt(spl[0]);
             if(a==-1)break;
             double[] nowLoca=new double[]{1.0,1.0};
             for(int i=1; i<=a-2;i++){
                 nowLoca=nextLoca(nowLoca);
                 //System.out.println(nowLoca[0]+" "+nowLoca[1]);
             }
                 System.out.println(nowLoca[0]);
                 System.out.println(nowLoca[1]);
                 
             } br.close();
         }catch(Exception e){e.printStackTrace();}         
     }  
    
     static double[] nextLoca(double[] nowLoca){
         double idoVx = -1*nowLoca[0]/Math.sqrt(nowLoca[0]*nowLoca[0]+nowLoca[1]*nowLoca[1]);
         double idoVy = -1*nowLoca[1]/Math.sqrt(nowLoca[0]*nowLoca[0]+nowLoca[1]*nowLoca[1]);
         //System.out.println(idoVx+" "+idoVy);
         double turnVx=idoVy, turnVy=-idoVx;
         return new double[]{nowLoca[0]+turnVx,nowLoca[1]+turnVy};
     }
     
}
 

Measured memory_bytes: 16988
h, w = map(int,input().split())
maze = []
for _ in range(h):
    maze.append(list(input()))
dx = [-1, 0, 1, -1, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 1, 1, 1]
for hh in range(h):
    for ww in range(w):
        if maze[hh][ww] == "#":
            continue
        cnt = 0
        for di in range(len(dx)):
            ny = hh + dy[di]
            nx = ww + dx[di]
            if ny < 0 or ny > h-1:
                continue
            if nx < 0 or nx > w-1:
                continue
            if maze[ny][nx] == "#":
                cnt += 1
        maze[hh][ww] = str(cnt)
for i in range(h):
    print("".join(maze[i]))


Measured memory_bytes: 40048
function Main(input) {
    input = input.trim();
    const r = parseInt(input,10);

    console.log(2 * r * Math.PI);
    
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29560
#include<bits/stdc++.h>
using namespace std;
int h[2010],nex[4010],to[4010],dep[2010],fa[2010],fav[2010],M;
void add(int a,int b){ M++; to[M]=b; nex[M]=h[a]; h[a]=M; }
void dfs(int x){ dep[x]=dep[fa[x]]+1; for(int i=h[x];i;i=nex[i]){ if(to[i]!=fa[x]){ fa[to[i]]=x; dfs(to[i]); } } }
void col(int x,int y){ if(dep[x]<dep[y])swap(x,y); while(dep[x]>dep[y]){ fav[x]++; x=fa[x]; } while(x!=y){ fav[x]++; fav[y]++; x=fa[x]; y=fa[y]; } }
struct rt{ int x,y; rt(int a=0,int b=0){x=a;y=b;} };
bool operator==(rt a,rt b){return a.x==b.x&&a.y==b.y;}
int d[2010],n;
vector<rt>solve(vector<rt>v){
    if(v.size()==0)return v;
    int x,u,i; for(x=1;x<=n;x++){ if(d[x]==1)break; }
    if(x>n)return v;
    for(i=h[x];i;i=nex[i]){ if(d[to[i]]){ u=to[i]; break; } }
    d[x]--; d[u]--; vector<rt>lx,nv; vector<int>id; int pos[2010];
    memset(pos,-1,sizeof(pos));
    for(i=0;i<(int)v.size();i++){ if(v[i].x==x||v[i].y==x){ lx.push_back(v[i]); id.push_back(i); }else{ nv.push_back(v[i]); pos[i]=nv.size()-1; } }
    if(lx.size()==0)return solve(v);
    for(i=0;i+1<(int)lx.size();i+=2){
        if(lx[i].y==x)swap(lx[i].x,lx[i].y); if(lx[i+1].y==x)swap(lx[i+1].x,lx[i+1].y);
        if(lx[i]==lx[i+1]){ if(v[id[i]]==v[id[i+1]])swap(v[id[i]].x,v[id[i]].y); continue; }
        nv.push_back(rt(lx[i].y,lx[i+1].y)); pos[id[i]]=pos[id[i+1]]=nv.size()-1;
    }
    if(lx.size()&1){
        if(lx[lx.size()-1].y==x)swap(lx[lx.size()-1].x,lx[lx.size()-1].y);
        if(lx[lx.size()-1].y!=u){ nv.push_back(rt(u,lx[lx.size()-1].y)); pos[id[lx.size()-1]]=nv.size()-1; }
    }
    nv=solve(nv); for(i=0;i<(int)v.size();i++){ if(pos[i]!=-1&&!(v[i].x==nv[pos[i]].x||v[i].y==nv[pos[i]].y))swap(v[i].x,v[i].y); }
    return v;
}
vector<rt>v;
int main(){
    int m,i,x,y,ans; scanf("%d%d",&n,&m);
    for(i=1;i<n;i++){ scanf("%d%d",&x,&y); add(x,y); add(y,x); d[x]++; d[y]++; }
    dfs(1); for(i=1;i<=m;i++){ scanf("%d%d",&x,&y); v.push_back(rt(x,y)); col(x,y); } v=solve(v);
    ans=0; for(i=2;i<=n;i++)ans+=min(2,fav[i]); printf("%d\n",ans);
    for(rt t:v)printf("%d %d\n",t.x,t.y);
}

Measured memory_bytes: 56064
#include <iostream>

using namespace std;

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

	int nums[w];
	for(int i=0;i<w;i++){
		nums[i]=i+1;
	}

	for(int i=0;i<n;i++){
		int a1,b1;
		char dummy;
		cin>>a1>>dummy>>b1;
		a1--;b1--;
		int tmp=nums[b1];
		nums[b1]=nums[a1];
		nums[a1]=tmp;
	}

	for(int i=0;i<w;i++){
		cout<<nums[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;




const int mod = 1000000007;
struct Mod {
public:
	int num;
	Mod() : num(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) { ; }
	Mod(int n) : num((n % mod + mod) % mod) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	assert(b.num != 0);
	return Mod(a) * inv(b);
}
Mod operator/=(Mod &a, const Mod b) {
	assert(b.num != 0);
	return a = a * inv(b);
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init() {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < MAX_MOD_N - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}

int main() {
	int N, P; cin >> N >> P;
	vector<int>nums;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		nums.push_back(a);
	}
	sort(nums.begin(), nums.end());
	Mod ans = 1;
	for (auto it = nums.begin(); it != nums.end();++it) {
		auto jt = lower_bound(nums.begin(), nums.end(), (*it) - P);
		ans *= (it-jt)+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11496
#include<bits/stdc++.h>
using namespace std;
const int inf=1e5+5;
typedef long long ll;
int n,m;
bool vis[100005];
vector<int> v[100005];
int main()
{
    cin>>n>>m;
    n--;m--;
    cout<<(n+m-1)/n<<endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}


P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    
    scanf("%d %d", &n, &q);
    for (i = 1; i<=n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;

    while ( head != tail ) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }


    }
}


Measured memory_bytes: 11952
n = int(input())
bb = 0
af = 0
ab = 0
p = 1
for i in range(n):
  s = input()
  l = len(s)
  if s[0] == "B":
    bb += 1
  if s[l - 1] == "A":
    af += 1
  if s[0] == "B" and s[l - 1] != "A":
    p = 0
  if s[0] != "B" and s[l - 1] == "A":
    p = 0
  for j in range(l - 1):
    if s[j] == "A":
      if s[j + 1] == "B":
        ab += 1
if af == bb:
  if af == 0:
    ans = ab
  else:
    ans = ab + af - p
else:
  ans = ab + min(af, bb)
print(ans)

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

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    double ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll p = i;
        ll cnt = 0;
        while (p < k)
        {
            p *= 2;
            cnt++;
        }
        ans += 1.0 / pow(2, cnt);
    }

    cout << SP(10) << ans / n << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c = map(int, input().split())
    STC = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:[x[2], x[0]])

    STC2 = []
    tmp = STC[0]
    for i in range(1, n):
        pre_s, pre_t, pre_c = tmp
        now_s, now_t, now_c = STC[i]
        if pre_c == now_c:
            if pre_t == now_s:
                tmp = [pre_s, now_t, now_c]
            else:
                STC2.append(tmp)
                tmp = STC[i]
        else:
            STC2.append(tmp)
            tmp = STC[i]
    if len(tmp):
        STC2.append(tmp)

    imos = [[0] * (10 ** 5 + 1) for _ in range(c)]
    for i in range(len(STC2)):
        s, t, c = STC2[i]
        imos[c - 1][s - 1] += 1
        imos[c - 1][t] -= 1

    for i in range(c):
        for j in range(1, 10 ** 5 + 1):
            imos[i][j] += imos[i][j - 1]

    res = [0] * (10 ** 5 + 1)
    for i in range(c):
        for j in range(10 ** 5 + 1):
            res[j] += imos[i][j]

    print(max(res))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 59472
L= list(map(int,[input() for i in range(5)]))
res = 10
res2 = 0
M = []
ans = 0
for i in range(5):
    if L[i] % 10 != 0:
        M.append(10 - L[i] % 10)
        if res > L[i] % 10:
            res = L[i] % 10
            res2 = 10 - L[i] % 10
    else:
         M.append(0)
for i in range(5):
    ans += L[i]+M[i]

ans -= res2
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

INF = 1 << 60
H, W, K = nm()
grid = []
for i in range(H):
    row = ns()
    assert len(row) == W
    grid.append(row)


def min_vsplits(ranges):
    vsplits = 0
    block_count = [0] * len(ranges)
    for c in range(W):
        line_count = [0] * len(ranges)
        for i, (start, end) in enumerate(ranges):
            for r in range(start, end):
                if grid[r][c] == "1":
                    line_count[i] += 1
                    block_count[i] += 1
        if max(line_count) > K:
            return INF  # one column contains more than K.
        if max(block_count) > K:
            vsplits += 1
            for i in range(len(block_count)):
                block_count[i] = line_count[i]
    return vsplits


def solve():
    S = 1 << (H - 1)
    min_splits = (H - 1) * (W - 1)  # split all
    for splits in range(S):
        ranges = []
        start = 0
        stop = 1
        while splits:
            if splits & 1:
                ranges.append((start, stop))
                start = stop
            splits >>= 1
            stop += 1
        ranges.append((start, H))
        hsplits = len(ranges) - 1
        vsplits = min_vsplits(ranges)
        s = hsplits + vsplits
        if min_splits > s:
            min_splits = s
            # print(
            #     f"min_splits={min_splits} ({hsplits}+{vsplits}) ranges={ranges}",
            #     file=sys.stderr,
            # )
    return min_splits


print(solve())


Measured memory_bytes: 44380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            long n = s.length();
            int[] a = s.chars().toArray();
            Map<Integer, Long> map = new TreeMap<>();
            for (int x : a) map.merge(x, 1L, (u, v) -> u + v);
            long ans = n * (n - 1) / 2 + 1;
            for (int x : map.keySet()) ans -= map.get(x) * (map.get(x) - 1) / 2;
            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 32408
from sys import stdin
N, W = map(int, input().split())
s = list(list(map(int, line.split())) for line in stdin.read().splitlines())

sumv = sum(s[i][1] for i in range(N))

INF = 10e12
dp = [INF] * (sumv + 1)  # minimum w required to achieve  value V. dp[v] = w
dp[sumv] = sum(s[i][0] for i in range(N))
dp[0] = 0

for n in range(N):
    w0, v0 = s[n]
    for v in range(sumv, v0 - 1, -1):
        dp[v] = min(dp[v], dp[v - v0] + w0)

for i in range(sumv, -1, -1):
    if dp[i] <= W:
        print(i)
        break


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll pow5(ll k) {
    ll s = k;
    s *= k;
    s *= k;
    s *= k;
    s *= k;
    return s;
}

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

    vector<P> v;

    rep(i, 120) v.push_back(P(i, pow5(i)));

    map<ll, P> m;

    for (P a : v) {
        for (P b : v) {
            m[a.second + b.second] = P(a.first, -b.first);
            m[-a.second - b.second] = P(-a.first, b.first);
            m[a.second - b.second] = P(a.first, b.first);
        }
    }

    P p = m[x];

    cout << p.first << ' ' << p.second << endl;

}


Measured memory_bytes: 5560
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = (int)2e5 + 777;

int a[MAX_N], n;

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

	int r = 0;
	int cnt = 0;
	int64 answ = 0;

	for(int l = 0; l < n; ++l) {
		while(r < n && (a[r] & cnt) == 0) {
			cnt ^= a[r++];
		}

		//cout << l << ' ' << r << '\n';

		answ += r - l;
		cnt ^= a[l];
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int n;
ll a[100000 + 10], pair1, pair2;
unordered_set<ll> us;

int main() {
	rd(n);
	repi(i, 0, n) rd(a[i]);

	sort(a, a + n);
	reverse(a, a + n);

	repi(i, 0, n) {
		if (us.find(a[i]) == us.end()) {
			us.insert(a[i]);
		}
		else {
			us.erase(a[i]);
			if (!pair1) pair1 = a[i];
			else {
				pair2 = a[i];
				break;
			}
		}
	}

	wrln(pair1*pair2);

	return 0;
}

Measured memory_bytes: 4644
(defn input []
  (let [[H W] (->> (clojure.string/split (read-line) #"\s")
                (map #(Integer/parseInt %)))]
    (list W (->> (repeatedly H read-line)))))

(defn PictureFrame [[W As]]
  (let [hbar (str (apply str (repeat (+ 2 W) \#))"\n")]
    (str hbar
      (apply str (map #(str "#" % "#\n") As))
      hbar)))

(-> (input)
  PictureFrame
  println)

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

ll gcd(ll a,ll b){
 if(b==0) return a;
 return gcd(b,a%b);
}
 
ll lcm(ll a,ll b){
 ll g=gcd(a,b);
 return a/g*b;
}
    
int main(){
 int N;
 cin >> N;
 ll ans = 1LL;

 for(int i=0;i<N;++i)
 {
 ll T;
 cin >>T;
 ans = lcm(ans, T);
 }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main() {

	int N, R, G, B, tmp;

	cin >> R >> G >> B >> N;

	int cnt = 0;	//何通り？

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			tmp = N - R * i - G * j;
			if (tmp % B == 0 && tmp>=0){
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
   string str,str1,str2;
   cin>>str>>str1;
   cin>>m>>n;
   cin>>str2;
   if(str==str2)
   {
      cout<<m-1<<" "<<n<<endl;

   }
   else if(str1==str2)
   {
       cout<<m<<" "<<n-1<<endl;
   }

 return 0;
}



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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    
    ll ans=0,n,x,m;
    cin>>n>>x>>m;
    vector<bool> rem(m+1,false);
    vector<int> nos;
    for(int i=0;i<n;i++){
        if(rem[x]){
            //cout<<"TRUE"<<x<<endl;
            int ind=0;
            for(int i=0;i<nos.size();++i){
                if(nos[i]==x){
                    ind=i;
                    break;
                }
            }
            ll remx=n-i;
            ll q=remx/(nos.size()-ind);
            ll bakki=remx%(nos.size()-ind);
            
            int bakkiind=ind;
            while(bakki--){
                ans+=nos[bakkiind];
                bakkiind++;
            }
            
            ll cs=0;
            for(int j=ind;j<nos.size();++j){
                cs+=nos[j];
            }
            //cout<<endl;
            //cout<<cs<<"----"<<q<<"---"<<ind<<"---"<<bakki<<endl;
            
            ans+=cs*q;
            break;
        }
        
        rem[x]=true;
        nos.push_back(x);
        ans+=x;
        //cout<<x<<" ";
        x=(x%m*x%m)%m;
        
    }
    
    cout<<ans;
    
    
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int K;
	cin >> K;
	
	cout << a[K-1] << endl;
	
	return 0;
}


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

int main(int argc, char const *argv[]) {
  int n, value=0;
  int b[110];
  cin>>n;
  for(int i=0; i<n-1; i++) cin>>b[i];

  value+=b[0];
  value+=b[n-2];
  for(int i=0; i<n-2; i++) value+=min(b[i],b[i+1]);
  cout<<value<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll n;
    cin >> n;
    for (ll i = 1; i <= 3500; i++) {
        for (ll j = 1; j <= 3500; j++) {
            ll k1 = n * i * j;
            ll k2 = (4 * i * j) - (n * i) - (n * j);
            if (k2 > 0) {
                ll k3 = k1 % k2;
                if (k3 == 0) {
                    cout << i << " " << j << " " << k1 / k2 << endl;
                    return 0;
                }
            }
        }
    }
}

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

using namespace std;
char c[3][3];

int main(){
   for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
         cin>>c[i][j];
      }
   }
   cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
}

Measured memory_bytes: 888
import java.util.Scanner;
public class Main{
    public static void main(String a[])
    {
	Scanner scan = new Scanner(System.in);
	int i=1;
	int x;
	while(true)
	    {
		x = scan.nextInt();
		if( x != 0 )
		    {
			System.out.println("Case "+i+": "+x);
			i++;
		    }
		else break;
	    }
    }
}

Measured memory_bytes: 44928
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const ll INF = 1LL << 60;

int N;
ll h[100010];

ll dp[100010];

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

    for(int i = 0; i < N; i++) dp[i] = INF;

    dp[0] = 0;

    for(int i = 1; i < N; i++){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[N-1] << endl;
    

    return 0;
}

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

using ll = long long int;
using ull = unsigned long long int;
constexpr int INF = 1 << 28;

struct BIT {
    int N;
    vector<int> bit;

    void init(int _n){
        N = _n;
        bit.resize(_n+1, 0);
    }
    int getSum(int i) {  // i番目までの要素の和を求める(1-index)
        int sum = 0;
        while (i > 0) {
            sum += bit[i];
            i -= i & -i;
        }
        return sum;
    }
    void add(int i, int x) {  // i番目の要素にxを加算
        while (i <= N) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int n;
int idx[2][2005];
vector<vector<int> > dp;

int rec(int i, int j, BIT &bit){
    if(i==n && j==n) return 0;
    if(dp[i][j] < INF) return dp[i][j];
    int res = INF, cost;
    if(i<n){
        bit.add(idx[0][i],-1);
        cost = bit.getSum(idx[0][i]);
        res = min(res, rec(i+1,j,bit)+cost);
        bit.add(idx[0][i],1);
    }
    if(j<n){
        bit.add(idx[1][j],-1);
        cost = bit.getSum(idx[1][j]);
        res = min(res, rec(i,j+1,bit)+cost);
        bit.add(idx[1][j],1);
    }
    return dp[i][j] = res;
}

int main(){
    cin >> n;
    for(int i=0;i<n*2;i++){
        char c;
        int a;
        cin >> c >> a;
        a--;
        idx[c&1][a] = i+1;
    }
    dp.resize(n+1,vector<int>(n+1,INF));
    BIT bit;
    bit.init(n*2);
    for(int i=0;i<n*2;i++){
        bit.add(i+1,1);
    }
    cout << rec(0,0,bit) << endl;
    return 0;
}

Measured memory_bytes: 16256
#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 a, b;
    cin >> a >> b;
    if (a == 1 && b == 2 || a == 2 && b == 1) cout << 3 << endl;
    else if (a == 2 && b == 3 || a == 3 && b == 2) cout << 1 << endl;
    else cout << 2 << endl;
}

Measured memory_bytes: 256
#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 endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

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

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int r, g;
    cin >> r >> g;

    cout << 2 * g - r << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		System.out.println((x >= a && x <= a + b) ? "YES" : "NO");
	}
	
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
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;}
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;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    pr(max(a*b,c*d));
}


Measured memory_bytes: 256
N = int(input())
ans = [0]*(10**4+10)

for i in range(1,10**2+10):
    for j in range(1, 10**2+10):
        for k in range(1, 10**2+10):
            v = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if v < 10**4+10:
                ans[v]+=1

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 73548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        out.println(phiFunc(n));
    }

    int phiFunc(int n) {
        int ret = n;
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                ret -= ret / i;
                while (n % i == 0) n /= i;
            }
        }
        if (n > 1) ret -= ret / n;
        return ret;
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24480
import java.util.Scanner;

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

		String[] str = sc.nextLine().split("/");
		if(Integer.parseInt(str[1]) <= 4) {

			System.out.println("Heisei");

		}else {

			System.out.println("TBD");

		}
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

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

	for (long long i = 0; i < a.size(); i++)
		b.push_back('x');

	cout << b << endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL A[100000],B[100000];

LL ans = 0;

LL val_sum(LL bit){
    LL ret = 0;
    for(int i=0;i<N;i++){
        bool ok = true;
        for(int j=0;j<30;j++){
            if(!((bit>>j)&1LL) && ((A[i]>>j)&1LL)) ok = false;
        }
        ret += ok*B[i];
    }
    return ret;
}

void solve(){
    ans = val_sum(K);
    for(int d=0;d<30;d++){
        //Kのd桁目が1なら
        if((K>>d)&1LL){
            LL wise = K;
            wise &= ~(1<<d);//d桁目を0に変える
            wise |= ((1<<d) - 1);//d-1桁目より下を1に変える
            ans = max(ans,val_sum(wise));
        }
    }
}
 
int main(){
	cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];
 
    solve();

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

Measured memory_bytes: 4744
#include <stdio.h>
int main(void) {
	char b;
	scanf("%c", &b);

	if (b == 'A')
		printf("T\n");
	else if (b == 'T')
		printf("A\n");
	else if (b =='G')
		printf("C\n");
	else if (b == 'C')
		printf("G\n");
	else
		printf("error");

	return 0;
}

Measured memory_bytes: 128
//Moh_K_Imar .......
//29/08/2020  ... 5,35.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(a+(b/2))<<endl;

    return 0;
}



Measured memory_bytes: 3540
#include <stdio.h>
	int main(){

		int n,k,tmp,max;
		scanf("%d %d",&n,&k);
		int l[n];
		for( int i=0;i<n;i++){
			scanf("%d",&l[i]);
		}

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

				if( l[i] < l[j]){
					tmp = l[i];
					l[i] = l[j];
					l[j] = tmp;
				}

			}
		}
		max =0;
		for( int i=0;i<k;i++){
			max = max + l[i];
		}
		printf("%d",max);
		
		return 0;
	}

Measured memory_bytes: 128
rectangles = 0
lozenges = 0
while True:
    try:
        x, y, r = map(int, raw_input().split(','))
        if x == y:
            lozenges += 1
        elif x**2 + y**2 == r**2:
            rectangles += 1
    except EOFError:
        print rectangles
        print lozenges
        break

Measured memory_bytes: 4196
import sys
n,m=map(int,input().split())
num=n
mum=m
if 2<=abs(n-m):
  print(0)
  sys.exit()
if abs(n-m)==1:
  while n>1:
    num*=n-1
    n-=1
    num=num%((10**9)+7)
  while m>1:
    mum*=m-1
    m-=1
    mum=mum%((10**9)+7)
  print((num*mum)%((10**9)+7))
  sys.exit()
if abs(n-m)==0:
  while n>1:
    num*=n-1
    n-=1
    num=num%((10**9)+7)
  print((2*(num**2))%((10**9)+7))
  sys.exit()

    
    


Measured memory_bytes: 3064
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int MOD = 1e9 + 7;
int ans = 0;
int c[100050];

int C(int n, int k) {
    if (n < k) {
        return 0;
    }
    if (n == k) {
        return 1;
    }
    return c[n];

    int mp = 1;
    for (int i = k + 1; i <= n; i++) {
        mp *= i;
    }
    for (int i = 1; i <= n - k; i++) {
        mp /= i;
    }
    return mp % MOD;
}

int gcdExtended(int a, int b, int *x, int *y) {
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1;
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    *x = y1 - (b / a) * x1;
    *y = x1;

    return gcd;
}

int modInverse(int b) {
    int x, y; 
    int g = gcdExtended(b, MOD, &x, &y);

    return (x % MOD + MOD) % MOD;
}

int modDivide(int a, int b) {
    int inv = modInverse(b);
    return (inv * 1ll * a) % MOD;
}

void solution() {
    int n, k;
    cin >> n >> k;
    vector <int> v(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &v[i]);
        v[i] += MOD;
    }
    sort(v.begin(), v.end());
    
    int res = 1;
    for (int i = k; i <= n; i++) {
        res = (res * 1ll * i) % MOD;
        c[i] = modDivide(res, i - k + 1);
        res = c[i];
        //cout << c[i] << " " << C(i, k - 1) << endl;
    }

    for (int i = 0; i < n; i++) {
        if (v[i] < 0) {
            v[i] += MOD;
        }
        int mx = v[i] * 1ll * C(i, k - 1) % MOD;
        ans = (ans + mx) % MOD;

        int mn = (v[i] * 1ll * C(n - i - 1, k - 1)) % MOD;
        ans = (ans + MOD - mn) % MOD;
    }
    cout << ans << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

    solution();

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, d[20], dp[50001];
  fill_n( dp, 50001, 1 << 30);
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> d[i];
  }
  sort( d, d + m);

  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(i + d[j] > n) break;
      dp[i + d[j]] = min( dp[i + d[j]], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1372