akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll n,m;
vector<ll> vec,rsum;
ll judge(ll val,ll pos){
  val-=vec[pos];
  ll num=lower_bound(vec.begin(),vec.end(),val)-vec.begin();
  return n-num;
}
ll j2(ll val,ll pos){
  val-=vec[pos];
  ll num=lower_bound(vec.begin(),vec.end(),val)-vec.begin();
  ll res=n-num;
  if(res<=0) return 0;
  if(num==0) return vec[pos]*res+rsum[n-1];
  else return vec[pos]*res+rsum[n-1]-rsum[num-1];
}
int main(){
  cin>>n>>m;
  vector<ll> kv;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    kv.push_back(a);
  }
  sort(kv.begin(),kv.end());
  for(int i=0;i<n;i++){
    vec.push_back(kv[i]);
    if(i==0) rsum.push_back(kv[i]);
    else rsum.push_back(rsum[i-1]+kv[i]);
  }
  vec.push_back(174417441744);
  ll lb=0,rb=174417441744;
  while(rb-lb>1){
    ll mid=(lb+rb)/2;
    ll kans=0;
    for(int i=0;i<n;i++){
      kans+=judge(mid,i);
    }
    if(kans>=m) lb=mid;
    else rb=mid;
  }
  ll ans=0,cnt=0;
  for(int i=0;i<n;i++) {
    ans+=j2(lb,i);
    cnt+=judge(lb,i);
    //cout<<j2(lb,i)<<" "<<judge(lb,i)<<endl;
  }
  //cout<<lb<<endl;
  if(cnt>m) ans-=(cnt-m)*lb;
  cout<<ans<<endl;
}


Measured memory_bytes: 3444
#include <stdio.h>

int main (void){
    int x1=0, x2 = 0, x3 = 0, input, s;

    for(s=0; s<10; s++){
        scanf("%d\n" ,&input);
        if(x1 < input){
            x3 = x2;
            x2 = x1;
            x1 = input;
        }else{
            if(x2 < input){
                x3 = x2;
                x2 = input;
            }else if(x3 < input) x3 = input;
        }
    }
    printf("%d\n%d\n%d\n",x1,x2,x3);
    return(0);
}

Measured memory_bytes: 1032
import sys
input = sys.stdin.readline

s = input().strip()
q = int(input())
query = [list(input().strip().split()) for _ in range(q)]

left = ''
right = ''
t = False
for ls in query:
    if len(ls) == 1:
        t = not t
    else:
        two, f, c = ls
        if f == '1':
            if t:
                right += c
            else:
                left += c
        else:
            if t:
                left += c
            else:
                right += c

if t:
    print(right[::-1] + s[::-1] + left)
else:
    print(left[::-1] + s + right)
    

Measured memory_bytes: 30964
#include<bits/stdc++.h>
using namespace std;
long long N,D,X,Y,ans;
int main(){
    cin>>N>>D;
    for(int i=0;i<N;i++){
        cin>>X>>Y;
        if(X*X+Y*Y<=D*D)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <string>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	double a, b, c;
	cin >> a >> b >> c;
	double c_ = c * M_PI / 180;
	double h = sin(c_) * b;
	double x = sqrt(pow(h, 2) + pow(a - cos(c_) * b, 2));
	cout << setprecision(100) << a * h / 2 << " " << a + b + x << " " << h << endl;
}


Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

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

    bool flg = false;
    rep(i, n) {
        string t = s.substr(0, i);
        if(s == t + t) flg = true; 
    }

    cout << (flg ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr==[]:
        arr.add(n)

    return arr

a,b = map(int, input().split())
a_soi = factorization(a)
b_soi = factorization(b)
both = list(a_soi & b_soi)
print(len(both)+1)

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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int len = s.length();

        int cnt0 = 0, cnt1 = 0;
        for (int i = 0; i < len; i++) {
            if (s.charAt(i) != ((i % 2 == 0) ? '0' : '1')) {
                cnt0++;
            } else {
                cnt1++;
            }
        }

        System.out.println(Math.min(cnt0, cnt1));
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23764
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


//右側と左側からのgcdをやると計算量が減るらしい．
void main()
{
    auto n = lread();
    auto a = aryread();
    long[] b = new long[n + 1];
    long[] c = new long[n + 1];
    foreach (i, ref e; b)
    {
        if (i == 0)
        {
            continue;
        }
        e = gcd(b[i - 1], a[i - 1]);
    }
    foreach_reverse (i, ref e; c)
    {
        if (i == n)
        {
            continue;
        }
        e = gcd(c[i + 1], a[i]);
    }
    // writeln(a);
    // writeln(b);
    // writeln(c);
    long max_gcd = 0;
    foreach (i; 0 .. n)
    {
        max_gcd = max(gcd(b[i], c[i + 1]), max_gcd);
    }
    writeln(max_gcd);
}

Measured memory_bytes: 7368
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int n, d; cin >> n >> d;
    int x = 2*d+1;
    
    int ans = (n+x-1)/x;
    cout << ans << endl;
    
    
 

}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        a_s: [usize; n],
    }
    let mut deque = a_s
        .iter()
        .take(k)
        .cloned()
        .collect::<std::collections::VecDeque<_>>();
    for i in k..n {
        let front = deque.pop_front().unwrap();
        deque.push_back(a_s[i]);
        let ans = if front < a_s[i] { "Yes" } else { "No" };
        println!("{}", ans);
    }
}


