akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#include<iostream>
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
#define N 1000050 
#define int long long
int lpf[N], mobius[N]; 
int fre[N] = {0}; 
#define rrr 	return 0;
void least_prime_factor() 
{ 
	for (int i = 2; i < N; i++) 

		// If it is a prime number 
		if (!lpf[i]) 

			for (int j = i; j < N; j += i) 

				// For all multiples which are not 
				// visited yet. 
				if (!lpf[j]) 
					lpf[j] = i; 
} 


void Mobius() 
{ 
	for (int i = 1; i < N; i++) { 

		// If number is one 
		if (i == 1) 
			mobius[i] = 1; 
		else { 

			// If number has a squared prime factor 
			if (lpf[i / lpf[i]] == lpf[i]) 
				mobius[i] = 0; 

			// Multiply -1 with the previous number 
			else
				mobius[i] = -1 * mobius[i / lpf[i]]; 
		} 
	} 
} 

int gppp(int a[], int n) 
{ 
	// To store maximum number 
	int maxi = 0; 

	// To store frequency of each number 
	

	// Find frequency and maximum number 
	for (int i = 0; i < n; i++) { 
		fre[a[i]]++; 
		maxi = max(a[i], maxi); 
	} 

	least_prime_factor(); 
	Mobius(); 


	int ans = 0; 
 
	for (int i = 1; i <= maxi; i++) { 
		if (!mobius[i]) 
			continue; 

		int temp = 0; 
		for (int j = i; j <= maxi; j += i) 
			temp += fre[j]; 

		ans += temp * (temp - 1) / 2 * mobius[i]; 
	} 


	return ans; 
} 
void check()
{
    if(false)
    cout<<"C"<<endl;
}
int32_t main() 
{ 
	int nn;
	cin >> nn;
	check();
	int a[nn];
	for(int i=0;i<nn;i+=1)
	{
		cin >> a[i];
	}

	int x= gppp(a, nn); 
	//cout << x << endl;
	if(!(x!=(nn*(nn-1))/2))
	{
		cout << "pairwise coprime"<<endl;;
		return 0;
	}
	else{
	    check();
	}
	
	int gc=a[0];
	for(int i=1;i<nn;i++)
	gc=__gcd(gc,a[i]);
	
	if(gc==1)
	{
		cout << "setwise coprime"<<endl;;
		rrr
	}
	
	cout << "not coprime"<<endl;;
	
	
	
	
	rrr
}

Measured memory_bytes: 34804
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		int a[] = new int[N];
		int b[] = new int[N];
		int max = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			max = Math.max(a[i], max);
		}
		
		Arrays.sort(b);
		int ans = 0;
		int sum = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(max > b[i]) {
				break;
			}
			sum += b[i];
			ans++;
			if(sum >= H) {
				System.out.println(ans);
				return;
			}
		}
		while(sum < H) {
			sum += max;
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 88172
#[macro_use]
mod reader {
    use std;
    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);
    pub fn read_trim() -> String { read_line!().trim().to_owned() }
}
use reader::*;
fn main() {
    let input = read_trim();
    let former: u32 = input[..2].parse().ok().unwrap();
    let latter: u32 = input[2..].parse().ok().unwrap();
    if 1 <= former && former <= 12 {
        if 1 <= latter && latter <= 12 {
            println!("AMBIGUOUS");
        } else { println!("MMYY"); }
    } else {
        if 1 <= latter && latter <= 12 {
            println!("YYMM")
        } else { println!("NA") }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char S[200010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),K=gi();
	if(K>2*n&&(~n&1)){for(int j=1;j<=n;++j)putchar('A'+(n-j&1));return 0;}
	scanf("%s",S+1);for(int i=1;i<=n;++i)S[i]-='A';
	int s=1,tag=0;
	for(int i=1;i<=2*n;++i){
		if(S[s]^tag)tag^=1,S[s]=tag,(s==n)?s=1:++s;
		else S[s]^=1;
		if(K==i)break;
	}
	if(K>2*n)S[s]^=(K-2*n&1);
	for(int j=0;j<n;++j)printf("%c",'A'+(S[(s+j-1)%n+1]^tag));
	return 0;
}


Measured memory_bytes: 640
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, m, V, P, ai[MAX_N];

bool check(int mid)
{
    if (ai[mid] + m < ai[P])
        return false;
    long long acc = 0;
    for (int i = P; i <= n; i++)
        if (i != mid && ai[i] < ai[mid] + m)
            acc += min(m, ai[mid] + m - ai[i]);
    return acc >= 1LL * (V - 1) * m;
}

int main()
{
    scanf("%d%d%d%d", &n, &m, &V, &P);
    for (int i = 1; i <= n; i++)
        scanf("%d", &ai[i]);
    sort(ai + 1, ai + 1 + n), reverse(ai + 1, ai + 1 + n);
    V = max(1, V - P + 1);
    int l = P, r = n, res = P;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid))
            res = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 4208
