akhauriyash/Code-Regression huggingface dataset:
/* Focus your enery towards light */

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define ford(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define inf 1e18

/******************************************************************************************************/
void file() {
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}
/******************************************************************************************************/

// const ll nax = 2e5 + 1;
// const ll mod = 1e9 + 7;



int main() {

    sync

    int testCases = 1;
    // cin >> testCases;

    while (testCases--) {
        int l, r, d;
        cin >> l >> r >> d;
        int ans = (r / d) - ((l - 1) / d);
        cout << ans;
    }
    return 0;
}

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

using namespace std;

#define rep(i,x) for (int i = 0 ; i < x; ++i)
#define rrep(i,x) for (int i = x - 1; i >= 0; --i)
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sqr(x) ((x) * (x))
#define re return

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


void GO(){
#ifdef DOD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int INF = 1e9 + 1;
const ll mod = 1e9 + 7;






//Var
//
 void input() {
     int a; cin >> a;
     cout << a + a * a + a * a * a;
 }

void solve(){
     
}








///Я призер Всеросса
int main() {
    GO();
    int Q = 1;
    while(Q--){ input(); solve(); } re 0;
}
///Я Кондедат в мастера


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int m, n, k;
string b[1010];
int c[100100][4];

// 1 base, 2D
template<typename T, int max_h, int max_w>
class BIT {
private:
    T bit[max_h+1][max_w+1];
    int h, w;
public:
    BIT(int _h = max_h, int _w = max_w) {
        h = _h;
        w = _w;
        memset(bit, 0, sizeof(bit));
    }
    // [1, y] * [1, x]
    T sum(int y, int x) {
        T s = 0;
        for (int i = y; i > 0; i -= i & -i)
            for (int j = x; j > 0; j -= j & -j)
                s += bit[i][j];
        return s;
    }
    // [y0, y1] * [x0, x1]
    T sum(int y0, int x0, int y1, int x1) {
        return sum(y1, x1) - sum(y0-1, x1) - sum(y1, x0-1) + sum(y0-1, x0-1);
    }

    void add(int y, int x, T v) {
        for (int i = y; i <= h; i += i & -i)
            for (int j = x; j <= w; j += j & -j)
                bit[i][j] += v;
    }
};

void solve() {
    BIT<int, 1010, 1010> bit_j;
    BIT<int, 1010, 1010> bit_o;
    BIT<int, 1010, 1010> bit_i;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (b[i][j] == 'J') {
                bit_j.add(i+1, j+1, 1);
            } else if (b[i][j] == 'O') {
                bit_o.add(i+1, j+1, 1);
            } else {
                bit_i.add(i+1, j+1, 1);
            }
        }
    }
    for (int i = 0; i < k; i++) {
        cout << bit_j.sum(c[i][0], c[i][1], c[i][2], c[i][3]) << " "
             << bit_o.sum(c[i][0], c[i][1], c[i][2], c[i][3]) << " "
             << bit_i.sum(c[i][0], c[i][1], c[i][2], c[i][3]) << endl;
    }
}

void input() {
    cin >> m >> n >> k;
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < k; i++)
        for (int j = 0; j < 4; j++)
            cin >> c[i][j];
}

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

    input();
    solve();
}



Measured memory_bytes: 17632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string s;

string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

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

  cin >> s;
  int d = find(day, day+7, s) - day;
  cout << 7-d << "\n";
  return 0;
}

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

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  
  // Represents the linear function as kx + b
  vector<long long> dk(m * 2), db(m * 2); 
  for (int i = 0; i < n - 1; i++) {
    int s = a[i] - 1, t = a[i + 1] - 1;
    if (s > t) t += m;
    
    dk[s + 1]--;
    dk[t + 1]++;
    db[s + 1] += s + 1;
    db[t + 1] -= s + 1;
  }

  long long y = 0;
  for (int i = 0; i < n - 1; i++)
    if (a[i] < a[i + 1])
      y += a[i + 1] - a[i];
    else
      y += a[i + 1] - a[i] + m;

  vector<long long> dy(m);
  long long k = 0, b = 0;
  for (int i = 0; i < m * 2; i++) {
    k += dk[i];
    b += db[i];

    dy[i % m] += k * i + b;
  }

  long long ans = y;
  for (int i = 0; i < m; i++)
    ans = min(ans, y + dy[i]);
  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 4480
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();

    int ans = 1;
    int odd = 1;

    for (int i = 0; i != n; ++i) {
        int v = input<int>();
        ans *= 3;

        if (v % 2 == 0)
            odd *= 2;
        else
            odd *= 1;
    }

    cout << ans - odd << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll d;
