akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	bool h=true;
	int n=s.size();
	rep(i,n-2)if(s[i]!=s[i+2])h=false;
	if(h)cout<<"Second"<<endl;
	else{
		if(s[0]!=s[n-1]){
			if(n%2)cout<<"First"<<endl;
			else cout<<"Second"<<endl;
		}else{
			if(n%2==0)cout<<"First"<<endl;
			else cout<<"Second"<<endl;		
		}
	}
}






Measured memory_bytes: 512
i = list(map(int, input().split()))
if i[0]==i[1] and i[1]!=i[2]:
    print ('Yes')
elif i[1]==i[2] and i[2]!=i[0]:
    print ('Yes')
elif i[2]==i[0] and i[0]!=i[1]:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
signed main() {
    int S;
    cin >> S;
    if(S == 1000000000000000000) {
        cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << endl;
        return 0;
    }
    cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 <<" ";
    int X = S/1000000000+1;
    int Y = X*1000000000-S;
    cout << Y << " " << X << endl;
}


Measured memory_bytes: 3608
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

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


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 0;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int gcd(int A, int B) {
	if (B == 0) return A;
	return gcd(B, A % B);
}

int main() {
	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	int B[100000];
	B[0] = A[0];
	rep1(i, N - 2) B[i] = gcd(A[i], B[i - 1]);

	int kotae = B[N - 2];
	int C = A[N - 1];
	rep1(i, N - 2) {
		kotae = max(kotae, gcd(C, B[N - 2 - i]));
		C = gcd(A[N - i - 1], C);
	}
	kotae = max(C, kotae);

	co(kotae);

	Would you please return 0;
}

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

signed main(void){
    int n,m,a,b,c;
    int ans=0;
    cin>>n;
    string s;
    cin>>s;
    rep(i,n-1){
        if(s[i]!=s[i+1])
        ans++;
    }
    cout<<ans+1<<endl;
    
}


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

using namespace std;

