akhauriyash/Code-Regression huggingface dataset:
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int t = 1;
		while (t-->0) {
		    int n = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
		    int[] ans = new int[n];
		    for (int i=1;i<=n ;i++ ){
		        for (int j=i+1;j<=n ;j++ ){
		            int p = Math.min(j-i,Math.abs(x-i)+1+Math.abs(j-y));
		            ans[p]++;
		        } 
		    } 
		    for (int i=1;i<n ;i++ ) System.out.println(ans[i]); 
		}
	}
	static ArrayList<Integer> key;
	static int n1;
	static void insert(int key1){
		key.add(key1);
		n1++;
		swim(n1);
	}
	static void swim(int k){
		while (k>1 && less(k/2, k)) {
			swap(k/2, k);
			k/=2;
		}
	}
	static int deleteMax(){
		int max = key.get(1);
		key.set(1,key.get(n1--));
		sink(1);
		key.remove(n1+1);
		return max;
	}
	static void sink(int k){
		while (2*k<=n1) {
			int j = 2*k;
			if (j<n1 && less(j,j+1)) {
				j++;
			}
			if (!less(k, j)) {
				break;
			}
			swap(k,j);
			k=j;
		}
	}
	static boolean less(int a, int b){
		return key.get(a)<key.get(b);
	}
	static void swap(int a, int b){
		int c=key.get(a);
		key.set(a,key.get(b));
		key.set(b,c);
	}
	static String getit(String s, String b){
	    StringBuilder temp=new StringBuilder(" ");
        temp.append(s);
        temp.append("#");
        temp.append(b);
	    int n = temp.length()-1;
	    String p = temp.toString();
	    int[] pi = new int[n+1];
	    pi[0] = -1;
	    int k = -1;
	    for (int i=1;i<=n ;i++ ){
	        while(k>=0 && p.charAt(k+1)!=p.charAt(i)) k = pi[k];
	        pi[i] = ++k;
	    } 
	    return s.substring(1,pi[n]);
	}
	static class Query {
		int x1, x2, y, id;
		public Query(int c, int d, int e, int a){
			x1 = c;
			x2 = d;
			y = e;
			id = a;
		}
	}
	static class Compare1 implements Comparator<Query>{
		@Override
		public int compare(Query q1, Query q2){
			if(q1.x2==q2.x2) return q1.x1-q2.x1;
			return q1.x2-q2.x2;
		}
	}
	static class Pair implements Comparable<Pair>{
		int a, b;
		public Pair(int c, int d){
			a = c;
			b = d;
		}
		public int compareTo(Pair p){
		    return a-p.a;
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}
		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll F(ll a,ll b){
	string s;stringstream ss;ss.clear();
	ss<<a;ss>>s;
	ll l=s.size();s="";ss.clear();ss<<b;ss>>s;
	return max(l,ll(s.size()));
}
int main(){
	ll a,b,i=0x3f3f3f3f,n;
	cin>>n;
	for(a=1;a<=sqrt(n);a++){
		if(n%a!=0){
			continue;
		}
		b=n/a;
		i=min(i,F(a,b));
	}
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
//#pragma warning(disable:4996)

#include <iostream>
#include <cstring>
using namespace std;

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

	char buff[10];
	sprintf(buff, "%d", N);

	int i;
	for (i = 0; i < strlen(buff); i++) {
		if (buff[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int N, p[2005];

int main() {
	scanf("%d", &N);
	for (int i = 2; i <= N; i++) {
		int ti = i;
		for (int j = 2; j <= i; j++) {
			while (ti % j == 0) {
				p[j]++;
				ti /= j;
			}
		}
	}
	long long ans = 1;
	for (int i = 2; i <= N; i++) {
		ans *= p[i] + 1;
		ans %= MOD;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    string a, b;
    cin>>a>>b;
    int n=a.length(), m=b.length();
    int i=0;
    for (i=0;i<min(n, m);i++)
    {
        cout<<a[i]<<b[i];
    }
    if (i<n)
    {
        cout<<a[i];
    }
    if (i<m)
    {
        cout<<b[i];
    }
    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
int main(){
  int n,a,b,x,y;
  scanf("%d%d%d",&n,&a,&b);
  if(a<=b)x=a;
  else x=b;
  if(n<a+b)y=a+b-n;
  else y=0;
  printf("%d %d",x,y);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    magic_count = 0
    previous_slime = a[0]

    # See:
    # https://beta.atcoder.jp/contests/agc026/submissions/2841276
    for i in range(1, n):
        if a[i] == previous_slime:
            magic_count += 1
            previous_slime = -1
        else:
            previous_slime = a[i]

    print(magic_count)


Measured memory_bytes: 3064
#include <queue>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const vector<int> dir = { 1, 0, -1, 0 };
int H, W; string s[109][109];
int main() {
	while (cin >> W >> H, H | W) {
		int sx, sy, gx, gy, cnt = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> s[i][j];
				if (s[i][j] == "S") sx = j, sy = i;
				if (s[i][j] == "G") gx = j, gy = i;
				if (isdigit(s[i][j][0])) cnt = max(cnt, stoi(s[i][j]));
			}
		}
		vector<vector<int> > px(cnt + 2), py(cnt + 2);
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int val = -1;
				if (s[i][j] == "S") val = 0;
				if (s[i][j] == "G") val = cnt + 1;
				if (isdigit(s[i][j][0])) val = stoi(s[i][j]);
				if (val >= 0) {
					px[val].push_back(j);
					py[val].push_back(i);
				}
			}
		}
		vector<vector<int> > dp(cnt + 2);
		dp[0] = { 0 };
		for (int i = 1; i <= cnt + 1; i++) {
			dp[i].resize(px[i].size(), 999999999);
			for (int j = 0; j < dp[i].size(); j++) {
				for (int k = 0; k < dp[i - 1].size(); k++) {
					int dist = abs(px[i][j] - px[i - 1][k]) + abs(py[i][j] - py[i - 1][k]);
					dp[i][j] = min(dp[i][j], dp[i - 1][k] + dist);
				}
			}
		}
		cout << dp[cnt + 1][0] << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
  cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
}

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

int main(){
  string s;
  char op[3];
  int n[4],sum;
  cin>>s;
  rep(i,4){
    n[i]=s[i]-'0';
  }
  rep(i,(1<<3)){
    sum=n[0];
    rep(j,3){
      if(i&(1<<j)){
        op[j]='-';
        sum-=n[j+1];
      }else{
        op[j]='+';
        sum+=n[j+1];
      }
    }
    if(sum==7){
      break;
    }
  }
  cout<<n[0];
  rep(i,3){
    cout<<op[i]<<n[i+1];
  }
  cout<<"=7"<<endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();
		if( S.equals(U) ){
			System.out.println((A-1)+" "+B);
		}else{
			System.out.println(A+" "+(B-1));
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>

int main(void){
  int n,an;
  long int dd,dxy,x,y,d;
  an=0;
  scanf("%d %ld", &n, &d);
  dd = d*d;
  for(int i=0;i<n;i++){
    scanf("%ld %ld", &x, &y);
    dxy = x*x+y*y;
    if(dxy<=dd){
      an++;
    }
  }
  printf("%d", an);
  
  return 0;
}

Measured memory_bytes: 1732
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

m = min([A,B,C,D,E])
if N%m ==0:
  ad = (N//m)-1
else:
  ad = (N//m)
print(ad+5)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(),x.end()
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n, m;
   cin >> n >> m;
   vector<ll> A, B;
   //Bは累積和
   rep(i,n){
      int x;
      cin >> x;
      A.push_back(-x);
   }
   sort(all(A));
   B.push_back(0);
   rep(i,n)B.push_back(A[i]);
   rep(i,n)B[i+1]+=B[i];
   ll l = -2e5-1, r = -1;
   ll ans = 0;
   while(true){
      ll mid = (l+r)/2;
      ll cnt = 0;
      rep(i,n){
         cnt += upper_bound(all(A),mid-A[i])-A.begin();
      }
      if (r-l<=1){
         rep(i,n){
            int idx = upper_bound(all(A),mid-A[i])-A.begin();
            ans -= B[idx] + A[i]*idx;
         }
         ans -= mid * (m-cnt);
         break;
      }
      else if(cnt < m) l = mid;
      else r = mid;
   }
   cout << ans << endl;
}

Measured memory_bytes: 5516
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          char[] s = Input.ScanStr().ToCharArray();
          int n=0;
          for(int i=0;i<4;i++) if(s[i]=='+') n++; else n--;
          Console.WriteLine(n);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S+1;

    n = strlen(S+1);

    if(n&1){
        cout<<"No\n";
        return 0;
    }

    bool judge = true;

    for(int i=1;i<=n;i++){
     if(i&1)judge&=(S[i]=='h');
     else judge&=(S[i]=='i');
    }

    if(judge)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    if (abs(x - a) > abs(x - b))
    {
        cout << "B" << endl;
    }
    else
    {
        cout << "A" << endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll N,A[100010],a=0;

int main(void){
	cin>>N;
	rep(i,N)cin>>A[i];
	sort(A,A+N);
	irep(i,N-1){
		if(A[i]==A[i+1]){
			if(a==0){
				a=A[i];
				i--;
			}else{
				a *= A[i];
				break;
			}
		}
	}
	printf("%lld\n", a);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
pll a[N];
int n;
ll ans[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i].first);
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	a[n].first = 0;
	int m = n;
	for (int i = 1; i <= n; i++) {
		m = min(m, (int)a[i - 1].second);
		ans[m] += (a[i - 1].first - a[i].first) * i;
	}
	for (int i = 0; i < n; i++)
		printf("%lld\n", ans[i]);

	return 0;
}


Measured memory_bytes: 3456
n, k = (int(i) for i in input().split())
 
a = [int(i) for i in input().split()]
 
dic = {}
 
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
 
ans_num= len(dic)-k
ans = 0
 
 
if ans_num <= 0:
    ans *= 0 
else:
    sort = sorted(dic.items(), key=lambda x:x[1])
    for i in range(ans_num):
        ans += sort[i][1]
 
print(ans)


Measured memory_bytes: 39044
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		System.out.println((getInt()+getInt())/2);
	}
}

Measured memory_bytes: 26220
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
using std::swap;
int main() {
    int n;cin>>n;
    V vec(n+1);
    int c=0;
    rep(i,n)cin>>vec[i];
    V reg;
    rep(i,n){
        if(i+1==vec[i]){
            c++;
            swap(vec[i],vec[i+1]);
        }
    }
    cout<<c<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    ll index = 0;
    vector<pair<ll, ll>> A;
    cin >> N >> K;
    A.resize(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        A[i] = pair<ll, ll>{a, b};
    }
    sort(A.begin(), A.end(), [](pair<ll, ll> a, pair<ll, ll> b) { return a.first < b.first; });
    iter(i, A) {
        index += i.second;
        if(index >= K) {
            cout << i.first << endl;
            break;
        }
    }
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    ll l, r; cin >> l >> r;

    ll ans = 2018;
    for(ll i = l; i < r; i++){
        for(ll j = i + 1; j <= r; j++){
            ans = min(ans, (i * j) % 2019);
            if(ans == 0){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
void bf(int n){
	int a[n] = {};
	for(int i=1;i<=n;i++){
		a[i-1] = i;
	}
	int b[n];
	int mx = 0;
	int sm;
	do{
		sm = 0;
		for(int i=0;i<n;i++){
			sm+=(i+1)%a[i];
		}
		if(sm>=mx){
			mx = sm;
			for(int i=0;i<n;i++)b[i] = a[i];
		}
	}while(next_permutation(a,a+n));
	cout<<"SOL FOR "<<n<<" IS "<<mx<<endl;
	for(int i=0;i<n;i++){
		cout<<b[i]<<" ";
	}
	cout<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n; 
	cin>>n;
	ll ans = n*(n-1);
	ans = ans/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*Divyam Goyal - IIT-BHU*/
#include<bits/stdc++.h>
using namespace std;

#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define bitcount    __builtin_popcountll
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define pb(x) push_back(x)
#define MOD 1000000007
#define MAX 100005



int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;

	for(int i=1;i<=3500;i++)
	{
		for(int j=i;j<=3500;j++)
		{

			ll x = 1ll*4*i*j-1ll*n*(i+j);
			ll y = 1ll*n*i*j;

			ll k = __gcd(x,y);

			x=x/k;
			y=y/k;

			if(x==1&&y>0)
			{
				cout<<i<<" "<<j<<" "<<y<<"\n";
				return 0;
			}
		}
	}





    return 0;


}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>

using namespace std;

const int M = 512;
const int L = 100000;

int main()
{
    int n; scanf("%d", &n);

    vector<int> v(n + 1), w(n + 1);
    static int m[M][L+1];

    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &v[i], &w[i]);
        if (i >= M) continue;

        for (int j = 0; j < w[i]; j++) {
            m[i][j] = m[i / 2][j];
        }
        for (int j = w[i]; j <= L; j++) {
            m[i][j] = max(m[i / 2][j], m[i / 2][j - w[i]] + v[i]);
        }
    }

    int q; scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        int u, l; scanf("%d%d", &u, &l);
        int ans = 0;
        int bits = 0;
        while ((u >> bits) >= M)
            ++bits;
        const int t = u >> bits;
        for (int j = 0; j < (1 << bits); j++) {
            int vv = 0, ww = 0;
            for (int k = 0; k < bits; k++) {
                if ((j >> k) & 1) {
                    vv += v[u >> k];
                    ww += w[u >> k];
                }
            }
            if (ww > l) continue;
            ans = max(ans, vv + m[t][l - ww]);
        }
        printf("%d\n", ans);
    }

    return 0;
}


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

const int N = 1e3;
bool f[N][N];
bool used[N];
int match[N];
int n,m,e;
int a[N],b[N],c[N],d[N];
bool DFS(int pos)
{
    for(int i=1; i<=m; i++)
    {
        if(f[pos][i] && !used[i])
        {
            used[i] = true;
            if(!match[i] || DFS(match[i])) 
            {
                match[i] = pos;
                return true;
            }
        }
    }
    return false; 
}

int main()
{
    int i,j;
	cin>>n;
    for(i=1;i<=n;i++)
    {
    	scanf("%d%d",&a[i],&b[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&c[i],&d[i]);
	}
	m=n;
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
	if(a[i]<c[j]&&b[i]<d[j])
	f[i][j]=true;
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        memset(used,false,sizeof(used)); 
        if(DFS(i)) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= i
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()

Measured memory_bytes: 21672
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <functional>

struct edge
{
  int to;
  long long cost;
};
std::vector<edge> edges[100000];
  
int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i)
  {
    edges[i].emplace_back(edge{i - 1, 0});
  }
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    long long c;
    scanf("%d%d%lld", &a, &b, &c);
    --a, --b;
    edges[a].emplace_back(edge{b, c}); 
  }
  long long dist[100000];
  using pair = std::pair<long long, int>;
  std::fill(dist, dist + n, 1e18);
  dist[0] = 0;
  std::priority_queue<pair, std::vector<pair>, std::greater<pair>> q;
  q.emplace(0, 0);
  while (q.size() > 0)
  {
    auto p = q.top(); q.pop();
    if (p.first > dist[p.second]) continue;
    for (const auto& e : edges[p.second])
    {
      long long next = p.first + e.cost;
      if (dist[e.to] > next)
      {
        dist[e.to] = next;
        q.emplace(next, e.to);
      }
    }
  }
  printf("%lld\n", dist[n - 1] == 1e18 ? -1 : dist[n - 1]);
  return 0;
}

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

int main(){
  long long N; cin >> N;
  vector<vector<long long>> AB(N,vector<long long>(3));
  for (int i=0; i<N; i++) {
    cin >> AB[i][0] >> AB[i][1];
    AB[i][2] = AB[i][0]+AB[i][1];
  }
  sort(AB.begin(), AB.end(), [](const auto& a, const auto& b){return a[2]>b[2];});
  long long ans = 0;
  for (int i=0; i<N; i++){
    if (i%2==0) ans += AB[i][0];
    else ans -= AB[i][1];
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin>>n;
  string s[n];
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  int m;
  cin>>m;
  string t[m];
  for(int i=0;i<m;i++){
    cin>>t[i];
  }
  int res=0;
  sort(s,s+n);
  sort(t,t+m);
  for(int i=0;i<n;i++){
    int temp=0;
    if(i==0){
      for(int j=0;j<n;j++){
        if(s[j]==s[i]) temp++;
        else break;
      }
      for(int j=0;j<m;j++){
        if(t[j]==s[i]) temp--;
      }
      if(temp>res) res=temp;
    }
    else if(s[i]==s[i-1]) continue;
    else {
      for(int j=i;j<n;j++){
        if(s[j]==s[i]) temp++;
        else break;
      }
      for(int j=0;j<m;j++){
        if(t[j]==s[i]) temp--;
      }
      if(temp>res) res=temp;
    }
  }
  cout<<res<<endl;
  return 0;
}

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

void dfs(int cur);

int A[100][100], d[100], f[100];;
int n,t=0;

int main()
{
    	cin>>n;
        
    	for(int i=0;i<n;++i){

		d[i]=0;
		f[i]=0;

        	for(int j=0;j<n;++j){
            		A[i][j]=0;
        	}
        
        	int m,k; //k=number of adj
        	cin>>m>>k;
        	assert(m==i+1);
        
        	for(int j=0;j<k;++j){
            		int adj;
            		cin>>adj;
            		if(adj){
                		A[i][adj-1]=1;
            		}
        	}
    	}

	/*
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	*/

	for(int i=0;i<n;++i){
		if(d[i]==0) dfs(i);
	}

	for(int i=0;i<n;++i){
		cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
	}

    	return 0;
}

void dfs(int cur)
{
	t+=1;
	d[cur]=t;
	//cout<<"visiting "<<cur+1<<" "<<t<<endl;

	for(int dst=0;dst<n;++dst){
		if(A[cur][dst]==1&&d[dst]==0){
			dfs(dst);
		}
	}

	t+=1;
	f[cur]=t;

	//cout<<"leaving "<<cur+1<<" "<<t<<endl;

	return;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> vec(n);
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        vec[i] = make_pair(a, b);
    }

    sort(all(vec));

    /*
    rep(i,n){
        cout << vec[i].first << " " << vec[i].second << endl;
    }
    */

    priority_queue<ll> que;

    ll ans = 0;
    ll tmp = 0;
    rep(i,m){

        for(ll j = tmp; j < n; j++){
            if(vec[j].first == (i+1)){
                que.push(vec[j].second);
            }else{
                tmp = j;
                break;
            }
        }
        
        if(!que.empty()){
            ans += que.top();
            que.pop();
        } 
    }

    cout << ans << endl;

}

Measured memory_bytes: 2936
# https://atcoder.jp/contests/abc111/tasks/arc103_a

import sys
# sys.setrecursionlimit(100000)
from collections import Counter


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    V = input_int_list()
    cnt = n // 2
    even = Counter(V[0::2]).most_common()
    odd = Counter(V[1::2]).most_common()
    if even[0][0] != odd[0][0]:
        ans = (cnt) - even[0][1] + (cnt) - odd[0][1]
    else:
        if len(even) > 1 and len(odd) > 1:
            ans = min(cnt - even[0][1] + cnt - odd[1][1], cnt - even[1][1] + cnt - odd[0][1])
        elif len(even) == 1 and len(odd) == 1:
            ans = cnt
        elif len(even) == 1 and len(odd) > 1:
            ans = min(cnt - odd[1][1])
        elif len(odd) == 1 and len(even) > 1:
            ans = min(cnt - even[1][1])
    print(ans)

    return


if __name__ == "__main__":
    main()


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

using namespace std;

const int N = 1e5 + 10;

int dp[N];
int nums[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	dp[1] = 0;
	dp[2] = abs(nums[1] - nums[2]);
	for(int i = 3; i <= n; i++) {
		dp[i] = min(dp[i-1] + abs(nums[i] - nums[i-1]), dp[i-2] + abs(nums[i] - nums[i-2]));
	}
	cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>

using namespace std;

typedef long long int LL;
typedef pair<int, int> PII;

int main(void) {
  LL N, M;
  LL cnt = 0;
  cin >> N >> M;


  if (2 * N <= M) {
    cnt += N;
    M -= (2 * N);
    cnt += (M / 4);
    cout << cnt << endl;
  } else {
    cnt += (M /2);
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

a_n = 0
b_n = 0
for i in range(N):
    if S[i] == "a":
        if a_n < A+B:
            a_n += 1
            print("Yes")
        else:
            print("No")
    elif S[i] == "b":
        if a_n < A+B and b_n < B:
            a_n += 1
            b_n += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
        

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

struct cake {
    int w, d;
    bool operator<(const cake& other) const {
        return area() < other.area();
    }
    int area() const {
        return w * d;
    }
};

int main() {
    int n, w, d;
    while(cin >> n >> w >> d, n || w || d) {
        vector<cake> cs = {cake{w, d}};
        for(int i = 0; i < n; ++i) {
            int p, s;
            cin >> p >> s;
            p--;
            s %= (cs[p].w + cs[p].d);
            cake c1, c2;
            if(s < cs[p].w) {
                c1 = cake{s, cs[p].d};
                c2 = cake{cs[p].w - s, cs[p].d};
            } else {
                s -= cs[p].w;
                c1 = cake{cs[p].w, s};
                c2 = cake{cs[p].w, cs[p].d - s};
            }
            if(c1.area() > c2.area()) {
                swap(c1, c2);
            }
            cs.push_back(c1), cs.push_back(c2);
            cs.erase(begin(cs) + p);
        }
        sort(begin(cs), end(cs));
        const int m = cs.size();
        for(int i = 0; i < m; ++i) {
            cout << cs[i].area() << " \n"[i + 1 == m];
        }
    }
}



Measured memory_bytes: 3156
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        N=Integer.parseInt(br.readLine().trim());
        String s[]=br.readLine().trim().split(" ");
        int a[]=new int[N];
        for(i=0;i<N;i++) a[i]=Integer.parseInt(s[i]);
        
        int count=0;
        for(i=0;i<N;i+=2) if(a[i]%2==1) count++;
        System.out.println(count);

    }
}

Measured memory_bytes: 32496
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using P = pair<int, int>;
const int mod = 1e9+7;

vector<bool> broken(100010, false);

const int INF = 1e9;
vector<ll> dp(100010,-1);

int rec(int i){
    if (dp[i] != -1) return dp[i];
    if (i == 0) return dp[0] = 1;
    int res = 0;
    if (!broken[i-1]) res += rec(i-1);
    if (i > 1 && !broken[i-2]) res += rec(i-2);
    return dp[i] = res % mod;
}


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

    rep(i,m){
        int x;
        cin >> x;
        broken[x] = true;
    }

    cout << rec(n) << endl;
    // rep(i,n+1){
    //     printf("%d ", dp[i]);
    // }
    // printf("\n");
    return 0;
}


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

int main(){
  long long int n,m=2;
  int ch=1;
  cin >> n;
  vector<int> ans;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  while(n!=0){
    if(n%m==0)ans.push_back(0);
    else {
      ans.push_back(1);
      n-=ch*m/2;
    }
    m*=2;
    ch*=-1;
  }
  int i=ans.size();
  i--;
  for(;i>-1;i--){
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


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

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <cstdio>

#define fol(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int a,b,ans;
    cin >>a>>b;
    ans = a-b <= 0 ? 0:a-b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 1e5;

int n;
int s[MaxN + 5];
int main() 
{
	while(scanf("%d", &n) != EOF)
	{
		for(int i = 1; i <= n; i++) {
			int l, r;
			scanf("%d %d", &l, &r);
			bool f = 1;
			for(int j = l; j <= r; j++)
				if(s[j] > 0)
					f = 0;
			if(f == 1)
				for(int j = l; j <= r; j++)
					s[j] = 1;
		}
		int ans = 0;
		for(int i = 1; i <= MaxN; i++)
			if(s[i] == 1)
				ans++;
		printf("%d\n", ans);
		memset(s, 0, sizeof(s));
	}
	return 0;
}

Measured memory_bytes: 512
fn main() {
    let (n, mut h) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let n: i32 = ws.next().unwrap().parse().unwrap();
        let h: i32 = ws.next().unwrap().parse().unwrap();
        (n, h)
    };

    let mut v = Vec::new();
    let mut max_a = 0;

    for _ in 0..n {
        let (a, b) = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s = s.trim_right().to_owned();
            let mut ws = s.split_whitespace();
            let a: i32 = ws.next().unwrap().parse().unwrap();
            let b: i32 = ws.next().unwrap().parse().unwrap();
            (a, b)
        };

        max_a = std::cmp::max(max_a, a);
        v.push(b);
    }

    v.sort_by(|a, b| b.cmp(a));

    let mut ans = 0;

    for e in v {
        if h <= 0 {
            break;
        }

        if e > max_a {
            h -= e;
            ans += 1;
        } else {
            break;
        }
    }

    if h > 0 {
        ans += h / max_a;
        ans += if h % max_a == 0 {
            0
        } else {
            1
        };
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{
    public static boolean[] num;
	public static int n,k,s;
    public static int check(int a,int b,int c){
        if(b<0){
            return 0;
        }
        else if(a==1){
            if(b<=n){
                if(num[b]==true&&b>c){
                    return 1;
                }
                else{
                    return 0;
                }
            }
            else{
                return 0;
            }
        }
        else{
            int tmp=0;
            for(int i=1;i<=n;i++){
                if(num[i]==true&&i>c){
                    num[i]=false;
                    tmp+=check(a-1,b-i,i);
                    num[i]=true;
                }
            }
            return tmp;
        }
    }
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            n=sc.nextInt();
			k=sc.nextInt();
            s=sc.nextInt();
			if(n!=0||k!=0||s!=0){
				num=new boolean[n+1];
				for(int i=0;i<=n;i++){
					num[i]=true;
				}
				System.out.println(check(k,s,0));
			}
            else{
                break;
            }
        }
    }
}


Measured memory_bytes: 27736
h, w = map(int, input().split())
A = []
A.append("."*(w+2))
for i in range(h):
  A.append(list("." + input() + "."))
A.append("."*(w+2))
f = True
for i in range(1, h+1):
  for j in range(1, w+1):
    if A[i][j] == "#" and A[i+1][j] == "." and A[i-1][j] == "." and A[i][j+1] == "." and A[i][j-1] == ".":
      f = False
if f:print("Yes")
else: print("No")

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

using namespace std;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    int a[n];
    memset(a, 0, sizeof a);
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int d = min(abs(j - i), abs(x - i) + 1 + abs(y - j));
            a[d]++;
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << a[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ABC_practice
{
    public class Program
    {

        #region templete

        private static void WL(string s) { WriteLine(s); }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
        /// <summary>
        /// 最小公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }

        static void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
        static void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

        public static void Main(string[] args)
        {
            new Program().Solve();
            ReadLine();
        }

        #endregion

        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var a = "CODEFESTIVAL2016";
            var ans = 0;

            for (int i = 0; i < a.Length; i++)
                if (s[i] != a[i]) ans++;

            WL($"{ans}");

        }
    }
}


#region console in

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

#endregion

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

int64_t sum(int64_t n){
  return n*(n+1)/2;
}

int main(){
  string S;
  cin >> S;
  int64_t ans = 0;
  int a = 0;
  int b = 0;
  if(S.at(0) == '>'){
    while(S.at(a) == '>'){
      a++;
      if(a == S.size()){
        break;
      }
    }
    ans += sum(a);
    b = a;
  }
  int64_t left = 0;
  int64_t right = 0;
  for(int i=b; i<S.size(); i++){
    if(S.at(i) == '<' && right == 0){
      left++;
    }
    else if(S.at(i) == '<'){
      if(left >= right){
        ans += sum(left) + sum(right-1);
      }
      else{
        ans += sum(left-1) + sum(right);
      }
      left = 1;
      right = 0;
    }
    else{
      right++;
    }
  }
  
 if(left > 0 && right > 0){
      if(left >= right){
        ans += sum(left) + sum(right-1);
      }
      else{
        ans += sum(left-1) + sum(right);
      }
  }
  else if(left > 0){
    ans += sum(left);
  }
  cout << ans << endl; 
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int x, y, z, k;
    cin>>x>>y>>z>>k;
    ll a[x], b[y], c[z];
    vector<ll> d;
    f(i, x) cin>>a[i];
    f(i, y) cin>>b[i];
    f(i, z) cin>>c[i];
    f(i, x){
        f(j, y) d.pb({a[i] + b[j]});
    }
    rs(d);
    int to = k;
    k = min(k, x * y);
    vector<ll> ans;
    f(i, k){
        f(j, z){
            ans.pb({d[i] + c[j]});
        }
    }
    rs(ans);
    f(i, to) cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 43364
N = int(input())

i = 0
A = input().split()
ans = 'APPROVED'

while i < N:
  a = A[i]
  if int(a) % 2 == 0:
    if not ((int(a) % 5 == 0) or (int(a) % 3 ==0)):
      ans = 'DENIED'

  if ans == 'DENIED':
    break

  i += 1

print(ans)

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

int main() {
int n,a,b,c,d;
    cin >> n >> a;
    if(n%500 == 0){
        cout << "Yes" << endl;
    }
    else {
        c = n/500;
        b = n -c*500;

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

Measured memory_bytes: 256
#include<stdio.h>


int main(){
  int i,a,b,ab,o;
  char str[3];
  a=b=ab=o=0;
  while(scanf("%d,%s",&i,str)!=EOF){
    if(str[0]=='A'){
      if(str[1]=='B') ab++;
      else a++;
    }else if(str[0]=='B'){
      b++;
    }else{
      o++;
    }
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
    
#define sz(x) (int) (x).size()
#define INF 0x3f3f3f3f
#define pb push_back
    
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
    
const int N = 100005;
const int mod = 1000000007;

vector<int> grafo[N];
vector<int> rec;
bool vis[N];

void dfs(int x) {
    vis[x] = true;
    for (int v: grafo[x])
        if (!vis[v]) dfs(v);
    rec.pb(x);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, a, b;
    cin >> n >> m;
    while (m--) {
        cin >> a >> b;
        grafo[a].pb(b);
    }
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) dfs(i);
    }
    int ans = 0;
    vector<int> dp(n + 1);
    for (int x: rec) {
        for (int v: grafo[x])
            dp[x] = max(dp[x], dp[v] + 1);
        ans = max(ans, dp[x]);
    }
    cout << ans << "\n";

    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

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

int main(){
  string S,T;
  cin>>S>>T;
  int sum=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      sum++;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3908
n, m = map(int, input().split())
A = [[] for i in range(n)]
b = [[0] * 1 for j in range(m)]

for i in range(n):
  A[i] = list(map(int, input().split()))

for j in range(m):
  b[j] = int(input())
 

for i in range(n):
  c = 0
  for j in range(m):
    c += A[i][j] * b[j]
  print(c)




Measured memory_bytes: 6028