akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> g;
vector<long long> sumx;

void bfs(long long c, vector<long long> &dist){
  queue<pair<int,long long>> que;
  dist[0] = c;
  que.emplace(0,c);

  while(!que.empty()){
    int from = que.front().first;
    c = que.front().second;
    que.pop();

    for(int to:g[from]){
      if(dist[to]==-1){
        que.emplace(to,c+sumx[to]);
        dist[to] = c+sumx[to];
      }
    }   
  }
}

int main(){
  int n,q;
  cin >> n >> q;
  g.assign(n,vector<int>());
  sumx.assign(n,0);

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

  for (int i = 0; i < q; i++)
  {
    int p;
    long long x;
    cin >> p >> x;
    p--;
    sumx[p]+=x;
  }

//  cout << "sumx0" << sumx[0] << endl;
  vector<long long> dist(n,-1);
  bfs(sumx[0],dist);
  for(long long dis:dist){
    cout << dis << " ";
  }
  cout << endl;
}

Measured memory_bytes: 18420
s = str(input())
p = 2019
mod = [0]*2019
mod[0] += 1#右端から見たときに2019の倍数がある場合に対応
now = 0
_10 = 1
for i in range(len(s)-1, -1, -1):
  now = (now + int(s[i])*_10) % p
  _10 *= 10
  _10 %= p
  mod[now] += 1
ans =  0
for i in mod:
  ans += i*(i-1)//2
print(ans)

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

long long N;
vector<long long> A;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

	sort(A.begin(), A.end(), greater<long long> ());

	long long num = 0;
	long long ans = 0;
	num++;
	ans += A[0];
	long long idx = 1;


	N--;
	while(num < N) {
		ans += A[idx];
		num++;
		if(num >= N){
			break;
		}
		ans += A[idx];
		num++;
		idx++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int H, W;
string s[52];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  s[0] = "............................................................";
  cin >> H >> W;
  FOR(i, 1, H+1){
    cin >> s[i];
    s[i] = "." + s[i] + ".";
  }
  s[H+1] = "............................................................";
  FOR(i, 1, H+1)FOR(j, 1, W+1){
    if(s[i][j] == '.' || s[i+1][j]=='#' || s[i-1][j]=='#' || s[i][j+1]=='#' || s[i][j-1]=='#') continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,aa;
  char c;
  scanf("%d",&a);
  while(1){
    scanf("%s",&c);
    if(c=='='){
      printf("%d\n",aa);
      break;
    }
    scanf("%d",&b);
    if(c=='+')
      aa=a+b;
    else if(c=='-')
      aa=a-b;
    else if(c=='*')
      aa=a*b;
    else if(c=='/')
      aa=a/b;
    a=aa;
  }
  return 0;
}

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

typedef struct point{
	int x,y;
} t_point;

bool cmp(const t_point& a, const t_point& b)
{
	if( a.x < b.x )return true;
	else if( a.x > b.x )return false;
	return a.y < b.y;
}

int main()
{
	int n;
	t_point points[3000];
	
	while(scanf("%d",&n),n){
		for(int i=0; i<n; i++)
			scanf("%d%d",&points[i].x, &points[i].y);
		sort( points, points+n, cmp );
		
		int ans = 0;
		int xi,xj,yi,yj;
		int left,right,diff;
		
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				xi = points[i].x; yi = points[i].y;
				xj = points[j].x; yj = points[j].y;
				t_point p3 = {yi-yj+xj, xj-xi+yj};
				t_point p4 = {yi-yj+xi,	xj-xi+yi};
				
				left = 0;
				right = n-1;
				while( left<=right ){
					diff = (left+right)/2;
					if( points[diff].x==p3.x && points[diff].y==p3.y )break;
					else if( cmp(points[diff],p3) )
						left = diff+1;
					else
						right = diff-1;
				}
				if( left>right )continue;
				
				left = 0;
				right = n-1;
				while( left<=right ){
					diff = (left+right)/2;
					if( points[diff].x==p4.x && points[diff].y==p4.y )break;
					else if( cmp(points[diff],p4) )
						left = diff+1;
					else
						right = diff-1;
				}
				if( left>right )continue;

				ans = max(ans,(p3.x-p4.x)*(p3.x-p4.x)+(p3.y-p4.y)*(p3.y-p4.y));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 904
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n;
       string s;
       cin>>n>>s;
       rep(i,s.size()){
           int a = s[i]-'A';
           int m = (n+a)%26;
           s[i] = 'A'+ m;
       }
       cout<<s;
    }
    


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    char s[200+50][100+50];
    int h , w ;
    scanf("%d%d",&h,&w);
    for(int i = 0; i < h ; i++){
        scanf("%s",s[i]);
    }
    for(int i = 0 ; i < h ; i++){
        printf("%s\n",s[i]);
        printf("%s\n",s[i]);
    }
    return 0;
}


Measured memory_bytes: 384
// OBツ嘉ッツ嘉債宿2011 Day3 A : Calender Colors

#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int N, M;
	double L[3][20];
	while(cin >> N >> M){
		for(int i=0;i<N;i++)
			for(int j=0;j<3;j++)
				cin >> L[j][i];
		double res = 0.0;
		for(int i=0;i<1<<N;i++){
			int cnt = 0;
			double tmp = 0.0;
			for(int j=0;j<N;j++){
				if(i&(1<<j)){
					cnt++;
					for(int k=j+1;k<N;k++){
						if(i&(1<<k)){
							for(int l=0;l<3;l++)
								tmp += (L[l][j]-L[l][k])*(L[l][j]-L[l][k]);
						}
					}
				}
			}
			if(cnt!=M) continue;
			res = max(res, tmp);
		}
		printf("%.10lf\n", res);
	}
}

