akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = LIST()

MAX = max(L)
SUM = sum(L)

if MAX < SUM-MAX :
	print("Yes")
else:
	print("No")

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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 (b < a) {
        a = b;
        return true;
    }
    return false;
}


auto solve() {
    int N,Q;
    cin>>N>>Q;
    string s;
    cin>>s;
    vector<pair<char,char>> mvs(Q);
    for(auto&&e:mvs) {
        cin >> e.first >> e.second;
    }

    auto bins = [&]() -> int
    {
        int lb = 0, rb = N+1;

        while(rb - lb > 1) {
            int _med = ((ll)rb + lb) / 2;
            int p = _med - 1;
            bool ok = false;

            for(auto&&e:mvs) {
                int c = s[p];

                if(c == e.first) {
                    if(e.second == 'R') p++;
                    else p--;
                }

                if(p < 0 || p >= N) {
                    ok = true;
                    break;
                }
            }

            if(ok) lb = _med;
            else rb = _med;
        }

        return lb;
    };

    // to left
    int leftp = bins();
    reverse(all(s));
    REP(i,Q) {
        if(mvs[i].second == 'R') mvs[i].second = 'L';
        else mvs[i].second = 'R';
    }
    int rightp = bins();

    return N - min(N, leftp+rightp);
}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "Yes" : "No") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


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

void code()
{
    ll n;
    cin>>n;
    ll A[n];
    for(ll i=0;i<n;i++)
    {
        cin>>A[i];
    }
    sort(A,A+n,greater<ll>());
    ll ans=A[0];
    ll a=A[1];
    ll j=1;
    for(ll i=2;i<n;i++)
    {
        if(i%2==0)
        {
            a=A[j];
            j++;
        }
        ans+=a;        
    }
    cout<<ans<<"\n";
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        code();
    }
}

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

