akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int s, w;
	cin >> s >> w;
	if(s<=w)
		cout << "unsafe";
	else
		cout << "safe";


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,k;
string s;

int main(){
    cin >> n >> s >> k;
    k--;
    rep(i,n){
        if(s[i] != s[k])cout << "*";
        else cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int
#include<cmath>
#include<bits/stdc++.h>
int main()
{
	string s;
	string s1;
	ll c=0;
	cin>>s>>s1;
	for(ll i=0;i<s.length();i++)
	{
		if(s[i]!=s1[i])
		c++;
	}
	cout<<c<<endl;
	return 0;
	
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
map<long long, long long> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}

signed main() {
    long long x, n;
    cin >> x >> n;
    vector<int> as(n);
    map<int, int> cnt;
    REP(i, n) {
        cin >> as[i];
        cnt[as[i]]++;
    }
    int mind = 10000;
    int ans;
    for (int i = x - 1000; i < x + 1000; i++) {
        if (cnt[i] == 0 && abs(i - x) < mind) {
            mind = abs(i - x);
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
#include<stdio.h>
	int main(void){
	int a,b,c,n,j,i;
	
	scanf("%d %d %d", &a,&b,&c);

		if(a>b){
			n=b;
			b=a;
			a=n;
		}
		if(b>c){
			j=c;
			c=b;
			b=j;
		}
		if(a>b){
			i=a;
			a=b;
			b=i;
		}
printf("%d %d %d\n",a,b,c);

return 0;
}

Measured memory_bytes: 596
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
a.sort()
li = np.zeros(a[-1])

u, counts = np.unique(a,return_counts=True)

for item in a[::-1]:
  li[item-1::item] = 0
  li[item-1] = 1

#print(li[:100])

for i in range(len(u)):
  if counts[i] >=2:
    li[u[i]-1] = 0

print(int(li.sum()))



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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
ld eps=1e-9;
#define Seg_Max_N (1<<18) 

using Value = pair<bool, long long int>;
const Value ini = make_pair(false,0);
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value connect(const Value&l, const Value&r) {
		if (l.first) {
			if (r.first) {
				return make_pair(false,r.second-l.second);
			}
			else {
				return make_pair(true,l.second+r.second);
			}
		}
		else {
			if (r.first) {
				return make_pair(true,r.second-l.second);
			}
			else {
				return make_pair(false,l.second+r.second);
			}
		}
	}
	// update k th element
	void update(int k, Value a) {
		k += N - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = connect(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return connect(al, ar);
	}
};
int main() {
	//int X;cin>>X;
	//if(X==3||X==5||X==7)cout<<"YES"<<endl;
	//else cout<<"NO"<<endl;

	string st;cin>>st;
	int ans=100000;
	for (int i = 0; i <= st.size() - 3; ++i) {
		string a=st.substr(i,3);
		int k=stoi(a);
		ans=min(ans,abs(753-k));

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;

int n,m,x,ans,v[N],tot,st;

int main(){
	int i,j;
	scanf("%d%d",&n,&x);m=(n<<1)-1;st=1;
	if(m==x || x==1){puts("No");return 0;}
	puts("Yes");v[1]=v[m]=v[x]=1;
	for(i=1;i+1<n;++i) {
	   for(;v[st];++st); printf("%d\n",st),v[st]=1;
	}
	printf("%d\n%d\n1\n",m,x);
	for(i=n+2;i<=m;++i){
		for(;v[st];++st); printf("%d\n",st),v[st]=1;
	}
	return 0;
}

Measured memory_bytes: 2304
S = str(input())
l = [0]* len(S)
q = 1
l[0] = int(S[len(S) - 1])
for i in range(1,len(S)):
    t = int(S[len(S) - i - 1])
    q = q * 10 % 2019
    l[i] = (t*q + l[i - 1]%2019)%2019
l.sort()
m = [0] * len(S)
k = 1
for i in range (len(S) - 1):
    if l[i] != l[i + 1]:
        m[i] = int(k*(k-1)/2)
        k = 1
    else:
        m[i] = 0
        k += 1
if k != 1:
    m[len(S) - 1] = int(k*(k-1)/2)
a = 0
for i in range(len(S)):
    if l[i] == 0:
        a += 1
    else:
        break
print(sum(m) + a)

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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

int main(){
    int x;x=read();
    int ans=(x/500)*1000;
    ans+=(x-(x/500)*500)/5*5;
    cout<<ans;

    return 0;
}


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

int main(){

    int N;
    int t[110000],x[110000],y[110000];
    t[0] = x[0] = y[0] = 0;

    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> t[i+1] >> x[i+1] >> y [i+1];   
    }

    bool can = true;

    for(int i=0; i < N; i++){
        int dt = t[i+1] - t[i]; //移動できる回数
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]); //移動したい距離
        if(dt < dist) can = false;
        if(dt % 2 != dist % 2) can = false;                                                                                                                                                                              

    }

    if (can) cout <<"Yes\n";
    else cout <<"No\n";
    
    

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n, m;
	cin >> n >> m;
	vector<int> l(m);
	vector<int> r(m);
	for(int i = 0; i < m; i++) cin >> l[i] >> r[i];

	SORT(l);
	SORT(r);

	int	ans = r[0] - l[m - 1] + 1;

	cout << (ans >= 0 ? ans : 0) << endl;
}


Measured memory_bytes: 1024
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

Int N,A,B;

int X[100010];

int main(){
	cin>>N>>A>>B;
	REP(i,N)cin>>X[i];
	Int s = X[N-1]-X[0];
	priority_queue<int> q;
	REP(i,N-1)q.push(X[i+1]-X[i]);
	Int ans = A*s;
	while(!q.empty()){
		Int d = q.top();q.pop();
		if(d*A>B){
			ans-=d*A-B;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1276
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    if N==1:
        print(0)
        exit()
    inf=10**10
    #xmax,xmin,ymax,yminそれぞれの時間変化のグラフを見ると上か下に凸ぽい，3本以下の直線で作れる
    #左右上下の値候補，-t,定数,tの時の定数部分
    #xminやxmaxなどが入れ替わるタイミングぐらいでしか最小を取り得ない
    
    X=[0]*N
    Y=[0]*N
    D=[0]*N
    
    for i in range(N):
        xyd=input().split()
        X[i]=int(xyd[0])
        Y[i]=int(xyd[1])
        D[i]=xyd[2]
        
    # x方向に-1,0,1の速度で動くそれぞれの最大値と最小値を求めるか，こいつらが交わるタイミングが大事
    # X方向か，Y方向か
    def calc_ts(S,XX):
        if S=="X":
            L="L"
            R="R"
        else:
            L="D"#min
            R="U"#max
        xmin=[inf,inf,inf]
        xmax=[-inf,-inf,-inf]
        for i in range(N):
            x=XX[i]
            d=D[i]
            if d==L:
                xmin[0]=min(xmin[0],x)
                xmax[0]=max(xmax[0],x)
            elif d==R:
                xmin[2]=min(xmin[2],x)
                xmax[2]=max(xmax[2],x)
            else:
                xmin[1]=min(xmin[1],x)
                xmax[1]=max(xmax[1],x)
        ts=[]
        
        t=xmin[0]-xmin[1]
        if t>0:
            ts.append(t)
            
        t=xmin[0]-xmin[2]
        if t>0:
            ts.append(t/2)
            
        t=xmin[1]-xmin[2]
        if t>0:
            ts.append(t)

        t=xmax[0]-xmax[1]
        if t>0:
            ts.append(t)
            
        t=xmax[0]-xmax[2]
        if t>0:
            ts.append(t/2)
            
        t=xmax[1]-xmax[2]
        if t>0:
            ts.append(t)
            
        return ts
    
    ts_all=[0]
    ts_all+=calc_ts("X",X)
    ts_all+=calc_ts("Y",Y)
    
    #t秒後の面積
    def calc(t):
        xmin=inf
        xmax=-inf
        ymin=inf
        ymax=-inf
        
        for i in range(N):
            x=X[i]
            y=Y[i]
            d=D[i]
            
            if d=="L":
                xmin=min(xmin,x-t)
                xmax=max(xmax,x-t)
                ymin=min(ymin,y)
                ymax=max(ymax,y)
            elif d=="R":
                xmin=min(xmin,x+t)
                xmax=max(xmax,x+t)
                ymin=min(ymin,y)
                ymax=max(ymax,y)
            elif d=="U":
                xmin=min(xmin,x)
                xmax=max(xmax,x)
                ymin=min(ymin,y+t)
                ymax=max(ymax,y+t)
            else:
                xmin=min(xmin,x)
                xmax=max(xmax,x)
                ymin=min(ymin,y-t)
                ymax=max(ymax,y-t)
        return (xmax-xmin)*(ymax-ymin)
    
    ans=inf**2
    for t in ts_all:
        temp=calc(t)
        ans=min(ans,temp)
        
    print(ans)
    

        
    


main()


Measured memory_bytes: 85092
#include<stdio.h>
int main(void){
  int l,i,j,tmp=0;
  scanf("%d",&l);
  int num[l];
  for(i=0;i<l;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<l;i++){
    for(j=i+1;j<l;j++){
      if(num[i]>num[j]){
        tmp=num[i];
        num[i]=num[j];
        num[j]=tmp;
      }
    }
  }
  printf("%d",(num[l-1]-num[0]));
  return 0;
}
        
  

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, m;
    cin >> n >> m;

    vector<int> b(n + 1);
    int s = 0;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;

        s += a;
        if (s >= m) s %= m;
        b[i] = s;
    }

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

    ll r = 0;
    int c, j0 = -1;
    for (const auto& j : b) {
        if (j != j0) {
            c = 0;
            j0 = j;
        } else {
            r += ++c;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
  }
}
 
//??????
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
 
//??????
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
 
//??? (??????)
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
 
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
 
//????§???¢
typedef vector<P> G;
 
G convex_hull(G &ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  G ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) == -1) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) == -1) --k;
  ch.resize(k-1);
  return ch;
}
 
int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    int x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  G ans = convex_hull(g);
  cout <<ans.size() <<endl;
  REP(i, ans.size()) cout <<ans[i].X <<" " <<ans[i].Y <<endl;
  return 0;
}

Measured memory_bytes: 5952
import * as fs from 'fs'

const stdin = fs.readFileSync('/dev/stdin', 'utf8').trim();
const input = stdin
	.split('\n')[0]
	.split(' ')
	.map(Number);

const a = input[0];
const b = input[1];

function solve(a: number, b: number): number {
	const plus = a + b;
	const minus = a - b;
	const multiply = a * b;
	const max = Math.max(plus, minus, multiply);
	return max;
}

export default solve;

console.log(solve(a, b));


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

int main(){
  bool even = false;
  string S;
  cin >> S;

  for (char c='a'; c<='z'; c++){
    for (int i=0; i<S.size(); i++){
      if (c==S.at(i)){
        break;
      }
      if (i==S.size()-1){
        even = true;
      }
    }
    if (even){
      cout << c << endl;
      break;
    }
  }
  if (even==false){
    cout << "None" << endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long abcbcbc;
    cin>>abcbcbc;
    long long s=abcbcbc/11*2;
    abcbcbc%=11;
    if(abcbcbc>=1&&abcbcbc<=6)s++;
    if(abcbcbc>=7&&abcbcbc<=10)s+=2;
    cout<<s<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    if (S.islower() and len(S) <= 10 and len(S) >= 1):
        if (S == T[:-1]):
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int N = 1e6 + 1000;
int cnt[N];
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  int ans = 0;
  for (int ii = 0; ii < n; ii++) {
    int x = a[ii];
    bool is = true;
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0 && (cnt[i] || cnt[x / i])) {
          is = false;
          break;
      }
    }
    if (cnt[x] > 1) is = false;
    if (cnt[1] && x != 1) is = false;
    if (is) ans++;
  }
  cout <<  ans << "\n";
}



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

