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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int a,b; scanf("%d%d",&a,&b);
    bool f=1;
    if(a>9||b>9)f=0;
    if(f)printf("%d\n",a*b);
    else printf("-1\n");
    return 0;
}


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

int main() {
  string N;
  int count;
  cin >> N;
  count = 0;
  
  for (int i = 0; i < N.size(); i++){
    if (N.at(i) == '9') {
      cout << "Yes" << endl;
      count++;
      break;
    }
  }
  if (count == 0)
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int main(){
	char in[10],ans=0;
	scanf("%s",in);
	F(i,0,3) if(in[i]=='1') ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;

class Monoid<T,R> implements BiFunction<T,T,R>{
	T					identity;
	BiFunction<T,T,R>	f;
	public Monoid(T identity,BiFunction<T,T,R> f){
		this.identity=identity;
		this.f=f;
	}
	@Override
	public R apply(T t,T u){
		return f.apply(t,u);
	}
}

class LazySegmentTree<T,A>{

	private T[]	array;
	private A[]	lazy;
	int			size;
	private int	highestbit,len[];

	/**
	 * a+0=a
	 * a+(b+c)=(a+b)+c
	 */
	private Monoid<T,T>				merger;
	/**
	 * (v,lazy)->v
	 */
	private BiFunction<T,A,T>		applyer;
	/**
	 * (apply,apply)->apply
	 */
	private Monoid<A,A>				unifyer;
	/**
	 * (v,lazy)->v
	 */
	private BiFunction<A,Integer,A>	multiplier;

	LazySegmentTree(int size,
			Monoid<T,T> merger,
			BiFunction<T,A,T> applyer,
			Monoid<A,A> unifyer,
			BiFunction<A,Integer,A> multiplier){
		this.size=size;
		this.highestbit=Integer.highestOneBit(size);
		this.merger=merger;
		this.applyer=applyer;
		this.unifyer=unifyer;
		this.multiplier=multiplier;
		initArray();
		Arrays.fill(array,merger.identity);
		Arrays.fill(lazy,unifyer.identity);
		for(int i=len.length-1;i>=0;--i)
			len[i]=i>=size?1:len[i<<1]+len[i<<1|1];
	}
	@SuppressWarnings("unchecked")
	private void initArray(){
		array=(T[])new Object[size*2];
		lazy=(A[])new Object[size*2];
		len=new int[size*2];
	}

	private void set(int i,A laz){
		array[i]=applyer.apply(array[i],
				multiplier.apply(laz,len[i]));
		if(i<size)
			lazy[i]=unifyer.apply(lazy[i],laz);
	}

	/**
	 * [l, r)
	 */
	void apply(int l,int r,A value){
		int l0=l+=size,r0=r+=size;
		for(;l<r;l>>=1,r>>=1){
			if((l&1)>0) set(l++,value);
			if((r&1)>0) set(--r,value);
		}
		updateParents(l0);
		updateParents(r0-1);
	}
	private void updateParents(int p){
		while(p>1){
			p>>=1;
			array[p]=applyer.apply(
					merger.apply(array[p<<1],array[p<<1|1]),
					multiplier.apply(lazy[p],len[p]));
		}
	}

	/**
	 * [l, r)
	 */
	T query(int l,int r){
		T res=merger.identity;
		spreadLazy(l+=size);
		spreadLazy((r+=size)-1);
		for(;l<r;l>>=1,r>>=1){
			if((l&1)>0) res=merger.apply(res,array[l++]);
			if((r&1)>0) res=merger.apply(res,array[--r]);
		}
		return res;
	}
	private void spreadLazy(int p){
		for(int s=highestbit;s>0;s>>=1){
			int i=p/s;
			if(!unifyer.identity.equals(lazy[i])){
				set(i<<1,lazy[i]);
				set(i<<1|1,lazy[i]);
				lazy[i]=unifyer.identity;
			}
		}
	}
}

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),q=s.nextInt();
		Monoid<Long,Long> m=new Monoid<>(0L,Long::sum);
		LazySegmentTree<Long,Long>seg=new LazySegmentTree<>(n,m,m,m,(l,i)->l*i);
		for(int i=0;i<q;++i) {
			if(s.nextInt()==0)
				seg.apply(s.nextInt()-1,s.nextInt(),s.nextLong());
			else
				System.out.println(seg.query(s.nextInt()-1,s.nextInt()));
		}
	}
}


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