function Main(input) {
	input = input.trim();
  var N = parseInt(input.split("\n")[0].split(" ")[0]);
  var M = parseInt(input.split("\n")[0].split(" ")[1]);
  var list = [];
  for(var i = 1; i <= N; i++){
    var tmp = input.split("\n")[i].split(" ");
    if(i == 1){
   	 for(var j = 1; j <= parseInt(tmp[0]); j++){
   	   list.push(tmp[j]);
   	 }
  	}else{
      tmp.shift();
      for(var j = 0; j < list.length; j++){
        if(tmp.indexOf(list[j]) == -1){
           list.splice(list.indexOf(list[j]),1);
          j--;
        }
      }
    }
  }
  console.log(list.length);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i,n) for (int i=1; i<=(n); i++)
typedef long long ll;
using namespace std;
 
int main(){
    int N; cin >> N;
    int ans=0;
    for (int i=1; i<=N; i+=2){
        int num=0;
        for (int j=1; j<=i; j++){
            if (i%j==0) num++;
        }
        if (num==8) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
def is_kaibun(s):
    half = int(len(s) / 2) if len(s) % 2 == 0 else int((len(s) + 1) / 2)
    for i in range(half):
        if s[i] != s[-(i + 1)]:
            return False
    return True


s = input()
s1 = s[:int((len(s) - 1) / 2)]
s2 = s[int(((len(s) + 3) / 2) - 1):]
result = is_kaibun(s) and is_kaibun(s1) and is_kaibun(s2)
print('Yes' if result else 'No')


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main(){

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 1;
  rep(i, n) ans *= 3;
  ll tmp = 1;
  rep(i, n) tmp *= (a[i] % 2 == 0 ? 2 : 1);
  ans -= tmp;

  cout << ans << endl;  

  return 0;
}


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

int main() {
  string N;
  cin >> N;

  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    char c[3][3];
    rep(i,0,2){
        rep(j,0,2){
            cin>>c[i][j];
        }
    }
    cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
    return 0;
}

Measured memory_bytes: 256
// OBツ嘉ッツ嘉債宿2011 Day3 I : White Bird

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const double EPS = 1e-8;

int main(){
	int N, V, X, Y;
	int L[50], B[50], R[50], T[50];
	while(cin >> N >> V >> X >> Y){
		vector<double> vd;
		int low = Y, high = 1000000007;
		for(int i=0;i<N;i++){
			cin >> L[i] >> B[i] >> R[i] >> T[i];
			L[i] = min(L[i], X);
			R[i] = min(R[i], X);
			if(L[i]<=X&&X<=R[i]&&B[i]>=high) high = min(high, B[i]);
		}
		bool clear = false;
		for(int i=1;i<900000;i++){
			double angle = (double)i/10000/180*acos(-1);
			double vx = V*cos(angle);
			double vy = V*sin(angle);
			bool ok = true;
			for(int j=0;j<N;j++){
				double my = vy*(L[j]/vx) - 4.9*(L[j]/vx)*(L[j]/vx);
				double My = vy*(R[j]/vx) - 4.9*(R[j]/vx)*(R[j]/vx);
				if(my > My) swap(my, My);
				if(L[j]+EPS < vx*vy/9.8 && vx*vy/9.8 < R[j]-EPS)
					My = vy*(vy/9.8) - 4.9*(vy/9.8)*(vy/9.8);
				if(min(My, (double)T[j]) - max(my, (double)B[j]) > EPS) ok = false;
			}
			if(!ok) continue;
			double y = vy*(X/vx) - 4.9*(X/vx)*(X/vx);
			if(low-EPS < y && y < high+EPS) clear = true;			
		}
		cout << (clear ? "Yes" : "No") << endl;
	}
}

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



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

    int N;
    cin>>N;
    int a[N];
    map<int,int> m;
    rep(i,N){
        cin>>a[i];
        m[a[i]]++;
    }
    int cou=0;
    for(auto p:m){
        cou++;
    }
    string ans="Yes";
    if(cou>3 ) ans="No";
    else if(cou==3){
        if(N%3!=0) ans="No";
        int y[3];
        int x[3];
        cou=0;
        for(auto p:m){
            x[cou]=p.first;
            y[cou]=p.second;
            cou++;
        }
        int w=x[0]^x[1];
        w=w^x[2];
        if(w!=0||y[0]!=y[1]||y[1]!=y[2]||y[0]!=y[2]) ans="No";


    }
    else if(cou==1){
        int x=0;
        for(auto p:m){
            x=p.first;
        }
        if(x!=0) ans="No";
    }else if(cou==2){
        if(N%3!=0) ans="No";
        int x,y;
        for(auto p:m){
            x=p.first;
            y=p.second;
        }
        if(x==0 || y!=2*N/3) ans="No";
    }
    cout << ans << endl;


}


Measured memory_bytes: 5760
<?php
fscanf(STDIN, '%d %d %d %d', $a, $b, $c, $k);

if ($a <= $k) {
  $sum = $a;
  $k -= $a;
} elseif ($k < $a) {
  $sum = $k;
  echo $sum;
  exit;
}

if ($b <= $k) {
  $k -= $b;
} else {
  echo $sum;
  exit;
}

if ($c <= $k) {
  $sum -= $c;
} else {
  $sum -= $k;
}

echo $sum;

Measured memory_bytes: 16180
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    if(i&1)continue;
    if(a&1) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int partition(int [], int, int);

int n;
int main()
{
  int i,q,A[100000];

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

  q=partition(A,0,n-1);

  for(i=0;i<n;i++){
     if(i!=0) printf(" ");
     if(i==q) printf("[");
     printf("%d",A[i]);
      if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}

int partition(int A[], int p, int r){
  int x,i,j,temp1,temp2;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      temp1=A[i];
      A[i]=A[j];
      A[j]=temp1;
    }
  }
  temp2=A[i+1];
  A[i+1]=A[r];
  A[r]=temp2;

  return i+1;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int x,y;
  cin >> x >> y;

  cout << x + (y/2) << endl;

  return 0;
}