int n;
int dp[102][2];

vector<int> v;
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	dp[0][0] = 0;
	dp[0][1] = 1;
	for (int i = 1; i < n; i++){
		for (int j = 0; j < 2; j++){
			dp[i][j] = INT_MAX;
			for (int k = 0; k < 2; k++){
				if (j == 0 && k == 0 && v[i] == v[i-1]){
					continue;
				}
				int th = dp[i - 1][k]+j;
				dp[i][j] = min(dp[i][j], th);
			}
		}
	}
	cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split();

            int NA = int.Parse(line[0])* int.Parse(line[1]);
            int B = int.Parse(line[2]);

            Console.WriteLine((NA >= B ? B : NA));
        }
    }


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

int main() {
    int N;
    cin >> N;
    int l[N], r[N];
    for (int i=0; i<N; i++){
       cin >> l[i] >> r[i];
    }
    int out = 0;
    for (int i=0; i<N; i++){
       out += r[i] - l[i] + 1;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
void test_case(){
	int n, s = 0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x, y;
		scanf("%d%d", &x, &y);
		if(x==y)s++;
		else s = 0;
		if(s>=3){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;
}
int main(){
	int t = 1;
	// scanf("%d", &t);
	while(t--)test_case();
}


Measured memory_bytes: 3680
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}

ll BuySell(vll price, ll n)
{
	ll i = 0;
	ll profit = 1000;
	//ll stocks = 0;
	while (i < n - 1)
	{
		//local min
		while ((i < n - 1) and (price[i + 1] <= price[i]))
		{
			i++;
		}
		if (i == n - 1) break;

		ll buy = i++;
		//local max
		while ((i < n) and (price[i] >= price[i - 1]))
		{
			i++;
		}
		ll sell = i - 1;
		profit = (profit / price[buy]) * price[sell] + profit % price[buy];
	}
	return profit;
}

void solve()
{
	ll n;
	cin >> n;
	vll arr(n);
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	cout << BuySell(arr, n) << "\n";

}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }

	return 0;
}

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

