akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

#define SIZE 100000
int prime[SIZE];

int sosu ( int n ) {
	int i , lim = (int)(sqrt(n));
	for ( i = 2; i <= lim; i++ ) {
		if ( n % i == 0 ) return 0;
	}
	return 1;
}

void tmp(void) {
	int i;
	prime[0] = prime[1] = 0;
	for ( i = 2; i < SIZE; i++ ) {
		prime[i] = sosu(i);
	}
	return;
}

int main (void) {
	int n , i , sosu1 , sosu2;
	tmp();
	
	while ( scanf("%d",&n) != EOF ) {
		for ( i = n - 1; ; i-- ) {
			if ( prime[i] ) {
				sosu1 = i;
				break;
			}
		}
		for ( i = n + 1; ; i++ ) {
			if ( prime[i] ) {
				sosu2 = i;
				break;
			}
		}
		printf("%d %d\n",sosu1,sosu2);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define Int const int &

int main(void) {
	int n;
	cin>>n;
	if (n%10==9 || n/10==9) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_C
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a, b;
  string op;
  while(cin >> a >> op >>b){
    if(op == "?"){
      break;
    }
    else{
      if(op == "+") cout << a+b << endl;
      if(op == "-") cout << a-b << endl;
      if(op == "*") cout << a*b << endl;
      if(op == "/") cout << a/b << endl;
    }
  }
}

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

int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  string s;
  cin >> s;

  int cnt = 0;
  string ret = "Yes";
  for(int i = b;i <= d;i++){
    if(s[i] == '#')cnt++;
    else cnt = 0;
    if(cnt >= 2){
      ret = "No";
      break;
    }
  }
  bool ok = false;
  int dcnt = 0;
  cnt = 0;
  for(int i = a;i < c;i++){
    if(s[i] == '#'){
      cnt++;
      dcnt = 0;
    }else{
      dcnt++;
      cnt = 0;
    }
    if(cnt >= 2){
      ret = "No";
      break;
    }
    if(dcnt >= 3 && i > b && i <= d+1){
      ok = true;
    }
  }
  if(a < b && c > d){
    if(!ok)ret = "No";
  }
  cout << ret << endl;
}

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

int digit = 0,kekka = 0,l;
int n;
char cand[] = {'3','5','7'};
void rec(int i,string now){
     if(i == l){
       int num = 0;
       for(int k = 0;k < now.size();k++){
         num = num*10 + (now.at(k) - '0');
       }
       if(num <= n && now.find("3") != string::npos && now.find("5") != string::npos && now.find("7") != string::npos){
         kekka++;
         return;
       }
       else{
         return;
       }
     }

     for(int j = 0; j < 3; j++){
       string c = now + cand[j];
       rec(i+1,c);
     }
}

int main(){
  cin >> n;
  int c = n;
  while(c > 0){
    c /= 10;
    digit++;
  }
  int result = 0;
  for(l = 3;l <= digit;l++){
    kekka = 0;
    rec(0,"");
    result += kekka;
  }
  cout << result << endl;
}

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

using namespace std;
const int maxn = 2e5+10;

int n, k;
int niz[maxn];
bool bio[maxn];
set<int> s;

int main() {
    memset(bio, false, sizeof bio);
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", niz+i);

    if (k == 1) {printf("1\n"); return 0;}

    int sol = n - k + 1;
    for (int i = 1; i < k; i++)
        s.insert(niz[i]);

    for (int i = k; i < n; i++) {
        if (niz[i] > *s.rbegin() && niz[i - k] < *s.begin()) sol--, bio[i] = true;
        s.erase(niz[i - k + 1]);
        s.insert(niz[i]);
    }

    int tren = 0;
    int kol = 0;
    for (int i = 1; i < n; i++) {
        if (niz[i] > niz[i - 1]) tren++;
        else tren = 0;

        if (tren >= k - 1 && !bio[i]) kol++;
    }
    sol -= max(0, kol - 1);
    printf("%d", sol);
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,taro=0,hana=0;
    cin>>n;
    for (int i = 0; i < n; i++){
        string s1,s2;
        cin>>s1>>s2;
        if(s1>s2)taro+=3;
        else if(s1==s2){
            taro+=1;
            hana+=1;
        }else hana+=3;
    }
    cout<<taro<<' '<<hana<<'\n';
}


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

int main(){
    int n; cin>>n;
    int a[200010];
    for(int i=1;i<=n;i++)cin>>a[i];
    if(n&1){
        for(int i=n;i>=1;i-=2)cout<<a[i]<<" ";
        for(int i=2;i<=n;i+=2)cout<<a[i]<<" ";
        cout<<endl;
    }else{
        for(int i=n;i>=1;i-=2)cout<<a[i]<<" ";
        for(int i=1;i<=n;i+=2)cout<<a[i]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 2944
n = int(input())
s = list(input())
ans = 0
cnt_w = s.count("W")
j = 1
for i in range(n - cnt_w):
    if s[i] == "W":
        while s[-j] == "W":
            j += 1
        s[i] = "R"
        s[-j] = "W"
        ans += 1


print(ans)        

Measured memory_bytes: 10756
#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;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	vll a(n);
	for(ll& x : a)cin >> x;
	
	vll pre(n, 0);
	for(int i=1 ; i<n ; ++i){
		pre[i] = max(pre[i-1], a[i-1]);
	}
	
	ll sum=0;
	for(int i=n-1 ; i>0 ; --i){
		sum += max(0LL, pre[i]-a[i]);
	}
	
	cout << sum;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    int m=INT_MAX;
    sort(a+1,a+n+1);
    for(int i=1;i<=n-k+1;i++)
    	m=min(m,a[i+k-1]-a[i]);
    cout<<m;
}

Measured memory_bytes: 1024
from collections import defaultdict
n, k, q = [int(i) for i in input().split()]
a = defaultdict(int)
allc = 0
for _ in range(q):
  a[int(input())] += 1
  allc += 1
for i in range(1, n+1):
  if k - (allc - a[i]) > 0:
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 16176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpConsoleApp {

    class Program {

        static int Main() {

            var input = Console.ReadLine().Split(' ').ToList();
            var N = int.Parse(input[0]) - 1;
            var M = int.Parse(input[1]) - 1;
            Console.WriteLine(N * M);
            return 0;
        }
    }
}

Measured memory_bytes: 11220
#include<stdio.h>

void marge(int *,int,int,int);
void margesort(int *,int,int);

int cnt=0;

int main()
{
  int n,i;

  scanf("%d",&n);

  int a[n];

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

  
  for(i = 0 ; i < n ; i++)
    {
      printf("%d",a[i]);
      if(i != n-1 ) printf(" ");
    }
  printf("\n%d\n",cnt);
  
  return 0;
}

void marge(int *a,int left,int mid,int right)
{
  int n1 = mid -left;
  int n2 = right - mid;
  int k;
  int i;

  int L[n1],R[n2];

  for(i = 0 ; i < n1 ; i++)
    {
      L[i] = a[left + i];
    }
   for(i = 0 ; i < n2 ; i++)
    {
      R[i] = a[mid + i];
    }

   L[n1] = 1000000001;
   R[n2] = 1000000001;

   int j = 0;
   i = 0;

   for(k = left ; k < right ; k++)
     {
       cnt += 1;
       if(L[i] <= R[j])
	 {
	   a[k] = L[i];
	   i += 1;
	 }
       else
	 {
	   a[k] = R[j];
	   j += 1;
	 } 
     }
}

void margesort(int *a,int left,int right)
{
  if(left+1 < right)
    {
      int mid = (left + right) / 2;
      margesort(&a[0],left,mid);
      margesort(&a[0],mid,right);
      marge(&a[0],left,mid,right);
    }

}



Measured memory_bytes: 5616
#include<iostream>
using namespace std;
int main(){
    string a;
    string s1,s2;
    cin >> a;
    while(1){
        s1.push_back(a[0]);
        a.erase(a.begin());
        if(a.size() == 0)break;
        s2.push_back(a[0]);
        a.erase(a.begin());
        if(a.size() == 0)break;
    }
    //cout <<s1 << " " <<s2 <<endl;
    bool q = true;
    for(int i = 0;i < s1.size();i++){
        if(s1[i] == 'R' || s1[i] == 'U' || s1[i] == 'D'){

        }
        else{
            q = false;
        }
    }
    for(int i = 0;i < s2.size();i++){
        if(s2[i] == 'L' || s2[i] == 'U' || s2[i] == 'D'){

        }
        else{
            q = false;
        }
    }
    if(q == false)cout << "No" <<endl;
    else cout << "Yes" <<endl;
    return 0;
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int n,m,x,c,q,a[101];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin >>n>>m>>x;
	for(int i=0;i<m;i++){
		cin>>a[i];

		if(a[i]>x&&a[i]!=n)c++;
		else if(a[i]<x)q++;
	}
	cout<<min(c,q)<<"\n";

	return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N;
  cin >> N;
  vector<ll>A(88);
  A[0] = 2; A[1] = 1;
  rep(i,86){
    A[i+2] = A[i+1] + A[i];
  }
  cout << A[N];
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    priority_queue<double> pq;

    rep(i, n) {
        double tmp;
        cin >> tmp;
        pq.push(-tmp);
    }

    while (pq.size() > 1) {
        double a, b;
        a = pq.top(); pq.pop();
        b = pq.top(); pq.pop();
        pq.push((a + b) / 2.0);
    }

    cout << Decimal << -pq.top() << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;

signed main(){
    int n, k;
    cin >> n >> k;
    int c = 1;
    while(n/k > 0) {
        n /= k;
        c++;
    }
    cout << c << endl;
    
}

Measured memory_bytes: 256
if __name__ == "__main__":
    N = int(input())
    tasks = []
    for _ in range(N):
        a, b = map(int, input().split())
        tasks.append((b, a))
    tasks.sort()
    t = 0
    for b, a in tasks:
        if t + a > b:
            break
        t += a
    else:
        print("Yes")
        exit(0)
    print("No")


Measured memory_bytes: 35128
//c
#include <stdio.h>
int main()
{
	int h1, m1, h2, m2, k;
	
	scanf ("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	int waktu = (h2-h1)*60 + m2-m1 - k;
	
	printf ("%d", waktu);
	
	
	return 0;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
map<int, int> mp;
map<string, int> q;
int main()
{
    int n;
    vector<pair<string, int>> v;
    cin >> n;
    int p[110];
    
    REP(i, n)
    {
        string x;
        int y;
        cin >> x >> y;
        v.push_back(make_pair(x, y));
        mp[y] = i;

    }
    sort(v.begin(), v.end());
    int i = 0;
    bool flag = true;
    int j = 0;
    //cerr << mp[35] << endl;
    while (i < n)
    {
        //cerr << i << endl;
        if (v[i].first == v[i + 1].first)
        {
            flag = false;
            i++;
            j++;
           // cerr << i << " " << j << endl;
            continue;
        }
        else if(!flag){
            for (int k = 0; k <=j; k++)
            {
                cout << mp[v[i - k].second]+1 << endl;
            }
            flag = true;
            j = 0;
            i++;
            continue;
        }
         cout << mp[v[i].second]+1<<endl;
        i++;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int N, p[111], res;

// 素因数分解 O(√N)
void pf(ll n) {
	for (ll i=2; i*i<=n; i++) while (n%i==0) n /= i, p[i]++;
	if (n!=1) p[n]++;
}

signed main() {
	cin >> N;
	reps(i,2,N+1) pf(i);
	rep(i,111) rep(j,111) reps(k,j+1,111) if (i!=j && i!=k && p[i]>=2 && p[j]>=4 && p[k]>=4) res++;
	rep(i,111) rep(j,111) if (i!=j) {
		if (p[i]>=4 && p[j]>=14) res++;
		if (p[i]>=2 && p[j]>=24) res++;
	}
	rep(i,111) if (p[i]>=74) res++;
	cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, M;
    //int[] a, b;
    bool[,] G;
    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        G = new bool[N, N];
        for (int i = 0; i < M;++i){
            var a = io.Int-1;
            var b = io.Int-1;
            G[a, b] = G[b, a] = true;
        }
        //cal
        bool[] visited = new bool[N];
        visited[0] = true;
        int ans = dfs(visited, 0);
        //res
        Console.WriteLine(ans);
    }
    int dfs(bool[] vis,int cur){
        if (vis.All(f => f)) return 1;
        int ret = 0;
        for (int i = 0; i < N;++i){
            if(G[cur,i]&&!vis[i]){
                vis[i] = true;
                ret += dfs(vis, i);
                vis[i] = false;
            }
        }
        return ret;
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13268
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int a[] = new int[n];
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        if (sum < h) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

        sc.close();
    }
}


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

using namespace std;

char c[10][10];
int dx[3]={-1,0,1},dy[3]={-1,0,1};

int solve(int y,int x,char now){

    int res=0;

    if(c[y][x]=='x' || c[y][x]=='o')return res;

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){

            if(i==1 && j==1)j++;

            int T=0,X=x,Y=y;

            while(1){
                int nx=X+dx[j],ny=Y+dy[i];

                if(c[ny][nx]=='.')break;

                else if(c[ny][nx]==now){
                    
                    res+=T;
                    break;

                }

                else{

                    T++;

                    X=nx;Y=ny;
                }

            }
        }
    }

    return res;

}

void hanten(int y,int x,char now){

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(i==1 && j==1)j++;

            int T=0,X=x,Y=y;

            while(1){
                int nx=X+dx[j],ny=Y+dy[i];

                if(c[ny][nx]=='.')break;
                
                else if(c[ny][nx]==now){
                    
                    for(int k=0;k<T;k++){

                        c[Y][X]=now;
                        
                        Y-=dy[i];X-=dx[j];

                    }

                    break;

                }

                else{

                    T++;

                    X=nx;Y=ny;

                }
            }
        }
    }
}

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

    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++)cin>>c[i][j];
    }
    for(int i=0;i<10;i++){
        c[i][0]='.';c[i][9]='.';c[0][i]='.';c[9][i]='.';
    }

    bool t=true;//trueなら巴マミのターン

    while(1){

        bool fi=true;//終了判定

        for(int i=1;i<=8;i++){
            for(int j=1;j<=8;j++){
                if(solve(i,j,'o')!=0 || solve(i,j,'x')!=0)fi=false;
            }
        }

        if(fi){
            for(int i=1;i<=8;i++){
                for(int j=1;j<=8;j++){
                    cout<<c[i][j];
                }
                cout<<endl;
            }
            break;
        }

        int x,y,MAX=0;//クッキーを置く位置

        if(t){
            t=false;
            for(int i=1;i<=8;i++){
                for(int j=1;j<=8;j++){
                    if(c[i][j]=='.'){
                        int a=solve(i,j,'o');
                        if(MAX<a){
                            x=j;y=i;MAX=a;
                        }
                    }
                }
            }

            if(MAX!=0){

                c[y][x]='o';

                hanten(y,x,'o');

            }
        }
        else{
            t=true;
            for(int i=8;i>0;i--){
                for(int j=8;j>0;j--){
                    if(c[i][j]=='.'){
                        int a=solve(i,j,'x');
                        if(MAX<a){
                            x=j;y=i;MAX=a;
                        }
                    }
                }
            }

            if(MAX!=0){

                c[y][x]='x';

                hanten(y,x,'x');
            }
        }

    }

}


Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#define Rep(i,n) for(int i = 0;i < (n);i++)	
typedef long long ll;

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }




int main() {
	ll x;
	int a, b;
	std::cin >> x;
	std::vector<ll>gojou;
	std::vector<int>ichijou;
	for (int i = -1000; i <= 1000; i++) {
		gojou.emplace_back(pow(i, 5));
		ichijou.emplace_back(i);
	}
	Rep(i, 2001) {
		Rep(j, 2001) {
			if (x + gojou[i] == gojou[j]) {
				a = ichijou[j];
				b = ichijou[i];
			}
		}
	}
	std::cout << a <<" "<<b << std::endl;
	
	return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

int main(){
    ll n,st;
    cin >> n >> st;
    ll x[n];
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    vector<ll> v;
    v.pb(abs(st-x[0]));
    for(ll i=1;i<n;i++){
        v.pb(abs(x[i]-x[i-1]));
        v.pb(abs(st-x[i]));
    }
    if(n==1){
        cout << abs(x[0]-st);
        return 0;
    }
    ll ans = 0;
    for(ll i=0;i<v.size();i++)
        ans = __gcd(ans,v[i]);
    cout << ans;
}

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

using namespace std;

int main(void){

    string str;
    cin >> str;

    bool flag = true;

    if(str.length() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0;i < str.length();i++){
        if(i % 2 == 0){
            if(str[i] != 'h') flag = false;
        }else{
            if(str[i] != 'i') flag = false;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int N;
std::vector<ll> A, a;
std::vector<std::vector<ll>> dp;

ll dfs(ll l, ll r) {
  int k = N - (r-l) - 1;
  if ( k >= N || r - l < 0 ) return 0;
  if ( dp[l][r] != 0 ) return dp[l][r];
  ll x = a[k];
  return dp[l][r] = std::max(dfs(l+1, r) + A[x] * std::abs(l-x), dfs(l, r-1) + A[x] * std::abs(r-x));
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> N;
  dp.resize(N+1); rep(i,N+1) dp[i].resize(N+1);
  A.resize(N); a.resize(N);
  rep(i,N) std::cin >> A[i]; 
  rep(i,N) a[i] = i;
  std::sort( all(a), [&](ll x, ll y) { return A[x] > A[y]; } ); 
  std::cout << dfs(0, N-1) << std::endl;
  return 0;
}



Measured memory_bytes: 34564
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main(){
    int N;
    ll T;

    cin >> N >> T;

    ll st = 0;
    ll end = T;
    ll total = 0;
    for(int i=0;i<N;i++){
        ll t;
        cin >> t;
        if(t>end){
            total += end-st;
            st = t;
            end = t+T;
        }else{
            end = t+T;
        }
    }

    total += end-st;

    cout << total << endl;

    return 0;
}


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

int main() {
  int i, j ; //for roop 
  int H, W; //array size 
  cin >> H >> W ;
  char array[H][W];
  
  for(i=0; i<H; i++){
   for(j=0; j<W; j++){
    cin >> array[i][j]; 
   }
  }
  
  for(i=0; i<W+2; i++){
    cout << '#';
  }
  cout << endl;
  
  for(i=0; i<H; i++){
    cout <<'#';
    for(j=0; j<W; j++){
     cout << array[i][j]; 
    }
    cout <<'#'<<endl;
  }
  
  for(i=0; i<W+2; i++){
    cout << '#';
  }
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException{
		int a, b, h;

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader in = new BufferedReader(isr);

		a = Integer.parseInt(in.readLine());
		b = Integer.parseInt(in.readLine());
		h = Integer.parseInt(in.readLine());

		System.out.println((a + b) * h / 2);
	}
}


Measured memory_bytes: 8276
A, V = map(int, input().split(' '))
B, W = map(int, input().split(' '))
T = int(input())

d = abs(A - B)
v = abs(V - W)

if d <= v * T:
    if V > W:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


Measured memory_bytes: 9120
#include <iostream>
#define swap(X, Y) { int Z; Z = Y; Y = X; X = Z;}
using namespace std;

int main(void) {
	int a, b, c, temp;
	cin >> a >> b >>c;
	if(a > b) {
		swap(a, b);
	} 
	if(a > c) {
		swap(a, c);	
	}
	if(b > c) {
		swap(b, c);
	}
	cout << a << " "<< b << " " << c << endl;	
	return 0;

}


Measured memory_bytes: 3104
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[5];

	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];

		for (int j = (i - 1); j >= 0; j--)
		{
			if (a[j] < a[j + 1])
			{
				swap(a[j], a[j + 1]);
			}
		}
	}

	cout << a[0] << ' ' << a[1] << ' ' << a[2] << ' ' << a[3] << ' ' << a[4] << endl;
	
	return 0;
}

Measured memory_bytes: 1160
line = int(input())
list = []
for i in range(line):
    list.append(input())
for i in range(4):
    for j in range(13):
        if i == 0:
            mark = "S "
        elif i == 1:
            mark = "H "
        elif i == 2:
            mark = "C "
        else:
            mark = "D "
        if mark + str(j+1) in list:
            mark = mark
        else:
            print(mark + str(j+1))
        
        


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
string x,y;
bool f(int s)
{
	for(int j=0;j<y.size();j++)
	{
		if(x[s]!=y[j])
		return false;
		s=(s+1)%y.size();
	}
	return true;
}
int main()
{
	int tf=0;
	cin>>x>>y;
	for(int i=0;i<x.size();i++)
	{
		if(f(i))
		tf=1;
	}
	if(tf)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h=nxt(),w=nxt();
    vector <string> v(h);
    for(int i=0;i<h;i++)
        cin>>v[i];
    vector <string> v2=v;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            if(v2[i][j]=='.')
            {
                int c=0;
                for(int x=i-1;x<=i+1;x++)
                    for(int y=j-1;y<=j+1;y++)
                        if(x>=0&&x<=h-1&&y>=0&&y<=w-1&&v[x][y]=='#')
                            c++;
                v2[i][j]=48+c;
            }
        }
    for(int i=0;i<h;i++)
        cout<<v2[i]<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = ll(1e9) + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {  // extended Euclidean algorithm, used for
                                       // modular multiplicative inverse
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;  // return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD) {  // return inv(a) mod m, ax+my=gcd(a,m)=1, m is
                                // prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;  // From (possibly) negative x to positive x
}

vector<ll> fact, invfact;
void calc_fact(int n, ll m = MOD) {  // Calculate factorial up to n
    fact.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = invfact[0] = 1;
    REP(i, n) {
        fact[i + 1] = fact[i] * (i + 1) % m;
        invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
    }
}
ll perm(int n, int k, ll m = MOD) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n - k] % m;
}
ll comb(int n, int k, ll m = MOD) {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}

