akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int x,ans;
  bool prime;
  cin >> x;

  if(x%2==0 && 3<x){
    x++;
  }
  for(int i=x; i<100010; i+=2){
    prime= true;
    for(int j=3; j<=sqrt(x); j++){
      if(i%j==0){
        prime= false;
      }
    }
    if(prime){
      ans= i;
      break;
    }
  }

  if(x<3){
    cout << x << endl;
  }else{
    cout << ans << endl;
  }
}


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

int main() {
#ifdef LOCAL_DEFINE
  // freopen("data.in", "rt", stdin);
  // freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<int>> dp(n + 1, vector<int>(3));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(j == k) continue;
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][k]);
			}
		}
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 11264
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1;i<=n;i++){
            int x = i;
            if(x%3 == 0){
                System.out.print(" "+i);
            } else {
                while(x != 0){
                    if(x%10 == 3){
                        System.out.print(" "+i);
                        break;
                    }
                x /= 10;
                }
            }
        }
        System.out.println("");
    }
}



Measured memory_bytes: 28500
#include <iostream>
#include <algorithm>

using namespace std;

long long ans = 0;
int n;

void get(string& s, int pos, long long tmp, long long sum) {
  if (pos == n) {
    ans += sum + tmp;
    return;
  }
  if (tmp == 0) {
    tmp = (s[pos] - '0');
    get(s, pos + 1, tmp, sum);
  } else {
    get(s, pos, 0, sum + tmp);

    tmp *= 10;
    tmp += (s[pos] - '0');
    get(s, pos + 1, tmp, sum);
  }
}

int main() {
  string s;
  cin >> s;
  n = s.length();
  get(s, 0, 0, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, M;
  cin>>N>>M;

  int a[N];
  int sum[N+1];
  sum[0]=0;
  REP(i, N) {
    cin>>a[i];
    sum[i+1] = (sum[i]+a[i])%M;
  }
  if(N==1){
    if(a[0]%M==0)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
  }
  map<int, LINT> mp;
  REP(i, N+1) ++mp[sum[i]];
  LINT ans=0;
  for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
    ans += itr->second*(itr->second-1)/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){
	
	ll N, A, B;
	cin >> N >> A >> B;
	ll diff = B - A;
	if(diff % 2) print("Borys");
	else print("Alice");	
	
}

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

	Main();
    
	return 0;
	
}





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

