akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int A, B;
    cin >> A >> B;
    if (A * B % 2 == 1) {
        Yes;
    } else {
        No;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for (; x > 0; ans++) {
			x -= ans;
		}
		System.out.println(ans - 1);
	}
}


Measured memory_bytes: 21972
import Data.List(sort)
-- after editorial
main = do
    n <- readLn
    ai <- (fmap read . words) <$> getLine
    let i = iterate (+1) 1
    let bi = sort $ zipWith (-) ai i
    let b = bi!!(div n 2)
    print $ foldl (+) 0 $ fmap abs $ zipWith (-) ai (iterate (+1) (b+1))


Measured memory_bytes: 113276
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var hi = Sarray();
            var cnt = 0L;
            for (var i = 1; i <= 100; ++i)
            {
                var flg = false;
                for (var j = 0; j < N; ++j)
                {
                    if (!flg && i <= hi[j])
                    {
                        flg = true;
                        ++cnt;
                    }
                    if (hi[j] < i)
                        flg = false;
                }
            }
            WriteLine(cnt);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28132
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 10005

int N,K;

struct Info{

	int x,y;
};

//右上がり
struct UP{
	UP(int arg_index,double arg_value){
		index = arg_index;
		value = arg_value;
	}
	bool operator<(const struct UP &arg) const{

		if(fabs(value-arg.value) > EPS){
			return value > arg.value; //切片の降順
		}else{

			return index < arg.index;
		}
	}
	int index;
	double value; //切片
};
//右下がり
struct DOWN{
	DOWN(int arg_index,double arg_value){
		index = arg_index;
		value = arg_value;
	}
	bool operator<(const struct DOWN &arg){

		if(fabs(value-arg.value) > EPS){

			return value < arg.value; //切片の昇順
		}else{

			return index < arg.index;
		}
	}

	int index;
	double value; //切片
};

int CURRENT = 0,NEXT = 1;
int up_loc[SIZE],down_loc[SIZE];
double NUM = sqrt(3);
vector<UP> up[2];
vector<DOWN> down[2];
Info info[SIZE];


//正三角形の周長を求める関数
double calc(double y,double up_value,double down_value){

	return 3*((down_value-y)/NUM-(y-up_value)/NUM);
}

void func(){

	for(int i = 0; i < 2; i++){
		up[i].clear();
		down[i].clear();
	}

	scanf("%d",&K);

	int max_Y = 0;

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

		scanf("%d %d",&info[i].x,&info[i].y);

		up[CURRENT].push_back(UP(i,(double)(info[i].y)-NUM*(double)(info[i].x))); //右上がり直線の切片
		down[CURRENT].push_back(DOWN(i,(double)(info[i].y)+NUM*(double)(info[i].x))); //右下がり直線の切片
		max_Y = max(max_Y,info[i].y);
	}

	sort(up[CURRENT].begin(),up[CURRENT].end());
	sort(down[CURRENT].begin(),down[CURRENT].end());

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

		//点iが配列上でどこにあるか
		up_loc[up[CURRENT][i].index] = i;
		down_loc[down[CURRENT][i].index] = i;
	}

	double ans = HUGE_NUM;
	int index_UP,index_DOWN;
	int num_out = 0,rest = N;

	bool is_OUT;

	for(int Y = 1; Y <= max_Y; Y++){

		if(num_out > K){

			break;
		}

		index_UP = 0; //左端から
		index_DOWN = rest-K+num_out-1; //外にちょうどK個出るようにする

		while(true){

			ans = min(ans,calc(Y,up[CURRENT][index_UP].value,down[CURRENT][index_DOWN].value));

			//今回点が外に出るかどうか
			is_OUT = down_loc[up[CURRENT][index_UP].index] <= index_DOWN;

			index_UP++;

			if(index_UP >= rest)break;

			if(is_OUT){ //外に出た点がないなら右下がりの直線の移動は不要
				index_DOWN++;
				while(index_DOWN < rest && up_loc[down[CURRENT][index_DOWN].index] < index_UP)index_DOWN++;
			}

			if(index_DOWN >= rest)break;
		}

		//後処理
		for(int k = 0; k < rest; k++){
			if(info[up[CURRENT][k].index].y > Y){
				up[NEXT].push_back(up[CURRENT][k]);
			}
			if(info[down[CURRENT][k].index].y > Y){
				down[NEXT].push_back(down[CURRENT][k]);
			}
		}

		up[CURRENT].clear();
		down[CURRENT].clear();

		swap(CURRENT,NEXT);
		rest = up[CURRENT].size();
		num_out = N-rest;

		//位置情報を記録
		for(int k = 0; k < rest; k++){

			up_loc[up[CURRENT][k].index] = k;
			down_loc[down[CURRENT][k].index] = k;
		}
	}

	printf("%.10lf\n",ans);
}

