akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int n, d;
        cin >> n >> d;
     
        int result = n / (2 * d + 1);
        if(n % (2 * d + 1) != 0) {
            result++;
        }
        cout << result << endl;
    }

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

int main()
{
    char alpha;
    cin >> alpha;
    if ('a' <= alpha && alpha <= 'z')
        cout << 'a' << endl;
    else if ('A' <= alpha && alpha <= 'Z')
        cout << 'A' << endl;
    return 0;
}

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

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

  int ans = 1;
  while (true) {
    if (ans * 2 > n) {
      cout << ans << endl;
      return 0;
    }
    ans *= 2;
  }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long lint;
using namespace std;
int main(){
	lint n,k,num=0;
	cin>>n>>k;
	vector<lint>h(n);
	rep(i,n)cin>>h.at(i);
	sort(h.begin(),h.end());
	reverse(h.begin(),h.end());
	for(int i=k;i<n;i++)num+=h.at(i);
	cout<<num<<endl;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s int
	fmt.Scan(&s)

	i := 0
	set := make(map[string]struct{})

	for {
		st := strconv.Itoa(s)
		if _, ok := set[st]; ok {

			break
		}

		set[st] = struct{}{}
		if s%2 == 0 {
			s /= 2
		} else {
			s = s*3 + 1
		}
		i++
	}

	fmt.Println(i + 1)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
vector<int>arr[100001];
bool vis[100001];
int dp[100001];

int dfs(int a){
	int temp=0;
	if(vis[a]){
		return dp[a];
	}
	int total=0;
	vis[a]=1;
	for(auto i:arr[a]){
		total=max(total, 1+dfs(i));
	}
	return dp[a]=total;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> x >> y;
		arr[x].push_back(y);
	}
	int maks=0;
	for(int i=1;i<=n;i++){
		maks=max(maks, dfs(i));
	}
	cout << maks << '\n';
}

Measured memory_bytes: 8320
import sys
sys.setrecursionlimit(2**20)
n = int(input())
NIL = -1
class node:
    def __init__(self,parent,left,right):
        self.parent = parent
        self.left = left
        self.right = right
T = [node(NIL,NIL,NIL) for _ in range(n)]
D = [0]*n
def setDepth(u,p):#uはノードの番号、pはノードpの深さ。
    if u == NIL:
        return
    D[u] = p      #uより下にあるノードの深さをDに保存し、かえす
    if T[u].left != NIL:
        setDepth(T[u].left,p+1)
    if T[u].right != NIL:
        setDepth(T[u].right,p+1)
    return D
H = [0]*n
def setHeight(u,H):
    hl = 0
    hr = 0
    if T[u].left != NIL:
        hl = 1 + setHeight(T[u].left,H)
    if T[u].right != NIL:
        hr = 1 + setHeight(T[u].right,H)
    ret = max(hl,hr)
    H[u] = ret
    return ret
def getDegree(u):
    cc = 0
    if T[i].left != NIL:
        cc += 1
    if T[i].right != NIL:
        cc += 1
    return cc
def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d
def getBrother(u):
    if T[u].parent == NIL:
        return NIL
    elif T[T[u].parent].left == u:
        return T[T[u].parent].right
    elif T[T[u].parent].right == u:
        return T[T[u].parent].left
def printChildren(u):#番号uのノードの子供をlistでかえす
    child = []
    if T[u].left != NIL:
        child.append(T[u].left)
    if T[u].right != NIL:
        child.append(T[u].right)
    return child
def ppp():
	for i in range(n):
  		ccc = T[i]
  		print(i,ccc.parent,ccc.left,ccc.right)
def findroot(u): #根をみつける
    while T[u].parent != NIL:
        u = T[u].parent
    return u
#巡回
rl = []
def rootleft(u,rl): #どのパターンでもrootからスタート
    if u == NIL:
        return
    rl.append(u)
    rootleft(T[u].left,rl)
    rootleft(T[u].right,rl)
lro = []
def leftroot(u,lro):
    if u == NIL:
        return
    leftroot(T[u].left,lro)
    lro.append(u)
    leftroot(T[u].right,lro)