int n,q,x,y,ans=0;
int father[200005],v[200005];

int find(int x)
{
	if (x!=father[x])  father[x]=find(father[x]);
	return father[x];
}

signed main()
{
	cin>>n>>q;
	for (int i=1;i<=n;i++)  father[i]=i;
	while (q--)
	{
		cin>>x>>y;
		father[find(y)]=find(x);
	}
	for (int i=1;i<=n;i++)  father[i]=find(father[i]);
	for (int i=1;i<=n;i++)  v[father[i]]++;
	for (int i=1;i<=n;i++)  ans=max(ans,v[i]);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6688
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    float ans;
    float r;
    cin >> r;
    ans = 2* 3.14159263 * r;
    printf("%.6f\n",ans);

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int tmp = 0;
    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != '0'){
            ans = max(ans, tmp + s[i] - '1' + 9 * ((int)s.size() - i - 1));
        }
        tmp += s[i] - '0';
    }
    ans = max(ans, tmp);
    cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>p(n),c(n); for(auto&&i:p)cin>>i; for(auto&&i:c)cin>>i;
	int64_t ans=INT64_MIN;
	for(int i=0;i<n;++i){
		vector<int>v(n,false);
		int64_t tans=0,tmx=0;
		for(int j=0,nw=i;j<k;++j){
			if(v.at(p.at(nw)-1)){
				ans=max(ans,tans*(k/j-1)+tmx);
				if(tans>0)tans*=k/j;
				nw=p.at(nw)-1;
				ans=max(ans,tans);
				for(int K=0,lim=k%j;K<lim;++K){
					tans+=c.at(p.at(nw)-1);
					nw=p.at(nw)-1;
					ans=max(ans,tans);
				}
				break;
			}
			else v.at(p.at(nw)-1)=true;
			tans+=c.at(p.at(nw)-1);
			tmx=max(tmx,tans);
			nw=p.at(nw)-1;
			ans=max(ans,tans);
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

signed main(){
    int a,b;
    cin >> a >> b;
    if(a%2 && b%2) puts("Odd");
    else puts("Even");

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main () {
int i,j;
char n[100000] = {0};
int  x[1001] = {0};
 
i = 0;
j = 0;
 
 
while(1) {
scanf("%c",&n[i]);
if(n[i] == '0' && n[i-1] == '\n'|| n[0] == '0') {break;}
 
if(n[i] >= '1' && '9' >= n[i] && n[i] != '\n') {
x[j] += n[i]-48;
}
  if(n[i] == '\n') {
j = j + 1;
}
 
i= i+1;
 
}
 
for(i=0; i < j;i++) {
printf("%d",x[i]);
printf("\n"); 
 
} 
 
return 0;
 
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
const int N =2000000+5, yzh = 1e9+7;

int k, n, fac[N], ifac[N]; char ch[N];

int quick_pow(int a, int b) {
    int ans = 1;
    while (b) {
        if (b&1) ans = 1ll*a*ans%yzh;
        b >>= 1, a = 1ll*a*a%yzh;
    }
    return ans;
}
int C(int n, int m) {return 1ll*fac[n]*ifac[m]%yzh*ifac[n-m]%yzh; }
int main() {
    scanf("%d%s", &k, ch+1); n = strlen(ch+1);
    ifac[0] = ifac[1] = fac[0] = 1;
    for (int i = 2; i <= n+k; i++) ifac[i] = -1ll*yzh/i*ifac[yzh%i]%yzh;
    for (int i = 1; i <= n+k; i++) {
        fac[i] = 1ll*fac[i-1]*i%yzh;
        ifac[i] = 1ll*ifac[i]*ifac[i-1]%yzh;
    }
    int ans = 0;
    for (int i = 0; i <= k; i++)
        (ans += 1ll*quick_pow(25, k-i)*quick_pow(26, i)%yzh*C(n+k-i-1, n-1)%yzh) %= yzh;
    printf("%d\n", (ans+yzh)%yzh);
    return 0;
}


Measured memory_bytes: 20336
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S; cin>>S;
  int ans=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='+') ans++;
    else ans--;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    if n <= 3 {
        return "0".to_string();
    }

    let mut r: Vec<usize> = vec![0; n + 1];
    let mut g: Vec<usize> = vec![0; n + 1];
    let mut b: Vec<usize> = vec![0; n + 1];
    for i in (0..n).rev() {
        if s[i] == 'R' {
            r[i] = r[i + 1] + 1;
            g[i] = g[i + 1];
            b[i] = b[i + 1];
        } else if s[i] == 'G' {
            r[i] = r[i + 1];
            g[i] = g[i + 1] + 1;
            b[i] = b[i + 1];
        } else {
            r[i] = r[i + 1];
            g[i] = g[i + 1];
            b[i] = b[i + 1] + 1;
        }
    }

    let mut ans = 0;

    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            let ci = s[i];
            let cj = s[j];
            let ng_index = j + (j - i);
            if ci == 'R' && cj == 'G' || ci == 'G' && cj == 'R' {
                ans += b[j + 1];
                if ng_index < n && s[ng_index] == 'B' {
                    ans -= 1;
                }
            } else if ci == 'G' && cj == 'B' || ci == 'B' && cj == 'G' {
                ans += r[j + 1];
                if ng_index < n && s[ng_index] == 'R' {
                    ans -= 1;
                }
            } else if ci == 'R' && cj == 'B' || ci == 'B' && cj == 'R' {
                ans += g[j + 1];
                if ng_index < n && s[ng_index] == 'G' {
                    ans -= 1;
                }
            }
        }
    }

    return ans.to_string();
}