Measured memory_bytes: 256
def solve(n, m, a, b):
    cell = n * m
    need = 2 * (a + b)
    if cell < need:
        return 'NO'

    d = '.<>^v'
    f = [[0] * m for _ in range(n)]

    if n & 1:
        for j in range(0, m - 1, 2):
            if a:
                f[-1][j] = 1
                f[-1][j + 1] = 2
                a -= 1
            else:
                break
    if m & 1:
        for i in range(0, n - 1, 2):
            if b:
                f[i][-1] = 3
                f[i + 1][-1] = 4
                b -= 1
            else:
                break

    sqa = a // 2
    sqb = b // 2
    sq = sqa + sqb
    ra, rb = a & 1, b & 1
    sqc = (n // 2) * (m // 2)
    if sq > sqc:
        return 'NO'
    if sq == sqc and (ra or rb):
        return 'NO'
    if sq + 1 == sqc and (ra and rb):
        if n & 1 and m & 1:
            f[-3][-3] = f[-1][-2] = 1
            f[-3][-2] = f[-1][-1] = 2
            f[-3][-1] = f[-2][-3] = 3
            f[-2][-1] = f[-1][-3] = 4
            ra = rb = 0
        else:
            return 'NO'

    i, j = 0, 0
    for i in range(0, n - 1, 2):
        for j in range(0, m - 1, 2):
            if sqa:
                f[i][j] = f[i + 1][j] = 1
                f[i][j + 1] = f[i + 1][j + 1] = 2
                sqa -= 1
            elif sqb:
                f[i][j] = f[i][j + 1] = 3
                f[i + 1][j] = f[i + 1][j + 1] = 4
                sqb -= 1
            else:
                break
            # print(sqa, sqb)
            # print('\n'.join(''.join(map(d.__getitem__, r)) for r in f))
            # print('---')
        else:
            continue
        break
    if ra:
        f[i][j] = 1
        f[i][j + 1] = 2
        j += 2
        if j >= m - 1:
            j = 0
            i += 2
    if rb:
        f[i][j] = 3
        f[i + 1][j] = 4

    return 'YES\n' + '\n'.join(''.join(map(d.__getitem__, r)) for r in f)


n, m, a, b = map(int, input().split())
print(solve(n, m, a, b))


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

int solve(int x, int y, int z) {
  return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

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

  vector<int> ans(1e5);

  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int k = 1; k < 100; k++) {
        ans[solve(i, j, k)]++;
      }
    }
  }

  for (int i = 1; i < n + 1; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
import collections
n = int(input())
S = [input() for i in range(n)]
c = collections.Counter(S)
li = c.most_common()
M = li[0][1]
ans = []
for x in li:
    if x[1] == M:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)

Measured memory_bytes: 47636
#include <stdio.h>
#include <string.h>
 