int main() 
{
    int A, B, C;
    cin >> A >> B >> C;
  
    int ab = A-B;
    int bc = B-C;
    int ca = C-A;
    
    cout << (((ab==0 || bc==0 || ca==0)
              && !(ab == 0 && bc == 0 && ca == 0))
             ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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 devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vector<vector<P>> X(N);

    rep(i, N){
        ll a;
        cin >> a;
        rep(j, a){
            ll x, y;
            cin >> x >> y;
            --x;
            X[i].pb({x, y});
        }
    }

    ll ans = 0;
    rep(i, 1 << N){
        bool counter = false;
        rep(j, N){
            bool honest = i & (1 << j);
            for(auto state : X[j]){
                bool target = i & (1 << state.first);
                if(honest) if(state.second != target) counter = true;
            }
        }
        if(!counter) chmax(ans, (ll)__builtin_popcount(i));
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
s = input()
count = 0
maxi = 0
for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count += 1
    else:
        if maxi < count:
            maxi = count
        count = 0
if maxi < count:
    maxi = count
print(maxi)


Measured memory_bytes: 2940
from collections import deque

N,M = map(int,input().split())

d = [None] * N

dic = {}

for i in range(M):

    a,b = map(int,input().split())
    a-=1
    b-=1

    if a not in dic:
        dic[a] = []
    if b not in dic:
        dic[b] = []

    dic[a].append(b)
    dic[b].append(a)

q = deque([0])
d[0] = 0
flag = False

while len(q) > 0:

    now = q.popleft()

    for i in dic[now]:

        if d[i] == None:
            d[i] = (d[now] + 1) % 2
            q.append(i)


        elif d[i] != (d[now] + 1) % 2:
            flag = True
            break

if flag:
    print (N * (N-1) // 2 - M)

else:
    odd = 0
    even = 0

    for i in d:
        if i == 0:
            even += 1
        else:
            odd += 1

    #print (d)
    print (odd * even - M)


Measured memory_bytes: 72664
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,da,dq;
char st[10000];
int main()
	{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
    	cin>>st[i];
    	if(st[i]=='I')dq++;
   		else dq--;
   	 	if(dq>da)da=dq;
	}
	cout<<da<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
const int inf=2e9+5;
const int maxn=100;
typedef vector<int> vi;
typedef long long ll;
#define fi first
#define se second
typedef pair<int,int> P;
int d[maxn+5][maxn+5];
int v,e;

void floyd()
{
  for(int k=0;k<v;k++)
  {
    for(int i=0;i<v;i++)
    {
      for(int j=0;j<v;j++)
      {
        if(d[i][k]==inf || d[k][j]==inf) continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
}

int main(void)
{
  cin >> v >> e;
  for(int i=0;i<maxn+5;i++)
  {
    for(int j=0;j<maxn+5;j++)
    {
      if(i==j) d[i][j]=0;
      else d[i][j]=inf;
    }
  }
  for(int i=0;i<e;i++)
  {
    int s,t,cost;
    cin >> s >> t >> cost;
    d[s][t]=cost;
  }
  floyd();
  bool nega=false;
  for(int i=0;i<v;i++)
  {
    if(d[i][i]<0)
    {
      nega=true;
    }
  }
  if(nega)
  {
    cout << "NEGATIVE CYCLE" << endl;
  }
  else
  {
    for(int i=0;i<v;i++)
    {
      for(int j=0;j<v;j++)
      {
        if(d[i][j]==inf) cout << "INF";
        else cout << d[i][j];
        if(j!=v-1) cout << ' ';
      }
      cout << endl;
    }
  }
}


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

int main() {
	string N;
	cin >> N;
	
	int dp[11][8]; // 第x桁目の部分集合y(y:{3,5,7})ができている組み合わせ
	memset(dp, 0, sizeof(dp)); // 全ての初期値は0よね
	
	for (int i = 0, tmp = N[0] & 15, j, k, cover = 0, isCover = 1;i < N.size();++ i, cover |= 1 << (tmp - 3 >> 1), isCover &= (tmp & 1) * (tmp & 6) ? 1 : 0, tmp = N[i] & 15) { // 桁数を求めたいのに固定したとき
		dp[i][0] = 1; // 第x桁目が空集合……すなわち今まで0だった、これが最初の桁の組み合わせは当然だが1通り
		for (j = 1;j < 8;j <<= 1) {
			for (k = 0;k < 8;++ k) dp[i + 1][j | k] += dp[i][k];
			if (isCover && (j & 6) + 3 > tmp) -- dp[i + 1][j | cover]; // Nを超える場合をちょっと引き算
		}
	}
	
	cout << dp[N.size()][7]; // {3,5,7}全てを含む場合のみが答えなので
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

dpすると解ける
*/

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a = 0, b = 0, count = 0; //n, kの値, 個数カウント

	scanf("%d %d", &a, &b);

	//アルゴリズム
	for (int i = 0; i < b; i++) {
		count += a / b;
		a = a - 1;
	}
	
	printf("%d", count);
}

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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int n,W;
ll totval=0LL;
vvl wi;
vl dp;

void printt(){
    Fo(i,1,n+1){
        ll currW = wi[i][0], currVal = wi[i][1];
        for(int j=totval;j>=0;j--){
            if(currVal<=j){
                if(dp[j-currVal]!=INT_MAX){
                    dp[j] = min(dp[j-currVal]+currW, dp[j]);
                }
            }
        }
    }
    ll mini=0;
    Fo(i,1,totval+1){
        if(dp[i]<=W && i>mini){
            mini = i;
        }
    }
    cout<<mini<<endl;
}

void take_inp() {
    cin>>n>>W;
    wi.resize(n+1, vl(2));
    Fo(i,1,n+1){
        ll a,b;
        cin>>a>>b;
        wi[i][0] = a;
        wi[i][1] = b;
        totval+=b;
    }
    dp.resize(totval+1,INT_MAX);
    dp[0] = 0;
}

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    take_inp();
    printt();
    return 0;
}

Measured memory_bytes: 1024
import bisect
n, m = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
line = make_divisors(m)
print(m//line[bisect.bisect_left(line, n)])

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

int main() {
	long long N, M, Cur = 0;
	vector<long long> ANS;
	string S;
	cin >> N >> M >> S;
	Cur = N;
	while (0 < Cur) {
		bool check = true;
		for (int i = max(0LL, Cur - M); i < Cur; i++) {
			if (S[i] == '0') {
				check = false;
				ANS.push_back(Cur - i);
				Cur = i;
				break;
			}
		}
		if (check) {
			cout << -1 << endl;
			return 0;
		}
	}
	reverse(ANS.begin(), ANS.end());
	for (int i = 0; i < ANS.size(); i++) {
		cout << ANS[i];
		if (i == ANS.size() - 1) cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 1528
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {

	cin.tie(0);
	
	int A,B;
	cin >> A >> B;

	if (A == B) {
		cout << A + B;
		return 0;
	}
	if (B > A) swap(A, B);
	cout << A + A - 1;
	
	return 0;
}

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

int main()
{
	int N,S,K,X,UD; double L,F,D,V;
	while(scanf("%d%d%d",&N,&S,&K),N||S||K)
	{
		double T[4][1500]={0};
		
		for(int i=0; i<N; i++)
		{
			scanf("%d%lf%lf%lf%d",&X,&L,&F,&D,&UD);
			X+=100;
			
			T[1][X]=L/F;
			T[2][X]=L/D;
			
			if(UD)
			{
				swap(T[1][X],T[2][X]);
				T[3][X]=T[2][X];
			}
		}
		
		for(int s=0; s<S; s++)
		{
			scanf("%lf",&V);
			for(int p=101-s; p<K+205-s; p++)
			{
				T[0][p]=max(T[0][p+1]-T[1][p+1],max(T[0][p-1]+1.0/V,T[3][p]))+T[1][p];
				T[3][p]=T[0][p]+T[2][p];
			}
		}
		printf("%.10lf\n",T[0][K+100]);
	}
}

Measured memory_bytes: 0
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

w,h,x,y = map(int,input().split())

mm = w*h/2
mul = 0

if abs(w/2-x) < 0.001 and abs(h/2-y) < 0.001:
    mul = 1
else:
    mul = 0

print(mm,mul)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    
    for (int i = 0; i <= 25; i++) {
        for (int j = 0; j <= 15; j++) {
            if (i*4 + j*7 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    ll ans = 0;
    ll m = 0;
    REP(i, N) {
        ll p;
        cin >> p;
        ans += p;
        m = max(m, p);
    }

    cout << ans - m / 2 << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;

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

    int N, K;
    cin >> N >> K;

    ll ans = 0;

    ll x = N / K;
    ans += x * x * x;
    if (K % 2 == 0) {
        ll y = (N + (K / 2)) / K;
        ans += y * y * y;
    }

    cout << ans << endl;

    return 0;
}

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

COLOR_LIST = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199]
free_color = 0
color_contain = [0, 0, 0, 0, 0, 0, 0, 0]



for i in a:
	cnt = 0
	for j in COLOR_LIST:
		if i > j:
			cnt += 1
	
	if cnt < len(color_contain):
	    color_contain[cnt] = 1
	else:
	    free_color += 1

if free_color == 0:
	min_ans = sum(color_contain)
	max_ans = sum(color_contain)
else:
    min_ans = max(1, sum(color_contain))
    max_ans = sum(color_contain) + free_color
print(min_ans, max_ans)
		

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

int main() {
    int k;
    int x;
    cin>>k>>x;

    if(x-k+1>=-1000000 && x+k-1<=1000000) {
        for(int i=x-k+1;i<=x+k-1;i++) {
            cout<<i;
            i==x+k-1? cout<<endl: cout<<' ';
        }
    }
    else if(x-k+1<-1000000) {
        for(int i=-1000000;i<=x+k-1;i++) {
            cout<<i;
            i==x+k-1? cout<<endl: cout<<' ';
        }
    }
    else if(x+k-1>1000000) {
        for(int i=x-k+1;i<=1000000;i++) {
            cout<<i;
            i==1000000? cout<<endl: cout<<' ';
        }
    }
}
 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

struct food{
	string n;
	int w;
	int s;
	int used;
};

int main(void){
	int n;
	while(cin>>n,n){
		vector<food> vf;
		rep(i,n){
			food f;
			cin >> f.n >> f.w >> f.s;
			f.used = 0;
			vf.push_back(f);
		}
		
		int weight = 0 ;
		rep(i,n)weight += vf[i].w;
		rep(i,n){
			vi vec;
			rep(j,n){
				if(!vf[j].used && vf[j].s >= weight - vf[j].w){
					vec.push_back(j);
				}
			}
			int wmax = -1;
			int u;
			rep(j,vec.size()){
				if(wmax < vf[vec[j]].w){
					wmax = vf[vec[j]].w;
					u = vec[j];
				}
			}
			cout<< vf[u].n << endl;
			vf[u].used = 1;
			weight -= vf[u].w;
			
		}
	}

}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


int main()
{
    long long x;
    cin >> x;

    long long ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main()
{
    bool f = false;
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b)
    {
        if (a == c)
        {
            f = true;
        }
    }
    if (f)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = int( input() )
a_array = list( map( int, input().split() ) )
q = int( input() )
bc_array = []
for _ in range( q ):
    bc_i = list( map( int, input().split() ) )
    bc_array.append( bc_i )

a_list = [ 0 for _ in range( 10 ** 5 + 1 ) ]
for a in a_array:
    a_list[ a ] += 1

s = 0
for i in range( 10 ** 5 + 1 ):
    s += i * a_list[ i ]

for b, c in bc_array:
    s = s + ( c - b ) * a_list[ b ]
    a_list[ c ] += a_list[ b ]
    a_list[ b ] = 0
    print( s )

Measured memory_bytes: 32980
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
signed main(){
	IOS;
	int n , k ;
	cin >> n >> k ; 
	int ans = 0 ; 
	int base = 1;
	while(base <= n){
		base *= k;
		ans++ ;
	}
	cout << ans << endl ;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in= new Scanner(System.in);
		while(in.hasNext())
		{
			int x=in.nextInt();
			int y=in.nextInt();
			if(x<y)
			{
				int tmp =x;
				x=y;
				y=tmp;
			}
			int c=0;
			if((x|y)==0)
				return;
			while(y!=0)
			{
				int tmp=y;
				y=x%y;
				x=tmp;
				c++;
			}
			System.out.println(x+" "+c);
		}
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;



int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false); 
    string s;
    cin >> s;
    bool ok = 1;
    forn(i, s.size())
    {
        if(i%2 == 0 && s[i] == 'L') ok = 0;
        if(i%2 == 1 && s[i] == 'R') ok = 0;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll p[A], q[B], r[C];
    REP(i, 0, A) {
        cin >> p[i];
    }
    REP(i, 0, B) {
        cin >> q[i];
    }
    REP(i, 0, C) {
        cin >> r[i];
    }
    sort(p, p + A);
    reverse(p, p + A);
    sort(q, q + B);
    reverse(q, q + B);
    sort(r, r + C);
    reverse(r, r + C);
    V<plglg> BC;
    REP(i, 0, B) {
        BC.push_back(plglg(q[i], i + inf));
    }
    REP(i, 0, C) {
        BC.push_back(plglg(r[i], i));
    }
    sort(BC.begin(), BC.end());
    reverse(BC.begin(), BC.end());
    V<bool> used(C, false);
    ll Asum = 0;
    REP(i, 0, X) {
        Asum += p[i];
    }
    ll Bsum = 0;
    REP(i, 0, Y) {
        plglg p = BC[i];
        Bsum += p.first;
        if (p.second < B) {
            used[p.second] = true;
        }
    }
    ll ans = Asum + Bsum;
    // cout << ans << endl;
    ll ind = Y;
    REP(i, 0, min(X, C)) {
        Asum -= p[X - 1 - i];
        Asum += r[i];
        if (used[i]) {
            Bsum -= r[i];
            plglg p = BC[ind];
            Bsum += p.first;
            if (p.second < B) {
                used[p.second] = true;
            }
            ind++;
            // cout << "aaa" << endl;
        }
        // cout << Asum + Bsum << endl;
        ans = max(ans, Asum + Bsum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8816
fun main(args: Array<String>) {
    val numN = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toLong).toMutableList()
    val eList = aList.filter { it % 2 == 0L }.toMutableList()

    var result = 0L
    eList.forEach {
        result += divide(it)
    }
    println(result)

}

fun divide(it:Long):Long{
    val mod = it % 2
    return if(mod != 0L){
        0L
    }else{
        1 + divide(it / 2)
    }
}

Measured memory_bytes: 40084
#include<stdio.h>
int main(){
	int i,j,n,a[5][105];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[0][i]);
	for(i=0;i<n;i++)
	scanf("%d",&a[1][i]);
	int sum=0,kum,maxx=0;
	for(i=0;i<n;i++){
		sum+=a[0][i];
		kum=sum;
		for(j=i;j<n;j++)
			kum+=a[1][j];
		if(kum>maxx)
			maxx=kum;
	}
	printf("%d\n",maxx);
	return 0;
}

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

int main() {
  string s, ans="None";
  int pos, i;
  
  cin >> s;
  
  for (i=0; i<=int('z'-'a'); i++) {
    pos = s.find(char('a'+i));
    if (pos == string::npos) {
      ans = char('a'+i);
      break;
    }
  }
  
  cout << ans << endl;
      
  return 0;  
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 200005
#define ll long long
#define db double
#define pb push_back
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,H,W,f[N],nowx,nowy,ans;
std::map<int,int>mp[N];
struct point{int x,y;}A[N];
std::vector<int>S[N];
int main()
{
	scanf("%d%d%d",&H,&W,&n),nowx=nowy=1,ans=H;
	for(int i=1;i<=n;i++) scanf("%d%d",&A[i].x,&A[i].y),mp[A[i].x][A[i].y]=1,S[A[i].y].pb(A[i].x);
	if(!n) return !printf("%d\n",H);
	f[1]=1;
	for(int i=1;i<=H;i++)
	{
		if(mp[nowx+1][nowy]) break;
		nowx++;
		if(nowy<W&&!mp[nowx][nowy+1]) nowy++,f[nowy]=nowx;
		// dbg1(nowx),dbg2(nowy);
	}
	for(int i=1;i<=nowy;i++) S[i].pb(H+1),std::sort(S[i].begin(),S[i].end());
	for(int i=1,res;i<=nowy;i++)
	{
		res=std::lower_bound(S[i].begin(),S[i].end(),f[i])-S[i].begin();
		ans=min(ans,S[i][res]-1);
		// dbg1(i),dbg1(f[i]),dbg2(res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int flag=0;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='C')
			flag=1;
		else if(flag==1&&s[i]=='F'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c){
        cout << 1 << endl;
    }else if(a!=b && b!=c && a!=c){
        cout << 3 << endl;
    }else{
        cout << 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N, K = map(int, input().split())

num_cnt = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    num_cnt[a] += b

cnt = 0
prev = None
for a, b in sorted(num_cnt.items()):
    if cnt >= K:
        break
    cnt += b
    prev = a
print(prev)


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

int main(){
    int n;
    cin>>n;
    string s;
    map<string,int> cnt;
    rep(i,n){
        cin>>s;
        cnt[s]+=1;
    }
    int maxv=0;
    for(const auto &x : cnt){
        int v=x.second;
        maxv=max(maxv,v);
    }
    for(auto itr=cnt.begin();itr!=cnt.end();itr++){
        if(itr->second==maxv) cout<<itr->first<<endl;
    }
}

Measured memory_bytes: 19104
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;
    cin >> n>>d;

    vector<vector<int>> a(n, vector<int>(d,0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int l = i + 1; l < n; ++l) {
            int sum = 0;
            for (int j = 0; j < d; ++j) {
                sum += (a[i][j] - a[l][j])*(a[i][j] - a[l][j]);
            }
            for (int k = 1; k*k <= sum; ++k) {
                if (k*k == sum)ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()

    val array = Array(10) { Array(10) { 0 } }

    for (i in 1..N) {
        val str = i.toString().toCharArray()
        array[str.first().toString().toInt()][str.last().toString().toInt()] += 1
    }

    var ans = 0
    for (j in 1..N) {
        val str = j.toString().toCharArray()
        ans += array[str.last().toString().toInt()][str.first().toString().toInt()]
    }

    println(ans)
}

Measured memory_bytes: 52628
#include <iostream>
#include <cstdio>
#define int long long
#define N 200002
using namespace std;
const int mod=1000000007;
int a,b,x,y,i,j,f[N],inv[N];
int poww(int a,int b)
{
	int ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
int C(int n,int m)
{
	return f[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main()
{
	cin>>a>>b>>x>>y;
	f[0]=1;
	for(i=1;i<=200000;i++) f[i]=f[i-1]*i%mod;
	inv[200000]=poww(f[200000],mod-2);
	for(i=199999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	int ans=C(a+b-2,b-1);
	for(i=a-x+1;i<=a-x+1;i++){
		for(j=1;j<=y;j++) ans=(ans-C(i+j-3,j-1)*C(a+b-i-j,b-j)%mod+mod)%mod;
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
const int INF = 1001001001;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define re0 return 0
#include<string.h>
int npr(int n , int r){//nPr
    r = n - r;
    int sum = 1;
    int i;
    for (i=n;i>=r+1;i--)sum*=i;
    return sum;
}
int gcd(int a, int b) {//最大公約数
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
    return a * b / gcd(a, b);
}
int digsum(int n) {//桁和
    int res = 0;
    while(n > 0) {
        //res += n%10;
        //　↑をres++;にすれば桁数
         res++;
        n /= 10;
    }
    return res;
}
bool isPrime(int x){//素数判定
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
/*bit全探索
for (int bit = 0; bit < (1<<N); ++bit) {
}
if (bit & (1 << i)) {
}
*/


signed main(){ 
    int a,b;
    cin >> a >> b;
    cout << a*b <<endl;
    return 0;
}


Measured memory_bytes: 3588
// C++ program for implementation of Ford Fulkerson algorithm 
#include <iostream> 
#include <limits.h> 
#include <string.h> 
#include <queue> 
#include <set>
using namespace std; 

#include <stdio.h>

int main(int argc, char *argv[]) {
   int tot;
   
   set<char>k;

   char* inp=new char[5];
    while(cin>>inp)
   {
     while(*inp!='\0')
     {
       k.insert(*inp);
       ++inp;
     }
     if(k.size()==1){
        cout<<"No";
        
     }else{
        cout<<"Yes";
     }
     k.clear();


   } 



   return(0);
}
   


Measured memory_bytes: 256
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
l = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)

res = 0
pos_1 = 0
pos_2 = 0
for _ in range(n):
    if pos_2 == m or a[pos_1] > l[pos_2][1]:
        res += a[pos_1]
        pos_1 += 1
    else:
        res += l[pos_2][1]
        l[pos_2][0] -= 1
        if l[pos_2][0] == 0:
            pos_2 += 1

print(res)

Measured memory_bytes: 101796
#include <iostream>

using namespace std;

int main(void){
  int N, D;
  
  cin >> N >> D;
  
  if(N < (D * 2 + 1)){
    cout << 1 << endl;
  }else if(N % (D * 2 + 1)){
    cout << N / (D * 2 + 1) + 1 << endl;
  }else{
    cout << N / (D * 2 + 1) << endl;
  }
}

Measured memory_bytes: 256
N,M = map(int,input().split())
cakes = []
k = [[],[],[],[],[],[],[],[]]
for i in range(N):
    x,y,z = map(int,input().split())
    k[0].append(x+y+z)
    k[1].append(x+y-z)
    k[2].append(x-y+z)
    k[3].append(x-y-z)
    k[4].append(-x+y+z)
    k[5].append(-x+y-z)
    k[6].append(-x-y+z)
    k[7].append(-x-y-z)

ans = 0
for i in range(8):
    k[i] = sorted(k[i],reverse=True)
    temp = 0
    for j in range(M):
        temp += k[i][j]
    ans = max(temp,ans)

print(ans)




Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
long long dp[102][100005];
int32_t main()
{
	int n,w;
	cin >> n >> w;
	vector<pair<int,int> > arr(n+1);
	for(int i=0;i<= n;i++)
		for(int j=1;j<=100003;j++)
			dp[i][j] = INT_MAX;
	for(int i=1;i<=n;i++)
	{
		cin >> arr[i].first >> arr[i].second;
	}
	for(int i = 1; i<= n ; i++)
	{
		dp[i][arr[i].second] = arr[i].first;
		for(int j = 1; j <= 100003 ;j++)
		{
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			if(j >= arr[i].second)
				dp[i][j] = min(dp[i][j],dp[i-1][j-arr[i].second]+arr[i].first);
		}
	}
	int ans = 0;
	for(int i=1;i<=100003;i++)
	{
		if(dp[n][i] <= w)
				ans = max(ans,i);
	}
	cout << ans;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;
lint gyaku(lint a, lint mod){
  lint s = 1, tmp = a, t = mod - 2;
  while(t > 0){
    if(t % 2 == 1){
      s *= tmp;
      s %= mod;
    }
    t /= 2;
    tmp *= tmp;
    tmp %= mod;
  }
  return s;
}
int main(){
  int n, m, k; cin >> n >> m >> k;
  v1li v(n+1, 1), u(n+1, 1), w(n+1, 1);
  rep(i, n){
    if(i == 0) v[i+1] = v[i] * m;
    else v[i+1] = v[i] * (m-1);
    v[i+1] %= mod2;
    u[i+1] = u[i] * (i+1);
    u[i+1] %= mod2;
    w[i+1] = w[i] * gyaku(i+1, mod2);
    w[i+1] %= mod2;
  }
  lint a = 0;
  for(int i = n-k; i <= n; ++i){
    lint t = v[i];
    t *= u[n-1];
    t %= mod2;
    t *= w[n-i];
    t %= mod2;
    t *= w[i-1];
    t %= mod2;
    a += t;
    a %= mod2;
  }
  cout << a << "\n";
  return 0;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int  n, m;

int main(){
	int i, j;
	string a, b , c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0];
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);// TODO 自動生成されたメソッド・スタブ
		int N = scn.nextInt();
		int MOD = 1000000007;
		long ans = 1;
		int[] num = new int[3];
		for(int i = 0;i < N;i++) {
			int A = scn.nextInt();
			int c = 0;
			for(int j = 0;j < 3;j++) {
				if(num[j]==A)c++;
			}
			ans *= c;
			ans %= MOD;
			for(int j = 0;j < 3;j++) {
				if(num[j]==A) {
					num[j]++;
					break;
				}
			}
			Arrays.sort(num);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 49540
import java.util.*;

class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    
	    int a = Integer.parseInt(sc.next());
	    int b = Integer.parseInt(sc.next());
	    
	    int sum_1 = a + a - 1;
	    int sum_2 = b + b - 1;
	    int sum_3 = a + b;
	    
	    int ans = Math.max(sum_1, Math.max(sum_2, sum_3));
	    
	    System.out.println(ans);
	}
}


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

int main(){
    int N;
    cin >> N;
    char S[N];
    long long r = 0;
    int g = 0;
    int b = 0;
    for (int l = 0; l < N; l++)
    {
        cin >> S[l];
        if (S[l] == 'R')
        {
            r++;
        } else if (S[l] == 'G')
        {
            g++;
        } else
        {
            b++;
        }

    }
    long long ans = 0;
    ans = r * g * b;

    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int k = 2 * j - i;
            if(k>=N || k<=j){
                continue;
            }
            if ((S[i] != S[j]) && (S[i] != S[k]) && (S[j] != S[k]))
            {
                ans = ans -1;
            }
            
        }
        
    }

    cout << ans << endl;
      
    return 0;
}

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

if R-L+1>=2019:
        print(0)
        exit()
else:
        List=[]
        for i in range(L,R+1):
                for j in range(L,R+1):
                        if i!=j:
                                List.append(i*j%2019)
        print(min(List))

Measured memory_bytes: 147620
N = input()
count = 0
prev = 0
for i in range(len(N)):
  if 0 <= int(N[i]) + prev < 5:
    count += int(N[i]) + prev
    prev = 0
  elif 6 <= int(N[i]) + prev <= 9:
    count += 10 - (int(N[i]) + prev)
    prev = 1
  elif int(N[i]) + prev == 10:
    prev = 1
  else:
    if (i < (len(N) - 1) and int(N[i+1]) < 5) or i == len(N) - 1:
      count += 5
      prev = 0
    else:
      count += 5
      prev = 1
count = count + prev
print(count)

Measured memory_bytes: 5492
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Yuan Lei
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task1001 solver = new Task1001();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task1001 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            int m = in.nextInt();
            int[] b = new int[m];
            for (int i = 0; i < m; ++i) {
                b[i] = in.nextInt();
            }
            Arrays.sort(a);
            Arrays.sort(b);
            int now = 0;
            for (int i = 0; i < m; ++i) {
                while (a[now] < b[i]) {
                    ++now;
                }
                if (a[now] > b[i]) {
                    out.println("NO");
                    return;
                } else {
                    ++now;
                }
            }
            out.println("YES");
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    final String line = reader.readLine();
                    if (line == null) return false;
                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }

        public String next() {
            if (hasNext()) return tokenizer.nextToken();
            return null;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

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; }

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int n,m,k;
int solve(){
    int ans=0;
    vi a(n),b(m);
    vl as(n+1),bs(m+1);
    int ai=0;
    int bi=0;
    rep(i,n){
        cin >> a[i];
        as[i+1] = as[i] + a[i];
    }
    rep(i,m){
        cin >> b[i];
        bs[i+1] = bs[i] + b[i];
        if(bs[i+1] <= k){
            bi=i+1;
        } 
    }
    for(ai; ai <= n; ai++){
        for(bi; bi >= 0; bi--){
            //cout << ai << " " << bi << endl;
            if(as[ai] + bs[bi] <= k){
                chmax(ans , ai+bi);
                break;
            }
        }
    }
    return ans;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    while(cin >> n >> m >> k){
        int ans = 0;
        cout << solve() << endl;
        //cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7928
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
        vector<string> vec(n);
        vector<int> depth(n,0);
        rep(i,n){
        cin >> vec[i];
          rep(j,vec[i].size()){
          if(vec[i][j] == '.' && vec[i][j+1] != '.'){
                vec[i][j] = '+';
                depth[i] = j+1;
                break;
          }
        }
          for(int j=i-1; j>=0; j--){
            if(depth[i] > depth[j]) break;
            if(depth[i] == depth[j]){
                for(int k=j+1; k<i; k++) vec[k][depth[j]-1] = '|';
                break;
            }
          }
        }
        rep(i,n){
          rep(j,vec[i].size()){
                if(vec[i][j] == '.') vec[i][j] = ' ';
          }
        }
        rep(i,n) cout << vec[i] << endl;
  }
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;

  int coin=0;
  for (int i=0; i<2; i++) {
    if (a>=b) {
      coin+=a;
      a--;
    } else {
      coin+=b;
      b--;
    }
  }

  cout << coin << endl;
}

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

using namespace std;

void usain_bolt()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int N = 1e3 + 5;

int dp[N][N];
char s[N][N];
int main()
{
    usain_bolt();

    int n, m;

    cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            cin >> s[i][j];
        }
    }
    dp[0][1] = 1;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(s[i][j] == '#') continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <assert.h>
#define int long long
using namespace std;
typedef long long ll;
const int maxk=101;
const int maxn=31624;
const int md=1e9+7;

int n,K;
int ans;
int f[2][maxn][maxk],g[maxn];
int f0sum[maxn],f1sum[maxn];

signed main(){
	cin>>n>>K;
	int lim=sqrt(n);
	int jed=lim*lim==n?lim-1:lim;
	for (int l=1,r;l<=n;){
		r=n/(n/l);
		if (r>lim&&n/l<=jed) g[n/l]=r-max(l,lim+1)+1;
		l=r+1;
	}

	for (int i=1;i<=lim;++i)
	f[0][i][1]=1;
	for (int i=1;i<=jed;++i)
	f[1][i][1]=g[i];

	for (int i=1;i<=lim;++i)
		f0sum[i]=(f0sum[i-1]+f[0][i][1])%md;
	for (int i=jed;i;--i)
		f1sum[i]=(f1sum[i+1]+f[1][i][1])%md;
	for (int k=2;k<=K;++k){
		for (int i=1;i<=lim;++i)
			f[0][i][k]=(f0sum[lim]+f1sum[i])%md;
		for (int i=1;i<=jed;++i)
			f[1][i][k]=1ll*f0sum[i]*g[i]%md;

		for (int i=1;i<=lim;++i)
			f0sum[i]=(f0sum[i-1]+f[0][i][k])%md;
		for (int i=jed;i;--i)
			f1sum[i]=(f1sum[i+1]+f[1][i][k])%md;

	}
	for (int i=1;i<=lim;++i)
		ans=(ans+f[0][i][K]+f[1][i][K])%md;
	cout<<ans<<endl;
}

Measured memory_bytes: 50944