Measured memory_bytes: 0
h, w = map(int, input().split())
n = int(input())
alist = list(map(int, input().split()))

ret = [0] * (h*w)

index = 0
color = 1
for a in alist:
    for i in range(a):
        ret[index+i] = color
    color += 1
    index += a

for i in range(h):
    if i%2 == 0:
        for c in ret[i*w:(i+1)*w]:
            print(str(c) + " ", end="")
    else:
        for c in ret[i*w:(i+1)*w][::-1]:
            print(str(c) + " ", end="")

    print()


Measured memory_bytes: 3956
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        a: [Chars; h],
    };

    let mut map = std::collections::BTreeMap::new();
    for r in 0..h {
        for c in 0..w {
            *map.entry(a[r][c]).or_insert(0) += 1;
        }
    }
    let mut q = std::collections::BinaryHeap::new();
    for (k, v) in map {
        q.push((v, k));
    }
    let h_e = h % 2 == 0;
    let w_e = w % 2 == 0;
    if h_e && w_e {
        // ExE
        while let Some((v, k)) = q.pop() {
            if v < 4 {
                println!("No");
                return;
            }
            if v - 4 > 0 {
                q.push((v - 4, k));
            }
        }
        println!("Yes");
    } else if (h_e && !w_e) || (!h_e && w_e) {
        // ExO or OxE
        for _ in 0..if h_e { (w - 1) * h } else { (h - 1) * w } / 4 {
            if let Some((v, k)) = q.pop() {
                if v < 4 {
                    println!("No");
                    return;
                }
                if v - 4 > 0 {
                    q.push((v - 4, k));
                }
            }
        }
        // 1xE or Ex1
        while let Some((v, k)) = q.pop() {
            if v < 2 {
                println!("No");
                return;
            }
            if v - 2 > 0 {
                q.push((v - 2, k));
            }
        }
        println!("Yes");
    } else {
        // OxO
        if h == 1 && w == 1 {
            println!("Yes");
        } else if (h == 1 && w != 1) || (h != 1 && w == 1) {
            for _ in 0..std::cmp::max(h, w) / 2 {
                if let Some((v, k)) = q.pop() {
                    if v < 2 {
                        println!("No");
                        return;
                    }
                    if v - 2 > 0 {
                        q.push((v - 2, k));
                    }
                }
            }
            println!("Yes");
        } else {
            for _ in 0..(h - 1) * (w - 1) / 4 {
                if let Some((v, k)) = q.pop() {
                    if v < 4 {
                        println!("No");
                        return;
                    }
                    if v - 4 > 0 {
                        q.push((v - 4, k));
                    }
                }
            }
            for _ in 0..h / 2 + w / 2 {
                if let Some((v, k)) = q.pop() {
                    if v < 2 {
                        println!("No");
                        return;
                    }
                    if v - 2 > 0 {
                        q.push((v - 2, k));
                    }
                }
            }
            println!("Yes");
        }
    }
}


Measured memory_bytes: 2200
#include <stdio.h>