int main(void){
  int n,m;
  while(cin>>n>>m, n||m){
    vector<int> p(n);
    for(int i=0;i<n;++i) cin>>p[i];
    sort(p.begin(), p.end(), greater<int>());
    int sum=0,tmp=0;
    for(int i=0;i<n-(n%m);++i){
    	tmp+=p[i];
    	if(i%m==m-1){
    		sum+=tmp-p[i];
    		tmp=0;
    	}
    }
    for(int i=n-(n%m);i<n;++i)sum+=p[i];
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, f_x = 0, devide_num = 10, temp, N_copy;
  
  cin >> N;
  N_copy = N;
  
  while (true) {
    if (N / 10 == 0) {
      f_x = N;
      break;
    }
    else if (N / devide_num == 0) {
      temp = N % devide_num;
      f_x += temp / (devide_num / 10);
      N -= temp;
      devide_num *= 10;
      break;
    }
    else {
      temp = N % devide_num;
      f_x += temp / (devide_num / 10);
      N -= temp;
      devide_num *= 10;
      // cout << f_x << endl;
    }
  }
  // cout << f_x << endl;
  if (N_copy % f_x == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define REP(var, num) for(int var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;

int main() {
    sll n, max_p = 0;
    cin >> n;

    sll sum = 0;
    REP(i, n) {
        sll p;
        cin >> p;
        max_p = max(max_p, p);
        sum += p;
    }

    sum = (sum - max_p) + (max_p / 2);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        for(int i = 0; i < 5; i++) {
            int x = scan.nextInt();
            if(x == 0){
                os.println(i+1);
                return;
            }
        }
    }
}

Measured memory_bytes: 26924
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

li = list(map(int, input().split()))
N, A, B, C = li[0], li[1], li[2], li[3]
l = sorted([ int(input()) for i in range(N) ])

ans = 1e9

# 0~3のデカルト積
# 0~3の組み合わせ全部
for X in product(range(4), repeat=N):
    # [[未使用], [Aの作成に使う], [Bの作成に使う], [Cの作成に使う]]
    # 作成の際使う竹は必ず合成する
    P = [[] for _ in range(4)]
    for i, x in enumerate(X):
        P[x].append(l[i])

    # A, B, Cを合成する竹がない場合スキップ
    if min(map(len, P[1:])) == 0:
        continue

    tmp = 0
    for q, d in zip(P[1:], [A, B, C]):
        tmp += 10*(len(q)-1) + abs(d-sum(q))
    if tmp < ans:
        ans = min(tmp, ans)

print(ans)

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

long long sum = 100L;
long long x;
int t = 0;

int main()
{
	cin >> x;
	long long s;
	while(1)
	{
		s = sum / 100L;
		sum += s;
		t++;
		if(sum >= x) {cout << t; return 0;}
	}
}

Measured memory_bytes: 3620
N, M = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
rank = [0] * N
parent = [i for i in range(N)]

def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]
 
 
def same(x, y):
    return find(x) == find(y)
 
 
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
 
    if rank[x] > rank[y]:
        parent[y] = x
    else:
        parent[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


for i in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)

# 一致している個数のカウント
num = 0
for i in range(N):
    num += same(i, P[i])
print(num)

Measured memory_bytes: 13812
a=input()
b=input()
c=input()
A=a.replace('a','0').replace('b','1').replace('c','2')
list0=[]
for a in A:
    list0.append(int(a))
B=b.replace('a','0').replace('b','1').replace('c','2')
list1=[]
for b in B:
    list1.append(int(b))
C=c.replace('a','0').replace('b','1').replace('c','2')
list2=[]
for c in C:
    list2.append(int(c))
L=[list0,list1,list2]
# print(L)
# print(list0,list1,list2)

turn=0
nextturn=0

while L[turn]!=[]:
    nextturn=L[turn][0]
    L[turn]=L[turn][1:]
    turn=nextturn

ansarr=['A','B','C']
print(ansarr[turn])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}
using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()
using pi=pair<int,int>;
void chmin(int&a,int b){a=a<b?a:b;}
void chmax(int&a,int b){a=a>b?a:b;}

const int Nmax=1<<17;
const int inf=LLONG_MAX/3;
vi ch[Nmax];
int cost[Nmax];
vector<pi> res[Nmax];

void Wafrelka(vector<pi>&r){
	int n=r.size(),j=0,w=inf;
	REP(i,n)
		if(r[i].second<w){
			w=r[i].second;
			r[j++]=r[i];
		}
	r.resize(j);
}

void dfs(int v,int m){
	res[v].clear();
	if(ch[v].empty())
		return void(res[v].PB(pi(cost[v],cost[v])));
	int a=ch[v][0],b=ch[v][1];
	dfs(a,m);
	dfs(b,m);
	if(res[a].size()>res[b].size())swap(a,b);
	if(res[a].empty())return;
	int j=0;
	REP(i,res[a].size()){
		while(j<int(res[b].size())&&res[a][i].second+res[b][j].first<=m)
			j++;
		if(j-1>=0)res[v].PB(pi(res[a][i].first,res[b][j-1].second));
	}
	Wafrelka(res[v]);
	int s=res[v].size();
	REP(i,s)res[v].PB(pi(res[v][s-1-i].second,res[v][s-1-i].first));
	inplace_merge(res[v].begin(),res[v].begin()+s,res[v].end());
	Wafrelka(res[v]);
	for(auto&p:res[v])
		p.first+=cost[v],p.second+=cost[v];
}

signed main(){
	int n=read(),bot=0,top=0;
	FOR(i,1,n){
		int p=read()-1;
		cost[i]=read();
		ch[p].PB(i);
		chmax(bot,cost[i]);
		top+=cost[i];
	}
	bot--;
	while(top-bot>1){
		int const mid=(top+bot)/2;
		dfs(0,mid);
		if(!res[0].empty())
			top=mid;
		else
			bot=mid;
	}
	cout<<top<<endl;
}


Measured memory_bytes: 33544
n = gets.to_i
c = gets.chomp

count = 0

i = 0
j = n - 1

loop do
  i = c.index('W', i)
  break if i.nil?
  j = c.rindex('R', j)
  break if j.nil?
  break if j < i

  c[i], c[j] = [c[j], c[i]]
  count += 1
  i += 1
  j -= 1
end

puts count


Measured memory_bytes: 14748
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

#define MAX 1300000
bool prime[MAX];

void erat()
{
	fill(prime, prime+MAX, true);
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i < MAX; i++)
		for (int j = 2*i; j < MAX; j += i)
			prime[j] = false;
}

int solve(int n)
{
	if (prime[n]) return 0;

	int a, b;
	for (a = n-1;; a--)
		if (prime[a])
			break;
	for (b = n+1;; b++)
		if (prime[b])
			break;

	return b-a;
}

