akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
void __dump(int x){cerr << x;}
void __dump(long long x){cerr << x;}
void __dump(long double x){cerr << fixed << setprecision(3) << x;}
void __dump(char x){cerr << '\'' << x << '\'';}
void __dump(const string &x){cerr << '"' << x << '"';}
void __dump(const char *x){cerr << '"' << x << '"';}
void __dump(bool x){cerr << (x ? "true" : "false");}
void _dump(){cerr << "\n";}
template <typename T, typename U> void __dump(const pair<T, U> &x){cerr << '{'; __dump(x.first); cerr << ','; __dump(x.second); cerr << '}';}
template <typename T, typename U, typename V> void __dump(const tuple<T, U, V> &x){cerr << '{'; __dump(get<0>(x)); cerr << ',';  __dump(get<1>(x)); cerr << ',';  __dump(get<2>(x)); cerr << '}';}
template <typename T> void __dump(const T& x){int f=0; cerr << '{'; for(auto&i:x) cerr << (f++ ? "," : ""), __dump(i); cerr << "}";}
template <typename T, typename ... U> void _dump(T t, U ... u){__dump(t); if(sizeof...(u)) cerr << ", "; _dump(u...);}
#ifdef ilyes
	#define dump(x ...) cerr  <<  "|dumping| "  <<  # x  <<  "  =  ", _dump(x) 
#else
	#define dump(...) 1998
#endif
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define pii pair<int,int>
const int INF = 1e9;
const int N = -1;

struct Trie{
	map<char,Trie*> child; bool en = false; int h = 0;
	void addWord(const string& _word){
		Trie* cur = this;
		for(int i=0; i<=size(_word)-1; ++i){
			Trie* nxt = (*cur).child[_word[i]];
			if(!nxt){
				nxt = new Trie();
				(*nxt).h = (*cur).h + 1;
				(*cur).child[_word[i]] = nxt;
			}
			cur = nxt;
		}
		(*cur).en = true;
	}
	bool hasWord(const string& _word){
		Trie* cur = this;
		for(int i=0; i<=size(_word)-1; ++i){
			Trie* nxt = (*cur).child[_word[i]];
			if(!nxt) return false;
			cur = nxt;
		}
		return (*cur).en;
	}
	void explore(vector<int>& vect){
		if(size(child) == 1) vect.emplace_back(h);
		if(child['0'] != nullptr) (*child['0']).explore(vect);
		if(child['1'] != nullptr) (*child['1']).explore(vect);
	}
};

int n;
LL l;
Trie* root = new Trie();

int main(){ FAST
	cin >> n >> l;
	for(int i=1; i<=n; ++i){
		string ss; cin >> ss;
		(*root).addWord(ss);
	}
	
	vector<int> vect;
	(*root).explore(vect);
	// dump(vect);
	LL xr = 0;
	for(int hh: vect) if(l - hh >= 1) xr ^= (1LL << __builtin_ctzll(l - hh));

	if(xr > 0) cout << "Alice" << ln;
	else cout << "Bob" << ln;
}

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


int main(){
	int A, B;
	cin >> A >> B;
	cout << A*B + 1 - A - B << endl;
	return 0;
}












Measured memory_bytes: 3636
n,m=map(int,input().split())
a=list(map(int,input().split()))
sort=sorted(a,reverse=True)
b=sum(a)
count=0

for i in sort:
  if i>=b/(4*m):
    count+=1

if count>=m:
  print('Yes')
else:
  print('No')
  

       

Measured memory_bytes: 9180
N, K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
h = sorted(h)

min_diff = 1000000000
for i in range(N - K + 1):
    diff = h[i + K - 1] - h[i]
    if min_diff > diff:
        min_diff = diff
print(min_diff)

Measured memory_bytes: 8280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
 
    sort(all(a));
    sort(all(c));
 
    ll ans=0;
    rep(i,n){
        ll x=lower_bound(all(a),b[i])-a.begin();
        ll y=c.end()-upper_bound(all(c),b[i]);
        ans+=x*y;
    }
 
    cout<<ans<<endl;
}

Measured memory_bytes: 5620
#include<stdio.h>

int main(void){
  int N;
  int K;
  int i;
  int val = 1;

  scanf("%d",&N);
  scanf("%d",&K);
  
  for(i=1; i<=N; i++){
    if(val <= K){
      val *= 2;
    }else{
      val += K;
    }
  }
  printf("%d\n", val);
  
  return 0;
}


Measured memory_bytes: 128
def solve():
    n = int(input())
    a = []
    for i in range(n):
        key, value = input().split()
        value = -int(value)
        a.append([key, value, i + 1])
    a.sort()
    for i in a:
        print(i[2])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