int main(void){
	int flag=0;
	char S[5];
	scanf("%s",S);

	if(S[0]=='0' && S[1] != '0'){
		flag+=1;
	}else if(S[0]=='1' && S[1]<'3'){
		flag+=1;
	}

	if(S[2]=='0' && S[3] != '0'){
		flag+=2;
	}else if(S[2]=='1' && S[3]<'3'){
		flag+=2;
	}

	if(flag==0){ printf("NA\n"); }
	else if(flag==1){ printf("MMYY\n"); }
	else if(flag==2){ printf("YYMM\n"); }
	else if(flag==3){ printf("AMBIGUOUS\n"); }
}

Measured memory_bytes: 128
n = int(input())
st = []
for _ in range(n):
    temp = input().split()
    s = temp[0]
    t = int(temp[1])
    st.append((s,t))
x = input()

ans = 0
flag = True
for y in st:
    if flag:
        if y[0] == x:
            flag = False
    else:
        ans += y[1]

print(ans)    

Measured memory_bytes: 3064
#include<iostream>
#include<utility>

using namespace std;

int main(){
    long long n, m, ans = 0;
    cin >> n >> m;
    if(n > m) swap(n, m);
    if(n == 1 && m == 1){
        ans = 1;
    }else if(n == 1){
        ans = m - 2;
    }else{
        ans = (n - 2) * (m - 2);
    }
    cout << ans << endl;
    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

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

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
  string S;
  cin >> S;
  sort(all(S));
  bool flag = true;
  REP(i, S.size() - 1){
    if(S.at(i) == S.at(i + 1)) flag = false;
  }
if(flag)print("yes");
else print("no");

}

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

#define REP(i,n) for(ll i=0;i<(n);i++)
#define REAP(i,a,n) for(ll i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

#define N 100000000



ll table[N+1];

void cou(){
    for(ll i=2;i*i<N;i++){
        for(ll j=i;j<N;j+=i){
            table[j]++;
        }
    }
}


int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    REAP(i,1,N){
        int cou=0;
        for(int j=1;j*j<=i;j++){
            if(i%j==0){
                if(i==j*j){
                    cou++;
                }else{
                    cou+=2;
                }
            }
        }
        if(cou==n){
            cout << i << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    if (A + B) % 2 != 0:
        return 'IMPOSSIBLE'
    return (A + B) // 2


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8124
#include<cstdio>
using namespace std;
int main(void){
    int n,k,p; scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d%d",&k,&p);

        if(k%p != 0) printf("%d\n",k%p);
        else printf("%d\n",p);
    }
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
h = list(map(int, input().split()))
ans = -1*float('inf')
cnt = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;



template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    int n, m;
    cin >> n >> m;
    int num[n];
    memset(num, -1, sizeof num);
    bool poss = true;
    from(i, m){
        int s, c;
        cin >> s >> c;
        --s;
        if(num[s] == -1) num[s] = c;
        else if(num[s] == c) num[s] = c;
        else poss = false;
    }
    
    if(!poss){
        cout << -1 << endl;
        return;
    }
    
    if(n == 1){
        if(num[0] == -1 || num[0] == 0) cout << 0 << endl;
        else cout << num[0] << endl;
        return;
    }

    if(num[0] == 0) {
        cout << -1 << endl;
        return;
    }
    else if(num[0] == -1) num[0] = 1;

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(num[i] == -1) num[i] = 0;
        ans = ans*10 + num[i];
    }
    
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char S[101]; char T[101];
    scanf("%*d"); scanf("%s", S); scanf("%s", T);
    int len = strlen(S);
    for (int i = 0; i < len; i++) {
        printf("%c%c",S[i],T[i]);
    }
    return 0;
}



Measured memory_bytes: 128
o = input()
e = input()

ans = ''
if len(o) == len(e):
    for i in range(len(o)):
        ans += o[i] + e[i]
elif len(o) > len(e):
    for i in range(len(e)):
        ans += o[i] + e[i]
    ans += o[-1]
else:
    for i in range(len(o)):
        ans += o[i] + e[i]
    ans += e[-1]

print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

//global variances
int N;
int A[20], B[20], C[20];
int point = 0;

//prototype
void input(int arr[], int size);

int main()
{
  	cin >> N;
  	input(A,N);
  	input(B,N);
  	input(C,N-1);
  	
  	for (int i = 0; i < N; ++i)
  	{
  	    point += B[i];
  	    if ((A[i]-1)+1 == (A[i+1]-1)) point += C[A[i]-1];
  	}
  	
  	cout << point;
  	
	return 0;
}
//definition
void input(int arr[], int size)
{
    for (int i = 0; i < size; ++i)
  	{
  	    cin >> arr[i];
  	}
}

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


using namespace std;

const int con = 100002;