int main(void)
{
	int n;
	erat();
	while (cin >> n, n) {
		cout << solve(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 2428
n = int(input())
#nを素因数分解したリストを返す
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
a = prime_decomposition(n)
list_num=[]
for i,n in enumerate(a):
  if i ==0:
    list_num.append(n)
  if n in list_num:
    continue
  elif n not in list_num:
    list_num.append(n)
count = 0
for i in list_num:
  num = a.count(i)
  handan = True
  j = 1
  counter = 0
  while handan == True:
    num -=j
    if num<0:
      handan =False
    elif num>=0:
      counter+=1
      j+=1
  count +=counter

print(count)  

Measured memory_bytes: 9236
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void yesno(bool f) { cout << (f ? "Yes" : "No") << endl; }

//


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

	map<int, int> mp[2];

	rep (i, n)
	{
		int v;
		cin >> v;

		if ( i % 2 == 0 )
		{
			mp[0][v]++;
		}
		else
		{
			mp[1][v]++;
		}
	}

	vector<pair<int, int>> v[2];
	for ( auto &p : mp[0] )
	{
		v[0].emplace_back(p.first, p.second);
	}

	for ( auto &p : mp[1] )
	{
		v[1].emplace_back(p.first, p.second);
	}

	sort(v[0].begin(), v[0].end(),
		[](const pair<int, int>& x, const pair<int, int>& y)
		{return x.second > y.second; });

	sort(v[1].begin(), v[1].end(),
		[](const pair<int, int>& x, const pair<int, int>& y)
		{return x.second > y.second; });

	if ( v[0].size() == 1 && v[0].size() == v[1].size() &&
		 v[0][0].first == v[1][0].first )
	{
		cout << n / 2 << endl;
	}
	else if ( v[0][0].first == v[1][0].first )
	{
		int ans = 0;

		if ( v[0].size() > 1 ) ans = max(ans, v[0][1].second + v[1][0].second);
		if ( v[1].size() > 1 ) ans = max(ans, v[0][0].second + v[1][1].second);

		cout << n - ans << endl;
	}
	else
	{
		cout << n - v[0][0].second - v[1][0].second << endl;
	}

	return 0;
}


Measured memory_bytes: 6136
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, sm = INF;

  std::cin >> N;

  for (int i = 1; i < N; i ++) {
    int A = i, B = N - A, a = 0, b = 0;

    for ( ; A; A /= 10)
      a += A % 10;

    for ( ; B; B /= 10)
      b += B % 10;

    sm = std::min(a + b, sm);
  }

  std::cout << sm << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char str[21];
    scanf("%[^\n]",str);
    for(int i=0;str[i]!='\0';i++)
    {
        if(str[i]==',')printf(" ");
        else printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int p[n];
  for (int i=0; i<n; i++) cin>>p[i];
  set<int> seen;
  int cnt = 0;
  for (int i=0; i<n; i++) {
    auto it = seen.upper_bound(p[i]);
    if (it == seen.begin()) {
      ++cnt;
    }
    seen.insert(p[i]);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 10368
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_066_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 i      PIC 9(3).
    01 j      PIC 9(3).
    01 k      PIC 9(3).

    01 l      PIC 9(3).

    01 ini    PIC 9(3).

    01 S      PIC X(200).
    01 len    PIC 9(3).
    01 ans    PIC X(3).
    01 flg    PIC 9(1).

    01 len2   PIC 9(3).

    01 ZS     PIC Z(4).
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT S.

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(S).
    SUBTRACT 1 FROM len GIVING l.

    PERFORM VARYING i FROM l BY -1 UNTIL i = 1
        MOVE 1 TO FLG

        IF FUNCTION MOD(i, 2) = 1 THEN
            MOVE 0 TO flg
        ELSE
            MOVE i TO k
            DIVIDE 2 INTO k GIVING ini
            MOVE ini TO len2
            ADD 1 TO ini

            IF S(1:len2) NOT = S(ini:len2) THEN
                MOVE 0 TO flg
            END-IF
        END-IF

        IF flg = 1 THEN
            EXIT PERFORM
        END-IF
    END-PERFORM.

    MOVE i TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
 
/*--------------------template--------------------*/
 
 
 
 
int main() {
    cin >> n;
    while (1) {
        ans = pow(k, 2);
        if (ans > n) {
            break;
        }
        k++;
    }
    cout << (ll)pow(k - 1, 2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define test int t;cin>>t;while(t--)
void fastcode()
{
    /*
    cout<<fixed<<setprecision(2);
    π = 3.141592653;
    itoa to convert any system itoa(n,bin,2)
    */
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    /*freopen(" ","r",stdin);
    freopen(" ","w",stdout);*/
    fastcode();
    int n;
    cin>>n;
    if(n<30)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    return 0;
}


Measured memory_bytes: 3604
import functools
def slove(s_list):
    char_list = sorted(functools.reduce(set.intersection,
                                        [set(i) for i in s_list]))
    ans = ""
    for c in char_list:
        wc = 51
        for s in s_list:
            wc = min(wc, s.count(c))
        ans += c*wc
    return ans

if __name__ == "__main__":
    n = int(input())
    s = [input() for i in range(n)]
    print(slove(s))


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int g = scan.nextInt();
		int b = scan.nextInt();
		System.out.println((r * 100 + g * 10 + b) % 4 == 0 ? "YES" : "NO");
		scan.close();

	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<queue>
#define sqr(x) (x)*(x)
using namespace std;
long long mod=1e9+7,n,m,i,j,dis1[100005],dis2[100005],dp1[100005],dp2[100005],s,t,y,x,z,ans;
vector<pair<long long,long long> > e[100005];
int main()
{
	cin>>n>>m>>s>>t;
	while (m--)
	{
		cin>>y>>x>>z;
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,z));
	}
	{
		priority_queue<pair<long long,long long> > pq;
		pq.push(make_pair(-0,s));
		memset(dp1,0,sizeof(dp1));
		memset(dis1,22,sizeof(dis1)); 
		dis1[s]=0;
		dp1[s]=1;
		while (!pq.empty())
		{
			x=pq.top().second;pq.pop();
			for (i=0;i<e[x].size();i++)
			{
				if (dis1[e[x][i].first]>dis1[x]+e[x][i].second)
				{
					dis1[e[x][i].first]=dis1[x]+e[x][i].second;
					pq.push(make_pair(-dis1[e[x][i].first],e[x][i].first));
				}
			}
		}
	}
	{
		priority_queue<pair<long long,long long> > pq;
		pq.push(make_pair(-0,t));
		memset(dp2,0,sizeof(dp2));
		memset(dis2,22,sizeof(dis2)); 
		dis2[t]=0;
		dp2[t]=1;
		while (!pq.empty())
		{
			x=pq.top().second;pq.pop();
			for (i=0;i<e[x].size();i++)
			{
				if (dis2[e[x][i].first]>dis2[x]+e[x][i].second)
				{
					dis2[e[x][i].first]=dis2[x]+e[x][i].second;
					pq.push(make_pair(-dis2[e[x][i].first],e[x][i].first));
				}
			}
		}
	}
	{
		priority_queue<pair<long long,long long> > pq;
		memset(dp1,0,sizeof(dp1));
		dp1[s]=1;
		for (i=1;i<=n;i++) pq.push(make_pair(-dis1[i],i));
		while (!pq.empty())
		{
			x=pq.top().second;pq.pop();
			for (i=0;i<e[x].size();i++)
			{
				if (dis1[e[x][i].first]==dis1[x]+e[x][i].second)
				{
					dp1[e[x][i].first]+=dp1[x];
					dp1[e[x][i].first]%=mod;
				}
			}
		}
	}
	{
		priority_queue<pair<long long,long long> > pq;
		memset(dp2,0,sizeof(dp2));
		dp2[t]=1;
		for (i=1;i<=n;i++) pq.push(make_pair(-dis2[i],i));
		while (!pq.empty())
		{
			x=pq.top().second;pq.pop();
			for (i=0;i<e[x].size();i++)
			{
				if (dis2[e[x][i].first]==dis2[x]+e[x][i].second)
				{
					dp2[e[x][i].first]+=dp2[x];
					dp2[e[x][i].first]%=mod;
				}
			}
		}
	}
	ans=dp1[t]*dp1[t]%mod;
	for (i=1;i<=n;i++)
	{
		if (dis1[i]==dis2[i]&&dis1[i]+dis2[i]==dis1[t]) (ans-=dp1[i]*dp2[i]%mod*dp1[i]%mod*dp2[i]%mod)%=mod;
		for (j=0;j<e[i].size();j++)
		{
			if (dis1[i]+e[i][j].second+dis2[e[i][j].first]==dis1[t])
			{
				//cerr<<e[i][j].first<<endl;
				int x=e[i][j].first;
				if (dis1[i]*2<dis1[t]&&dis1[x]*2>dis1[t])
				{
					//cerr<<i<<' '<<x<<endl;
					(ans-=dp1[i]*dp2[e[i][j].first]%mod*dp1[i]%mod*dp2[e[i][j].first]%mod)%=mod;
				}
			}
		}
	}
	cout<<(ans%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 20152
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[200005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n = strlen(str);

    ll ans=0;
    int i;
    int cnt=0;   // count a
    for(i=1; i<n; i++) {
        if(cnt>0 && str[i-1]=='B' && str[i]=='C') {
            ans += cnt;
            i++;
        }
        else if(str[i-1]=='A') {
            cnt++;
        }
        else {
            cnt=0;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>      /* printf */
#include <math.h>       /* sqrt */

using namespace std;

int main ()
{
  long long N;
  cin >> N;
  
  long long limit = sqrt(N);
  long long ans = 0;
  for (long long i = 0; i < limit; i++) {
    if (N % (limit - i) == 0) {
      ans = (limit - i) + N / (limit - i) - 2;
      break;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define all(_v) _v.begin(), _v.end()
#define ll long long

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k;
	cin >> k;
	ll ans = 0;
	for(int i = 1; i <= k; ++i) {
        for(int j = 1; j <= k; ++j) {
            for(int z = 1; z <= k; ++z) {
                ans += __gcd(__gcd(i, j), z);
            }
        }
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=1LL;
	cin >>n;
	V t(n);
	rep(i,n){
		cin>>t[i];
		ans*=t[i]/__gcd(ans,t[i]);
	}

		cout<<ans<<endl;
}

Measured memory_bytes: 384
#!/usr/bin/env php
<?php
function solve(int $a, int $b)
{
    if (($a * $b) % 2) {
        echo "Odd".PHP_EOL;
    } else {
        echo "Even".PHP_EOL;
    }
}

$inputs = [];
while (($item = fgets(STDIN)) !== false) {
    $inputs = array_merge($inputs, explode(' ', $item));
}
$a = (int)array_shift($inputs);
$b = (int)array_shift($inputs);
solve($a, $b);



Measured memory_bytes: 4856
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    x, y = s[:i], s[i:]
    setX = set()
    setY = set()
    for a in x:
        setX.add(a)
    for b in y:
        setY.add(b)
    z = setX & setY
    ans = max(ans, len(z))

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
  long n,a,b ;
  cin >> n >> a >> b;
  
  long div,r;
  div = n/(a+b) ;
  r = n%(a+b);
  long ans = div*a+min(r,a);
  
  cout << ans << endl ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (1<<18);
typedef long long ll;
struct seg {
  int n;
  ll dat[2*MAX_N-1];

public:
  void init(int _n = MAX_N){
    n = 1;
    while(n < _n) n *= 2;
  }


  ll get(int k){
    k += n - 1;
    ll res = dat[k];
    while(k > 0){
      k = (k - 1) / 2;
      res += dat[k];
    }
    return res;
  }

  void add(int a, int b, ll x){ add(a, b, x, 0, 0, n);}
  void add(int a, int b, ll x, int k, int l, int r){
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) dat[k] += x;
    else{
      add(a, b, x, k*2+1, l, (l+r)/2);
      add(a, b, x, k*2+2, (l+r)/2, r);
    }
  }
};

int N,Q;
ll S,T;
seg Seg;

ll ch( ll sa ){
  if( sa >0 ) return -sa*S;
  else return -sa*T;
}

int main(){
  cin >> N >> Q >> S >> T;

  Seg.init(N+1);

  ll res = 0LL;
  ll pv; cin >> pv;
  for(int i=1;i<=N;i++){
    ll a; cin >> a;
    Seg.add(i,i+1,a);
    res += ch(a-pv);
    pv = a;
  }
  for(int i=0;i<Q;i++){
    int l,r; ll x;
    cin >> l >> r >> x;
    ll ms1 = Seg.get(l) - Seg.get(l-1);
    ll ms2 = r==N?0:Seg.get(r+1) - Seg.get(r);
    res -= ch(ms1);
    res -= ch(ms2);
    Seg.add( l, r+1, x );
    ll ns1 = Seg.get(l) - Seg.get(l-1);
    ll ns2 = r==N?0:Seg.get(r+1) - Seg.get(r);
    res += ch(ns1);
    res += ch(ns2);
    cout << res << endl;
  }
}

Measured memory_bytes: 6236
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 基本的な演算
namespace BasicMath {
    // 二つの値の最小値を求める関数
    static Int Min(const Int a, const Int b);
    // 二つの値の最大値を求める関数
    static Int Max(const Int a, const Int b);
    // 二つの値の最大値を求める関数
    Int Max(const Int a, const Int b) {
        if (a >= b) {
            return a;
        } else {
            return b;
        }
    }
    // 二つの値の最小値を求める関数
    Int Min(const Int a, const Int b) {
        if (a <= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;

int main(void) {
    Int n, k;
    cin >> n >> k;
    VI h(n);
    for (Int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    Int result = INT_MAX;
    for (Int i = 0; i <= n - k; ++i) {
        result = Min(result, h[i + k - 1] - h[i]);
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3908
#include<bits/stdc++.h>
#define ll long long
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
#define mod 1000000007
#define inf (1ll<<60)
using namespace std;


int main()
{
    iof;
    ll n,w; cin>>n>>w;
    vector<pair<ll,ll> >v;
    for(ll i=0;i<n;i++)
    {
        ll x,y; cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    ll dp[n+1][w+1];
    for(ll i=0;i<=n;i++)
        for(ll j=0;j<=w;j++)
            dp[i][j]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(j<v[i-1].first)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i-1].first]+v[i-1].second);
        }
    }
    cout<<dp[n][w];
}


Measured memory_bytes: 79232
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

import heapq
n, m = getList()

nums = getList()

h = []
for num in nums:
    heapq.heappush(h, -num)

for i in range(m):
    cur = heapq.heappop(h)
    # print(cur, h)
    cur = cur / 2
    heapq.heappush(h, cur)
#
# print(h)
ans = 0

for num in h:
    ans += -num // 1
    # print(ans)

print(int(ans))

Measured memory_bytes: 83480
Month = [0,31,29,31,30,31,30,31,31,30,31,30,31]
Week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while (mon, day = gets.split(" ").map(&:to_i)) != [0,0]
  puts Week[(day + Month[0..(mon - 1)].inject{|sum,i|sum + i} + 2) % 7]
end

Measured memory_bytes: 6100
import java.util.Scanner;

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

        int total = 0;
        for (int i = 105; i <= n; i += 2) {
            int count = 0;
            for (int j = 1; j <= n; j++) {
                if (i % j == 0) count++;
            }
            
            if (count == 8) total++;
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 23380
N, M = map(int, input().split())
s = set()
t = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s.add(b)
    elif b == N:
        t.add(a)

if len(s & t) >= 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 19024
X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
AB=[0]*(X*Y)
t=0
for i in A:
 for j in B:
  AB[t]=i+j
  t+=1
AB.sort(reverse=True)
ABA=AB[0:min(K,X*Y)]
D=[0]*(Z*len(ABA))
t=0
for i in ABA:
 for j in C:
  D[t]=i+j
  t+=1
D.sort(reverse=True)
for i in range(K):
 print(D[i])


Measured memory_bytes: 98572
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91
#include <array>
#include <map>
#include <string>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  bool f = true;
  for (const usize i : rep(0, n)) {
    const u32 a = scan<u32>();
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
      f = false;
  }
  std::cout << (f ? "APPROVED" : "DENIED") << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mo 1000000007
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

ll comb(ll N_, ll C_) {
	const int NUM_ = 4000001;
	static ll fact[4000002], factr[4000002], inv[4000002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mo, factr[i] = factr[i - 1] * inv[i] % mo;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mo*factr[N_ - C_] % mo;
}
ll modpow(ll a, ll n = mo - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a%mo, n >>= 1;
	return r;
}

int g(int a, int b) {
	return comb(a + b + 2, a + 1) - 1;
}






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

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	A--;
	B--;

	cout << (g(C, D) - g(A, D) - g(C, B) + g(A, B) + mod) % mod << endl;
	

	return 0;
}



Measured memory_bytes: 93952
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<functional>
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(c.begin(),c.end()),c.end())
#define pb push_back
using namespace std;
int n;
string plszero(string s){
	for(;(int)s.size()!=n;){
		s="0"+s;
	}
	//cout<<n<<"   "<<s.size()<<endl;
	return s;
}
string itos(int x){
	string s;
	while(x){
		s=(char)((x%10)+'0')+s;
		x/=10;
	}
	return s;
}
int num(string s){
	int ret=0;
	int l=s.size();
	for(int i=0;i<l;i++){
		ret*=10;
		ret+=s[i]-'0';
	}
	return ret;
}
int main(){
	string s;
	int count=1;
	while(cin>>s>>n,s!="0"||n){
		s=plszero(s);
		int cnt=1;
		map<string,int> mp;
		mp.clear();
		do{
			mp[s]=cnt++;
			string a=s,b=s;
			sort(all(a));
			sort(all(b),greater<char>());
			int x=atoi(b.c_str())-atoi(a.c_str());
			string t=itos(x);
			t=plszero(t);
			//cout<<"      "<<a<<" "<<b<<endl;
			if(mp[t]){
				cout<<mp[t]-1<<" "<<atoi(t.c_str())<<" "<<cnt-mp[t]<<endl;
				break;
			}
			//cout<<t<<endl;
			s=t;
		}while(1);
		//cout<<count++<<endl;
	}
	return 0;
}

Measured memory_bytes: 1252
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]++;
    int mx = 0;
    int s = 0;
    queue<int> q;
    rep(i, n){
        s += p[i];
        q.push(p[i]);
        if(q.size() > k){
            s -= q.front();
            q.pop();
        }
        if(q.size() == k){
            mx = max(mx, s);
        }
    }
    double ans = mx;
    ans /= 2;
    printf("%.10lf\n", ans);
    return 0;
}

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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    int ret = X, A;
    for (int i = 0; i<N; i++) {
        cin >> A;
        ret += int((D-1)/A) + 1;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
const ll MAX = 2*(ll)pow(10, 5);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s; cin >> s;
  bool flag = 1;
  rep(i, s.size()-1) {
    if (s.at(i) == s.at(i+1)) {
      cout << i+1 << ' ' << i+2 << endl;
      flag = 0;
      break;
    }
  }
  if (flag) {
    rep(i, s.size()-2) {
      if (s.at(i) == s.at(i+2)) {
        cout << i+1 << ' ' << i+3 << endl;
        flag = 0;
        break;
      }
    }
  }
  if (flag) cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,k; cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  vector<bool> ten(n-1);
  rep(i,n-1){
    if(p[i]>p[i+1]) ten[i]=1;
  }
  vector<int> sten(n);
  rep(i,n-1) sten[i+1]=sten[i]+ten[i];
  set<int> tenst;
  bool noten=0;
  rep(i,k){
    tenst.insert(p[i]);
  }
  int ans=1;
  if(sten[k-1]-sten[0]==0){
    noten=1;
    ans=0;
  }
  for(int i=1;i<n-k+1;i++){
    bool henka=0;
    if(*begin(tenst)!=p[i-1]){
      henka=1;
    }
    tenst.erase(p[i-1]);
    tenst.insert(p[i+k-1]);
    if(*rbegin(tenst)!=p[i+k-1]){
      henka=1;
    }
    if(sten[i+k-1]-sten[i]&&henka) ans++;
    if(sten[i+k-1]-sten[i]==0) noten=1;
  }
  if(noten) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 14280
L, R = map(int, input().split())

if R - L + 1 >= 673:
    print(0)
else:
    mini = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            mini = min(mini, (i*j) % 2019)
    print(mini)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	vector<int > v;
	int a[2000*20+1];
	int sum = 0;
	memset(a,0,sizeof(a));
	cin >> n;

	for(int i = 0;i<n;i++){
		int k;
		cin >> k;
		sum +=k;
		v.push_back(k);
	}
	for(int i = 0;i<(1<<n);i++){
		int total = 0;
		for(int j = 0;j<n;j++){
			if(i & (1<<j)) total += v[j];
		}
		a[total] = 1;
	}
	cin >> m;

	for(int i = 0 ;i < m; i++){
		int k;
		cin >> k;
		if(a[k] == 1) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 1372
import java . util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int number = input.nextInt();
        int sum = 0;
        for (int i = 1; i <= number; i++) {
            sum =sum+i;
        }
         System.out.println(sum);
            
        }
        } 
                

Measured memory_bytes: 27088
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

string S;
int N;
ll m, a, r, c, h;
ll D[5];

int P[10] = {0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
int Q[10] = {1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
int R[10] = {2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};

int main(){


    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S;
        if(S[0] == 'M') m++;
        else if(S[0] == 'A') a++;
        else if(S[0] == 'R') r++;
        else if(S[0] == 'C') c++;
        else if(S[0] == 'H') h++;
    }

    D[0] = m;
    D[1] = a;
    D[2] = r;
    D[3] = c;
    D[4] = h;

    ll ans = 0;

    for(int i = 0; i < 10; i++) ans += D[ P[i] ] * D[ Q[i] ] * D[ R[i] ];

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int size = 1e3+100;


int main()
{	
	ios_base::sync_with_stdio(0);
	int x=0,y=0,t=0;	
	int n;
	cin >> n;
	bool check=1;
	while(n--)
	{
		int tt,xt,yt;
		cin >> tt >> xt >> yt;
		t=tt-t;
		t-=abs(x-xt)+abs(y-yt);
		if(t<0||t%2)
			check=0;
		x=xt;
		y=yt;
		t=tt;
	}
	if(check)
		cout <<"Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  ll ans = 1;
  REP(i, 1, N+1) {
    ans = ans * i % kMod;
  }
  cout << ans % kMod << endl;

  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
mini=h*w
for i in range(1,h):
    if mini > max(w*(h-i),(w//2+w%2)*i) - min(w*(h-i),(w//2)*i):
        mini = max(w*(h-i),(w//2+w%2)*i) - min(w*(h-i),(w//2)*i)

for i in range(1,w):
    if mini > max(h*(w-i),(h//2+h%2)*i) - min(h*(w-i),(h//2)*i):
        mini = max(h*(w-i),(h//2+h%2)*i) - min(h*(w-i),(h//2)*i)

if h%3 == 0 or w%3 == 0:
    mini=0
else:
    if mini > h:
        mini = h
    elif mini > w:
        mini = w
    else:
        pass
print(mini)

Measured memory_bytes: 3064
import fractions

def return_prime(aa):
    a_list = [1]
    for i in range(2, int(aa ** 0.5) + 2):
        while aa % i == 0:
            a_list.append(i)
            aa = aa // i
    if aa != 1:
        a_list.append(aa)
    return a_list

a, b = map(int, input().split())
a_list = return_prime(fractions.gcd(a, b))
print(len(set(a_list)))

Measured memory_bytes: 5048
H,W = map(int,input().split())
A = []
for i in range(H):
    A.append(list(map(int,input().split())))
ans = []
for h in range(H):
    for w in range(W):
        if A[h][w]%2 == 0:
            continue
        h1 = h
        w1 = w
        if w == W-1:
            if h != H-1:
                w2 = w
                h2 = h+1
                A[h2][w2] += 1
                
            else:
                break
        else:
            w2 = w+1
            h2 = h
            A[h2][w2] += 1
        ans.append([h1+1,w1+1,h2+1,w2+1])
print(len(ans))
for i in ans:
    print(*i)


Measured memory_bytes: 30268
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



int main() {
	ll x,y,s=0,t=0,ans=1,mod=1000000007,cnt=0,a,b;
	bool flg = true;
	in(x);
	in(y);
	if ((x + y) % 3 != 0) {
		outn(0);
		return 0;
	}
	if (x < y) {
		a = x;
		x = y;
		y = a;
	}
	
	while (x>s&&y>t) {
		if ((x - s) / 1 == (y - t) / 2) {
			a = s / 2;
			b = x - s;
			flg = false;
			break;
		}
		s += 2;
		t += 1;
	}
	if (flg) {
		if (x == s) {
			a = 0;
			b = x - s;
		}
		else {
			outn(0);
			return 0;
		}
	}

	s = 1;
	t = 1;
	ll j = 1;
	repeq(i, 1, a) {
		j++;
	}
	repeq(i, 1, b) {
		t *= modinv(i,mod);
		t %= mod;
		s *= j;
		s %= mod;
		j++;
	}

	outn((s*t)%mod);

	return 0;



}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */


int main() {
  
  int n, q; cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(ALL(a));

  for (int i = 0; i < q; i++) {
    int l, r; cin >> l >> r;
    auto x = upper_bound(a.begin(), a.end(), r);
    auto y = lower_bound(a.begin(), a.end(), l);
    cout << x - y << endl;
 
  }
  return 0;
}



Measured memory_bytes: 3096