cin >> d;
vector<ll> contest_variety(26,0);
vector<ll> c(26,0);
rep(i,26){
    cin >> c[i];
}
vector<vector<ll>> calender(d,vector<ll> (26,0));
rep(i,d){
    rep(j,26){
        cin >> calender[i][j];
    }
}

vector<ll> choose(d);

ll ans = 0;
vector<ll> tmp_minus(26,0);
rep(i,d){
    ll tmp = ans;
    ll minus_sum = 0;
    rep(j,26) {
        tmp_minus[j] = c[j] * (i + 1 - contest_variety[j]);
        minus_sum += tmp_minus[j];
    }
    ll ind = 0;
    ll tmp_max = ans;
    rep(j,26){
       if(tmp_max < tmp - minus_sum + tmp_minus[j] + calender[i][j]){
           ind = j;
           tmp_max = tmp - minus_sum + tmp_minus[j] + calender[i][j];
       }
    }
    cout << ind + 1 << endl;
    ans = tmp_max;
    contest_variety[ind] = i + 1;
}
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(20)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n, a;
	cin >> n;
	mii mp;
	rep(i, 0, n - 2) {
		cin >> a;
		mp[a]++;
	}
	rep(i, 1, n) {
		cout << mp[i] << "\n";
	}
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

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

using namespace std;

int main()
{
    int m;
    
    scanf("%d", &m);
    
    while (m--){
        set<string> s;
        string st;
        char tmp[128];
        
        scanf("%s", tmp);
        
        st = (string)tmp;
        
        for (int i = 0; i < st.size() - 1; i++){
            for (int j = i + 1; j < st.size(); j++){
                string u = st.substr(0, i + 1), v = st.substr(i + 1, st.size() - i - 1);
                string ur = u, vr = v;
                reverse(ur.begin(), ur.end()); reverse(vr.begin(), vr.end());
                s.insert(u + v); s.insert(v + u);
                s.insert(u + vr); s.insert(vr + u);
                s.insert(ur + v); s.insert(v + ur);
                s.insert(ur + vr); s.insert(vr + ur);
            }
        }
        
        printf("%d\n", s.size());
    }
    
    return (0);
}

Measured memory_bytes: 1316
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
 
n = int(input())
a = list(map(int,input().split()))
 
b = [a[0]]
c = [a[-1]]
 
for i in range(1,n):
     j = n-1-i
     b.append(gcd(b[-1],a[i]))
     c.append(gcd(c[-1],a[j]))
     
ans = max(b[-2],c[-2])
for i in range(n):
     ans = max(ans,gcd(b[i],c[n-3-i]))
print(ans)

