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

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader in = new FastReader();
        FastWriter out = new FastWriter();
        int x = in.nextInt();
        int a = in.nextInt();
        out.pl(x<a?0:10);
        out.close();
    }
}
class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}
class FastWriter{
    PrintWriter out;
    FastWriter(){
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	out.flush();
    }
    void pl(Object o){
        out.write(o.toString());
	    out.write("\n");
        out.flush();
    }
    void pl(){
        out.write("\n");
    }
    void p(Object o){
        out.write(o.toString());
    }
    void close(){
        out.flush();
        out.close();
    }  
}


Measured memory_bytes: 32880
S = str(input())
N = len(S)
def is_palindrom(s):
  return s == s[::-1]

i = int((N - 1) / 2)
j = int((N + 3) / 2 - 1)
if is_palindrom(S) and is_palindrom(S[0:i]) and is_palindrom(S[j:N]):
  print('Yes')
else:
  print('No')

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

int main(void){
	int N,M;
	cin >> N >> M;
	set<int> st;
	st.insert(1);
	vector<int> cnt(N+1,1);

	for(int i=0;i<M;i++){
		int x,y;
		cin >> x >> y;
		cnt[x]--;
		cnt[y]++;
		if(st.find(x) != st.end()){
			st.insert(y);
		}
		if(cnt[x] == 0)st.erase(x);
	}

	int ans = 0;
	for(auto it=st.begin();it!=st.end();it++){
		if( cnt[*it] > 0 )ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include <string>
#include<vector>

using namespace std;
#define int long long
int l[20];
int r[20];
int dp[1000100];
int pr[1000100];
const int mod = 998244353;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int k;
	cin >> k;
	for (int i = 0; i < k; i++) {
		cin >> l[i] >> r[i];
	}
	dp[0] = 1;
	int d = 0;
	for (int i = 0; i < n; i++) {
		d += pr[i];
		d %= mod;
		dp[i] += d;
		dp[i] %= mod;
		for (int j = 0; j < k; j++) {
			pr[i + l[j]] += dp[i];
			pr[i + l[j]] %= mod;
			pr[i + r[j] + 1] -= dp[i];
			pr[i + r[j] + 1] = (pr[i + r[j] + 1] + mod) % mod;
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 8264
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    vector<int> s;
    double ave = 0, var = 0;
    cout << fixed << setprecision(10);
    while (1)
    {
        cin >> n;
        if (n == 0)
            break;
        s.resize(n);
        for(int i = 0; i < n; i++) {
            cin >> s[i];
            ave += s[i];
            var += s[i] * s[i];
        }
        ave /= n;
        var = var / n - ave * ave;
        cout << sqrt(var) << '\n';
        ave = 0;    var = 0;
    }
    
  
    return 0;
}


Measured memory_bytes: 3288
#include<stdio.h>
#include<math.h>
int main()
{
  int a,b,c,d,x,y,z,s=0;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  for(x=0;x<=a;x++)
	  for(y=0;y<=b;y++)
		  for(z=0;z<=c;z++)
		  {
            if(500*x+100*y+50*z==d)
				s++;
		  }
		  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int N = 2e4+100;
const int M =1e9+7;
#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>  
const int mod = 1e9 + 7;

int a[200];
int vist[N];
signed main() { 
    fast;
    int n,m;
    cin>>m>>n;
   if(n==m){
    cout<<"Yes";
}
    else cout<<"No";
   
   
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

//typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}


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

    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    
    // 短い方二つを決めて二分探索
    int ans = 0;
    rep(i, n) repr(j, i+1, n){
        int k = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
        ans += k - j - 1;
    }
    cout << ans << endl;

    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAX 100000000000000000
int main()
{

    //freopen("inputfile.txt","r",stdin);
    IOS;
    ll x,d,k;cin>>x>>k>>d;
    x = abs(x);
    if(x>0 && (x/d)>=k)
    {
        cout << x-(d*k)<<endl;
        return 0;
    }
    ll y = (x/d);
    x -= (d*y);
    k -= y;
    if(k%2==0)cout<<abs(x)<<endl;
    else cout<<min(abs(x-d),abs(x+d))<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(e) (e).begin(), (e).end()
typedef long long ll;
ll n;
vector<ll> tubo28;

map<ll,ll> dp;

void make(ll m,int digit) {
    if(m) tubo28.push_back(m);
    if(digit==18) {
        return;
    }
    make(m*10+2,digit+1);
    make(m*10+8,digit+1);
}

ll dfs(ll n) {
    if(n==1) {
        return 0;
    }
    if(dp.count(n)) return dp[n];
    ll ret=-1;

    rep(i,tubo28.size()) {
        if(tubo28[i]>n) break;
        if(n%tubo28[i]==0) {
            ll t=dfs(n/tubo28[i]);
            if(t>=0) ret=max(ret,t+1);
        }
    }
    
    return dp[n]=ret;
}

int main() {
    make(0,0);
    sort(all(tubo28));
    //reverse(all(tubo28));
    //comp();
    cin>>n;
    ll ans=dfs(n);
    if(ans<=0) ans=-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000001ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll ans=1;
    for(int i=0;i<n-1;i++)
    	if(s[i]!=s[i+1])
    		ans++;
    while(ans>1 && k>0)
    {
    	if(ans>2)
    		ans-=2;
    	else
    		ans--;
    	k--;
    }
    cout<<n-ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

#define LL long long

LL sum(LL x){
	LL res=0;
	while(x>0){
		res += (x%10);
		x/=10;
	}
	return res;
}

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	LL k;
	cin>>k;

	LL x=1;
	while(k--){
		cout<<x<<endl;

		LL y=0;
		for(LL i=1;i<=1000000000000000;i*=10){
			if(y==0 || (y*sum(x+i) > (x+i)*sum(y))){
				y = x+i;
			}
		}
		x=y;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, C;
long long D[31][31];
long long c[510][510];
long long cost[31][3] = {};

int main() {
    cin >> N >> C;
    for(int i=0; i<C; ++i) {
        for(int j=0; j<C; ++j) cin >> D[i][j];
    }
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            cin >> c[i][j];
            --c[i][j];
        }
    }

    for(int k=0; k<C; ++k) {
        for(int i=0; i<N; ++i) {
            for(int j=0; j<N; ++j) {
                cost[k][(i + j) % 3] += D[c[i][j]][k];
            }
        }
    }

    long long res = 1001001001001001001;
    for(int i=0; i<C; ++i) {
        for(int j=0; j<C; ++j) {
            for(int k=0; k<C; ++k) {
                if(i == j || j == k || k == i) continue;
                res = min(res, cost[i][0] + cost[j][1] + cost[k][2]);
            }
        }
    }
    
    cout << res << '\n';
}

Measured memory_bytes: 2304
import java.util.Scanner;
import java.util.Stack;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<Integer> stack = new Stack<>();
		int n;
		while(in.hasNext()) {
			n = in.nextInt();
			if(n!=0)
				stack.push(n);
			else
				System.out.println(stack.pop());
		}
		in.close();
	}
}


Measured memory_bytes: 26160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[100001][3];
int dp[100002][3];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
    rep(i,n)rep(j,3)rep(k,3)if(j!=k){
        dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i][k]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	HashSet<Long> set = new HashSet<Long>();
	int N = Integer.parseInt(sc.next());
	for(int i = 0; i<N; i++) {
	    long num = Long.parseLong(sc.next());
	    if(set.contains(num)) {
		set.remove(num);
	    }else{
		set.add(num);
	    }
	}
	System.out.println(set.size());

    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);

    for(int i = 0; i < n; ++i) {
        a[i] = b[n - 1 - i] = (i+1) * 20000;
    }

    int p;
    for(int i = 0; i < n; ++i) {
        cin >> p;
        b[p - 1] += i;
    }

    for(int i = 0; i < n; ++i) {
        cout << a[i];
        if (i == n - 1) cout << endl;
        else cout << " ";
    }

    for(int i = 0; i < n; ++i) {
        cout << b[i];
        if (i == n - 1) cout << endl;
        else cout << " ";
    }
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		char[] S = sc.next().toCharArray();

		sc.close();

		int min = 0;
		for(int i = 1; i < N; i++) {
			if(S[i] == 'E') min++;
		}

		int karimin = min;
		for(int i = 1; i < N; i++) {
			if(S[i-1] == 'W' && S[i] == 'W') karimin +=1;
			if(S[i-1] == 'E' && S[i] == 'E') karimin -=1;
			
			if(karimin < min) min = karimin;
		}

		System.out.println(min);
	}

}


Measured memory_bytes: 31004
N, M = map(int, input().split())

H = list(map(int, input().split()))

active = [True] * N

for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        active[a-1] = False
    elif H[a-1] > H[b-1]:
        active[b-1] = False
    else:
        active[a-1] = False
        active[b-1] = False

print(len(list(filter(lambda x:x, active))))

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

int main() {
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  double a = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);

  cout << setprecision(15) << sqrt(a) << endl;
}



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