lri = []
def leftright(u,lri):
    if u == NIL:
        return
    leftright(T[u].left,lri)
    leftright(T[u].right,lri)
    lri.append(u)
#ここから入力
firstid = 0
for i in range(n):
    id,left,right = map(int,input().split())
    if n == 0:
        firstid = id
    if left != NIL:
        T[id].left = left
        T[left].parent = id
    if right != NIL:
        T[id].right = right
        T[right].parent = id
r = findroot(firstid)
D = setDepth(r,0)
setHeight(r,H)
leftright(r,lri)
leftroot(r,lro)
rootleft(r,rl)
s0 = " ".join(map(str,rl))
s1 = " ".join(map(str,lro))
s2 = " ".join(map(str,lri))
print("Preorder")
print(" "+s0)
print("Inorder")
print(" "+s1)
print("Postorder")
print(" "+s2)


Measured memory_bytes: 5636
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const _r = stdin.split('\n')[0]

const r = Number(_r)

let res = 'AGC'
if (r < 1200) {
  res = 'ABC'
} else if (r < 2800) {
  res = 'ARC'
}

console.log(res)


Measured memory_bytes: 7372
package main

import (
	"fmt"
	"math"
	"sort"
)

//4
//1 4 6 3
func main() {
	var n int
	fmt.Scanf("%d", &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scanf("%d", &a)
		arr[i] = a
	}

	sort.IntSlice(arr).Sort()
	var ans int
	ans = int(math.Abs(float64(arr[len(arr)-1]-arr[0])))
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, FReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = 0, y = 0, t = 0;

            while(n-- > 0) {
                int nt = in.nextInt();
                int nx = in.nextInt();
                int ny = in.nextInt();

                int diff = Math.abs(nx - x) + Math.abs(ny - y);
                if(diff > nt - t) {
                    out.println("No");
                    return;
                } else {
                    if((nt - t - diff) % 2 != 0) {
                        out.println("No");
                        return;
                    }
                }

                t = nt;
                x = nx;
                y = ny;
            }

            out.println("Yes");
        }

    }

    static class FReader {
        private BufferedReader  r;
        private String          line;
        private StringTokenizer st;
        private String          token;

        public FReader() {
            this(System.in);
        }

        public FReader(InputStream i) {
            r = new BufferedReader(new InputStreamReader(i));
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        private String peekToken() {
            if(token == null)
                try {
                    while(st == null || !st.hasMoreTokens()) {
                        line = r.readLine();
                        if(line == null) return null;
                        st = new StringTokenizer(line);
                    }
                    token = st.nextToken();
                } catch(IOException e) { }
            return token;
        }

        private String nextToken() {
            String ans = peekToken();
            token = null;
            return ans;
        }

    }
}



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

int main() {
    int n;
    ll v;
    scanf("%d",&n);
    vector<ll> a(n+1);
    for(int i=0;i<n;i++) {
        scanf("%lld",&a[i+1]);
    }

	vector<ll> dp(n+1,0);
	dp[1] = 0;
	// odd prefix
	vector<ll> prefix(n+1);
	prefix[1] = a[1];
	for(int i=3;i<=n;i+=2){
		prefix[i] = prefix[i-2]+a[i];
	}
	for(int i=2;i<=n;i++){
		if(i&1){
			dp[i]=max(dp[i-1],dp[i-2]+a[i]);
		}else{
		    // two case when even
			dp[i] = a[i] + dp[i-2]; // select
			dp[i] = max(dp[i],prefix[i-1]); // or don't select, get all odd prefix
		}
	}
	cout<<dp[n];
}


Measured memory_bytes: 8020
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {
    string n; cin >> n;
    int res = 0;
    for(char c: n){
        res += c - '0';
    }
    int num = 9*(n.size()-1)+n[0]-'1';
    chmax(res,num);
    cout << res << ln;
}


Measured memory_bytes: 256
#include <stdio.h>

int i, j, n, A[2000], q, m, true, false;
j = 0;	
true = 1;
false = 0;

