akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
const ll INF = 1e18L+7;
void min_self(ll& a,ll b)
{
    a = min(a,b);
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n,w;
    cin>>n>>w;
    vector<int> weight(n),value(n);
    int max_sum = 0;
    for(int i=0;i<n;++i)
    {
        cin>>weight[i]>>value[i];
        max_sum += value[i];
    }
    vector<ll> dp(max_sum+1,INF);
    dp[0] = 0;
    for(int item = 0;item < n;++item)
    {
        for(int value_already = max_sum - value[item];value_already>=0;--value_already)
        {
            min_self(dp[value_already+value[item]],dp[value_already] + weight[item]);
        }
    }
    ll ans = 0;
    for(int i=0;i<=max_sum;++i)
    {
        if(dp[i]<=w)
            ans = max(ans,(ll)i);
        
    }
    cout<<ans<<endl;

    
    return 0;

}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string od[100050];
char ans[100050];
int n;
void dfs(int i,int a,int b,int c){
    if(i==n){
        printf("Yes\n");
        for(int j=0;j<n;j++)
            printf("%c\n",ans[j]);
        exit(0);
    }
    if(od[i]=="AB"){
        if(a>0) {
                ans[i]='B';
                dfs(i+1,a-1,b+1,c);
        }
        if(b>0) {
            ans[i]='A';
            dfs(i+1,a+1,b-1,c);
        }
    }
    if(od[i]=="BC"){
        if(b>0) {
            ans[i]='C';
            dfs(i+1,a,b-1,c+1);
        }
        if(c>0) {
            ans[i]='B';
            dfs(i+1,a,b+1,c-1);
        }
    }
    if(od[i]=="AC"){
        if(a>0) {
            ans[i]='C';
            dfs(i+1,a-1,b,c+1);
        }
        if(c>0) {
            ans[i]='A';
            dfs(i+1,a+1,b,c-1);
        }
    }
}
int main(){
    int a,b,c;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(int i=0;i<n;i++){
        cin>>od[i];
    }
    dfs(0,a,b,c);
    printf("No");
}


Measured memory_bytes: 14728
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

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

int main() {
  int n, m, o = 0, p;
  ll l = 1;
  cin >> n >> m;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    a.at(i) >>= 1;
    l = lcm(l, a.at(i));
    if(l > m)
      o = -1;
    if(i)
      if(p != __builtin_ffs(a.at(i)))
        o = -1;
    p = __builtin_ffs(a.at(i));
  }
  if(o == -1) {
    std::cout << 0 << endl;
    return 0;
  }
  o = (m - l) / (l * 2) + 1;
  std::cout << o << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll d = x%11;
    if (d == 0) PRINT((x/11)*2);
    else if (d <= 6) PRINT((x/11)*2+1);
    else PRINT((x/11)*2+2);
}





Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int pa[100005];
int t[100005];
vector<int> v1;

int search(int a){
	if(pa[a]==-1){
		for(int i=0;i<v1.size();i++){
			pa[v1[i]]=a;
		}
		v1.clear();
		return a;
	}
	v1.push_back(a);
	return search(pa[a]);
}