class Edge{
public:
	int from,to,cost;
	bool operator <(const Edge& r)const{
		return cost < r.cost;
	}
};

class UnionFind{
private:
	vector<int> par,rank;
public:
	UnionFind(int N){
		par.reserve(N);
		rank.reserve(N);
		for(int i=0; i<N; ++i){
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x){
		if(par[x]==x)	return x;
		else			return par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y)	return;
		if(rank[x]<rank[y]){
			par[x]=y;
		}else{
			par[y]=x;
			if(rank[x]==rank[y])	++rank[x];
		}
	}
	bool isSame(int x,int y){
		return find(x)==find(y);
	}
};

int N,M;
const int INF=1<<28;

int kruskal(Edge edges[], int a){
	UnionFind uf(N);
	int cnt=0,max=0,min=INF;
	for(int i=a; i>=0; --i){
		Edge e = edges[i];
		if(!uf.isSame(e.from, e.to)){
			uf.unite(e.from, e.to);
			max=std::max(max, e.cost);
			min=std::min(min, e.cost);
			++cnt;
		}
	}
	return cnt==N-1? (max-min): INF;
}
void solve(){
	Edge edges[M];
	for(int i=0; i<M; ++i){
		cin>>edges[i].from>>edges[i].to>>edges[i].cost;
		--edges[i].from;	--edges[i].to;
	}
	sort(edges, edges+M);

	int ans=INF;
	for(int i=0; i<M; ++i)	ans=min(ans, kruskal(edges, i));
	cout << (ans>=INF? -1: ans) << endl;
}
int main(){
	while(true){
		cin>>N>>M;
		if((N|M)==0)	break;
		solve();
	}
}