int main(){
  int a,b,c,d;
  int sum=0;

  cin >> a >> b >> c >> d;

  if(a > b)
    {
      sum += b;
    }
  else
    {
      sum += a;
    }
  if(c > d)
    {
      sum += d;
    }
  else
    {
      sum += c;
    }
  cout << sum << endl;
  return 0;
}
  

Measured memory_bytes: 256
from collections import*
n,*v=map(int,open(0).read().split())
a=Counter(v[::2]).most_common()+[(0,0)]
b=Counter(v[1::2]).most_common()+[(0,0)]
if a[0][0]==b[0][0]:
    print(min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1]))
else:
    print(n-a[0][1]-b[0][1])

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

using namespace std;

int main(void) {
  int H, N;
  cin >> H >> N;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    H -= a;
  }
  cout << (H > 0 ? "No" : "Yes") << endl;

  return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

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

n,m = na()
mp = []
for i in range(n):
    mp.append([_ for _ in ns().strip()])

for i in range(n):
    for j in range(m):
        if  mp[i][j] != '#':
            bo = 0
            for k in range(-1,2):
                for l in range(-1,2):
                    ni = i + k
                    nj = j + l
                    if 0 <= ni < n and 0 <= nj < m and mp[ni][nj] == '#':
                        bo += 1
            mp[i][j] = chr(bo + 48)

for i in mp:
    print("".join(i))


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigDecimal;
import java.util.Arrays;

public class Main{
        