int solve(int i, int m){
	if(m == 0)
	return true;
	if (i == n)
	return false;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main()
{
		scanf("%d",&n);
		
		for(i = 0; i < n; i++){
			scanf(" %d",&A[i]);
			
		}
		scanf("%d",&q);
		
		for(i = 0; i < q; i++){
			scanf(" %d",&m);
			if(solve(j, m) == true) {
				printf("yes\n");
			}else{
			printf("no\n");
			}
		}
	return 0;
}

Measured memory_bytes: 1812
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


n = int(input())
A = list(map(int, input().split()))
q = partition(A, 0, n - 1)
for i in range(n):
    if i != 0:
        print(" ", end="")
    if i == q:
        print("[", end="")
    print(A[i], end="")
    if i == q:
        print("]", end="")
print("")



Measured memory_bytes: 16392
#include<stdio.h>

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

  int d[101]={0};
  int e[101]={0};
  int i,j;
  for(i=0;i<N;i++){
    scanf("%d",&e[i]);
    for(j=0;j<N;j++){
      if(d[j]==0){
		d[j]=e[i];
        break;
      }else if(d[j]==e[i]){
		break;
      }
    }
  }
  int cnt=0;
  for(i=0;i<N;i++){
    if(d[i]!=0){
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    int c;
    int d;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        c = i;
        d = 0;
        while(c != 0){
            d += c % 10;
            c = (c - c % 10) / 10;
        }
        if(a <= d && d <= b){
            ans += i;
        }
    }
    printf("%d\n",ans);

    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    set<ll> s;

    REP(i, N){
        ll a;
        cin >> a;
        s.insert(a);
    }

    cout << s.size() << endl;
    return 0;
}

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

#define ll long long
#define mx  100005
#define mod 1000000009
#define lim 10000000
#define N 18
using namespace std;

int ans[1<<N+5];
pair<int,int>p[1<<N+5];

pair<int,int> getBest(pair<int,int>a,pair<int,int>b)
{
	if(a.first<b.first)swap(a,b);
	a.second=max(a.second,b.first);
	return a;
}

int main(){
	ios_base::sync_with_stdio(false);
     int n;cin>>n;

     for(int i=0;i<1<<n;i++)
     	cin>>p[i].first,p[i].second=0;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<1<<n;j++)
		{
			if(j>>i & 1)
			{
				p[j]=getBest(p[j],p[j^1<<i]);
			}
		}
	}
     ans[0]=0;
	for(int k=1;k<1<<n;k++)
	{
		ans[k]=p[k].first+p[k].second;
		ans[k]=max(ans[k],ans[k-1]);
		cout<<ans[k]<<"\n";
	}
     return 0;
}


Measured memory_bytes: 9216
h,w = map(int,input().split())
cambus = [list(input()) for _ in range(h)]
import sys
for i in range(h):
  for j in range(w):
    if cambus[i][j]=="#":
      b = []
      if i != 0:
        b.append(cambus[i-1][j] == "#")
      if i != h-1:
        b.append(cambus[i+1][j] == "#")
      if j != 0:
        b.append(cambus[i][j-1] == "#")
      if j != w-1:
        b.append(cambus[i][j+1] == "#")

      if not any(b):
        print("No")
        sys.exit()

print("Yes")
          


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define INF 1000000000
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<pii> vii;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
multiset<int>ms;
int main(){
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		ms.insert(t);
	}
	int ans=0;
	while(!ms.empty()){
		multiset<int>::iterator it=ms.end();
		it--;
		int x=*it;
		ms.erase(it);
		int i;
		for(i=1;i<=x;i*=2);
		if(ms.find(i-x)!=ms.end()){
			ans++;
			ms.erase(ms.find(i-x));
		}
	}
	cout<<ans<<endl;
	//cout<<r; 
	return 0;
}