Measured memory_bytes: 1268
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a, b, c;
int main() {
	scanf("%d%d%d", &a, &b, &c);
	if(a + b >= c && c >= a)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100005
#define MOD 1000000007

typedef long long int lli;

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

  int l[MAX], r[MAX];
  rep(i, 0, Q) scanf("%d %d", &l[i], &r[i]);

  int p[MAX] = {0};
  int n[MAX] = {0};
  for ( int i = 2; i <= 100000; i++ ) {
    int ok = 1;
    for ( int j = 2; j < i; j++ ) {
      if ( i % j != 0 ) continue;
      ok = 0; break;
    }
    if ( ok ) p[i] = 1;
    if ( ok && p[(i+1)/2] ) n[i] = 1; 
  }

  
  int sum[MAX];
  sum[1] = 0;
  for ( int i = 1; i <= 100000; i++ ) {
    sum[i + 1] = sum[i] + n[i];
  }

  rep(i, 0, Q) {
    printf("%d\n", sum[r[i]+1] - sum[l[i]]);
  }
  return 0;
}


Measured memory_bytes: 2560
N = int(input())
A = [int(i)for i in input().split()]
p = 0
min = 10**9 + 1
ans = 0
for i in A:
    if i < 0:
        p += 1
    i = abs(i)
    ans += i
    if min > i:
        min = i