int main(){

	while(true){

		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	ll K; cin >> K;
	--K;

	int lastOne = -1;
	char res = 0;
	rep (i, (int)S.length()){
		if (S[i] == '1'){
			lastOne = i;
			continue;
		}else{
			res = S[i];
			break;
		} // end if
	} // end if

	cout << ((ll)lastOne >= K ? '1' : res) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>

#define mp make_pair
#define x first
#define y second
#define pb push_back
using namespace std;

int n, k, m, cnt, ans;
string s; char ch;

int main()
{
    cin >> n >> k >> s;
    ch = s[0]; cnt = 1;
    for(int i=1; i<n; ++i) if (ch != s[i]) {
        ch = s[i]; cnt += 1;
    } else ans += 1;
    if (cnt&1) m = cnt/2; else m = (cnt-1) / 2;
    m = min(m, k); ans += m * 2;
    if ((cnt&1) == 0) ans += (m < k);
    cout << ans;
}


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

int main(){
  int a, b, c, d, e, f, g, h, i;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;

  if(b-a==e-d && e-d==h-g && c-b==f-e && f-e==i-h && 
     d-a==e-b && e-b==f-c && g-d==h-e && h-e==i-f) cout << "Yes" <<endl;
  else cout << "No" << endl;
}


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


using namespace std;

bool Check2(vector<int> solution)
{
    for (int i = 1; i <= 9; i++)
    {
        if(solution[i] > 2)
        {
            solution[i] -= 3;
        }
        
        while(solution[i - 1] > 0) //667
        {
            solution[i - 1]--;
            solution[i]--;
            solution[i+1]--;
            
            if(solution[i] < 0 || solution[i + 1] < 0)
            {
                return 0;
            }
        }
    }
    
    return 1;
}

bool Check(vector<int> solution)
{
    bool isAdd;

    for (int i = 1; i <= 9; i++)
    {
        if(solution[i] > 1) // check if there are same numbers bigger than 1, like 99 or 777
        {
            solution[i] -= 2;
            
            isAdd = Check2(solution);
            
            solution[i] += 2; //repeat from above
            
            if(isAdd)
            {
                return 1;
            }
        }
    }
    
    return 0;
}

int main()
{
    string str;
    
    while(cin>>str)
    {
        vector<int> solution(14); // to save the number for new string
        
        bool flag = 0; //judge if there is a number can be added to str
        
        for (int i = 0; i < 13; i++)
        {
            //calculate the frequent rate of numbers, and start to formulate the rules to program
            solution[str[i] - '0']++; //save the frequent rate, base on rules, can not above 5
        }
        
        for (int i = 1; i <= 9 ; i++)
        {
            if(solution[i]>3)
            {
                continue;  // solution[i] == 0 or 1 or 2 or 3
            }
            
            solution[i]++; // try to add 1(frequent rate) for each number
            
            if(Check(solution))
            {
                if(flag)
                {
                    cout<<" ";
                }
                
                cout<<i;
                
                flag = 1;
            }
            
            solution[i]--;
        }
        
        if(!flag)
        {
            cout<<0<<endl;
        }
        else
        {
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1200
N = int(input())
A = list(map(int,input().split()))

S = abs(A[0])
for i in range(N-1):
    S += abs(A[i]-A[i+1])
S+= abs(A[-1])
#print(S)

if min(0,A[1]) <=  A[0] <= max(0, A[1]):
    print(S)
elif A[0] < min(0,A[1]):
    print(S+2*(A[0] - min(0,A[1])))
elif max(0, A[1]) < A[0]:
    print(S+2*(max(0, A[1]) - A[0]))
    
for i in range(1, N-1):
    if min(A[i-1],A[i+1]) <=  A[i] <= max(A[i-1], A[i+1]):
        print(S)
    elif A[i] < min(A[i-1],A[i+1]):
        print(S+2*(A[i] - min(A[i-1],A[i+1])))
    elif max(A[i-1], A[i+1]) < A[i]:
        print(S+2*(max(A[i-1], A[i+1]) - A[i]))

if min(A[-2],0) <=  A[N-1] <= max(A[-2], 0):
    print(S)
elif A[N-1] < min(A[-2],0):
    print(S+2*(A[N-1] - min(A[-2],0)))
elif max(A[-2], 0) < A[N-1]:
    print(S+2*(max(A[-2], 0) - A[N-1]))

Measured memory_bytes: 84332
#include<stdio.h>
#include <stdbool.h>

#define N 8
#define FREE -1
#define NOT_FREE 1
//#define false 0
//#define true 1


int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void initialize()
{
  int i;
  for(i = 0; i < N; i++)
    {
      row[i] = FREE;
      col[i] = FREE;
    }
  for(i = 0; i < 2 * N - 1; i++)
    {
      dpos[i] = FREE;
      dneg[i] = FREE;
    }
}

void printBoard()
{
  int i,j;
   for(i = 0; i < N; i++)
    {
      for(j = 0; j < N; j++)
	{
	  if(X[i][j])
	    if(row[i] != j)
	      return;
	}
    }
   for(i = 0; i < N; i++)
     {
       for(j = 0; j < N; j++)
	 {
	   if(row[i]==j)
	     printf("Q");
	   else
	     printf(".");
	 }
       printf("\n");
     }
}

void recursive(int i)
{
  int j;
  if(i == N)
    {
      printBoard();
      return;
    }
  for(j = 0; j < N; j++)
    {
      if(NOT_FREE == col[j] ||
	 NOT_FREE == dpos[i+j] ||
	 NOT_FREE == dneg[i - j + N -1])
	continue;   
      row[i] = j;
      col[j] = dpos[i+j] = dneg[i - j + N - 1] = NOT_FREE;
      recursive(i + 1);
      col[j] = dpos[i+j] = dneg[i - j + N - 1] = FREE;;
    }
}

int main()
{
  int i,j,k;
  int r,c;
  initialize();
  for(i = 0; i < N; i++)
    for(j = 0; j < N; j++)
      X[i][j] = false;

  scanf("%d",&k);
  for(i = 0; i < k; i++)
    {
      scanf("%d%d",&r,&c);
      X[r][c] = true;
    }
  recursive(0);
  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N;
    scanf("%lld", &N);
    printf("%lld\n", N*(N+1)/2);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
h,n,*t = map(int,open(0).read().split())

dp = [0] + [10**8]* h

for a,b in  zip(*[iter(t)]*2):
    for life_point in range(h +1):
        
        original_life = max(0,life_point - a)
#         print(original_life)
        magic_consum = dp[original_life]+ b
#         print(magic_consum)
        dp[life_point] = min(dp[life_point],magic_consum)
#         print(dp)
print(dp[h])

Measured memory_bytes: 42220
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include <math.h>
#define INF 0x3f3f3f3f
using namespace std;
int main() 
{
	int n,m;
	scanf("%d %d",&n,&m);
	printf("%d\n",(n-1)*(m-1));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    cin.sync_with_stdio(false);

    int n, m, x;

    cin >> n >> m >> x;
    int tollsleft = 0, tollsright = 0;

    while (m --> 0) {
        int pos;
        cin >> pos;
        if (pos < x) {
            tollsleft++;
        } else {
            tollsright++;
        }
    }

    cout << min(tollsleft, tollsright);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

const int MAXN = (int)2e5;

int p[MAXN];

int solve(int n) {
  int cur_min = p[0];
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (p[i] < cur_min) {
      cur_min = p[i];
      ++ans;
    }
  }
  return ans;
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> p[i];
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int sum = 0;
	int ans = 1e18;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int tt = 0;
	for(int i=1;i<=n;i++)
	{
		tt+=a[i];
		int rem = sum-tt;
		ans = min(ans,abs(tt-rem));
	}
	cout<<ans;
    return 0;
}
//.........

Measured memory_bytes: 1792
<?php

$s = explode(" ", trim(fgets(STDIN)));
$a = $s[0];
$b = $s[1];

$i = 0;
$c = 1;
while(true){
    if($c >= $b) break;
    $c = $c + ($a -1);
    $i++;
}
echo $i."\n";

Measured memory_bytes: 4728
if __name__ == '__main__':
    a, b, c =map(int, input().split())
    ab = 4 * a * b
    a_b_c = (c - (a + b))
    a_b_c_2 = a_b_c ** 2
    if a_b_c <= 0:
        print("No")
    else:
        if ab < a_b_c_2:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int max = Math.max(A,B);
        String result = "Yay!";
        if(max>8) result = ":(";
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
from collections import deque

n,m=map(int, input().split())
g = [[] for _ in range(n + 1)]
d = deque()
ans = [0]*(n+1)

for i in range(m):
    a,b=map(int, input().split())
    g[a].append(b)
    g[b].append(a)

d = deque()
for i in g[1]: 
    d.append(i)
    ans[i]=1

while d:
    tmp = d[0]
    for i in g[tmp]:
        if ans[i] == 0:
            ans[i]=tmp
            d.append(i)
    d.popleft()

if 0 in ans[2:]:
    print('No')
else:
    print('Yes')
    for i in range(2,n+1):
        print(ans[i])

Measured memory_bytes: 34740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <queue <ll>> v(n, queue <ll> ());
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    if (a == 0) {
      cout << v.at(b-1).front() << endl;
      v.at(b-1).pop();
    } else {
      ll min = INF, tmp;
      rep(j, n) {
        if (min > v.at(j).size()) {
          min = v.at(j).size();
          tmp = j;
        }
      }
      v.at(tmp).push(b);
    }
  }
}


Measured memory_bytes: 3236
#define M 300001
a[M],i,j;main(n,q,x){
	for(scanf("%d%d",&n,&q);i<n;i++)scanf("%d",&x),a[x]=x;
	for(i=1;i<M;i++)if(!a[i])a[i]=a[i-1];
	for(i=0;i<q;printf("%d\n",n),i++)for(n=0,scanf("%d",&x),j=x;j<=M;j+=x)if(n<a[j-1]%x)n=a[j-1]%x;
	exit(0);
}

Measured memory_bytes: 1768
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int X;

int main(){
    cin>>X;
    if(X<1200)out("ABC");
    else out("ARC");
}


Measured memory_bytes: 256
import numpy as np
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


l,r = map(int,input().split())
ans = 10000000

if r-l >= 2018:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            sup = (i*j)%2019
            if sup < ans:
                ans = sup

    print(ans)




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

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 a, b, c, d;
  cin >> a >> b >> c >> d;

  int i = 0;
  while(a > 0 && c > 0){
    if(i & 1){
      a -= d;
    }
    else{
      c -= b;
    }
    ++i;
  }

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    int c[n],s[n],f[n];
    rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
    rep(i,n){
        int t=0;
        for(int j=i;j<n-1;j++){
            if(t<s[j]) t=s[j];
            else if(t%f[j]==0);
            else t=t+f[j]-t%f[j];
            t+=c[j];
        }
        cout<<t<<endl;
    }
}



Measured memory_bytes: 256
func readIntList() -> [Int] {
    return readLine()!.split(separator: " ").map{Int($0)!}
}

func readInt() -> Int {
    return Int(readLine()!)!
}
func main() {
    let n = readInt()
    let aList = readIntList()
    var baget = 1000
    var stock = 0
    for i in 1...n {
        let nextPrice = aList[i+1-1]
        let nowPrice = aList[i-1]
        if stock > 0 {
            if  nextPrice >= nowPrice {
                continue
            } else {
                // sell
                baget += stock * nowPrice
                stock = 0
            }
        } else { // stock == 0
            if nextPrice <= nowPrice {
                continue
            } else {
                // buy
                stock = baget / nowPrice
                baget -= stock * nowPrice
            }
        }
    }
    if stock > 0 {
        baget += stock * aList[n-1]
    }
    print(baget)
}

main()



Measured memory_bytes: 8288
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next() + sc.next();
        int b = Integer.parseInt(a);
        int c = (int)Math.sqrt((double)(b));
        if(b == c*c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

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

    int pos = 0;
    int count = 1;  // at least bound one time because initial position is 0
    for (int i = 1; i <= n; ++i) {
        int l;
        cin >> l;
        pos += l;
        if (pos <= x)
            ++count;
    }
    cout << count << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

#define R (6378.1)

inline double Rad(double Deg){ return  Deg * ( acos(-1.0) / 180 ); }

struct EarthPoint{
	EarthPoint():x(0),y(0),z(0),longitude(0),latitude(0){}
	double longitude;
	double latitude;
	bool bValid;
	double operator ^(const EarthPoint &t) const {
		double distance;
		double r_sqd = pow(this->x - t.x,2.0) + pow(this->y - t.y,2.0) + pow(this->z - t.z, 2.0);

		distance = R * acos( 1 - r_sqd / (2*R*R) );
		return distance;
	}
	friend istream &operator>>(istream &, EarthPoint &);
private:
	double x,y,z;
};

istream &operator>>(istream &is, EarthPoint &t){
	is >> t.latitude >> t.longitude;
	
	if( t.latitude < -90 || t.latitude > 90 )
		t.bValid = false;
	if( t.longitude < 0 || t.longitude > 360 )
		t.bValid = false;

	if( !t.bValid ) return is;

	t.x = R * cos( Rad( t.latitude ) ) * sin( Rad( t.longitude ) );
	t.y = R * cos( Rad( t.latitude ) ) * cos( Rad( t.longitude ) );
	t.z = R * sin( Rad( t.latitude ) );
	return is;
}

int main(){
	while( true ){
		EarthPoint A, B;

		cin >> A >> B;

		if( !(A.bValid && B.bValid) ) break;

		cout << floor( (A ^ B) + 0.5 ) << endl;
	}
	return 0;
}

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

int main() {
    int n, k, q, a[100000] = {}, b[100000] = {};
    cin >> n >> k >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i];
        b[a[i] - 1]++;
    }
    for (int i = 0; i < n; i++) {
        if (k + b[i] - q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
    int n;cin >> n;
    bool e=false;
    for(int i=1;i<=n;i++){
        if(i*108/100==n){printf("%d\n",i);e=true;break;}
    }
    if(!e)printf(":(\n");
}

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

using namespace std;

int main()
{
    int n, m;
    int a[2048], b[2048];
    static int ca[1500 * 1000 + 1], cb[1500 * 1000 + 1];
    
    while (scanf("%d %d", &n, &m) && n){
        
        memset(ca, 0, sizeof(ca));
        memset(cb, 0, sizeof(cb));
        
        for (int i = 0; i < n; i++){
            scanf("%d", a + i);
            if (i) a[i] += a[i - 1];
            for (int j = 0; j <= i; j++){
                int s = a[i] - (j ? a[j - 1] : 0);
                ca[s]++;
            }
        }
        
        for (int i = 0; i < m; i++){
            scanf("%d", b + i);
            if (i) b[i] += b[i - 1];
            for (int j = 0; j <= i; j++){
                int s = b[i] - (j ? b[j - 1] : 0);
                cb[s]++;
            }
        }
        
        long long res = 0;
        
        for (int i = 1; i <= 1500 * 1000; i++){
            res += (long long)ca[i] * cb[i];
        }
        
        printf("%lld\n", res);
    }
    
    return (0);
}

Measured memory_bytes: 12928
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
        Array.Sort(a);
        Console.WriteLine(n % 2 == 0 ? getAnsEven(a, n) :getAnsOdd(a, n));
    }
    public static long getAnsOdd(int[] a, int n)
    {
        var n2 = n / 2;
        var ans = 0L;
        for (int i = 0; i < n2; i++)
            ans += (a[i + n2 + 1] - a[i]) * 2;
        ans += a[n2 - 1] - a[n2 + 1];
        var ans1 = ans + a[n2 + 1] - a[n2];
        var ans2 = ans + a[n2] - a[n2 - 1];
        return Max(ans1, ans2);
    }
    public static long getAnsEven(int[] a, int n)
    {
        var n2 = n / 2;
        var ans = 0L;
        for (int i = 0; i < n2; i++)
            ans += (a[i + n2] - a[i]) * 2;
        ans += a[n2 - 1] - a[n2];
        return ans;
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
vector<int> E[2020];
int num[2020];
vector<int> S[2020];

void dfs(int id,int cur,int pre,int d) {
	if(d>K) S[id].push_back(cur), num[id]++;
	FORR(r,E[cur]) if(r!=pre) dfs(id,r,cur,d+1);
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	FOR(i,N) dfs(i,i,-1,0);
	int del=0;
	FOR(i,2020) {
		int ma=0;
		FOR(x,N) if(num[x]>num[ma]) ma=x;
		if(num[ma]==0) break;
		FORR(r,S[ma]) num[r]--;
		num[ma]=0;
		del++;
	}
	
	cout<<del<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long i,a,N,S,ans=0;
  cin>>N>>S;
  vector<long long> v(S+1,0);
  while(N--){
    cin>>a;
    ++v[0];
    for(i=S;i>=a;i--)(v[i]+=v[i-a])%=998244353;
    ans+=v[S];
  }
  cout<<ans%998244353<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {

    int r; std::cin >> r;
    
    if (r < 1200) {
        std::cout << "ABC" << std::endl;
    }
    else if (r < 2800) {
        std::cout << "ARC" << std::endl;
    }
    else {
        std::cout << "AGC" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
//const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//解法:えすぱー
	llint h,i,j,n,K,mod;cin>>n>>K>>mod;
	static llint cp[301][301]={0};
	static llint dp[301][301]={0};
	cp[0][0]=1;
	for(i=1;i<=n;i++){
		cp[i][0]=1;
		//cerr<<"1 ";
		for(j=1;j<=i;j++){
			cp[i][j]=(cp[i-1][j]*(j+1)+cp[i-1][j-1])%mod;
			//cerr<<cp[i][j]<<" ";
		}
		//cerr<<endl;
	}
	dp[0][0]=1;
	for(i=1;i<=K;i++){
		for(j=0;j<=n;j++){
			for(h=0;h<=j;h++){
				dp[i][j]+=dp[i-1][h]*cp[j][h];
				dp[i][j]%=mod;
			}
			//cerr<<dp[i][j]<<" ";
		}
		//cerr<<endl;
	}
	llint ans=0;
	cout<<dp[K][n]<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  cout<<fixed;
  cout<<setprecision(32);
  long double a,b,eps=5e-4;
  cin>>a>>b;
  cout<<(ll)floor((a*b)+eps)<<endl;
  return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define OPTIMISE ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

#define POW5(i) (i*i*i*i*i)

int main() {
	OPTIMISE;

	long long int x;
	cin >> x;
	for (long long int i = -200; i <= 200; i++)
		for (long long int j = -200; j <= 200; j++)
			if (POW5(i) - POW5(j) == x) {
				cout << i << ' ' << j;
				return 0;
			}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int a=10000,b=-1,sum=0;
		for(int i=0;i<n;i++){
			int s;
			cin>>s;
			sum+=s;
			a=min(a,s);
			b=max(b,s);
		}
		cout<<(sum-a-b)/(n-2)<<endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int a, b; cin >> a >> b;
  cout << (b-1) / (a-1) + (int)(bool)((b-1) % (a-1)) << endl;
}


Measured memory_bytes: 256
a, b, c, k = map(int, input().split())
ans = 0
ans += 1*( min(a, k) )
k -= min(a, k)
ans += 0*( min(b, k) )
k -= min(b, k)
ans += (-1)*( min(c, k) )
k -= min(c, k)
print(ans)

Measured memory_bytes: 61528
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const long double pi = acos(-1);

int main()
{
	int a , b ; 
	cin >> a >> b ; 
	if(a > 12){
		cout << b <<endl ;
	}
	else if(a <= 12 and a >= 6){
		cout << b/2 << endl ;
	}
	else{
		cout << 0 << endl ;
	}
	return 0 ;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s,t;
int n,num;
ll a[N];

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

  cin >> n >> s;
  rep(i,n-2) {
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') num++;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
(defun fun ()
  (let ((a (read))
	(b (read))
	(c (read))
	(x (read))
	(ans 0))
    (dotimes (i (1+ a))
      (dotimes (j (1+ b))
	(dotimes (k (1+ c))
	  (if (eq x (+ (* 500 i)
		       (* 100 j)
		       (* 50  k)))
	      (setf ans (1+ ans))))))
    ans))

(format t "~A~%" (fun))

Measured memory_bytes: 12640
diagram = gets.chomp.chars

search = ->{
  max = min = height = 0
  diagram.each_with_index do |x, i|
    case x
    when "\\"
      height -= 1
      min = height if height < min
    when "/"
      height += 1
      max = height if height > max
    end
  end
  [max - min, max]
}

n, level = search.()
table = Array.new(n) {[]}

diagram.each_with_index do |x, i|
  case x
  when "\\"
    table[level] << i
    level += 1
  when "/"
    level -= 1
    a = table[level].last
    table[level] << i if a
  end
  table
end
table.map! do |one_level|
  one_level.each_slice(2).with_object([]) {|x, ar| ar << x if x.size == 2}
end

calc_area = ->(pair, level) {
  area = pair[1] - pair[0]
  return area if level == n
  table1 = table[level]
  table[level].each do |downer_pair|
    if pair[0] < downer_pair[0] and downer_pair[1] < pair[1]
      table1 -= [downer_pair]
      area += calc_area.(downer_pair, level + 1)
    end
  end
  table[level] = table1
  area
}

pools = []
solve = ->{
  min = [[Float::INFINITY, 0], 0]
  table.each_with_index do |one_level, i|
    next if one_level.empty?
    pair = one_level[0]
    min = [pair, i] if pair[0] < min[0][0]
  end
  table[min[1]] -= [min[0]]
  pools << calc_area.(min[0], min[1] + 1) if min[0][0] != Float::INFINITY
  solve.() unless table.flatten.empty?
}

solve.() unless table.empty?

if pools.empty?
  puts 0, 0
else
  puts pools.inject(&:+)
  puts pools.size.to_s + " " + pools.join(" ")
end


Measured memory_bytes: 124288
#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using namespace atcoder;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 998244353;

int main() {
	ll N;
	cin >> N;
	map<ll, pair<ll,ll>> P;
	ll a = 2;
	N *= 2;
	ll j = 0;
	while (a * a <= N) {
		ll k = 0;
		if (N % a == 0) {
			
			while (N % a == 0) {
				k++;
				N /= a;
			}
			P[j] = make_pair(a, k);
			j++;
		}
		a++;
	}
	if (N != 1) {
		P[j] = make_pair(N, 1);
	}
	ll ABC = P.size();
	ll k = 1e18;
	ll an = 1;
	if (ABC == 1) {
		rep(i, P[0].second) {
			an *= 2;
		}
		cout << an - 1 << endl;
		return 0;
	}
	for (int bit = 0; bit < (1 << ABC); ++bit) {
		ll A1 = 1;
		ll A2 = 1;
		vector<int> S;
		for (int i = 0; i < ABC; ++i) {
			if (bit & (1 << i)) { // 列挙に i が含まれるか
				rep(m, P[i].second) {
					A1 *= P[i].first;
				}
			}
			else {
				rep(m, P[i].second) {
					A2 *= P[i].first;
				}
			}
		}
		if ((A1 - 1) * (A2 - 1) != 0) {
			ll AN = inv_mod(A1, A2);

			k = min(k, A1*AN - 1);
		}
		
	}

	cout << k << endl;
}

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

int main() {
  int n;
  cin >>n;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  rep(i,n){
    string s;
    cin >>s;
    if (s=="AC") ac++;
    if (s=="WA") wa++;
    if (s=="TLE") tle++;
    if (s=="RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


Measured memory_bytes: 3620
N=int(input())
XY=[list(map(int,input().split())) for i in range(N)]
sum=0
kaijyo=1
for i in  range(N):
  for j in range(N):
    if i!=j:
      sum+=((XY[i][0]-XY[j][0])**2+(XY[i][1]-XY[j][1])**2)**0.5
    else:
      continue
print(sum/N)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>

using namespace std;

typedef std::pair<int, int> REC;

bool isLarger(REC rec1, REC rec2)
{
	int ret = (rec1.first*rec1.first + rec1.second*rec1.second ) - ( rec2.first*rec2.first + rec2.second*rec2.second);

	if (ret > 0)
		return true;
	if (ret < 0)
		return false;

	if (rec1.first > rec2.first)
		return true;
	return false;
}

int main()
{
	REC in, out, max(150, 150);

	while(1)
	{
		cin >> in.first >> in.second;
		if (in == make_pair(0, 0))
			break;

		out = max;
		for(int h = 1; h <= max.first; ++h)
		{
			for(int w = h + 1; w <= max.second; ++w)
			{
				auto temp = make_pair(h, w);
				if (isLarger(temp, in) && !isLarger(temp, out))
					out = temp;
			}
		}

		cout << out.first << " " << out.second << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

#define MAX 100

int main(){

	int n,q;
	int m;
	int data;
	int cnt[MAX+1];
	int max;
	int num;

	while(1){

		cin>>n>>q;
		if(n==0&&q==0) break;

		for(int i=0;i<=MAX;i++) cnt[i]=0;

		for(int i=0;i<n;i++){
			cin>>m;
			for(int j=0;j<m;j++){
				cin>>data;
				cnt[data]++;
			}
		}

		max=0;
		for(int i=0;i<=MAX;i++){
			if(cnt[i]>=q&&max<cnt[i]){
				max=cnt[i];
				num=i;
			}
			if(i==MAX){
				if(max==0) cout<<"0"<<endl;
				else cout<<num<<endl;
			}
		}

	}

}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b, c; cin >> a >> b >> c;
  ll ans = 0;
  for(ll i = 0;i < 1000000;i++)
  {
    if(a % 2 == 1||b % 2 == 1||c % 2 == 1)
    {
      fin(i)
      exit(0);
    }
    ll A = a / 2, B = b / 2, C = c / 2;
    a = B + C;
    b = A + C;
    c = B + C;
  }
  fin(-1)
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

int main(){
    ll a;
    long double b;
    cin >> a >> b;

    put(ll(a * b));
}

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

long long calc(long long a, long long b, long long divisor) {
	return b/divisor - (a-1)/divisor;
}
long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}
int main() {
	long long a, b, c, d;
	cin>>a>>b>>c>>d;
	long long e = c*d/gcd(c, d);
	cout<< (b+1-a) - calc(a, b, c) - calc(a, b, d) + calc(a, b, e) <<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input[] = { sc.nextInt(), sc.nextInt(), sc.nextInt() };
        int tmp;

        for (int i = 0; i < input.length; i++) {
            for (int j = i + 1; j < input.length; j++) {
                if (input[i] > input[j]) {
                    tmp = input[i];
                    input[i] = input[j];
                    input[j] = tmp;
                }
            }
        }
        StringBuffer sb = new StringBuffer(input[0] + " " + input[1] + " "
                + input[2]);
        System.out.println(sb);
    }
}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int A,B;
int main(){
  cin>>A>>B;
  swap(A,B);
  A--;
  B--;
  cout<<100<<" "<<100<<endl;
  string board="";
  rep(i,49){
    rep(j,100){
      if(A>0 && (j)%2==1&&i%2==0){
        board+='#';
        A--;
      }else{
        board+='.';
      }
    }
    board+='\n';
  }
  rep(i,100)board+='.';
  board+='\n';
  rep(j,100)board+='#';
  board+='\n';
  rep(i,49){
    rep(j,100){
      if(B>0 && (j)%2==1&& i%2==0){
        board+='.';
        B--;
      }else{
        board+='#';
      }
    }
    board+='\n';
  }
  cout<<board<<endl;



}


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

namespace ConsoleApp11
{
    class Class26
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse ).ToList();

            long R = (int)Math.Pow(3,N), Odd = 1;
            for(int i = 0; i < N; i++)
                Odd*= A[i] % 2 == 0 ? 2 : 1;
            Console.WriteLine(R-Odd);
            
        }
    }
}


Measured memory_bytes: 13268
from itertools import combinations_with_replacement

def main():
    n, m, q = map(int, input().split())
    abcd_l = [list(map(int, input().split())) for _ in range(q)]

    ans = 0
    # m+n_C_n で重複組み合わせで広義単調増加の数列を表現する(高々 20_C_10 \simeq 2 \times 10^5)
    for i in combinations_with_replacement(range(1, m+1), n-1):
        A = [1] + list(i) # A の最小値は必ず１なのでn-1個選んで端に１を足してる
        total = 0
        for abcd in abcd_l:
            # Python は  0-originだから−１に注意 A_b - A_a = c
            if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]:
                total += abcd[3]
        ans = max(ans, total)
    return ans

if __name__ == "__main__":
    print(main())

Measured memory_bytes: 9212