struct process
{
	string name;
	int time;
};

class queue
{
public:
	process q[con];
	int tail,head;
	void initialize();
	void enqueue(process x);
	process dequeue();
};

void queue::initialize()
{
	head = tail = 0;
}

void queue::enqueue(process x)
{
	q[tail] = x;
	if (tail+1 == con)
	{
		tail = 0;
	}else
	{
		tail++;
	}
}

process queue::dequeue()
{
	process x;
	x = q[head];

	if (head+1 == con)
	{
		head = 0;
	}else
	{
		head++;
	}

	return x;
}



int main()
{
	int n, q, nowtime, j = 0;
	process p[100000], result[100000], temp;
	queue que;

	que.initialize();

	cin >> n >> q;

	for(int i = 0; i < n; i++)
	{
		cin >> p[i].name >> p[i].time;
		que.enqueue(p[i]);
	}

	while(que.tail != que.head)
	{
		temp = que.dequeue();

		if (temp.time - q <= 0)
		{
			nowtime += temp.time;

			/*result[j].name = temp.name;
			result[j].time = nowtime;
			j++;
			*/

			cout << temp.name << " " << nowtime << "\n";

		}else
		{
			temp.time -= q;
			nowtime += q;
			que.enqueue(temp);
		}

	}

	/*for(int i = 0; i < n; i++)
	{
		cout << result[i].name << " " << result[i].time <<"\n";
	}*/


	return 0;
}

Measured memory_bytes: 10004
N = int(input())
A = [int(i) for i in input().split()]

res = 0
while True:
  #check
  if len(list([i for i in A if i % 2 != 0])) == 0:
    res += 1
  else:
  	break
  #2でわる
  A = [i // 2 for i in A]

  
print(res)

Measured memory_bytes: 9192
#!/usr/bin/env python3

from heapq import heapify, heappop, heappush

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*-1, input().split()))

heapify(a)