int main(int argc, const char * argv[]) {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int minv = 2000000000;
    for(int i = 0; i <= 100000; i++) {
        int v = 2 * C * i + max(X - i, 0) * A + max(Y - i, 0) * B;
        minv = min(v, minv);
    }
    
    cout << minv << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std ;

const double delta=0.006;
const double eps=1e-8;
const int MAXN=1e3+100;

int a[MAXN];
int n ;
int T , A ;

int main ()
{
	int i ;
	scanf("%d%d%d",&n,&T,&A);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	double Tdel=1000000000.0;
	int ans ;
	for ( i=1 ; i<=n ; i++ ) 
	{
		double del=T-delta*a[i];
		if ( fabs(A-del)+eps<fabs(A-Tdel) ) Tdel=del,ans=i;
	}
	printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX1 1000000000 
#define MAX2 1000000
#define MAX3 2000000

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node*NodePointer;

NodePointer nil;

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
NodePointer listSearch(int);
void init(void);
void printList(void);
void deleteNode(NodePointer );

int main(){
  int key, n, i;
  int size=0;
  char com[20];
  int np=0, nd=0;

  scanf("%d",&n);

  init();

  for(i=0;i<n;i++){
    scanf("%s%d", com, &key);
    if(0>=key&&key>=MAX1){
      printf("error");
    }
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]== 'd'){
      if(strlen(com)>6){
	if(com[6]=='F'){
	  deleteFirst();    
	}
	else if(com[6]=='L'){
	  deleteLast();
	}
      } else {
	delete(key);
	nd++; 
      }
      size--;
    }
    if(size>MAX2){
      printf("error"); 
    }
  }

  if(!( np+nd <= MAX3)){
    printf("error");
  }
  if(!( nd <= 20)){
    printf("error");
  }
  printList();

  return 0;
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

Measured memory_bytes: 31788
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
i=0
t=[]
ans=0
while i<N
  if S[i]=="B" and S[i+1]=="C"
      t.push("BC")
      i+=2
  elsif S[i]=="A"
      t.push("A")
      i+=1
  else
      bc=0
      t.each_with_index do|c,i|
        if c=="BC"
          ans+=i-bc
          bc+=1  
        end
      end
      t=[]
      i+=1
  end
end
if t!=[]
      bc=0
      t.each_with_index do|c,i|
        if c=="BC"
          ans+=i-bc
          bc+=1  
        end
      end
      t=[]
      i+=1

end
puts ans

Measured memory_bytes: 39464
#include <iostream>
#include <vector>
#include <algorithm>
 
class Baseball {
private:
    int out;
    int runner;
    int score;
 
public:
    //constructor
    Baseball() {
        out = 0; 
        runner = 0;
        score = 0;
    }
 
    //getter
    int getOut() { return out; }
    int getRunner() { return runner; }
    int getScore() { return score; }
 
    //input OUT
    void execOut() { ++out; }
 
    //input HIT
    void execHit() {
        if(runner == 3) ++score;
        else ++runner;
    }
 
    //input HOMERUN
    void execHomerun() {
        score += runner + 1;
        runner = 0;
    }
 
};
 
int main(){
    int dataSetNum;
    std::cin >> dataSetNum;
 
    std::vector< Baseball > baseball;
    baseball.resize(dataSetNum);
 
    for(int i = 0; i < dataSetNum; ++i){
 
        while(baseball[i].getOut() != 3){
             
            //input
            std::string tmp;
            std::cin >> tmp;
 
            if(tmp == "OUT")baseball[i].execOut();
            else if(tmp == "HIT")baseball[i].execHit();
            else if(tmp == "HOMERUN")baseball[i].execHomerun();
        }
 
    }
    //output
    std::for_each(baseball.begin(), baseball.end(),
    [](Baseball x) { std::cout << x.getScore() << std::endl; } );
 
    return 0;
}

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

#define ll long long

using namespace std;

template<typename T>
class SegmentTree
{
private:
	using F = function<T(T,T)>;
	vector<T> btree;
	F f, _update;
	T e;
	int n;
public:
	SegmentTree(const vector<T> &v, F f, T e, F g=[](T a,T b){return b;})
		: f(f),e(e),_update(g)
	{
		int _n = v.size();
		init(_n);
		for(int i=0; i<_n; i++) btree[i+n-1] = v[i];
		build();
	}
	void init(int _n){
		n = 1;
		while(_n>n) n<<=1;
		btree.resize(2*n-1, e);
	}
	void build(){
		for(int i=n-2; i>=0; i--) btree[i] = f(btree[2*i+1], btree[2*i+2]);
	}
	void update(int k, T a){
		k += n-1;
		btree[k] = _update(btree[k], a);
		while(k>0){
			--k>>=1;
			btree[k] = f(btree[2*k+1], btree[2*k+2]);
		}
	}
	T query(int a, int b){
		T L=e, R=e;
		a+=n-1; b+=n-1;
		while(a<b){
			if (!(a&1)) L=f(L, btree[a++]);
			if (!(b&1)) R=f(btree[--b], R);
			a>>=1; b>>=1;
		}
		return f(L,R);
	}
	T operator[](int k){return btree[k+n-1];}
};

const int INF = 2000001;

int main()
{
	int n, D;
	cin >> n >> D;
	vector<int> x(n),y(n),d(n);
	for(int i=0;i<n;i++)
		cin >> x[i] >> y[i] >> d[i];
	
	set<ll> Set;
	for(int i=0; i<n; i++){
		Set.insert(d[i]);
	}
	map<ll,int> Map;
	map<int,ll> Rmap;
	int idx=0;
	for(auto e:Set){
		Map[e] = idx;
		Rmap[idx++] = e;
	}
	int sz = Set.size();
	vector<int> xmax(sz, 0), ymax(sz, 0);
	vector<int> xmin(sz, INF), ymin(sz, INF);
	for(int i=0; i<n; i++){
		int ad = Map[d[i]];
		xmax[ad] = max(xmax[ad], x[i]);
		ymax[ad] = max(ymax[ad], y[i]);
		xmin[ad] = min(xmin[ad], x[i]);
		ymin[ad] = min(ymin[ad], y[i]);
	}
	for(int i=0;i<sz;i++)
	{
		//cout << xmax[i] << endl;
		//cout << xmin[i] << endl;
		//cout << ymin[i] << endl;
	}

	SegmentTree<int> segxmax(xmax,[](int x,int y){return max(x,y);},0);
	SegmentTree<int> segymax(ymax,[](int x,int y){return max(x,y);},0);
	SegmentTree<int> segxmin(xmin,[](int x,int y){return min(x,y);},INF);
	SegmentTree<int> segymin(ymin,[](int x,int y){return min(x,y);},INF);

	int head=0,tail=0;
	long long ans=0;
	while(tail<sz)
	{
		int x=segxmax.query(head,tail+1)-segxmin.query(head,tail+1);
		int y=segymax.query(head,tail+1)-segymin.query(head,tail+1);
		ans = max(ans, (long long)x*y);
		//cout << x << " " << y << endl;
		tail++;
		while(Rmap[tail]-Rmap[head]>D)head++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 50900
def lcs(X,Y):
    res = [0 for i in range(len(X)+1)]
    for y in Y:
        previous = res[:]
        for i,x in enumerate(X):
            if x == y:
                res[i+1] = previous[i] + 1
            elif res[i] > previous[i+1]:
                res[i+1] = res[i]
    return res[-1]

n = int(input())
for i in range(n):
    X = input()
    Y = input()
    print(lcs(X,Y))


Measured memory_bytes: 5628
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=5000;

int n; ll A,B;
int p[MAXN];

int pos[MAXN];

ll dp[MAXN][MAXN]; // dp[i][j] = minimum cost to place [0..j] so that i is the last one of them that stays in place

void upd(ll &a,ll b) { a=min(a,b); }
ll solve() {
	REP(i,n) pos[p[i]]=i;
	//printf("pos:"); REP(i,n) printf(" %d",pos[i]); puts("");
	
	REP(i,n) REP(j,n) dp[i][j]=LLONG_MAX;
	REP(i,n) dp[i][i]=i*B;
	REP(j,n-1) REPE(i,j) if(dp[i][j]!=LLONG_MAX) {
		int k=j+1;
		// let k stay in same place
		if(pos[k]>pos[i]) upd(dp[k][k],dp[i][j]);
		// move k left
		if(pos[k]>pos[i]) upd(dp[i][k],dp[i][j]+B);
		// move k right
		if(pos[k]<pos[i]) upd(dp[i][k],dp[i][j]+A);
	}
	//REP(i,n) REP(j,n) if(dp[i][j]!=LLONG_MAX) printf("(%d,%d) = %lld\n",i,j,dp[i][j]);
	ll ret=LLONG_MAX; REP(i,n) ret=min(ret,dp[i][n-1]); return ret;
}

void run() {
	scanf("%d%lld%lld",&n,&A,&B);
	REP(i,n) scanf("%d",&p[i]),--p[i];
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 195584
#include<iostream>
#include<cmath>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e15;
ll mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll ans[200001];

int main()
{
    //freopen("telecow.in", "r", stdin), freopen("telecow.out", "w", stdout);
    fast_io;
    ll n, i, v;
    cin >> n;
    for (i = 2; i <= n; i++) cin >> v, ans[v]++;
    for (i = 1; i <= n; i++) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 5204
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    int sum = a + b + c;
    int d = Math.max(a, Math.max(b, c));
    sum -= d;
    d = (int)Math.pow(2, k) * d;
    sum += d;
    System.out.println(sum);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  int f[10]={1,1,2,3,5,8,13,21,34,55};
  ll dp[h+1][w];
  rep(i,0,h+1){
    rep(j,0,w){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  rep(i,0,h){
    rep(j,0,w){
      dp[i+1][j]+=dp[i][j]*f[j]*f[w-1-j];
      if(j!=w-1) dp[i+1][j]+=dp[i][j+1]*f[j]*f[w-2-j];
      if(j!=0) dp[i+1][j]+=dp[i][j-1]*f[j-1]*f[w-1-j];
      dp[i+1][j]%=mod;
    }
  }
  cout<<dp[h][k-1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
	std::cin >> a[i] >> b[i];
    }
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    double am, bm;
    double ans;
    if(n % 2 == 1){
	am = a[(n+1)/2 - 1];
	bm = b[(n+1)/2 - 1];
	ans = bm - am + 1;
    }else{
	am = (a[n/2 - 1] + a[n/2]);
	bm = (b[n/2 - 1] + b[n/2]);
	ans = (bm - am) + 1;
    }
    long long ans2;
    ans2 = ans + 0.1;
    std::cout << ans2 << std::endl;
    return 0;
}



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

int top, S[1000];
//topを0に移動してスタックを空にする
void initialize() {
	top = 0;
	return;
}
//スタックが空かどうか調べる
bool isEmpty() {
	if (top == 0) return 1;
	else return 0;
}
//スタックが満杯かどうか調べる
bool isFull() {
	if (top >= 999) return 1;
	else return 0;
}
//topを1増やして要素をinする
void push(int x) {
	if (isFull()) return;
    top++;
	S[top] = x;
	return;
}
//topを減らしてtopにあった要素をoutする
int pop() {
	//if (isEmpty) return 0;
	top--;
	return S[top + 1];
}
int main() {
    int a, b;
    initialize();
    char s[100];
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
            a = pop();
            b = pop();
            push(b - a);
        }
        else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;

int n;
int a[N];
long long cnt = 0;
map <int, int> d1, d2;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], d2[a[i] - i]++, d1[a[i] + i]++;
	for(int i = 1; i <= n; i++)
	{
		d2[a[i] - i]--;
		d1[a[i] + i]--;
		cnt += d1[i - a[i]];
		cnt += d2[-(i + a[i])];
		d2[a[i] - i]++;
		d1[a[i] + i]++;
	}
	cout << cnt / 2 << endl;
}      

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back


//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);



bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

ll prime[10000006];


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;

    // cout << "Ads" << endl;
    for(ll i = 0; i<=n; i++)
    {
        prime[i] = 1;
    }

    for (ll p=2; p<=n; p++) 
    { 
        for (ll i=2 * p; i<=n; i += p)
        {
            prime[i]++;
        } 
    }

    // ll sum = 0;
    // for(ll i = 1; i<=n; i++)
    // {
    //     cout << prime[i] << " ";
    // }
    // cout << endl;
    ll sum = 1;
    for(ll i = 2; i<=n; i++)
    {
        sum += i * (prime[i]+1);
    }  
    cout << sum << endl;  
    return 0;
}   

Measured memory_bytes: 81696
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int w,h,x,y,r;
	cin >>w >> h >> x >> y >> r;
	
	
	if(x < w && y < h && r < w)
	
	{
		if(x < 0)
		{
			cout<<"No"<<endl;
			
		}
		else if(y < 0)
		{
			cout<<"No"<<endl;
		}
		else if(r < 0)
		{
			cout<<"No"<<endl;
		}
		else if(r+x > w)
		{
			cout<<"No"<<endl;
		}
		else if (x > 0 && y > 0 && r > 0)
		{
			cout<<"Yes"<<endl;
		}
		
	}
	else
	{
		cout<<"No"<<endl;
	}
		
		
}




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

int main()
{
  long long i,o,t,j,l,s,z;
  scanf("%lld%lld%lld%lld%lld%lld%lld",&i,&o,&t,&j,&l,&s,&z);
  long long a=((i/2)+(j/2)+(l/2))*2;
  if(i>0&&j>0&&l>0){
    a=max(a,3+(((i-1)/2)+((j-1)/2)+((l-1)/2))*2);
  }
  printf("%lld\n",a+o);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int he = a+b+c;
    int maxi = max(max(a,b),c);
    he -= maxi;
    he = he + pow(2,k)*maxi;
    printf("%d\n",he);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_X = 15;
const int MAX_Y = 15;

/* typedef */

/* global variables */

int gx, gy;
int dp[MAX_Y + 1][MAX_X + 1];
bool hes[MAX_Y + 1][MAX_X], ves[MAX_Y][MAX_X + 1];

/* subroutines */

/* main */

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

  while (tn--) {
    cin >> gx >> gy;

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    memset(hes, true, sizeof(hes));
    memset(ves, true, sizeof(ves));

    int n;
    cin >> n;

    while (n--) {
      int x0, y0, x1, y1;
      cin >> x0 >> y0 >> x1 >> y1;

      if (y0 == y1) hes[y0][min(x0, x1)] = false;
      else ves[min(y0, y1)][x0] = false;
    }

    for (int y = 0; y <= gy; y++)
      for (int x = 0; x <= gx; x++) {
	if (x > 0 && hes[y][x - 1]) dp[y][x] += dp[y][x - 1];
	if (y > 0 && ves[y - 1][x]) dp[y][x] += dp[y - 1][x];
      }

    if (dp[gy][gx] == 0)
      cout << "Miserable Hokusai!" << endl;
    else
      cout << dp[gy][gx] << endl;
  }

  return 0;
}

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

int main(){
  int N, K; cin >> N >> K;
  vector<int> x(N);
  for(int i = 0; i < N; i++){
    cin >> x[i];
  }
  
  int ans = 1e9;
  
  for(int i = 0; i < N-K+1; i++){
    int tmp;
    int beg = x[i], end = x[i + K - 1];
    if(end <= 0) tmp = -beg;
    else if(beg >= 0) tmp = end;
    else tmp = min(- 2 * beg + end, - beg + 2 * end);
    
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
import sys
import math
input = sys.stdin.readline


def eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, n // 2 + 1):
        if is_prime[i]:
            for j in range(2, n // i + 1):
                is_prime[i * j] = False
    return is_prime


q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r)
is_prime = eratosthenes(r_max)
a = [0] * (r_max + 1)
for i in range(3, r_max + 1):
    a[i] = a[i - 1]
    if is_prime[i] and is_prime[(i + 1) // 2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i] - 1])


Measured memory_bytes: 13424
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int maxn = 2e3 + 10;
const int inf = 2e9;

int n, k, q;
int a[maxn], b[maxn];
bool ban[maxn];
int ans = inf;

void Doit()
{
	vector<int> c, d;
	for (int i = 1; i <= n + 1; ++ i)
	{
		if (ban[i])
		{
			if (c.size() >= k)
			{
				sort(c.begin(), c.end());
				int p = c.size() - k + 1;
				for (int i = 0; i < p; ++ i) d.push_back(c[i]);
			}
			c.clear();
			continue;
		}
		c.push_back(a[i]);
	}
	sort(d.begin(), d.end());
	if (d.size() < q) return;
	ans = min(ans, d[q - 1] - d[0]);
}

int main()
{
	scanf("%d%d%d", &n, &k, &q);
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d", a + i);
		b[i] = a[i];
	}
	sort(b + 1, b + n + 1);
	ban[n + 1] = true;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 1; j <= n; ++ j)
			ban[j] = a[j] < b[i];
		Doit();
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#define N 1005
using namespace std;

typedef long long ll;
ll n, m, c[N], d[N];
bool v[N];
vector<ll> a[N], b[N];

bool ff(int p) {
	int i;
	if (p == n) return 1;
	if (v[p]) return 0;
	v[p] = 1;
	for (i = 0; i < a[p].size(); i++) if (ff(a[p][i])) return 1;
	return 0;
}

void f(ll p, ll q) {
	ll i;
	if (c[p]) {
		memset(v, 0, sizeof(v));
		if (q > c[p] && ff(p)) {cout << "inf"; exit(0);}
		else return;
	}
	c[p] = q;
	for (i = 0; i < a[p].size(); i++) f(a[p][i], q + b[p][i]);
}

ll g(ll p) {
	ll i, mx = -1e18;
	if (p == n) return 0;
	if (d[p]) return d[p];
	d[p] = mx;
	for (i = 0; i < a[p].size(); i++) mx = max(mx, g(a[p][i]) + b[p][i]);
	return d[p] = mx;
}

int main()
{
	ll t1, t2, t3;
	cin >> n >> m;
	while (m--) {
		scanf("%lld %lld %lld", &t1, &t2, &t3);
		a[t1].push_back(t2);
		b[t1].push_back(t3);
	}
	f(1, 0);
    cout << g(1) << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n;
  string str;

  cin >> n;
  cin.ignore();
  int count = 0;
  while (n--) {
    cin >> str;
    if (str == "E869120") count++;
  }

  cout << count << endl;
}



Measured memory_bytes: 3204
#include <stdio.h>
#include <stdlib.h>

int main () {
	int a[3];
	int max = 0;
	int min = 101;
	scanf ("%d %d %d", a, a+1, a+2);

	for (int i=0; i<3; i++) {
		if (a[i] > max)
			max = a[i];
		if (a[i] < min)
			min = a[i];
	}

	printf ("%d\n", max - min);

	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e2 + 5;

int dp[MAXN][MAXN];

int used[MAXN];

int rec_sol(int k, int v) {
	if (v < k) {
		return 0;
	}
	if (v % k == 0) {
		return v / k;
	}
	int period = v / k + 1;
	int last = v - v % k;
	int mod = v % period;
	int prev = (last - mod) / period * period + mod;
	return rec_sol(k, prev);
}

void solve(){
	int n, sum = 0;
	scanf("%d", &n);
	REP(i, 0, n) {
		int a, k;
		scanf("%d%d", &a, &k);
		sum ^= rec_sol(k, a);
	}
	if (sum == 0) {
		printf("Aoki\n");
	} else {
		printf("Takahashi\n");
	}
	
	/*REP(i, 1, MAXN) {
		printf("%d: ", i);
		REP(j, 1, MAXN) {
			printf("%d ", rec_sol(i, j));
		}
		putchar('\n');
	}*/
	
	/*int top = 0;
	REP(i, 1, MAXN) {
		REP(j, 1, MAXN) {
			top++;
			REPN(k, 1, j / i) {
				if (j - k >= 0) {
					used[dp[i][j - k]] = top;
				}
			}
			dp[i][j] = -1;
			for(int k = 0; used[k] == top; k++) {
				dp[i][j] = k;
			}
			dp[i][j]++;
		}
	}
	
	REP(i, 1, MAXN) {
		printf("%d: ", i);
		REP(j, 1, MAXN) {
			printf("%d ", dp[i][j]);
		}
		putchar('\n');
	}*/
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
<?php
  $isPrime = array_fill(0, 10001, true);
  $isPrime[0] = $isPrime[1] = false;
  for($i = 2 ; $i <=5000 ; $i++) {
    for($j = 2 ; $i*$j <= 10000 ; $j++) {
      $isPrime[$i*$j] = false;
    }
  }

  $primeNumber = array();
  foreach ($isPrime as $key => $value) {
    if($value) {
      $primeNumber[] = $key;
    }
  }
  //$input = [2, 3, 17, 41, 20, 666, 12, 53, 0];
  while(true) {
    fscanf(STDIN, "%d", $input);
      if($input == 0)
        break;
        $result = 0;
        for($l = 0 ; $l < count($primeNumber) ; $l++) {
          $sum = 0;
          for($m = $l ; $m < count($primeNumber) ; $m++) {
            $sum += $primeNumber[$m];
            if($sum == $input) {
              $result++;
            }
          }
          unset($sum);
        }
        echo $result . "\n";
        unset($result);
}

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

int main()
{
	int n;
  cin>>n;
  while(n)
  {
	int a = n%10;
    if(a==7)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
    n = n/10;
  }
  cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

































int main(){
    ll x;
    cin >> x;
    ll n = 0, ans = 0;
    do{
        n += x;
        n %= 360;
        ans++;
    }while(n);
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define IOS                 ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)              cout << #x << " = " << x << endl
#define deb2(x, y)          cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)         for(i = a; i < n; i++)
#define f1(i, a, n)         for(i = a; i <= n; i++)
#define tc(t)               int t; cin >> t; while(t--)
#define ini(x, y)           memset(x, y, sizeof(x))
#define all(x)              x.begin(),x.end()
#define sz(x)               x.size()
#define ll                  long long int
#define vi                  vector<int>
#define si                  set<int>
#define pb                  emplace_back
#define ppb                 pop_back
#define mp                  make_pair
#define M                   1000000007
#define endl                '\n'
#define bits(x)             __builtin_popcountll(x)
#define zrbits(x)           __builtin_ctzll(x)

using namespace std;

void solve() {
        ll n, i;
        cin >> n;
        cout << (!n) << endl;
}

int main () {
        IOS;
        // tc(t)
        solve();
        return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();

		int kaiJun = 0;
		int tuka = 0;
		for (int i = 1; i <= n; i++) {
			if ('a' == s.charAt(i - 1) && tuka < a + b) {
				System.out.println("Yes");
				tuka++;
			} else if ('b' == s.charAt(i - 1) ) {
				kaiJun++;
				if (tuka < a + b && kaiJun <= b) {
					System.out.println("Yes");
					tuka++;
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		}

		sc.close();
	}

}


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

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

    int ans = 1000;
    for(int i = 0; i <= s.size()-3; i++){
        int num = stoi(s.substr(i, 3));
        ans = min(ans, abs(753-num));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
from collections import Counter
C=Counter(A)
Q=list(C.values())
def qq(F):
    n=len(F)
    ans=0
    for i in range(n):
        ans+= F[i]*(F[i]-1)//2
    return ans
ans=qq(Q)
for i in range(n):
    print(ans-C[A[i]]+1)

Measured memory_bytes: 25716
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()

using namespace std;
const int inf = 2e9;

vector<long long> a;
vector<bool> good;

int main() {
	int n, mx = -inf, mxi;
	long long odd = -inf, even = -inf;
	scanf("%d", &n);
	a.push_back(-1);
	good.push_back(false);
	for (int i = 1, q; i <= n; i++) {
		scanf("%d", &q);
		a.push_back(q);
		good.push_back(false);
		if (mx < q) {
			mx = q;
			mxi = i;
		}
		if (q > 0) {
			if (i&1) {
				if (odd == -inf)
					odd = 0;
				odd += q;
			} else {
				if (even == -inf)
					even = 0;
				even += q;
			}
		}
	}
	if (mx <= 0) {
		printf("%d\n%d\n", mx, n-1);
		for (int i = 1; i < mxi; i++) {
			printf("1\n");
			n--;
		}
		while (n > 1) {
			printf("%d\n", n);
			n--;
		}
		return 0;
	}
	printf("%lld\n", max(even, odd));
	int tmp = 1; 
	if (even > odd)
		tmp = 2;
	for (int i = tmp; i <= n; i += 2) {
		if (a[i] > 0)
			good[i] = true;
	}
	vector<int> res;
	while (!good[1]) {
		good.erase(good.begin()+1);
		res.push_back(1);
		n--;
	}
	while (!good[n]) {
		good.pop_back();
		res.push_back(n);
		n--;
	}
	for (int i = 1; i <= n; i++) {
		if (good[i]) {
			continue ;
		}
		if (good[i+1]) {
			good.erase(good.begin()+i);
			good.erase(good.begin()+i);
			res.push_back(i);
			n-=2;
		} else {
			res.push_back(i+1);
			good.erase(good.begin()+i);
			good.erase(good.begin()+i);
			n-=2;
		}
		i--;
	}
	printf("%d\n", (int)res.size());
	for (auto rs : res) 
		printf("%d\n", rs);

	return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[11000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++)scanf("%d",p+i);
	for(int i=0;i<b;i++)a-=p[i];
	if(a<0)a=-1;
	printf("%d\n",a);
}


Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string.h>
#include<vector>
#include<algorithm>
#define ll long long
#define maxn 200020
using namespace std;

vector<ll>q[2];
ll x[maxn],y[maxn];
ll bit[100];
int n;

ll solve()//我擦。。这个归并太吊了
{
    ll ans=0;
    for(ll i=0;i<62;i++)
    {
        ll tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(x[j]>>i)&1].push_back(x[j]);
        for(ll j=0;j<q[0].size();j++)
            x[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            x[++tot]=q[1][j];
        tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(y[j]>>i)&1].push_back(y[j]);
        for(ll j=0;j<q[0].size();j++)
            y[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            y[++tot]=q[1][j];
        ll len1=1,len2=1,len3=1;
        ll limit1=1ll<<i;
        ll limit2=1ll<<(i+1);
        ll all=(1ll<<(i+1))-1;///这里加1LL
        //        cout<<all<<" all"<<endl;
        ll sum=0;
        //        for(int i=1;i<=tot;i++) cout<<x[i]<<" ";
        //        cout<<endl;
        //        for(int i=1;i<=tot;i++) cout<<(x[i]&all)<<" ";
        //        cout<<endl;
        //        for(int i=1;i<=tot;i++) cout<<y[i]<<" ";
        //        cout<<endl;
        for(ll i=n;i>=1;i--)
        {
            while((((x[i]&all)+(y[len1]&all))<limit1) && (len1<=n)) len1++;//这里多加几个（）
            while((((x[i]&all)+(y[len2]&all))<limit2) && (len2<=n)) len2++;
            while(((x[i]&all)+(y[len3]&all)<limit1+limit2) && (len3<=n)) len3++;//cout<<(x[i]&all)<<" "<<(y[len3]&all)<<" "<<len3<<" "<<y[len3]<<" "<<(limit1+limit2)<<endl;
            sum+=n-(len1-1-len2+1+len3-1);
            //            cout<<len1<<" "<<len2<<" "<<len3<<endl;
            //            cout<<n-(len1-1-len2+1+len3-1)<<endl;
        }
        //        cout<<sum<<" sum   "<<i<<endl;
        if(sum&1) ans+=bit[i];
    }
    return ans;
}

int main()
{
    //    freopen("1003.txt","r",stdin);
    bit[0]=1;
    for(ll i=1;i<=61;i++)
        bit[i]=bit[i-1]*2;
    
    scanf("%d",&n);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&x[i]);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&y[i]);
    printf("%lld\n",solve()) ;
    
}


Measured memory_bytes: 6508
#include <bits/stdc++.h>
 
using namespace std;
using ll=long long;
 
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define rrep(i,m) RREP(i,m,0)
#define debug(x) cout << #x << "=" << (x) << endl;
const int MOD=1e9+7;
 
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
 
void solve(){
    int num;string s;
    cin >> num >> s;
    int ct=0;
    rep(i,num-1)
        ct+=s[i]!=s[i+1];
    cout << ct+1 << endl;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 512
#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;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
ll cnt_factor(ll x){
  if(x==1)return 0;
  ll cnt=1;
  for (ll i = 2; i*i <= x; i++)
  {
    if(x%i==0){
      if(x/i!=i){
        cnt+=2;
      }else{
        cnt++;
      }
    }
  }
  return cnt;
}
vector<ll> set_factor(ll x){
  vector<ll> ret;
  for(ll i=1;i*i<=x;++i){
    if(x%i==0){
      ret.push_back(i);
      if(x/i!=i){
        ret.push_back(x/i);
      }
    }
  }
  return ret;
}
void solve(long long N){
  ll ans=cnt_factor(N-1);
  auto s=set_factor(N);
  for (auto &&i : s)
  {
    if(i==1)continue;
    ll NN=N;
    while(NN%i==0){NN/=i;}
    if(NN%i==1)++ans;
  }
  cout<<ans<<endl;
  
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int tmp = N;
      int sum = 0;
      while(tmp > 0){
        sum += tmp % 10;
        tmp /= 10;
      }
      myout((N % sum == 0) ? "Yes" : "No");
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32956