akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  string year_ = s.substr(0, 4), month_ = s.substr(5, 2), day_ = s.substr(8, 2);
  int year = stoi(year_), month = stoi(month_), day = stoi(day_);
  if (year > 2019 || (year == 2019 && month > 4) || (year == 2019 && month == 4 && day > 30)) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 256
// 400, review
fun bd092(args: Array<String>) {
    val N = args[0].toInt()
    val redList =
            args.drop(1).take(N)
                    .map { line -> line.split(" ").map { it.toInt() } }
                    .sortedByDescending { it[1] }
                    .toMutableList()
    val blueList =
            args.drop(1 + N)
                    .map { line -> line.split(" ").map { it.toInt() } }
                    .sortedBy{ it[0] }
    var cnt = 0
    blueList.forEach { blue ->
        val firstIndex = redList.indexOfFirst{ it[0] < blue[0] && it[1] < blue[1] }
        if (firstIndex != -1) {
            redList.removeAt(firstIndex)
            cnt++
        }
    }

    println(cnt)
}

fun main(args: Array<String>) {
    bd092(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 38308
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
void Main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  REP(i, n)
  cin >> l[i];
  
  sort(ALL(l));
  
  int count = 0;
  
  for(int i = 1; i < n - 1; i++){
    for(int j = 0; j < i; j++){
      for(int k = i + 1; k < n; k++){
        if(l[j] + l[i] < l[k])
          break;
        if(l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[j] + l[i])
          count++;
      }
    }
  }
  
  printf("%d", count);
}
 
int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import collections

def main():
    N,C,K = map(int,input().split())
    T = []
    for _ in range(N):
        T.append(int(input()))
    T.sort()
    q = collections.deque(T)

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 < t0 + K + 1 and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8112
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int a,b;
  string s;
  cin >> a >> b >> s;
  a--;b--;
  rep(i,s.size()){
    char c = s[i];
    
    if(i <= a){
      if(isdigit(c) == false){
        cout << "No";
        return 0;
      }
    }else if (i == a+1){
      if(c != '-'){
        cout << "No";
        return 0;
      }
    }else{
      if(isdigit(c) == false){
        cout << "No";
        return 0;
      }
    }
  }
  
  cout << "Yes";
  
  return 0;
}

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

int main(){
    int X,N;
    cin >> X >> N;
    map<int,int> used;
    for(int i =0; i < N; i++){
        int p;
        cin >> p;
        used[p] = 1;
    }
    for(int i =0; i < 100; i++){
        if(!used[X - i]){
            cout << X-i << endl;
            return 0;
        }
        if(!used[X+i]){
            cout << X+i << endl;
            return 0;
        }
    }
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int total = A + B;
  int total2 = B + C;
  int total3 = A + C;
  int ans = min(total, total2);
  int ans2 = min(ans, total3);
  cout << ans2 << endl;
}

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

using namespace std;

#define debug(x) cout << "\n" << __LINE__ << " " <<  (#x) << " is " << (x) << endl

int cnt(int N){
	int ret = 0;
	while(N != 0){
		ret++;
		N /= 10;
	}
	return ret;
}
int main(){
	#ifdef EVAL	
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int N;
	cin >> N;
	int ans = 0;
	while(N >= 1){
		if(cnt(N) % 2 == 1){
			ans++;
		}
		N--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
h.reverse()
t=1
i=0
while i<n-1:
    if h[i]<h[i+1]:
        h[i+1]-=1
        if h[i]<h[i+1]:
            t=0
            print('No')
            break
        else:
            i+=1
    else:
        i+=1
if t:
    print('Yes')


Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <set>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
    }
    int reg=1e9;
    if(n==1){
        cout<<vec[0]<<endl;
    }else if(k==1){
        for(int i=0;i<n;i++){
            reg=min(reg,abs(vec[i]));
        }
        cout<<reg<<endl;
    }else{
    for(int i=0;i<n-k+1;i++){
        reg=min(reg,min(abs(vec[i+k-1]),abs(vec[i]))+vec[i+k-1]-vec[i]);
    }
    cout <<reg<<endl;
    }
}