int main(void) {
	char str[1001], order[10], tmp[1001];
	int q, a, b;
	int i;
	
	scanf("%s", str);
	scanf("%d", &q);
	
	while (q--){
		scanf("%s %d %d", order, &a, &b);
		
		if (strcmp(order, "print") == 0){
			for (i = a; i <= b; i++) printf("%c", str[i]);
			printf("\n");
		}
		else if (strcmp(order, "replace") == 0){
			scanf("%s", tmp);
			strncpy(&str[a], tmp, b-a+1);
		}
		else {
			strcpy(tmp, str);
			for (i = 0; i <= b-a; i++) tmp[a+i] = str[b-i];
			strcpy(str, tmp);
		}
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<ll> H(N);
	rep(i, N) cin >> H[i];

	ll mx = 0;
	for(int i = 0; i < N; i++){
		if(mx >= H[i] + 2){
			cout << "No" << endl;
			return 0;
		}

		mx = max(mx, H[i]);
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 100000007
#define INF 1e9
/****************************/
using namespace std;
int a[310][310];
bool can[310][310];
int main()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		rep(j,n)
		{
			cin>>a[i][j];
		}
	}
	memset(can,true,sizeof(can)); 
	rep(k,n)
	{
		rep(i,n)
		{
			rep(j,n)
			{
				if(k!=i&&k!=j&&i!=j)
				{
					if(a[i][j]==a[k][i]+a[k][j])
					{
						can[i][j]=false;
					}
					if(a[i][j]>a[k][i]+a[k][j])
					{
						cout<<"-1";
						return 0;
					} 
				}
			} 
		}
	}
	long long ans=0;
	rep(i,n)
	{
		rep(j,n)
		{
			if(can[i][j])
			{
				ans+=a[i][j];
			}
		}
	}
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18

const int RT = 31644;

vector<int>prime;
vector<int>factor;
bitset<31666> status;

void sieve()
{
    int rt = 3164;
    for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;

    prime.push_back(2);
    status[2]=false;

    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

lll primefac(int n)
{
    int pf_idx=0,pf=prime[pf_idx],SIZE=prime.size();
    lll ans=1,lol=0;
    while(pf*pf<=n&&pf<SIZE)
    {
        if(n%pf==0)
        {
            lol=0;
            while(n%pf==0) {n/=pf; lol++; }
            ans*=(lol+1);
            //cout<<ans<<endl;
        }
        pf=prime[++pf_idx];
    }
    if(n!=1) ans*=(1+1);
    return ans;
}
void solve()
{
   sieve();
   int n;
   cin>>n;
   lll num=1;
   for(int i=2;i<=n;i++)
   {
      num+=(primefac(i)*i);
   }
   cout<<num<<endl;
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //int t; cin>>t; while(t--) solve();
    solve();

}


Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	public static final int MAX = 123456;
	
	public static void main(String[] args) {
		boolean[] is_prime = new boolean[MAX * 2 + 1];
		
		Arrays.fill(is_prime, true);
		is_prime[0] = is_prime[1] = false;
		
		for(int i = 0; i <= MAX * 2; i++){
			if(is_prime[i]){
				for(int j = 2 * i; j <= MAX * 2; j += i){
					is_prime[j] = false;
				}
			}
		}
		
		int[] count = new int[MAX * 2 + 1];
		
		for(int i = 0; i <= MAX * 2; i++){
			if(is_prime[i]){
				count[i] = 1;
			}
		}
		
		for(int i = 1; i <= MAX * 2; i++){
			count[i] += count[i-1];
		}
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			System.out.println(count[2*n] - count[n]);
		}
		
		sc.close();
	}

}

Measured memory_bytes: 23808
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]

T.sort()
ans = 1
now_t = T[0] + K
now_p = 1

for t in T:
    if now_t < t or now_p > C:
        ans += 1
        now_p = 1
        now_t = t + K
    now_p += 1

print(ans)


Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  int maxcnt = 0;
  int cnt = 0;
  for (int i = N-1; i >= 1; i--) {
    if (H[i] <= H[i-1]) cnt++;
    else {
      maxcnt = max({maxcnt, cnt});
      cnt = 0;
    }
  }
  maxcnt = max({maxcnt, cnt});
  cout << maxcnt << endl;
  return 0;
}


Measured memory_bytes: 640
# https://atcoder.jp/contests/nomura2020/submissions/13746705
t = gets.to_s.chomp
n = t.size

r = 0
ans = 0
t.chars.each_with_index do |c, i|
  k = i - r
  if c == '0'
    r += 1 if k.even?
  else
    ans += i / 2 - k / 2
    ans += n - i if k.even?
  end
end

puts ans

Measured memory_bytes: 30676
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

#define MAX 1000002
typedef unsigned char byte;
byte mask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

int Lv[MAX];
int n, k;

bool cmp_Lv(const int i, const int j){ return Lv[i] < Lv[j]; }

bool cmp(const int i, const int j){
    if(Lv[i] != Lv[j]){ return Lv[i] < Lv[j]; }
    int L_i = (i + k >= n ? -1 : Lv[i + k]);
    int L_j = (j + k >= n ? -1 : Lv[j + k]);

    return L_i < L_j;
}

int main()
{
    int A[MAX];
    std::string T;
    std::cin >> T;
    n = T.size();
	byte *t;
	t = new byte [(n >> 3) + 1];

    int i;
    for(i = 0; i < n; i++){ A[i] = i; }
    for(i = 0; i < n; i++){ Lv[i] = T[i]; }
    std::sort(A, A + n, cmp_Lv);

	for(i = 1; i < n; i++){
		t[i >> 3] = (Lv[A[i]] != Lv[A[i - 1]] ? t[i >> 3] | mask[i & 7] : t[i >> 3] & ~mask[i & 7]);
	}

    Lv[A[0]] = 0;
    for(i = 1; i < n; i++){
        Lv[A[i]] = Lv[A[i - 1]] + !!(mask[i & 7] & t[i >> 3]);
    }

    k = 1;
    while(1){
        if(k > n) break;

        std::sort(A, A + n, cmp);

		for(i = 1; i < n; i++){
			t[i >> 3] = (cmp(A[i - 1], A[i]) ? t[i >> 3] | mask[i & 7] : t[i >> 3] & ~mask[i & 7]);
		}
		Lv[A[0]] = 0;
		for(i = 1; i < n; i++){
			Lv[A[i]] = Lv[A[i - 1]] + !!(mask[i & 7] & t[i >> 3]);
		}

        if(Lv[A[n - 1]] == n - 1) break;
        k <<= 1;
    };

    //std::string P;
	char p[1000];
    int q, left, right, mid, crit;
    bool exist;
    scanf("%d", &q);

    A[n] = n;

    while(q){
        //std::cin >> P;
		scanf("%s", p);
		std::string P = std::string(p);
        left = 0, right = n, exist = false;
        while(left < right){

            if(n < P.size()){ exist = false; break; }

            mid = (left + right) / 2;
            crit = T.compare(A[mid], P.size(), P);

            if(crit > 0){ right = mid; }
            else if(crit < 0){ left = mid + 1; }
            else{ exist = true; break; }
        };
        if(T.compare(A[right], P.size(), P) == 0) exist = true;
        if(exist){ printf("1\n"); }else{ printf("0\n"); }
        q--;
    }
    return 0;
}