Measured memory_bytes: 10240
import java.util.*;

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

        int n = sc.nextInt();
        double sum = 0;

        for (int i = 0; i < n; i++) {
            double m = sc.nextDouble();
            if (sc.next().charAt(0) == 'J') {
                sum += m;
            } else {
                sum += m * 380000;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 23252
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#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;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;
    vector<ll> A(N + 2);
    A[0] = 0;
    A[N + 1] = 0;

    FOR(i, 1, N)
    cin >> A[i];

    ll sum = 0;
    FOR(i, 0, N)
    sum += abs(A[i + 1] - A[i]);

    FOR(i, 1, N)
    {
        ll ans = sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]);
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3652
from collections import defaultdict

N, K = map(int, input().split())

A = [int(x) - 1 for x in input().split()]

cur = 0
step = 0
d = defaultdict(int)
d[0] = step
li = []
while True:
    cur = A[cur]
    li.append(cur)
    if d[cur] != 0:
        break
    step += 1
    d[cur] = step

pre = li[:d[cur]]
loop = li[d[cur]:]

if K <= len(pre):
    print(pre[K - 1] + 1)
else:
    K -= len(pre) + 1
    print(loop[K % (len(loop))] + 1)


Measured memory_bytes: 40564
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n,a[200005],ans;
map<int,int> have;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		//if(i-a[i]==24)cout<<i<<" "<<i<<" "<<a[i]<<endl;
		have[i-a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		have[i-a[i]]--;
		if(have.count(i+a[i]))ans+=have[i+a[i]];
	//	cerr<<i+a[i]<<" "<<have[i+a[i]]<<endl;
	//	have[i-a[i]]--;
	}
	cout<<ans;
}

Measured memory_bytes: 16552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int r,s,p;
int f(char c){
    if(c=='r')return p;
    if(c=='s')return r;
    if(c=='p')return s;
    return 0;
}