    public static void main(String[] args)throws IOException{
	br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
	int n = nextInt();
	int v[] = new int[n];
        for(int i = 0; i<n;i++){
	    v[i] = nextInt();
	}
	if(n==1){
	    out.println(v[0]);
	}else if(n==2){
	    out.println((double)(v[0]*v[1])/(double)(v[0]+v[1]));
	}else{
	    long x = v[0]*v[1];
	    long y = v[0]+v[1];
	    BigDecimal a = new BigDecimal(""+x);
	    BigDecimal b = new BigDecimal(""+y);
	    BigDecimal xt;
	    for(int i = 2;i<n;i++){
		xt = new BigDecimal(""+v[i]);
	        b = b.multiply(xt).add(a);
		a = a.multiply(xt); 
	    }
	    double t1 = a.doubleValue();
	    double t2 = b.doubleValue();
	    out.println(t1/t2);
	}
	out.close();
    }
    
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");
    static String next()throws IOException{
	while(!st.hasMoreTokens()){
	    st = new StringTokenizer(br.readLine());
	}
	return st.nextToken();
    }
    static int nextInt()throws IOException{
	return Integer.parseInt(next());
    }
    static long nextLong()throws IOException{
	return Long.parseLong(next());
    }
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s, t;
  cin >> s >> t;
  cout << (t.substr(0, s.size()) == s ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3584
h, w = map(int, input().split( ))
a = []
m = 10**9+7
for i in range(h):
    inpt = input()
    a.append(inpt)

DP = [[0 for j in range(w)] for i in range(h)]

DP[0][0] = 1###

for i in range(h):
    for j in range(w):
        if i!=0 or j !=0:###
            if a[i][j] == "#":
                pass
            else:
                DP[i][j] = DP[i-1][j]+DP[i][j-1]
        DP[i][j] %=m
print(DP[h-1][w-1])


Measured memory_bytes: 54236
a,b,c,x,y = map(int,input().split())
fx = x
fy = y
fl = 0
val = int(0)
fmin = min(x,y)
if a>2*c:
  x = 0
  y = y - fx
  val += 2*c*fx
  fl += 1
if y < 0:
  y = 0
if b>2*c:
  if fl == 1:
    val += 2*c*y
    y = 0
  else:
    val += 2*c*y
    x = x -y
    y = 0 
if x < 0:
  x = 0
nx = x
ny = y
if a+b>2*c:
  x = x - min(nx,ny)
  y = y - min(nx,ny)
  val += 2*c*min(nx,ny)
print(val+a*x+b*y)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main() {
  int k,x;cin>>k>>x;
  for(int i=x-k+1;i<x+k;i++)
  {
    cout<<i;
  cout<<' ';
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long LL;
const int N=200005;
int n,m1[N],m2[N],sz[N],low[N];char s[N];LL ans;
int pp,lnk[N],nxt[N*2],to[N*2];
void ae(int k1,int k2){to[++pp]=k2,nxt[pp]=lnk[k1],lnk[k1]=pp;}
void dfs(int k1,int k2){
	sz[k1]=s[k1]&15;
	if(s[k1]=='0')low[k1]=0X3F3F3F3F;
	for(int i=lnk[k1];i;i=nxt[i])if(to[i]!=k2){
		dfs(to[i],k1);
		int len=m1[to[i]]+1; 
		if(len>m1[k1])m2[k1]=m1[k1],m1[k1]=len;
		else m2[k1]=max(m2[k1],len);
		sz[k1]+=sz[to[i]];
		if(sz[to[i]])low[k1]=min(low[k1],m1[to[i]]+1);
	}
}
void dfs2(int k1,int k2){
	ans+=max(0,min(m1[k1]-1,m2[k1]+1)-low[k1]+1);
//	fprintf(stderr,"%d %d %d %d %lld\n",k1,m1[k1],m2[k1],low[k1],ans);
	for(int i=lnk[k1];i;i=nxt[i])if(to[i]!=k2){
		int len=m1[k1]==m1[to[i]]+1?m2[k1]+1:m1[k1]+1;
		if(len>m1[to[i]])m2[to[i]]=m1[to[i]],m1[to[i]]=len;
		else m2[to[i]]=max(m2[to[i]],len);
		if(sz[to[i]]<sz[1])low[to[i]]=min(low[to[i]],len);
		dfs2(to[i],k1);
	}
}
int main(){
	scanf("%d",&n);
	rep(i,2,n){
		int k1,k2;scanf("%d%d",&k1,&k2);
		ae(k1,k2),ae(k2,k1);
	}
	scanf("%s",s+1);
	dfs(1,0),dfs2(1,0);
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 14592
d = input()
for a in '+-':
    for b in '+-':
        for c in '+-':
            s = d[0] + a + d[1] + b + d[2] + c + d[3]
            if eval(s)==7:
                print(s+'=7')
                break
        else:
            continue
        break
    else:
        continue
    break


Measured memory_bytes: 2940
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=1e6+5;
int n,h;
int in[maxn],out[maxn];
int fa[maxn],occ[maxn],ok[maxn];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	read(n);read(h);
	rep(i,0,h+h)fa[i]=i;
	rep(i,1,n){
		int a,b,c,d;read(a);read(b);read(c);read(d);
		int l=!c?a+h:c,r=!d?b:d+h;
		out[l]++;
		in[r]++;
		l=find(l);r=find(r);
		occ[l]=occ[r]=1;
		if(l!=r)fa[l]=r;
	}
	int flag=1;
	rep(i,h+1,h+h)if(occ[i]&&out[i]<in[i])flag=0;
	rep(i,0,h)if(occ[i]&&in[i]<out[i])flag=0;
	rep(i,0,h+h)if(occ[i])ok[find(i)]|=(out[i]!=in[i]);
	rep(i,0,h+h)if(occ[i]&&!ok[find(i)])flag=0;
	if(flag)puts("YES");
	else puts("NO");
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n) {
        int shreshold = h[i];
        bool ok = true;
        rep(j, i + 1) {
            if (h[j] > shreshold) ok = false;
        }
        if (ok) ans++;
    }
    out(ans);
    return 0;
}


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

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k <= a + b){
  	cout<<min(a,k)<<endl;
  }
  else if(k > a + b){
  	ll ans = a - (k - a - b);
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main(void){
  int a, b, max;
  cin >> a >> b;
  max = a + b;
  if(a - b > max){
    max = a - b;
  }
  if(a * b > max){
    max = a * b;
  }
  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

//がんばってputintつくるかぁ
const int MAX = 10000;
const int dm = 1 << 17;
char dn[dm], * di = dn, * owad = dn + dm - 20;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 4 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
	void putint(ll A) {
		if (owad < di) {
			fwrite(dn, 1, di - dn, stdout);
			di = dn;
		}
		int dig = 1;
		if (A >= 100000000) {
			if (A >= 10000000000) dig = 3;
			else if (A >= 1000000000) dig = 2;
			memcpy(di + 4 + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += 8 + dig;
		}
		else if (A >= 10000) {
			if (A >= 10000000) dig = 4;
			else if (A >= 1000000) dig = 3;
			else if (A >= 100000) dig = 2;
			memcpy(di + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += 4 + dig;
		}
		else {
			if (A >= 1000) dig = 4;
			else if (A >= 100) dig = 3;
			else if (A >= 10) dig = 2;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += dig;
		}
		*di++ = '\n';
	}
} f;



int A[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	ll kotae = 0;
	rep(i, N) {
		int kari = getint();
		A[kari]++;
		kotae += kari;
	}

	int Q = getint();
	rep(i, Q) {
		int b = getint();
		int c = getint();

		A[c] += A[b];
		kotae += A[b] * ll(c - b);
		A[b] = 0;

		f.putint(kotae);
	}


	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i,j,k;
	cin>>n>>k;
	ll h[n+2];
	for(i=0;i<n;i++)
		cin>>h[i];
	ll dp[n+2];
	dp[0]=0;
	for(i=1;i<n;i++)
	{
		ll mini = 1e18;
		for(j=i-1;j>=max(0ll, i-k);j--)
		{
			mini = min(mini, dp[j] + abs(h[j]-h[i]));
		}
		dp[i]=mini;
	}
	cout<<dp[n-1]<<nl;
	return 0;
}

Measured memory_bytes: 5192
#次の項を求めるための定義分
def next_number(N):
  if N%2 == 0:
    return N/2
  else:
    return 3*N + 1

#ここからメイン文
S = int(input())
i = 2
flag = True
list = [S]
while flag == True:
    S = next_number(S)
    
    #listに追加する文字が既にlist内にないか確認
    if S in list:
        print(i)
        break
    else:
        list.append(S)
        i += 1


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

using i64 = long long int;

const i64 MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<pair<i64, int>> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.emplace_back(a, 1);
    }
    for(int i=0;i<n;++i){
        i64 b;
        cin >> b;
        v.emplace_back(b, -1);
    }

    sort(v.begin(), v.end());

    i64 ans = 1, acc = 0, prev_acc;
    for(auto e : v){
        prev_acc = acc;
        acc += e.second;
        if(abs(acc) < abs(prev_acc))ans = ans * abs(prev_acc) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N;
    cin>>N;
    int a[100001];
    rep(i, 100001){
        a[i]=0;
    }
    int b;
    int cnt=0;
    rep(i, N){
        cin>>b;
        if(b>100000){
            cnt++;
        }
        else{
            a[b]++;
        }
    }
    for(int i=1;i<=100000;i++){
        if(a[i]>=i){
            cnt+=a[i]-i;
        }
        else{
            cnt+=a[i];
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 640
t,*grid = open(0)
h,w = map(int,t.split())
L,R,U,D = eval("[[0]*(w+2) for _ in range(h+2)],"*4)
for y in range(h):
	for x in range(w):
		if grid[y][x]==".":
			L[y+1][x+1] = L[y+1][x]+1
		if grid[y][w-x-1]==".":
			R[y+1][w-x] = R[y+1][w-x+1]+1
for x in range(w):
	for y in range(h):
		if grid[y][x]==".":
			U[y+1][x+1] = U[y][x+1]+1
		if grid[h-y-1][x]==".":
			D[h-y][x+1] = D[h-y+1][x+1]+1
print(max(L[y][x] + R[y][x] + U[y][x] + D[y][x] -3 for y in range(1,h+1) for x in range(1,w+1)))

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

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    ll k,x;
    cin>>k>>x;

    ll s=x-k+1;
    ll e=x+k-1;

    while(s<=e)
    {
        cout<<s<<" ";
        s++;
    }

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007



int main()
{
    lli n;
    cin>>n;
    lli sum=0;
    lli x=n/500;
    n=n-(500*x);
    lli y=(n/5)*5;
    cout<<1000*x+y<<"\n";
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_FLOOR

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = input().split()
A = Decimal(int(A))
B = Decimal(B)
C = A*B
print(C.quantize(Decimal("0"), rounding=ROUND_FLOOR))


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

int main() {
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i,t) cin >> a[i];
  
  int maxa = 0;
  rep(i,t){
    maxa = max(maxa,a[i]);
  }
  
  cout << max(0,2*maxa-1-k) << endl;
}



Measured memory_bytes: 256
n = int(input())
arr = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    # print(arr[i], arr[i + 1], arr[i + 2])
    if (arr[i] < arr[i+1] and arr[i+1] < arr[i+2]) or (arr[i] > arr[i+1] and arr[i+1] > arr[i+2]):

        ans += 1

print(ans)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int a[26];
int main()
{
  int i,j,k,r;
  for(;;){
    cin >> i;
    if(i==0)break;
    for(j=0;j<i;j++){
      cin >> a[j];
    }
    r = 32;
    j = 0;
    while(r > 0){
      r -= (r - 1) % 5;
      cout << r << endl;
      r -= a[j++];
      if(i==j) j = 0;
      if(r < 0) r = 0;
      cout << r << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	k := nextInt()
	a := nextInt()
	b := nextInt()
	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}

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

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1756
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 100000000000007;

int N;
int a[110];

const int S = 0;
const int T = 101;

struct edge {
  int to;
  ll cap;
  int rev;
};

bool visited[110];
vector<edge> V[110];

void add_edge(int from, int to, ll cap) {
  V[from].push_back(edge{to, cap, (int)V[to].size()});
  V[to].push_back(edge{from, 0, (int)V[from].size()-1});  
}

ll dfs(int src, int dst, ll f) {
  if (src == dst) return f;
  visited[src] = true;
  for (auto &x : V[src]) {
    if (!visited[x.to] && x.cap > 0) {
      ll d = dfs(x.to, dst, min(f, x.cap));
      if (d > 0) {
        x.cap -= d;
        V[x.to][x.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(int src, int dst) {
  ll flow = 0;
  while (true) {
    fill(visited, visited+110, false);
    ll f = dfs(src, dst, infty);
    if (f == 0) return flow;
    flow += f;
  }
}

int main () {
  cin >> N;
  for (auto i = 1; i <= N; ++i) {
    cin >> a[i];
  }
  for (auto i = 1; i <= N; ++i) {
    for (auto j = 2; i*j <= N; ++j) {
      add_edge(i, i*j, infty);
    }
  }
  ll sum = 0;
  for (auto i = 1; i <= N; ++i) {
    if (a[i] > 0) {
      add_edge(i, T, a[i]);
      sum += a[i];
    } else if (a[i] < 0) {      
      add_edge(S, i, -a[i]);
    }
  }
  cout << sum - max_flow(S, T) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() 
{
	int n, m;
	cin >> n >> m;
	if (n <= m)rep(i, 0, m)cout << n;
	else rep(i, 0, n)cout << m;
}




Measured memory_bytes: 3600
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn gcd(a:u64, b:u64) -> u64 {
    if b==0 {
        a
    } else {
        gcd(b, a%b)
    }
}
fn main() {
    input! {
        n:usize,
        xx:i64,
        x: [i64;n],
    }
    let mut v:Vec<u64> = vec![0;n];
    for i in 0..n {
        v[i] = (x[i]-xx).abs() as u64;
    }
    let mut ans = v[0];
    for i in 0..n {
        ans = gcd(ans, v[i]);
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=600002;
typedef long long ll;
int n,i,x,y,m,cnt[N],p;
struct Uzi{
    int val,id,tmp;
}a[N];
ll s[N];
bool cmp(Uzi u,Uzi v){
    return u.val<v.val;
}
void init(){
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&x,&y);
        a[++m]=(Uzi){x,i,0};
        a[++m]=(Uzi){y,i,1};
    }
    sort(a+1,a+m+1,cmp);
}
void work(){
    for(i=1;i<=m;i++)
        s[i]=s[i-1]+a[i].val;
    for(i=1;i<=n;i++){
        cnt[a[i].id]++;
        if(cnt[a[i].id]>1){
            printf("%lld\n",s[n]);
            return;
        }
        p+=a[i].tmp==0;
    }
    if(p%n==0){
        printf("%lld\n",s[n]);
        return;
    }
    cnt[a[n].id]--;
    cnt[a[n+1].id]++;
    if(cnt[a[n+1].id]>1){
        printf("%lld\n",s[n-1]+a[n+1].val);
        return;
    }    
    printf("%lld",s[n-2]+min(a[n-1].val+a[n+2].val,a[n].val+a[n+1].val));
}
int main(){
    init();
    work();
    return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define sz 150010
const int mod=1000000007;

ll solve(ll n){
    ll cnt=0,temp=5;
    while(1){
        if(n/temp==0) break;
        cnt+=(n/temp)/2;
        temp*=5;
    }
    return cnt;
}

int main(){
    BeatMeScanf;
    ll n,ans;
    cin>>n;
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    ans=solve(n);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  long N ,A ,B, ans, result, amari;
  cin >> N >> A >> B;
result = N/(A+B);
amari = N%(A+B);
if(amari >= A){
  ans = A+A*result;
}
else{
  ans = amari+A*result;
}
cout << ans << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()
print(S[:-8])

Measured memory_bytes: 5144
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>

using namespace std;

#define int long long

int N;
vector<int> e[26];
int graphSize;

int CountVertex(int v, bool isUsed[26])
{
	if (isUsed[v]) return 0;
	isUsed[v] = true;
	int ret = 1;
	for (int i = 0; i < e[v].size(); i++)
	{
		ret += CountVertex(e[v][i], isUsed);
	}
	return ret;
}

bool IsConnected()
{
	for (int i = 0; i < 26; i++)
	{
		bool isUsed[26] = {};
		if (CountVertex(i, isUsed) == graphSize) return true;
	}
	return false;
}

signed main()
{
	while (cin >> N, N)
	{
		int in[26] = {}, out[26] = {};
		bool flag[26] = {};
		graphSize = 0;
		for (int i = 0; i < 26; i++) e[i].clear();
		for (int i = 0; i < N; i++)
		{
			string s;
			cin >> s;
			int a = s[0] - 'a', b = s[s.size() - 1] - 'a';
			out[a]++;
			in[b]++;
			e[a].push_back(b);
			e[b].push_back(a);
			graphSize += !flag[a];
			flag[a] = true;
			graphSize += !flag[b];
			flag[b] = true;
		}
		bool ans = true;
		for (int i = 0; i < 26; i++)
		{
			if (in[i] != out[i]) ans = false;
		}
		if (ans && IsConnected()) puts("OK");
		else puts("NG");
	}
	return 0;
}

Measured memory_bytes: 1332
#include <stdio.h>

int main(){
  int a, b, c;
  int count=0;

  scanf("%d %d %d", &a, &b, &c);

  for(; a<=b; a++){
    
    if(c % a == 0){
      count += 1;
    }
  }

  printf("%d\n", count);
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int X, Y, Z;

	cin >> X >> Y >> Z;

	cout << Z << " " << X << " " << Y << endl;

	return 0;
}

Measured memory_bytes: 256
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
                if K >= S - (x + y) >= 0 :
                    count += 1
                    
    print(count)

if __name__ == '__main__':
    K, S = map(int, input().split())
    solve(K, S)

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> dp(n);
  dp[0] = 0;
  for(int i = 1; i < n; ++i) {
    dp[i] = dp[i-1];
    string cmp = "";
    cmp += s[i-1];
    cmp += s[i];
    if(cmp == "AC") {
      ++dp[i];
    }
  }
  
  for(int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    int ans = 0;
    ans = dp[r] - dp[l];
    printf("%d\n", ans);
  }
  return 0;
}
  

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

int main(){
  ll N,X; cin>>N>>X;
  ll a=X,b=N-X;
  if(a<b) swap(a,b);
  ll ans=N;
  while(b){
    ll k=a/b;
    ans+=2*k*b;
    ll c=a%b;
    a=b,b=c;
  }
  ans-=a;
  cout<<ans<<endl;
  return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
    return 0;
}

Measured memory_bytes: 256
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1'000'000'007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n);
    ll ans=0;
    FOR(i,1,n+1){
        if(!(i%3==0||i%5==0)) ans+=i;
    }
    
    out(ans);
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}


int main()
{
    int A,P;
    cin >> A >> P;
    P += A*3;
    cout << P/2 << endl;
    return 0;
}


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

using namespace std;

int N, M;
char S[100000], T[100000];

int main() {
  scanf("%d%d", &N, &M);
  scanf("%s%s", S, T);
  
  // 最大公約数を計算
  int g = __gcd(N, M);
  int stepS = N / g;
  int stepT = M / g;
  for (int i = 0; i < g; ++i) {
    if (S[stepS * i] != T[stepT * i]) {
      puts("-1");
      return 0;
    }
  }
  printf("%lld", 1ll * N / g * M);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	vector<cpp_int>alpha(n);
	rep(i, n) {
		string s;
		cin >> s;
		cpp_int tmp = 0;
		rep(j, s.size()) {
			int t = s[j] - 97;
			//cout << t << endl;
			cpp_int m = 1;
			rep(k, t) {
				m *= 10;
			}
			tmp += m;
		}
		alpha[i] = tmp;
	}
	ll ans = 0;
	sort(all(alpha));
	ll cnt = 0;
	rep(i, n - 1) {
		if ((alpha[i] xor alpha[i + 1])==0) {
			cnt++;
		}
		else {
			ans += cnt * (cnt + 1) / 2;
			cnt = 0;
		}
	}
	ans += cnt * (cnt + 1) / 2;
	cout << ans << endl;
}


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

int main() {
	int N;
	cin >> N;
	
	bool f = false;
	for (int i = 0; i < 26; ++i) {
		for (int j = 0; j < 15; ++j) {
			int total = 4 * i + 7 * j;
			if (total == N) f = true;
		}
	}

	cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3088
import sys

B, W = map(int, sys.stdin.readline().split())
MOD = 10**9 + 7

L = B+W
fact = [1]*(L+1)
rfact = [1]*(L+1)
for i in range(L):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

rev2 = pow(2, MOD-2, MOD)

p = q = 0
base = 1
ans = ["%d\n" % rev2]
for i in range(1, B+W):
    base = rev2 * base % MOD
    if i-B >= 0:
        p = (p + (fact[i-1]*rfact[B-1]*rfact[i-B] % MOD)*base % MOD) % MOD
    if i-W >= 0:
        q = (q + (fact[i-1]*rfact[W-1]*rfact[i-W] % MOD)*base % MOD) % MOD
    ans.append("%d\n" % ((1-p+q)*rev2 % MOD))
sys.stdout.writelines(ans)

Measured memory_bytes: 35176
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
 for(int i=0;i<n;i++){
     cin>>a[i];
 }
  sort(a,a+n);
  cout<<abs(a[n-1]-a[0]);
  return 0;
}

Measured memory_bytes: 256
*rgb, N = map(int, input().split())
rgb.sort()

max_roop = N//rgb[2]+1

c = [1 for n1 in range(max_roop) for n2 in range((N-n1*rgb[2])//rgb[1]+1) if (N-n1*rgb[2]-n2*rgb[1])%rgb[0]==0]

print(len(c))


Measured memory_bytes: 38296
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const long long int MOD = 1000000007;

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

	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;

LL mod=1000000007LL;
//         
int main(){
   
    string s;

    cin>>s;

    int length=SZ(s);
    int k;
    cin>>k;

    set<string> sset;
    REP(b,length){

        for(int e=1;e<=k;e++){

            sset.insert(s.substr(b,e));
        }
    }
    // auto itr=sset.begin();
    // itr+=k;
    // for(auto a: sset){
    //     cerr<<a<<endl;
    // }
    // dump(sset.size());
    // for(auto i=sset.begin();i!=sset.end();++i){
    //     cerr<<*i<<endl;
    // }

    auto itr=std::next(sset.begin(),k-1);
    cout<<*(itr)<<endl;

}


Measured memory_bytes: 1664
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer> num = new HashSet<>();
		for(int i=0; i<N ; i++){
			int di = sc.nextInt();
			num.add(di);
		}
		System.out.println(num.size());
	}
}

Measured memory_bytes: 23124