akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      Long K = sc.nextLong();
      Long A = sc.nextLong();
      Long B = sc.nextLong();
      if(B - A <= 2 || K <= A){
        System.out.println(1 + K);
      }else{//A出現ごとにBに変換
        Long nokori = K - (A - 1);
        Long addBisuke = A + (B - A) * (nokori / 2);
        if(nokori % 2 == 1){//ビスケット1回たたく
          addBisuke++;
        }
        System.out.println(addBisuke);
      }
	}
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  set<ll> s;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    if (a[i] == a[i + 1]) {
      cnt++;
      a[i + 1] = 100001;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        hh: [u32; n],
        ab: [(usize1, usize1); m],
    };

    let mut is_good = vec![true; n];
    for (a, b) in ab {
        let ha = hh[a];
        let hb = hh[b];
        if ha <= hb {
            is_good[a] = false;
        }
        if hb <= ha {
            is_good[b] = false;
        }
    }
    println!("{}", is_good.iter().fold(0, |a, b| a + if *b {1} else {0}));
}


Measured memory_bytes: 6064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string S;
    cin >>S;

    if(S[1]=='B' ){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    



    return 0;
    

}

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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadget
{	// DFSライブラリ

	struct DFSedge
	{
		ll v = 0;	// 頂点
		DFSedge(ll vindex) { v = vindex; }
	};

	template <class TE = DFSedge> struct DFS
	{
		using Graph = vector<vector<TE>>;
		Graph graph;

		DFS(ll size) { graph.resize(size); }
		// 頂点xと接続されている頂点を全て取得したいときに使う演算子
		vector<TE>& operator [](int x) { return graph[x]; }

		/**
		@brief 辺を追加する関数
		@note
		 頂点v1とv2を結ぶ辺を追加する。
		**/
		void CreateEdge(ll v1, ll v2)
		{	// 後戻りも出来るようにv1→v2とv2→v1の両方の辺を追加する
			graph[v1].push_back(DFSedge(v2));
			graph[v2].push_back(DFSedge(v1));
		}
	};

}

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadget;

/**
@brief 深さ優先探索
@param r 根
@param v 頂点
@param dfs 処理するDFSグラフ
@param memo 前処理したメモ(加算するべきカウンタの値)
@param ans 出力する答えを格納する配列
@note
 DFSで全てのノードを処理する。
**/
void Solve(ll r, ll v, DFS<>& dfs, vector<ll>& memo, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	each(e, dfs[v])
	{	// 後戻りしないようにする
		if (e.v == r)
			continue;

		Solve(v, e.v, dfs, memo, ans);
	}
}