Measured memory_bytes: 2236
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;
 
 int main(){
	 int N;
	 string S, ans = "Three";
	 cin >> N;
	 rep(i, N){
		 cin >> S;
		 if(S == "Y"){
			 ans = "Four";
			 break;
		 }
	 }
	 cout << ans;
	 return 0;
 }

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r):
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)

def resolve():
    n, k = map(int, input().split())
    A = [int(input()) for _ in range(n)]
    M = max(A)
    tree = SegmentTree([0] * (M + 1), max, 0)

    for v in A:
        l = max(0, v - k)
        r = min(M, v + k)
        tree.update(v, tree.sum(l, r + 1) + 1)

    print(tree.sum(0, M + 1))
resolve()

Measured memory_bytes: 97072
#include<bits/stdc++.h>
const double EPS =  1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y){}

    Point operator + (Point p){
        return Point(x + p.x, y + p.y);
    }
    Point operator - (Point p){
        return Point(x - p.x, y - p.y);
    }
    Point operator * (Point p){
        return Point(x * p.x, y * p.y);
    }
    Point operator * (double r){
        return Point(x * r, y * r);
    }
    Point operator / (Point p){
        return Point(x / p.x, y / p.y);
    }

    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x * x + y * y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
    
    
};

typedef Point Vector;

