akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a,b,c,d,e,f;

int main(){
	cin>>a>>b>>c>>d>>e>>f;
	a*=100,b*=100;
	int anssw,anss;
	double ans=-INF;
	for(int i=0;a*i<=f;i++){
		for(int j=0;b*j+a*i<=f;j++){
			for(int k=0;b*j+a*i+c*k<=f&&100*c*k<=e*(a*i+b*j);k++){
				for(int l=0;b*j+a*i+c*k+d*l<=f&&100*(c*k+d*l)<=e*(a*i+b*j);l++){
					if(i!=0||j!=0||k!=0||l!=0)
					if((double)100*(c*k+d*l)/(double)(a*i+b*j+c*k+d*l)>ans){
						ans=100*(double)(c*k+d*l)/(a*i+b*j+c*k+d*l);
						anssw=b*j+a*i+c*k+d*l;
						anss=c*k+d*l;
					}
				}
			}
		}
	}
	cout<<anssw<<" "<<anss<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;
    vector<int> ans(N);
    rep(i,X+1) {
        repi(j,i+1,Y) {
            ans[min(j-i, (X-i)+1+(Y-j))]++;
        }
        repi(j,Y,N) {
            ans[j-i-(Y-X)+1]++;
        }
    }
    repi(i,X+1,N) {
        repi(j,i+1,N) {
            ans[min(j-i, (i-X)+1+abs(j-Y))]++;
        }
    }
    repi(i,1,N) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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




int main(void) {
	int n;
	int blue = 0;
	int red = 0;
	string s;

	cin >> n;
	cin >> s;

	FOR(i, 0, s.size() - 1) {
		if (s[i] == 'R') {
			red++;
		}
		else {
			blue++;
		}

	}

	if (red > blue) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main()
{
  int64_t N, K, cnt = 0;
  cin >> N >> K;
  vector<int64_t> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  if (K >= N)
  {
    cout << 0 << endl;
    return 0;
  }
  sort(H.begin(), H.end());
  for (int i = 0; i < N - K; i++)
  {
    cnt += H.at(i);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int r,g,b,n;
	int rest,ans = 0;
	scanf("%d%d%d%d",&r,&g,&b,&n);
	for (int i = 0; i <= 3000; ++i){
		for (int j = 0; j <= 3000; ++j){
			rest = i * r + j * g;
			if(n >= rest && (n - rest) % b == 0) ++ans;
		}
	}
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

vector< vector<int> > edges;
vector< vector<int> > length;
vector<int> color;

void dfs(int n, int f) {
	if (color[n] < 0) {
		color[n] = f;
		for (int i = 0; i < (int)edges[n].size(); ++i) {
			dfs(edges[n][i], (f + length[n][i]) % 2);
		}
	}
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	edges.resize(n);
	length.resize(n);
	color = vector<int>(n, -1);
	for (int i = 0; i < n - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		--u, --v;
		edges[u].push_back(v);
		edges[v].push_back(u);
		length[u].push_back(w);
		length[v].push_back(w);
	}
	dfs(0, 0);
	for (int i = 0; i < n; ++i) {
		cout << color[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13312
x=int(input())
if(x>=400 and x<=599):
  print("8")
if(x>=600 and x<=799):
  print("7")
if(x>=800 and x<=999):
  print("6")
if(x>=1000 and x<=1199):
  print("5")
if(x>=1200 and x<=1399):
  print("4")
if(x>=1400 and x<=1599):
  print("3")
if(x>=1600 and x<=1799):
  print("2")
if(x>=1800 and x<=1999):
  print("1")


Measured memory_bytes: 9176
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


ll dp[210000][40];

main(){
    ios
    int n=in();
    ll t=in();
    vec a,b,b2;
    rep(i,n){
        int A=in(),B=in()+1;
        if(A==0)b2.pb(B);
        else a.pb(A),b.pb(B);
    }
    int m=a.size();
    vec id;
    rep(i,m)id.pb(i);
    sort(all(id),[&](int x,int y){
        return (a[x])*b[y] > (a[y])*b[x];
    });
    vec id2;
    rep(i,n-m){
        id2.pb(i);
    }
    sort(all(id2),[&](int x,int y){
        return b2[x]<b2[y];
    });
    rep(i,n+1)rep(j,40)dp[i][j]=INT_MAX;
    dp[0][0]=1;
    rep(i,m){
        rep(j,31){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j+1],dp[i][j]+dp[i][j]*a[id[i]]+b[id[i]]);
        }
    }
    t++;
    int ans=0;
    rep(j,31){
        ll T=dp[m][j];
        if(T>t)continue;
        int now=j;
        int p=0;
        while(p<n-m and T+b2[id2[p]]<=t){
            T+=b2[id2[p]]; p++;
        }
        chmax(ans,p+(int)j);
    }
    cout<<ans<<endl;
        
}


Measured memory_bytes: 66164
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
      int m=sc.nextInt();
      int x=sc.nextInt();
      int y=sc.nextInt();
      int x2=sc.nextInt();
      for(int i=1;i<n;i++){x2=Math.max(sc.nextInt(),x2);
      }
      int y2=sc.nextInt();
      for(int i=1;i<m;i++)y2=Math.min(sc.nextInt(),y2);
      if(x2<y2&&x2<y&&y2>x)
        System.out.println("No War");
    else System.out.println("War");
    }
}

Measured memory_bytes: 22996
N = gets.to_i
A = gets.split.map(&:to_i).unshift(nil)

cur = Array.new(N + 1, 0)

(N).downto(1) do |i|
  balls = i.step(N, i).inject(0) { |sum, j| sum + cur[j] }

  cur[i] = 1 if balls % 2 != A[i]
end

ans = cur.map.with_index { |a, i| i if a > 0 }.compact
puts ans.size
puts ans.join(' ') if ans.size > 0

Measured memory_bytes: 26880
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
 
int N;
char s[101];
 
int hold[10], place = 0;
 
int main()
{
    while( scanf( "%d", &N ), N )
    {
        std::fill( hold, hold+10, 0 );
        place = 0;
 
        scanf( "%s", s );
 
        rep( i, 100 )
        {
            int p = i % N;
 
            if( s[i] == 'M' )
                ++hold[p];
            else if( s[i] == 'S' )
            {
                place += hold[p]+1;
                hold[p] = 0;
            }
            else if( s[i] == 'L' )
            {
                hold[p] += place+1;
                place = 0;
            }
        }
 
        std::sort( hold, hold+N );
 
        rep( i, N )
            printf( "%d ", hold[i] );
 
        printf( "%d\n", place );
    }
 
    return 0;
}

Measured memory_bytes: 1052
import numpy as np
import itertools
import math
n, m, x = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(n)] 
CA = np.array(CA)
C = CA[:, 0]
A = CA[:, 1:]
B = np.array([x]*m)

combs = itertools.product(range(2), repeat=n)
opt_val = math.inf
for com in combs:
    X = np.array(com)
    if np.all(A.T @ X >= B):
        opt_val = min(C @ X, opt_val)
if opt_val == math.inf:
    print('-1')
else:
    print(opt_val)

Measured memory_bytes: 27272
from fractions import gcd
A,B = map(int,input().split())
g = gcd(A,B)

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

facts = factorize(g)
print(len(facts) + 1)

Measured memory_bytes: 5048
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

pair<int,int> hitBlow(int a, int b){
  int hit = 0;
  int blow = 0;
  int cntA[10] = { 0 };
  int cntB[10] = { 0 };

  REP(i, 4){
    int aa = a % 10;
    int bb = b % 10;

    if(aa == bb) ++hit;
    ++cntA[aa];
    ++cntB[bb];

    a /= 10;
    b /= 10;
  }

  REP(i,10){
    blow += min(cntA[i], cntB[i]);
  }
  blow -= hit;

  return make_pair(hit, blow);
}

bool different(int a){
  int cnt[10] = { 0 };
  REP(i,4){
    int aa = a % 10;
    if(cnt[aa]++ != 0)
      return false;
    a /= 10;
  }
  return true;
}

int main(){
  int n;
  while((n = getInt()) != 0){
    int fdn[n];
    int hits[n];
    int blows[n];
    vector<int> ans;

    REP(i,n){
      fdn[i] = getInt();
      hits[i] = getInt();
      blows[i] = getInt();
    }

    REP(i,10000) if(different(i)){
      REP(j,n){
        pair<int,int> ret = hitBlow(i, fdn[j]);
        int hit = ret.f;
        int blow = ret.s;

        if(hits[j] != hit || blows[j] != blow){
          goto bad;
        }
      }
      ans.push_back(i);
    bad:;
    }

    if(ans.size() == 1){
      printf("%04d\n", ans[0]);
    }else if(ans.size() > 1 && ans.size() < 25){
      bool ok = false;
      REP(i,10000) if(different(i)){
        int cnt[5][5] = {{ 0 }};
        REP(j, ans.size()){
          pair<int,int> ret = hitBlow(i, ans[j]);
          if(cnt[ret.f][ret.s]++ != 0)
            goto bad2;
        }
        printf("%04d\n", i);
        ok = true;
        break;
      bad2:;
      }
      if(!ok) puts("????");
    }else{
      puts("????");
    }
  }
  return 0;
}

Measured memory_bytes: 904
t=gets.to_i
t.times{
    n,k = gets.split.map &:to_i
    x = gets.split.map &:to_i
    d = []
    (0..x.size-2).each{|i|
        d << x[i+1] - x[i]
    }
    puts x[-1] - x[0] - d.sort.reverse.slice(0,k-1).sum
}


Measured memory_bytes: 21728
import heapq
class PriorityQueue:
	"""
	動的に優先度付きで値をpopする
	値を変更してから再度ソートして取り出すみたいな操作をするなら
	Priority Queue!
	"""
	def __init__(self,num_list=None,reverse=False):
		self.reverse = reverse
		self.heap = []
		if num_list != None :
			for num in num_list:
				self.push(num)

	def push(self,num):
		heapq.heappush(self.heap,-num if self.reverse else num)

	def pop(self):
		num = heapq.heappop(self.heap)
		return -num if self.reverse else num
	
	def get(self):
		return list(map(lambda x: x*(-1),self.heap))


def cmd1(a,b):
	return a+1,b+1

def cmd2(n):
	return n+2

a,b,c = map(int,input().split())
const = min(a,b,c)
a -= const
b -= const
c -= const
count = 0
pq = PriorityQueue(num_list=[a,b,c],reverse=True)
total = 0
while True :
	num_max = pq.pop()
	a = pq.pop()
	b = pq.pop()

	a_req = num_max - a
	b_req = num_max - b
	
	if num_max == a == b :
		break

	if a_req > 0 and b_req > 0:
		a,b = cmd1(a,b)
		total += 1
	else :
		b = cmd2(b)
		total += 1
	pq.push(num_max)
	pq.push(a)
	pq.push(b)
print(total)

Measured memory_bytes: 3188
def invr(x):
    if len(x)<=1:
        return x,0
    m=len(x)
    x1=x[:m//2]
    x2=x[m//2:]
    x11,r1=invr(x1)
    x22,r2=invr(x2)
    x11=x11[::-1]
    x22=x22[::-1]
    rx=[];r=r1+r2
    while x11 and x22:
        if x11[-1]<=x22[-1]:
            rx.append(x11.pop())
        else:
            rx.append(x22.pop())
            r+=len(x11)
    rx+=x11[::-1]
    rx+=x22[::-1]
    return rx,r
n=int(input())
*a,=map(int, input().split())
_,ans=invr(a)
print(ans)


Measured memory_bytes: 27468
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > > 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define err(n) cout<<n<<" ";
#define t1 cout<<",";

void err_mask(ll n){
	if(n==0)return;
	while(n){
		cout<<n%2;
		n/=2;
	}
	cout<<" ";
}
ll MOD= 98244353;

void add_self (ll& a, ll b){
	a+= b;
	a%=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

ll mul(ll a, ll b){
	a*=b;
	a%=MOD;
	return a;
}

void min_self(double& a, double b){
	a= min(a,b);
}


bool conflict(pll a, pll b){
	if(b.fr> a.sc)return 0;
	else return 1;
}


int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j;

ll n;cin>>n;
string s;cin>>s;
ll ans=0;
if(n==1){cout<<1;return 0;}
repup(1, n-1,i){
	if(s[i]!= s[i-1])ans++;
	if(i== n-1)ans++;
	
}
cout<<ans<<'\n';
}
	

Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	// input = input.split("\n");
	// tmp = input[1].split(" ");
	var value = parseInt(input);
	//出力
	console.log('%d', value * value);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  ll x;
  cin >> x;
  ll ans = (x / 11) * 2;
  if(ans > 0){
    x %= 11;
  }
  if(x > 6){
    ans += 2;
  }else if(x > 0){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var n int
        fmt.Scan(&n)

        dp := make([]bool, 100)
        dp[0] = true
        for i := range dp {
                if !dp[i] {
                        continue
                }
                if i+4 == n || i+7 == n {
                        fmt.Println("Yes")
                        return
                }
                if i+4 > n {
                        fmt.Println("No")
                        return
                }
                dp[i+4] = true
                if i+7 > n {
                        continue
                }
                dp[i+7] = true
        }
        fmt.Println("No")
}

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

using namespace std;

int main() {
	int N, ans = 0;
	cin >> N;

	vector<int> V;

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

		V.push_back(A);
	}

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

	for (int i = 0; i < N;i++) {
		if (V[i] != V[i + 1]) {

		}
		else if (V[i] == V[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

ll calc(ll a, ll b, ll c) {
    return max(a, max(b, c)) - min(a, min(b, c));
}

int main () {
    ll H, W; cin >> H >> W;
    ll a1, a2, a3, h1, h2, h3, w1, w2, w3, ans = INF;

    w2 = W / 2; w3 = W - w2;
    for (h1 = 1; h1 < H; ++h1) {
        h2 = (H - h1) / 2; h3 = H - h1 - h2;

        // if (h2 == 0 || h3 == 0) continue;

        a1 = h1 * W, a2 = h2 * W, a3 = h3 * W;
        ans = min(ans, calc(a1, a2, a3));

        a2 = (H-h1) * w2, a3 = (H - h1) * w3;
        ans = min(ans, calc(a1, a2, a3));
    }

    h2 = H / 2; h3 = H - h2;
    for (w1 = 1; w1 < W; ++w1) {
        w2 = (W - w1) / 2; w3 = W - w1 - w2;

        // if (w2 == 0 || w3 == 0) continue;

        a1 = H * w1, a2 = H * w2, a3 = H * w3;
        ans = min(ans, calc(a1, a2, a3));

        a2 = h2 * (W-w1), a3 = h3 * (W-w1);
        ans = min(ans, calc(a1, a2, a3));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, a, b;
  cin >> x >> a >> b;
  if (a - b >= 0)
    cout << "delicious" << endl;
  else if (b - a > x)
    cout << "dangerous" << endl;
  else
    cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    
signed main(){
    speed;
    int n; cin >> n;
    int ans = 0;
    map<string, bool> m;
    vi v(n);
    rep(i, n) cin >> v[i];
    rep(i, n - 2) {
        for(int j = i + 1; j < n - 1; j++) {
            for(int k = j + 1; k < n; k++) {
                vector<int> t = {v[i], v[j], v[k]};
                sort(all(t));
                if(t[0] + t[1] > t[2] && t[0] != t[1] && t[1] != t[2] && t[2] != t[0]) {
                    if(i != j && j != k && i != k) {
                        string s = "";
                        s += '#';
                        s += t[0] + '0';
                        s += '#';
                        s += t[1] + '0';
                        s += '#';
                        s += t[2] + '0';
                        s += '#';
                        s += i + '0';
                        s += '#';
                        s += j + '0';
                        s += '#';
                        s += k + '0';
                        m[s] = true;
                    }
                }
            }
        }
    }
    // iter(m) {
    //     cout << it->first << " " << it->second << endl;
    // }
    cout << m.size();
    return 0;
}

Measured memory_bytes: 16252
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String ln = br.readLine();
        String ans = getAnswerString(ln);
        System.out.println(ans.length());
    }
    
    private static String getAnswerString(String st) {
        int st_len = st.length();
        st = delOneChar(st);
        while (!isDoubled(st)) {
            st = delOneChar(st);
        }
        return st;
    }
    
    private static boolean isDoubled(String st) {
        int st_len = st.length();
        if (st_len == 1) {
            return true;
        }
        if (st_len%2 != 0) {
            return false;
        }
        int start1 = 0;
        int start2 = st_len/2;
        
        while (start1 < st_len/2) {
            char st1 = st.charAt(start1);
            char st2 = st.charAt(start2);
            if (st1 != st2) {
                return false;
            }
            start1++;
            start2++;
        }
        return true;
    }
    
    private static String delOneChar(String st) {
        return st.substring(0, st.length() - 1);
    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long int ll;


int main()
{
	ll n,m;
	cin>>n>>m;
	ll ans = 0;
	if( 2*n >= m){
		ans = m / 2;
	}else{
		ans = n;
		m = m - 2*n;
		ans += m / 4;
	}
	cout<<ans<<endl;
	return 0;
}



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

typedef long long ll;

bool is_prime(int x){
    if (x<=1) return false;
    for (int i=2;i*i<x;i++){
        if (x%i==0) return false;
    }
    return true;
}

int main() {
    int X;
    cin >> X;
    while (!is_prime(X)) X++;
    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

// void findStr(vector<string> strs, string str){
//     int size = strs.size();
//     if(size==0){
//         cout << "no" << endl;
//     }else{
//         for(int i=0; i<size; i++){
//             if(strs[i]==str){
//                 cout << "yes" << endl;
//                 break;
//             }else if(i==size-1 && strs[i]!=str){
//                 cout << "no" << endl;
//             }
//         }
//     }
// }

int main(){

    // TLE

    // int n;
    // cin >> n;
    //
    // vector<string> strs;
    //
    // string cmd;
    // string str;
    // for(int i=0; i<n; i++){
    //     cin >> cmd >> str;
    //     if(cmd=="insert"){
    //         strs.push_back(str);
    //     }else if(cmd=="find"){
    //         int size = strs.size();
    //         if(size==0){
    //             cout << "no" << endl;
    //         }else{
    //             for(int i=0; i<size; i++){
    //                 if(strs[i]==str){
    //                     cout << "yes" << endl;
    //                     break;
    //                 }else if(i==size-1 && strs[i]!=str){
    //                     cout << "no" << endl;
    //                 }
    //             }
    //         }
    //     }
    // }





    // TLE strの最初の文字を調べ、４種のvectorに格納

    // int n;
    // cin >> n;
    //
    // vector<string> strs_A;
    // vector<string> strs_C;
    // vector<string> strs_G;
    // vector<string> strs_T;
    //
    // string cmd;
    // string str;
    //
    // for(int i=0; i<n; i++){
    //     cin >> cmd >> str;
    //     if(cmd=="insert"){
    //         if(str[0]=='A'){
    //             strs_A.push_back(str);
    //         }else if(str[0]=='C'){
    //             strs_C.push_back(str);
    //         }else if(str[0]=='G'){
    //             strs_G.push_back(str);
    //         }else if(str[0]=='T'){
    //             strs_T.push_back(str);
    //         }
    //     }else if(cmd=="find"){
    //         if(str[0]=='A'){
    //             findStr(strs_A, str);
    //         }else if(str[0]=='C'){
    //             findStr(strs_C, str);
    //         }else if(str[0]=='G'){
    //             findStr(strs_G, str);
    //         }else if(str[0]=='T'){
    //             findStr(strs_T, str);
    //         }
    //     }
    // }

    set<string> str_set;
    int n;
    cin >> n;
    while(n--){
        string cmd, str;
        cin >> cmd >> str;
        if(cmd=="insert"){
            str_set.insert(str);
        }else if(cmd=="find"){
            bool result = (str_set.find(str) != str_set.end());
            if(result){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 32204
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main() {
	int x,cnt=1;
	while(true){
		cin >>x;
		if(x==0){
			break;
		}
		printf("Case %d: %d\n",cnt++,x);
	}
	return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	string s; cin >> s;
	int q; cin >> q;
	vector<set<int>> st(26);
	rep(i,n) st[s[i]-'a'].insert(i);
	vi ans;
	rep(i,q){
		int type; cin >> type;
		if(type==1){
			int i; cin >> i;
			--i;
			char c; cin >> c;
			st[s[i]-'a'].erase(i);
			s[i]=c;
			st[c-'a'].insert(i);
		}else{
			int l,r; cin >> l >> r;
			--l;--r;
			int sum = 0;
			rep(x,26){
				auto itr = st[x].lower_bound(l);
				if(itr!=st[x].end() && *itr<=r) sum++;
			}
			ans.push_back(sum);
		}
	}
	rep(i,ans.size()) cout << ans[i] << endl;
}



Measured memory_bytes: 24452
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  while(1) {
    int sum; cin >> sum;
    if(sum == 0) break;
    FOR(i,0,9) {
      int in;
      cin >> in;
      sum -= in;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3004
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;


int an[105];
int ans,a,b,c;

int main()
{
	cin >> a >> b >> c;
	an[a]++;
	an[b]++;
	an[c]++;
	for(int i = 0; i < 105; i++){
		ans = max(ans,an[i]);
	}
	cout << (3-ans+1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

vector<long long> stairs(200001,0),inv(200001,0), sinv(200001,0);   //inv[i]*i%M = 1,sinv[i]*(i!)%M = 1(0<=i<=N)

void setup() {
	stairs[0] = 1;
	stairs[1] = 1;
	inv[1] = 1;
	sinv[0] = 1;
	sinv[1] = 1;
	for (int n = 2; n <= 200000; n++) {
		stairs[n] = (stairs[n - 1] * n) % MOD;
		inv[n] = MOD - (inv[MOD % n] * (MOD / n)) % MOD;
		sinv[n] = (sinv[n - 1] * inv[n]) % MOD;
	}
}

int H, W, A, B;

int main() {
	cin >> H >> W >> A >> B;
	setup();
	long long ans = 0;
	for (int k = 0; k < min(W-B,H-A); k++) {
		long long temp = (stairs[B+H-1-A] * sinv[B+k])%MOD;
		temp = (temp * sinv[H - 1 - A - k]) % MOD;
		temp = (temp * stairs[W - 1 + A - B]) % MOD;
		temp = (temp * sinv[A + k]) % MOD;
		temp = (temp * sinv[W - 1 - k - B]) % MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define INF INT_MAX
#define mod 1000000007ll
#define forn(i,n) for(int i=0;i<n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define forba(i,b,a) for(int i=b;i>=a;i--)
#define debx(x) cout << #x << ": " << x << endl
#define debxy(x,y) cout << #x << ": " << x << ' ' << #y << ": " << y << endl
#define YESp cout << "YES" << endl
#define NOp cout << "NO" << endl
#define Yesp cout << "Yes" << endl
#define Nop cout << "No" << endl
#define write(a) cout << a << endl
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vpi vector<pair<int, int>>
#define pq priority_queue

ll fast_exp(ll base, ll power){ll ans=1;while(power){if(power&1)ans=(ans*base)%mod;base=(base*base)%mod;power=power>>1;}return ans%mod;}
ll modInv(ll a,ll p){return fast_exp(a,p-2)%p;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b,b%a);}

pii moves[] = {{-1, 0}, {1, 0}, {0 ,-1}, {0, 1}};

/****** S ****** X ****** T ****** Y ****** A ****** M ******/


int main() {
    int n, a, count = 0;
    cin >> n;
    forn(i, n) {
        cin >> a;
        if(!(i&1) && (a&1)) count++;
    }
    cout << count << endl;
}

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

using namespace std;

int main()
{
	list<int> li;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		char s[20];
		int t;
		scanf("%s",s);
		if(s[6]==0) scanf("%d",&t);
		if(s[0]=='i') li.push_front(t);
		else if(s[6]==0)
		{
			for(list<int>::iterator it=li.begin();it!=li.end();++it)
				if(*it==t)
				{
					li.erase(it);
					break;
				}
		}
		else if(s[6]=='F') li.pop_front();
		else if(s[6]=='L') li.pop_back();
	}
	for(list<int>::iterator it=li.begin();it!=li.end();)
	{
		printf("%d",*it);
		printf("%c",(++it)==li.end()?'\n':' ');
	}
	return 0;
}

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

MOD = 1000000007  # type: int


def solve(N: int, S: str):
    abc = "abcdefghijklmnopqrstuvwxyz"
    ans = 2**N % MOD
    n = N
    pre = 1
    for c in abc:
        count = S.count(c)
        kaburi = ((2 ** count)-1-count)
        ans -= pre * kaburi * (2 ** (n - count))
        pre *= (1 + count) % MOD
        n -= count
        ans = ans % MOD
    print(int(ans-1))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


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

int main(){

    int N;
    cin >> N;
    string s;
    cin >> s;

    int blue = 0, red = 0;
    for(int i = 0; i < N; i++){
        if(s[i] == 'R') red++;
        else blue++;
    }

    if(blue < red) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    h, w, k = map(int, input().split())
    grid = ["."*(w+2)]+["."+input()+"." for _ in [0]*h]+["."*(w+2)]
    visit = [[False]*(w+2) for _ in [0]*(h+2)]
    for i in range(h+2):
        for j in range(w+2):
            if grid[i][j] == "S":
                start = (i, j)
                break
    visit[start[0]][start[1]] = True
    q = [start]
    for i in range(k):
        q2 = []
        while q:
            x, y = q.pop()
            if x-1 >= 0:
                if grid[x-1][y] == "." and visit[x-1][y] is False:
                    q2.append((x-1, y))
                    visit[x-1][y] = True
            if x+1 <= h+1:
                if grid[x+1][y] == "." and visit[x+1][y] is False:
                    q2.append((x+1, y))
                    visit[x+1][y] = True
            if y-1 >= 0:
                if grid[x][y-1] == "." and visit[x][y-1] is False:
                    q2.append((x, y-1))
                    visit[x][y-1] = True
            if y+1 <= w+1:
                if grid[x][y+1] == "." and visit[x][y+1] is False:
                    q2.append((x, y+1))
                    visit[x][y+1] = True
        q = q2
    dist = 10**9
    for i in range(h+2):
        for j in range(w+2):
            if visit[i][j]:
                dist = min([dist, i, h+1-i, j, w+1-j])
    print((max(dist-1, 0)-1)//k+2)


main()

Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vs vector<string>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define itr ::iterator
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fne(i,a,b) for(ll i=a;i>=b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define all(v) v.begin(),v.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007
#define pi 3.14159265358979323846

int grid[1005][1005];
long long int dp[1005][1005];
int n=0,m=0;
char ch;

long long int solve(int i,int j)
{ 
  if(i>n-1 || j>m-1)
    return 0;

  if(grid[i][j]==1)
    return dp[i][j]=0;

  if(dp[i][j]!=-1)
    return dp[i][j];

  if(i==n-1 && j==m-1)
    return dp[i][j]=1;

  return dp[i][j] = ((solve(i+1,j))%M + (solve(i,j+1))%M)%M;
}

int main()
{  
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
   IOS;
   
   // int T=1;
   // //cin>>T;
   // fe(t,1,T)
   //  { 
   //    // ll n=0,i=0,j=0,c=0,k=0,flag=0;
      cin>>n>>m;
      f(i,0,n)
       {
        f(j,0,m)
         { 
          dp[i][j]=-1;
         }
      }
      
      f(i,0,n)
       {
        f(j,0,m)
         {
          cin>>ch;
          if(ch=='.') grid[i][j]=0;
          else grid[i][j]=1;
         }
       }

      solve(0,0);

      cout<<dp[0][0];
    //}
     
  return 0;
}


Measured memory_bytes: 15564
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin >> n;
  string s,t,str;
  cin >> s >> t;
  rep(i,n){
    str = str + s[i]+t[i];
  }
  cout << str << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
const double pi = 3.141592653589793;

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//階乗
ll fact(ll a) {
	int ans = 1;
	for (int i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

//コンビネーション
ll combi(ll a, ll b) {
	return fact(a) / (fact(b) * fact(a - b));
}

int main() {
	rep(i, 5) {
		int x;
		cin >> x;
		if (x == 0) {
			cout << i + 1 << endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3616
package main
import (
    "fmt"
    "os"
    "bufio"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}


func main(){
    sc.Split(bufio.ScanWords)
    
    n := nextInt()
    m := nextInt()
    
    // cango := make(map[int][]int)
    cango := make([][]int, n+1)
    
    for i := 0; i < m; i++ {
        a := nextInt()
        b := nextInt()
        
        cango[a] = append(cango[a], b)
        cango[b] = append(cango[b], a)
    }
    
    var q Queue
    q.Add(1)
    
    // togo := make(map[int]int)
    togo := make([]int, 100010)
    
    for len(q) > 0 {
        now := q.Remove()
        for i := 0; i < len(cango[now]); i++ {
            if togo[cango[now][i]] == 0 {
                togo[cango[now][i]] = now
                q.Add(cango[now][i])
            }
        }
    }
    
    var ans []int
    for i := 2; i <= n; i++ {
        if x := togo[i]; x != 0 {
            ans = append(ans, x)
        } else {
            fmt.Println("No")
            return
        }
    }
    
    fmt.Println("Yes")
    for i := 0; i < len(ans); i++ {
        fmt.Println(ans[i])
    }
}
 
type Queue []int
 
func (q *Queue) Add (n int) {
    *q = append(*q, n)
}
 
func (q *Queue) Remove () int {
    temp := *q
    *q = temp[1:]
    return temp[0]
}

Measured memory_bytes: 21928
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int p = Integer.parseInt(scan.next());
        int q = Integer.parseInt(scan.next());
        int r = Integer.parseInt(scan.next());
        System.out.println(Math.min(Math.min(p+q,q+r),r+p));
    }
}

Measured memory_bytes: 22612
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll L, R;
    cin >> L >> R;
    if(R-L>=2018)
    {
        cout << 0;
        return 0;
    }
    L=L-(L/2019)*2019;
    R=R-(R/2019)*2019;
    if(R<L)
    {
        ll min=2020;
        for(int i=L; i!=R+1; i=(i+1)%2019)
        {
            for(int j=L; j!=R+1; j=(j+1)%2019)
            {
                if((i*j)%2019<min)
                    min=(i*j)%2019;
            }
        }
        cout << min;
    }
    else
    {
        ll min=2020;
        FOR(i,L,R+1)
        {
            FOR(j,i+1,R+1)
            {
                if((i*j)%2019<min)
                    min=(i*j)%2019;
            }
        }
        cout << min;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 601, C = 2e5 + 7;
int sqr[C];
int n, num[N][N], d[2];
vector <int> g[2][N * N];
bool c[2][N * N], used[N * N];
void dfs(bool t, int u) {
    used[u] = 1;
    for (int v : g[t][u]) {
        if (!used[v]) {
            c[t][v] = c[t][u] ^ 1;
            dfs(t, v);
        }   
    }   
}   
vector <ii> ans[2][2];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif        
    for (int i = 0; i < C; ++i) sqr[i] = -1;
    for (int i = 0; i < C; ++i) if (i * i < C) sqr[i * i] = i;
    cin >> n >> d[0] >> d[1];
    int p = 0;
    for (int i = 0; i < 2 * n; ++i) 
        for (int j = 0; j < 2 * n; ++j) 
            num[i][j] = p++;
    for (int t = 0; t < 2; ++t) {
        vector <ii> v;
        for (int i = 0; i * i <= d[t]; ++i) 
            if (sqr[d[t] - i * i] != -1) {
                v.app(mp(i, sqr[d[t] - i * i]));
                v.app(mp(i, -sqr[d[t] - i * i]));
                v.app(mp(-i, sqr[d[t] - i * i]));
                v.app(mp(-i, -sqr[d[t] - i * i]));
            }
        for (int i = 0; i < 2 * n; ++i) 
            for (int j = 0; j < 2 * n; ++j) 
                for (auto e : v) if (0 <= i + e.f && i + e.f < 2 * n && 0 <= j + e.s && j + e.s < 2 * n)
                    g[t][num[i][j]].app(num[i + e.f][j + e.s]);
        memset(used, 0, sizeof used);           
        for (int i = 0; i < 4 * n * n; ++i) 
            if (!used[i]) {
                dfs(t, i);
            }
    }    
    for (int i = 0; i < 4 * n * n; ++i) ans[c[0][i]][c[1][i]].app(mp(i / (n << 1), i % (n << 1)));
    for (int i = 0; i < 2; ++i) 
        for (int j = 0; j < 2; ++j) 
            if (ans[i][j].size() >= n) {
                cerr << Time << '\n';
                for (int k = 0; k < n * n; ++k) cout << ans[i][j][k].f << ' ' << ans[i][j][k].s << '\n';
                exit(0);   
            }
    exit(1);
}

Measured memory_bytes: 190924
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vector<pair<ll,ll>>item;
ll knapsack(int n,ll w){
  ll ret=-1;
  ll dp[n+10][w+10];
  for(int i=0;i<n+10;i++)
    for(int j=0;j<w+10;j++)
      dp[i][j]=-1;
  dp[0][0]=0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=w;j++){
      if(dp[i-1][j]!=-1){
	if(j!=w)
	  dp[i][min(w,j+item[i-1].F)]=max(dp[i][min(w,j+item[i-1].F)],dp[i-1][j]+item[i-1].S);	
	dp[i][j]=max(dp[i][j],dp[i-1][j]);
      }
    }
  }
  for(int j=0;j<=n;j++)
  for(int i=0;i<=w;i++)
    ret=max(dp[j][i],ret);
  return ret;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,t;cin>>n>>t;
  for(int i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    item.pb(mp(a,b));
  }
  sort(ALL(item));
  cout<<knapsack(n,t)<<endl;
  return 0;
}


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

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,f[N][3]	,a[N][3];

int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i) 
				for (j=0;j<3;++j) scanf("%d",&a[i][j]); 
		memset(f,-1,sizeof(f));
		f[0][0]=f[0][1]=f[0][2]=0;
		for (i=0;i<n;++i)
			for (j=0;j<3;++j)
				for (k=0;k<3;++k)
					if (j!=k) 
						f[i+1][k]=max(f[i+1][k],f[i][j]+a[i+1][k]);
		printf("%d\n",max(f[n][0],max(f[n][1],f[n][2]))); 
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> a(n, 0);
    for (size_t i = 0; i < n; ++i)
        cin >> a[i];
    std::sort(begin(a), end(a));
    for (size_t i = 1; i < n; ++i) {
        if (a[i] == a[i - 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 100000;
int N, M, S;
int dp[50][3010];

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

    while (cin >> N >> M >> S, N) {
        const int K = N * N;
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        REP(i, M) {
            for (int j = K - 1; j >= 0; --j) {
                for (int k = S; k >= 0; --k) {
                    if (!dp[j][k]) continue;
                    if (k + i + 1 <= S) (dp[j + 1][k + i + 1] += dp[j][k]) %= MOD;
                }
            }
        }
        cout << dp[K][S] << endl;
    }
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

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

int main()
{
    string s;

    ci >> s;

    int n = 0, m = 0;
    int bw = 0;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0' + bw) n++;
        bw = (bw + 1) % 2;
        if(s[i] == '0' + bw) m++;
    }

    co << min(n, m) << en;

    return 0;
}

Measured memory_bytes: 512