Measured memory_bytes: 6952
#include<stdio.h>
int main(void)
{
    int N,Ans=0;
    char S[100000];
    scanf("%d\n",&N);
    //scanf("%c",&S[0]);
    for(int i=1;i<=N;i++)
    {
        scanf("%c",&S[i]);
    }
    for(int i=1;i<=N-1;i++)
    {
        if(S[i]!=S[i+1])
        {
            Ans=Ans+1;
        }
    }
    printf("%d\n",Ans+1);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

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

    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int n;
	cin >> n;
	if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	if (n == 25) {
		cout << "Christmas" << endl;
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using std::vector;
using std::find;
using std::distance;
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);

    for(int i = 0; i < M; i++) {
        int  x, y, z;
        cin >> x >> y >> z;
        tree.unite(x-1, y-1); // xの木とyの木を併合する
    }

    int cnt=1;
    for(int i=0;i<N;i++){
        if(!tree.same(0,i)){
            tree.unite(0, i);
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int N, M;
  int L[100000], R[100000];
  
  
  cin >> N >> M;
  
  int min = 0;
  int max = N;
  
  for(int i = 0; i < M; i++)
  {
    cin >> L[i] >> R[i];
    
    if (L[i] > min) min = L[i];
    if (R[i] < max) max = R[i];
  }
  
  int total = 0;
  
  //cout << max << ' ' << min << endl;
  
  if ((max - min) >= 0) 
  {
    total = (max - min) + 1;
  }
  
  cout << total << endl;
}

Measured memory_bytes: 4388
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/


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

using ll = long long;

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

    ll n, k;
    cin >> n >> k;

    ll sum = 0;
    // k = 1;
    for (ll b = k + 1; b <= n; ++b) {
        // if (k == 0){
        //     sum += n;
        // } else {
            sum +=  n / b * (b - k);
            ll res = n + 1 - (n / b * b + k);
            if (res > 0) sum += res;
        // }
    }
    if (k == 0) sum -= n;

    cout << sum << '\n';
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  string s,t;
  cin >> s >> t;
  string u;
  for (int i = 0; i < N; i++) {
    u += s.at(i);
    u += t.at(i);
}
      cout << u << endl;
}


Measured memory_bytes: 256
/*
AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

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

    int A, B, K;
    cin >> A >> B >> K;

    for(int i = A; i <= B; i++){
        if(i < A + K || i > B - K) cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
<?php

class Inputs
{
    public static function d()
    {
        fscanf(STDIN, '%d', $a);
        return $a;
    }
    public static function ss()
    {
        fscanf(STDIN, "%s %s", $s, $t);
        return [$s, $t];
    }
}

$n = Inputs::d();
list($s, $t) = Inputs::ss();

$ss = str_split($s);
$st = str_split($t);

foreach ($ss as $i => $k) {
    echo $k . $st[$i];
}
echo PHP_EOL;


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Integer[] H = new Integer[N];
        for (int i=0;i<N;i++) {
            H[i] = sc.nextInt();
        }
        Arrays.sort(H, (o1, o2)->Integer.compare(o2, o1));
        long ans = 0L;
        for (int i=0;i<N;i++) {
            if (K>0) {
                K--;
                continue;
            }
            ans += H[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 96632
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main() {
  int n, x;
  int l[n];
  cin >> n >> x;
  for (int i=0;i<n;i++) cin >> l[i];
  int sum = 0;
  for (int i=0;i<n;i++){
    sum = sum + l[i];
    if (sum > x){
      cout << i+1 << endl;
      exit(0);
    }
  }
  cout << n+1 << endl;
}

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

int N;
vector<pair<int, int>> adj[100000];
int color[100000];


void go(int now){
    int now_color = color[now];
    for(int i = 0; i < adj[now].size(); i++){
        int next = adj[now][i].first;
        int next_color = ((now_color - 1) + adj[now][i].second) % 2 + 1;
        if(color[next] == 0){
            color[next] = next_color;
            go(next);
        }
    }
        
}

int main(){
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        adj[u - 1].push_back(make_pair(v - 1, w % 2));
        adj[v - 1].push_back(make_pair(u - 1, w % 2));
    }

    color[0] = 1;
    go(0);
    for(int i = 0; i < N; i++){
        cout << color[i] - 1 << endl;
    }
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> a(H,vector<char>(W)) ;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a.at(i).at(j);
    }
  }
  vector<bool> yoko(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)=='#')break;
      if(j==W-1) yoko.at(i)=1;
    }
  }
   vector<bool> tate(W);
  for(int i=0;i<W;i++){
    for(int j=0;j<H;j++){
      if(a.at(j).at(i)=='#')break;
      if(j==H-1) tate.at(i)=1;
    }
  }
  for(int i=0;i<H;i++){
    if(yoko.at(i))continue;
    for(int j=0;j<W;j++){
      if(tate.at(j))continue;
      cout<<a.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
ans = ""
flag = 1
al = ["z","a","b","c","d","e","f","g","h","i","j",
      "k","l","m","n","o","p","q","r","s","t",
      "u","v","w","x","y"]

while(n > 0):
    a = n % 26
    n = n //26
    for i in range(26):
        if a == i:
            ans += al[i]
    if a == 0:
        
        n = n - 1

ans = ans[::-1]

print(ans)

Measured memory_bytes: 9108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a = Integer.parseInt(in.next());
            String ans = "No";

            int rem = n % 500;
            if (rem <= a) ans = "Yes";

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;


template <class T>
class Matrix {
    public:
        Matrix(int h,int w,T u = 1) : mHeight(h), mWidth(w), mUnit(u) {
            mData.assign(h,vector<T>(w));
        }

        Matrix GetIdentity(int n){
            Matrix identity(n,n);
            for(int i = 0; i < n; ++i){
                identity[i][i] = mUnit;
            }
            return identity;
        }

        // matrix multiplication
        Matrix &operator*=(Matrix &m){
            int h = m.GetHeight();
            int w = m.GetWidth();
            // assert(h == mWidth);
            mRes.assign(mHeight,vector<T>(w));
            for(int i = 0; i < mHeight; ++i){
                for(int j = 0; j < w; ++j){
                    T x = 0;
                    for(int k = 0; k < mWidth; ++k){
                       x  += GetCell(i,k) * m.GetCell(k,j);
                    }
                    mRes[i][j] = x;
                }
            }
            mData.swap(mRes);
            return *this;
        }
        //

        // only square matrix
        Matrix operator^(int exp){
            Matrix res = GetIdentity(mHeight);
            while(exp > 0){
                if(exp & 1) res *= mData;
                mData *= mData;
                exp >>= 1;
            }
            return res;
        }
        //

        T& GetCell(int i, int j){ return mData[i][j];}
        int GetHeight() const { return mHeight;}
        int GetWidth() const { return mWidth;}

    private:
        vector<vector<T> > mData;
        vector<vector<T> > mRes;
        int mHeight;
        int mWidth;
        T mUnit;

};

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    Matrix<long long> a(n,m);
    Matrix<long long> b(m,l);
    for(int i = 0;i < n;++i){
        for(int j = 0; j < m; ++j){
            cin >> a.GetCell(i,j);
        }
    }

    for(int i = 0; i < m; ++i){
        for(int j = 0; j < l; ++j){
            cin >> b.GetCell(i,j);
        }
    }
    a *= b;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            cout << a.GetCell(i,j) << (j==l-1 ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<P> edge(n);
  rep(i, n){
    int x, l;cin>>x>>l;
    edge[i]=P(x+l, x-l);
  }
  sort(edge.begin(), edge.end());
  int ans=1, pos=0;
  repb(i, 1, n){
  	if(edge[i].second<edge[pos].first)continue;
    else{
      ans++;pos=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1152
#include <stdio.h>

int solve1(int, int *, int, int);

int main(){
  int n, a[20], q, mi[200], i, x;

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

  scanf("%d" ,&q);
  for(i = 0; i < q; i++) scanf("%d" ,&mi[i]);

  for(i = 0; i < q; i++){
    x = solve1(n, a, 0, mi[i]);
    if(x == 1) printf("yes\n");	 
    else printf("no\n");
    }
  return 0;
}

int solve1(int n, int *a, int i, int mi){ 
  int res1;

  if(mi == 0) return 1;
  else if(i >= n) return 0;

  res1 = solve1(n, a, i + 1, mi) || solve1(n, a, i + 1, mi - a[i]);
  return res1;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N; cin >> N;
  string s; cin >> s;

  int ans = 0;
  int i = 0;
  while (true) {
    size_t p = s.find("ABC", i);
    if (p == string::npos) break;
    ans++;
    i = p + 3;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
if n == 0:
  print(0)
  exit()
ans = []
while n>0 or n<0:
  if n == 0:
    break
  else:
    if n%2==0:
      ans.append(0)
      n = n//(-2)
    else:
      ans.append(1)
      n = (n-1)//(-2)
    
print(*ans[::-1], sep='')

Measured memory_bytes: 9124
#include <iostream>

int main()
{
	int n, k, a = 1;
	std::cin >> n >> k;
	
	for (int i = 0; i < n; ++i)
	{
		if (a * 2 <= a + k)
			a *= 2;
		else
			a += k;
	}
	
	std::cout << a;
}

Measured memory_bytes: 256
N,Q = map(int, input().split())
S   = input()
L = []
R = []
A = []

for _ in range(Q):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)
Query = list(zip(L, R))

for i in range(len(S)-1):
    if S[i]=="A" and S[i+1]=="C":
        A.append(1)
    else:
        A.append(0)

S = [0]*(len(A)+1)
for i in range(len(A)):
    S[i+1] = S[i] + A[i]

for l,r in Query:
    print(S[r-1]-S[l-1])

Measured memory_bytes: 23732
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	llong mod=998244353;
	
	int n;
	cin>>n;
	
	vi d(n);
	int tmp=0;
	REP(i,n){
		cin>>d[i];
		tmp=max(tmp,d[i]);
	}
	
	vector<llong> cnt(n,0);
	REP(i,n) cnt[d[i]]++;
	
	if(d[0]==0 and cnt[0]==1){}
	else{
		cout<<0<<endl;
		return 0;
	}
	
	llong ans=1;
	REP(i,tmp){
		if(cnt[i]==0){
			cout<<0<<endl;
			return 0;
		}
		REP(j,cnt[i+1]){
			ans*=cnt[i];
			ans%=mod;
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 1408
N, M = map(int, input().split())

if N % 2 == 1:
    for i in range(M):
        j = N - i
        print(f'{i + 1} {j}')
else:
    for i in range(M):
        j = N - i
        if i < M / 2:
            print(f'{i + 1} {j}')
        else:
            print(f'{i + 1} {j - 1}')


Measured memory_bytes: 9180
#include <stdio.h>

#define N 100

int main(void){

  int i,j,n,tmp,c=0;
  int arr[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }

  for(i=0;i<n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(arr[j] < arr[j-1]){
	tmp = arr[j];
	arr[j] = arr[j-1];
	arr[j-1] = tmp;
	c++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",arr[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n%d\n",c);
  
  return 0;
}



Measured memory_bytes: 2064
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		string inputs = Console.ReadLine();
		int len = inputs.Length;


		if (Calc(inputs.Substring(0, (len - 1) / 2)) == false)
		{
			Console.WriteLine("No");
			return;
		}

		if (Calc(inputs.Substring((len + 2) / 2)) == false)
		{
			Console.WriteLine("No");
			return;
		}

		if (Calc(inputs) == false)
		{
			Console.WriteLine("No");
			return;
		}

		Console.WriteLine("Yes");
	}

	private static bool Calc(string word)
	{
		string revWord = word;
		revWord = new string(revWord.Reverse().ToArray());

		if (word == revWord)
			return true;
		else
			return false;
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std ;
int main ()
{
int A,B;
scanf("%d %d",&A,&B);
if (A==1&&B==1)
cout<<"Draw";
else if (A==1)
cout<<"Alice";
else if (B==1)
cout<<"Bob";
else if (A>B)
cout<<"Alice";
else if (B>A)
cout<<"Bob";
else
cout<<"Draw";

}

Measured memory_bytes: 256
from collections import Counter
N, P = map(int, input().split())
if P not in [2,5]:
  pt = [1]
  for i in range(N):
    pt.append(pt[-1]*10%P)
  S = [int(c)%P for c in input()]
  dp = [(S[0]*pt[N-1])%P]
  for i in range(1,N):
    dp.append((dp[-1]+S[i]*pt[N-1-i])%P)

  c = Counter(dp)
  ans = sum(u*(u-1)//2 for u in c.values())
  print(ans+c[0])
elif P==2:
  S = [int(c) for c in input()]
  ans = 0
  for i in range(N):
    if S[i]%2==0:
      ans += i+1
  print(ans)
else:
  ans = 0
  S = [int(c) for c in input()]
  for i in range(N):
    if S[i]%5==0:
      ans += i+1
  print(ans)

Measured memory_bytes: 61492
#include<stdio.h>
int main(void)
{
	int N,i;
	int count =0;
	scanf("%d", &N);
	for(i =1; i <= N;i++){
		int j = i;
		int digit =0;
		while(j !=0){
		j = j / 10;
		++digit;}
		int n =digit;
	if(n%2==1){
	count++;}
		else count=count+0;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
import sys
i = []
for line in sys.stdin.readlines():
  i.append(line.rstrip().split(" "))

list_i1 = [int(s) for s in i[1]]

a = 0
distance = []
for list_i1[a] in list_i1:
  if a > len(list_i1)-2:
    break
  distance.append(list_i1[a+1] - list_i1[a]) 
  a += 1
c = 0
for b in distance:
  c += b
distance.append(int(i[0][0]) - c)

print(int(i[0][0]) - max(distance))

Measured memory_bytes: 26728
function main(input) {
    input = input.trim().split("\n");
    var n = parseInt(input[0].split(" "), 10);
    var days = 0;
    input[1].split(" ").forEach(x => {
        days += parseInt(x, 10);
    })

    if (n-days < 0) {
        console.log(-1);
    } else {
        console.log(n-days);
    }

  }
   
  main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30616
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val nums = listOfInt()
    if (nums[0] <= nums[2] && nums[2] <= nums[1]) {
        println("Yes")
    } else {
        println("No")
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37812
#include<stdio.h>
int main(void)
{
	
	int a1,a2,a3,a4;
	int b1,b2,b3,b4;
	while(scanf("%d %d %d %d %d %d %d %d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)!=EOF){
 int co=0,co2=0;
 if(a1==b1)co++;
else if(a1==b2 || a1==b3 || a1==b4)co2++;
 if(a2==b2)co++;
else  if(a2==b1 || a2==b3 || a2==b4)co2++;
 if(a3==b3)co++;
 else  if(a3==b1 || a3==b2 || a3==b4)co2++;
 if(a4==b4)co++;
else  if(a4==b1 || a4==b2 || a4==b3)co2++;
 printf("%d %d\n",co,co2);
	}
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#define INF 1000000
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m, n | m)
	{
		string master[15], str[15];
		int num[15] = {};
		for (int i = 0; i < n; i++)
		{
			cin >> master[i];
			int pos = 0;
			while (master[i][pos] == '.')
			{
				num[i]++;
				pos++;
			}
		}
		for (int i = 0; i < m; i++)
			cin >> str[i];
		int R1[15] = {}, C1[15] = {}, S1[15] = {};
		int R2[15] = {}, C2[15] = {}, S2[15] = {};
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < master[i].size(); j++)
			{
				if (master[i][j] == '(')
					R1[i]++;
				if (master[i][j] == '{')
					C1[i]++;
				if (master[i][j] == '[')
					S1[i]++;
				if (master[i][j] == ')')
					R1[i]--;
				if (master[i][j] == '}')
					C1[i]--;
				if (master[i][j] == ']')
					S1[i]--;
			}
			R1[i + 1] = R1[i];
			C1[i + 1] = C1[i];
			S1[i + 1] = S1[i];
		}
		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < str[i].size(); j++)
			{
				if (str[i][j] == '(')
					R2[i]++;
				if (str[i][j] == '{')
					C2[i]++;
				if (str[i][j] == '[')
					S2[i]++;
				if (str[i][j] == ')')
					R2[i]--;
				if (str[i][j] == '}')
					C2[i]--;
				if (str[i][j] == ']')
					S2[i]--;
			}
			R2[i + 1] = R2[i];
			C2[i + 1] = C2[i];
			S2[i + 1] = S2[i];
		}
		vector<int> vec(15, INF);
		vec[0] = 0;
		for (int r = 1; r <= 20; r++)
		{
			for (int c = 1; c <= 20; c++)
			{
				for (int s = 1; s <= 20; s++)
				{
					bool flag = true;
					for(int i = 0; i < n - 1; i++)
					{
						if (R1[i] * r + C1[i] * c + S1[i] * s != num[i + 1])
							flag = false;
					}
					if(flag)
					{
						for(int i = 0; i < m - 1; i++)
						{
							int tmp = R2[i] * r + C2[i] * c + S2[i] * s ;
							if(vec[i + 1] == -1 || vec[i + 1] == tmp)
								continue;
							if(vec[i + 1] != tmp && vec[i + 1] != INF)
								vec[i + 1] = -1;
							else
								vec[i + 1] = tmp;
						}
					}
				}	
			}
		}
		for(int i = 0; i < m; i++)
		{
			if(i == 0)
				cout << vec[i];
			else
				cout << " " << vec[i];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3012
#include <stdio.h>
#include <string.h>
int main()
{
char str[100];
scanf("%s", str);
int a = 0, c = 0, i;
for(i = 0; i < strlen(str)-1;i++){
if(str[i] == 'A' && str[i+1] == 'C')
a = 1;
}
if(a)
printf("Yes\n");
else
printf("No\n");
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    int l = 1, r = N - 1;
    cout << 0 << endl;
    string fx;
    cin >> fx;
    if (fx == "Vacant") {
        return 0;
    }
    string opp = (fx == "Male" ? "Female" : "Male");
    string act[2] = {fx, opp};
    REP (i, 0, 19) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        string res;
        cin >> res;
        if (res == "Vacant") {
            return 0;
        }
        int t = mid % 2;
        if (res == act[t]) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
        dump(l);
        dump(r);
    }
    return 0;
}

Measured memory_bytes: 852
n=io.read("*n")
d={}
for i=1,n do
  table.insert(d,io.read("*n"))
end

v={}
for i=1,n-1 do
  l=0
  for j=i+1,n do
    l=l+d[j]
  end
  table.insert(v,l)
end

ans=0
for i=1,n-1 do
  ans=ans+(d[i]*v[i])
end

print(ans)

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

using namespace std;

char taro[100];
char hanako[100];

void clean(char arr[]) {
	for (int i = 0; i < 100; i++)
		arr[i] = 0;
}

int main() {
	int n, taro_p = 0, hanako_p = 0;
	bool f;
	cin >> n;
	for (int i = 0; i < n; i++) {
		clean(taro); clean(hanako);
		cin >> taro >> hanako;
		
		f = true;
		for (int j = 0; j < 100; j++) {
			if (taro[j] < hanako[j]) {
				hanako_p += 3;
				f = false;
				break;
			}
			else if (taro[j] > hanako[j]) {
				taro_p += 3;
				f = false;
				break;
			}
		}
		if (f) {
			taro_p++;
			hanako_p++;
		}
	}
	
	cout << taro_p << " " << hanako_p << endl;

	return 0;
}

Measured memory_bytes: 1168
#include <iostream>

using namespace std;

class GreatestCommonDivisor
{
 public:
  int solve( int a, int b );
};

int GreatestCommonDivisor::solve( int a, int b )
{
  while((a != 0) && (b != 0))
    {
      if (a > b)
        {
          a = a % b;
        }
      else
        {
          b = b % a;
        }
    }
  if (a == 0)
    return b;
  else
    return a;
}

int main( void )
{
  int a, b;

  GreatestCommonDivisor *greatestcommondivisor = new GreatestCommonDivisor();

  cin >> a >> b;

  cout << greatestcommondivisor -> solve( a, b ) << endl;

  delete greatestcommondivisor;

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int s;
    cin>>s;
    vector<int> m(1000001);
    int a=s,ans=1;
    while(1){
        if(m[a]!=0)break;
        m[a]++;
        ans++;
        if(a%2==0){
            a/=2;
        }else{
            a=3*a+1;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
	long long int N, W;
	cin >> N >> W;
	long long int w[N+1] = {}, v[N+1] = {};
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}

	long long int dp[N+1][W+1] = {}; //dp[i][w]  ->  iまでの荷物でw以下の重さのOPT 
	for (int i = 0; i <= W; i++) {
		dp[0][i] = 0;
	}

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

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			//荷物iをいれるかどうか
			if (j >= w[i]) { 
				dp[i][j] = max(
					dp[i-1][j - w[i]] + v[i], //荷物iをいれるとき
					dp[i-1][j] //いれないとき
				);
			}
			else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}


	cout << dp[N][W];

	return 0;
}

Measured memory_bytes: 79104
import queue

N, M = map(int, input().split())
e = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    e[A].append(B)
    e[B].append(A)
# print(e)

seen = [-1] * N
k = -1
for i in range(N):
    if seen[i] == -1:
        k += 1
        seen[i] = k
        que = queue.Queue()
        que.put(i)
        while not que.empty():
            v = que.get()
            for nv in e[v]:
                if seen[nv] != -1: continue
                seen[nv] = k
                que.put(nv)
# print(seen)
print(k)


Measured memory_bytes: 27156
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    sc.close();

    // count[0]はaの個数、[1]はbの個数、[25]はzの個数
    int[] count = new int[26];

    for (int i = 0; i < S.length(); i++) {
      count[(int) S.charAt(i) - 97]++;
    }

    String result = "yes";

    for (int i = 0; i < 26; i++) {
      if (2 <= count[i]) {
        result = "no";
        break;
      } 
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 23764
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def prime_decomposition(n):
    table = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            table += [i]
            n //= i
        if n == 1:
            break
    if n != 1:
        table += [n]
    return table

n = I()

ans  = 0
for i in range(1, n + 1):
    r = n - n % i
    cnt = n // i
    ans += (i + r) * cnt // 2




print(ans)


Measured memory_bytes: 76464
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
    while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
    return tmp*f;
}
using namespace std;
int cost[20][20];
int main()
{
	int n=read(),m=read(),i,j,k;
	for(i=0;i<=9;i++)
		for(j=0;j<=9;j++)
			cost[i][j]=read();
	for(k=0;k<=9;k++)
		for(i=0;i<=9;i++)
			for(j=0;j<=9;j++)
				cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	ll ans=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			int k=read();
			if(k>=0)ans+=cost[k][1];
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll m=1e9+7,dp1[105][50005],dp2[105][50005],n,k;

ll get(ll i)
{
	return n/i-n/(i+1);
}

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>k;
ll sq=sqrt(n),sq2=n/sq-1;

if(n==1)
{
	ol("1");
	return 0;
}

rep(i,1,sq)
{
	dp1[1][i]=1;
}
rep(i,1,sq2)
{
	dp2[1][i]=get(i);
}

rep(i,2,k)
{
	rep(j,1,sq)
	{
		dp1[i][1]=(dp1[i][1]+dp1[i-1][j])%m;
		dp2[i][sq2]=(dp2[i][sq2]+dp1[i-1][j])%m;
		dp2[i][j-1]=(dp2[i][j-1]-dp1[i-1][j])%m;
	}
	rep(j,1,sq2)
	{
		dp1[i][1]=(dp1[i][1]+dp2[i-1][j])%m;
		dp1[i][j+1]=(dp1[i][j+1]-dp2[i-1][j])%m;
	}
	rep(j,1,sq)
	{
		dp1[i][j]=(dp1[i][j]+dp1[i][j-1])%m;
	}
	ren(j,sq2,1)
	{
		dp2[i][j]=(dp2[i][j]+dp2[i][j+1])%m;
	}
	rep(j,1,sq2)
	{
		dp2[i][j]=(get(j)*dp2[i][j])%m;
	}
}

ll ans=0;
rep(i,1,sq)
{
	ans=(ans+dp1[k][i])%m;
}
rep(i,1,sq2)
{
	ans=(ans+dp2[k][i])%m;
}
ans=(ans+m)%m;
ol(ans);
return 0;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, Y;
    cin >> n >> Y;
    for (int x=0; x<=n; ++x) {
        for (int y=0; y<=n-x; ++y) {
            int z = n-x-y;
            if (10000*x + 5000*y + 1000*z == Y) {
                cout << x << ' ' << y << ' ' << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
    ll n; cin>>n;
    map<ll,ll> mp;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ll x; cin>>x;
        ans+=mp[i-x];
        mp[i+x]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 26300
#include <stdio.h>
#include <string.h>

int main(void){
  char s[4] = {'\0'};
  char cmp[4] = "abc";
  char temp;
  scanf("%3s", s);
  for(int i = 0; i < 3; i++){
    for(int j = i + 1; j < 3; j++){
      if(s[i] > s[j]){
	temp = s[i];
	s[i] = s[j];
	s[j] = temp;
      }
    }
  }

  if(strcmp(s, cmp) == 0) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int count;
  string num;
  
  cin >> num;
  
  if(num[0] == num[1] && num[0] == num[2] || num[1] == num[2] && num[1] == num[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
bool tap(char a[]){
    for (int i = 0; i < strlen(a); i++) {
        // 奇数
       if(i%2==0){
           if(a[i] == 'L'){
               return false;
           }
       }else{
        // 偶数
           if(a[i] == 'R'){
               return false;
           }
       }
    }
    return true;
}
int main(void){
    char a[100];
    string b;
    
    cin >> a;
    b = "No";
    if(tap(a)){
        b = "Yes";
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
// Tax Rate Changed
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1192&lang=jp
// https://onlinejudge.u-aizu.ac.jp/#/problems/1192
//
// 中央 ×中央

#include <iostream>
using namespace std;

int X, Y, S;

int tax(int rate, int price) {
	return price * (100 + rate) / 100;
}

int solve() {
	int maximum = 0;
	for (int i = 1; i < S; ++i) { 
		for (int j = 1; j < S; ++j) {
			if (tax(X, i) + tax(X, j) == S)
				maximum = max(maximum, tax(Y, i) + tax(Y, j));
		}
	}
	return maximum;
}
//調べたところ、for文の添え字は、C++では前置インクリメントより後置インクリメントの方が良いということだったが、挙動が変わることはないのか？

int main(void) {
	while (cin >> X >> Y >> S && X > 0)	{
		cout << solve() << endl;
	}
}




Measured memory_bytes: 3092
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 1000000001






int A[200001],B[200002],C[200002],D[200002];//Bは前から


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

	int n;
	cin >> n;
	FOR(i, 0, n) {
		cin >> A[i];
		if (D[A[i]] != 0) {
			B[i+1] += D[A[i]];
		}
		B[i+1] += B[i];
		D[A[i]]++;
	}


	FOR(i, 0, 200002)D[i] = 0;
	for (int i = n-1; i >= 0; i--) {
		if (D[A[i]]!= 0) {
			C[i+1] += D[A[i]];
		}
		C[i+1] += C[i + 2];
		D[A[i]]++;
	}
	ll sum = 0;
	FOR(i, 1, n + 1)sum += B[i] - B[i - 1] + C[i] - C[i + 1];
	sum /= 2;
	FOR(i, 1, n+1) {
		cout << sum -(B[i] - B[i - 1] + C[i] - C[i + 1]) << endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 5760
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var s = nextstr(), t = nextstr();
  var ans = 0;
  for(var i = 0; i < s.length; i++){
    if(s[i] !== t[i])ans++;
  }
  return ans;
}

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

int main() {
  int N;
  cin >>N;
   for (int i = 1; i <10; i++) {
   if(N/i<10 && N%i==0){
   cout << "Yes";
   return 0;
    }
   }
  cout << "No";
 }


Measured memory_bytes: 3604
def readln():
    return list(map(int, input().split()))


D, G = readln()
PC = [readln() for _ in range(D)]

ans = 10000

for i in range(1 << D):
    score = 0
    difficulty = -1  # バグにならないようにあとで注意
    n_problem = 0
    for j in range(D):
        if (i >> j) % 2:
            score += PC[j][1] + PC[j][0] * 100 * (j + 1)
            n_problem += PC[j][0]
        else:
            difficulty = max(difficulty, j)

    if difficulty == -1:  # すべてが−1となるとき全問取り終わっているということ
        ans = min(ans, n_problem)
        break

    for j in range(PC[difficulty][0]):
        # print(j)
        if score >= G:
            ans = min(ans, n_problem)
            # print(ans)
            break
        else:
            score += (difficulty+1) * 100
            n_problem += 1

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,k;
    cin>>n>>k;
    if(n<=5) cout<<0<<endl;
    else if(n>=6 && n<=12) cout<<k/2<<endl;
    else if(n>=13) cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=100000;
struct edge{
    int src,dst,cost;
    edge(int src,int dst,int cost):
    src(src),dst(dst),cost(cost){}
    };
bool operator < (const edge &e,const edge &f){
    return e.cost!=f.cost?e.cost<f.cost:
    e.src!=f.src?e.src<f.src:e.dst<f.dst;
}
struct UnionFind{
    int par[MAX_N],rank[MAX_N]; 
    void init(int n){
        for (int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    } 
    int find(int x){
        if (x==par[x]) return (x);
        return (par[x]=find(par[x]));
    }
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    } 
    bool same(int x, int y){
        return (find(x) == find(y));
    } 
};
vector<edge> ve;
int kruskal(int v){
    sort(ve.begin(),ve.end());
    UnionFind uf;
    uf.init(v);
    int res=0;
    rep(i,ve.size()){
        edge e=ve[i];
        if(!uf.same(e.src,e.dst)){
            uf.unite(e.src,e.dst);
            res +=e.cost;
        }
    }
    return res;
}
pint x[100001],y[100001];
int main(){
    int n,xx,yy;
    cin>>n;
    rep(i,n){
        cin>>xx>>yy;
        x[i].first=xx;
        y[i].first=yy;
        x[i].second=i;
        y[i].second=i;
    }
    sort(x,x+n);
    sort(y,y+n);
    rep(i,n-1){
        ve.pb(edge(x[i].second,x[i+1].second,abs(x[i].first-x[i+1].first)));
        ve.pb(edge(y[i].second,y[i+1].second,abs(y[i].first-y[i+1].first)));
    }
    cout<<kruskal(n)<<endl;
    return 0;
}

Measured memory_bytes: 6388
#include <iostream>

using namespace std;

int main()
{
	int N, K, answer = 0, tmp;
	cin >> N >> K;
	for (int count = 0; count < N; count++)
	{
		cin >> tmp;
		if (tmp >= K)
		{
			answer++;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256