class Segment : public Point{
    public:
    Point p1, p2;
    Segment(Point p1_, Point p2_){
        p1 = p1_;
        p2 = p2_;
    }
    Segment(double a, double b, double c, double d){
        Point(a, b);
        Point(c, d);
    }
    
};

typedef Segment Line;

double dot(Point a, Point b){
    return a.x * b.x + a.y * b.y;
}
double cross(Point a, Point b){
    return a.x * b.y - a.y * b.x;
}
bool isOrthogonal(Point a, Point b){
    return equals(dot(a, b), 0.0);
}
bool isParallel(Point a, Point b){
    return equals(cross(a, b), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2){
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s1.p1), 0.0);
}
bool isParallel(Segment s1, Segment s2){
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s1.p1), 0.0);
}

Point project(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    //Vector tmp = s.p1 + base * r;
    Vector tmp = base * r;
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p){
    return p + (project(s, p) - p) * 2;
}

int ccw(Point p1, Point p2, Point p3){
    Vector a = p2 - p1;
    Vector b = p3 - p1;
    if( cross(a, b) > EPS ) return 1;
    else if( cross(a, b) < -EPS ) return -1;
    else if( dot(a, b) < -EPS ) return 2;
    else if( a.norm() < b.norm() ) return -2;
    //std::cout << std::fixed << std::setprecision(10) << ans.x << " " << ans.y << std::endl;
    else return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4){
    return(ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

int main(void){
    Point p0, p1, p2, p3;
    
    
    int q;
    std::cin >> q;

    for(int i = 0; i < q; i++){
        std::cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        std::cout << intersect(p0, p1, p2, p3) << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, x;
    cin >> n >> x;
    int count = 0;
    int d = 0;
    if(d<=x){
        count++;
    }
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        d += a;
        if(d<=x){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int res = 0;
    rep(i, 10) {
        rep(j, 10) {
            rep(k, 10) {
                vector<int> v = {i, j, k};
                int t = 0;
                rep(l, n) {
                    if ((s[l] - '0') == v[t]) t++;
                    if (t == 3) {
                        res++; break;
                    }
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int N;
            cin >> N;
                if(N % 2 == 0){
                    cout << (N + 1)*(N / 2);
                }else if(N % 2 == 1){
                    cout << ((N + 1) / 2)*N;
                }
    return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
int n,k;
int main ()
{
	scanf("%d%d",&n,&k);
	char s;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(i==k) 
		{
			cout<<(char)(s+32);
		}
		else cout<<s;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,t;
  int sum,i=1;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&t);
  while(1)
  {
    if(t<a)break;
    else
    {
      t-=a;
      i++;
      sum+=b;
    }
  }
  printf("%d",sum);
}

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

int main(){
  while(1){
    int ans=1;
    int n;
    cin>>n;
    if(n==0)break;
    vector< vector<int> > xy (21, vector<int>(21,0) );
    int x=10;
    int y=10;
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      xy[a][b]=1;
    }
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
      string s;
      int m;
      cin>>s>>m;
      for(int j=0;j<m;j++){
        if(s=="N")y++;
        if(s=="E")x++;
        if(s=="S")y--;
        if(s=="W")x--;
        xy[x][y]=0;
      }
    }
    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
        if(xy[i][j]!=0){
          ans=0;
        }
      }
    }
    if(ans==1){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

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

const int mod = 1e9 + 7;
const int MX = 4010;
const int offset = 2000;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}
int fact[10010], invf[10010];
int comb(int n, int k) {
    return 1LL * fact[n] * invf[k] % mod * invf[n - k] % mod;
}

int N;
int A[200010], B[200010];
int chk[4010][4010];

int cc[4010][4010];
int dp(int x, int y) {
    if(x >= MX || y >= MX) return 0;
    int &ret = cc[x][y];
    if(ret != -1) return ret;

    ret = 0;
    ret += chk[x][y];
    ret %= mod;
    ret += dp(x + 1, y);
    ret %= mod;
    ret += dp(x, y + 1);
    ret %= mod;
    return ret;
}

int main() {
    fact[0] = 1;
    for(int i = 1; i < 10010; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < 10010; i++) {
        invf[i] = inv(fact[i]);
    }

    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d %d", &A[i], &B[i]);
        chk[ A[i] + offset ][ B[i] + offset ]++;
    }

    memset(cc, -1, sizeof(cc));
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += dp(-A[i] + offset, -B[i] + offset);
        ans %= mod;
    }
    for(int i = 0; i < N; i++) {
        ans += mod - comb(2 * A[i] + 2 * B[i], 2 * A[i]);
        ans %= mod;
    }
    ans = 1LL * ans * inv(2) % mod;
    ans %= mod;
    printf("%d", ans);
}


Measured memory_bytes: 99072
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

int main()
{
    string s;

    cin>> s ;
    string ans="No";

    if(s[0]=='7'  || s[1]=='7' ||s[2]=='7')ans="Yes";
    cout<<ans;
}






Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0,maxi=0;
    s.push_back('S');
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            c++;
        }
        else{
            maxi=max(maxi,c);
            c=0;
        }
        //bcout<<maxi<<endl;
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int x1,x2,x3,x4,y1,y2,y3,y4,X,Y;
	cin >> x1 >> y1 >> x2 >> y2;
	X=x2-x1;
	Y=y2-y1;
	x3=x2-Y;
	y3=y2+X;
	x4=x3-X;
	y4=y3-Y;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

INF = 10 ** 20

while True:
  n, m, l = map(int, input().split())
  if n == 0:
    break
  edges = [[] for _ in range(n * (l + 1))]
  for _ in range(m):
    a, b, d, e = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(d, l + 1):
      edges[i * n + a].append((0, (i - d) * n + b))
      edges[i * n + b].append((0, (i - d) * n + a))
    for i in range(l + 1):
      edges[i * n + a].append((e, i * n + b))
      edges[i * n + b].append((e, i * n + a))
  
  que = []
  heappush(que, (0, l * n))
  costs = [INF] * (n * (l + 1))
  costs[l * n] = 0
  while que:
    total, node = heappop(que)
    for enemy, to in edges[node]:
      if costs[to] > total + enemy:
        costs[to] = total + enemy
        heappush(que, (total + enemy, to))

  ans = min(costs[i * n + n - 1] for i in range(l + 1))
  print(ans)


Measured memory_bytes: 60104
H,W,K = map(int, input().split())
fields = [list(input()) for i in range(H)]
bins = []
hs = [] #区切る位置
ws = []
for i,f in enumerate(fields):
    if "#" in f:
        hs.append(i)
hs = hs+[H]
cnt = 0
ans = []
h_fr = 0
for i in range(1,len(hs)):
    h_to = hs[i]
    if h_fr - h_to == 0:continue
    f = fields[h_fr:h_to]
    # print(i,h_fr,h_to,f)
    ws = []
    for j in range(W):
        for i in range(h_fr,h_to):
             if fields[i][j] == "#":
                 ws.append(j)
    ws += [W]
    cnts = []
    w_fr = 0
    for j in range(1,len(ws)):
        w_to = ws[j]
        if w_to-w_fr > 0:
            cnt += 1
            cnts.extend([cnt]*(w_to-w_fr))
            w_fr = w_to
    for i in range(h_to-h_fr):
        ans.append(cnts)
    h_fr = h_to
# print(ans)
for f in ans:
    print(*f)

Measured memory_bytes: 8272
#include <stdio.h>
int main(){

  int i,j,N[100],loop,count=0,num;

  scanf("%d",&loop);

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

  for(i=0; i<loop-1; i++){
    for(j=loop-1; j>i; j--){
      if(N[j-1]>N[j]){
	num = N[j-1];
	N[j-1] = N[j];
	N[j] = num;
	count++;
      }
    }
  }

  for(i=0; i<loop-1; i++){
    printf("%d ",N[i]);
  }
  printf("%d\n",N[i]);
  printf("%d\n",count);

  return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

const int INF = 1001001001;
// long long max => LLONG_MAX


vector<vector<int>> tree;

vector<int> distU;
vector<int> distV;
int f[100005];




void dfsU(int _v, int _p){
    for(int nv : tree[_v]){
        if(nv == _p) continue;
        distU[nv] = distU[_v]+1;
        dfsU(nv, _v);
    }
}

void dfsV(int _v, int _p){
    for(int nv : tree[_v]){
        if(nv == _p) continue;
        distV[nv] = distV[_v]+1;
        dfsV(nv, _v);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    tree.resize(n);
    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    f[0] = 0;
    f[1] = 0;
    f[2] = 1;
    for(int i = 3; i < 100005; i++){
        f[i] = 2 + f[i-2];
    }

    distU.resize(n);
    distV.resize(n);
    distU[u] = 0;
    distV[v] = 0;
    dfsU(u, -1);
    dfsV(v, -1);

    int ans = 0;

    
    for(int i = 0; i < n; i++){
        int difDist = distV[i] - distU[i];
        if(difDist > 0){
            int ansTmp = distU[i] + f[difDist];
            ans = max(ans, ansTmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10752
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
#define lFor(i,a,b) for(ll i=a;i<b;i++)
#define lFOR(i,a,b) for(ll i=a;i<=b;i++)
#define lcFor(i,a,b) for(ll i=a;i>b;i--)
#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
int main(){
	char x;
	cin>>x;
	cout<<((char)(x+1))<<endl;
} 

Measured memory_bytes: 256
/*
    coder:xxjAc
    name:
    time:2017/8/12 
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>
using namespace std;
const int INF=1000000007;
int main(){
	string s;
	cin>>s;
	if (s[0]==s[2]){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cmath>
long long int m = pow(10,9) + 7;
int main()
{
    long long int n ;
    cin >> n;
    long long int flag = 0;
    long long int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
        flag+=arr[i];
    }
    long long int final_arr[n];
    for(int i=0;i<n;i++){
        final_arr[i] = flag - arr[i];
        flag-=arr[i];
    }
    long long int product = 0;
    for(int i=0;i<n;i++){
        product += (((arr[i] % m) * (final_arr[i] % m))%m);
        product = product % m;
    }
    cout << product << endl;
}


Measured memory_bytes: 6676