Measured memory_bytes: 10168
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

mon = 0
for i in range(n):
    if a[i] <= b[i]:
        mon += a[i]
        b[i] = b[i] - a[i]
        a[i] = 0
        if a[i+1] <= b[i]:
            mon += a[i+1]
            b[i] = b[i] - a[i+1]
            a[i+1] = 0
        else:
            mon += b[i]
            a[i+1] -= b[i]
            b[i] = 0
    else:
        mon += b[i]
        a[i] -= b[i]
        b[i] = 0

print(mon)

Measured memory_bytes: 18752
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<double> A(N);
    rep(i, N) cin >> A.at(i);

    double revSum = 0;
    rep(i, N) {
        revSum += 1 / A.at(i);
    }
    double ans = 1 / revSum;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


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

const int mod=1000000007;
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
int main(){
    int n,m;
    cin>>m>>n;
    ll ans=mod_pow(m,n,mod);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
n,m = map(int,input().split())

dp = [float("inf")]*(1<<n)
dp[0] = 0
for _ in [0]*m:
    a,b = map(int,input().split())
    sc = 0
    for e in map(int,input().split()):
        sc += 1<<(e-1)
    
    for i in range(1<<n):
        dp[i|sc] = min(dp[i|sc],dp[i]+a)


if dp[-1] == float("inf"):
    print(-1)
else:
    print(dp[-1])

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

int main(void){
    int N, Abuf;
    vector<int> A;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
    }
    sort(A.begin(), A.end(), std::greater<int>());
    if(N%2==0){
        cout << 2LL*accumulate(A.begin(), A.begin()+N/2, 0LL)-A[0] << endl;
    }else{
        cout << 2LL*accumulate(A.begin(), A.begin()+N/2+1, 0LL)-A[0]-A[N/2] << endl;
    }
    return 0;
}

Measured memory_bytes: 4316
import sys


try:
    sys.stdin = open(sys.path[0] + '\\input.txt', 'r')
    sys.stdout = open(sys.path[0] + '\\output.txt', 'w')
except FileNotFoundError:
    pass


n, m = list(map(int, input().split()))
arr = list(map(int, input().split()))

sm = n - sum(arr)

print(sm if sm >= 0 else -1)


Measured memory_bytes: 10056
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

namespace geo
{
  const double EPS = 1e-10;

  class Point
  {
  public:
    double x, y;
    
    Point(double _x = 0.0, double _y = 0.0)
      :x(_x), y(_y) {}
    
    inline double abs() const
    {
      return sqrt(x*x + y*y);
    }
    
    // 内積
    inline double dot(const Point& p) const
    {
      return (x*p.x + y*p.y);
    }
    
    // 外積
    inline double cross(const Point& p) const
    {
      return (x*p.y - y*p.x);
    }
    
    // 直交
    /*
      AOJ0058: EPS -> 0.0 
    */
    inline bool orthogonal(const Point& p) const
    {
      if (dot(p) < EPS)
	return true;
      return false;
    }
    
    // 平行
    inline bool parallel(const Point& p) const
    {
      if (cross(p) < EPS)
	return true;
      return false;
    }
    
    Point operator +(const Point& p) const
    {
      return Point(x+p.x, y-p.y);
    }
    
    Point operator -(const Point& p) const
    {
      return Point(x-p.x, y-p.y);
    }
    
    Point operator =(const Point& p)
    {
      x = p.x;
      y = p.y;
    }
    
    bool operator ==(const Point& p) const
    {
      if ((*this - p).abs() < EPS)
	return true;
      return false;
    }
    
    bool operator <(const Point& p) const
    {
      if (std::abs(x-p.x) < EPS)
	return y < p.y;
      return x < p.x;
    }
  };

  /*
    凸多角形の面積（要反時計回り or 時計回り）
    凹多角形にも適用可能であるが，自己交差などを含む場合は除く
    Verifyed:
  */
  double convex_area(const vector<Point>& ps)
  {
    double area = 0.0;
    for (unsigned int i = 0; i < ps.size(); ++i)
      area += ps[i].cross(ps[(i+1)%ps.size()]);
    return std::abs(area/2.0);
  }