int main(void)
{
	ll n; cin >> n;
	vector<ll> memo(9 * 9);

	rep(i, 1, 10)
	{
		rep(j, 1, 10)
		{
			if (i * j == n)
			{
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<algorithm>
using namespace std;

struct Point {
	double x, y;
};

Point point[1001];


void treasure() {
	point[2].x = 1.0;
	point[2].y = 1.0;
	double r_p = sqrt(2), r_n;
	double theta;
	for (int i = 3; i < 1001; i++) {
		r_n = sqrt(r_p * r_p + 1);
		theta = acos((r_n * r_n + r_p * r_p - 1) / (2 * r_n * r_p));
		point[i].x = ((cos(-1 * theta) * point[i - 1].x - sin(-1 * theta) * point[i - 1].y) * (r_n / r_p));		//r_n/r_pは比
		point[i].y = ((sin(-1 * theta) * point[i - 1].x + cos(-1 * theta) * point[i - 1].y) * (r_n / r_p));
		r_p = r_n;
	}
	
}

int main() {
	int n;
	treasure();
	while (true) {
		cin >> n;
		if (n == -1) {
			break;
		}
		printf("%.2lf\n%.2lf\n", point[n].y, point[n].x);
	}
	return 0;
}


Measured memory_bytes: 3460
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N;
    private int[] a;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }

    public void Solve()
    {
        Scan();
        int min = a.Min();
        int max = a.Max();
        if (max - min > 1)
        {
            Console.WriteLine("No");
            return;
        }
        if (max - min == 0)
        {
            if (a[0] == N - 1 || a[0] * 2 <= N)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            return;
        }
        else if (max - min == 1)
        {
            int x = a.Count(i => i == min);
            int y = N - x;
            if (x < max && 2 * (max - x) <= y)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            return;
        }
    }
}


Measured memory_bytes: 20192
#include <stdio.h>

int main(void) {
	int M1, D1, M2, D2;
	if (scanf("%d%d", &M1, &D1) != 2) return 1;
	if (scanf("%d%d", &M2, &D2) != 2) return 1;
	printf("%d\n", M1 != M2);
	return 0;
}


Measured memory_bytes: 1684
X,Y,A,B,C = list(map(int, input().split()))
As = sorted(list(map(int, input().split())), reverse=True)
Bs = sorted(list(map(int, input().split())), reverse=True)
Cs = list(map(int, input().split()))

As = As[:X]
Bs = Bs[:Y]
ans = 0
Xs = sorted(As+Bs+Cs, reverse=True)
print(sum(Xs[:X+Y]))

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n;
double r[500], pos[500];
double f(double a, double b){
	return sqrt(4 * a * b);
}
int main(){
	cin >> n;
	rep(i, n) cin >> r[i];
	pos[0] = r[0];
	for(int i = 1; i < n; i++){
		
		double mx = 0;
		rep(j, i) mx = max(mx, pos[j] + f(r[i], r[j]));
		pos[i] = max(r[i], mx);
	}
	double ans = 0;
	rep(i, n){
		ans = max(ans, pos[i] + r[i]);
	}
	printf("%.20f\n", ans);
	
	return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<ll> h(n);
    rep(i,n)cin>>h[i];
    int pre =-999;
    rep(i,n){
        if(pre<=h[i]-1){
            pre=h[i]-1;
        }else if(pre<=h[i]){
            pre=h[i];
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int p, r, t;
	cin >> p >> r >> t;
	vi resource(r);
	REP(i, r) cin >> resource[i];
	vector<vi> need(p, vi(r));
	REP(i, p)REP(j, r) cin >> need[i][j];
	vector<pii> query;
	REP(i, t)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		query.emplace_back(a, b);
	}		

	int lb = 0, ub =  t + 1;
	while (ub - lb > 1)
	{
		int time = (ub + lb) / 2;
		auto available = resource;
		auto tmp = need;
		REP(i, time)
		{
			int p = query[i].first, r = query[i].second;
			available[r]--;
			tmp[p][r]--;
		}
		vector<bool> f(p, true);
		REP(i, p)
		{
			bool ff = true;
			REP(j, r)
			{
				if (tmp[i][j] > 0) ff = false;
			}
			if (ff)
			{
				f[i] = false;
				REP(j, r) available[j] += need[i][j];
			}
		}
		bool update = true;
		while (update)
		{
			update = false;
			REP(i, p)
			{
				if (!f[i]) continue;
				bool ff = true;
				REP(j, tmp[i].size())
				{
					if (tmp[i][j] > available[j])
					{
						ff = false;
					}
				}
				if (ff)
				{
					REP(j, r) available[j] += need[i][j] - tmp[i][j];
					update = true;
					f[i] = false;
				}
			}
		}
		bool ok = true;
		REP(i, p)
		{
			if (f[i]) ok = false;
		}
		if (ok) lb = time;
		else ub = time;
	}
	if (ub == t + 1) cout << -1 << endl;
	else cout << ub << endl;
	return 0;
}

Measured memory_bytes: 5276
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = s[0];
            int y = s[1];
            WriteLine(x % y != 0 ? x : -1);
        }
    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n, m;
  cin >> n >> m;
  auto g = vector<vector<int>>(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  auto from = vector<int>(n, -1);
  from[0] = -2;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (auto i : g[now]) {
      if (from[i] == -1) {
        q.push(i);
        from[i] = now;
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << from[i] + 1 << endl;
  }
}


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

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long x = sc.nextInt();

        List<Long> aList = new ArrayList<>();

        for(int i=0; i<N; i++){
            aList.add((long)sc.nextInt());

        }
        Collections.sort(aList);

        int count = 0;

        for(int i=0; i<N; i++){
            x = x - aList.get(i);
            if(x == 0){
                count += 1;
                break;
            }else if(x < 0){
                break;
            }else if(aList.size()-1 != i){
                count += 1;
            }
        }

        System.out.print(count);

    }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main()
{
int h, w, i, j;
while(1){
scanf("%d", &h);
scanf("%d", &w);
if (h==0&&w==0) {
break;
} else {
for (j=0;j<h;j++){
for (i=0;i<w;i++){
if ((j!=0&&j!=h-1)&&(i!=0&&i!=w-1)) {
printf(".");
} else {
printf("#");
}
}
printf("\n");
}
printf("\n");
}
}
return 0;
}

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

using namespace std;

int n;
char c[202020];

int main() {
	scanf("%d", &n);
	scanf("%s", c + 1);
	int le = 1, ri = n;
	int ans = 0;
	for (;le < ri;) {
		while ( c[le] == 'R' && le < ri) le++;
		while ( c[ri] == 'W' && le < ri) ri--;
		if (le < ri) {
			swap(c[le],c[ri]);
			le++;
			ri--;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

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

const int INF = 1000000007;

int main(){
	int n; cin>>n;
	int a[110]={0};
	for(int i=0;i<n;i++) cin>>a[i];

	int maxv = -1;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			int d = abs(a[i] - a[j]);
			maxv = max(maxv, d);
		}
	}

	cout<< maxv <<endl;

	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
src = [int(input()) for i in range(N)]

cums = [(0,1)]
for i,a in enumerate(src):
    cums.append((cums[-1][0] + a - K, i+2))

bit = [0] * (N+2)
def bit_add(a,w):
    x = a
    while x <= N:
        bit[x] += w
        x += (x & -x)

def bit_sum(a):
    x = a
    ret = 0
    while x > 0:
        ret += bit[x]
        x -= (x & -x)
    return ret

ans = 0
for i,a in sorted(cums):
    ans += bit_sum(a-1)
    bit_add(a, 1)
print(ans)


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

#define PI 3.14159265359

double clockcos(double h, double m){
    return cos(abs(30*h - 5.5*m)*PI/180);
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    cout << setprecision(11) <<sqrt(a*a + b*b - 2*a*b*clockcos(h,m));
    return 0;
}


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

using namespace std;
typedef long long ll;
int n;
double d;
double x,y;
int main()
{
   cin>>n>>d;
   int res=0;
   for(int i=1;i<=n;i++)
   {
        cin>>x>>y;
        double  sum=sqrt(x*x+y*y);
        if(sum<=d) res++;
   }
   printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

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

	cout << r * r << endl;


}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll k,A,B;
void solve(){
	cin>>k;
	string s;
	cin>>s;
	rep(i,0,sz(s)){
		cout<<(char)('A'+(s[i]-'A'+k)%26);
	} 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main() {
    int r, g;
    cin >> r >> g;

    int ans = 2 * g - r;

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


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

using namespace std;

typedef long long ll;

int main(){
        ll N, x;
        cin>>N>>x;
        vector <ll> a(N);
        for(int i=0;i<N;i++){
                cin>>a[i];
        }
        ll res=0;
        for(ll i=1;i<N;i++){
                /*for(int j=0;j<N;j++){
                        cout<<a[j]<<":";
                }
                cout<<endl;*/
                if(a[i]+a[i-1]>x){
                        res+=a[i]+a[i-1]-x;
                        ll m=a[i]+a[i-1]-x;
                        if(a[i]>=m){
                                a[i]-=m;
                        }
                        else{
                                a[i-1]-=(m-a[i]);
                                a[i]=0;
                        }
                }
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
 
        long ans = 0;
        for(int i = 1; i <= n; i++)
        {
            if (i % 3 == 0) continue;
            if (i % 5 == 0) continue;
            ans = ans + i;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27528
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define reps(i, s, n) for (ll i = s; i < (ll)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    ll L, R;
    cin >> L >> R;
    ll ans = 8001;
    if (R - L <= 8001) {
        reps(i, L, R) {
            reps(j, i + 1, R + 1) { ans = min(ans, (i * j) % 2019); }
        }
    } else {
        R = L + 8001;
        reps(i, L, R) {
            reps(j, i + 1, R + 1) { ans = min(ans, (i * j) % 2019); }
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

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

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

#define INF 1000000000

using namespace std;

typedef long long ull;

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

    vector<ull> A(N, 0);
    vector<ull> count(200000 + 1, 0);

    REP(i, N) {
        cin >> A[i];
        count[A[i]]++;
    }

    ull sum = 0;
    for (auto i : count) {
        sum += i * (i - 1) / 2;
    }

    REP(i, N) {
        ull before = count[A[i]] * (count[A[i]] - 1) / 2;
        ull after = (count[A[i]] - 1) * (count[A[i]] - 2) / 2;

        cout << sum - before + after << endl;
    }

    return 0;
}


Measured memory_bytes: 5760
#include <climits>
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int a[n];
	int max = INT_MIN;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max) {
			max = a[i];
			count = 1;
		} else if (a[i] == max) {
			count++;
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (a[i] < max || count >= 2) {
			cout << max << endl;
		} else {
			int m = INT_MIN;
			for (int j = 0; j < n; j++) {
				if (j != i) {
					if (a[j] > m) {
						m = a[j];
					}
				}
			}
			cout << m << endl;
		}
	}
}

Measured memory_bytes: 2432
A, B, C = [int(n) for n in input().split()]

if len({A, B, C}) == 1 and A % 2 == 0:
    print(-1)
else:
    numbers = [A, B, C]
    ans = 0

    while True:
        next_numbers = [0, 0, 0]
        next = True
        for i in range(3):
            if numbers[i] % 2 != 0:
                next = False
            else:
                next_numbers[i] = (numbers[(i + 1) % 3] + numbers[(i + 2) % 3]) // 2
        if not next:
            break
        ans += 1
        numbers = next_numbers
    print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    string s;
    cin >> s;
    int l = s.size();

    int k = 1;
    int g = 0;
    int R = 1;
    int ve[100000];
    rep(i, 0, l) { ve[i] = 0; }
    rep(i, 1, l) {
        if(s[i] == 'R') {
            if(R % 2 == 0) {
                k++;
            } else {
                g++;
            }
            R++;
        } else if(R != 0) {
            if(R % 2 == 0) {
                ve[i] += k;
                ve[i - 1] += g;
            } else {
                ve[i] += g;
                ve[i - 1] += k;
            }
            k = 0;
            g = 0;
            R = 0;
        }
    }
    int kk = 1;
    int gg = 0;
    int L = 1;
    // rep(i, 0, l) { cout << ve[i] << " "; }
    // cout << endl;
    rep(i, 1, l) {
        int r = l - i - 1;
        if(s[r] == 'L') {
            if(L % 2 == 0) {
                kk++;
            } else {
                gg++;
            }
            L++;
        } else if(L != 0) {
            if(L % 2 == 0) {
                ve[r] += kk;
                ve[r + 1] += gg;
            } else {
                ve[r] += gg;
                ve[r + 1] += kk;
            }
            kk = 0;
            gg = 0;
            L = 0;
        }
    }
    rep(i, 0, l) { cout << ve[i] << " "; }
    cout << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
// iteration and input/output stream
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()) cout<<x[i]<<" "; cout<<endl;

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

using namespace std;

#define tc() int tcase; cin >> tcase ; rep(tc,1,tcase+1)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair

// Error detection
#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 trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

ll gcd(ll a,ll b){ return ((b==0)? a:gcd(b,a%b) ); }


int main()
{
    SYNC
    int a,b;
    cin>>a>>b;
    if(b==1)
        cout<<0;
    else
    {
        int cnt =1;
        rep(i,1,30)
        {
            cnt = cnt-1 + a;
            //trace2(cnt,i);
            if(cnt >= b)
            {
                cnt = i;
                break;
            }
        }
        cout<<cnt;
    }
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int a[N];
	
	for(int i=0; i<N; i++){
		cin >> a[i];
		a[i]--;
	}
	
	int i = 0;
	for(int j=1; j<=N; j++){
		i = a[i];
		if(i == 1){
			cout << j;
			return 0;
		}
	}
	
	cout << -1;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int N,K;
long long ans;
int main(){
    cin>>N>>K;
    for(int i=K+1;i<=N;i++){
        ans+=N/i*(i-K)+max(N%i-K+1,0);
    }
    if(K==0)ans-=N;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
  for j in range(i+1,N-1):
    k=2*j-i
    if k>=N:
      continue
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      ans-=1
print(ans)

Measured memory_bytes: 9588
#include <stdio.h>                                                      
 
int main()
{
    int h,w;
    while(scanf("%d%d", &h, &w) != EOF && h+w)
    {
        for (int i = 0; i < h; i++)
        {
            if (i == 0 || i == h-1)
            {
                for (int j = 0; j < w; j++)
                {
                    printf("#");
                }
            }
            else
            {
                printf("#");
                for (int j = 1; j < w-1; j++)
                    printf( ".");
                printf( "#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
} 



Measured memory_bytes: 2596
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k,s;
  cin>>n>>k>>s;
  vll a(n);
  rep(i,n){
    if(i<k){
      a[i]=s;
    }
    else{
      if(s!=1000000000){
        a[i]=1000000000;
      }
      else{
        a[i]=1000000000-1;
      }
    }
  }
  rep(i,n){
    cout<<a[i]<<" ";
  }
  cout<<endl;
}

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

int main(){
  int d;
  cin >> d;
  if(d%7==0){
    cout << "thu" << endl;
  }
  if(d%7==1){
    cout << "fri" << endl;
  }
  if(d%7==2){
    cout << "sat" << endl;
  }
  if(d%7==3){
    cout << "sun" << endl;
  }
  if(d%7==4){
    cout << "mon" << endl;
  }
  if(d%7==5){
    cout << "tue" << endl;
  }
  if(d%7==6){
    cout << "wed" << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
def main():
    X, N = map(int, input().split())
    P = [int(p) for p in input().split()]

    NP = list()

    for i in range(-500, 501):
        if i in P:
            pass
        else:
            NP.append(i)

    mi = 10000

    for i in range(len(NP)):
        diff = abs(NP[i] - X)

        if diff < mi:
            mi = diff

    ans = list()

    for i in range(len(NP)):
        if abs(NP[i] - X) == mi:
            ans.append(NP[i])

    ans.sort()
    print(min(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9216
//#include <algorithm>
//#include <cassert>
//#include <cfloat>
//#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int A, B, C; scanf("%d%d%d", &A, &B, &C);
  bool judge{};
  for (int i{1}; i < B; ++i) {
    if (A * i % B == C) {
      judge = true;
      break;
    }
  }

  printf("%s\n", judge ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){ 
  int d,n; cin >>d>>n;
   cout<<(int)pow(100,d)*(n+n/100)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,ia=0,ib=0,ic=0,turna=1,turnb=0,turnc=0;
char sa[101],sb[101],sc[101];
cin>>sa>>sb>>sc;
while(1){
if(turna==1) {
 if(sa[ia]=='\0') { cout<<"A"<<endl;
                          return 0;
  }
  if(sa[ia]=='b') { turna = 0;
                      turnb =1;
  }
   if(sa[ia]=='c') { turna = 0;
                      turnc =1;
  }
 ia++;
 continue;
 }
if(turnb==1) {
 if(sb[ib]=='\0') { cout<<"B"<<endl;
                          return 0;
  }
  if(sb[ib]=='a') { turnb = 0;
                      turna =1;
  }
   if(sb[ib]=='c') { turnb = 0;
                      turnc =1;
  }
 ib++;
 continue;
 }
if(turnc==1) {
 if(sc[ic]=='\0') { cout<<"C"<<endl;
                          return 0;
  }
  if(sc[ic]=='a') { turnc = 0;
                      turna =1;
  }
   if(sc[ic]=='b') { turnc = 0;
                      turnb =1;
  }
 ic++;
 continue;
 }
}
}

Measured memory_bytes: 256
from collections import defaultdict
from bisect import bisect

n, m = map(int, input().split())

city = []

for i in range(m):
    p, y = map(int, input().split())
    city.append([p, y])

dic = defaultdict(list)
for p, y in sorted(city):
    dic[p] += [y]

# print(sorted(city))
# print(dic)

for p, y in city:
    x = bisect(dic[p], y)
    print("{0:06d}{1:06d}".format(p, x))



Measured memory_bytes: 39460
//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N=2500;

int32_t main()
{
	
	int x;
	cin>>x;
	int l,r;
	for(int i=1;i<=N;i++)
	{
		l=i*i*i*i*i;
		for(int j=-N;j<=N;j++)
		{
			r=j*j*j*j*j;
			
			if((l-r)==x)
			{
				cout<<i<<" "<<j;
				return 0;
			}
			
			
		}
	}
	
	
	
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
       int n;
      cin>>n;
      vector<int> v(n);
      for(int i=0;i<n;i++) cin>>v[i];
      int ans=0,count=0;
      for(int i=0;i<n-1;i++){
        if(v[i+1]<=v[i]) count++;
        else ans=max(ans,count),count=0;
      }
      ans=max(ans,count);
      cout<<ans;
    }

Measured memory_bytes: 640
N = int(input())
ans = N


def simulate(m):
    for a in range(1, m):
        global ans
        sum_a = sum([int(i) for i in str(a)])
        sum_b = sum([int(i) for i in str(N-a)])
        if sum_a + sum_b < ans:
            ans = sum_a + sum_b


if N % 2 == 0:
    simulate(N//2+1)
else:
    simulate(N//2+2)

print(ans)

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

int main(){
  int x,y;
  vector<int> n(3);
  rep(i,3){
    cin >> n.at(i);
  }
  sort(n.begin(),n.end());

  x = n.at(2) - n.at(1);
  y = n.at(2) - n.at(0) - x;

  if(y%2){
    ++x; ++y;
  }
  cout << x+y/2 << endl;
}


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

int main(){

ll n;
cin>>n;
ll a[n],i;
for(i=0;i<n;i++)
    cin>>a[i];
    if(n<=2)
        cout<<0<<endl;
    else{
            sort(a,a+n);
    i=0;
ll j=1,k=2,cnt=0;
for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
        for(k=j+1;k<n;k++){
            if(a[i]+a[j]>a[k] and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k])
                cnt++;
        }
    }
}
cout<<cnt<<endl;
    }

    return 0;

}


Measured memory_bytes: 3648
#include "bits/stdc++.h"

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int A() {
	int n;
	scani(n);

	switch (n % 10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon");
		break;
	case 3:
		printf("bon");
		break;
	}

	return 0;
}

int Main() {
	int k;
	string s;
	scani(k);
	cin >> s;

	if (s.length() <= k) {
		for (int i = 0; i < s.length(); i++) {
			printf("%c", s[i]);
		}
	}
	else {
		for (int i = 0; i < k; i++) {
			printf("%c", s[i]);
		}
		printf("...");
	}

	return 0;
}

int main()
{
	Main();
	return 0;
}

Measured memory_bytes: 3760
s=input()
ok = "ATGC"
ans = 0
cnt = 0
isok = False

for i in range(len(s)):
    for j in range(4):
        if s[i] == ok[j]:
            isok = True
    if isok == False:
        cnt = 0
        continue
    cnt += 1
    ans = max(ans,cnt)
    isok = False
print(ans)

Measured memory_bytes: 3060
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n,t = na()
ct = [na() for _ in range(n)]

ctt = []
for i in ct:
    if i[1] <= t:
        ctt.append(i[0])

if len(ctt) == 0:
    print("TLE")
else:
    print(min(ctt))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
    cout<<"YES";
else
    cout<<"NO";
    return 0;
}




Measured memory_bytes: 3536
#include <iostream>

using namespace std;

int i = 1;
int sum = 1;
int num[2] = {1, 1};
int l = 0;
int fib(int n)
{
  if (i == n) return sum;
  sum += num[l];
  num[l] = sum;
  l = 1 - l;

  if (i != n) {
   i++;
   return fib(n);
  }
}

int main()
{
  int n;
  cin >> n;
  
  if (n == 0) cout << 1 << endl;
  else cout << fib(n) << endl;

  return 0;
}

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

using namespace std;

string check(int a) {
    for(int i=1;i<10;i++) for(int j=1;j<10;j++) if(i*j == a) return "Yes";
    return "No";
}

int main() {
    int a;
    cin >> a;
    cout << check(a) << endl;
    return 0;
}


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

using namespace std;

int main(){
	
	int t ;
	cin >> t;
	
	
	
	if (t < 10) cout << t % 10;
	else if(t < 100) cout <<  9;
	else if (t < 1000) cout << 9 + (t - 99) ;
	else if (t < 10000) cout << 909;
	else if (t < 100000) cout << 909 + (t - 9999);
	else cout << 90909;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

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

    vector<pair<int,string>> vp;
    int id;string str;
    for(int i=0;i<m;i++){
        cin>>id>>str;
        vp.pb({id,str});
    }

    int freq[100001];
    memset(freq,0,sizeof(freq));
    set<int> s;
    for(int i=0;i<m;i++){
        if(!s.count(vp[i].F)){
            if(vp[i].S=="AC")
                s.insert(vp[i].F);
            else
                freq[vp[i].F]++;
        }
    }

    int ans1=0,ans2=0;
    for(auto x:s){
        ans1++;
        ans2+=freq[x];
    }

    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

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

const int N = 200 + 7;
int a[N][N];
int col[N];
bool mark[N], rid;
int n;

void dfs(int v)
{
	mark[v] = true;
	for (int i=0; i<n; i++)
		if (a[v][i] == 1)
		{
			if (!mark[i])
			{
				col[i] = col[v] ^ 1;
				dfs(i);
			}
			else
			{
				if (col[i] == col[v])
					rid = true;
			}
		}
}

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

	cin >> n;
	for (int i=0; i<n; i++)
	{
		string s;
		cin >> s;
		for (int j=0; j<n; j++)
		{
			a[i][j] = s[j] == '0' ? (i != j ? N : 0) : 1;
		}
	}


			for(int k=0; k<n; k++)
	for (int i=0; i<n; i++)
		for(int j=0; j<n; j++)
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);


	int d = 0;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			d = max(d, a[i][j]);

	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			for (int k=0; k<n; k++)
				if ((a[i][j] + a[j][k] + a[k][i]) % 2 != 0)
				{
					cout << "-1\n";
					return 0;
				}
	cout << d + 1 << "\n";

	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
A=[]
for i in range(n):
  A.append(abs(a[i]))
m=A.index(max(A))
print(2*n-1)
for i in range(1,n+1):
  print(m+1,i)
if a[m]>=0:
  for i in range(1,n):
    print(i,i+1)
else:
  for i in range(n,1,-1):
    print(i,i-1)

Measured memory_bytes: 38384
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const ll mod=1e9+7;
int n;
string refe="AGCT";
ll dp[105][5][5][5][5];

string get(int i,int j,int k,int e){
	string s;
	if(i!=-1)s.pb(refe[i]);
	if(j!=-1)s.pb(refe[j]);
	if(k!=-1)s.pb(refe[k]);
	if(e!=-1)s.pb(refe[e]);
	return s;
}

bool sat(string &s){
	if(sz(s)<=2)return false;
	if(s.substr(0,3)=="AGC")return true;
	if(s.substr(0,3)=="GAC")return true;
	if(s.substr(0,3)=="ACG")return true;
	if(sz(s)==3)return false;
	if(s.substr(1,3)=="AGC")return true;
	if(s.substr(1,3)=="GAC")return true;
	if(s.substr(1,3)=="ACG")return true;
	if(s[0]=='A'&&s[1]=='G'&&s[3]=='C')return true;
	if(s[0]=='A'&&s[2]=='G'&&s[3]=='C')return true;
	return false;
}

ll solve(int tam,int i,int j,int k,int e){
	string s=get(i,j,k,e);
	if(sat(s))return 0;
	if(tam==0)return 1;
	ll &ans=dp[tam][i][j][k][e];
	if(ans!=-1)return ans;
	ans=0;
	FER(c,0,4)ans=(ans+solve(tam-1,j,k,e,c))%mod;
	return ans;
}


int main(){	
	fastio;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	cout<<solve(n,-1,-1,-1,-1)<<endl;

	return 0;
}


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

int main(){
  int N, c = 0, A = 0;
  cin >> N;
  for(int i = 1; i < N+1; i++) {
    if(i % 2 == 1) {
      for(int j = 1; j < i+1; j++){
        if(i % j == 0) c++;
      }    
    if(c == 8) {A++;}
    c = 0;
    }
  }
  cout << A;
}

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

int testcase_ends() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);
  if (N == 0 && M == 0) return 1;

  std::vector<int> min(N), max(N);
  for (size_t i = 0; i < M; ++i) {
    int S;
    size_t k;
    scanf("%d %zu", &S, &k);
    std::vector<size_t> c(k);
    for (size_t j = 0; j < k; ++j) {
      scanf("%zu", &c[j]);
      --c[j];
    }

    if (k == 1) {
      min[c[0]] += S;
      max[c[0]] += S;
      continue;
    }
    for (size_t j = 0; j < k; ++j) {
      max[c[j]] += S;
    }
  }

  std::vector<int> max_left(N+1), max_right(N+1);

  for (size_t i = 0; i < N; ++i) {
    max_left[i+1] = std::max(max_left[i], max[i]);
  }
  for (size_t i = N; i--;) {
    max_right[i] = std::max(max_right[i+1], max[i]);
  }

  int res = 0;
  for (size_t i = 0; i < N; ++i) {
    int max0 = std::max(max_left[i], max_right[i+1]);
    res = std::max(res, max0-min[i]+1);
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}




Measured memory_bytes: 2824
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
int A[100];
int main() {
	int N, M;
	cin >> N >> M;
	if (N == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	if (M == 1) {
		cout << N << endl;
		cout << 2 << endl;
		cout << N - 1 << " " << 1 << endl;
		return 0;
	}
	vector<int> odd;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		if (A[i] % 2) odd.push_back(i);
	}
	if (odd.size() > 2) {
		cout << "Impossible" << endl;
		return 0;
	}
	if (odd.size() >= 1) swap(A[0], A[odd[0]]);
	if (odd.size() >= 2) swap(A[M - 1], A[odd[1]]);
	for (int i = 0; i < M; i++) {
		cout << A[i] << " ";
	}
	cout << endl;
	if (A[0] > 1) {
		cout << M << endl;
		cout << A[0] - 1 << " ";
	}
	else {
		cout << M - 1 << endl;
	}
	for (int i = 1; i < M; i++) {
		if (i == M - 1) cout << A[i] + 1 << " ";
		else cout << A[i] << " ";
	}
	cout << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<bool> dp(10001, false);
    dp[0] = true;
    for (int i = 0; i < N; i++) {
        int s;
        cin >> s;
        for (int j = 10000; j >= s; j--){
            dp[j] = dp[j] | dp[j-s];
        }
    }
    for (int i = 10000; i >= 1; i--){
        if (i % 10 != 0 && dp[i]) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "0\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main() {
	string a, b;
	cin >> a >> b;
	P c;
	cin >> c.first >> c.second;
	string d;
	cin >> d;
	if (d == a) {
		c.first -= 1;
	}
	else {
		c.second -= 1;
	}
	cout << c.first << ' ' << c.second << endl;
}

Measured memory_bytes: 256
/*
 * 2517.cc: Hotel
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_D = 50;

const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;

/* global variables */

int ps[MAX_N][MAX_D];
int dp0[MAX_D][MAX_N], dp1[MAX_D][MAX_N];
vi dpv[MAX_D][MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++)
    for (int j = 0; j < d; j++) cin >> ps[i][j];

  for (int j = 0; j < n; j++)
    dp0[0][j] = ps[j][0], dp1[0][j] = 0, dpv[0][j].push_back(j);
  for (int i = 1; i < d; i++)
    for (int j = 0; j < n; j++)
      dp0[i][j] = dp1[i][j] = INF;

  for (int i = 0; i < d - 1; i++)
    for (int j = 0; j < n; j++) {
      int &cd0 = dp0[i][j], &cd1 = dp1[i][j];
      for (int k = 0; k < n; k++) {
	int nd0 = cd0 + ps[k][i + 1];
	int nd1 = (j != k) ? cd1 + 1 : cd1;

	if (dp0[i + 1][k] > nd0 ||
	    (dp0[i + 1][k] == nd0 &&
	     (dp1[i + 1][k] > nd1 ||
	      (dp1[i + 1][k] == nd1 && dpv[i + 1][k] > dpv[i][j])))) {
	  dp0[i + 1][k] = nd0;
	  dp1[i + 1][k] = nd1;
	  dpv[i + 1][k] = dpv[i][j];
	  dpv[i + 1][k].push_back(k);
	}
      }
    }

  int mindp0 = INF, mindp1 = INF;
  vi minv(d, INF);
  for (int j = 0; j < n; j++)
    if (mindp0 > dp0[d - 1][j] ||
	(mindp0 == dp0[d - 1][j] &&
	 (mindp1 > dp1[d - 1][j] ||
	  (mindp1 == dp1[d - 1][j] && minv > dpv[d - 1][j]))))
      mindp0 = dp0[d - 1][j], mindp1 = dp1[d - 1][j], minv = dpv[d - 1][j];

  printf("%d %d\n", mindp0, mindp1);
  for (int i = 0; i < d; i++) printf("%d\n", minv[i] + 1);
  return 0;
}

Measured memory_bytes: 1792