int inp[100000];
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&inp[i]);
	sort(inp,inp+n);
	for(int i=0,cnt;i<n;i++)
	{
		cnt=1;
		while(inp[i]==inp[i+1])
		{
			cnt++;
			i++;
		}
		if(inp[i]<=cnt) ans+=cnt-inp[i];
		else ans+=cnt;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 5000

using namespace std;

int n;
int R[2][N], G[2][N], B[2][N];
char s[N];

int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i) {
        R[0][i] = R[0][i - 1] + (s[i] == 'R');
        G[0][i] = G[0][i - 1] + (s[i] == 'G');
        B[0][i] = B[0][i - 1] + (s[i] == 'B');
    }
    for (int i = n; i >= 1; --i) {
        R[1][i] = R[1][i + 1] + (s[i] == 'R');
        G[1][i] = G[1][i + 1] + (s[i] == 'G');
        B[1][i] = B[1][i + 1] + (s[i] == 'B');
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R') {
            ans += G[0][i - 1] * B[1][i + 1];
            ans += G[1][i + 1] * B[0][i - 1];
        } else if (s[i] == 'G') {
            ans += R[0][i - 1] * B[1][i + 1];
            ans += R[1][i + 1] * B[0][i - 1];
        } else if (s[i] == 'B') {
            ans += R[0][i - 1] * G[1][i + 1];
            ans += R[1][i + 1] * G[0][i - 1];
        }
    }
    for (int len = 1; len <= n; ++len) {
        for (int i = 1; i <= n; ++i) {
            if (i - len < 1)
                continue;
            if (i + len > n)
                continue;
            ans -= (s[i - len] != s[i] && s[i + len] != s[i] && s[i - len] != s[i + len]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3948
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    char c[4];
    cin >> c[0] >> c[1] >> c[2] >> c[3];
    int flag = 0;
    for (int i = 1; i < 4; i++)
    {
        if(c[i] == c[i-1]){
            flag = 1; 
            break;
        }
    }
    if(flag==1) printf("Bad\n");
    else printf("Good\n");

    return 0;
    
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

K = INT()

cur = 7
for i in range(1, K+1):
    cur %= K
    if cur == 0:
        print(i)
        break
    cur *= 10
    cur += 7
else:
    print(-1)


Measured memory_bytes: 9468
#define _USE_MATH_DEFINES

#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>
#include <cmath>
#include <iomanip>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Itr>
	void PrintLine(Itr begin, Itr end)
	{
		bool first = true;

		for (int i = 0; begin != end; ++begin, ++i)
		{
			if (!first)
			{
				std::cout << ' ';
			}

			std::cout << (*begin);

			first = false;
		}
		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	const int kNil = -1;

	struct Node
	{
		int parent;
		int left;
		int right;

		Node()
			: parent(kNil)
			, left(kNil)
			, right(kNil)
		{}
	};

	Node node[25];

	std::vector<int> pre;
	std::vector<int> in;
	std::vector<int> post;

	void Construction(int left, int right)
	{
		if (right <= left)
			return;

		static int pos = 0;

		int root = pre[pos];
		++pos;

		int middle = std::distance(in.begin(), find(in.begin(), in.end(), root));

		Construction(left, middle);
		Construction(middle + 1, right);

		post.push_back(root);
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int num = GetValue<1>(stream)[0];
	pre = GetValue(stream, num, ' ');
	in = GetValue(stream, num, ' ');

	Construction(0, pre.size());

	bool first = true;
	for (int e : post)
	{
		if (!first)
		{
			std::cout << ' ';
		}

		first = false;
		
		std::cout << e;
	}

	std::cout << std::endl;
}



Measured memory_bytes: 3192
while(True):
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        if i%2:
            for j in range(W):
                if j%2:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
        else:
            for j in range(W):
                if j%2:
                    print('.',end='')
                else:
                    print('#',end='')
            print()
    print()




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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;

    if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h> 
using namespace std;
typedef vector<int> int_vector;
typedef vector<long> long_vector;
typedef vector< vector<int> > int_matrix;
typedef vector<string> string_vector;
typedef vector< vector<string> > string_matrix;

int main(){
    long h=0;
    cin >> h;
    long cnt = pow(2, floor(log2(h)));
    cout << cnt + cnt-1 << endl;
}

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

void swapp(int y[],int u, int k){

    int temp=y[u];
        y[u]=y[k];
        y[k]=temp;


}

int main(){
    int y,juml=0;
    scanf("%d",&y);
    int *p=new int[y];
    for(int i=0;i<y;i++){
        scanf("%d",&p[i]);
    }

    for(int u=0;u<y-1;u++){
        int minim=u;
        for(int k=u+1;k<y;k++){
            if(p[k]<p[minim])
            minim=k;
   }

        if(p[minim]<p[u])
        {
            swapp(p,u,minim);
        juml++;
        }

    }

    for(int r=0;r<y;r++){
        
           if( r ) printf(" ");
        printf("%d", p[r]);
       
    }
    cout<<"\n"<<juml<<"\n";
}



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

int N,M,Q;
vector<int> a(50),b(50),c(50),d(50);
long long ans=0;
vector<int> A;

void DFS(int pos,int x){
	if(pos==N){
		long long tmp=0;
		for(int i=0;i<Q;i++){
			if(A[b[i]-1]-A[a[i]-1]==c[i])tmp+=d[i];
		}
		ans=max(ans,tmp);
	}
	else{
		for(int i=x;i<=M;i++){
			A.push_back(i);
			DFS(pos+1,i);
		}
	}
	A.erase(A.begin()+pos-1);
}

int main(){
	cin >> N >> M >> Q;
	for(int i=0;i<Q;i++)cin >> a[i] >> b[i] >> c[i] >> d[i];
	
	A.push_back(1);
	DFS(1,1);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_table(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

class Bit:
    def __init__(self, n, default=0):
        self.size = n
        self.tree = [default] * (n + 1)

    # get sum of [0, i]
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i = max(i, 1)
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # get sum of [l, r], or just l
    def get(self, l, r=None):
        if r is None: r = l
        return self.sum(r) - self.sum(l-1)

class ExBIT:
    def __init__(self, n):
        self.p = Bit(n + 1)
        self.q = Bit(n + 1)

    # add x to [l, r] (not [l, r)])
    def add(self, x, l, r=None):
        if r is None: r = l
        r += 1
        self.p.add(l, -x * l)
        self.p.add(r, x * r)
        self.q.add(l, x)
        self.q.add(r, -x)

    def sum(self, l, r):
        r += 1
        return self.p.sum(r) + self.q.sum(r) * r - self.p.sum(l) - self.q.sum(l) * l

    def get(self, l, r=None):
        if r is None: r = l
        return self.sum(l, r)

def main():
    N, D, A = LI()
    XH = sorted(LIR(N), key=lambda x: x[0])
    X = [xi for xi, _ in XH]
    bit = ExBIT(N)

    for i in range(N):
        _, hi = XH[i]
        bit.add(math.ceil(hi / A), i)

    ans = 0

    for i, (xi, hi) in enumerate(XH):
        right = bisect_right(X, xi + 2 * D) - 1
        cnt = bit.get(i)
        if cnt > 0:
            bit.add(-cnt, i, right)
            ans += cnt

    print(ans)



if __name__ == '__main__':
    main()

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

using namespace std;
using LL = long long;

const LL INF = 1L << 61;

int main() {
    LL N, W, v[40]{0}, w[40]{0};
    cin >> N >> W;

    for (int i = 0; i < N; i++) {
        cin >> v[i];
        cin >> w[i];
    }

    LL n2 = N / 2;
    vector<pair<LL, LL>> P; //重さ, 価値

    for (int i = 0; i < 1 << n2; i++) {
        LL v1 = 0, w1 = 0;
        for (int j = 0; j < n2; j++) {
            if (i >> j & 1) {
                v1 += v[j];
                w1 += w[j];
            }
        }
        P.emplace_back(w1, v1);
    }

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

    int k = 1;
    for (int i = 0; i < 1 << n2; i++) {
        if (P[k - 1].second < P[i].second) {
            P[k++] = P[i];
        }
    }

    LL ans = 0;

    for (int i = 0; i < 1 << (N - n2); i++) {
        LL v1 = 0, w1 = 0;
        for (int j = 0; j < N - n2; j++) {
            if (i >> j & 1) {
                v1 += v[n2 + j];
                w1 += w[n2 + j];
            }
        }
        if (w1 <= W) {
            LL v2 = (lower_bound(P.begin(), P.begin() + k, make_pair(W - w1, INF)) - 1)->second;
            ans = max(ans, v1 + v2);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 19464
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++){
    cin >> a[i];
  }
  int ret = 1000000000;
  for(int i = -100; 100 >= i; i++){
    int tmp = 0;
    for(int j = 0; n > j; j++){
      tmp += (a[j]-i)*(a[j]-i);
    }
    ret = min(tmp,ret);
  }
  cout << ret << endl;
}

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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}




void solve(){
	
	int n;
	cin>>n;
	
	vector<int>vec(n);
	for(int i=0;i<n;i++) cin>>vec[i];
	
	vector<int>v;
	v.pb(vec[0]);
	for(int i=1;i<n;i++){
		if(vec[i]!=vec[i-1]) v.pb(vec[i]);
	}
	v.pb(v.back()-1);
	
	ll money=1000;
	int minVal=v[0];
	
	for(int i=1;i<=v.size();i++){
		if(v[i-1]>v[i] && v[i+1]>v[i]){
			minVal=v[i];
		}
		if(v[i-1]<v[i] && v[i+1]<v[i]){
			money+=(ll)(v[i]-minVal)*(money/minVal);
		}
	}
	
	cout<<money<<endl;
}

int main(){
	
	fastio();

	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case #"<<tt+1<<": ";solve();
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
 
int main() {
	vector<int> c;
  	c.pb(1);
  	int n = 6;
  	for (int i = 1; i <= 7; i++) {
      c.pb(n);
      n*=6;
    }
  	n = 9;
  	for (int i = 1; i <= 6; i++) {
      c.pb(n);
      n*=9;
    }
  	cin >> n;
  	int dp[n+1];
  	for (int i = 0; i <= n; i++) dp[i] = INT_MAX;
  	dp[0] = 0;	
  	for (int i = 1; i <= n; i++) {
    	for (int j = 0; j < c.size(); j++) {
        	if (i >= c[j] && dp[i-c[j]] != INT_MAX && dp[i - c[j]] + 1 < dp[i]) {
            	dp[i] = dp[i - c[j]] + 1;
            }
        }
    }
  	cout << dp[n] << endl;
  	return 0;
}

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

const ll INF = 1LL << 60;

ll N, M;
vector<P> v;
int main() {
    cin >> N >> M;
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        v.push_back(P(b, a));
    }

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

    // first: right
    // second: left

    // 重なる辺
    ll ans = 1;
    ll pos = v[0].first;

    for (int i = 1; i < M; i++) {
        // cout << v[i].second + 1 << " " << v[i].first + 1 << endl;
        if (v[i].second < pos) {
            continue;
        }

        pos = v[i].first; 
        ans++;
    }

    cout << ans << endl;
}

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

int main() {
  int N, M;
  int WA[100001];
  int scr=0, pnl=0;
  cin >>N >>M;
  vector<int> res(N);
  for(int i=0; i<N; i++){
    WA[i]=0;
  }
  for ( int i = 0 ; i < M ; i++ ){
    int p;
    string S;
    cin >>p >>S;
    if(res.at(p-1)!=0){
      continue;
    }
    else{
      if(S=="AC"){
        res.at(p-1)=1;
        scr++;
        pnl+=WA[p-1];
      }
      else{
        WA[p-1]++;
      }
    }
  }
  cout <<scr <<" " <<pnl <<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;

int main(){
    int n,l,r,sum=0;
    cin>>n;

    for(int i=0; i<n; i++){
        cin>>l>>r;
        sum += r-l;
    }
    cout<<sum+n<<endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())
A = [100,101,102,103,104,105]
dp = [[-1 for _ in range(X+1)] for _ in range(7)]
for i in range(1,7):
    dp[i][0] = 10**6
for i in range(1,7):
    for j in range(1,X+1):
        if dp[i-1][j]>=0:
            dp[i][j] = 10**6
        elif j<A[i-1] or dp[i][j-A[i-1]]<=0:
            dp[i][j] = -1
        else:
            dp[i][j] = dp[i][j-A[i-1]]-1
if dp[6][X]>=0:
    print(1)
else:
    print(0)

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

typedef long long ll;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll dp[MAXV];
int N,W,V,wi[MAXN],vi[MAXN];

int main(){

	cin >> N >> W;
	for(int i = 1;i<=N;i++){
		cin >> wi[i] >> vi[i];
		V += vi[i];
	}

	for(int i = 1;i<=V;i++) dp[i] = INF;
	dp[0] = 0;
	
	for(int item = 1;item<=N;item++){
		int w = wi[item], v = vi[item];
		for(int i = V;i>=v;i--){
			dp[i] = min(dp[i],dp[i - v] + w);
		}
	}

	for(int i = V;i>=0;i--){
		if(dp[i] <= W){
			cout << i << endl;
			break;
		}
	}

	return 0;

}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	char S[N+1];
	scanf("%s",S);
	int l=0,r=0;
	int pl=0,pr=0;
	for(int i=0;i<N;i++){
		if(S[i]=='('){
			l++;
		}
		else{
			r++;
			if(l==0)pl++;
			else l--;
		}
	}
	for(int i=0;i<pl;i++)printf("(");
	for(int i=0;i<N;i++)printf("%c",S[i]);
	for(int i=0;i<l;i++)printf(")");
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

int main()
{
    boost
    ll a[3],k;
    cin >> a[0] >> a[1] >> a[2];
    cin >> k;
    while( a[1]<=a[0] && k>0 )  {
        a[1]*=2;
        k--;
    }
    while( a[2]<=a[1] && k>0 )  {
        a[2]*=2;
        k--;
    }
    bool flag=true;
    for(ll i=1;i<3;i++) {
        if( a[i]<=a[i-1] )   {
            flag=false;
        }
    }
    if( flag )  {
        cout << "Yes";
    }
    else  {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n,k,c;
	string s;
	cin>>n>>k>>c>>s;
	int cnt=0;
	int earliest[k],latest[k];
	rep(i,n){
		if(s[i]=='o'){
			earliest[cnt]=i;
			cnt++;
			i+=c;
		}
		if(cnt==k){
			break;
		}
	}
	cnt--;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='o'){
			latest[cnt]=i;
			cnt--;
			i-=c;
		}
		if(cnt==-1){
			break;
		}
	}
	vi ans;
	rep(i,k){
		if(earliest[i]==latest[i]){
			ans.pb(earliest[i]+1);
		}
	}
	rep(i,ans.size()){
		cout<<ans[i]<<endl;
	}
	re 0;
}

Measured memory_bytes: 4216
#include<stdio.h>
 
int main(void){
int a, b;
int sum, dif, pro;
scanf("%d %d", &a, &b);
 
sum = a + b;
dif = a - b;
pro = a * b;
 
printf("%d", (sum > dif) ? ((sum > pro) ? sum : pro) : ((dif > pro) ? dif : pro));
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;

vector<LL> factor(int n) {
    vector<LL> ret(n+1, 1);
    for (int i = 1; i <= n; i++) {
        ret[i] = (ret[i-1]* (n-i+1)) / i;
    }
    return ret;

}

int main() {
//    freopen("test.txt", "r", stdin);
    int n, p, tmp;
    scanf("%d%d", &n, &p);
    int one = 0;
    int two = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);
        if (tmp & 1) one++;
        else two++;
    }
    vector<LL> factor_one = factor(one);
    vector<LL> factor_two = factor(two);

    LL ret1 = 0;
    LL ret2 = 0;
    for (int i = 0; i <= two; i++) {
        ret2 += factor_two[i];
    }
    if (p == 0) {

        for (int i = 0; i <= one; i+=2) {
            ret1 += factor_one[i];
        }
        cout << ret1*ret2 << endl;
    }
    else {
        for (int i = 1; i <= one; i+=2) {
            ret1 += factor_one[i];
        }
        cout << ret1*ret2 << endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair

vector<vector<pair<ll,ll>>> out(1e5);
vector<vector<ll>> in(1e5);
ll inf=1e18;
ll p=1e9+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,i,j,t,a,b,temp,m,k,x,y,ctr;
	ld r;
	cin>>n>>k;
	ll arr[n+1],pre[n+1],suf[n+1];
	pre[0]=0;
	for(i=0;i<=n;i++)
	{
	   arr[i]=i;
	   if(i>=1)
	   pre[i]=pre[i-1]+i;
	   
	    
	    
	}
	suf[n]=n;
	for(i=n-1;i>=0;i--)
	{
	    suf[i]=suf[i+1]+arr[i];
	}
	ll ans=0;
	for(i=k;i<=(n+1);i++)
	{
	    ll t1=i;
	    ll t2=n-i+1;
	    //cout<<pre[t1-1]<<" "<<suf[t2];
	    ll t3=suf[t2]-pre[t1-1]+1;
	    t3+=p;
	    t3%=p;
	    ans+=t3;
	    ans%=p;
	}
	cout<<ans;
	return 0;
	
	
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int h = in(), n = in();
    vint a = in(n);
    if (accumulate(ALL(a), 0) >= h)
        Yes;
    else
        No;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 640
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索する過程で親を更新
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        t = (x == y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return t


    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]
import sys
input = sys.stdin.readline
n = int(input())
data = [list(map(int,input().split()))+[i] for i in range(n)]

data.sort()
edge = []
append = edge.append
for i in range(1,n):
    append([data[i][0]-data[i-1][0],data[i][2],data[i-1][2]])
data.sort(key=lambda x:x[1])
for i in range(1,n):
    append([data[i][1]-data[i-1][1],data[i][2],data[i-1][2]])

edge.sort()
uf = UnionFind(n)
ans = 0
for x,y,z in edge:
    if not uf.same_check(y,z):
        uf.union(y,z)
        ans += x

print(ans)

Measured memory_bytes: 125352
# coding: utf-8
# Your code here!
N=int(input())
H=list(map(int,input().split()))

dp=[0]*N
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
    
print(dp[-1])

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 100010;

V<int> g[maxn];
int st[maxn];

void dfs(int v, int c) {
	st[v] = c;
	for (int to : g[v]) {
		if (st[to] == -1) {
			dfs(to, c ^ 1);
		}
	}
}

int main() {
	int N, M; cin >> N >> M;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b);
		g[b].pb(a);
	}
	memset(st, -1, sizeof(st));

	dfs(0, 0);

	bool bi = 1;
	int cnt = 0;
	rep(i, N) {
		if (st[i]) ++cnt;
		for (int to : g[i]) {
			if (st[i] == st[to]) {
				bi = 0;
			}
		}
	}

	if (bi) {
		cout << (ll)cnt * (N - cnt) - M << endl;
	} else {
		cout << (ll)N * (N - 1) / 2 - M << endl;
	}

	return 0;
}

Measured memory_bytes: 6656
#include <stdio.h>

int main(void) {

  char b;
  do {
    scanf("%c", &b);
  } while (b != 'A' && b != 'C' && b != 'G' && b != 'T');

  if (b == 'A') {
    printf("%c\n", 'T');
  } else if (b == 'C') {
    printf("%c\n", 'G');
  } else if (b == 'G') {
    printf("%c\n", 'C');
  } else if (b == 'T') {
    printf("%c\n", 'A');
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin >> n;
    double d;
    cin >> d;
    int cnt = 0;
    while(n--)
    {
        double a,b;
        double dis ;
        cin >> a >> b;
        dis = sqrt(a*a + b*b) ;

        if(dis<=d)cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


// --- FIX begin --- cut here ---
template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}
// --- FIX end --- cut here ---



int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, D; cin >> N >> D;
  vector<vector<int>> num(D, vector<int>(D));
  vector<vector<int>> rank(D, vector<int>(D));
  for (int i = 0; i < N; i++) {
    int x, y; cin >> x >> y;
    num.at(x % D).at(y % D)++;
  }
  int vmax = 0;
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < D; j++) vmax = max(vmax, num.at(i).at(j));
  }
  int k = ceil(sqrt(vmax) - 0.001);
  
  
  for (int x = 0; x < D; x++) {
    for (int y = 0; y < D; y++) {
      rank.at(x).at(y) =
	num.at(x).at(y) <= (k-1)*(k-1) ? 0 :
	num.at(x).at(y) <=   k  *(k-1) ? 1 : 2;
    }
  }

  auto setCum = [&](int th) {
    vector<vector<int>> cum(2*D + 1, vector<int>(2*D + 1));
    for (int x = 0; x < 2*D; x++) {
      for (int y = 0; y < 2*D; y++) {
	cum.at(x+1).at(y+1) = (rank.at(x % D).at(y % D) >= th ? 1 : 0)
	  + cum.at(x).at(y+1) + cum.at(x+1).at(y)
	  - cum.at(x).at(y);
      }
    }
    return cum;
  };
  auto cum1 = setCum(1);
  auto cum2 = setCum(2);

  auto emp = [&](int th, int x, int y, int dx, int dy) {
    const auto& cum = th == 1 ? cum1 : cum2;
    int n = cum.at(x + dx).at(y + dy) + cum.at(x).at(y)
            - cum.at(x + dx).at(y) - cum.at(x).at(y + dy);
    return n == 0;
  };

  auto chk = [&](int m) {
    for (int x = 0; x < D; x++) {
      for (int y = 0; y < D; y++) {
	if (emp(1, x + m, y + m, D - m, D - m) &&
	    emp(2, x + m, y,     D - m, m) &&
	    emp(2, x,     y + m, D,     D - m)) {
	  return true;
	}
      }
    }
    return false;
  };

  int lo = 0, hi = D;
  while (lo + 1 < hi) {
    int mid = (lo + hi) / 2;
    if (chk(mid)) hi = mid;
    else lo = mid;
  }
  cout << (k - 1) * D + lo << endl;

}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int INF = 1001001001;

int n;
vector<int> a;
vector<int> g[N];
vector<int> dp(N, INF);
vector<int> ans;

void dfs(int v, int p = -1) {
  int i = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
  for (int u : g[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  dp[i] = old;
}

int main() {
  cin >> n;
  a.resize(n);
  ans.resize(n);
  for (int &i : a) cin >> i;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 27952
// D - Maximum Average Sets

// 組み合わせを計算する解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

const int N_MAX = 50;

ll comb[N_MAX + 1][N_MAX + 1];

void init_comb() {
	comb[0][0] = 1;
	for (int i=1; i<=N_MAX; i++) {
		for (int j=0; j<=i; j++) {
			comb[i][j] += comb[i-1][j];
			if (j > 0) comb[i][j] += comb[i-1][j-1];
		}
	}
}

long double v[51];
map<long double, int> v_cnt; // vの各値の個数
map<long double, int> v_first_appear_idx; // 降順ソート後にvの各値が最初に出てくるindex
vector<int> last_v_idx_list; // 平均が最大となるときの最後に選んだvのindex

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	for (int i=0; i<N; i++) {
		cin >> v[i];
		v_cnt[v[i]]++;
	}

	sort(v, v+N, greater<long double>());

	// vの各値が最初に出てくるindexを求めておく
	v_first_appear_idx[v[0]] = 0;
	for (int i=1; i<N; i++) {
		if (v[i] != v[i-1]) {
			v_first_appear_idx[v[i]] = i;
		}
	}

	// ---- 平均値の最大値を求める ---- //
	long double total = 0;
	long double max_mean = 0;
	for (int i=0; i<N; i++) {
		total += v[i];
		if (i+1 >= A && i+1 <= B) {
			long double tmp_mean = total / (i+1);
			if (tmp_mean > max_mean) {
				max_mean = tmp_mean;
				last_v_idx_list.clear();
				last_v_idx_list.push_back(i);
			} else if (tmp_mean == max_mean) {
				last_v_idx_list.push_back(i);
			}
		}
	}

	// ---- 場合の数を求める ---- //
	init_comb();
	ll num_ways = 0;
	for (int last_v_idx : last_v_idx_list) {
		long double last_v = v[last_v_idx];
		int num_selected_last_v = last_v_idx - v_first_appear_idx[last_v] + 1;
		num_ways += comb[v_cnt[last_v]][num_selected_last_v];
	}

	cout << fixed << setprecision(10);
	cout << max_mean << endl;
	cout << num_ways << endl;

	return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val mod = 2019L
  val Array(l, r) = in.readLine.split(" ").map(_.toLong)

  val r2 = r min (l+mod*2)
  var res:Long = Integer.MAX_VALUE
  for {
    i <- l to r2
    j <- i+1 to r2
  } {
    val x = (i*j) % mod
    if(res > x) res = x
  }

  val ans = res
  println(ans)
}

Measured memory_bytes: 77412
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int xmax = n / 4;
		int ymax = n / 7;
		// 4x+7y=n

		for (int x = 0; x <= xmax; x++) {
			for (int y = 0; y <=ymax; y++) {
				if (n == 4 * x + 7 * y) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");

	}

}


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

int main() {
    int A, B, K;
    int recent_max[100], idx=0;
    cin >> A >> B >> K;
    for (int divide = 1; divide <= min(A, B); ++divide) {
        if ((A % divide == 0) && (B % divide == 0)) {
//            cout << idx << " " << divide << endl;
            recent_max[idx] = divide;
            idx++;
        }
    }
    cout << recent_max[idx - K] << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
from math import factorial

def combinations_count(n, r): #組み合わせ
    return factorial(n) // (factorial(n - r) * factorial(r))

n = int(input())
li = []
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    li.append(''.join(s))

c = list(collections.Counter(li).values())
c.sort(reverse=True)

for i in c:
    if i == 1:
        break
    ans += combinations_count(i, 2)

print(ans)

Measured memory_bytes: 19852
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	printf("%d\n", (int)(pow(2, M) * (1800 * M + 100 * N)));
	return 0;
}

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

vector<int> sieve (int n) {
  vector<int> res(n + 1);
  iota(res.begin(), res.end(), 0);
  for (int i = 2; i <= n; i++) {
    if (res[i] != i) continue;
    for (int j = i + i; j <= n; j += i) {
      res[j] = i;
    }
  }
  return res;
}

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n;
  cin >> n;
  auto v = sieve(n);
  long long ans = 0;
  for (int c = 1; c < n; c++) {
    int x = n - c;
    map<int, int> mp;
    if (x == 1) ans += 1;
    else {
      while (x > 1) {
        mp[v[x]]++;
        x /= v[x];
      }
      long long cur = 1;
      for (auto& p : mp) {
        cur *= (p.second + 1);
      }
      ans += cur;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int count = 0;
  int realcount = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      if (S[i] == '(') count++;
      else count--;
    } else {
      if (S[i-1] == '(' && S[i] == '(') count++;
      else if (S[i-1] == ')' && S[i] == '(' && count >= 0) count++;
      else if (S[i] == ')') count--;
      else {
        realcount -= count;
        count = 0;
      }
    }
    if (count <= 0) {
      realcount -= count;
      count = 0;
    }
  }
  
  if (realcount > 0) {
    for (int i = 0; i < realcount; i++) S = '(' + S;
  }
  if (count > 0) {
    for (int i = 0; i < count; i++) S = S + ')';
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
while True:
    n,x = map(int, input().split())
    if (n==0)&(x==0): break
    ans = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5592
import numpy as np
N, K, *H = map(int, open(0).read().split())
dp = np.zeros(N, dtype=int)
heights = np.array(H)
for i in range(1, N):
    start = 0 if i - K < 0 else i - K
    dp[i] = (dp[start:i] + np.abs(heights[i] - heights[start:i])).min()
print(dp[-1])

Measured memory_bytes: 22948
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(12);
  double x1,y1,x2,y2,a,b,ans;
  cin >> x1 >> y1 >> x2 >> y2;

  a = x2-x1;
  if(a<0) a = a * (-1);
  b = y2-y1;
  if(b<0) b = b * (-1);

  a = pow(a,2);
  b = pow(b,2);

  ans = a+b;
  ans = sqrt(ans);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3260
from collections import deque
H,W,K = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1
Pond = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp = list(temp)
  Pond.append(temp)
#print(Pond)
Q = deque([])
Q.append((sx,sy))
reach = [[INF]*W for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
while Q:
  nx,ny = Q.popleft()
  step = K
  for i in range(4):
    for fac in range(1,K+1):
      tx = nx + fac*dxdy[i][0]
      ty = ny + fac*dxdy[i][1]
      #print(i,tx,ty)
      if 0>tx or tx>=H or 0>ty or ty>=W or Pond[tx][ty] == "@": #or reach[tx][ty] != INF:
        #print(i,tx,ty,reach[2][0])
        break #範囲外やハスがあった、到達済みの場合には終了
      #print(i,tx,ty)
      if reach[nx][ny] + 1 > reach[tx][ty]: #もし現時点よりもステップが大きい場合はだめ。
        #同じ場合は向き的に得している場合もあるので残す。
        break
      if reach[nx][ny] + 1 == reach[tx][ty]:
        continue
      reach[tx][ty] = reach[nx][ny] + 1
      Q.append((tx,ty))
      if tx == gx and ty == gy:
        print(reach[gx][gy])
        exit()
#print(reach)
#ans = reach[gx][gy]
#if ans == INF:
print(-1)
#else:
#  print(ans)

Measured memory_bytes: 140368
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let rec f x = function
    | [] -> true
    | y :: ys -> if x = y then false else f y ys

[<EntryPoint>]
let main argv =
    let s = read string
    s.ToCharArray()
    |> List.ofArray
    |> fun (x :: xs) -> f x xs
    |> fun b -> if b then "Good" else "Bad"
    |> printfn "%s"
    0

Measured memory_bytes: 14812
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n,m,k;
	cin >> n >> m >> k;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			if(m*i+n*j-2*i*j==k){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main(){
	
	int a, b;
	
	cin >> a >> b;
	
	int outlet = 1;
	int ans = 0;
	
	while (outlet < b){
		outlet+=a;
		outlet--;
		ans++;
	}
	
	cout << ans;

	
}

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

vector<string> let = {"z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"};

int main(){
    ll N;
    cin >> N;
    string ans="";
    while(true){
        int k = N%26;
        ans.insert(0,let[k]);
        if(k == 0){
            N = N - 26;
        }else{
            N = N - N%26;
        }
        N = N/26;
        if(N==0){
            break;
        }
    }
    
    cout << ans << endl;
    
}
    

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

int bm[] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
int lm[] = {20, 20, 20, 20, 20, 20, 20, 20, 20, 20};

const int Y = 1000, M = 10;

int days[Y] = {};

int main(){
	int n, y, m, d, ds;
	int bms = 0, lms = 0;
	cin >> n;
	for(int i = 0;i < M;++i){
		bms += bm[i];
		lms += lm[i];
	}
	for(int i = 0;i < n;++i){
		cin >> y >> m >> d;
		ds = 0;
		for(int ms = m; ms <= M; ++ms){
			ds += (y % 3 == 0) ? lm[ms - 1] : bm[ms - 1];
			if(ms == m){
				ds -= d;
				++ds;
			}
		}
		for(int ys = y + 1; ys < Y; ++ys){
			if(ys % 3 == 0){
				ds += lms;
			}
			else{
				ds += bms;
			}
		}
		cout << ds << endl;
	}
}

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

int main()
{
        string S;
        cin >> S;

        if (S == "Sunny") {
                cout << "Cloudy" << endl;
        }
        else if (S == "Cloudy") {
                cout << "Rainy"<< endl;
        }
        else {
                cout << "Sunny" << endl;
        }

        return 0;
}

Measured memory_bytes: 256