  /*
    凸包:graham scan(p.234), O(nlogn)
    Verified:AOJ0068
  */
  vector<Point> convex_hull_gs(vector<Point>& ps)
  {
    sort(ps.begin(), ps.end());
    int k = 0, n = static_cast<int>(ps.size());
    vector<Point> qs(n * 2);
    for (int i = 0; i < n; ++i) {
      while (k > 1 && (qs[k-1] - qs[k-2]).cross(ps[i] - qs[k-1]) < EPS)
	--k;
      qs[k++] = ps[i];
    }

    for (int i = n-2, t = k; i >= 0; --i) {
      while (k > t && (qs[k-1] - qs[k-2]).cross(ps[i] - qs[k-1]) < EPS)
	--k;
      qs[k++] = ps[i];
    }

    qs.resize(k-1);
    return qs;
  }
}

int main()
{
  double x, y;
  vector<geo::Point> ps;
  while (~scanf("%lf,%lf", &x, &y))
    ps.push_back(geo::Point(x, y));  
  printf("%.6f\n", geo::convex_area(ps));
  return 0;
}

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

const int MAX = 1e6 + 6;
ll fact[MAX] , invfact[MAX];

//a^b % MOD
ll bigMod(ll a , ll b) {

    ll p ;
    if( b == 0) return 1;
    p = ( bigMod(a , b/2) % MOD );
    p = ( p * p) % MOD;
    if( b & 1 ) p = ( p * a) % MOD;
    return p;
}


// (1/a) % MOD == (a ^ MOD-2 )%MOD
ll modInverse( ll x ) {
    return bigMod(x, MOD-2);
}


//nCr % MOD
ll ncr(int n , int r) {
    if( n  < r || n < 0 || r < 0) return 0;
    ll up = fact[n];
    ll down = (invfact[r] * invfact[n-r])%MOD;
    return ( up * down )%MOD;
}

void pre() {
    
    fact[0] =1 ;
    for(int i =1 ; i <  MAX ; i++) fact[i] = ( fact[i-1] * i )%MOD;
    
    invfact[MAX-1] = modInverse(fact[MAX-1]);
    for(int i = MAX-2 ; i >= 0 ; i--) invfact[i] = (invfact[i+1] * (i+1))%MOD;
}   
int main() {

    pre();
    ll s;
    cin>>s;
    ll ans = 0;

    for(int i = 1 ; i<=s ; i++ ) {
        ll tgt = s - i* 3;
        if(tgt < 0) break;


        ll tmp = ncr(tgt + i - 1 , i-1);

        // cout<<i<<" "<<tgt<<" "<<tmp<<'\n';

        ans = (ans + tmp)%MOD;

    }

    cout<<ans<<'\n';

    return 0;
}

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

typedef long long ll;
#define INF INT_MAX


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

    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0 ; i < N ; i++)
        cin >> v[i];

    int mj = v[0];
    int ans = 0;
    for(int i = 0 ; i < N ; i++){
        if(v[i] > mj)continue;
        ans++;
        mj = min(mj,v[i]);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#define rush() int T;cin>>T;while(T--)
#define go(a) while(cin>>a)
#define ms(a,b) memset(a,b,sizeof a)
#define E 1e-8
using namespace std;
typedef long long ll;
const int N=1e5+5;

    int n,m,t;
    int fa[N];
    int i,j,k;
struct point
{
    int x,y,id;
}p[N];
struct Edge
{
    int u,v,valu;
    bool const operator<(const Edge &b)
    const{
        return valu<b.valu;
    }
}edge[N];
int Find(int son)
{
    return son==fa[son] ? son : fa[son]=Find(fa[son]);
}
bool Union(int x,int y)
{
    x=Find(x),y=Find(y);
    if(x==y) return 1;
    else{
        fa[y]=x;
        return 0;
    }
}
bool cmpx(point &a,point &b){
    return a.x<b.x;
}
bool cmpy(point &a,point &b){
    return a.y<b.y;
}
int main()
{
    cin.tie(0);istream::sync_with_stdio(false);
    while(cin>>n){
        for(i=1;i<=n;i++) fa[i]=i;

        for(i=1;i<=n;i++){
            cin>>p[i].x>>p[i].y;
            p[i].id=i;
        }

        int num=0;
        sort(p+1,p+1+n,cmpx);
        for(i=1;i<n;i++){
            edge[++num].u=p[i].id;
            edge[num].v=p[i+1].id;
            edge[num].valu=min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y));
        }
        sort(p+1,p+1+n,cmpy);
        for(i=1;i<n;i++){
            edge[++num].u=p[i].id;
            edge[num].v=p[i+1].id;
            edge[num].valu=min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y));
        }

        stable_sort(edge+1,edge+1+num);
        int ans=0,cnt=0;
        for(i=1;i<=num;i++){
            if(0==Union(edge[i].u,edge[i].v)){
                ans+=edge[i].valu;
                cnt++;
            }
            if(cnt==n-1) break;
        }
        cout<<ans<<endl;
    }
}

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

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

    ll a[n];
    map<ll, int> l;
    map<ll, int> r;
    ll max = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ll k = (i + 1) - a[i];
        auto itr = l.find(k);
        if(itr == l.end()){
            l[k] = 1;
        }else{
            l[k]++;
        }
    }

    ll ans = 0;

    for(int i = 0; i < n; i++){
        ll k = (i + 1)+ a[i];
        auto itr = l.find(k);
        if(itr != l.end()){
            ans += itr->second;
        }
    }

    cout << ans << endl;
}

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