Measured memory_bytes: 640
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int max = 0;
		int[] value = new int[num];
		int[] cost = new int[num];
		
		for (int i = 0; i < num; i++) {
			value[i] = scan.nextInt();
		}
		
		for (int i = 0; i < num; i++) {
			cost[i] = scan.nextInt();
		}
		
		for (int i = 0; i < num; i++) {
			if (value[i] > cost[i]) {
				max += value[i] - cost[i];
			}
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 23124
#include <stdio.h>

int     main(void)
{
    int a, b;
    int i;
    char op;
    
    i = 0;
    while (i < 20000)
    {
        scanf("%d %c %d", &a, &op, &b);
    
        if (op == '+')
            printf("%d\n", a + b);
        else if (op =='*')
            printf("%d\n", a * b);
        else if (op =='/')
            printf("%d\n", a / b);
        else if (op =='-')
            printf("%d\n", a - b);
        else
            break;
        i++;
    }
    return (0);
}


Measured memory_bytes: 2024
#include <iostream>
using namespace std;
int T, p; // number of test cases, number of matatabi
int Gx, Gy; // goal coordinates
int A[100][100]; // Goal matrix value
bool Horiz[100][100]; // Horizontal movement
bool Vert[100][100]; // Vertical movement

struct matatabi {
  int x1;
  int y1;
  int x2;
  int y2;
};
int main() {
  cin >> T;
  for (int t=0; t<T; ++t) {
    int x1, y1, x2, y2;
    cin >> Gx >> Gy;
    cin >> p;
    for (int a=0; a<Gx+1; ++a) {
      for (int b=0; b<Gy+1; ++b) {
	Horiz[a][b] = true;
	Vert[a][b] = true;
      }
    } // Initialize matatabi coordinates as true

    for (int i=0; i<p; ++i) {
      cin >> x1 >> y1 >> x2 >> y2;
      if (x1 == x2) Vert[x2][max(y1,y2)] = false;
      else if (y1 == y2) Horiz[max(x1,x2)][y2] = false;
    } // Mark where the matatabi are

    for (int i=0; i<Gx+1; ++i) {
      for (int j=0; j<Gy+1; ++j) {
	Vert[i][0] = false;
	Horiz[0][j] = false;
	if (i == 0 && j == 0)
	  {
	    A[i][j] = 1;
	  }
	else if (!Horiz[i][j] && !Vert[i][j])
	  {
	  A[i][j] = 0;
	  }
	else if (Horiz[i][j] && !Vert[i][j])
	  {
	  A[i][j] = A[i-1][j];
	  }
	else if (!Horiz[i][j] && Vert[i][j])
	  {
	  A[i][j] = A[i][j-1];
	  }
	else if (Horiz[i][j] && Vert[i][j])
	  {
	  A[i][j] = A[i-1][j] + A[i][j-1];
	  }
      }
    }
    if (A[Gx][Gy] == 0) cout << "Miserable Hokusai!" << endl;
    else cout << A[Gx][Gy] << endl;
  }
}

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

int involve3(int a){
  int flag=0;
  int tmp=a;
  while(1){
    if(tmp%10 == 3){
      flag=1;
      break;
    }
     tmp = tmp/10; 
     if(tmp==0) break;  
  }
return flag;
}

int main(){
  int num;
  int a=3;
  cin>>num;
  while(1){
    if(a>num) break;
    if(a%3==0){
      cout<<" "<<a;
    }else if(involve3(a)==1){
      cout<<" "<<a;
    }
    a+=1;
  }
  cout<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int n;

int main() {
    cin >> n;
    map<char, lint> count;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        count[s[0]]++;
    }
    lint ans = 0;
    vector<char> c{'M', 'A', 'R', 'C', 'H'};
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += count[c[i]] * count[c[j]] * count[c[k]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 998244353
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long ll;
//priority_queue<int,vector<int >,greater<int > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
struct A {
 int x;
 bool operator < (A z)
 {
     return x%10 >z.x%10;
 }
}s[6];
int main()
{ int sum=0;
int q=0;
  for(int i=1;i<=5;i++)
     { cin>>s[i].x;if((s[i].x)%10==0)sum++,q+=s[i].x;}
  sort(s+1,s+1+5);
  if(sum<5)
 q+=s[1].x;
 for(int i=2;i<=5-sum;i++)
    q+=(10-s[i-1].x%10)%10+s[i].x;
    cout<<q<<endl;

}

/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


Measured memory_bytes: 256
use proconio::input;

const LIM: usize = 1000000;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.sort();

    let mut f = vec![true; LIM + 1];
    let mut c = vec![0; LIM + 1];
    let mut r = 0;
    for i in 0..n {
        if f[a[i]] || c[a[i]] > 0 {
            c[a[i]] += 1;
        }
        let mut x = 1;
        if f[a[i]] {
            while a[i] * x <= LIM {
                f[a[i] *x] = false;
                x += 1;
            }
            r += 1;
        }
    }
    println!("{}", r - c.iter().filter(|&ci| *ci > 1).count());
}


Measured memory_bytes: 9864
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL

int main(){
    int n,a[MAX];
    cin>>n;rep(i,n)cin>>a[i];
    int ans=0;
    rep(i,n){
        while(i<n-1 && a[i]==a[i+1])i++;
        if(i<n-1 && a[i]<a[i+1]){
            while(i<n-1&&a[i]<=a[i+1]){
                i++;
            }
        }
        else if(i<n-1 && a[i]>=a[i+1]){
            while(i<n-1&&a[i]>=a[i+1]){
                i++;
            }
        }
        ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int> vec(N,-1);
  
  for(int i=0;i<M;i++){
    int s,c;
    cin>>s>>c;
    if(vec.at(s-1)!=-1){
      if(vec.at(s-1)==c) vec.at(s-1)=c;
      else{
        cout<<-1<<endl;
        return 0;
      }
    }
    else vec.at(s-1)=c;
  }
  if(N==1){
    if(vec.at(0)==-1) cout<<0<<endl;
    else cout<<vec.at(0)<<endl;
  }
  else{
    if(vec.at(0)==-1) cout<<1;
    else if(vec.at(0)==0) {
      cout<<-1<<endl;
      return 0;
    }
    else cout<<vec.at(0);
    for(int i=1;i<N;i++){
      if(vec.at(i)==-1) cout<<0;
      else cout<<vec.at(i);
    }
    cout<<endl;
  }
  
  
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,ans=0;
	cin >> a >> b >> c;
	if(a%2==1||b%2==1||c%2==1){
		cout << ans << endl;
		return 0;
	}else if(a==b&&b==c){
		cout << -1 << endl;
		return 0;
	}else{
		for(int i=0;i<1000000000;i++){
			int A=a,B=b,C=c;
			a=(B+C)/2;b=(C+A)/2;c=(A+B)/2;
			ans++;
			if(a%2!=0||b%2!=0||c%2!=0){
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
function readInt(str) {
  return parseInt(str, 10);
}
function Main(raw: string) {
  const input = raw.split("\n");
  const [A,B]=input[0].split(" ").map(readInt);


  //出力
  console.log("%d", Math.max(Math.max(2*A-1,2*B-1),A+B));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d, x;
		while (sc.hasNext()) {
			int area = 0;
			d = sc.nextInt();
			for (int i = 0; i < 600; i += d) {
				x = i * i;
				area += x * d;
			}
			System.out.println(area);
		}
	}
}

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

int N;
int G[105][105];
int d[105], f[105];
int used[105];

int dfs(ll v, ll t) {
  used[v] = true;
  d[v] = t;
  for (ll i = 0; i < N; i++) {
    if (!used[i] && G[v][i]) {
      t = dfs(i, t + 1);
    }
  }
  return f[v] = t + 1;
}

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

  cin >> N;
  for (ll i = 0; i < N; i++) {
    ll U, K; cin >> U >> K;
    for (ll j = 0; j < K; j++) {
      ll v; cin >> v; v--;
      G[i][v] = 1;
    }
  }

  int t = 0;
  for (ll i = 0; i < N; i++) {
    if (!used[i]) {
      t = dfs(i, t + 1);
    }
  }

  for (ll i = 0; i < N; i++) {
    cout << (i + 1) << ' ' << d[i] << ' ' << f[i] << '\n';
  }
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  set<int> st{a, b, c};
  cout<<st.size()<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int a = cin.nextInt();
		int b = cin.nextInt();
		int ans = gcd(a, b);
		for (int i = 2; i < n; i++) {
			b = cin.nextInt();
			ans = gcd(ans, b);
		}
		System.out.println(ans);
	}
	static int gcd(int a, int b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
}

Measured memory_bytes: 50432
H,W = [int(v) for v in input().split()]
arr = [input() for _ in range(H)]
     
dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
dp[1][1] = 1
dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
dp[1][1] = 1
     
#print(dp)
for h,row in enumerate(arr,1):
        for w,cell in enumerate(row,1):
            if cell != '#':
                dp[h][w] += int((dp[h-1][w] + dp[h][w-1]) % (1e9 + 7))
    
print(dp[-1][-1])
     
  

Measured memory_bytes: 53364
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	char c;
	cin>>c;
	if(c=='a')cout<<"b"<<endl;
	if(c=='b')cout<<"c"<<endl;
	if(c=='c')cout<<"d"<<endl;
	if(c=='d')cout<<"e"<<endl;
	if(c=='e')cout<<"f"<<endl;
	if(c=='f')cout<<"g"<<endl;
	if(c=='g')cout<<"h"<<endl;
	if(c=='h')cout<<"i"<<endl;
	if(c=='i')cout<<"j"<<endl;
	if(c=='j')cout<<"k"<<endl;
	if(c=='k')cout<<"l"<<endl;
	if(c=='l')cout<<"m"<<endl;
	if(c=='m')cout<<"n"<<endl;
	if(c=='n')cout<<"o"<<endl;
	if(c=='o')cout<<"p"<<endl;
	if(c=='p')cout<<"q"<<endl;
	if(c=='q')cout<<"r"<<endl;
	if(c=='r')cout<<"s"<<endl;
	if(c=='s')cout<<"t"<<endl;
	if(c=='t')cout<<"u"<<endl;
	if(c=='u')cout<<"v"<<endl;
	if(c=='v')cout<<"w"<<endl;
	if(c=='w')cout<<"x"<<endl;
	if(c=='x')cout<<"y"<<endl;
	if(c=='y')cout<<"z"<<endl;


	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    N, *A = map(int, read().split())
    M = 200003
    P = [0] * (M-1)
    A = [a for a in A if a != 0]
    val2arr = {}
    arr2val = {}
    val = 1
    for p in range(M-1):
        val2arr[val] = p
        arr2val[p] = val
        val *= 2
        val %= M

    for a in A:
        k = val2arr[a]
        P[k] += 1

    L = 1 << (2 * M - 3).bit_length()

    fft_f = np.fft.ifft(np.fft.fft(P, L) ** 2)
    fft_f = [int(np.rint(val)) for val in fft_f]
    sum = 0
    for i in range(L):
        k = i % (M-1)
        sum += fft_f[i] * arr2val[k]

    sub = 0
    for a in A:
        sub += (a * a) % M
    print(int((sum - sub) // 2))



if __name__ == "__main__":
    run()

Measured memory_bytes: 104364
import itertools

n,m=map(int,input().split())
path={i+1:[] for i in range(n)}
for i in range(m):
    u,v=map(int,input().split())
    path[u].append(v)
    path[v].append(u)
chk=[i for i in range(2,n+1)]
ans=0
for way in list(itertools.permutations(chk)):
    now=1
    if way[0] in path[now]:
        f=1
        for j in way:
            if j in path[now]:
                now=j
                f+=1
            else:
                break
        if f==n: ans+=1
print(ans)

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

int main(){

    int N; cin >> N;
    int L[N];for (int i = 0; i < N; i++){cin >> L[i];}
    sort(L, L+N);

    long long cnt = 0;
    int sum;
    int bottom, top, mid;

    for(int i = 0; i < N-2; i++){
        for(int j = i+1; j < N-1; j++){

            sum = L[i] + L[j];
            bottom = j; top = N;

            while(top-bottom > 1){
                mid = (bottom + top)/2;
                if(L[mid] < sum){bottom = mid;}
                else{top = mid;}
            }

            //cout << "L[i] = " << L[i] << ", L[j] = " << L[j] << ", how = " << top-(j+1) << endl;

            cnt += top-(j+1);
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	char a[100005];
	char b[100005];
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			a[i] = '0';
		}
		else {
			a[i] = '1';
		}

	}
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			b[i] = '1';
		}
		else {
			b[i] = '0';
		}
	}
	int count = 0;
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != a[i]) {
			count++;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != b[i]) {
			sum++;
		}
	}
	cout << min(sum, count) << endl;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0
for i in range(N):
    if A[i] > B[i]:
        cnt += B[i]
        A[i] -= B[i]
        B[i] = 0
        
    else:
        cnt += A[i]
        B[i] -= A[i]
        A[i] = 0
        
            
    if A[i+1] > B[i]:
        cnt += B[i]
        A[i+1] -= B[i]
        B[i] = 0
        
    else:
        cnt += A[i+1]
        B[i] -= A[i+1]
        A[i+1] = 0

    #print(A)
    #print(B)
    #print(cnt)
    #print('')
        
       
cnt += min(A[-1],B[-1]) 


print(cnt)
        


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> x(n);
    REP(i, n) {
        cin >> x[i];
    }

    ll l;
    cin >> l;
    vvec<ll> next(20, vec<ll>(n, 0));
    REP(i, n) {
        auto it = upper_bound(all(x), x[i] + l);
        it--;
        next[0][i] = it - x.begin();
    }

    REP(i, 19) {
        REP(j, n) {
            next[i + 1][j] = next[i][next[i][j]];
        }
    }

    ll q;
    cin >> q;
    while(q--) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b)
            swap(a, b);

        ll ans = n;
        ll con = 0;
        int now = a;
        REP2(i, 20) {
            if(next[i][now] < b) {
                con += 1LL << i;
                now = next[i][now];
            } else {
                chmin(ans, con + (1LL << i));
            }
        }
        cout << ans << en;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


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

# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    A, B = list(map(int, input().split()))
    print(max(A-B*2, 0))


if __name__ == '__main__':
    main()


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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define maxn   3005

ll a[maxn][maxn];

ll f[maxn][maxn][5];

int main() {
//        freopen(".inp","r",stdin);

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int m, n, k;
        cin >> m >> n >> k;

        for(int i = 1; i <= k; ++ i) {
            int x, y, v;
            cin >> x >> y >> v;
            a[x][y] = v;
        }

        for(int i = 1; i <= m; ++ i) {
            for(int j = 1; j <= n; ++ j) {
                for(int z = 1; z <= 3; ++ z) {
                    f[i][j][z] = max(f[i][j][z], f[i][j-1][z]);
                    f[i][j][1] = max(f[i][j][1], f[i-1][j][z] + a[i][j]);
                    if(z > 1)
                        f[i][j][z] = max(f[i][j][z], f[i][j-1][z-1] + a[i][j]);
                }
            }
        }
        cout << max({f[m][n][1], f[m][n][2], f[m][n][3]});
}




Measured memory_bytes: 426132
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int W,H,x,y,r;
		W=sc.nextInt();
		H=sc.nextInt();
		x=sc.nextInt();
		y=sc.nextInt();
		r=sc.nextInt();
		if(x-r<0||x+r>W){
			System.out.println("No");
		}else{
			if(y-r<0||y+r>H){
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}
		}
		sc.close();
	}
}



Measured memory_bytes: 26260
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define endl '\n'
#define ff first
#define ss second
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;
using namespace boost::multiprecision; 

const ll inf = 1e18 + 42;

const ll M = 998244353;

ll power(ll x, ll y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	ll t = power(x, y / 2);
	return (t * t);
}

const ll MAX = 1e3 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void ahShitHereWeGoAgain()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll cnt = 0;
	for(ll i = 0; i < n; i++)
	{
		cin >> a[i];
		if(a[i] == 0) cnt++;
	}
	if(cnt)
	{
		cout << 0 << endl;
		return;
	}
	cpp_int ans = 1;
	for(ll i = 0; i < n; i++)
	{
		ans = ans * a[i];
		deb(ans);
		// deb(ans * a[i]);
		if(ans > 1000000000000000000)
		{
			cout << -1 << endl;
			return;
		}
		// ans = ans * a[i];
	}
	cout << ans << endl;
}

