akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
long long gcd(long long a,long long b)
{
	long long c;
	while (a%b!=0) {
		c=a%b;
		a=b;
		b=c;
	}
	return b;
}
int main()
{
	//freopen("GCDLCM.in","r",stdin);
	//freopen("GCDLCM.out","w",stdout);
	long long a,b,maxy,minb;
	while (cin>>a>>b) {
		maxy=gcd(a,b);
		minb=a*b/maxy;
		cout<<maxy<<" "<<minb<<endl;
	}
	return 0;
}

Measured memory_bytes: 3052
N, Y = map(int, input().split())
x, y, z = -1, -1, -1

for a in range(N+1):
    for b in range(N+1):
        c = N-a-b
        if c < 0:
            break
        num = 10000*a + 5000*b + 1000*c
        if a+b+c == N and num == Y:
            x, y, z = a, b, c
            break

print(x, y, z)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

// #include "prettyprint.hpp"

using namespace std;

typedef long long ll;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && a == c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	long long ans = 0;
	if (L <= -N) {
		for (int i = 0; i < N - 1; i++) {
			ans += L + i;
		}
	}
	else if (L < 0) {
		for (int i = 0; i < N; i++) {
			ans += L + i;
		}
	}
	else {
		for (int i = 1; i < N; i++) {
			ans += L + i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
t=int(input())
print(arr[t-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
    {
      if(n==i*j)
      {
        cout<<"Yes";
        return 0;
      }
    }
  cout<<"No";
  return 0;
}

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

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,h,u,v,x,y,z;
    string s;
    cin>>s;
    ll sum = 0;
    for(auto ch:s)
    {
        sum+=(ch-'0');
    }
    if(sum%9)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	string S;
	cin >> S;
	string tmp_S;
	int C_index;
	int lower_count = 0;
	if (S[0] == 'A') {
		tmp_S = S.substr(2, S.length() - 3);
		if (count(tmp_S.cbegin(), tmp_S.cend(), 'C') == 1) {
			C_index = S.find('C');
			for (int i = 1; i < S.length(); i++) {
				if (i != C_index) {
					if (!islower(S[i])) {
						cout << "WA";
						return 0;
					}
				}
			}
			cout << "AC";
			return 0;
		}
	}
	cout << "WA";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int Q;
    cin >> Q;
    vector<pair<int,int>> BC(Q);
    for(int i = 0; i < Q; i++) cin >> BC[i].fi >> BC[i].se;

    map<ll,ll> count;
    ull sum = 0;
    for(int a : A) {
        count[a]++;
        sum+= a;
    }
    for(auto bc : BC){
        sum += (bc.se - bc.fi) * (count[bc.fi]);
        count[bc.se] += count[bc.fi];
        count[bc.fi] = 0;
        cout << sum << endl;
    }
}

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

using namespace std;

int main(){
    
    int n,sum=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i <n; i ++)cin>>v[i];
    
    sort(v.begin(),v.end());
    
    for(int i=0; i <n; i ++){
        for(int j=i+1; j <n-1; j ++){
            
            int start = j+1, end = n-1, k;
            if(v[i] + v[j] <= v[start]) k = j;
            else if (v[i] + v[j] > v[end]) k = n-1;
            else {
                
                while(start < end - 1){
                    int c = (start + end)/2;
                    
                    if(v[i] + v[j] <= v[c]) end = c;
                    else start = c;
                    
                }
                
                k = start;
                
            }
            
            sum += (k-j);
            //cout<<sum << " "<< i <<" "<< j <<endl;
        }
    }
    
    
    
    cout<<sum<<endl;
    
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll N,M,x;
int ans[200001];
bool b[200000];
int main()
{
	memset(ans,-1,sizeof(ans));
	cin>>N>>M;
	if(M>=3) x=M-2;
	else x=M+2;
	b[M-1]=b[M]=b[M+1]=b[x]=1;
	if(M==1||M==2*N-1) puts("No");
	else{
		puts("Yes");
		if(N==2){
			cout<<"1 2 3"<<endl;
			return 0;
		}
		else{
			if(x==M+2){
				ans[N-1]=M+1;
				ans[N]=M;
				ans[N+1]=M-1;
				ans[N+2]=M+2;
			}
			else{
				ans[N-1]=M-1;
				ans[N]=M+1;
				ans[N+1]=M;
				ans[N+2]=M-2;
			}
			int cnt=1;
			for(int i=1;i<=2*N-1;i++){
				if(ans[i]!=-1) continue;
				while(b[cnt]) cnt++;
				ans[i]=cnt;
				cnt++;
			}
		}
	rep1(i,2*N-2) cout<<ans[i]<<" ";
	cout<<ans[2*N-1]<<endl;
	}
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,A,B,C;
const int MAX_N=200010;
ll mod_pow(ll x, ll n, ll mod=MOD){
    if (n==0) return 1;
    ll res=mod_pow(x*x%mod, n/2, mod);
    if (n%2==1) res=res*x%mod;
    return res;
}
ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}

ll mod_inverse(ll a, ll m=MOD){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
ll fact[MAX_N], invfact[MAX_N];
ll comb(ll a, ll b){
    return fact[a]*invfact[b]%MOD*invfact[a-b]%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>A>>B>>C;
    fact[0]=1;
    invfact[0]=1;
    rep(i,1,MAX_N){
        fact[i]=fact[i-1]*i%MOD;
        invfact[i]=mod_inverse(fact[i]);
    }
    ll ans=0;
    ll a=A*mod_inverse(A+B)%MOD, b=B*mod_inverse(A+B)%MOD;
    rep(i,0,N){
        ans+=mod_pow(b, i)*comb(N+i-1, i)%MOD*(N+i)%MOD;
        ans%=MOD;
    }
    ans=ans*mod_pow(a, N)%MOD;
    ll t=mod_pow(b, N);
    rep(i,0,N){
        ans+=t*mod_pow(a, i)%MOD*comb(N+i-1, i)%MOD*(N+i);
        ans%=MOD;
    }
    cout << ans*mod_inverse(100-C)%MOD*100%MOD<<"\n";
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void){
    int i,j,k;
    int n,l,m;
    int mata[100][100] = {};
    int matb[100][100] = {};
    long long int seki;

    seki = 0;
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&mata[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&matb[i][j]);
        }
    }

    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            seki = 0;
            for(k=0;k<m;k++){
                seki = seki + mata[i][k] * matb[k][j];
            }
            if(j+1 == l){
                printf("%lld",seki);
            }
            else{
                printf("%lld ",seki);
            }
        }
        printf("\n");
    }
    return(0);
}

