akhauriyash/Code-Regression huggingface dataset:
# -*- 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(10000)


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(N, T, A, H):

    tmp = []
    for i, h in enumerate(H):
        tmp.append((abs(A-(T-h*0.006)), i))
    return min(tmp)[1] + 1


def main():
    N = read_int()
    T, A = read_int_n()
    H = read_int_n()
    print(slv(N, T, A, H))


if __name__ == '__main__':
    main()


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

using namespace std;

#define MAX_H 30
#define MAX_W 30

int H, W;

string str[MAX_H][MAX_W];

void input()
{
  cin >> H >> W;
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      cin >> str[i][j];
    }
  }
}

int main()
{
  input();
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      if(str[i][j] == "snuke"){
        char c = 'A' + j;
        cout << c << i + 1<< endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;

int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}

	sort(H.rbegin(), H.rend());
	long long count = 0;
	for (int i = K; i < N; ++i) {
		count += H[i];
	}
	cout << count << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;


int calc_max_dist(vector<string> S, vector<pair<int, int>> points, pair<int, int> p_s) {
    int h = S.size();
    int w = S[0].size();
    map<pair<int, int>, int> distance;
    for (auto p: points) {
        distance[p] = -1;
    }
    queue<pair<pair<int, int>, int>> que;
    que.push(make_pair(p_s, 0));
    while (!que.empty()) {
        auto t = que.front();
        auto p = t.first;
        auto d = t.second;
        que.pop();
        auto y = p.first; auto x = p.second;
        if (0 > x || x >=  w || y < 0 || y >= h) {
            continue;
        }
        if (S[y][x] == '#') {
            continue;
        }
        if (distance[p] != -1) {
            continue;
        }

        distance[p] = d;
        que.push(make_pair(make_pair(y, x - 1), d + 1));
        que.push(make_pair(make_pair(y, x + 1), d + 1));
        que.push(make_pair(make_pair(y - 1, x), d + 1));
        que.push(make_pair(make_pair(y + 1, x), d + 1));
    }
   
    int max_dist = -1;
    for (auto d: distance) {
        max_dist = max(max_dist, d.second);
    }
    return max_dist;
}

int main(int argc, char const *argv[])
{
    int h, w;
    cin >> h >> w;

    vector<string> S(h);
    for (int y = 0; y < h; y++) {
        cin >> S[y];
    }

    vector<pair<int, int>> points;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            if (S[y][x] == '.') {
                points.push_back(make_pair(y, x));
            }
        }
    }
    vector<int> distance;
    for (int i = 0; i < points.size(); i++) {
        auto p_s = points[i];
        int d = calc_max_dist(S, points, p_s);
        distance.push_back(d);
    }
    cout << *max_element(distance.begin(), distance.end()) << endl;
    return 0;
}


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