void connect(int a,int b){
	a=search(a),b=search(b);
	if(a!=b)pa[b]=a;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int s=0;
	memset(pa,-1,sizeof(pa));
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a;
		t[a-1]=i;
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		connect(a,b);
	}
	for(i=0;i<n;i++){
		a=search(i),b=search(t[i]);
		if(a==b)s++;
	}
	cout<<s<<endl;
	return 0;
}
		


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int>W(N);
    for(int i=0;i<N;i++){
        cin>>W[i];
    }
    vector<int>sumW(N);
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=W[i];
        sumW[i]=sum;
    }
    int sub=10000000;
    for(int i=0;i<N;i++){
        sub=min(sub,abs(sum-2*sumW[i]));
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 256
n= int(input())
p=list(map(int,input().split()))

cnt =0
l=[]

for i in range(1,n-1):
    l.append(p[i-1])
    l.append(p[i])
    l.append(p[i+1])
    l.sort()
    
    if l[1]==p[i]:
        cnt+=1
    l = []

print(cnt)

Measured memory_bytes: 3060
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */


  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9+7;


  int main()
  {
      long long n,m;
      cin>>n>>m;
      long long s=__gcd(n,m);
      s=(n*m)/s;
      cout<<s;
      return 0;
  }


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<utility>
#include<map>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

const int mod = 998244353;
enum{N=200023};

class chtholly{
private:
	#define range pair<int,int>
	#define CH map<range,int>
	#define FI first
	#define SE second
	CH m;
	il CH::iterator split(int p){
		CH::iterator it=m.lower_bound(range(p,0));
		if( it->FI.FI==p ) return it;
		it--;
		int l=it->FI.FI, r=it->FI.SE, x=it->SE;
		m.erase(it);
		m[range(l,p-1)]=x;
		m[range(p,r)]=x;
		return m.find(range(p,r));
	}
public:
	il void init(int n){
		m.clear();
		m[range(1,n)]=-1;
		m[range(n+1,n)]=-1;
	}
	il void assign(int l,int r,int x){
		CH::iterator R=split(r+1), L=split(l);
		m.erase(L,R);
		m[range(l,r)]=x;
	}
	il int query(int x){
		return split(x)->SE;
	}
}ch;

struct sth{
	int x,y;
	bool operator<(const sth&e)const{
		return x<e.x;
	}
}d[N];
int b[N];

ll dfs(int l,int r){
	ll ans=1;
	int i=l+1;
	while( i<=r ){
		ans=ans*dfs(i,d[i].y)%mod;
		i=d[i].y+1;
	}
	return (ans+1)%mod;
}

int main(){
	int n=ci();
	rep(i,1,n){
		d[i].x=ci(), d[i].y=d[i].x+ci()-1;
	}
	sort(d+1,d+n+1);
	rep(i,1,n) b[i]=d[i].x;
	rep(i,1,n){
		d[i].y = upper_bound(b+1,b+n+1,d[i].y)-b-1;
	}
	ch.init(n);
	rev_rep(i,n,1){
		d[i].y = ch.query(d[i].y);
		if( d[i].y==-1 ) d[i].y=i;
		ch.assign(i,d[i].y,d[i].y);
	}
	ll ans = 1;
	int i=1;
	while( i<=n ){
		ans=ans*dfs(i,d[i].y)%mod;
		i=d[i].y+1;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 11904
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int M;
int A[100010];
map<int, int> numMap;

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

	cin >> N >> M;
	rep(i, 0, N) {
		cin >> A[i];
		if (i > 0)A[i] += A[i - 1];
		numMap[A[i] % M]++;
	}

	int ans = 0;
	for (auto& p : numMap)
	{
		if (p.first == 0)
		{
			ans += (p.second)*(p.second + 1) / 2;
		}
		else
		{
			ans += (p.second)*(p.second + 1) / 2 - p.second;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
import math

EPS = 1e-10

def equals(a, b):
    return abs(a - b) < EPS


class Point:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

    def __add__(self, p):
        return Point(self.x + p.x, self.y + p.y)

    def __sub__(self, p):
        return Point(self.x - p.x, self.y - p.y)

    def __mul__(self, a):
        return Point(self.x * a, self.y * a)

    def __rmul__(self, a):
        return self * a

    def __truediv__(self, a):
        return Point(self.x / a, self.y / a)

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

    def __lt__(self, p):
        if self.x != p.x:
            return self. x < p.x
        else:
            return self.y < p.y

    def __eq__(self, p):
        return equals(self.x, p.x) and equals(self.y, p.y)


def dot(a, b):
    return a.x * b.x + a.y * b.y


def cross(a, b):
    return a.x * b.y - a.y * b.x


def contains(g, p):
    n = len(g)
    isIn = False
    for i in range(n):
        a = g[i] - p
        b = g[(i + 1) % n] - p
        if abs(cross(a, b)) < EPS and dot(a, b) < EPS:
            return 1
        if a.y > b.y:
            a, b = b, a
        if a.y < EPS and EPS < b.y and cross(a, b) > EPS:
            isIn = not isIn
    if isIn:
        return 2
    else:
        return 0


if __name__ == '__main__':
    n = int(input())
    g = []
    for i in range(n):
        x, y =  [int(v) for v in input().split()]
        g.append(Point(x, y))

    q = int(input())
    ans = []
    for i in range(q):
        x, y =  [int(v) for v in input().split()]
        ans.append(contains(g, Point(x, y)))

    for v in ans:
        print(v)


Measured memory_bytes: 5832
def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,m = list(sorted(getints()))

if n == 1:
    if m != 1:
        res = m - 2
    else:
        res = 1
elif n == 2:
    res = 0
else:
    res = n * m - 2 * n - 2 * m + 4

print(res)


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

int main() {
	vector<double> vec(0); double temp;
	while (cin >> temp) { vec.push_back(temp); }
	sort(vec.begin(), vec.end());
	cout << vec[vec.size() - 1] - vec[0] << endl;
	return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>

int main(){
  int verline[31], horline, x, y, sum, stack, i;
  char trash;


  scanf("%d",&sum);
  scanf("%d",&horline);

  for(i = 1; i <= sum; i++){
    verline[i] = i;
  }

  for(i = 0; i < horline; i++){
    scanf("%d %c %d",&x,&trash,&y);
    stack = verline[x];
    verline[x] = verline[y];
    verline[y] = stack;
  }


  for(i = 1; i <= sum; i++){
    printf("%d\n",verline[i]);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

bool solve(int mx, map<int, int> &mp){
    if(mx%2){
        if(mp[(mx+1)/2]!=2) return false;
        for(int x=0; x<(mx+1)/2; x++)
            if(mp[x]>0) return false;
        for(int x=(mx+1)/2+1; x<=mx; x++)
            if(mp[x]<2) return false;
        return true;
    }else{
        if(mp[mx/2]!=1) return false;
        for(int x=0; x<x/2; x++)
            if(mp[x]>0) return false;
        for(int x=mx/2+1; x<=mx; x++)
            if(mp[x]<2) return false;
        return true;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    int mx = *max_element(a.begin(), a.end());
    map<int, int> mp;
    REP(i, N) mp[a[i]]++;
    cout << (solve(mx, mp) ? "Possible" : "Impossible") << endl;
    return 0;
}

Measured memory_bytes: 3648
using System;

namespace E___Double_Factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine().Trim());
            Console.WriteLine(Solve(N));

        }
        static long Solve(long N)
        {
            if (N == 0 || N % 2 == 1)
            {
                return 0L;
            }
            else
            {
                long ans = 0;
                long a = 10;
                while (N >= a)
                {
                    ans += N / a;
                    a *= 5;
                }
                return ans;
            }
        }
    }
}


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

const int N = 100005;

int n, t, a[N];
map<int, int> pos, was;

int main() {
    ios::sync_with_stdio(false);

    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pos[a[i]] = i;
    }
    int mx = 0;
    int diff = 0;
    int result = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] > mx) {
            mx = a[i];
        } else {
            if (mx - a[i] > diff) {
                result = 1;
                diff = mx - a[i];
            } else
            if (mx - a[i] == diff) {
                ++result;
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 5376
s = input()
t = input()

ans_list = []
end = len(s) - len(t) + 1
for i in range(end):
    word = s[i:i+len(t)]
    tmp = 0
    for j in range(len(t)):
        if t[j] != word[j]:
            tmp += 1
    ans_list.append(tmp)

ans_list.sort()
ans = ans_list[0]

print(ans)

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
check = [-1]*n
cntr = 0
tmp = 0
while 1:
    if check[tmp] != -1:
        break
    check[tmp] = cntr
    cntr += 1
    tmp = a[tmp] - 1
c = check[tmp]
if cntr > k:
    for i in range(n):
        if check[i] == k % cntr:
            ans = i+1
            break
else:
    for i in range(n):
        if check[i] - c == (k-c) % (cntr-c):
            ans = i+1
            break
print(ans)

Measured memory_bytes: 90104
#include <bits/stdc++.h>
using namespace std;
int n,a[21],maxx,ans;
int main()
{
	cin>>n;
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
		if (a[i]>=maxx) ans++,maxx=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    string s;
    ll a=0,b=0;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='0') a++;
        if(s[i]=='1') b++;
    }
    cout<<min(a,b)*2<<endl;
    return 0;
}


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

int main(void){
    int n = 0; 
    int a = 0;
    int approve = 1;

    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%d", &a);
        if(a % 2 == 0){
            if(a % 3 == 0 || a % 5 == 0){

            }else{
                approve = 0;
            }
        }
    }
    if(approve == 1){
        printf("APPROVED\n");
    }else{
        printf("DENIED\n");
    }

    return 0;

} 


Measured memory_bytes: 256
M,D = list(map(int, input().split()))
ans = 0
if M >=4:
    for i in range(4, M+1):
        if D >= 22:
            for j in range(22, D+1):
                if int(j/10) >=2 and j%10 >=2 and i == int(j/10) * int(j%10):
                    ans += 1
                    #print(str(i) + " " + str(j))
print(ans)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define Rint register LL
using namespace std;
typedef long long LL;
LL n, ans;
int main(){
	scanf("%lld", &n);
	for(Rint i = 1, last;i <= n;i = last + 1){
		last = n / (n / i);
		if(n % (n / i) == 0 && last > i)
			ans += last - 1;
	}
	printf("%lld", ans);
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    int ans = 0;
    sort(all(p));
    rep(i, k)
    {
        ans += p[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
struct place{
    int x;
    int y;
};
void serch(char line[][101],struct place map,char sign){
    line[map.y][map.x]='%';
    struct place temp;
    if(line[map.y][map.x+1] == sign){
        line[map.y][map.x+1]='%';
        temp.x=map.x+1;
        temp.y=map.y;
        serch(line,temp,sign);
    }
    if(line[map.y+1][map.x] == sign){
        line[map.y+1][map.x]='%';
        temp.x=map.x;
        temp.y=map.y+1;
        serch(line,temp,sign);
    }
    if(map.x != 0){
        if(line[map.y][map.x-1] == sign){
            line[map.y][map.x-1]='%';
            temp.x=map.x-1;
            temp.y=map.y;
            serch(line,temp,sign);
        }
    }
    if(map.y != 0){
        if(line[map.y-1][map.x] == sign){
            line[map.y-1][map.x]='%';
            temp.x=map.x;
            temp.y=map.y-1;
            serch(line,temp,sign);
        }
    }
}
int main(void){
    int n,m,sum,i,o,sign,l,q;
    while(1){
        char line[101][101]={0};
        struct place p;
        scanf("%d %d",&n,&m);
        if(n == 0)
            break;
        sum=0;
        for(i=0;i<n;i++){
            scanf("%s",line[i]);
        }
        for(i=0;i<n;i++){
                for(o=0;o<m;o++){
                    if(line[i][o] != '%'){
                        p.x=o;
                        p.y=i;
                        serch(line,p,line[i][o]);
                        sum++;
                    }
                }
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

using namespace std;

const int INF = 1e9;

int N, M, Q;
string S[2005];
int node[2005][2005], edgeH[2005][2005],edgeW[2005][2005];

int main() {
  cin>>N>>M>>Q;
  REP(i,0,N) cin>>S[i];

  /*累積和の配列は、一個ずつずらす（範囲外アクセス対策）*/
  REP(i,0,N){
    REP(j,0,M){
      if(S[i][j] == '1') node[i+1][j+1]++;
      if(j > 0){
        if(S[i][j-1] == '1' && S[i][j] == '1') edgeW[i+1][j+1]++;
      }
      if(i > 0){
        if(S[i-1][j] == '1' && S[i][j] == '1') edgeH[i+1][j+1]++;
      }
    }
  }

  REP(i,0,N+1){
    REP(j,1,M+1){
      node[i][j] += node[i][j-1];
      edgeW[i][j] += edgeW[i][j-1];
      edgeH[i][j] += edgeH[i][j-1];
    }
  }
  REP(i,1,N+1){
    REP(j,0,M+1){
      node[i][j] += node[i-1][j];
      edgeW[i][j] += edgeW[i-1][j];
      edgeH[i][j] += edgeH[i-1][j];
    }
  }

  REP(i,0,Q){
    int y1,x1,y2,x2;
    cin>>y1>>x1>>y2>>x2;

    int n,eh,ew;
    n = node[y2][x2] - node[y2][x1-1] - node[y1-1][x2] + node[y1-1][x1-1];
    //縦の記録：対象行より「上」の情報　→　y1につての情報は消すべき(範囲より上の辺を切る)
    eh = edgeH[y2][x2] - edgeH[y2][x1-1] - edgeH[y1][x2] + edgeH[y1][x1-1];
    ew = edgeW[y2][x2] - edgeW[y2][x1] - edgeW[y1-1][x2] + edgeW[y1-1][x1];

    cout<<n-eh-ew<<endl;
  }

  return 0;
}


Measured memory_bytes: 52992
#include<iostream>
#define MOD 1000000007LL
using namespace std;
long long n,rez,i,A[100005],Dp[100005],val;

long long p(long long a, long long b)
{
    long long i,rez=1LL;
    for(i=0; (1LL<<i)<=b; i++)
    {
        if((1<<i)&b)
            rez=(rez*a)%MOD;
        a=(a*a)%MOD;
    }
    return rez;
}

int main()
{
    ios::sync_with_stdio(false);
    //Dp[i]=nr de permutari in care, pentru o secventa de lungime i,
    //elementul curent este primul eliminat
    //Dp[i]=n!/i. Dem. cu prob veizi solutia oficiala
    //Dem cu comb: x-nr de elemente care nu apar in intervalul de lg i, x=n-i
    //Dp[i]=n*(n-1)*(n-2)*...*(n-x+1)*(n-x-1)*(n-x-2)*(n-x-3)*...*2*1=n!/i
    //rezultatul e Dp[1...i]+Dp[2...n-i]
    //deoarece nr de premutari in care el i e legat de un element j, si elementul j se sterge
    //este egal cu Dp[j-i+1]
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>A[i];
    val=1;
    for(i=1; i<=n; i++)
        val=(val*i)%MOD;
    for(i=1; i<=n; i++)
        Dp[i]=(val*p(i,MOD-2))%MOD;
    for(i=1; i<=n; i++)
        Dp[i]=(Dp[i-1]+Dp[i])%MOD;
    for(i=1; i<=n; i++)
        rez=(rez+(A[i]*((Dp[i]+Dp[n-i+1]-Dp[1]+MOD)%MOD))%MOD)%MOD;
    cout<<rez<<"\n";
    return 0;
}


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

// C - gacha
int main() {
    int N;
    cin >> N;
    set<string> S;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S.insert(s);
    }

    cout << S.size();
}


Measured memory_bytes: 19104
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

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

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

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

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    char s;
    cin >> s;

    if (isupper(s)) {
        print('A');
    } else {
        print('a');
    }
}


Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
   int n,i,j=0,c=0;
   scanf("%d",&n);
   int a[n],b[n];
   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
       if(a[i]%4==0){
          b[j]=a[i];
          j++;
          }
          if(a[i]%2==0&&a[i]%4!=0)
              c++;
   }
    if(j>=n-j-1)
    {
        printf("Yes");
    }
    if(j<n-j-1&&n-j-c<=j)
        printf("Yes");
     if(j<n-j-1&&n-j-c>j)
            printf("No");
  return 0;
}



Measured memory_bytes: 896
#include <iostream>

#define MAX 100 
using namespace std;

int num[MAX+1]={};
//ind d[MAX+1]={};

int main(void){
  int N,K;
  cin >> N >> K;
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int n=0;n<d;n++){
      int A;
      cin >> A;
      num[A] = num[A] + 1;
    }
  }
  int ans = 0;
  for(int i=1;i<=N;i++){
    if(num[i] == 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s, t;
  cin >> s;

  int N = s.size();
  REP(i, N){
    if(i != N-1 && s[i] == 'B' && s[i+1] == 'C') t += "D", i++;
    else t += s[i];
  }

  int M = t.size();
  int cnt = 0, ans = 0;
  REP(i, M){
    if(t[i] == 'A') cnt++;
    else if(t[i] == 'D'){
      ans += cnt;
    }else{
      cnt = 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 776
s = gets.strip

words = ['dream', 'dreamer', 'erase', 'eraser']

until s.empty? do
    reduced = false
    words.map do |w|
        if s[-w.size, w.size] == w
            s = s[0..-w.size - 1]
            reduced = true
            break
        end
    end

    unless reduced
        puts 'NO'
        exit 0
    end
end

puts 'YES'

Measured memory_bytes: 56268
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

const int INF = (1LL << 31) - 1;
const int sqrtN = 512;
struct SqrtDecomposition {
    int N, K;
    vector<int> data;
    vector<int> bucketMin;
    SqrtDecomposition(int n) : N(n) {
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(K * sqrtN, 0);
        bucketMin.assign(K, 0);
    }
    void update(int x, int y) {
        int k = x / sqrtN;
        data[x] += y;
        bucketMin[k] += y;
    }
    int find(int x, int y) {
        int val = 0;
        rep(k, K) {
            //sqrtN区間ずつみる
            int l = k * sqrtN, r = (k + 1) * sqrtN;
            //範囲外
            if (r <= x || y <= l) continue;
            //完全被覆
            if (x <= l && r <= y) val += bucketMin[k];
            //部分被覆
            else rrep(i, max(x, l), min(y, r)) {
                val += data[i];
            }
        }
        return val;
    }
    void check() {
        rep(i, N) cout << data[i] << " "; cout << endl;
    }
};
int main() {
    int n, q;
    cin >> n >> q;
    SqrtDecomposition sd(n);
    rep(i, q) {
        int p, a, b;
        cin >> p >> a >> b;
        a--;
        if (p == 1) b--;
        if (p == 0) sd.update(a, b);
        else cout << sd.find(a, b + 1) << endl;
        //sd.check();
    }
    return 0;
}



Measured memory_bytes: 3120
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static int mod = 1000000000 + 7;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        List<Long> plus = new ArrayList<Long>();
        List<Long> minus = new ArrayList<Long>();
        List<Long> zero = new ArrayList<Long>();
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(scan.next());
            if (a > 0) {
                plus.add(a);
            } else if (a < 0) {
                minus.add(a);
            } else {
                zero.add(a);
            }
        }
        scan.close();

        if (n == k) {
            long ans = 1;
            for (long a : plus) {
                ans *= a;
                ans %= mod;
            }
            for (long a : minus) {
                ans *= -a;
                ans %= mod;
                if (minus.size() % 2 == 1) {
                    ans = mod - ans;
                }
            }
            for (long a : zero) {
                ans *= a;
            }
            System.out.println(ans);
            return;
        }

        if (plus.size() == 0 && k % 2 == 1) {
            if (zero.size() != 0) {
                System.out.println(0);
                return;
            }
            Collections.sort(minus, Collections.reverseOrder());
            long ans = 1;
            for (int i = 0; i < k; i++) {
                ans *= -minus.get(i);
                ans %= mod;
            }
            if (k % 2 == 1) {
                ans = mod - ans;
            }

            System.out.println(ans);
            return;
        }

        if (plus.size() + minus.size() < k) {
            System.out.println(0);
            return;
        }

        Collections.sort(plus, Collections.reverseOrder());
        Collections.sort(minus);
        int minusCount;
        int plusCount;
        if (k <= minus.size()) {
            minusCount = k;
        } else {
            minusCount = minus.size();
        }
        if (minusCount % 2 != 0) {
            minusCount -= 1;
        }
        plusCount = k - minusCount;

        while (minusCount >= 2 && plusCount <= plus.size() - 2 &&
                minus.get(minusCount - 1) * minus.get(minusCount - 2) < plus.get(plusCount) * plus.get(plusCount + 1)) {
            minusCount -= 2;
            plusCount += 2;
        }

        long ans = 1;
        for (int i = 0; i < plusCount; i++) {
            ans *= plus.get(i);
            ans %= mod;
        }
        long minusAns = 1;
        for (int i = 0; i < minusCount; i++) {
            minusAns *= -minus.get(i);
            minusAns %= mod;
        }

        ans *= minusAns;
        ans %= mod;

        System.out.println(ans);
    }
}


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

using namespace std;

int main(void)
{
    int X, Y;
    cin >> X >> Y;

    int A = 4 * X - Y;
    int B = Y - 2 * X;
    
    if(A < 0 || B < 0 || (Y % 2 == 1)){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3612
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n = s(s);
	n += k;
	int z = 26;
	ll ans = 1;
	mul(ans,fastexp(z,n));
	// cout<<ans<<"\n";
	ll fac[n+1];
	fac[0] = 1;
	repa(i,1,n+1){
		fac[i] = fac[i-1]*i;
		fac[i] %= mod;
	}
	int len = s(s);
	rep(i,len){
		ll temp = fac[n];
		mul(temp,inverse(fac[i]));
		mul(temp,inverse(fac[n-i]));
		mul(temp,fastexp(z-1,n-i));
		sub(ans,temp);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 19868
program prob5
    implicit none
    integer :: K, S
    integer :: x, y
    integer :: ans

    read(*,*) K, S

    ans = 0
    do x = 0, K
        do y = 0, K
            if(x + y >= S - K .and. x + y <= S) then
                ans = ans + 1
            end if
        end do
    end do

    write(*,*) ans
    stop
contains
end program prob5

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

//#define int int64_t
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) begin(c), end(c)
#define breakif(cond) if(cond) break; else

#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int n, m;
	int x = 1;
	while (cin >> n >> m && n) {
		V hs(n), ws(m);
		input(hs); input(ws);
		V hh;
		rep(i, n) {
			int sum = 0;
			REP(j, i, n) hh.push_back(sum += hs[j]);
		}
		sort(all(hh));
		int ans = 0;
		rep(i, m) {
			int sum = 0;
			REP(j, i, m) {
				sum += ws[j];
				ans += upper_bound(all(hh), sum) - lower_bound(all(hh), sum);
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
  ll n;
  cin >> n;
  int ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    for (int j = 1; j <= cnt; j++) {
      ans++;
      cnt -= j;
    }
  }
  if (n != 1) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
import java.io.*;
public class Main {
	static NODE node;
	static NODE root;
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));	
		int n=Integer.parseInt(br.readLine());
		
		for(int i=0;i<n;i++){
			String[] str=br.readLine().split(" ");
		
			if("print".equals(str[0])) {
				inorder(root);
				System.out.println("");	
				preorder(root);
				System.out.println("");	
			}
			else if("insert".equals(str[0])){
				int key=Integer.parseInt(str[1]);
				NODE newnode=new NODE();
				newnode.key=key;
				insert(newnode);
			}

		}
	}

	static void inorder(NODE node){
		if(node==null) return;
		inorder(node.left);
		System.out.print(" " + node.key);
		inorder(node.right);
	}
	
	static void preorder(NODE node){		
		if(node==null) return;
		System.out.print(" " + node.key);
		preorder(node.left);
		preorder(node.right);	
	}
	
	static void insert(NODE node){
        if(root==null){
            root = node;
            return;
        }
        NODE tnode = root;
        NODE parent = null;
        while(tnode != null) {
            parent = tnode;
            if(tnode.key > node.key)
                tnode = tnode.left;
            else
                tnode = tnode.right;
        }
        if(parent.key > node.key)
            parent.left = node;
        else
            parent.right = node;
		
	}
}

class NODE{
	int key;
	NODE left;
	NODE right;;
	NODE(){
		key=-1;
		left=null;
		right=null;
	}
}

Measured memory_bytes: 222736
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 1e9
long double PI =3.14159265358979323846;
 
const ll M=1e12;
const ll inf=1e18;
const ll ms=10000000;
fast;
ll ans,l,r;
void solve()
{
    cin>>l>>r;
    ans=2020;
    for(ll i=l;i<min(r,l+2020);i++)
    {
        for(ll j=i+1;j<=min(r,l+2020);j++)
        {
            ans=min(ans,(i*j)%2019);
            //cout<<i<<" "<<j<<" "<<(i*j)%2019<<endl;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3640
// AtCoder Beginner Contest 164 - Problem C: gacha (https://atcoder.jp/contests/abc164/tasks/abc164_c)
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    set<string> xs;

    for (int i = 0; i < N; ++i)
    {
        string x;
        cin >> x;

        xs.insert(x);
    }

    cout << xs.size() << '\n';

    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/16  Problem: nagoya_19_03  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

string ans;

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

	cin >> N;
	string s, t;
	cin >> s >> t;
	for (int l = N; l >= 0; l--) {
		if (s.substr(N - l) == t.substr(0, l)) {
			cout << 2 * N - l << endl;
			return 0;
		}
	}

	return 0;
}

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

string a,b;

ll memo[3009][3009];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>a>>b;
    memset(memo,0,sizeof(memo));
    ll n=a.length(),m=b.length();
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            if(a[i-1]==b[j-1])memo[i][j]=memo[i-1][j-1]+1;
            else memo[i][j]=max(memo[i-1][j],memo[i][j-1]);
        }
    }
    string s;

    ll i=n,j=m;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            s=a[i-1]+s;
            i--;
            j--;
        }
        else if(memo[i-1][j]>memo[i][j-1])i--;
        else j--;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 35712
using System;
using System.Linq;
 
namespace AtcoderProj
{
    class AtcoderClass
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int sum = 0;

            for(int i = 0; i < input.Length; i++)
            {
                int x = input[i];
                foreach(int y in input.Skip(i + 1))
                {
                    sum += x * y; 
                }
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13396
n = int(input())
a = list(map(int, input().split()))

dp = [[-float('inf')] * 2 for _ in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i])
    dp[i + 1][1] = max(dp[i][1] + a[i], dp[i][0] - a[i])

print(dp[n][0])

Measured memory_bytes: 78112
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<P> person_true[N];
    for(int n=0; n<N; n++){
        cin >> A[n];
        for(int j=0; j<A[n]; j++){
            int x,y;
            cin >> x >> y;
            x--;
            person_true[n].push_back(P(x,y));
        }
    }

    vector<int> flag(N);
    int ans=0;
    for(int loop=0; loop<(1<<N); loop++){
        fill(flag.begin(), flag.end(), -1);
        int tmp=loop, tmpans=0, dis=0;
        for(int n=0; n<N; n++){
            if(tmp%2==0){
                flag[n]=1;
                tmpans++;
            }else flag[n]=0;

            tmp/=2;
        }
        for(int n=0; n<N; n++){
            bool tp=flag[n];
            
            for(int i=0; i<A[n]; i++){
                P pairs=person_true[n][i];
                if(tp){
                    if(flag[pairs.first]!=pairs.second) dis=1;
                }
            }
            if(dis==1) break;
        }
        if(dis==0) ans=max(ans, tmpans);
    }
    cout << ans << endl;

    

    return 0;
}

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

using namespace std;
int main(){
  int op;
  stack<int> intStack;
  while(cin>> op){
    if(op == 0){
      cout << intStack.top() << endl;
      intStack.pop();
    } else {
      intStack.push(op);
    }
  }
  return 0;
}
    
      

Measured memory_bytes: 1200
import kotlin.math.ceil

fun solver(n: Int, x: Int, t: Int): Int {
    val times = ceil(n.toDouble() / x).toInt()

    return times * t
}

fun main(args: Array<String>) {
    val (n, x, t) = readLine()!!.split(" ").map { it.toInt() }

    /*
    val n = 20
    val x = 12
    val t = 6  
     */

    val result = solver(n, x, t)

    println(result)
}


Measured memory_bytes: 36420
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
    ll n;
    cin>>n;  
    
    ll a[n+1];
    
    for(ll i=1;i<=n;i++)
    cin>>a[i];
    
    ll sum=0;
    
    for(ll i=1;i<=n;i++){
        ll j=i;
        
        ll res=0;
        while(j<=n&&a[j]!=0){
            res+=a[j++];
        }
        
        i=j;
        
        sum+=res/2;
    }
    
    cout<<sum<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 4428