Measured memory_bytes: 692
#include<bits/stdc++.h>
using namespace std;
const int M=1e3+60;
int a[M][M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			scanf("%d",&a[i][j]);
		}
		a[i][0]=1;
	}
	int num=n*(n-1)/2;
	int flag=0;
	int ans=0;
	int i=0;
	while(1){
		int flag2=0;
		int used[M]={0};
		for(int j=1;j<=n;j++){
			int k=a[j][0];
			if(k!=n&&!used[j]){
				int t1=a[j][k];
				int k2=a[t1][0];
				int t2=a[t1][k2];
				if(!used[t1]&&k2!=n&&t2==j){
					a[t1][0]++;
					a[j][0]++;
					used[t1]=1;
					used[j]=1;
					flag2=1;
					i++;
				}
			}
		}
		ans++;
		if(!flag2){
			flag=1;
			break;
		}
		if(i==num){
			break;
		}
	}
	if(!flag){
		printf("%d\n",ans);
	}else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  string s;
  cin >> s;
  if (s.size()%2 == 1) s += "0";
  while(1) {
    s.erase(s.size()-2,2);
    if (s.substr(0,s.size()/2) == s.substr(s.size()/2,s.size()/2)) {
      cout << s.size() << '\n';
      return 0;
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

vector<string> lis;
vector<vector<int> > dp;
int h, w;

int main(){
    cin >> h >> w;
    lis = vector<string>(h);
    dp = vector<vector<int> >(h, vector<int>(w, 1e9));
    REP(i, 0, h){cin >> lis[i];}
    dp[0][0] = 0;
    queue<Pii> q;
    q.push({0, 0});
    int count = 0;
    REP(i, 0, h){
        REP(l, 0, w){
            if(lis[i][l] == '#'){
                count++;
            }
        }
    }
    while(!q.empty()){
        Pii a = q.front();
        q.pop();
        int x = a.first, y = a.second;
        REP(i, 0, 4){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx >= 0 && ny >= 0 && nx < h && ny < w && lis[nx][ny] == '.' && dp[nx][ny] > dp[x][y]+1){
                dp[nx][ny] = dp[x][y]+1;
                q.push({nx, ny});
            }
        }
    }
    if(dp[h-1][w-1] == 1e9){
        cout << -1 << endl;
        return 0;
    }
    cout << h*w - (dp[h-1][w-1]+1) - count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    float s = 0;
    for (int i = 0; i < n; i++) {
        float x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            s += x;
        } else {
            s += x * 380000;
        }
    }
    cout << s << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,d,ans=0,dd,ddd;
    cin>>n>>d;
    long long x[n][d];
    f(i,0,n){
        f(j,0,d){
            cin>>x[i][j];
        }
    }
    f(i,0,n){
        f(j,i+1,n){
            dd=0;
            f(k,0,d){
                dd+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            ddd=sqrt(dd);
            if(ddd*ddd==dd){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3664
n, m = (int(x) for x in input().split())
matrix = []
vector = []

for i in range(n):
    matrix.append([int(x) for x in input().split()])

for i in range(m):
    vector.append(int(input()))

ans_vector = []

for line in matrix:
    sum = 0
    for i in range(m):
        sum += line[i] * vector[i]
    
    ans_vector.append(sum)

for ans in ans_vector:
    print(ans)



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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

long get_hash(string thing){
    long ans = 0;
    for(long i = 0; i < thing.size(); i++){
        ans += (thing[i] - 'a') * (thing[i] - 'a') * (i + 1) * (i + 1);
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    string space[N * 2];
        for(int i = 0; i < N; i++){
        cin >> space[i];
        space[i] += space[i];
        space[N + i] = space[i];
        
    }
    long row_hash[N * 2][N];
    long column_hash[N][N * 2];
    for(int i = 0; i < N * 2; i++){
        for(int j = 0; j < N; j++){
            string this_string;
            for(int k = 0; k < N; k++){
                this_string.push_back(space[i][j + k]);
            }
            row_hash[i][j] = get_hash(this_string);
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N * 2; j++){
            string this_string;
            for(int k = 0; k < N; k++){
                this_string.push_back(space[i + k][j]);
            }
            column_hash[i][j] = get_hash(this_string);
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            bool is_ok = true;
            for(int k = 0; k < N; k++){
                if(row_hash[i + k][j] != column_hash[i][j + k]){
                    is_ok = false;
                    break;
                }
            }
            ans += is_ok;
        }
    }
    cout << ans << endl;
}



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

using namespace std;

int main(){
    long long t1, t2, a1, b1, a2, b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;
    if(a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2){
        cout << "infinity\n";
        return 0;
    }
    long long cnt = 0;
    long long rap1 = (a1 - b1) * t1, rap2 = (a2 - b2) * t2, rap = rap1 + rap2;
    if(rap1 == 0){
        cout << 1 << "\n";
        return 0;
    }
    if(rap1 < 0 == rap > 0){
        long long div = abs(rap1) / abs(rap), mod = abs(rap1) % abs(rap);
        cnt += abs(rap1) / abs(rap) * 2;
        if(mod){
            cnt++;
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	int K,X; cin >> K >> X;
	for (int i = X-(K-1); i <= X+(K-1); i++)
	{
		cout << i << ' ';
	}
	
	
	cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;cin>>n;
    ll sum=0;
    map<ll,ll>mp;
    ll a[n];
    for(int i=0;i<n;i++){cin>>a[i];mp[a[i]]++;sum+=a[i];}
    int q;cin>>q;
    while(q--)
    {
        ll b,c;
        cin>>b>>c;
        ll val = mp[b];
        mp[b]=0;mp[c]+=val;
        sum = sum - b*(val)+c*(val);
        cout<<sum<<endl;
    }
    
   
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vec;


int main(){
    ll N,K; cin >> N >> K;
    vec h(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    vec dp(N,1e+15);    
    dp[0] = 0;

    for (ll i = 0; i < N; i++)
    {
        for (ll j = 1; i+j < N and j <= K; j++)
        {
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));        
        }
    }
    cout << dp[N-1] << endl;
    


}

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

int main(){
   int H, W;
   
   while(1){
    cin >> H >> W;
   if (W==0&&H==0) break;
   for (int i=1; i<=H; i++){
          for  (int j=1; j<=W; j++){
            cout << '#';
   }
        cout << endl;
   }
   cout<< endl;
}

 return 0;
}



Measured memory_bytes: 3104
using System;
using System.Linq;

namespace ProgramingLearning
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var n = int.Parse(Console.ReadLine());

            var ans = 1;

            for(int i = 2; i < n; i++)
            {
                var m = i;

                //mの素因数分解
                var sum = 1;
                for (int j = 2; j <= Math.Sqrt(m); j++)
                {
                    var count = 0;
                    while(m % j == 0)
                    {
                        count++;
                        m /= j;
                    }
                    sum *= (count + 1);
                    if(m == 1)
                    {
                        break;
                    }
                }
                if(m != 1)
                {
                    sum *= 2;
                }
                ans += sum;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27528
import java.util.ArrayList;
import java.util.Arrays;
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();
    int k = sc.nextInt();
    long answer = Long.MIN_VALUE;
    int[] p = new int[n];
    long[] c = new long[n];
    for(int i = 0; i < n; i++) p[i] = sc.nextInt() - 1;
    for(int i = 0; i < n; i++) c[i] = sc.nextLong();
    List<Cycle> cycleList = new ArrayList<>();
    boolean[] isVisit = new boolean[n];
    Arrays.fill(isVisit, false);
    for(int i = 0; i < n; i++){
      int idx = i;
      if(isVisit[idx] == true){
        continue;
      }
      ArrayList<Long> cList = new ArrayList<>();

      while(true){
        if(isVisit[idx] == true) break;
        cList.add(c[p[idx]]);
        isVisit[idx] = true;
        idx = p[idx];
      }
      cycleList.add(new Cycle(cList.stream().mapToLong(l -> l).toArray()));
    }
    for(Cycle cycle : cycleList){
      if(cycle.total <= 0 ){
        int k2 = Integer.min(k, cycle.size);
        for(int i2 = 0; i2 < cycle.size; i2++){
          long total2 = 0;
          int cnt = 0;
          while(cnt < k2){
            total2 += cycle.c[(i2 + cnt) % cycle.size];
            answer = Math.max(answer, total2);
            cnt++;
          }
        }
      } else {
        int k1 = Integer.max(0, (k / cycle.size) - 1);
        int k2 = Integer.min(k, cycle.size + (k % cycle.size));
        for(int i2 = 0; i2 < cycle.size; i2++){
          long total2 = cycle.total * k1;
          int cnt = 0;
          while(cnt < k2){
            total2 += cycle.c[(i2 + cnt) % cycle.size];
            answer = Math.max(answer, total2);
            cnt++;
          }
        }
      }
    }
    System.out.println(answer);
  }
  static class Cycle {
    long total;
    int size;
    long[] c;
    public Cycle(long[] c){
      this.c = c;
      size = c.length;
      for(long v : c){
        total += v;
      }
    }
  }
}

Measured memory_bytes: 49532
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(ix,v.size())cout<<" "<<v[ix];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))

const int INF = 2125252830;

int r,c,n;
int xx[125252],yy[125252];
int val[125252];

int xmin[125252];
vector<pii> ys[125252];
vector<pii> g[125252];
ll dist[125252];
bool used[125252];

bool po[125252];
int a;
int node[125252];
int vere[125252];

bool check(){
  REP(i,a)vere[node[i]] = i;
  REP(i,a)dist[i] = 0;
  REP(i,a)used[i] = false;
  dist[0] = 0;
  used[0] = true;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    int id = node[p];
    ll d = dist[p];
    REP(i,g[id].size()){
      int to = vere[g[id][i].first];
      ll cost = (ll)g[id][i].second;
      ll nd = d+cost;
      if(used[to]){
        if(dist[to]!=nd)return false;
      }else{
        dist[to] = nd;
        used[to] = true;
        Q.push(to);
      }
    }
  }
  // negative check
  ll sm = *min_element(dist,dist+a);
  REP(i,a){
    if(sm + (ll)xmin[node[i]] < 0){
      return false;
    }
    if(i==a-1)break;
    sm -= dist[i+1]-dist[i];
  }
  return true;
}
 
bool valid(int n){
  REP(i,125252)po[i]=false;
  REP(i,n){
    if(po[i])continue;
    a = 0;
    po[i] = true;
    node[a++] = i;
    queue<int> Q;
    Q.push(i);
    while(!Q.empty()){
      int p = Q.front(); Q.pop();
      REP(j,g[p].size()){
        int to = g[p][j].first;
        if(po[to])continue;
        po[to] = true;
        node[a++] = to;
        Q.push(to);
      }
    }
    sort(node,node+a);
    if(!check())return false;
  }
  return true;
}

int Sx[125252],Sy[125252];
int Mx[125252],My[125252];
 
int main(){
  scanf("%d%d%d",&r,&c,&n);
  REP(i,n){
    scanf("%d%d%d",xx+i,yy+i,val+i);
    Sx[i] = xx[i];
    Sy[i] = yy[i];
  }
  sort(Sx,Sx+n);
  sort(Sy,Sy+n);
  r = unique(Sx,Sx+n)-Sx;
  c = unique(Sy,Sy+n)-Sy;
  REP(i,r)Mx[Sx[i]]=i;
  REP(i,c)My[Sy[i]]=i;

  REP(i,125252)xmin[i] = INF;
  REP(i,n){
    int x,y;
    x=Mx[xx[i]];
    y=My[yy[i]];
    CHMIN(xmin[y],val[i]);
    ys[x].push_back(pii(y,val[i]));
  }
  // graph
  REP(i,r){
    sort(ALL(ys[i]));
    vector<pii> &vec = ys[i];
    REP(j,vec.size()-1){
      int s,t;
      s = vec[j].first;
      t = vec[j+1].first;
      int sa = vec[j+1].second - vec[j].second;
      g[s].push_back(pii(t,sa));
      g[t].push_back(pii(s,-sa));
    }
  }
  if(!valid(r)){
    puts("No");
    return 0;
  }
  // ok
  puts("Yes");
  return 0;
}


Measured memory_bytes: 13952
S = input()
N = len(S)
r_cnt = 1
l_cnt = 0
idx = 0
ans = [0] * N
for i in range(1, N):
    if S[i-1] == "L" and S[i] == "R":
        if (r_cnt + l_cnt) % 2 == 0:
            ans[idx-1] = (r_cnt + l_cnt) // 2
            ans[idx] = (r_cnt + l_cnt) // 2
        else:
            if l_cnt % 2 == 0:
                ans[idx-1] = (r_cnt + l_cnt) // 2 + 1
                ans[idx] = (r_cnt + l_cnt) // 2
            else:
                ans[idx - 1] = (r_cnt + l_cnt) // 2
                ans[idx] = (r_cnt + l_cnt) // 2 + 1
        r_cnt = 0
        l_cnt = 0

    elif S[i-1] == "R" and S[i] == "L":
        idx = i
    if S[i] == "R":
        r_cnt += 1
    elif S[i] == "L":
        l_cnt += 1

if (r_cnt + l_cnt) % 2 == 0:
    ans[idx - 1] = (r_cnt + l_cnt) // 2
    ans[idx] = (r_cnt + l_cnt) // 2
else:
    if l_cnt % 2 == 0:
        ans[idx - 1] = (r_cnt + l_cnt) // 2 + 1
        ans[idx] = (r_cnt + l_cnt) // 2
    else:
        ans[idx - 1] = (r_cnt + l_cnt) // 2
        ans[idx] = (r_cnt + l_cnt) // 2 + 1
print(*ans)

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
long double a,b,h,m,c,d1,d2;
int main()
{
	cin>>a>>b>>h>>m;
	d1=m/2.0+h*30.0;
	d2=m*6.0;
	d2=d1-d2;
	d2/=180.0;
	c=sqrt(2.0*a*b)*sqrt((a*a+b*b)/(2.0*a*b)-cos(d2*3.14159265358979323846264338327950L));
	cout<<fixed<<setprecision(15)<<c; 
}


Measured memory_bytes: 4176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    bool ans = false;
    for (int i = 0; i <= 25; i++) {
        for (int j = 0; j <= 15; j++) {
            if (4 * i + 7 * j == N) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int A = 0;
  cin >> N;
  for(int i =0;i < (N + 1);i++){
  string Color;
  cin  >> Color;
  bool X = (Color == "P"  || Color =="W" || Color == "G");
  bool Y = (Color == "Y");
    if(X){
    A += 0;}
    if(Y){
    A += 1;}
    if(i == N){
      if(A == 0){
    cout << "Three" << endl;}
      else cout << "Four" << endl;}}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1,2,0,-2,0};
const int dy[]={0,1,-1,0,1,1,-1,-1,0,2,0,-2};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
vector < Pii > D[7];
vector < Pii > N[7];
int main(){
	int W,H;
	while(scanf("%d%d",&W,&H),(W|H)){
		rep(i,7){
			D[i].clear();
		}
		rep(i,H){
			char s[1024];
			scanf("%s",s);
			rep(j,W){
				if(s[j] == 'S'){
					D[0].PB(Pii(i,j));
				}
				else if(s[j] == 'G'){
					D[6].PB(Pii(i,j));
				}
				else if(s[j] != '.'){
					D[s[j]-'0'].PB(Pii(i,j));
				}
			}
		}
		int dp[6][1024];
		Pii ans;
		ans.fr = INF;
		ans.sc = INF;

		N[0] = D[0];
		N[5] = D[6];
		
		reps(f,1,6){
			//init
			rep(i,6){
				rep(j,1024){
					dp[i][j] = INF;
				}
			}
			dp[0][0] = 0;

			//p
			reps(i,1,5){
				int prev = ((f+i-1)%5)+1;
				N[i] = D[prev];
			}

			//dp
			rep(i,6){
				if(i == 5)continue;
				rep(j,N[i].size()){
					rep(k,N[i+1].size()){
						dp[i+1][k] = min(dp[i+1][k],dp[i][j]+abs(N[i][j].fr-N[i+1][k].fr)+abs(N[i][j].sc-N[i+1][k].sc));
						//printf("%d\n",dp[i+1][k]);
					}
				}
			}

			//update
			ans = min(ans,mk(dp[5][0],f));
		}

		if(ans.fr == INF){
			puts("NA");
		}
		else{
			printf("%d %d\n",ans.sc,ans.fr);
		}
	}
	return 0;
}

Measured memory_bytes: 1308
import scala.io.StdIn._

object Main extends App {
  val Seq(a, b, k) = readLine().split(" ").map(_.toInt).toSeq
  ((a until a + k) ++ (b - k + 1 to b)).toSet.filter(i => a <= i && i <= b).toSeq.sorted.map(println)
}


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

int main(){
    int r;
    double pi = 3.141592;
    cin >> r;
    double l;
    l = 2*r*pi;
    cout << l << endl;

    return 0;
}



Measured memory_bytes: 3788
#include <stdio.h>
main(){
  int i,N,fx[200],fy[200],num,xmax,xmin,ymax,ymin,d;
  int dx[4] = {-1,0,1,0};
  int dy[4] = {0,1,0,-1};
  fx[0] = 0;
  fy[0] = 0;

  while(1){
    scanf("%d",&N);
    if(N == 0) break;
    
    for(i=1;i<N;i++){
      scanf("%d%d",&num,&d);
      fx[i] = fx[num] + dx[d];
      fy[i] = fy[num] + dy[d];
    }

    xmax = 0;
    xmin = 0;
    ymax = 0;
    ymin = 0;

    for(i=0;i<N;i++){
      if(fx[i] > xmax) xmax = fx[i];
      if(fx[i] < xmin) xmin = fx[i];
      if(fy[i] > ymax) ymax = fy[i];
      if(fy[i] < ymin) ymin = fy[i];
    }

    printf("%d %d\n",xmax-xmin+1,ymax-ymin+1);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){

int i,n;

int number;

long long int sum=0;

int min=0;

int max=0;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&number);

if(i==0){

min=number;

max=number;

}

if(number<min)min=number;

if(number>max)max=number;

sum+=number;

}

printf("%d %d %lld\n",min,max,sum);

return 0;

}
 

Measured memory_bytes: 600
#include<stdio.h>
#define N 100
int main(){
  int ary[N];
  int i,j,n,tmp,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(ary[j]<ary[j-1]){
	tmp=ary[j];
	ary[j]=ary[j-1];
	ary[j-1]=tmp;
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",ary[i]);
  }
  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>
int main()
{
int n,a;
  double x,all=0;
  char u[3];
scanf("%d ",&n);
  for(a=0;a<n;a++){
 scanf("%lf %s",&x,u);
  if(u[0]=='J')
  all+=x;
  else  
  all+=x*380000;
  }
   printf("%f\n",all);
return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  bool flag[4] = {false, false, false, false};
  int n;
  for (int i=0; i<4; i++){
    cin >> n;
    switch(n){
      case 1:
        flag[0] = true;
        break;
      case 9:
        flag[1] = true;
        break;
      case 7:
        flag[2] = true;
        break;
      case 4:
        flag[3] = true;
        break;
      default:
        continue;
    }
  }
  
  cout << (flag[0]*flag[1]*flag[2]*flag[3] ? "YES" : "NO") << endl;
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    int R,B;
    R=0; B=0;
    for(int i = 0; i < S.length(); i++)
    {
        if(S[i]=='0') R++;
        else B++;
    }
    int ans = min(R,B) * 2;
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n,k;
  cin >> n >> k;
  vi h(n,0);
  rep(i,n) cin >> h.at(i);
  sort(rrng(h));

  ll ans = 0;
  srep(i,k,n) ans+=h.at(i);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();//球
		int K=sc.nextInt();//颜色
		int ways=K;
		for(int i=0;i<N-1;i++) {
			ways=ways*(K-1);
		}
		System.out.println(ways);
		

	}

}


Measured memory_bytes: 21716
def pre_combi1(n, p):
    fact = [1]*(n+1)  # fact[n] = (n! mod p)
    factinv = [1]*(n+1)  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0]*(n+1)  # factinv 計算用
    inv[1] = 1
    # 前処理
    for i in range(2, n + 1):
        fact[i]= fact[i-1] * i % p
        inv[i]= -inv[p % i] * (p // i) % p
        factinv[i]= factinv[i-1] * inv[i] % p
    return fact, factinv

def combi1(n, r, p, fact, factinv):
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p

import sys
x,y=map(int,input().split())
if (x+y)%3 > 0:
  print(0)
  sys.exit()
n=(x+y)//3
r=x-n
f,inv=pre_combi1(n,1000000007)
print(combi1(n,r,1000000007,f,inv))

Measured memory_bytes: 54256
#include<iostream>

using namespace std;

int main(void) {
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  int i = min(a, b);
  for (; cnt < k; i--) {
    if (a % i == 0 && b % i == 0) {
      cnt++;
    }
  }
  i++;
  cout << i << endl;
  return 0;
  }


Measured memory_bytes: 256
def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()



def main():
    H,A = isRaw()
    return (H+A-1)//A


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


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n,m;
int u,v;
int ans[N];
vector<int> s[N];

void bfs(){
    queue<int> q;
    q.push(1);
    ans[1]=1;
      while(!q.empty()){
          int tmp=q.front();
          q.pop();
          for(auto w:s[tmp]){
              if(ans[w]==0){
                  ans[w]=tmp;
                  q.push(w);
              }
          }
      }
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m;
     for(int i=1;i<=m;++i){
         cin>>u>>v;
          s[u].pb(v);
          s[v].pb(u);
     }
     bfs();

     for(int i=1;i<=n;++i){
         if(ans[i]==0){
             puts("No");
             return 0;
         }
     }
     puts("Yes");
     for(int i=2;i<=n;++i) printf("%d\n",ans[i]);

    return 0;
}

Measured memory_bytes: 31708
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n-1)

	for i := range a {
		fmt.Scan(&a[i])
	}

	res := make([]int, n)

	for _, n := range a {
		res[n]++
	}

	for i, r := range res {
		if i == 0 {
			continue
		}
		fmt.Println(r)
	}
	fmt.Println(0)
}


Measured memory_bytes: 7988
while x = gets.split()
  if x[1] == "?"
    break
  elsif x[1] == "+"
    puts x[0].to_i+x[2].to_i
  elsif x[1] == "-"
    puts x[0].to_i-x[2].to_i
  elsif x[1] == "*"
    puts x[0].to_i*x[2].to_i
  elsif x[1] == "/"
    puts x[0].to_i/x[2].to_i
  end
end

Measured memory_bytes: 8660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int L,R;
    cin >> L >> R;
    int ans=2019;
    if(R-2019>L) ans=0;
    else{
        L%=2019;
        R%=2019;
        if(L>R) ans=0;
        else {
            for(int i=L;i<=R;i++){
                for(int j=L;j<=R;j++){
                    if(i==j) continue;
                    ans=min(ans,i*j%2019);
                }
            }
        }
    }
    cout << ans<< endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

const int W = 200010;
const int M = 1000000007;
 
long long inv[W];
long long fact[W];
long long factinv[W];
 
void init() {
  inv[1] = 1;
  for (int i=2; i<W; i++) {
    inv[i] = ((M - inv[M%i]) * (M/i))%M;
  }
  fact[0] = factinv[0] = 1;
  for (int i=1; i<W; i++) {
    fact[i] = (i * fact[i-1])%M;
    factinv[i] = (inv[i] * factinv[i-1])%M;
  }
}
 
long long nCr(int n, int k)
{
  if (n >=0 && k >= 0 && n-k >= 0) {
    return ((fact[n] * factinv[k])%M * factinv[n-k])%M;
  }
  return 0;
}


int main()
{
  init();
    
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  --H, --W;
  long long val = nCr(H + W, H);
  for(int i = 0; i < B; i++) {
    long long mos = nCr((H - A) + i, (H - A));
    long long kas = nCr(A - 1 + (W - i), A - 1);
    val += MOD * MOD - mos * kas;
    val %= MOD;
  }
  cout << val << endl;
}



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

#define endl '\n'

bool prime(int x){
    for (int i=2; i*i<=x; i++){
        if (x % i == 0) return false;
    }
    return true;
}

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

    int x; cin >> x;
    for (int i=x; ; i++){
        if (prime(i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int sum = 0;
		StringBuilder out = new StringBuilder();
		
		// 標準入力
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String words = sc.next();
			
			if(words.equals("0"))
			break;
			
			char ch[] = words.toCharArray();

			//
			sum = 0;
			for (int i = 0; i < ch.length; i++) {
				//
				String str = String.valueOf(ch[i]);
				int num = Integer.parseInt(str);
				sum += num;
			}
			out = new StringBuilder(out+(sum+"\n"));
		}

		// 結果出力
		System.out.print(out);

	}

}

Measured memory_bytes: 18684
package main

import (
	"bufio"
	"fmt"
	"os"
)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - March
	var N int
	fmt.Scan(&N)

	sc.Split(bufio.ScanWords)
	S := make(map[int]int, N)
	var temp string
	for i := 0; i < N; i++ {
		temp = nextStr()
		if temp[0:1] == "M" {
			S[0]++
		} else if temp[0:1] == "A" {
			S[1]++
		} else if temp[0:1] == "R" {
			S[2]++
		} else if temp[0:1] == "C" {
			S[3]++
		} else if temp[0:1] == "H" {
			S[4]++
		}
	}

	var n int = 5
	var sum int
	var ans int
	var count int
	if len(S) < 3 {
		fmt.Println("0")
	} else {
		for i := 0; i < (1 << n); i++ {
			count = 1
			sum = 0
			for j := 0; j < n; j++ { // 各行の網羅
				if i>>j&1 == 1 { // 判定
					count *= S[j]
					sum++
				}
			}

			if sum == 3 {
				ans += count
			}
		}
		fmt.Println(ans)
	}

}


Measured memory_bytes: 2872
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include<tuple>

#include <set>
#include <utility>
using namespace std;

int main(){
    int n;
    cin >> n;
    // vector<int> p;
    // vector<string> s;
    set<tuple<string,int, int>> tt;
    tuple<string,int, int> t;
    for(int i = 0; i < n; i++){
        int bufp;
        string bufs; 
        cin >> bufs >> bufp;
        // s.push_back(bufs); p.push_back(bufp);
        tuple<string,int, int> buf = make_tuple(bufs, 100-bufp, i);
        tt.insert(buf);
    }
    auto itr =  tt.begin();
    for(int i = 0; i < n; i++){
        tuple<string, int, int> res = *itr;
        cout << get<2>(res)+1 << endl;
        itr++;
    }



}
    // for (int i = 0; i < ; i++){
        
        //         if(!(i+offset < n)) break;
        // int c = i + offset;
        // if(n/c == n%c){
        //     res += i;
        //     offset += 
        // }
    // }


Measured memory_bytes: 256
import java.util.*;

public class  Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int d = sc.nextInt();
	long[] x = new long[n * 2];
	for(int i = 0; i < n * 2; i++) {
		x[i] = sc.nextInt();
    }
    int count = 0;
    for(int j = 0; j < n * 2; j += 2) {
        if(d >= Math.sqrt((x[j] * x[j]) + (x[j + 1] * x[j + 1]))){
        count++;
        }
    }
    System.out.println(count);
	sc.close();
	}
}