int main() {
  int N, count = 0;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  for (int j = 0; j < N - 2; j++) {
    int a = vec.at(j);
    int b = vec.at(j + 1);
    int c = vec.at(j + 2);
    if (a > b && b > c || a < b && b < c) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();

    sin.read_line(&mut buf).ok();
    let mut ws = buf.split_whitespace();
    let n: usize = ws.next().unwrap().parse().unwrap();
    let m: usize = ws.next().unwrap().parse().unwrap();
    let l: usize = ws.next().unwrap().parse().unwrap();

    let mut a: Vec<Vec<u64>> = vec![vec![0; m]; n];
    let mut b: Vec<Vec<u64>> = vec![vec![0; l]; m];
    let mut c: Vec<Vec<u64>> = vec![vec![0; l]; n];

    for i in 0..n {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        for (j, v) in buf.split_whitespace().enumerate() {
            a[i][j] = v.parse::<u64>().unwrap();
        }
    }
    
    for i in 0..m {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        for (j, v) in buf.split_whitespace().enumerate() {
            b[i][j] = v.parse::<u64>().unwrap();
        }
    }

    for i in 0..n {
        for j in 0..l {
            for k in 0..m {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for i in 0..n {
        let s = c[i].iter()
            .map(|v| v.to_string())
            .collect::<Vec<String>>()
            .join(" ");
        println!("{}", s);
    }
}


Measured memory_bytes: 5060
n=int(input())
p=list(map(int,input().split()))
cnt=0
p.sort()

if n%2==0:
    mid1=n/2
    mid2=n/2
    mid1=int(mid1-1)
    mid2=int(mid2)
    cnt=p[mid2]-p[mid1]
else:
    cnt=0

print(cnt)


Measured memory_bytes: 14396
import sys
from collections import deque,Counter
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    s = S()
    t = S()
    ans = 0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 27208
#include <stdio.h>
main(){
int set;
scanf("%d",&set);
int a[set],b[set],c[set],i;
for(i=0;i<set;i++){
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}

for(i=0;i<set;i++){
if(b[i]>=a[i] && b[i]>=c[i]){
b[i]=b[i]*b[i];

if(b[i]==a[i]*a[i]+c[i]*c[i]){
printf("YES\n");
}
else printf("NO\n");
}
else if(a[i]>b[i] && a[i]>=c[i]){
a[i]=a[i]*a[i];
if(a[i]==b[i]*b[i]+c[i]*c[i]){
printf("YES\n");
}
else printf("NO\n");
}
else if(c[i]>a[i] && c[i]>b[i]){
c[i]=c[i]*c[i];

if(c[i]==a[i]*a[i]+b[i]*b[i]){
printf("YES\n");
}
else printf("NO\n");
}
}
return 0;
}

Measured memory_bytes: 588
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

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

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

alias sread = () => readln.chomp();

void main()
{
    auto nx = aryread();
    long[] m = new long[](nx[0]);
    foreach (i; 0 .. nx[0])
    {
        m[i] = lread();
    }
    long x = nx[1];
    x -= m.sum();
    long result = m.length;
    result += x / reduce!min(m);
    writeln(result);
}


Measured memory_bytes: 256
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
sumac = 0
for i in range(n):
    sumc = c
    a = list(map(int,input().split()))
    for j in range(m):
        sumc += a[j]*b[j]
    if sumc > 0: sumac += 1
print(sumac)

Measured memory_bytes: 3064
N = int(input())
al = []
bl = []
for i in range(N):
    a, b = map(int, input().split())
    al.append(a)
    bl.append(b)
cnt = 0

for i in range(N - 1, -1, -1):
    tmp = (al[i] + cnt) % bl[i]
    if tmp != 0:
        cnt += bl[i] - tmp

print(cnt)


Measured memory_bytes: 11052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
int main(){
  vector<int> Product(5);
  for (int  i = 0; i < 5; i++)
  {
    cin >> Product[i];
  }
  int min_time = 20021003;
  sort(Product.begin(), Product.end());
  do{
    int ans = 0;
    for (int  i = 0; i < 5; i++)
    {
      while (ans % 10 != 0)
      {
        ans++;
      }
      ans += Product[i];
    }
    min_time = min(min_time, ans);
  } while(next_permutation(Product.begin(), Product.end()));
  cout << min_time << endl;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

if a * a * b / 2 <= x:
  ans = math.degrees(math.atan((a*a*b - x) * 2 / a**3))
else:
  ans = math.degrees(math.atan(a*b*b/2/x))
  
print(ans)

Measured memory_bytes: 9264
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

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

int main(){
    ll h,w; cin >> h >> w;
    string s[h];
    rep(i,h)cin >> s[i];

    int dx[] = {0,1};
    int dy[] = {1,0};
    auto check = [&](int x, int y){
        if(x < 0 || h <= x)return false;
        if(y < 0 || w <= y)return false;
        return true;
    };

    vector<vector<ll>> graph(h, vector<ll>(w,INF));
    deque<Pll> deq;
    graph[0][0] = (s[0][0] == '.') ? 0 : 1;
    deq.emplace_front(0,0);
    while(!deq.empty()){
        auto p = deq.front();deq.pop_front();
        // print(p);
        int x = p.first, y = p.second;
        ll c = graph[x][y];
        rep(i,2){
            int nx = x + dx[i], ny = y + dy[i];
            
            if(!check(nx,ny)){continue;}
            // if(graph[nx][ny] != INF)continue;

            if(s[nx][ny] == '#'){
                if(s[x][y] == '#'){
                    if(chmin(graph[nx][ny], c))deq.emplace_front(nx,ny);
                }
                else {
                    if(chmin(graph[nx][ny], c + 1))deq.emplace_back(nx,ny);
                }
            }
            else{
                if(chmin(graph[nx][ny], c))deq.emplace_front(nx, ny);
            }
            
            // print(nx,ny);
            // debug("test");
        }
        
    }
    // print(graph);
    cout << graph[h-1][w-1] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string a;
bool u[30];
int main()
{
	cin>>a;
	for(int s=0;s<a.size();s++)
	{
		if(u[a[s]-'a']==0)u[a[s]-'a']=1;
		else
		{
			cout<<"no"<<endl;
			exit(0);
		}
	}
	cout<<"yes"<<endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);
bool isMultiOf(LL, LL);

int main() {
	int a[] = { 1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y; cin >> x >> y;
	if (a[x - 1] == a[y - 1])coutY();
	else coutN();
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}
bool isMultiOf(LL a, LL b) {
	return a % b == 0;
}

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

int main() {
	int res=0;
	string a;
	cin >> a;
	for (int i = 0; i < 4; i++) {
		if (a[i] == '+') res++;
		if (a[i] == '-') res--;
	}
	cout << res << "\n";
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
void solve()
{
    lli s,c;cin>>s>>c;
    c=c/2;
    lli x=min(s,c);
    lli ans=x;
    s-=x,c-=x;
    if(c>0)
    {
        ans+=c/2;
    }
    cout<<ans<<endl;
}
int main()
{
    FAST;
    //int tc=1;cin>>tc;while(tc--)solve();
    solve();
}



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

int main(){
	int n,c[21],v[21];
	cin>>n;
	for(int i=1;i<=n;++i)	cin>>v[i];
	for(int i=1;i<=n;++i){
		cin>>c[i];
		c[i]=v[i]-c[i];
	}
	int ans=0;
	for(int i=1;i<=n;++i)
		if(c[i]>0)	ans+=c[i];
	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int w[301],h[301],i;
    for(i=0;;i++)
    {
        scanf("%d%d",&h[i],&w[i]);
        if(w[i]==0 && h[i]==0)
            break;
    }
    for(i=0;;i++)
    {
        int a,b;
        for(a=1;a<=h[i];a++)
           {
               for(b=1;b<=w[i];b++)
               {
                   printf("#");
               if(b==w[i])
                printf("\n");
               }
           }
        if(w[i]==0 && h[i]==0)
            break;
        printf("\n");

    }
    return 0;
}



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

using namespace std;

int main(void) {
    string s; cin >> s; // 入力
    bool flag = true; // 「踏みやすい」かどうか判定するフラグ,

    // 文字列sの要素数だけループ回す(10文字だと10回回る)
    // 踏みにくいステップ(文字列)を受け取った場合、即座にフラグがfalseになる
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) { // 偶数ステップ(i=0,2,4,6...)
            if (s[i] == 'L') {
                flag = false; // 踏みにくい！
                break;
            }
        }
        else { // 奇数ステップ(i=1,3,5,7...)
            if (s[i] == 'R') {
                flag = false; // 踏みにくい！
                break;
            }
        }
    }

    // 踏みやすい(flag == true)なら"Yes"、そうでなければ"No"
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
ll modp(ll a,ll b,ll m){
  if(b==0) return 1;
  if(b%2) return modp(a,b-1,m)*a%m;
  return modp(a,b/2,m)*modp(a,b/2,m)%m;
}
ll npow(ll a,ll b){
  if(b==0) return 1;
  if(b%2) return npow(a,b-1)*a;
  return npow(a,b/2)*npow(a,b/2);
}
int main(){
  ll L,A,B,M;
  cin>>L>>A>>B>>M;
  ll X[18]={};
  ll nine=0,sum=0;
  ll D[3];
  D[0]=0;
  D[1]=A%M;
  D[2]=1;
  ll AA=A;
  int size=0;
  while(AA){
    AA/=10;
    size++;
  }
  rep(i,18){
    nine=nine*10+9;
    if(i+1>=size){
      ll Y=(nine-A)/B+(i+1>=size);
      ll tmp=min(L,Y);
      X[i]=max(0LL,tmp-sum);
      sum=tmp;
    }
  }
  rep(i,18){
    ll P[3][3][70]={};
    ll Q[3][3]={};
    rep(j,3) rep(k,3) P[j][k][0]=(j==k);
    rep(j,3) rep(k,3) Q[j][k]=(j==k);
    P[0][0][1]=modp(10,i+1,M);
    P[1][0][1]=1;
    P[1][1][1]=1;
    P[2][1][1]=B%M;
    P[2][2][1]=1;
    rep(j,65){
      if(j>1) rep(k,3) rep(l,3){
        P[k][l][j]=(P[k][l][j]+P[k][0][j-1]*P[0][l][j-1])%M;
        P[k][l][j]=(P[k][l][j]+P[k][1][j-1]*P[1][l][j-1])%M;
        P[k][l][j]=(P[k][l][j]+P[k][2][j-1]*P[2][l][j-1])%M;
      }
    }
    rep(j,64){
      ll QQ[3][3];
      if(X[i]&npow(2,j)){
        rep(k,3) rep(l,3) QQ[k][l]=Q[k][l];
        rep(k,3) rep(l,3){
          Q[k][l]=(QQ[k][0]*P[0][l][j+1])%M;
          Q[k][l]=(Q[k][l]+QQ[k][1]*P[1][l][j+1])%M;
          Q[k][l]=(Q[k][l]+QQ[k][2]*P[2][l][j+1])%M;
        }
      }
    }
    ll DD[3];
    rep(j,3) DD[j]=D[j];
    rep(j,3){
      D[j]=(DD[0]*Q[0][j])%M;
      D[j]=(D[j]+DD[1]*Q[1][j])%M;
      D[j]=(D[j]+DD[2]*Q[2][j])%M;
    }
  }
  cout<<D[0]<<endl;
}

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

int g[15][15];
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,60) {
        ll x = 0;
        rep(j,n) if (a[j]>>i&1) x++;
        ll now = x*(n-x)%mod;
        rep(j,i) now = now*2%mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5540
MOD = 998244353
A,B,C,D = map(int,input().split())
dp = [[1 for i in range(D+1)] for j in range(C+1)]
for i in range(B+1, D+1):
	dp[A][i] = dp[A][i-1] * A % MOD
for j in range(A+1, C+1):
	dp[j][B] = dp[j-1][B] * B % MOD

for i in range(A+1, C+1):
	for j in range(B+1, D+1):
		dp[i][j] = (dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1)*(j-1)) % MOD
print(dp[C][D])

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

#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(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int K, X;
  cin >> K >> X;
  if(500 * K >= X){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((LL)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin, (X).rend()
// #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define readV(X) for(int &ele : (X)) cin >> ele
#define readVI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define length(a) (hypot((a).imag(), (a).real()))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) * (b)).imag())
#define lengthSqr(p) dot(p, p)
#define rotateO(p, ang) ((p) * exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define X real()
#define Y imag()
 
using namespace std;
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
// void err(istream_iterator<string> it) {}
// template<typename T, typename... Args>
// void err(istream_iterator<string> it, T a, Args... args) {
//     cerr << *it << " = " << a << endl;
//     err(++it, args...);
// }
// template<typename... Args>
// void read(Args&... args)
// {
//     ((cin >> args), ...);
// }
 
// template<typename... Args>
// void write(Args... args)
// {
//     ((cout << args), ...);
// }
typedef long long LL;
typedef complex<double> point;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);


int main(){
    FAST_IO
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    char o, t;
    cin >> o >> t;
    if(o < t) cout << "<\n";
    else if(o > t) cout << ">\n";
    else cout << "=\n";

}  

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}


typedef vector<ll> vec;
typedef vector<vec> mat;

int main(){
	int n;
	cin>>n;
	vec x(n);
	rep(i, n) cin>>x[i];
	vec y(n+1);
	y[0] = x[0];
	rep(i, n) y[i+1] = x[i+1]-x[i];
	ll m, k;
	cin>>m>>k;
	vec f(n+1);
	rep(i, n+1) f[i] = i;
	vec g(f);
	rep(i, m){
		int a;
		cin>>a; a--;
		swap(f[a], f[a+1]);
	}
	while(k){
		if(k&1){
			rep(i, n+1) g[i] = f[g[i]];
		}
		vec f2(f);
		rep(i, n+1) f[i] = f2[f2[i]];
		k >>= 1;
	}
	vec y2(y);
	rep(i, n+1) y[i] = y2[g[i]];
	x[0] = y[0];
	rep(i, n) x[i+1] = y[i+1]+x[i];
	rep(i, n) cout<<x[i]<<endl;
	return 0;
}


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

int gcd(int a,int b){
    int ans;
    for(int i=1;i<min(a,b);i++){
        if(a%i==0&&b%i==0) ans=i;
    }
    return ans;
}
int main(){
    ll a,b; cin>>a>>b;
    for(int i=1;i<=b;i++){
        if((a*i)%b==0){
            cout<<a*i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

ll com[16][16];
int n;
ll dp[1 << 16];
ll val[1 << 16];


int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) 
		cin >> com[i][j];
	dp[0] = 0;
	for (int i = 1; i < (1 << n); i++) {
		int ind;
		for (ind = 0; ind < n; ind++) {
			if (i & (1 << ind)) break;
		}
		val[i] += val[i ^ (1 << ind)];
		for (int j = ind + 1; j < n; j++) {
			if (i & (1 << j)) val[i] += com[ind][j];
		}
		int mask = i;
		while (mask > 0) {
			dp[i] = max(dp[i], dp[i ^ mask] + val[mask]);
			mask = (mask - 1) & i;
		}
		// case: mask = 0
		dp[i] = max(dp[i], val[i]);
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}

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

using namespace std;
const long long INF = 1LL<<60;

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

    long long dp[110][100100];

    // dpテーブル初期化
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < 100100; ++sum_v) {
            dp[i][sum_v] = INF;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for (long long sum_v = 0; sum_v < 100100; ++sum_v) {
            if (sum_v < v[i]) {
                dp[i+1][sum_v] = dp[i][sum_v];
            } else {
                dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v-v[i]] + weight[i]);
            }
        }
    }

    long long ans = 0;
    for (int sum_v = 0; sum_v < 100100; ++sum_v) {
        if(dp[N][sum_v] <= W) ans = sum_v;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long ll;

typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 3E5+7;
const ll MOD = 1e9+7;
const ll M1 = 1e9+7;
const ll INF = 1E17;
const ld eps = 0.00000000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
	static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution <int> (a, b)(rng);
}

ll cnt[2][DIM];
vector<ll> G[DIM];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll h,w;
    cin>>h>>w;
    ll m;
    cin>>m;
    forn(i,m){
        ll x,y;
        cin>>x>>y;
        ++cnt[0][x];
        ++cnt[1][y];
        G[x].pb(y);

    }
    ll mx = 0;
    forn(i,w){
        mx = max(mx,cnt[1][i]);
    }
    ll num = 0;
    forn(i,w){
        if (cnt[1][i]==mx)++num;
    }
    ll res = 0;
    forn(i,h){
        ll cur = num;
        for(ll to:G[i]){
            if (cnt[1][to]==mx)--cur;
        }
        res = max(res,cnt[0][i]+mx-(cur==0));
    }
    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 24744
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <algorithm>

int main(){
  int N;
  std::cin >> N;

  std::vector<int> ta(N), va(N);
  for(int i = 0; i < N; i++) std::cin >> ta[i];
  for(int i = 0; i < N; i++) std::cin >> va[i];

  std::vector<int> t_arr(N);
  std::unordered_map<int, int> tv_map, tl_map;
  int t_total = 0;
  tl_map[0] = 0;
  for(int i = 0; i < N; i++){
    int t=ta[i], v=va[i];
    t_arr[i] = t_total;
    tv_map[t_total] = v;
    tl_map[t_total] = std::min(tl_map[t_total], v);
    tl_map[t_total+t] = v;
    t_total += t;
  }
  tl_map[t_total] = 0;

  double prev_v = 0.0;
  double ans = 0;
  for(int i = 0; i <= t_total*2; i++){
    double t = i/2.0;
    double v_max = tv_map[*(std::lower_bound(t_arr.begin(), t_arr.end(), t)-1)];
    for(auto&& it: tl_map){
      v_max = std::min(v_max, std::abs(it.first-t)+it.second);
    }
    ans += 0.5*(prev_v+v_max)*0.5;
    prev_v = v_max;
  }
  std::cout << std::setprecision(9) << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
s = input()

ans = 1000
for cur in "abcdefghijklmnopqrstuvwxyz":
    count = 0
    t_count = 0
    for i in s:
        if i == cur:
            count = max(count, t_count)
            t_count = 0
        else:
            t_count += 1

    count = max(count, t_count)
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

int main() {
  string s;
  cin>>s;
  set<char> vis;
  trav(x,s) {
    if(vis.find(x) != vis.end()) {
      cout<<"no";
      return 0;
    }
    vis.insert(x);
  }
  cout<<"yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
#define fi first
#define se second
#define mp make_pair

const int N = (1 << 18) + 5;

int n, a[N], id[5], res;
ii maxx[N];

ii operator + (ii x, ii y) {
	id[1] = x.fi;
	id[2] = x.se;
	id[3] = y.fi;
	id[4] = y.se;
	sort(id + 1, id + 5, [](int u, int v){
		// if (v == -1) return true;
		// if (u == -1) return false;
		return a[u] > a[v];
	});
	if (id[1] != id[2]) return mp(id[1], id[2]);
	else if (id[1] != id[3]) return mp(id[1], id[3]);
	else return mp(id[1], id[4]);
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < (1 << n); i ++) {
		scanf("%d", &a[i]);
		maxx[i] = mp(i, 0);
		for (int j = 0; j < 18; ++ j) {
			if ((i & (1 << j)) > 0) {
				maxx[i] = maxx[i] + maxx[i ^ (1 << j)];
			}
		}
		if (i > 0) {
			res = max(res, a[maxx[i].fi] + a[maxx[i].se]);
			printf("%d\n", res);
		}
	}
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int[] A = new int[3];
            for (int i = 0; i < 3; i++) {
                A[i] = in.nextInt();
            }

            int min = (int) 1e9;
            min = Math.min(min, Math.abs(A[0] - A[1]) + Math.abs(A[1] - A[2]));
            min = Math.min(min, Math.abs(A[0] - A[2]) + Math.abs(A[2] - A[1]));
            min = Math.min(min, Math.abs(A[1] - A[0]) + Math.abs(A[0] - A[2]));
            min = Math.min(min, Math.abs(A[1] - A[2]) + Math.abs(A[2] - A[0]));
            min = Math.min(min, Math.abs(A[2] - A[0]) + Math.abs(A[0] - A[1]));
            min = Math.min(min, Math.abs(A[2] - A[1]) + Math.abs(A[1] - A[0]));

            System.out.println(min);
        }
    }

}


Measured memory_bytes: 22732
import Control.Monad
import Control.Monad.State
import qualified Data.Map as Map
import qualified Data.List as List

type AlpMap = Map.Map Char Int
type AlpState = State AlpMap Int

nan :: Int
nan = 51

main :: IO ()
main = do
  n <- readLn :: IO Int
  strs <- replicateM n getLine
  putStrLn $ solve strs

solve :: [String] -> String
solve strs = map2Str $ execState  (update inputs) initMap
  where
    inputs :: [[(Char, Int)]]
    inputs = map (toInput .
                  List.group . List.sort)
             strs
    initMap :: AlpMap
    initMap = Map.fromList $ zip ['a','b'..'z'] $ repeat nan

toInput :: [String] -> [(Char, Int)]
toInput str = go str ['a'..'z']
  where
    go [] ss = zip ss $ repeat 0
    go _ [] = []
    go (x:xs) (y:ys) =
      case head x of
         _ | y == head x -> (y, length x) : go xs ys
         _  -> (y, 0) : go (x:xs) ys

update :: [[(Char, Int)]] -> AlpState
update [] = do
  return 0
update (s:ss) = do
  _ <- upd s
  update ss
  where
    upd :: [(Char, Int)] -> AlpState
    upd [] = return 0
    upd ((c, i):is) = do
      i' <- gets (Map.lookup c)
      case i' of
        Nothing -> upd is
        Just y -> do
          modify (Map.insert c (min i y))
          upd is
    
map2Str :: AlpMap -> String
map2Str = Map.foldWithKey (\k a b -> if a == nan
                                     then b
                                     else replicate a k ++ b) []


Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

bool check(P a, P b) {
	if (a.second <= b.first) {
		return false;
	}
	return true;
}

P merge(P a, P b) {
	P c;
	c.first = max(a.first, b.first);
	c.second = min(a.second, b.second);
	return c;
}

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

	vector<P> data(m);

	P p;

	for (long long int i = 0; i < m; i++) {
		cin >> p.first >> p.second;
		data[i] = p;
	}

	sort(data.begin(), data.end());

	long long int count = 1;

	for (int i = 0; i < m; i++) {
		P aa = data[i];
		for (int j = i + 1; j < m; j++) {
			if (check(aa, data[j])) {
				aa = merge(aa, data[j]);
				i++;
			}
			else {
				count++;
				break;
			}
		}
		//cout << aa.first << ' ' << aa.second << endl;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1792
Program Main

    Implicit None
    Character               :: S*100, num*3
    Character, Allocatable  :: X(:)*1
    Integer                 :: A,i

    Read(*,*) S

    A = Len_trim(S)
    Allocate (X(A))  ; X(:) ="x"

    Write(num,"(I3)") A
    Write(*,"("//num//"(a))")(X(i),i=1,A)

  End Program


Measured memory_bytes: 640
def main():
    mod = 2019
    count = [0] * 2019
    count[0] = 1
    s = input().strip()
    digit = 1
    current = 0
    for c in s[::-1]:
        current = (current + int(c) * digit) % mod
        count[current] += 1
        digit = digit * 10 % mod
    return sum([n * (n - 1) // 2 for n in count if n > 1])


print(main())


Measured memory_bytes: 9364
import sys
from collections import Counter

def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    MAX_A = max(A)
    A_COUNT = Counter(A)

    if min(A) == 1:
        if A_COUNT[1] == 1:
            print(1)
        else:
            print(0)
        exit()

    ans = 0
    prime = [False] * 2 + [True] * (MAX_A - 1)
    for a in A:
        if prime[a]:
            if A_COUNT[a] == 1:
                ans += 1
            for j in range(a, MAX_A + 1, a):
                prime[j] = False
    print(ans)

if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,q; cin>>n>>q;
  vector<tuple<int,int,int>> a(n);
  rep(i,n) {
    int l,r,x; cin>>l>>r>>x;
    l-=x;
    r-=x;
    a[i] = tie(x,l,r);
  }
  vsort(a);
  set<pii> s;
  rep(i,q){
    int d; cin>>d;
    s.insert(pii(d,i));
  }
  vi ans(q, -1);
  rep(i,n){
    int x,l,r;
    tie(x,l,r)=a[i];
    auto it = s.lower_bound(pii(l,-1));
    while(it!=s.end()){
      if(it->first >= r) break;
      ans[it->second]=x;
      s.erase(it++);
    }
  }
  rep(i,q)cout<<ans[i]<<endl;
}


Measured memory_bytes: 14464
#include <stdio.h>

int returnMax(int a,int b,int c);

int main(void){
  int datanum;
  scanf("%d",&datanum);
  int num[3];
  int i,j;
  int temp;
  while(datanum !=0){
    scanf("%d %d %d",&num[0],&num[1],&num[2]);
    for(i=0;i<3;i++){
      for(j=i;j<3;j++){
        if(num[i] < num[j]){
          temp = num[i];
          num[i] = num[j];
          num[j] =temp;
        }
      }
    }
    if((num[0]*num[0] )==(num[1] * num[1] +num[2]*num[2])){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    datanum--;
  }

  //check
  /*
  for(i=0;i<datanum;i++){
    printf("%d-%d-%d\n",num[i],num[i+1],num[i+2]);
  }
  */
  return(0);
}
int returnMax(int a,int b,int c){

  if(a>b+c){
    return(a);
  }
  else if(b>a+c){
    return(b);
  }
  else
    return(c);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    if (A==1){
        A=14;
    }
    if (B==1){
        B=14;
    }
    if (A>B){
        cout << "Alice";
    }
    if (B>A){
        cout << "Bob";
    }
    if (A==B){
        cout << "Draw";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;

const int N = 1e5 + 10, mod = 1e9 + 7;
int n, m;
int a[N], b[N];
int cnt, top;
int s[N], f[N];
pair < int, int > p[N];
int c[N];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline bool mycmp(pair < int, int > a, pair < int, int > b) { return a.fi == b.fi ? a.se > b.se : a.fi < b.fi; }\

inline int lowbit(int x) { return x & -x; }

inline void add(int x, int v) {
	for(; x < top; x += lowbit(x))	c[x] = (c[x] + v) % mod;
}

inline int ask(int x) {
	int re = 0;
	for(; x; x -= lowbit(x))	re = (re + c[x]) % mod;
	return re;
}

int main() {
	n = read(), m = read();
	for(int i = 1; i <= n; ++i)	a[i] = read();
	for(int i = 1; i <= m; ++i)	b[i] = read();
	for(int i = 1; i <= n; ++i) {
		if(a[i] < b[1] || a[i] >= b[m])	continue;
		int x = lower_bound(b + 1, b + m + 1, a[i]) - b;
		if(b[x] == a[i])	continue;
		p[++cnt] = make_pair(a[i] - b[x - 1], b[x] - a[i]);
		s[++top] = b[x] - a[i];
	}
	sort(s + 1, s + top + 1);
	top = unique(s + 1, s + top + 1) - s - 1;
	for(int i = 1; i <= cnt; ++i)	p[i].se = lower_bound(s + 1, s + top + 1, p[i].se) - s;
	sort(p + 1, p + cnt + 1, mycmp);
	cnt = unique(p + 1, p + cnt + 1) - p - 1;
	f[0] = 1;
	for(int i = 1; i <= cnt; ++i)
		f[i] = ask(p[i].se - 1) + 1, add(p[i].se, f[i]);
	int ans = 0;
	for(int i = 0; i <= cnt; ++i)	ans = (ans + f[i]) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2688
#!/usr/bin/env python3
def main():
    from math import gcd

    N = int(input())
    A = []
    INF = 10 ** 6 + 5
    frequency = [0] * INF
    for a in [int(x) for x in input().split()]:
        A.append(a)
        frequency[a] += 1
    
    pairwise = True
    for i in range(2, INF):
        cnt = 0
        for j in range(i, INF, i):
            cnt += frequency[j]
        if cnt > 1:
            pairwise = False
    if pairwise:
        print("pairwise coprime")
        return

    g = 0
    for i in range(N):
        g = gcd(g, A[i])
        if g == 1:
            print('setwise coprime')
            return
    
    print('not coprime')


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    long long l, r;
    cin >> l >> r;
    if (r-l+1 >= 2019) cout << 0;
    else{
        int res = 2019;
        for (int i = l; i < r; i++){
            for (int j = i+1; j <= r; j++){
                if (((i % 2019)*(j % 2019)) % 2019 < res){
                    res = ((i % 2019)*(j % 2019)) % 2019;
                }
            }
        }
        cout << res;
    }
    return 0;
}


Measured memory_bytes: 256
class Ruiseki2D:
    """二次元累積和を構築する"""
    def __init__(self, matrix):
        self.h = len(matrix)
        self.w = len(matrix[0])
        self.ru = [[0] * (self.w + 1) for _ in range(self.h + 1)]

        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] = self.ru[i + 1][j] + matrix[i][j]
        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] += self.ru[i][j + 1]

    def get_sum(self, hl, hr, wl, wr):
        """[hl, hr), [wl, wr) で囲まれた部分の和を求める"""
        return (self.ru[hr][wr] + self.ru[hl][wl]
                - self.ru[hr][wl] - self.ru[hl][wr])

n, m, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
query = [list(map(int, input().split())) for i in range(q)]

matrix = [[0] * (n + 1) for i in range(n + 1)]
for l, r in info:
    matrix[l][r] += 1

ru = Ruiseki2D(matrix)

for q1, q2 in query:
    print(ru.get_sum(q1, q2 + 1, q1, q2 + 1))

Measured memory_bytes: 111616
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

const ll fi = 5 * 1e15;
ll po[10];

int main(int argc, char const* argv[])
{
	string s;
	ll k;
	cin >> s;
	cin >> k;
	int index = 0;
	while(s[index] == '1'){
			if(index+1 == k){
					cout << 1 << endl;
					return 0;
			}
			index++;
	}
	cout << s[index] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1;
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };





int main(){
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int>s(n);
	rep(i, 0, n)cin >> s[i];

	int msk = 1;
	rep(i, 0, n)msk *= 4;

	int ans = INF;
	rep(bit, 0, msk) {
		vector<int>v(4,0);
		vector<int>vd(4, 0);
		int temp = bit;
		rep(i, 0, n) {
			int mod = temp % 4;
			v[mod] += s[i];
			vd[mod]++;
			temp /= 4;
		}
		if (v[0] != 0 && v[1] != 0 && v[2] != 0) {
			int res = abs(a-v[0]) + abs(b-v[1]) + abs(c-v[2]);
			res += 10 * (vd[0] - 1) + 10 * (vd[1] - 1) + 10 * (vd[2] - 1);
			ans = min(ans,res);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define i64 long long
#define pii pair<i64, i64>
#define fi first
#define se second
using namespace std;

const int N = 2e5 + 10;
const i64 inf = 1e16;
int n, q, a, b, x[N];

struct node {
	i64 v, mn1, mn2, tag;
} tr[N * 4];

void build(int o, int l, int r) {
	tr[o] = (node) {inf, inf, inf, 0};
	if (l == r) return;
	int mid = l + r >> 1;
	build(o << 1, l, mid);
	build(o << 1 | 1, mid + 1, r);
}

void update(int x, i64 v) {
	tr[x].v += v, tr[x].tag += v;
	tr[x].mn1 += v, tr[x].mn2 += v;
}

void pushdown(int o) {
	if (!tr[o].tag) return;
	update(o << 1, tr[o].tag);
	update(o << 1 | 1, tr[o].tag);
	tr[o].tag = 0;
}

void modify(int o, int l, int r, int p, i64 v) {
	if (l == r) {
		tr[o].v = min(tr[o].v, v);
		tr[o].mn1 = tr[o].v - l;
		tr[o].mn2 = tr[o].v + l;
		return;
	}
	pushdown(o);
	int mid = l + r >> 1;
	if (p <= mid) modify(o << 1, l, mid, p, v);
	else modify(o << 1 | 1, mid + 1, r, p, v);
	tr[o].mn1 = min(tr[o << 1].mn1, tr[o << 1 | 1].mn1);
	tr[o].mn2 = min(tr[o << 1].mn2, tr[o << 1 | 1].mn2);
	tr[o].v = min(tr[o << 1].v, tr[o << 1 | 1].v);
}

pii query(int o, int l, int r, int x, int y) {
	if (x <= l && r <= y) return pii(tr[o].mn1, tr[o].mn2);
	pushdown(o);
	int mid = l + r >> 1;
	pii a(inf, inf), b(inf, inf);
	if (x <= mid) a = query(o << 1, l, mid, x, y);
	if (y > mid) b = query(o << 1 | 1, mid + 1, r, x, y);
	return pii(min(a.fi, b.fi), min(a.se, b.se));
}

int main() {
	scanf("%d %d %d %d", &n, &q, &a, &b);
	for (int i = 1; i <= q; ++ i) scanf("%d", &x[i]);
	x[0] = b;
	build(1, 1, n);
	modify(1, 1, n, a, 0);
	for (int i = 1; i <= q; ++ i) {
		pii t1 = query(1, 1, n, 1, x[i]);
		pii t2 = query(1, 1, n, x[i], n);
		int tp = abs(x[i] - x[i - 1]);
		tr[1].tag += tp, tr[1].v += tp;
		tr[1].mn1 += tp, tr[1].mn2 += tp;
		modify(1, 1, n, x[i - 1], t1.fi + x[i]);
		modify(1, 1, n, x[i - 1], t2.se - x[i]);
	}
	cout << tr[1].v;
	return 0;
}


Measured memory_bytes: 19456