int main()
{
	DESYNC	
	ll t = 1;
	// cin >> t;
	while (t--)
		ahShitHereWeGoAgain();
	return 0;
}



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

const int N = 100010;

int n, c, k, a[N];

int main(){
	scanf("%d%d%d", &n, &c, &k);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	std::sort(a, a + n);
	int cnt = 0, now = a[0] + k, ans = 0;
	for (int i = 0; i < n; ++ i){
		if (cnt == c || a[i] > now){
			now = a[i] + k;
			cnt = 0;
			++ ans;
		}
		++ cnt;
	}
	if (cnt){
		++ ans;
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
BOX = [None for i in range(N)]
ANS_LIST = []
for i in range(N-1,-1,-1):
    loop = N//(i+1)
    cnt = 0
    for j in range(loop):
        if BOX[(i+1)*(j+1)-1]!=None:
            cnt+=BOX[(i+1)*(j+1)-1]
    BOX[i]=(cnt-A[i])%2

for i in range(N):
    if BOX[i]==1:
        ANS_LIST.append(i+1)

print(sum(BOX))
print(*ANS_LIST)

Measured memory_bytes: 14136
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i;
  int j;
  int change;
  int num = 0;
  int count = 0;
  int flag = 1;
  int *data;

scanf("%d",&num);
data = (int *)malloc(sizeof(int)*num);

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

  while(flag){
    flag = 0;

for(i = num - 1;i > 0;i--){
  if(data[i] < data[i - 1]){
    change = data[i];
    data[i] = data[i - 1];
    data[i - 1] = change;
    flag = 1;
    count++;
  }
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



Measured memory_bytes: 2140
#include <iostream>

int main() {
	int x;		//X日過ぎまでなら大丈夫
	int a, b;	//賞味期限のA日前購入, 買ってからB日後に食べる

	std::cin >> x >> a >> b;


	if (a - b >= 0) {
		std::cout << "delicious" << std::endl;
		return 0;
	}
	else if(a + x - b >= 0) {
		std::cout << "safe" << std::endl;
		return 0;
	}
	else {
		std::cout << "dangerous" << std::endl;
		return 0;
	}

	return 0;
}

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

#define MAX 100000
#define SENTINEL 2000000000

struct card
{
	char suit;
	int value;
};

card L[MAX/2+2], R[MAX/2+2];

void merge( card A[], int n, int left, int mid, int right)
{
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for( i = 0; i<n1; i++)	L[i] = A[i+left];
	for( i = 0; i<n2; i++)	R[i] = A[i+mid];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for( k = left; k < right; k++ )
	{
		if (L[i].value<=R[j].value)
		{
			A[k] = L[i++];
		}
		else 
		{
			A[k] = R[j++];
		}
	}
}

void mergeSort( card A[], int n, int left, int right)
{
	int mid;
	if(left + 1 < right)
	{
		mid = (left + right)/2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(card A[], int n, int p, int r)
{
	int i, j;
	card t, x;
	x = A[r];
	i = p-1;
	for(j = p; j < r; j++)
	{
		if (A[j].value <= x.value)
		{
			i++;
			t = A[i];
			A[i] = A[j];
			A[j] = t;
		}
	}
	t = A[r];
	A[r] = A[i+1];
	A[i+1] = t;
	return i+1;
}

void quickSort( card A[], int n, int p, int r)
{
	int q;
	if(p<r)
	{
		q = partition(A, n, p, r);
		quickSort(A, n, p, q-1);
		quickSort(A, n, q+1, r);
	}
}

int main(int argc, char const *argv[])
{
	int n, i, v;
	card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}

	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n-1);

	for (int i = 0; i < n; ++i)
	{
		if (A[i].suit!=B[i].suit)
		{
			stable = 0;
		}
	}
	if(stable) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
	for (int i = 0; i < n; ++i)
	{
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	return 0;
}


Measured memory_bytes: 5476
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 13, M = N << 1;

int n, m, x;
int c[N], a[N][N];
int b[N];
bool vis[N];
int ans = 0x3f3f3f3f;

void check()
{
    int sum = 0;
    for (int i = 1; i <= m; i+=1) b[i] = 0;
    for (int i = 1; i <= n; i+=1) if (vis[i])
    {
        sum += c[i];
        for (int j = 1; j <= m; j+=1)
            b[j] += a[i][j];
    }
    for (int i = 1; i <= m; i+=1) if (b[i] < x) return;
    ans = min(ans, sum);
    return;
}

void dfs(int u)
{
    if (u > n) {check(); return;}
    vis[u] = true;
    dfs(u + 1);
    vis[u] = false;
    dfs(u + 1);
}

int main()
{
    n = gi(), m = gi(), x = gi();
    for (int i = 1; i <= n; i+=1)
    {
        c[i] = gi();
        for (int j = 1; j <= m; j+=1)
            a[i][j] = gi();
    }
    dfs(1);
    if (ans == 0x3f3f3f3f) puts("-1");
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    static const double pi = 3.141592653589793;
    double a, b; cin >> a >> b;
    double h, m; cin >> h >> m;

    double tansin = 30*h + 0.5*m;
    double tyousin = 6 * m;

    double kakudo = abs(tansin - tyousin);
    kakudo = min(kakudo,360-kakudo);

    //cout << kakudo << endl;

    double ans2 = a*a + b*b - 2*a*b*cos(kakudo*pi/180.0);
    //cout << 2*a*b*cos(kakudo*pi/180.0) << endl;
    ans2 = sqrt(ans2);

    cout << fixed << setprecision(20) << ans2 << endl;



    
}

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

    # divisors.sort()
    return divisors


test_list = make_divisors(a)
test_list_modify = [i-1 for i in test_list if i > 2 and a//(i-1) == a%(i-1)]
print(sum(test_list_modify))

Measured memory_bytes: 3296
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
struct input_t{template<class T>operator T(){T t;std::cin>>t;return t;}}input;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n=input;
    std::set<std::string>set;
    while(n--){
        std::string s=input;
        set.insert(s);
    }
    std::cout<<set.size()<<'\n';
}


Measured memory_bytes: 19140
N=int(input())
A=list(map(int,input().split()))
bef=99999999999999
count=0
max=0
for i in range(N):
  l=A.pop()
  if l >= bef:
    count +=1
  else:
    count=0
  if max <= count:
    max=count
  bef=l
print(max)
    


Measured memory_bytes: 20568
N = int(input())
A = list(map(int,input().split()))

A_odd = 0
A_eve = 0

for i in range(N):
    if i % 2 ==0:
        A_eve += A[i]
    else:
        A_odd += A[i]

ans_list = []
for i in range(N):
    if i ==0:
        ans = A_eve-A_odd
    else:
        ans = -ans + A[i - 1]*2
    ans_list.append(str(ans))

print(' '.join(ans_list))

Measured memory_bytes: 92624
#include<stdio.h>

int main(){
	int a,g,b;
	int sum;

	scanf("%d%d%d",&a,&g,&b);

	sum=100*a+10*g+b;

	if(sum%4)
		printf("NO\n");
	else
		printf("YES\n");

	return 0;
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    while(true) {
        int n;
        vi v;
        cin >> n;
        if(n==0) break;

        while(n--) {
            int tmp;
            cin >> tmp;
            v.push_back(tmp);
        }
        vi w(v);
        rep(i, v.size()) v[i] = max(v[i-1] + v[i], v[i]);
        P(*max_element(ALL(v)));
    }
    return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int city[100] = {0};
	int a;
	for (int i = 0; i < m*2; i++) {
		cin >> a;
		city[a]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << city[i] << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

#define S_MAX 1000000000

int main(void)
{
    int N, K, S;
    int i;
    
    scanf("%d %d %d", &N, &K, &S);

    if ( S < S_MAX ) {
        for ( i = 0; i < N; i++ ) {
            if ( i < K ) {
                printf("%d ", S);
            } else {
                printf("%d ", (S + 1));
            }
        }
    } else {
        for ( i = 0; i < N; i++ ) {
            if ( i < K ) {
                printf("%d ", S);
            } else {
                printf("1 ");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    map<int, int> groups{
            { 1, 1 }, { 2, 3 }, { 3, 1 }, { 4, 2 }, { 5, 1 }, { 6, 2 },
            { 7, 1 }, { 8, 1 }, { 9, 2 }, { 10, 1 }, { 11, 2 }, { 12, 1 },
    };
    int x, y;
    cin >> x >> y;
    if (groups[x] == groups[y])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int n,d;
  int x[20][20];
  int count=0;
  scanf("%d %d",&n,&d);
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      scanf("%d",&x[i][j]);
    }
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int sum=0;
      for(int k=0;k<d;k++){
        int tmp=abs(x[i][k]-x[j][k]);
        sum+=tmp*tmp;
      }
      for(int l=0;l<=16000;l++){
        if(l*l==sum){
          count++;
        }
      }
    }
  }

  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
def find(A,B,C,K):
#     A<B<C
    for i in range(K+1):
        v1 = i
        v2 = K - i
        B0 = B*(2**v1)
        C0 = C*(2**v2)
        if A < B0 and B0 < C0:
            return True
    return False

A,B,C = list(map(int,input().strip().split()))
K = int(input())
if find(A,B,C,K):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61724
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000000

int main(){

    vector<bool> array(100001, true);
    
    for(int i = 2; i <= 100000; i++){
        if(array[i] == true){
            for(int j = i*2; j <= 100000; j += i) array[j] = false;
        }
    }

    vector<int> imos(100001, 0);
    for(int i = 3; i <= 100000; i += 2){
        if(array[i] == true && array[(i + 1) / 2] == true) imos[i] = 1;
        imos[i] += imos[i - 2];
    }

    int Q; cin >> Q;
    for(int i = 0; i < Q; i++){
        int l, r; cin >> l >> r;
        if(l == 1) cout << imos[r] << endl;
        else cout << imos[r] - imos[l - 2] << endl;
    }
    return 0;
}

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

int main() {
  char a,b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H'){
      cout << "H" << endl;
    }
    else{
      cout << "D" << endl;
    }
  }
  else{
    if(b=='H'){
      cout << "D" << endl;
    }
    else{
      cout << "H" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,max,sum,panel[3];
  for(i=0;i<3;i++){
    scanf("%d",&panel[i]);
  }
  max=panel[0];
  for(i=0;i<3;i++){
    sum+=panel[i];
  	if(max<panel[i]) max=panel[i];
  }
  printf("%d",(10*max)+sum-max);
  return 0;
}


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

int main() {
  int A, N;
  int x, y;
  cin >> N >> A;
  
  x = N / 500;
  y = N % 500;
  
 // cout << x << endl << y <<endl;
 
    if (A >= y){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }



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

bitset<50001> pt;

void MakeTable(int n){
  pt.reset();
  pt.set(2);
  
  int i;
  for(i=3;i<=n;i+=2)pt.set(i);
  
  i = 3;
  while(i*i<=n){
    for(int j=3*i;j<=n;j+=2*i)pt.reset(j);
    while(!pt[++i]);
  }
}

int main(){
  int n,ans;
  MakeTable(50000);

  while(scanf("%d",&n) && n){
    if(n&1)pt[n-2]?printf("1\n"):printf("0\n");
    else{
      ans = 0;
      for(int i=0;i<=n/2;i++)
	if(pt[i] && pt[n-i])ans++;
      printf("%d\n",ans);
    }
  }
}
	

Measured memory_bytes: 768
h, w = list(map(int, input().split()))
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == -1: continue
        ans += c[a[i][j]][1]

print(ans)

Measured memory_bytes: 3444
using System;
using System.Text;

namespace ITP_8_A{
    public class Program{
        public static void Main(string[] args){
            char[] temp = Console.ReadLine().ToCharArray();
            StringBuilder output = new StringBuilder();

            foreach(char target in temp){
                if(char.IsLower(target)){
                    //??§?????????????????????
                    output.Append(char.ToUpper(target));
                }else{
                    //?°??????????????????????
                    //ToLower??¢??°????°?????????§?????§????????§???????????´????????????????????????????§?
                    output.Append(char.ToLower(target));
                }
            }
            Console.WriteLine(output.ToString());
        }
    }
}

Measured memory_bytes: 9160
#include <iostream>
#include <vector>
using namespace std;
 
struct shop {
  string name;
  int point;
  int index;
};
 
int main() {
  int N;
  cin >> N;
  vector<shop> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i].name >> vec[i].point;
    vec[i].index = i + 1;
  }
  for(int i=0; i<N-1; i++){
    for(int j=0; j<N-1-i; j++){
      for(int k=0; k<vec[j].name.length(); k++){
        if(vec[j].name[k] == vec[j+1].name[k]){
          if(k == vec[j].name.length()-1 && vec[j].point < vec[j+1].point && vec[j].name.length() == vec[j+1].name.length()){
            shop temp = vec[j];
            vec[j] = vec[j+1];
            vec[j+1] = temp;
            break;
          }else{
          	continue;
          }
        }else if(vec[j].name[k] > vec[j+1].name[k]){
          shop temp = vec[j];
          vec[j] = vec[j+1];
          vec[j+1] = temp;
          break;
        }else{
          break;
        }
      }
    }
  }
  for(int i=0; i<N; i++){
    cout << vec[i].index << endl;
  }
  return 0;
}

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

int main(){
	int n,r;
	while(cin >> n >> r, n, r){
		int data[50], tmp[50];
		for(int i=0; i<n; i++){
			data[i]	= n-i;
			tmp[i] = n-i;
		}
		for(int i=0; i<r; i++){
			int p,c;
			cin >> p >> c;
			for(int j=0; j < p+c-1; j++){
				if(j<p-1){
					tmp[j+c] = data[j];
				}else{
					tmp[j-p+1] = data[j];
				}
			}
			for(int j=0; j<n; j++){
				data[j] = tmp[j];	
			}
		}
		cout << data[0] << endl;
	}
}

Measured memory_bytes: 3076
#include <cstdio>
#include <functional>
#include <algorithm>

int main()
{
    int N = 0;

    scanf("%d", &N);
    int a[N] = {0};
    for (int i = 0; i < N; ++i)
    {
        scanf("%d", &a[i]);
    }
    std::sort(a, a + N, std::greater<int>());
    int alice = 0, bob = 0;
    for(int i = 0; i < N; ++i)
    {
        if ( i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob += a[i];
        }
        
    }

    // Output
    printf("%d\n", alice - bob);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int n, a, mx, cnt, c[105];
void f() {
	puts("Impossible");
	exit(0);
}

int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) {
		scanf("%d", &a);
		c[a]++;
		mx = max(mx, a);
		cnt++;
	}
	if(cnt != n) f();
	if(c[mx] <= 1) f();
	if(mx == 1 && n > 2) f();
	if(mx % 2) {
		for(i=mx-1; i>mx/2+1; i--) {
			if(c[i] < 2) f();
		}
		if(c[mx/2+1] != 2) f();
	} else {
		for(i=mx-1; i>mx/2; i--) {
			if(c[i] < 2) f();
		}
		if(c[mx/2] != 1) f();
	}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;
const int INF = 1000000001;

struct Robot {
    int x, l;
    
    bool operator < (const Robot& r) const {
        return x + l < r.x + r.l;
    }
};

int n;
Robot a[MAX];

int solve() {
    sort(a, a + n);
    int last = -INF, ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i].x - a[i].l < last) {
            continue;
        }
        last = a[i].x + a[i].l;
        ans++;
    }
    return ans;
}

int main(void) {
	// in = fopen("B.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%d %d", &a[i].x, &a[i].l);
	    
	fprintf(out, "%d\n", solve());
	
	return 0;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  string s1, s2;
  cin >> s1 >> s2;
  
  vector<int> x;
  for(int i = 0; i < n; i++){
    if(s1.at(i) == s2.at(i)) x.push_back(1);
    else{
      x.push_back(2);
      i++;
    }
  }
  
  ll ans;
  if(x.at(0) == 1) ans = 3;
  else ans = 6;
  
  for(int i = 1; i < x.size(); i++){
    if(x.at(i - 1) == 1){
      ans *= 2;
    }
    else{
      if(x.at(i) == 2) ans *= 3;
    }
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
  int N, X, T, ans = 0, count = 0 ;
  char S[200005] = {} ;
  cin >> S ;
  for(int i=0;i<200005;i++){
    count = (count + ctoi(S[i])) % 9 ;
  }
  if(count == 0){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}  

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

int f(int n) {
	return (n % 2 == 0) ? n / 2 : 3 * n + 1;
}

int main(int argc, char const *argv[])
{
	int s; cin >> s;
	int a = s;
	vector<int> memo(1000100, -1);
	memo[a] = s;
	int idx = 2;
	while (1) {
		int nexta = f(a);
		if (memo[nexta] != -1) {
			printf("%d\n", idx);
			return 0;
		}
		memo[nexta] = idx++;
		a = nexta;
	}
	return 0;
}


Measured memory_bytes: 4096