int main()
{
    //データ定義
    int height;
    int width;
    
    //入力されたデータを取得
    cin >> height >> width;

    //
    while(height != 0 || width != 0){
        for(int i = 0; i < height; i++){
            for(int j = 0; j < width; j++){
                cout << "#";
            }
            cout << endl;
        }
        cin >> height >> width;
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
n = int(input())
sum = 1
noFlag = False
zeroFlag = False
a = list(map(int, input().split()))
for i in range(n):
  if a[i] == 0:
    zeroFlag = True
if zeroFlag == False:
  for i in range(n):
    sum = sum*a[i]
    if sum > 10 ** 18:
      noFlag = True
      break  
  if noFlag == True and zeroFlag == False:
    print(-1)
  else:
    print(sum)
else:
  print(0)


Measured memory_bytes: 21484
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    int64_t kisuupattern = 1;
    int64_t zenpattern = 1;
    for (int64_t i=0; i<N; i++) {
        zenpattern *= 3;
        int64_t num;
        cin >> num;
        if (num % 2 == 0) {
            kisuupattern *= 2;
        } else {
            kisuupattern *= 1;
        }
    }

    cout << zenpattern - kisuupattern << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s , t;
  cin>>s>>t;
  int a, b;
  cin>>a>>b;
  string tmp;
  cin>>tmp;
  if(tmp==s)
    cout<<a-1<<" "<<b;
  else
  {
    cout<<a<<" "<<b-1;
  }
  
  return 0;
}

Measured memory_bytes: 892
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

N %= 1000
if N==0:
    print(0)
else:
    print(1000-N)

Measured memory_bytes: 61888
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

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

	string s;
	cin >> s;
	int n = s.size();

	auto ok = [&](int i, int j){
		while(i <= j && s[i] == s[j])
			i++, j--;
		return i > j;
	};

	int lf = n / 2 - 1;
	cout << (ok(0, n - 1) && ok(0, lf) && ok(lf + 2, n - 1) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef pair<lint, pii> plp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 998244353;
const lint INF = mod*mod;
const int MAX = 100010;

int ctoi(char c){
    if(c=='R') return 0;
    if(c=='G') return 1;
    else return 2;
}

int other(int x, int y){
    if(x==0) return y==1 ? 2 : 1;
    if(x==1) return y==2 ? 0 : 2;
    else return y==0 ? 1 : 0;
}

int main(){
    int n;
    string s;
    cin>>n>>s;
    lint ans=1;
    lint a[3], b[3];
    rep(i, 3) a[i]=b[i]=0;
    rep(i, 3*n){
        int idx=ctoi(s[i]);
        if(b[idx]){
            (ans*=b[idx])%=mod;
            --b[idx];
        }
        else{
            bool flag=false;
            rep(j, 3)if(j!=idx && a[j]){
                flag=true;
                (ans*=a[j])%=mod;
                ++b[other(idx, j)]; --a[j];
            }
            if(!flag) ++a[idx];
        }
    }
    for(lint i=1; i<=n; ++i) (ans*=i)%=mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree < int,  null_type,  less<int>,  rb_tree_tag,  tree_order_statistics_node_update > ordered_set;
typedef long long ll;
#define pb push_back
#define pi (acos(-1))
#define ull  unsigned long long
#define ld long double
#define all(v) v.begin(), v.end()
///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);
ll LCM(ll a, ll b)
{
    ll g = __gcd(a,b);
    return (a/g)*b ;
}
string numtostr(ll n)
{
    ostringstream str1 ;
    str1 << n ;
    return str1.str();
}
ll strtonum(string s)
{
    ll x ;
    stringstream str1(s);
    str1 >> x ;
    return x ;
}
#define mx 1000000007
int n,i;
ll s=0,sum=0,b=0;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
   ll a[n];
   for(i=0;i<n;++i)
    cin>>a[i];
   for(i=1;i<n;++i)
    s+=a[i];
    for(i=0;i<n;++i)
    {
        if(i==0)
          sum=((sum%mx)+((s%mx)*(a[i]%mx)))%mx;
          else
          {
              s-=a[i];
              sum=((sum%mx)+((s%mx)*(a[i]%mx)))%mx;
          }
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 5164
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

ans = a[0] > x ? a[0] - x : 0
a[0] -= ans

1.upto(n - 1) do |i|
    s = a[i-1] + a[i]
    if s > x
        a[i] -= s - x
        ans += s - x
    end
end

puts ans

Measured memory_bytes: 8580
n = int(input())
sp = []
for i in range(n):
    sp.append(input().split())
    sp[i].append(i)
    sp[i][1] = int(sp[i][1])
sp = sorted(sp, key = lambda x : x[1], reverse = True)
sp = sorted(sp, key = lambda x : x[0])
for i in range(n):
    print(sp[i][2]+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  while(n){
    if(n%10==7){
      cout<<"Yes"<<endl;
      return 0;
    }
    n/=10;
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
int p[200];
vector<int>ans;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>p[i];
	int hd=0;
	while(ans.size()<=1e5)
	{
		bool issorted=true;
		for(int i=0;i<N;i++)if(p[(hd+i)%N]!=i)
		{
			issorted=false;
			break;
		}
		if(issorted)break;
		if(p[hd]!=0&&p[hd]<p[(hd+N-1)%N])
		{
			ans.push_back(N-1);
			swap(p[hd],p[(hd+N-1)%N]);
		}
		ans.push_back(1);
		hd=(hd+1)%N;
	}
	if(ans.size()>1e5)return 1;
	cout<<ans.size()<<endl;
	for(int v:ans)cout<<v<<endl;
}


Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int w = in.nextInt();

			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < s.length; i++) {
				if (i % w == 0) {
					sb.append(s[i]);
				}
			}

			out.println(sb.toString());

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
#include<iostream>
using namespace std;
string s;
bool pd(int a,int b)
{
	for(int i=a;i<=(a+b)/2;++i)
		if(s[i]!=s[b-i+a])
			return false;
	return true;
}
int main()
{
	cin>>s;int l=s.length();
	if(pd(0,l-1)&&pd(0,(l-1)/2-1)&&pd((l+3)/2-1,l-1))	cout<<"Yes";
	else											cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)      for (int i=0; i<(int)(n); i++)
#define pb push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod=1e9+7;
const int inf=1e9+5;
const ll  INF=(ll)1e18+5;
const int N=2e5+5;    /// check

int main()
{
#ifdef LOCAL
freopen("input.in","r",stdin);
#endif
    IOS;
    int l,r;
    cin>>l>>r;
    if(r/2019 != (l-1)/2019 )cout<<"0\n";
    else{
        //r=r%2019;
        //l=l%2019;
        ll ans=inf;
        rep(i,l,r+1)
          for(int j=i+1;j<=r;++j)
          {
              ans=min(ans,((ll)i*j)%2019 );
          }
          cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
public class AtCoder
{
    public static void Main()
    {
        var input = System.Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
 
        string answer = (a * b % 2 == 0) ? "Even" : "Odd";
 
        System.Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<P> candy(N);
    for(int i=0; i<N; ++i) {
        cin >> candy[i].first >> candy[i].second;
    }
    sort(begin(candy), end(candy));

    if(N == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    int res = 1001001001;
    for(int i=0; i<N; ++i) {
        for(int j=i+1; j<N; ++j) {
            int p = candy[j].first - candy[i].first;
            int q = candy[j].second - candy[i].second;
            int tmpres = 0;

            vector<bool> used(N, false);
            for(int k=0; k<N; ++k) {
                if(used[k]) continue;
                used[k] = true;
                ++tmpres;
                int x = candy[k].first;
                int y = candy[k].second;
                while(true) {
                    auto b = upper_bound(begin(candy), end(candy), P(x + p, y + q));
                    auto a = lower_bound(begin(candy), end(candy), P(x + p, y + q));
                    if((int)(b - a) == 1) {
                        x += p;
                        y += q;
                        used[(int)(a - begin(candy))] = true;
                    } else {
                        break;
                    }
                }
                P cur = candy[k];
                while(true) {
                    auto b = upper_bound(begin(candy), end(candy), P(x -p, y-q));
                    auto a = lower_bound(begin(candy), end(candy), P(x -p, y-q));
                    if((int)(b - a) == 1) {
                        x -= p;
                        y -= q;
                        used[(int)(a - begin(candy))] = true;
                    } else {
                        break;
                    }
                }
            }
            res = min(res, tmpres);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, ans;
  ans = 1;
  cin >> N;
  string x;
  string st[N+10];
  for (int i = 0; i < N; ++i) {
    cin >> x;
    st[i] = x;
  }
  sort(st, st+N);
  for (int i = 1; i < N; ++i) {
    if (st[i] != st[i-1]) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

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

  for (int i = 0; i < 3; i++) {
    if (n[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.stream.Stream;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String[] b = a.split(" ");
        int[] c = Stream.of(b).mapToInt(Integer::parseInt).toArray();
        String d;
        if(c[0]<=c[1]){
            if(c[0]<=c[2]){
                if(c[1]>=c[2]){
                    d="Yes";
                }
                else{
                    d="No";
                }
            }
            else{
                d="No";
            }
        }
        else if(c[0]>=c[1]){
            if(c[0]>=c[2]){
                if(c[1]<=c[2]){
                    d="Yes";
                }
                else{
                    d="No";
                }
            }
            else{
                d="No";
            }
        }else{
            d="No";
        }
        System.out.println(d);
    }
}


Measured memory_bytes: 29268