if p%2 ==1:
    ans -= min*2
print(ans)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long int lint;
typedef unsigned long long int ulint;

lint dp[3020][3020]={0},siz1,siz2,cevs;
string s1,s2,cev;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lint i,j,k,l;
	cin>>s1>>s2;
	siz1=s1.size();
	siz2=s2.size();
	for(j=1;j<=siz1;j++){
		for(i=1;i<=siz2;i++){
			char a=s1[j-1],b=s2[i-1];
			if(a==b) dp[j][i]=dp[j-1][i-1]+1;
			else dp[j][i]=fmax(dp[j][i-1],dp[j-1][i]);
		}
	}
	cevs=dp[siz1][siz2];
	cev.resize(cevs);
	lint temp=cevs;
	for(j=siz1,i=siz2;dp[j][i]>0;){
		if(s1[j-1]==s2[i-1]){
			cev[--cevs]=s1[j-1];
			j--;
			i--;
		}else{
			if(dp[j][i]==dp[j-1][i]) j--;
			else i--;
		}
	}
	for(i=0;i<temp;i++) cout<<cev[i];
	return 0;
}

Measured memory_bytes: 71040
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// ここまで

fn run() {
    input! {
        n: usize,
        d: usize,
        x: [[i32; d]; n],
    }
    let mut ans = 0;
    for i in 0 .. n {
        for j in i + 1 .. n {
            let mut s = 0;
            for k in 0..d {
                let d = x[i][k] - x[j][k];
                s += d * d;
            }
            let mut k = 1;
            while k * k < s {
                k += 1;
            }
            if k * k == s {
                ans += 1;
            }
        }
    }
    println! ("{}", ans);
}