int main() {
    ll n, m;
    cin >> n >> m;
    unordered_map<ll, int> ma;
    for (ll i = 2; i * i <= m; ++i) {
        while (m % i == 0) {
            ma[i]++;
            m /= i;
        }
    }
    if (m != 1) {
        ma[m]++;
    }
    calc_fact(1000 + 2*n);
    ll ans = 1;
    for (auto elem : ma){
        ll k = elem.second;
        ans = (ans * comb(n + k - 1, k)) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>

using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
#define eps 1.0e-14;

int main(){
    long double A,B;
    cin >> A >> B;
    ll ans = floor( A * B );
    cout << ans << endl;
}


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

int main()
{
	long long n;
	cin>>n;
	cout<<((n*(n+1))/2)-3*(((n/3)*((n/3)+1))/2)-5*(((n/5)*((n/5)+1))/2)+15*(((n/15)*((n/15)+1))/2);
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN=100005;

int N;
set<int> E[MAXN];
map<int,int> cnt[MAXN];
queue<pair<int,int>> Q;

int fa[MAXN];
int Root(int x)
{return fa[x]==0?x:(fa[x]=Root(fa[x]));}

void Link(int u,int v)
{
    E[u].insert(v);
    E[v].insert(u);
    if(u>v)
        swap(u,v);
    cnt[u][v]++;
    if(cnt[u][v]>2)
    {
        puts("NO");
        exit(0);
    }
    if(cnt[u][v]==2)
        Q.emplace(u,v);
}
void Cut(int u,int v)
{
    E[u].erase(v);
    if(u>v)
        swap(u,v);
    cnt[u].erase(v);
}

int main()
{
    scanf("%d",&N);
    for(int i=1;i<=2*N-2;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        Link(u,v);
    }
    for(int i=1;i<N;i++)
    {
        int u,v;
        do
        {
            if(Q.empty())
            {
                puts("NO");
                return 0;
            }
            u=Root(Q.front().first),v=Root(Q.front().second);
            Q.pop();
        }while(u==v);
        if(E[u].size()<E[v].size())
            swap(u,v);
        fa[v]=u;
        Cut(u,v);
        for(auto e:E[v])
        {
            int t=Root(e);
            if(t==u)
                continue;
            Link(t,u);
            Cut(t,v);
        }
    }
    puts("YES");

    return 0;
}


Measured memory_bytes: 38272
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

// 自力で解こうとしたがうまくいかなかったので答えを見た
// O(NQ+N^2)解法

fn main() {
    input! {
        N: usize,
        M: usize,
        Q: usize,
        tmpLRs: [(usize, usize); M],
        tmpPQs: [(usize, usize); Q],
    }

    // 0-origin
    let LRs: Vec<(usize, usize)> = tmpLRs.iter().map(|&(l, r)| (l - 1, r - 1)).collect();
    let PQs: Vec<(usize, usize)> = tmpPQs.iter().map(|&(p, q)| (p - 1, q - 1)).collect();

    // O(10^5)のループの内側でクエリに回答する
    // つまり、クエリへの回答はO(1)でできる必要がある (← 注: これ嘘です。10^7までは食えるので今回はO(NQ)までいけます)
    // ある「領域」に属する個数を高速で求める → 累積和
    // ここで、領域は幅を持っている → 2次元累積和
    // この問題ではオーバーキルな解法らしい
    // なので、いったんN <=500、つまり N^2 < 10^6を利用した解法を使う

    // x[l][r]を区間[l,r]を走る電車の本数とするとき、
    // acc[l][r+1] := sum $ [ x[l][i] for i in 0..r ]
    let mut acc: Vec<Vec<i64>> = vec![vec![0i64; N + 1]; N];

    // まず目印を付けて、後でaccに直す
    let mut mark: Vec<Vec<i64>> = vec![vec![0i64; N]; N];
    for &(l, r) in LRs.iter() {
        mark[l][r] += 1;
    }

    // accに直す
    // 横一列の累積和でO(N)、それをN行重ねるからO(N^2)
    for l in 0..N {
        for r in 0..N {
            acc[l][r + 1] = acc[l][r] + mark[l][r];
        }
    }

    for &(p, q) in PQs.iter() {
        // ループの中はほぼO(1)じゃないと間に合わない (← 注: これ嘘です。10^7までは食えるので今回はO(NQ)までいけます)
        // 区間、O(1)と来れば累積和でしょう

        let mut ans = 0;
        for l in p..=q {
            ans += acc[l][q + 1] - acc[l][l];
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 17640
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  // int y=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
  int m=(s[5]-'0')*10+(s[6]-'0');
  int d=(s[8]-'0')*10+(s[9]-'0');
  if(m<=4&&d<=30)
  cout<<"Heisei"<<endl;
  else
  cout<<"TBD"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k;
    cin>>n>>k;
    vector<long long> v(n);
    for(auto&i:v) cin>>i;
    
    sort(v.begin(),v.end());
    long long ans=0;
    for(int i=0; i<n-k; i++){
        ans+=v[i];
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 1792
N,Q = map(int,input().split())
S = input()
ACs = [0] * N #i文字目までの"AC"の数
number = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        number += 1
    ACs[i+1] = number
for j in range(Q):
    l,r = map(int,input().split())
    print(ACs[r-1]-ACs[l-1])

Measured memory_bytes: 6060
#include <stdio.h>
int main()
{
   int i,j,n,a[1000];
   scanf("%d",&n);
   for(i=0;i<n;i++)
    scanf("%d",&a[i]);
   for(i=n-1;i>n-2;i--)
    printf("%d",a[i]);
   for(i=n-2;i>=0;i--)
    printf(" %d",a[i]);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2128
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

def check(a, b, c):
    if a == b or a == c or b == c:
        return False
    if a + b <= c:
        return False
    if a + c <= b:
        return False
    if b + c <= a:
        return False
    return True

n = ini()
a = inl()
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for t in range(j+1, n):
            if check(a[i], a[j], a[t]):
                ans += 1
print(ans)

Measured memory_bytes: 9240
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val s = Array(m) { 0 }
    val c = Array(m) { 0 }
    for (i in 0 until m) {
        s[i] = sc.nextInt()
        c[i] = sc.nextInt()
    }
    for (i in 0 until 1000) {
        var ok = true
        val str = i.toString()
        if (str.length != n) continue
        for (j in 0 until m) {
            if (str[s[j] - 1].toString() != c[j].toString()) {
                ok = false
                break
            }
        }
        if (ok) {
            println(i)
            return
        }
    }
    println(-1)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,-1,1,1,-1};
int dy[]={0,1,0,-1,-1,-1,1,1};


int main(){
    int n;cin >> n;
    for (int i = 1; i <= n; i++) {
        int ans = 0;
        for (int x = 1; x * x <= i; x++) {
            for (int y = 1; x * x + y * y + x * y <= i; y++) {
                for (int z = 1; x * x + y * y + z * z + x * y + y * z + x * z <= i; z++) {
                    if(x * x + y * y + z * z + x * y + y * z + z * x == i) ans++;
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

class Mint
{
public:
    ll x;
    Mint(ll x = 0) :x((x% mod + mod) % mod) {}
    ll Get() const { return x; }
    Mint operator-() const { return Mint(-x); }
    Mint& operator+=(const Mint a)
    {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    Mint& operator-=(const Mint a)
    {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    Mint& operator*=(const Mint a) { (x *= a.x) %= mod; return *this; }
    Mint operator+(const Mint a) const { return Mint(*this) += a; }
    Mint operator-(const Mint a) const { return Mint(*this) -= a; }
    Mint operator*(const Mint a) const { return Mint(*this) *= a; }
    Mint pow(ll t) const
    {
        if (!t) return 1;
        Mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    Mint inv() const { return pow(mod - 2); }
    Mint& operator/=(const Mint a) { return *this *= a.inv(); }
    Mint operator/(const Mint a) const { return Mint(*this) /= a; }
};

class Sieve
{
private:
    int n;
    vector<int> f, primes;
public:
    Sieve(int n = 1) :n(n), f(n + 1)
    {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool IsPrime(int x) { return f[x] == x; }
    vector<int> PrimeList(int x)
    {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<ll, int>> PrimeFrequency(int x)
    {
        vector<int> fl = PrimeList(x);
        if (fl.size() == 0) return {};
        vector<pair<ll, int>> res(1, pair<ll, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            }
            else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll, int>> PrimeFrequencySelf(ll x)
    {
        vector<pair<ll, int>> res;
        for (int p : primes) {
            int y = 0;
            while (x % p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p, y);
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    Sieve sieve(1e6);
    map<int, int> pf;
    for (int i = 0; i < n; i++) {
        vector<pair<ll, int>> primeFrequency = sieve.PrimeFrequency(a[i]);
        for (const auto& item : primeFrequency) {
            if (pf[item.first] < item.second) pf[item.first] = item.second;
        }
    }
    
    Mint lcm = 1;
    for (const auto& item : pf) {
        for (int i = 0; i < item.second; i++) lcm *= item.first;
    }

    Mint ans;
    for (int i = 0; i < n; i++) ans += lcm / a[i];
    cout << ans.x << endl;
}


Measured memory_bytes: 4988