Measured memory_bytes: 14436
using System;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Array.ConvertAll(System.Console.ReadLine().Split(' '), int.Parse);
            for(int i=0;i<5;i++)
            {
                if(n[i]==0)
                {
                    System.Console.WriteLine(i + 1);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m,c,j,i;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  for(i = 0;i<m;i++){
    cin >> b[i];
  }
  for(i = 0;i<n;i++){
    for(j = 0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int ans = 0;
  int tmp = 0;
  for(i = 0;i<n;i++){
    tmp = 0;
    for(j = 0;j<m;j++){
      tmp += a[i][j] * b[j];
    }
    tmp += c;
    if(tmp > 0){
      ans++;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
n = gets.to_i
a = b = 0
ary = []

n.times do
    s = gets.chomp

    i = j = 0
    s.each_char do |c|
        if c == ?(
            i += 1
        elsif i == 0
            j += 1
        else
            i -= 1
        end
    end

    if j == 0
        a += i
    elsif i == 0
        b += j
    else
        ary << [j, i]
    end
end

ary.sort_by!{|e| e[0] - e[1]}.each do |e|
    a -= e[0]
    break if a < 0
    a += e[1]
end

puts a == b ? "Yes" : "No"

Measured memory_bytes: 34000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <cstring>
#define N 200005
struct edge {
    int next, link;
} e[N * 2];
int n, m, x, y, z, tot, head[N], visit[N];
int ans, num, sum;

void add(int u,int v) {
    e[++tot].link = v;
    e[tot].next = head[u];
    head[u] = tot;
}

void DFS(int k) {
    num++;
    visit[k] = 1;
    for (int i = head[k]; i; i = e[i].next) 
        if (e[i].link != 0 && !visit[e[i].link]) DFS(e[i].link);
}
int main() {
    scanf("%d%d",& n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d",& x,& y,& z);
        add(x, y);
        add(y, x);
    }
    memset(visit, 0, sizeof(visit));
    ans = sum = 0;
    for (int i = 1; i <= n; i++)
        if (visit[i] == 0) {
            num = 0;
            DFS(i);
            sum += num;
            ans++;
        }
    printf("%d", ans + n - sum);
    return 0;
}

Measured memory_bytes: 5504
import std.algorithm,
       std.string,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int   N = readln.chomp.to!int;
  int[] s = N.iota.map!(_ => readln.chomp.to!int).array;
  sort!"a<b"(s);

  if (s.sum % 10 == 0) {
    int min = s.sum;

    foreach (si; s) {
      if (si % 10 && si < min) {
        min = si;
      }
    }

    (s.sum - min).writeln;
  } else {
    writeln(s.sum);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

ll GCD (ll x, ll y) {
  if (y == 0) return x;
  return GCD(y, x%y);
}
int main() {
    ll a,b; cin >> a >> b;
    ll ans = 1;
    ll gcd = GCD(a,b);
    for (ll i = 2; i*i <= gcd; i++) // i <= sqrt(gcd)
    {
        if (gcd % i == 0) {
            ans++;
            while (gcd % i == 0) {
                gcd /= i;
            }
        }
    }
    if (gcd != 1) ans++;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
N = int(input())
w = [list(map(int, input().split())) for i in range(N)]
w.sort(key = lambda w : w[1])
t = 0
for i in range(N):
    t += w[i][0]
    if t > w[i][1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 53724
while True:
    n=int(input())
    if n==0:
        break
    else:
        c=[0]*10
        for i in range(n):
            a=int(input())
            c[a]+=1
        for j in range(10):
            if c[j]==0:
                print("-")
            else:
                print("*"*c[j])


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int a[1010][1010] = {};
    int head[1010] = {};
    rep(i,n){
        rep(j,n-1){
            int x;
            cin >> x;
            x--;
            a[i][j] = x;
        }
    }
    int turn = 0;
    vector<int> used(n, -1);
    while(true){
        bool ng = true;
        int empty_cnt = 0;
        rep(i,n){
            if (head[i] == n-1) {
                empty_cnt++;
                continue;
            }
            int j = a[i][head[i]];
            if (used[i] == turn || used[j] == turn) continue;
            if (a[j][head[j]] == i) {
                head[i]++;
                head[j]++;
                used[i] = used[j] = turn;
                ng = false;
            }
        }
        if (empty_cnt == n) break;
        if (ng) {
            cout << -1 << endl;
            return 0;
        }
        turn++;
    }
    cout << turn << endl;

    return 0;
}


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

class Program {
  static void Main(string[] args) {
    var rgbn = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
    int r = rgbn[0], g = rgbn[1], b = rgbn[2], n = rgbn[3];

    int ans = 0;

    for (int i = 0; i <= n; i += r) {
      for (int j = 0; i + j <= n; j += g) {
        if ((n - i - j) % b == 0) {
          ans++;
        }
      }
    }

    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define m 1000000007
int main(){
  long long n,k;
  cin>>n>>k;
  long long res=0;
  for(long long i=k;i<=n+1;i++){
    long long first=i*(i-1)/2;
    long long second=(n*2-i+1)*i/2;
    long long tot=second-first+1;
    res=(res+tot)%m;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3644
n = int(input())

taro = 0
hana = 0

for x in range(n):
    t, h = list(input().split())
    if t == h:
        taro +=1
        hana +=1
    elif t > h:
        taro +=3
    else:
        hana +=3

print(taro, hana, sep=" ")



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

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > b(10), dp(10, vector<int>(k + 1, 0));
  
  for (int i = 0; i < n; i++) {
    int c, g;
    cin >> c >> g;
    g--;
    b[g].push_back(c);
  }
  
  for (int i = 0; i < 10; i++) {
    sort(b[i].begin(), b[i].end(), greater<int>());
  }
  
  for (int i = 0; i < 10; i++) {
    for (int j = 1; j < b[i].size(); j++) {

      b[i][j] += b[i][j - 1];
    }
  }
  
  for (int i = 1; i <= min(k, (int)b[0].size()); i++) dp[0][i] = b[0][i - 1] + (i - 1) * i;
  
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= min(j, (int)b[i].size()); l++) {
        if (l == 0) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        else dp[i][j] = max(dp[i][j], dp[i - 1][j - l] + b[i][l - 1] + (l - 1) * l);
      }
    }
  }
  
  /*for (int i = 0; i < 10; i++) {
    for (int j = 0; j <= k; j++) {
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }*/
  
  cout << dp[9][k] << endl;
}


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

using namespace std;

class Edge{
public:
    int from, to, cost;
};

vector < vector < Edge > > edge;
vector <bool> visited;

void dfs(int now){
	int l=edge[now].size();
    for(int i=0; i<l; i++){
        if(!visited[edge[now][i].to]){
            visited[edge[now][i].to]=true;
            dfs(edge[now][i].to);
        }
    }
}

int main(){
    int N, M;
    int from, to, cost;

    cin>>N>>M;
    edge.resize(N);
    for(int i=0; i<M; ++i){
        cin>>from>>to>>cost;
        edge[from-1].push_back((Edge){from-1, to-1, cost%2});
        edge[to-1].push_back((Edge){to-1, from-1, cost%2});
    }

    visited.resize(N);
    for(int i=0; i<N; ++i){
        visited[i]=false;
    }

    int ans=0;
    for(int i=0; i<N; ++i){
        if(visited[i] == false){
            visited[i]=true;
            dfs(i);
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 10368
L, R = map(int, input().split())
MOD = 2019
ans = float("inf")
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, i * j % MOD)
        if ans == 0:
            print(0)
            exit()
print(ans)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// How many divider
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ary := strings.Split(strings.TrimSpace(sc.Text()), " ")
	a, _ := strconv.Atoi(ary[0])
	b, _ := strconv.Atoi(ary[1])
	c, _ := strconv.Atoi(ary[2])
	cnt := 0
	for i := a; i <= b; i++ {
		if c%i == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 1100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int solve(){
  int n;
  cin >> n;
  vector<int>v(n);
  int maxn = 0,minn = 0;
  rep(i,n){
    cin >> v[i];
  }
  maxn = v[0];
  minn = v[0];
  int ans = 0;
  rep(i,n){
    if(minn >= v[i])ans++;
    minn = min(v[i],minn);
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}
ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
ll g(ll x, ll y) {return x / y;}
ll f(ll x, ll m, ll n) {
    return x - (g(x, m) + g(x, n) - g(x, lcm(m, n)));
}
/* main */
int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << f(B, C, D) - f(A - 1, C, D) << '\n';
}


Measured memory_bytes: 256
def print_A():
    for i, n in enumerate(A):
        if i == N - 1:
            print(n)
        else:
            print(n, end=' ')

def insert():
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print_A()

N = int(input())
A = list(map(int, input().split()))
print_A()
insert()



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

int main(){

    
    set<int> s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
    
return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int n=1;
  int base=a%b;
  if(base==c){
    cout << "YES" << endl;
    return 0;
  }
  while(true){
    n++;
    if((a*n)%b==c){cout << "YES" << endl; return 0;}
    else if((a*n)%b==base){cout << "NO" << endl; return 0;}
    else{}
  }
  

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n;
  cin>>n;
  vector<string> s(n+1);
  for(ll i=0;i<n;i++){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  s[n]="wwwwwwwwww";
  sort(s.begin(),s.end());
  string memo=s[0];
  ll count=1,ans=0;
  for(ll i=1;i<n+1;i++){
    //cout<<s[i]<<endl;
    if(s[i]==memo)count++;
    else {
      ll memo2=1;
      if(count>1){
      	memo2=(count*(count-1))/2;
        ans+=memo2;
      }
      //cout<<ans<<endl;
      memo=s[i];
      count=1;
    }
   }
  cout<<ans<<endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (auto &t : a) {
		cin >> t;
	}
	for (auto &t : b) {
		cin >> t;
	}
	auto check = [&]() {
		int ok = 1;
		for (int i = 0; i < n; i++) {
			ok &= (a[i] != b[i]);
		}
		if (ok) {
			cout << "Yes\n";
			for (auto t : b) {
				cout << t << ' ';
			}
			cout << '\n';
			exit(0);
		}
	};
	check();
	reverse(b.begin(), b.end());
	check();
	vector<int> good;
	vector<int> bad;
	int some = -1;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			bad.push_back(i);
			some = a[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] && a[i] != some && b[i] != some) {
			good.push_back(i);
		}
	}
	if (bad.size() > good.size()) {
		cout << "No" << '\n';
	} else {
		for (int i = 0; i < (int)bad.size(); i++) {
			swap(b[bad[i]], b[good[i]]);
		} 
		check();
		cout << "No\n";
	}
}

Measured memory_bytes: 5672
#include <iostream>

using namespace std;

struct Dice {
  string input;
  size_t pos;
  int values[6];

  int top;
  int bottom;
  int front;
  int back;
  int left;
  int right;

  void Init() {
    pos = 0;
    top = 1;
    bottom = 6;
    front = 2;
    back = 5;
    left = 4;
    right = 3;
  }

  int Value() const {
    return values[top - 1];
  }

  bool Done() const {
    return pos == input.size();
  }

  void Next() {
    const char d = input[pos];
    int temp = 0;
    switch (d) {
      case 'S':
        temp = front;
        front = top;
        top = back;
        back = bottom;
        bottom = temp;
        break;
      case 'N':
        temp = back;
        back = top;
        top = front;
        front = bottom;
        bottom = temp;
        break;
      case 'E':
        temp = right;
        right = top;
        top = left;
        left = bottom;
        bottom = temp;
        break;
      case 'W':
        temp = left;
        left = top;
        top = right;
        right = bottom;
        bottom = temp;
        break;
    }
    ++pos;
  }
};

int main() {
  Dice dice;
  dice.Init();
  for (int i = 0; i < 6; ++i) {
    cin >> dice.values[i];
  }
  cin >> dice.input;

  for (; !dice.Done(); dice.Next());

  cout << dice.Value() << endl;
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define endl '\n'
#define trace(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;
ll mod(ll x,ll y)
{
  if(x<0)x+=y;
  if(x<y)return x;
   return x%y;
}

ll maxn = 1000000007;
ll m,n,row,col,k;
ll ara[105];
ll dp[105][100006];
ll pref[105][100006];
void solve()
{
  cin >> n >> k;
  for(ll w=0;w<n;w++)cin>> ara[w];
  for(ll w=0;w<=k;w++)
  {
    dp[0][w] = (w>=0 && w<= ara[0]) ? 1 : 0;
    pref[0][w] = (w==0)?mod(dp[0][w],maxn):mod(pref[0][w-1] + dp[0][w],maxn);
  }
    for(ll j = 0; j <= k; j++)
    {
      for(ll i=1;i<n;i++)
      {
        ll x = min(ara[i],j);
        ll y = j - x - 1;
        if(y>=0)dp[i][j] = mod(pref[i-1][j]-pref[i-1][y],maxn);
        else dp[i][j] = mod(pref[i-1][j],maxn);
        if(j!=0)pref[i][j] = mod(pref[i][j-1] + dp[i][j],maxn);
        else pref[i][j] = mod(dp[i][j],maxn);
      }
    }

    cout << dp[n-1][k] << endl;

}
void test()
{
  ll t;
  //scanf("%d",&t);
  t = 1;
  for(ll test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 160000
#include <stdio.h>

int binary(int);

int s[100001], n;

int main(){
  int i, c = 0, q, t[50001];

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &s[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++) scanf("%d", &t[i]);

  for(i=0; i<q; i++) c += binary(t[i]);

  printf("%d\n", c);
  
  return 0;
}

int binary(int key){
  int left = 0, right = n, mid;

  while(left < right){
    mid = (left + right) / 2;
    if(s[mid] == key) return 1;
    else if(key < s[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 1180
import java.util.*;
class P
{
	double time;
	int num;
	P(int num, double time)
	{
		this.num = num;
		this.time = time;
	}
}
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		List<P> a = new ArrayList<P>();
		List<P> b = new ArrayList<P>();
		List<P> c = new ArrayList<P>();
		List<P> d = new ArrayList<P>();
		for(int i = 0; i < 8; ++i)
		{
			int n = stdIn.nextInt();
			double t = stdIn.nextDouble();
			a.add(new P(n, t));
		}
		for(int i = 0; i < 8; ++i)
		{
			int n = stdIn.nextInt();
			double t = stdIn.nextDouble();
			b.add(new P(n, t));
		}
		for(int i = 0; i < 8; ++i)
		{
			int n = stdIn.nextInt();
			double t = stdIn.nextDouble();
			c.add(new P(n, t));
		}
		Collections.sort(a, new Comparator<P>()
		{ 
			public int compare(P t1, P t2)
			{
				return (t1.time - t2.time > 0 ? 1 : -1); 
			}
		} );
		Collections.sort(b, new Comparator<P>()
		{ 
			public int compare(P t1, P t2)
			{
				return (t1.time - t2.time > 0 ? 1 : -1); 
			}
		} );
		Collections.sort(c, new Comparator<P>()
		{ 
			public int compare(P t1, P t2)
			{
				return (t1.time - t2.time > 0 ? 1 : -1); 
			}
		} );
		d.add(a.get(2));
		d.add(a.get(3));
		d.add(b.get(2));
		d.add(b.get(3));
		d.add(c.get(2));
		d.add(c.get(3));
		Collections.sort(d, new Comparator<P>()
		{ 
			public int compare(P t1, P t2)
			{
				return (t1.time - t2.time > 0 ? 1 : -1); 
			}
		} );
		System.out.println(a.get(0).num + " " + a.get(0).time);
		System.out.println(a.get(1).num + " " + a.get(1).time);
		System.out.println(b.get(0).num + " " + b.get(0).time);
		System.out.println(b.get(1).num + " " + b.get(1).time);
		System.out.println(c.get(0).num + " " + c.get(0).time);
		System.out.println(c.get(1).num + " " + c.get(1).time);
		System.out.println(d.get(0).num + " " + d.get(0).time);
		System.out.println(d.get(1).num + " " + d.get(1).time);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  /*
  理想
  a b c a b c a b
  b c a b c a b c
  c a b c a b c a
  a b c a b c a b
  ...
  */
  int N,C; cin >>N >>C;
  vector<vector<int>> D(C, vector<int>(C, 0));
  rep(i, C) rep(j, C) cin >>D[i][j];
  // D[i][j] := 色を i から j に塗り替えるときの違和感

  vector<vector<int>> field(N, vector<int>(N, 0));
  rep(i, N) rep(j, N) cin >>field[i][j];
  rep(i, N) rep(j, N) field[i][j]--;
  // field[i][j] := 最初に(i,j) に塗られている色

  vector<vector<int>> color(3, vector<int>(C, 0));
  // color[i][j] :=
  //   同じ色で塗るべき領域は3つ。領域 i について、
  //   最初に塗られている色 j の数

  vector<vector<ll>> dif(3, vector<ll>(C, 0));
  // dif[i][j] := 
  //   領域 i について、色を j で塗ると決めた時の違和感の総和

  rep(i, N) rep(j, N) color[(i+j)%3][field[i][j]]++;
  
  rep(k, 3){
    // 領域 k について
    rep(c, C){
      // 塗る色を c に決めた時の違和感の総和を計算
      // 領域 k について、最初に塗られている色 j の数はcolor[k][j]に格納されている
      rep(j, C) dif[k][c] += (ll)color[k][j] * (ll)D[j][c];
    }
  }
  ll res = numeric_limits<ll>::max();
  rep(i, C){
    rep(j, C){
      if (i == j) continue;
      rep(k, C){
        if (i == k || j == k) continue;
        ll buf = dif[0][i] + dif[1][j] + dif[2][k];
        chmin(res, buf);
      }
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k, a[3000];
lli memo[3001][3001];

lli dfs(lli t, lli l, lli r) {
  if (memo[l][r] != 1e18) return memo[l][r];
  lli yl = dfs(-t, l+1, r);
  lli yr = dfs(-t, l, r-1);
  lli res;
  if (t == 1) res = max(yl + a[l], yr + a[r]);
  else res = min(yl - a[l], yr - a[r]);
  return memo[l][r] = res;
}

int main() {
  cin >> n;
  read_n(a, n);
  for (lli i=0; i<n; ++i) fill(&memo[i][i], &memo[i][n+1], 1e18);
  cout << dfs(1, 0, n-1) << '\n';
  return 0;
}



Measured memory_bytes: 70272
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll n;
    vector<ll> v;
    vector<ll> c;

    cin >> n;

    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        v.push_back (temp);
    }

    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        c.push_back (temp);
    }

    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) ans += v[i] - c[i];
    }

    cout << ans << endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  string ans = "";
  int R; cin>>R;
  if(R<1200) ans = "ABC";
  else if(R<2800) ans =	"ARC";
  else ans = "AGC";
  cout << ans << endl;
  return 0;
}



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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	long long ans1 = 0, ans2 = 0, sum = 0;

	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 && sum <= 0) {
			ans1 += -sum + 1;
			sum = 1;
		}
		else if (i % 2 == 1 && sum >= 0) {
			ans1 += sum + 1;
			sum = -1;
		}
	}

	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 1 && sum <= 0) {
			ans2 += -sum + 1;
			sum = 1;
		}
		else if (i % 2 == 0 && sum >= 0) {
			ans2 += sum + 1;
			sum = -1;
		}
	}
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(){
	int a,b,c,d,n,x;
	while(cin >> n){
		x=0;
		for(a=0;a<10;a++)
		for(b=0;b<10;b++)
		for(c=0;c<10;c++)
		for(d=0;d<10;d++)
		if(a+b+c+d==n) x++;
		cout << x << endl;
	}
}



Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		if (n % 2 == 0) {
			for (int i = n - 1; i >= 0; i = i - 2) {
				sb.append(a[i] + " ");
			}
			for (int i = 0; i < n; i = i + 2) {
				sb.append(a[i] + " ");
			}
		}else {
			for (int i = n - 1; i >= 0; i = i - 2) {
				sb.append(a[i] + " ");
			}
			for (int i = 1; i < n; i = i + 2) {
				sb.append(a[i] + " ");
			}
		}
		sb.deleteCharAt(sb.length()-1);
		System.out.println(sb);

	}
}


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

#define ll long long 
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i <n; i++){
        cin >> a.at(i);
        cin >> b.at(i);
    }
    // debug a,b
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll res;
    if(n%2 == 1)
        res = b.at((n)/2) - a.at((n)/2)+1;
    else
        res = b.at(n/2-1)+b.at(n/2)-a.at(n/2-1)-a.at(n/2)+1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

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

int gcd(int x,int y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(x%y,y);
}

int main()
{

    int N;
    cin>>N;

    int A[100010];
    REP(i,N) cin>>A[i];

    int L[100010],R[100010];

    L[0] = 0;
    R[N+1] = 0;
    FOR(i,1,N+1){
    	L[i] = gcd(A[i-1],L[i-1]);
    	R[N-i+1] = gcd(A[N-i],R[N-i+2]);
    }

    int M[100010];
    int max=0;
    FOR(i,1,N+1){
    	M[i]=gcd(L[i-1],R[i+1]);
    	if(max<M[i]) max=M[i];
    }

    cout << max << endl;


}


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

int main(){
	
	int cup[3]={0};
	cup[0]=1;
	char a,b,comma;
	while(cin>>a>>comma>>b){
		if(a=='A'&&b=='B'||a=='B'&&b=='A')
			swap(cup[0],cup[1]);
		else if(a=='B'&&b=='C'||a=='C'&&b=='B')
			swap(cup[1],cup[2]);
		else if(a=='A'&&b=='C'||a=='C'&&b=='A')
			swap(cup[0],cup[2]);
	}
	for(int i=0;i<3;i++){
		if(cup[i]==1){
			if(i==0)
				cout<<"A"<<endl;
			else if(i==1)
				cout<<"B"<<endl;
			else
				cout<<"C"<<endl;
		}
	
	
}
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
struct UnionFind
{
  vector<i64> data;
  UnionFind(i64 size) : data(size, -1) {}
  bool unionSet(i64 x, i64 y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(i64 x, i64 y)
  {
    return root(x) == root(y);
  }
  i64 root(i64 x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  i64 size(i64 x)
  {
    return -data[root(x)];
  }
};

int main()
{
  i64 N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<i64> cnt(N);
  for (i64 i = 0; i < M; i++)
  {
    i64 A, B;
    cin >> A >> B;
    A--;
    B--;
    cnt[A]++;
    cnt[B]++;
    uf.unionSet(A, B);
  }
  vector<i64> weak[N];
  for (i64 i = 0; i < K; i++)
  {
    i64 C, D;
    cin >> C >> D;
    C--;
    D--;
    weak[C].push_back(D);
    weak[D].push_back(C);
  }
  for (i64 i = 0; i < N; i++)
  {
    i64 ans = uf.size(i) - cnt[i] - 1;
    for (i64 j : weak[i])
      if (uf.findSet(i, j))
        ans--;
    cout << ans << " \n"[i == N - 1];
  }
  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
using namespace std;
bool isin(int *p, int n, int v){
    for(int i=0;i<n;i++){
        if(p[i]==v)return true;
    }
    return false;
}
int main(int,char**){
    int x,n,*p;
    cin>>x>>n;
    p=new int[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<100;i++){
        if(!isin(p,n,x-i)){
            cout<<x-i;
            return 0;
        }
        if(!isin(p,n,x+i)){
            cout<<x+i;
            return 0;
        }
    }
}

Measured memory_bytes: 3624
import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Measured memory_bytes: 9440
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	int n, k;
	cin >> n >> k;

	LL ans = k;

	for (int i = 1; i < n; i++) {
		ans *= (k - 1);
	}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    List<Integer>[] lists = new ArrayList[n];
    int[] dp = new int[n];

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<n; i++) lists[i] = new ArrayList<>();

        for (int i=0; i<m; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            lists[s].add(t);
        }

        Arrays.fill(dp, -1);

        int ret = 0;

        for (int i=0; i<n; i++) {
            ret = Math.max(ret, rec(i));
        }

        System.out.println(ret);

    }

    int rec(int v) {
        if (dp[v] != -1) return dp[v];

        int ret = 0;

        for (int u: lists[v]) {
            if (dp[u] == -1) rec(u);
            ret = Math.max(ret, dp[u] + 1);
        }

        return dp[v] = ret;
    }
}



Measured memory_bytes: 62564
main = do
 str <- getLine
 let a = read str :: Integer
 let sequense = [1..a]
 line <- getLine
 let xs = [read x ::Integer | x <- (words line)]
 let diff = sum [ 1 | (x, y) <- zip sequense xs, x /= y ]
 if diff == 2 || diff == 0 then putStrLn "YES" else putStrLn "NO"


Measured memory_bytes: 764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = getInputInteger(sc);
 
        // programming
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = getInputInteger(sc);
        }

        int count = 0;
        l1: while (true) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 != 0) {
                    break l1;
                }
                a[i] = a[i] / 2;
            }
            count++;
        }

        output(String.valueOf(count));
	}

	public static String getInputString(Scanner sc) {
		return sc.next();
	}

	public static int getInputInteger(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	public static void output(String... params) {
		boolean isInit = true;
		String str = "";
		for (String s : params) {
			if (!isInit) {
				str += " ";
			}
			str += s;
			isInit = false;
		}
		System.out.println(str);
	}

    public static int[] toIntegerList(String s) {
        int[] ret = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            ret[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
        }
        return ret;
    }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, T, A;

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

    std::cin >> N >> T >> A;

    int id = -1, mn = 1001001001;

    for(int i=1;i<=N;++i){
        int H;
        std::cin >> H;

        int d = std::abs((1000 * T - H * 6) - 1000 * A);
        if(d < mn){
            id = i;
            mn = d;
        }
    }

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


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

void Main()
{
	int a, b, h; cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
}

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


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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c) cout << b + c;
    else cout << b + a + b + 1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    int h, n;
    cin >> h >> n;
    ll arr[n + 5], sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    if(sum >= h)
        cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 1024