void run(){
    int n,k;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    int ans=0;
    rep(i,n){
        if(i>=k&&t[i-k]==t[i]){
            t[i]='?';
        }
        ans+=f(t[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
from math import floor, sqrt
from collections import defaultdict
def factors(n):
    d = defaultdict(int)
    for i in range(2,floor(sqrt(n))+1):
        while n % i == 0:
            n //= i
            d[i] += 1
        if n == 1:
            break
    if n != 1:
        d[n] += 1
    return d
N = int(input())
mod = 10**9+7
d = defaultdict(int)
for i in range(1,N+1):
    e = factors(i)
    for k in e:
        d[k] += e[k]
ans = 1
for k in d:
    ans = (ans*(d[k]+1)) % mod
print(ans)

Measured memory_bytes: 43224
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean flag = false;

		String st[] = new String[N];

		for(int n=0;n<N;n++){
			st[n] = sc.next();
		}

		for(int n=0;n<N;n++){
			for(int m=n+1;m<N;m++){
				if(st[n].equals(st[m])){
					flag = true;
					break;
				}
			}
		}

		char ch = st[0].charAt(st[0].length()-1);
		for(int n=1;n<N;n++){
			if(ch != st[n].charAt(0)){
				flag = true;
				break;
			}
			ch = st[n].charAt(st[n].length()-1);
		}

		if(flag) System.out.println("No");
		else System.out.println("Yes");

	}
}

Measured memory_bytes: 23508
import java.util.Scanner;

/**
 * A - Station and Bus
 * AtCoder 市には 3 つの駅があり、1,2,3 の番号がつけられています。
 * これらの駅は、それぞれ鉄道会社A, Bのいずれかが管理しています。
 * 管理状況は長さ3 の文字列S で表され、駅i は Si が A のとき鉄道会社 A が、B のとき鉄道会社 B が管理しています。
 * 鉄道会社 A が管理している駅と、鉄道会社 B が管理している駅の間には、交通の便のためにバスを運行することになりました。
 * 実際にバスが運行することになる駅の組み合わせが存在するかどうかを判定してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // モンスターの体力
        String s = sc.next();
        // AとB両方あればYes
        if( s.contains( "A" ) && s.contains( "B" ) ) {
            System.out.println( "Yes" );
        }
        else {
            System.out.println( "No" );
        }

        sc.close();
    }
}

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

#define ll long long
#define N 4010
const ll MOD = (ll)998244353;
int n;
char s[N];
ll f[N][N];
int a[N], b[N];

template <class T>
void add(T &x, T &y) { x += y; if (x >= MOD) x -= MOD; }

int main()
{
	while (scanf("%s", s + 1) != EOF)
	{
		n = strlen(s + 1);
		for (int i = 1; i <= n; ++i) a[i] = a[i - 1] + 2 - (s[i] - '0'), b[i] = b[i - 1] + s[i] - '0';
		memset(f, 0, sizeof f);
		f[0][0] = 1;
		for (int i = 0; i <= 2 * n; ++i)
			for (int j = 0; j <= i; ++j) if (f[i][j])
			{
				if (a[min(i + 1, n)] > j) add(f[i + 1][j + 1], f[i][j]);
				if (b[min(i + 1, n)] > i - j) add(f[i + 1][j], f[i][j]);
			}
		printf("%lld\n", f[2 * n][a[n]]);
	}
	return 0;
}


Measured memory_bytes: 125952
#include <bits/stdc++.h>
using namespace std;
char x;
long long n = 0;
int main ()
{
    while (cin >> x)
    	{
    		n++;
			if (n % 2 == 1)
				{
					cout << x;
				}
		}
	cout << endl;	
    return 0;                       
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int n,s,cnt;

void dfs(vector<int> A){ 
  
  if(A.size()==n+1){
    int c=0;
    for(int i=1;i<n+1;i++) c+=A[i];
    if(c==s) cnt++;
  }
    
  for(int i=A.back()+1;i<=9;i++){
    A.push_back(i);
    dfs(A);
    A.pop_back();
  }
}


int main(){
  
  while(cin>>n>>s){
    
    if(n==0)break;
    
    cnt=0;
    vector<int> vec(1,-1);
    
    dfs(vec);
    cout<<cnt<<endl;
  }
      
  return 0;
}


Measured memory_bytes: 3092
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        s: chars
    }
    let ss: String = s.into_iter().collect();
    if a >= 3200 {
        println!("{}", ss);
    }else{
        println!("red");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;
int A[MAX_N];

void solve() {
	cin >> N >> K;
	rep(i, 0, N) cin >> A[i];
	cout << (N + K - 3) / (K - 1) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll mod=1e9+7;

struct Matrix{
    ll val[50][50];
    Matrix(){
        rep(i,50){
            rep(j,50){
                val[i][j]=0;
            }
        }
    }
};

Matrix operator*(Matrix a,Matrix b){
    Matrix c;
    rep(i,50){
        rep(j,50){
            rep(k,50){
                c.val[i][j]+=a.val[i][k]*b.val[k][j]%mod;
                c.val[i][j]%=mod;
            }
        }
    }
    return c;
}

Matrix I;

Matrix pow(Matrix a,ll p){
    if(p==0) return I;
    Matrix res=pow(a,p/2);
    res=res*res;
    if(p%2==1) res=res*a;
    return res;
}

int main()
{
    ll n,k;
    cin >> n >> k;
    Matrix a;
    rep(i,n){
        rep(j,n){
            cin >> a.val[i][j];
        }
    }
    rep(i,n){
        I.val[i][i]=1;
    }
    Matrix a_k=pow(a,k);
    ll ans=0;
    rep(i,n){
        rep(j,n){
            ans+=a_k.val[i][j];
            ans%=mod;
        }
    }
    cout << ans << endl;
    return 0;
} 

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

int main() { 
    string s;
    cin >> s;

    int n = s.size();
    vector<int> ans(n,0);
    vector<int> index;
    index.push_back(-1);
    rep(i,n-1) {
        if (s[i] != s[i+1]) {
            index.push_back(i);
        }
    }
    index.push_back(n-1);
    rep(i,index.size()) {
        if (i % 2 == 1) {
            int n_l = index[i] - index[i-1];
            int n_r = index[i+1] - index[i];
            ans[index[i]] = (n_l+1)/2 + n_r/2;
            ans[index[i]+1] = n_l/2 + (n_r+1)/2;
        }
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 1528
#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<ll>> dp(N, vector<ll>(M));
  vector<vector<ll>> sum(N, vector<ll>(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;
    }
  }
  ll ans = sum[N-1][M-1] + 1;
  ans %= MOD;
  cout << ans << CRLF;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 62976
#include<set>  
#include<map>  
#include<stack>  
#include<cstdio>  
#include<queue>  
#include<cmath>  
#include<vector>  
#include<cstring> 
#include<iostream> 
#include<climits>  
#include<algorithm> 
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
LL read(){ 
    LL f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
#define MAXN 10
LL a,ans;
int len;
char A[MAXN+5];
LL Pow[15]={1,10,100,1000,10000,100000,1000000,10000000,100000000ll,1000000000ll,10000000000ll};
void DFS(int x,LL sum,LL l){
	if(x>len-1){
		if(!l) ans+=sum;
		return ;
	}
	DFS(x+1,sum,l);
	sum+=l/Pow[len-x-1],l%=Pow[len-x-1];
	DFS(x+1,sum,l);
	return ;
}
int main(){
	scanf("%s",A);
	len=strlen(A);
	sscanf(A,"%lld",&a);
	DFS(0,0,a);
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import numpy as np

def main(w_list):
    cum = np.cumsum(w_list)

    print(min([abs(cum[-1] - 2*cum[i]) for i in range(len(w_list))]))

if __name__ == "__main__":
    N = input()
    w_list = [int(x) for x in input().split()]

    main(w_list)


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

typedef long long ll;
ll N;
vector<ll> A, B;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  B.resize(N);
  // B[i]/2 + B[i-1]/2 == A[i-1]
  for (ll i = 1; i < N; ++i) B[i] = 2 * (A[i - 1] - B[i - 1] / 2);
  // B[0]/2 + B[N-1]/2 == A[N-1]
  ll x = A[N - 1] - (B[0] / 2 + B[N - 1] / 2);
  for (ll i = 0; i < N; ++i) B[i] += (i % 2 == 0 ? 1 : -1) * x;
  bool first = true;
  for (ll b : B) {
    cout << (first ? "" : " ") << b;
    first = false;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

const int limit = 50;

int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int from) {
	visited[from] = true; //訪問した
	rep(to, n) {
		if (!graph[from][to]) continue; //辺がつながっていて
		if (visited[to]) continue; //行ったことがないなら
		dfs(to); //toを始点としてdfs
	}
}

int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	rep(i, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false; //辺の削除
		rep(j, n) visited[j] = false; //全て未訪問
		dfs(0); //始点0からdfs
		bool bridge = false;
		rep(j, n) {
			if (!visited[j]) bridge = true; //未訪問があるなら橋である
		}
		if (bridge) ans++;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true; //戻す
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()

int main()
{
    int N;
    cin >> N;
    int A[N+1];
    A[0] = 0;
    REP(i, N) cin >> A[i+1];

    ll sum = 0;
    REP(i, N+1) {
        sum += abs(A[i]-A[(i+N)%(N+1)]); 
    }

    FOR(i, 1, N+1) {
        ll ans = sum;
        ans -= abs(A[i]-A[i-1]) + abs(A[(i+1)%(N+1)]-A[i]);
        ans += abs(A[(i+1)%(N+1)]-A[i-1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
def I(): return int(input())
def LI(): return list(map(int, input().split()))


n = I()
a = LI()
cnt = [0] * ((10 ** 6) + 1)
for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10 ** 6) + 1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10 ** 6) + 1)

a = list(set(a))

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 47528
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int64_t X, Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    cout << X << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
// ABC151A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
    char C;
	cin >> C;
	int num=(int)C;
	cout << (char)(num + 1)<<endl;
}

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

template <class T>
class Lazy_Segment_Tree{
	private:
	int n;
	vector<T> date,lazy;
	void Set_Lazy(int k,T x){
		date[k]+=x;
		lazy[k]+=x;
	}
	void Push(int k){
		Set_Lazy(k*2+1,lazy[k]);
		Set_Lazy(k*2+2,lazy[k]);
		lazy[k]=0;
	}
	void Fix(int k){
		date[k]=min(date[k*2+1],date[k*2+2]);
	}
	void Add_func(int a,int b,int k,int l,int r,T x){
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			Set_Lazy(k,x);
			return;
		}
		Push(k);
		int m=(l+r)/2;
		Add_func(a,b,k*2+1,l,m,x);
		Add_func(a,b,k*2+2,m,r,x);
		Fix(k);
	}
	public:
	Lazy_Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=lazy=vector<T>(2*n-1);
		for(int i=0;i<n_;i++) date[i+n-1]=n_-i-1;
		for(int i=n-2;i>=0;i--) date[i]=min(date[i*2+1],date[i*2+2]);
	}
	void Add(int a,int b,T x){
		Add_func(a,b,0,0,n,x);
	}
	T Min(){
		return date[0];
	}
};

int n,m;
vvi a;

int main(){
	cin>>n>>m;
	a=vvi(m+1);
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		a[l].push_back(r);
	}
	Lazy_Segment_Tree<int> st(m+1);
	priority_queue<int> q;
	int t=0;
	for(int l=0;l<=m;l++){
		for(auto r:a[l]){
			q.push(r);
			st.Add(0,r,-1);
			t++;
		}
		while(t>m||st.Min()<0){
			int r=q.top();
			st.Add(0,r,1);
			t--;
		}
		st.Add(0,m+1,1);
	}
	cout<<n-t<<endl;
}

Measured memory_bytes: 13820
N = gets.to_i
MOD = 10 ** 9 + 7

if N < 2
  puts 0
else
  all = 10.pow(N, MOD)
  no_9 = 9.pow(N, MOD)
  no_0 = 9.pow(N, MOD)
  no_09 = 8.pow(N, MOD)

  puts (all - (no_0 + no_9) + no_09) % MOD
end


Measured memory_bytes: 14420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;cin>>n>>k;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    vector<bool> dp(k+1,0);
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-v[j]>=0&&dp[i-v[j]]==0)dp[i]=1;
        }
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
    
}

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


int main() {
  string S;
  cin>>S;
  int N=S.size();
    
  
  vector<char> a(N,'0');
  vector<char> b(N,'0');
  if(N%2==0){
    for(int i=0;i<N/2;i++){
      a.at(2*i)='1';
      b.at(2*i+1)='1';
    }
  }
  else{
    for(int i=0;i<N/2;i++){
      a.at(2*i)='1';
      b.at(2*i+1)='1';
      a.at(N-1)='1';
    }
  }
  
  int suma=0;
  for(int i=0;i<N;i++){
    if(S.at(i)!=a.at(i)) suma++;
  }
  int sumb=0;
   for(int i=0;i<N;i++){
    if(S.at(i)!=b.at(i)) sumb++;
  }
  if(N==1) cout<<0<<endl;
  else cout<<min(suma,sumb)<<endl;
 
  
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll mod = 1e9 + 7;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, d; cin >> n >> d;
    ll x[n], y[n];
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    ll d2 = d * d;
    ll cnt = 0;
    rep(i, n){
        if(x[i] * x[i] + y[i] * y[i] <= d2){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main() {

  int N,K,X;
  cin >> N >> K;
  int A = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> X;
    if (X < K-X) {
      A += 2 * X;
    }
    else { A += 2 * (K-X); }
  }
  cout << A << endl;
}


Measured memory_bytes: 3604
n = int(input())

guidebook = list()
for num in range(n):
    s = input().split()
    new_page = [s[0], -int(s[1]), int(num + 1)]
    guidebook.append(new_page)
sorted_data = sorted(guidebook, key=lambda x:(x[0], x[1]))

for page in sorted_data:
    print(page[2])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    
    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
        int val1 = sc.nextInt();
        
        int hour = val1/3600;
        Math.floor(hour);
        
        int minutes =val1/60 ;
        Math.floor(minutes);
        minutes = minutes - hour*60;
        
        int second = val1 ;
        second = second - (hour*3600 + minutes*60);
        
        System.out.println((hour) + ":" + (minutes) +":"+ (second));
         
    }
    
}


Measured memory_bytes: 26360
/*
Watch
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, 
$s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Input
An integer $S$ is given in a line.

Output
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.

Constraints
$0 \leq S \leq 86400$
*/
#include <iostream>

using namespace std;

int main(){
	int S;	//Seconds
	int h,m,s;
	
	cin>>S;
	
	s=S%60;S=S/60;
	m=S%60;S=S/60;
	h=S;
	
	cout<<h<<":"<<m<<":"<<s<<endl;
	
	return 0;
}


Measured memory_bytes: 3088
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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


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

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

class HashPair
{
public:
	static size_t m_hash_pair_random;

	template<class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const {

		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);

		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= m_hash_pair_random + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

size_t HashPair::m_hash_pair_random = (size_t)random_device()();

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	//map<pll, int> cnt;
	unordered_map<pll, int, HashPair> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = 1;
	if (cnt[{0, 0}] == 0)
		num00 = 0;
	else
		num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0,0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = cnt.begin();
		pll this_pair = this_item->first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item->second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(this_item);
		cnt.erase(anti_item);
	}
	ll retval = (num00 + num + modval - 1) % modval;  // -1 for zero-case
	cout << retval << "\n";
		
	return 0;
}
MY_NAMESPACE_

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define SZ(S) S.size()
#define vi vector<int>
#define pr pair<int,int>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define FORD(i,b,a) for(int i=(int)(b);i>=(int)(a);--i)
#define CLR(A,x) memset(A,x,sizeof(A))
#define ALL(S) S.begin(),S.end()

#define OUT(a,l,r) cout<<#a": ";FOR(i,l,r)cout<<a[i]<<" ";cout<<endl
#define PRT(a) cout<<"--> "#a" "<<a<<endl

using namespace std;
typedef unsigned long long ll;

const int N=90,INF=0x3f3f3f3f;
const ll P=1e9+7;

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

ll f[N];
int w1[]={0,1,0,-1};
int w2[]={-1,0,1,0};

int main() {
	f[0]=f[1]=1;
	REP(i,2,N) f[i]=f[i-1]+f[i-2];
	
	ll T,x,y;
	read(T);
	while(T--) {
		read(x),read(y);
		if(y>x) swap(x,y);
		int now=1;
		while(f[now+2]<=x&&f[now+1]<=y) now++;
		
		if(now==1) {
			printf("%d %lld\n",now,(x*y)%P);
			continue;
		}
		
		ll a=f[now+1],b=f[now];
		ll ans=0;
		if(x>=a&&y>=b) ans=(ans+1+(x-a)/b)%P;
		if(y>=a&&x>=b) ans=(ans+1+(y-a)/b)%P;
		
		int t=0;
		FORD(i,now,0) {
			t=(t+1)%4;
			a+=f[i]*w1[t],b+=f[i]*w2[t];
			if(i!=now) {
				if(x>=a&&y>=b) ans=(ans+1+(x-a)/b)%P;
				if(y>=a&&x>=b) ans=(ans+1+(y-a)/b)%P;
			}
		}
		printf("%d %lld\n",now,ans);
	}
	return 0;
}

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

int main(){
  int a;
  int b;
  int c;
  int d;
  int p;
  int ans;
  int x;
  int y;

  cin >> a >> b >> c >> d >> p;

  x = a * p;

  if (c >= p){
    y = b;
  }

  else {
    y = b + (p - c) * d;
  }

  if (x > y){
    cout << y <<"\n";
  }
  else {
    cout << x  <<"\n";
  }

  return 0;
}
    
  

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

int main(){

    int n; cin >> n;

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

    sort(d, d+n);

    // for(int i=0; i<n; i++){
    //     cout << d[i];
    // }

    cout << (d[n/2] - d[n/2-1]) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	double a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v == w)
	{
		if (a == b)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		return 0;
	}
	if (b > a)
	{
		double temp = (b - a) / (v - w);
		if (temp > 0 && temp <= t)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		return 0;
	}
	if (a > b)
	{
		double temp = (b - a) / (w - v);
		if (temp > 0 && temp <= t)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		return 0;
	}
}

Measured memory_bytes: 3784
#include <stdio.h>

#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest, s;
  l = 2*i;
  r = 2*i+1;
  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;
  if(largest!=i){
    //swap(A[i], A[largest]);
    s = A[i];
    A[i] = A[largest];
    A[largest] = s;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  
  scanf("%d", &H);

  for(i=1; i<=H; i++) scanf("%d", &A[i]);

  for(i=H/2; i>=1; i--) maxHeapify(i);

  for(i=1; i<=H; i++){
    //if(i<H) printf("%d ", A[i]);
    //else printf("%d", A[i]);
    printf(" %d", A[i]);
  }

  printf("\n");
    
  return 0;
}



Measured memory_bytes: 3808