for i in range(m):
    min = heappop(a)
    heappush(a, (-1)*(-1*min//2)) # 要素の挿入

ans = -sum(a)

print(ans)


Measured memory_bytes: 14180
#include <cstring>
#include <iostream>

using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int h[n + 1];
  int no[n + 1];
  memset(no, 0, sizeof(no));
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  while (m--) {
    int a, b;
    cin >> a >> b;
    if (no[a] == -1)
      ;
    else {
      if (h[a] > h[b])
        no[a] = 1;
      else
        no[a] = -1;
    }
    if (no[b] == -1)
      ;
    else {
      if (h[b] > h[a])
        no[b] = 1;
      else
        no[b] = -1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (no[i] >= 0)
      ans++;
  cout << ans;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll tmin = 1e9;
    ll argmin = -1;
    ll tmax = -1e9;
    ll argmax = -1;
    for(i = 0;i < n;++i){
        if(chmin(tmin, a.at(i))) argmin = i;
        if(chmax(tmax, a.at(i))) argmax = i;
    }
    if(tmin >= 0){
        cout << n-1 << endl;
        for(i = 1;i <= n-1;++i){
            cout << i << " " << i+1 << endl;
        }
        return 0;
    }else if(tmax <= 0){
        cout << n-1 << endl;
        for(i = n;i >= 2;--i){
            cout << i << " " << i-1 << endl;
        }
        return 0;
    }
    if(tmax >= abs(tmin)){
        vector<pair<ll,ll>> ans;
        for(i = 0;i < n;++i){
            if(a.at(i) < 0) ans.emplace_back(argmax+1, i+1);
        }
        cout << ans.size() + n - 1 << endl;
        for(i = 0;i < ans.size();++i){
            cout << ans.at(i).first << " " << ans.at(i).second << endl;
        }
        for(i = 1;i <= n-1;++i){
            cout << i << " " << i+1 << endl;
        }
        return 0;
    }else{
        vector<pair<ll,ll>> ans;
        for(i = 0;i < n;++i){
            if(a.at(i) > 0) ans.emplace_back(argmin+1, i+1);
        }
        cout << ans.size() + n - 1 << endl;
        for(i = 0;i < ans.size();++i){
            cout << ans.at(i).first << " " << ans.at(i).second << endl;
        }
        for(i = n;i >= 2;--i){
            cout << i << " " << i-1 << endl;
        }
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
int head[N], cnt = 0;
struct node { int to, next, v; } e[N];
int n, m, d[N], vis[N];
set <int> c[N]; 
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void add(int x, int y, int z) {
	e[++cnt].to = y; e[cnt].v = z;
	e[cnt].next = head[x]; head[x] = cnt;
}
priority_queue <pii> q;
void dij(int k) {
	rep(i, 1, n) d[i] = 1e9;
	d[k] = 0;
	q.push(mp(d[k], k));
	while(!q.empty()) {
		int x = q.top().second; 
		q.pop();
		if(vis[x]) continue;  vis[x] = 1;
		for(int i = head[x]; i; i = e[i].next) {
			int y = e[i].to, w = c[x].count(e[i].v) ? 0 : 1;
			if(d[x] + w < d[y]) {
				d[y] = d[x] + w; q.push(mp(-d[y], y));
				c[y].clear(); c[y].insert(e[i].v);
			}
			if(d[x] + w == d[y]) c[y].insert(e[i].v);
		}
	}
}
void init(){
	n = read(); m = read();
	rep(i, 1, m) {
		int xx = read(), yy = read(), c = read();
		add(xx, yy, c);
		add(yy, xx, c);
	}
	dij(1);
	if(d[n] == 1e9) puts("-1");
	else printf("%d\n", d[n]);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init();
	return 0;
}


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

using ll = long long;

int main() {
    int N;
    ll ans = 0;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    priority_queue<vector<int>> q;
    rep(i, N) {
        cin >> B[i];
        q.push({B[i], i});
    }
    while (!q.empty()) {
        auto t = q.top();
        q.pop();
        if (t[0] <= A[t[1]]) continue;
        int d = B[(t[1] - 1 + N) % N] + B[(t[1] + 1) % N];
        int r = (t[0] - A[t[1]]) / d;
        t[0] -= d * r;
        ans += r;
        if (t[0] < A[t[1]] || r == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (t[0] > A[t[1]]) {
            q.push({t[0], t[1]});
        }
        B[t[1]] = t[0];
    }
    rep(i, N) {
        if (A[i] != B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    /*
    9817 1108 6890 4343 8704
    0005
                        4356
              1439
                        0008
                    2896
                    1449
                       2
               329
          774
          440
          106
               221
               113
                5
           96
           86
           76
           66
           56
           46
           36
           26
           16
            6
                            1
    */
}

Measured memory_bytes: 14764
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

vector<int> to(8);
int visited[8];
int e[10][10];
int ans=0;
int n;

void dfs(int v){
    int all=1;
    rep(i,n){
        if(visited[i]==0){
            all=0;
        }
    }
    if(all){
        ans++;
        return;
    }
    rep(u,n){
        if(e[v][u]==1&&visited[u]==0){
            visited[u]++;
            dfs(u);
            visited[u]=0;
        }
    }
    return;
}

int main(){
    int m;
    cin >> n>> m;
    rep(i,m){
        int a,b;
        cin >> a>> b;
        a--;b--;
        e[a][b]=1;
        e[b][a]=1;
        //to[a].push_back(b);
        //to[b].push_back(a);
    }
    visited[0]=1;
    dfs(0);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
#define int long long
const int mod = 1e9+7;

int dp[10003][100][2];

 main(){
	string K;
	int D; 
	cin >> K >> D;
	int n = K.length();
	
	for(int i = 0; i < K[0] - '0'; i++){
		dp[0][i%D][0]++;
	}
	dp[0][(K[0]-'0')%D ][1]++;
	
	for(int i = 1; i < n; i++){
		for(int j = 0; j < D; j++){
			for(int k = 0; k < 2; k++){
				int up = 9;
				if(k) up = K[i] - '0';
				for(int d = 0; d <= up; d++){
					int ns = k & (d==up);
					dp[i][(j+d)%D][ns]+=dp[i-1][j][k];
					dp[i][(j+d)%D][ns]%=mod;
				}
			}
		}
	}
	int res = 1ll*(dp[n-1][0][0] + dp[n-1][0][1]-1+mod) % mod;
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<string> g;


int main(){
	int h, w;
	cin >> h >> w;
	g.resize(h);
	int wcnt = 0;
	for(int i = 0; i < h; ++i){
		cin >> g[i];
		for(auto v : g[i]){
			if(v == '.')++wcnt;
		}
	}

	vector<vector<int>> dist(h, vector<int>(w, -1));
	queue<P> que;
	dist[0][0] = 0;
	que.push({0, 0});

	while(!que.empty()){
		P v = que.front();
		que.pop();
		int x = v.first;
		int y = v.second;

		for(int i = 0; i < 4; ++i){
			int nx = x + dx[i];
			int ny = y + dy[i];

			if(nx < 0 || w <= nx || ny < 0 || h <= ny)continue;
			if(g[ny][nx] == '#')continue;
			if(dist[ny][nx] != -1)continue;

			dist[ny][nx] = dist[y][x] + 1;
			que.push({nx, ny});
		}
	}

	if(dist[h - 1][w - 1] == -1)cout << -1 << endl;
	else cout << wcnt - dist[h - 1][w - 1] - 1 << endl;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
count = 0
i = 1
for i in range(N+1):
    stri = str(i)
    L = len(stri)
    dec = i
    some = 0
    for j in range(L-1):
        zan = dec%10
        dec = int(dec/10)
        some += zan 
    some += dec
    if some >= A and some <= B:
        count+=i
    
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		Main mySystem = new Main();
		int n = scan.nextInt();
		while(n != 0){
			int masu[][] = new int[n][n];
			int hantei[][] = new int[n][n];
			for(int i = 0 ; i < n ; i++){
				for(int j = 0 ; j < n ; j++){
					hantei[j][i] = 0;
				}
			}
			masu[n/2][n/2+1] = 1;
			hantei[n/2][n/2+1] = 1;
			mySystem.kensaku(masu , hantei , 2 , (n/2+1) , (n/2+2) , n);
			for(int i = 0 ; i < n ; i++){
				for(int j = 0 ; j < n ; j++){
					if(masu[j][i] < 10){
						System.out.print("   ");
					}else if(masu[j][i] < 100){
						System.out.print("  ");
					}else{
						System.out.print(" ");
					}
					System.out.print(masu[j][i]);
				}
				System.out.println();
			}
			n = scan.nextInt();
		}
	}
	public int[][] kensaku(int[][] masu , int[][] hantei , int cun , int x , int y , int n){
		if(cun <= n*n){
			if(x < n && y < n){
				if(hantei[x][y] == 0){
					masu[x][y] = cun;
					hantei[x][y] = 1;
						kensaku(masu , hantei , cun+1 , x+1 , y+1 , n);
				}else{
					if(x-1 >= 0){
						kensaku(masu , hantei , cun , x-1 , y+1 , n);
					}else{
						kensaku(masu , hantei , cun , n-1 , y+1 , n);
					}
				}
			}else if(x >=  n){
				kensaku(masu , hantei , cun , 0 , y , n);
			}else if(y >= n){
				kensaku(masu , hantei , cun , x , 0 , n);
			}
		}
		return masu;
	}
}

Measured memory_bytes: 26976
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ABV057BBSolve solve = new ABV057BBSolve();
		solve.main();
	}
}

class ABV057BBSolve {
	
	int N;
	int M;
	Point[] checkPoints;
	Point[] studentPoints;
	
	ABV057BBSolve() {
		Scanner cin = new Scanner(System.in);
		
		this.N = cin.nextInt();
		this.M = cin.nextInt();
		
		this.studentPoints = new Point[N];
		this.checkPoints = new Point[M];
		
		for (int i = 0; i < N; i++) {
			int a = cin.nextInt();
			int b = cin.nextInt();
			studentPoints[i] = new Point(a, b);
		}
		for (int i = 0; i < M; i++) {
			int a = cin.nextInt();
			int b = cin.nextInt();
			checkPoints[i] = new Point(a, b);
		}
	}
	
	void main() {
		for (Point studentPoint : studentPoints) {
			
			int min = Integer.MAX_VALUE / 2;
			int minPointId = -1;
			
			for (int i = M - 1; i >= 0; i--) {
				Point checkPoint = checkPoints[i];
				int distance = distance(studentPoint, checkPoint);
				if (distance <= min) {
					min = distance;
					minPointId = i;
				}
			}
			
			System.out.println(minPointId + 1);
		}
	}
	
	int distance(Point a, Point b) {
		return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
	}
	
	class Point {
		int x;
		int y;
		
		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N;
string S;

int main() {
	cin >> N;
	cin >> S;
	rep(i, sz(S))S[i] = (S[i] + N - 'A') % 26 + 'A';
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctime>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char a[3];
	scanf("%s",a);
	if(a[0]=='9'||a[1]=='9')
	{
		printf("Yes");
	 } 
	 else
	 {
	 	printf("No");
	 }
	return 0;
}


Measured memory_bytes: 256
s = raw_input()
p = raw_input()
idx = []
for i in range(0,len(s)):
    if s[i] == p[0]:
        idx.append(i)
for i in idx:
    for j in range(0,len(p)):
        if p[j] == s[(i+j)%len(s)]:
            continue
        else:
            break
    else:
        print 'Yes'
        break
else:
    print 'No'

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

#define MAX_N (1<<18)
#define N 100000
#define mod 100000

class Range {
	int data[MAX_N];
	int n;
public:
	void init(int pn) {
		n = 1;
		while(n < pn) n <<= 1;
		for(int i=0; i<2*n; ++i) data[i] = 0;
	}
	
	void add(int k, int a) {
		k += n-1;

		while(k) {
			data[k] = (data[k] + a)%mod;
			k = (k-1) / 2;
		}
		data[0] = (data[0] + a)%mod;
	}
	
	int query(int a, int b, int l, int r, int k) {
		if(r<=a || b<=l) return 0;
		int sum = 0;
		if(a<=l && r<=b) return data[k];
		sum += query(a, b, l, (l + r)/2, 2*k + 1);
		sum += query(a, b, (l + r)/2, r, 2*k + 2);
		return sum%mod;
	}
	
	int sum(int a, int b) {
		return query(a, b, 0, n, 0);
	}
};

int main() {
	int n, m;
	Range r;
	int s, a, ans = 0;
	cin >> n >> m;
	r.init(n-1);
	for(int i=0; i<n-1; ++i) {
		cin >> s;
		r.add(i, s);
	}
	int pos = 0;
	for(int i=0; i<m; ++i) {
		cin >> a;
		if(a>0) {
			ans = (ans + r.sum(pos, pos+a)) % mod;
		}else if(a<0) {
			ans = (ans + r.sum(pos+a, pos)) % mod;
		}
		pos += a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2188
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let s = get!(String;n);
    let mut set = BTreeSet::new();
    for i in 0..n {
        set.insert(s[i].clone());
    }
    println!("{}", set.len());
}


Measured memory_bytes: 26144
#include<stdio.h>

int main(){
  int n,q,i,j,count=0;
  
  scanf("%d",&n);
  int S[10000];

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

  
  scanf("%d",&q);
  int T[500];

  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }

  
  for(j=0;j<q;j++){
    i = 0;
    while(i<n && S[i] != T[j]){
      i++;
    }
    if(i == n){
    }else{
      count++;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2104
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) co(i);}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, x;
	cin >> n >> x;
	if(n == 1){
		puts("Yes");
		co(1);
	}else if(n == 2){
		if(x == 2){
			puts("Yes");
			coVec({1, 2, 3});
		}else{
			puts("No");
		}
	}else{
		if(x == 1 || x == n*2-1) puts("No");
		else{
			puts("Yes");
			unordered_set<ll> ust;
			Vec ans(2*n-1);
			ans[n-2] = 1, ans[n-1] = x, ans[n] = n*2-1;
			ust.insert({1, x, n*2-1});
			if(x != 2){
				ans[n+1] = 2;
				ust.insert(2);
			}else{
				ans[n-3] = n*2-2;
				ust.insert(n*2-2);
			}
			ll cnt = 1;
			rep(i, n*2-1){
				while(true){
					if(ust.find(cnt) == ust.end()) break;
					cnt++;
				}
				if(!ans[i]) ans[i] = cnt++;
			}
			coVec(ans);
		}
	}

	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b; cin >> a >> b;
    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3636
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
p = [ni() for _ in range(n)]
print(sum(p) - max(p)//2)

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

using namespace std;

typedef long long ll;

bool check_bit(int mask, int num) {
    return (mask & (1 << num)) != 0;
}

int main() {
    ll n, m;
    cin >> n >> m;

    vector<vector<ll> > a(n, vector<ll>(3, 0));
    for (auto &i : a)
        cin >> i[0] >> i[1] >> i[2];

    ll ans = -1;
    vector<ll> signs(3, 1);
    for (int mask = 0; mask < (1 << 3); mask++) {
        for (int i = 0; i < 3; i++)
            signs[i] = (check_bit(mask, i) ? 1LL : -1LL);

        vector<ll> tmp;
        for (int i = 0; i < n; i++) {
            ll res = 0;
            for (int j = 0; j < 3; j++)
                res += signs[j] * a[i][j];
            tmp.push_back(res);
        }

        sort(tmp.begin(), tmp.end()); reverse(tmp.begin(), tmp.end());

        ll curr_ans = 0;
        for (int i = 0; i < m; i++)
            curr_ans += tmp[i];

        ans = max(ans, curr_ans);
    }

    cout << ans;
    return 0;
}

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


using namespace std;


int main(){
    
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> a(m);

    for(int i = 0; i < m; i++){
        cin >> a[i];
      }
    
    int lo,up;
    lo = lower_bound(a.begin(), a.end(), x) - a.begin();
    up = m - lo;

    cout << min(lo, up);
    
    
    return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(), (x).end()

int conv(char s){ return s - 'a'; }

int main(){
string s, t; cin>>s>>t;
int n = s.length();
vector<int> sv[26];
rep(i, n) sv[conv(s[i])].push_back(i);
rep(i, n) sv[conv(s[i])].push_back(i+n);
int now = -1; long count = 0; bool err = false;
rep(i, t.length()){
  int u = conv(t[i]);
  auto itr = upper_bound(all(sv[u]), now);
  if(itr==sv[u].end()){ err=true; break; }
  now = *itr; //cout<<now<<endl;
  if (now >= n){ count++; now -= n; }
}
long ans = now + count*n + 1;
if(err) ans = -1;
cout<<ans<<endl;
}

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

# 学生N人の現在地(a,b)
A_B = [list(map(int, input().split())) for _ in range(N)]
# チェックポイントM個の場所(c,d)
C_D = [list(map(int, input().split())) for _ in range(M)]


for a, b in A_B:
    temp_distance = 10**10
    temp_checkpoint = -1
    checkpoint_count = 1
    for c, d in C_D:
        manhattan_distance = abs(a-c) + abs(b-d)
        if temp_distance > manhattan_distance:
            temp_distance = manhattan_distance
            temp_checkpoint = checkpoint_count
        checkpoint_count += 1
    print(temp_checkpoint)

Measured memory_bytes: 9052
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=1e5+7;
const ll INF=1e9+7;
ll a[N],v[N],c[N*2],sm[N];
ll n;
ll low(ll x){return x&(-x);}
void ins(ll x){for(ll i=x;i<=2*n;i+=low(i))c[i]++;}
ll check(ll x){
	ll ans=0;
	for(ll i=x;i;i-=low(i))ans+=c[i];
	return ans;
}
bool query(ll x){
	memset(c,0,sizeof(c));
	ll q=0;
	ins(n);
	rep(i,n){
		sm[i]=sm[i-1];
		if(a[i]>=x)sm[i]++;
		q+=check(2*sm[i]-i+n);
		ins(2*sm[i]-i+n);
	}
	return (2*q)>=(n*(n+1)/2);
}
int main(){
	scanf("%lld",&n);
	rep(i,n)scanf("%lld",&a[i]),v[i]=a[i];
	sort(v+1,v+n+1);
	ll L=1,R=n;
	while(L<R-1){
		ll mid=(L+R)>>1;
		if(query(v[mid]))L=mid;
		else R=mid;
	}
	if(query(v[R]))printf("%lld\n",v[R]);
	else printf("%lld\n",v[L]);
	return 0;
}
//4 10 20 30 40

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename Tp>
Tp CeilDiv(Tp _dividend, long long _divider) {
    return static_cast<Tp>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a) {
        b <<= 1;
        --k;
    }
    while (c <= b) {
        c <<= 1;
        --k;
    }
    if (k >= 0) {
        RET("Yes");
    }
    cout << "No" endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int  main() {
	int n;
	long long t = 0;
	cin >> n;
	for (long long i = 1; i<= 1000000; i++) {
		for (long long j = 1; j <= 1000000; j++) {
			if (i * j >= n)break;
			t++;
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int sosu_hantei(int x){
  if(x<=1)
    return 0;
  else if(x==2)
    return 1;
  else if(x%2==0)
    return 0;
  
  for(int i=3;i<=x/i;i+=2){
    if(x%i==0)
      return 0;
  }
  return 1;
}
int main() {
  int Q;
  cin>>Q;
  vector<int> l(Q),r(Q),ans(Q),sum(100001);
  for(int i=0;i<Q;i++){
    cin>>l.at(i)>>r.at(i);
  }
  
  for(int i=1;i<=100000;i++){
    if(sosu_hantei(i)*sosu_hantei((i+1)/2))
   	  sum.at(i)=sum.at(i-1)+1;
    else
      sum.at(i)=sum.at(i-1);
  }
  for(int i=0;i<Q;i++)
    ans.at(i)=sum.at(r.at(i))-sum.at(l.at(i))+sosu_hantei(l.at(i))*sosu_hantei((l.at(i)+1)/2);
  for(int i=0;i<Q;i++)
    cout<<ans.at(i)<<endl;
}


Measured memory_bytes: 2176