fn main() {
    run();
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 l,r;
    cin >> l >> r;
    int32 ans = 2018;
    FOR(i,l,min(l+2019,r))FOR(j,i+1,min(i+1+2019,r+1)){
        ans = min(ans, i * j % 2019);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

const mod = 1000000007

var fac, finv, inv []int

func initCmb(x int) {
	fac, finv, inv = make([]int, x+1), make([]int, x+1), make([]int, x+1)
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i <= x; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func cmb(x, y int) int {
	if y > x {
		return 0
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	if (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	a := (2*y - x) / 3
	b := (2*x - y) / 3
	if a < 0 || b < 0 {
		fmt.Println(0)
		return
	}

	initCmb(a + b)
	fmt.Println(cmb(a+b, a))
}


Measured memory_bytes: 17024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> left(n + 2), right(n + 2);
  for(int i = 1; i <= n; ++i){
    left[i] = left[i - 1] + a[i - 1];
  }
  reverse(a.begin(), a.end());
  for(int i = 1; i <= n; ++i){
    right[i] = right[i - 1] + a[i - 1];
  }
  ll ans = LLONG_MAX;
  for(int i = 1; i < n; ++i){
    ll x = left[i], y = right[n - i];
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
require "complex"

n, d = gets.chomp.split(" ").map(&:to_i)
x = []
n.times do |n|
  array = gets.split(" ").map(&:to_i).to_a
  x.push(array)
end

count = 0

x.combination(2) do |a, b|
  sum = 0
  d.times do |i|
    sum += (a[i - 1] - b[i - 1]) ** 2
  end
  distance = Math.sqrt(sum)
  count += 1 if distance % 1 == 0
end

puts count


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
using namespace std;
int main(){
    vector<long> so;
    long x,z=0;
    cin>>x;
    for(int i=0;i<x;i++){
        long y;
        cin>>y;
        z^=y;
        so.push_back(y);
    }
    for(int i=0;i<x;i++){
        int a=z^so[i];
        cout<<a<<" ";
    }
}


Measured memory_bytes: 5320
#include<stdio.h>
#define INFTY 1000000000
int n,S[500000],count=0;
void merge(int S[], int left, int mid, int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1], R[n2];
    for(i = 0;i<n1;i++){
      L[i] = S[left + i];
    }
  for(i = 0; i<n2;i++){
    R[i] = S[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left;k<right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i + 1;
      count++;
    }
    else{ 
      S[k] = R[j];
      j = j + 1;
      count++;
    }
  }
}
int mergeSort(int S[], int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
}
int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int B[n];
  for (int i = 0; i < n - 1;i++)
    cin >> B[i];
  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    if(i==0)
      ans += B[i];
    else if(i==n-1)
      ans += B[i - 1];
    else
      ans += min(B[i], B[i - 1]);

  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int c[100];

int greedy(int x){
  int res=0;
  for(int i=n-1;i>=0;i--){
    res+=x/c[i];
    x%=c[i];
  }
  return res;
}

int dp[5000];

void solve(){
  if(c[0]!=1){
    printf("Cannot pay some amount");
    return;
  }

  fill( dp, dp+5000, 1e9);
  dp[0]=0;
  
  for(int i=0;i<n;i++){
    int val=c[i];
    for(int j=0;j<2000;j++){
      if(j-val>=0)dp[j]=min(dp[j],dp[j-val]+1);
    }
  }
  
  for(int num=0;num<2000;num++){
    int cost=greedy(num);
    if(cost!=dp[num]){
      //      cout<<num<<' '<<cost<<' '<<dp[num]<<endl;
      printf("Cannot use greedy algorithm");
      return;
    }
  }

  for(int j=2000;j<5000;j++){

    for(int i=0;i<n;i++){
      int val=c[i];      
      dp[j]=min(dp[j],dp[j-val]+1);
    }
    
    if( dp[j]!=dp[j- c[n-1] ]+1 ){
      printf("Cannot use greedy algorithm");
      return;
    }
  }
  printf("OK");
}

int main(){
  for(int tc=1;;tc++){
    scanf("%d",&n);
    if(n==0)break;
    for(int i=0;i<n;i++)scanf("%d",&c[i]);
    printf("Case #%d: ",tc);
    solve();
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3180
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	ans := b - a
	if b%a == 0 {
		ans = a + b
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        p: i64,
        q: i64,
        r: i64,
    }

    let mut vec = vec![p, q, r];
    vec.sort();
    println!("{}", vec[0] + vec[1]);
}


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

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const ll inf = 1e12;
const ll mod = 1e9 + 7;


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

  ll n; cin >> n;

  string s, t; cin >> s >> t;

  string ret = "";

  f0r(i, n) {
    ret += s[i];
    ret += t[i];
  }

  cout << ret << endl;

}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

char g[53][53];

int main() {
    int H, W;
    scanf("%d %d ", &H, &W);
    forn(i, 0, H) {
        string line;
        getline(cin, line);
        forn(j, 0, W) {
            g[i][j] = line[j];
        }
    }
    
    bool good = true;
    forn(i, 0, H) {
        forn(j, 0, W) {
            if (g[i][j] == '#' &&
                g[i - 1][j] != '#' &&
                g[i + 1][j] != '#' &&
                g[i][j - 1] != '#' &&
                g[i][j + 1] != '#') {
                good = false;
            }
        }
    }
    printf(good ? "Yes\n" : "No\n");
    return 0;
}


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

const int N=305;
int n,cnt[4];
double f[N][N][N];

//cnt1 cnt2 cnt3
double dp(int x,int y,int z) {
	if(x+y+z==0) return 0;
	if(f[x][y][z]>0) return f[x][y][z];
	int s=x+y+z; double ret=1.0*n/s;
	if(x>0) ret+=dp(x-1,y,z)*1.0*x/s;
	if(y>0) ret+=dp(x+1,y-1,z)*1.0*y/s;
	if(z>0) ret+=dp(x,y+1,z-1)*1.0*z/s;
	return f[x][y][z]=ret;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	scanf("%d",&n);
	for(int i=1,a;i<=n;++i) scanf("%d",&a),++cnt[a];
	printf("%.10lf\n",dp(cnt[1],cnt[2],cnt[3]));
	
	return 0;
}


Measured memory_bytes: 219392
s = input()

odd = ["R", "U", "D"]
even = ["L", "U", "D"]

flag = True

for i in range(len(s)):
    if i % 2 == 0:
        if not s[i] in odd:
            flag = False
    else:
        if not s[i] in even:
            flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int N, M, A[100], i, k, tmp;

  scanf("%d %d", &N, &M);

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

  for(k = 1; k <= M; k++){
    for(i = 0; i < N-1; i++){
      if(A[i]%k > A[i+1]%k){
	tmp = A[i];
	A[i] = A[i+1];
	A[i+1] = tmp;
      }
    }
  }
  for(i = 0; i < N; i++)
    printf("%d\n", A[i]);

  return 0;
}

Measured memory_bytes: 596
amt = int(input())
same = 0

while amt > 0:
    item = list(map(int, input().split()))
    if item[0] == item[1]:
        same += 1
        if same == 3:
            print("Yes")
            amt = 0
    else:
        same = 0
    amt -= 1

if amt == 0:
    print("No")

Measured memory_bytes: 9092
#include<cstdio>
#include<functional>
#include<algorithm>
#define M 2000000000
using namespace std;
int main(void)
{
	int n,i,j,sum,p[5000],a[5000],mn;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&p[i]);
	mn=M;
	for(i=0;i<=p[0];i++)	{
		for(j=0;j<n;j++)	a[j]=p[j];
		a[0]=a[0]-i;
		sum=i;
		for(j=0;j<n-1;j++)	{
			if(a[j]>0)	{
				a[j+1]-=a[j];
				sum+=a[j]*2;
				a[j]=0;
			}
		}
		if(a[n-1]>0)	sum+=a[n-1];
		mn=min(mn,sum);
	}
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 2704
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }  // O( log(a) )
bool isPrime(ll n) {                                  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) flag = false;
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll tmp = c - (a + b);
  if (4 * a * b < tmp * tmp && tmp > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
int main(void){
	
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int i,z;
	for(i=0;i<3;i++){
		if(a>b){
			z=a; a=b; b=z;
		}else if(b>c){
			z=b; b=c; c=z;
		}
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif   
    int a,b,c;
    cin>>a>>b>>c;
    // cout<<1<<endl;
    for(int i=0;i<=64;i++)
    {
        if(a%2 || b%2 || c%2)
        {
            cout<<i<<endl;
            return 0;
        }
        int d,e,f;
        d = a+b;
        d/=2;
        e = b+c;
        e/=2;
        f = a+c;
        f/=2;
        a=e;
        b=f;
        c=d;
    }
    cout<<-1<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

struct edge {
  int to; ll cost;
  edge(int t, ll c): to(t), cost(c) {}
};

vector<edge> G[100001];
ll d[100001];

void dijkstra(int s) {
  priority_queue<P> que;
  fill(d, d + 100001, 1e18);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(void) {
  int n;
  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a - 1].push_back(edge(b - 1, c));
    G[b - 1].push_back(edge(a - 1, c));
  }

  int Q, K;
  cin >> Q >> K;

  dijkstra(K - 1);

  vector<int> x(Q), y(Q);
  for (int i = 0; i < Q; i++) {
    cin >> x[i] >> y[i];
  }

  for (int i = 0; i < Q; i++) {
    cout << d[x[i] - 1] + d[y[i] - 1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 11120
from itertools import product
N = input()
length = len(N)
T = [''.join(t) for t in product(('3','5','7'),repeat = 3)]

def f(N,s):
    if len(s) == length:
        if int(s) <= int(N) and '3' in s and '5' in s and '7' in s:
            return 1
        else:
            return 0
    else:
        if '3' in s and '5' in s and '7' in s:
            a = 1
        else:
            a = 0
        a += sum(f(N,s+c) for c in('3','5','7'))
        return a
if int(N)<357:
    print(0)
else:
    print(sum(f(N, t) for t in T))

Measured memory_bytes: 3064
#include <cassert>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;

int main() {
    int n, k; cin >> n >> k;
    vector<pair<int, int> > ans;
    for (int i = 2; i <= n; i++) ans.push_back({1, i});
    int cnt = (n-2) * (n-1) / 2;
    if (cnt < k) { cout << "-1\n"; return 0; }
    if (cnt == k) goto done;
    for (int i = 2; i < n; i++)
        for (int j = i+1; j <= n; j++) {
            ans.push_back({i, j});
            cnt--;
            if (cnt == k) goto done;
        }
done:
    cout << ans.size() << endl;
    for (auto x : ans) cout << x.first << ' ' << x.second << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        String line=sc.nextLine();
        String ans="";
        int length=line.length();
        for(int i=0;i<length;i++){
            char ch=line.charAt(i);
            if(Character.isLowerCase(ch)){
                ans+=Character.toUpperCase(ch);

            }
            else ans+=Character.toLowerCase(ch);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 31324
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
bool isp(int a) {
	for (int i = 2; i < a; i++) {
		if (a % i == 0) {
			return false;
		}
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int a = 3;
	vector<int> res;
	while((int)res.size()<N){
		if (isp(a)) {
			res.push_back(a);
		}
		a += 10;
	}
	for (int i = 0; i < res.size(); i++) {
		if (i > 0)cout << " ";
		cout << res[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 10000000

using namespace std;

int n;
bool viz[maxn+5];
vi prime;

void ciur () {
  int i, j; viz[0] = viz[1] = 1;
  for (i = 2; i*i <= n; i++)
    if (!viz[i])
      for (j = i*i; j <= n; j += i) viz[j] = 1;
  for (i = 0; i <= n; i++) {
    if (!viz[i]) prime.pb(i);
    viz[i] = 0;
  }
}

int put[664579+5];
ll ans;

void df (int x, ll now) {
  ans += 1LL*x*now;
  viz[x] = 1;
  for (int i = 0; i < sz(prime); i++) {
    if (1LL*x*prime[i] > n) break;
    if (!viz[x*prime[i]]) {
      ll nn = now / (put[i]+1) * (put[i]+2);
      put[i]++;
      df(x*prime[i], nn);
      put[i]--;
    }
  }
}

int main () {
  cin >> n;
  ciur();
  df(1, 1);
  cout << ans;
  return 0;
}

Measured memory_bytes: 18380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 998244353;

void solve() {
    ll x, n;
    cin >> x >> n;
    unordered_set<ll> s;
    for(ll i = 0; i < n; i++) {ll temp; cin >> temp; s.emplace(temp);}
    if(!n) {cout << x; return;}
    ll l = x, r = x;
    while(s.find(l) != s.end()) l--;
    while(s.find(r) != s.end()) r++;
    if(abs(x - l) <= abs(x - r)) cout << l;
    else cout << r;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;   
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
N, x = map(int, input().split())
A = list(map(int, input().split()))
A = [0] + A
t = 0
ans = 0
for i in range(N+1):
    if t + A[i] > x:
        ans += (t+A[i]) - x
        A[i] -= (t+A[i]) - x
    t = A[i]

print(ans)


Measured memory_bytes: 63856
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, K, ans = 0, maxi = 0, count ;
  cin >> N ;
  int L[N] ;
  for(int i=0;i<N;i++){
    cin >> L[i] ;
  }
  if(N < 3){
    cout << 0 << endl ;
    return 0 ;
  }
  sort(L,L+N) ;
  for(int i=2;i<N;i++){
    for(int j=1;j<i;j++){
      for(int k=0;k<j;k++){
        if((L[i] == L[j]) || (L[j] == L[k]) || (L[i] == L[k]) ){
          continue ;
        }
        if(L[i] < (L[k] + L[j]) ){
          ans++ ;
        }
      }
    }
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int N;

int main(){
  int N;
  cin >> N;
  map<string,ll> m;
  for(ll i = 0; i < N; i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }
  ll ans = 0;
  for(auto p:m){
    ll x = p.second;
    ans += x*(x-1)/2;
  }
  cout << ans << endl; 
  return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, q;
	cin >> n >> q;
	string st;
	cin >> st;
	ll pref[n];
	string cur = "";
	for(ll i=0; st[i]; i++){
		pref[i] = 0;
		if(st[i-1] == 'A' and st[i] == 'C')
			pref[i] = (i > 0 ? pref[i-1] : 0) + 1;
		else
			pref[i] = (i > 0 ? pref[i-1] : 0);
	}
	ll l, r;
	while(q--){
		cin >> l >> r;
		--r, --l;
		cout << pref[r] - pref[l] << "\n";
	}
	return 0;
}

Measured memory_bytes: 4560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	int h,w;
	cin>>h>>w;
	int ans[h+1][w+1];
	string str[h];
	
	for(int i = 0;i<h;i++)
		cin>>str[i];
		
	for(int i = h;i>=0;i--){
		for(int j = w;j>=0;j--){
			if(i==h||j==w){
				ans[i][j] = 0;
			}else if(i==h-1&&j==w-1){
				ans[i][j] = 1;
			}else{
				if(str[i][j]=='.')
					ans[i][j] = (ans[i+1][j]+ans[i][j+1])%mod;
				else
					ans[i][j] = 0;
			}
		}
	}
	
	cout<<ans[0][0];
	return 0;
}

//Total solved problems:- 13



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

int sum(int n) {
  int sum=0;
  while (n>0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, min=1000000; cin >> N;
  for (int i=1; i<N; i++) {
    if (min > sum(i)+sum(N-i)) min = sum(i)+sum(N-i);
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

int main()
{
    std::string hoge;
    std::cin >> hoge;
    for (int i = 0; i < 3; i++) {
        if (hoge[i] == hoge[i + 1]) {
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i]-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long x,a,b;

	while(scanf("%lld%lld%lld",&x,&a,&b)!=EOF)
	{
		if(b-a<=0)
		printf("delicious\n");
		
		else if(b-a<=x)
		printf("safe\n");
		else 
		printf("dangerous\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::vector<int> L(N);
  for(int i=0; i<N; i++) std::cin >> L[i];

  int sum = std::accumulate(L.begin(), L.end(), 0);
  int Lmax = *std::max_element(L.begin(), L.end());

  if ( Lmax < (sum-Lmax) ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppll pair <pll, pll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll binpow(ll a, ll b){
	if (b == 0) return 1;
	ll x = binpow(a, b/2); x *= x;
	if (b % 2) return x * a; else return x;
}
int main(){
	ll m, k; cin >> m >> k;
	if (k >= binpow(2, m)){
		cout << -1 << endl; return 0;
	}
	else if (m == 0){
		if (k == 0) cout << "0 0" << endl;
		else cout << -1 << endl;
	}
	else if (m == 1){
		if (k == 0) cout << "0 0 1 1" << endl;
		else cout << -1 << endl;
	}
	else{
		for (ll i = 0; i<binpow(2, m); i++){
			if (i != k) cout << i << " ";
		}
		cout << k << " ";
		for (ll i = binpow(2, m) - 1; i>=0; i--){
			if (i != k) cout << i << " ";
		}
		cout << k << endl;
	}
}

Measured memory_bytes: 1792