Measured memory_bytes: 62360
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int x = inp.nextInt();
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = a - b;
        if (-a + b <= 0) System.out.println("delicious");
        else if (-a + b <= x) System.out.println("safe");
        else System.out.println("dangerous");
    }
}


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

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

void visit(const vvi &g, int v, vvi& scc,
           stack<int> &S, vector<bool> &inS,
           vector<int> &low, vector<int> &num, int& time) {
    low[v] = num[v] = ++time;
    S.push(v); inS[v] = true;
    iter(e, g[v]) {
        int w = *e;
        if (num[w] == 0) {
            visit(g, w, scc, S, inS, low, num, time);
            low[v] = min(low[v], low[w]);
        } else if (inS[w])
            low[v] = min(low[v], num[w]);
    }
    if (low[v] == num[v]){
        scc.push_back(vi());
        while (1) {
            int w = S.top(); S.pop(); inS[w] = false;
            scc.back().push_back(w);
            if (v == w) break;
        }
    }
}
 
void scc(vvi const& g, vvi& res) {
    int const n = g.size();
    vi num(n), low(n);
    stack<int> S;
    vector<bool> inS(n);
    int time = 0;
    rep(u,n)if(num[u]==0) visit(g, u, res, S, inS, low, num, time);
}
 
bool f(string const& a, string const& b){
    if(a.size()!=b.size()) return false;
    bool res=true;
    rep(i,a.size()){
        if(a[i]=='*') continue;
        if(a[i]!=b[i]){
            res=false;
            break;
        }
    }
    return res;
}

int main(){
    int b,r,g,c,s,t;
    while(cin >> b>>r>>g>>c>>s>>t && max({b,r,g,s,t})){
        int win = 100;
        win += 
            + b * (15 + 5*15 + 5)
            + r * (15 + 3*15 + 3)
            + g * 7 + c*2;

        int p=t-s;
        int lose = p*3;
        cout<<win-lose<<endl;
    }
     
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <limits.h>
 
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;


ll gcd(ll l, ll r)
{
	if (l < r) swap(l, r);
	while(true)
	{
		ll m = l % r;
		if (m == 0) return r;
		l = r;
		r = m;
	}
}

ll lcm(ll l, ll r)
{
    ll gcdlr = gcd(l, r);
    ll lf = l / gcdlr;
    ll rf = r / gcdlr;
    return gcdlr * lf * rf;
}

int main()
{
    int A, B;
    cin >> A >> B;

    ll ans = lcm(A, B);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,x;
int a[N];
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n+1&&x>=0;x-=a[i++])
		if(x<a[i]||i==n+1)
			printf("%d\n",i-1-(i==n+1&&x>0));
	return 0;
}

Measured memory_bytes: 256