akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long C(long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(a);lin(b);lin(x);
  
  a+=(x-a%x)%x;
  b-=b%x;
  
  ll d=b-a;
  
  cout<<d/x+1<<endl;
  //cout<<a<<" "<<b;
}

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

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

int main() {
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    --Ch;
    --Cw;
    --Dh;
    --Dw;

    vector<string> Graph(H);
    rep(i, H) cin >> Graph.at(i);

    const int INF = 10e9;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    deque<P> que;

    que.push_front(make_pair(Ch, Cw));
    dist[Ch][Cw] = 0;
    bool goal = false;
    while (!que.empty()) {
        P p;
        p = que.front();
        que.pop_front();
        for (int direction = 0; direction < 4; ++direction) {
            int nh = p.first + dx[direction];
            int nw = p.second + dy[direction];

            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (dist[nh][nw] <= dist[p.first][p.second]) continue;
            if (Graph[nh][nw] == '#') continue;
            dist[nh][nw] = dist[p.first][p.second];
            que.push_front(make_pair(nh, nw));
        }
        for (int k = -2; k <= 2; ++k) {
            for (int l = -2; l <= 2; ++l) {
                int nh2 = p.first + k;
                int nw2 = p.second + l;
                if (nh2 < 0 || nh2 >= H || nw2 < 0 || nw2 >= W) continue;
                if (dist[nh2][nw2] <= dist[p.first][p.second] + 1) continue;
                if (Graph[nh2][nw2] == '#') continue;
                dist[nh2][nw2] = dist[p.first][p.second] + 1;
                que.push_back(make_pair(nh2, nw2));
            }
        }
    }
    int ans = dist[Dh][Dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 9420
N,x=map(int,input().split())
if x==1 or x==2*N-1:
  print("No")
else:
  print("Yes")
  ans=[int(x+1) for x in range(2*N-1)]
  if N-x > 0:
    cnt=abs(N-x)
    ans=ans[(2*N-1)-cnt:]+ans[:(2*N-1)-cnt]
  elif N-x < 0:
    cnt=abs(N-x)
    ans=ans[cnt:]+ans[:cnt]
  for i in range(2*N-1):
    print(ans[i])

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

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

using namespace std;

typedef long long ll;

const int MAX = 100010;
const int IINF = INT_MAX;
int V,E,s,t;
vector<int> G[MAX];
int mindist[2][MAX]; // 0 -> start, 1 -> goal
ll counter[2][MAX];

void BFS(int sp){
  int index = (sp==t);
  mindist[index][sp] = 0;
  deque<int> deq;
  deq.push_back(sp);
  while( !deq.empty() ){
    int cur = deq.front(); deq.pop_front();
    rep(i,G[cur].size()){
      int next = G[cur][i];
      if( mindist[index][next] == IINF ) {
        mindist[index][next] = mindist[index][cur] + 1;
        deq.push_back(next);
      }
    }
  }
}

void compute(){
  rep(i,2) rep(j,V) mindist[i][j] = IINF, counter[i][j] = 0;
  BFS(s);
  BFS(t);
  int mini = mindist[0][t];
  ll answer = 0;
  rep(i,V) {
    if( mindist[0][i] != IINF ) ++counter[0][mindist[0][i]];
    if( mindist[1][i] != IINF ) ++counter[1][mindist[1][i]];
  }
  rep(i,mini-1) answer += ( counter[0][i] * counter[1][mini-2-i] );
  cout << answer << endl;
}

int main(){
  scanf("%d %d %d %d",&V,&E,&s,&t);
  --s,--t;
  rep(i,E) {
    int a,b;
    scanf("%d %d",&a,&b);
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  compute();
  return 0;
}

Measured memory_bytes: 9980
const main = input => {
    const [ S, T ] = input.trim().split('\n');
    const length = S.length;
    let count = 0;
    for (let i = 0; i < length; i++) {
        if (S.substr(i, 1) !== T.substr(i, 1)) {
            count++;
        }
    }

    console.log(count)
};

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 33072
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {

	ll A, B, C;

	cin >> A>>B>>C;

	cout << min(C, B / A);

	system("PAUSE");
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 1000000 + 3;
int a[MAXN];

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

    for (int i = 0; i < N; i ++){
        cin >> a[i];
    }
    sort(a, a + N);

    long long ans = (long long)a[N - 1];
    int k = N - 2;
    for (int i = N - 3; i >= 0; i -=2){
        ans += (long long)a[k];
        if (i - 1 >= 0){
            ans += (long long)a[k];
        }
        k --;
        //cout << ans << endl;
    }
    cout << ans;
    system("pause");
    return 0;
}

Measured memory_bytes: 4344
#include <cstring>
#include <algorithm>
#include <map>
#include <stack>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
int a[maxn];

int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int m;
        cin >> m;
    }
    int idx = 1, cnt = 0;
    while (idx < n) {
        idx += k - 1;
        cnt ++;
    }
    cout << cnt << endl;
}

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

int main()
{
  int a,n,m,x;
  int zero = 0;
  int max = 0;

  cin >> n >> m >> x;

  int* masu = new int[n+1];

  for (int i = 0; i < m; i++) {
    std::cin >> a;
    masu[a] = 1;
  }

/*
  for (int i = 0; i <= n; i++) {
      std::cout << "m" << i << ":" << masu[i] << '\n';
  }
*/
  for (int i = x; i <= n; i++) {
    max += masu[i];
  }

  for (int i = x; i >= 0; i--) {
    zero += masu[i];
  }

  //printf("zero = %d,max = %d\n",zero,max);

  if (zero > max) {
    std::cout << max << '\n';
  }else{
    std::cout << zero << '\n';
  }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int h, w;
    cin >> h >> w;
    int a[h][w];
    bitset<40000> dp[2][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) {
        int b;
        cin >> b;
        a[i][j] -= b;
        a[i][j] = abs(a[i][j]);
    }
    dp[0][0].set(20000 + a[0][0]);
    dp[0][0].set(20000 - a[0][0]);
    rep(i, h) rep(j, w) {
        bool I = i & 1;
        if(i) {
            dp[I][j].reset();
            dp[I][j] |= (dp[!I][j] << a[i][j]) | (dp[!I][j] >> a[i][j]);
        }
        if(j) dp[I][j] |= (dp[I][j - 1] << a[i][j]) | (dp[I][j - 1] >> a[i][j]);
    }
    int ans = 1e9;
    rep(i, 40000) if(dp[h + 1 & 1][w - 1][i]) chmin<int>(ans, abs(20000 - i));
    cout << ans << endl;
}

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

int main(void){
  double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
  while(cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2){
    if(xb2<xa1 or xa2<xb1){
      cout<<"NO"<<endl;
    }
    else if(yb2<ya1 or ya2<yb1){
      cout<<"NO"<<endl;
    }
    else{
      cout<<"YES"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3156
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for (int i = 1; i <= N; i++) {
			A[sc.nextInt()] = i;
		}
		for (int i = 1; i <= N; i++) {
			System.out.print(A[i] + " ");
		}
	}
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 40180
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl "\n"
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fb(i, a, b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector <int>
#define vl vector <long long>
#define pi pair <int, int>
#define sz(x) (int) x.size()
#define M 100005
#define mod 1000000007
using namespace std;

void solve()
{
	int n, m, flag = 0, ans = 0;
	cin>>n>>m;
	int h[n], u, v;
	f(i, 0, n) cin>>h[i];
	vector <int> adj[n];
	f(i, 0, m)
	{
		cin>>u>>v;
		u--, v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	f(i, 0, n)
	{
		flag = 0;
		for(auto p : adj[i])
		{
			if(h[p] >= h[i]) flag++;
		}
		if(flag == 0) ans++;
	}
	cout<<ans;
}

int main()
{
    IOS
    int t = 1;
    //cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9144
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
sortedA = sorted(a)
if sortedA[-1] == sortedA[-2]:
    for j in range(n):
        print(sortedA[-1])
else:
    l = a.index(sortedA[-1])
    for j in range(l):
        print(sortedA[-1])
    print(sortedA[-2])
    for k in range(n-l-1):
        print(sortedA[-1])


Measured memory_bytes: 14112
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const int N = 1e6+5;
const ll mod = 1e9+7 ;
typedef pair<ll,ll> pii;


void TEST_CASES(int cas)
{
    ll n;
    cin>>n;
    ll mini = 1e18 , maxi = -1;
    vector<ll>a(n);
    vector<ll>b(n);
    for(ll i=0;i<n;i++)
    {
        ll u,v;
        cin>>u>>v;
        a[i] = u+v;
        b[i] = v-u;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans = max(abs(a[0]-a.back()) , abs(b[0]-b.back()));
    cout<<ans<<endl;

}



/*

*/

int main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int t=1,cas=0;
    //cin>>t;
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 6340
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(abs(a[0] - w))
    exit()
mx = max(abs(a[n - 2] - a[n - 1]), abs(a[-1] - w))

print(mx)


Measured memory_bytes: 5588
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
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

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if 0 > self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if 0 > x]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
	
	
N, M = MAP()

tree = UnionFind(N)
for _ in range(M):
	X, Y, Z = MAP()
	tree.union(X-1, Y-1)

print(tree.group_count())


Measured memory_bytes: 9928
#include<stdio.h>
int main()
{
  long x,y,k;
  int result;
  scanf("%ld%ld",&x,&y);
  if(x<y)
    {
      k=x;
      x=y;
      y=k;
    }
  while(1)
    {
      if(x%y==0) break;
      x%=y;
      k=x;
      x=y;
      y=k;
    }
  printf("%ld\n",y);
  return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#define N 101
 
void Printing(int arr[], int n){
    int i;
    for(i = 0; i < n-1; i++){
        printf("%d ", arr[i]);
    }
    printf("%d\n", arr[n-1]);
}
 
void insertion(int arr[], int n) {
    int key, i, j;
    Printing(arr, n);
    for (i = 1; i < n; i++) {
        key = arr[i];
        j = i - 1;
        while(j >= 0 && key < arr[j]){
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = key;
        Printing(arr, n);
    }
}
 
 
int main() {
    int n, i, arr[N];
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    insertion(arr, n);
    return 0;
}

Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, ans;
int d1[N], d2[N];
vector<int> G[N];
void dfs(int u, int last, int *d) 
{
	for(int i = 0; i < G[u].size(); ++i)
	{
		int v = G[u][i];
		if(v == last) continue;
		d[v] = d[u] + 1;
		dfs(v, u, d);
	}
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i < n; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, 0, d1);
	dfs(n, 0, d2);
	for(int i = 1; i <= n; ++i) if(d1[i] <= d2[i]) ++ans; else --ans;
	puts(ans > 0 ? "Fennec" : "Snuke");	
	return 0;
}

Measured memory_bytes: 14336
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	A := readInt()
	P := readInt()

	println((A*3 + P) / 2)

}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll n;
int sgs[3] = {7, 5, 3};

int dfs(ll x, int bit) {
  if (x > n) return 0;
  ll res = 0;
  if (bit == (1<<3)-1) res++; //753が揃っていればカウント
  rep(i,3) {
    res += dfs(10*x + sgs[i], bit|(1<<i)); //フラグを立てる
  }
  return res;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  cin >> n;
  int ans = 0;
  rep(i,3) {
    ans += dfs(sgs[i], (1<<i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def factorization(n):
    factorization_list = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

    if temp != 1:
        factorization_list.append(temp)

    if factorization_list==[]:
        factorization_list.append(n)

    return factorization_list


if __name__ == "__main__":
    A, B = map(int, input().split())
    A_fac = set(factorization(A))
    B_fac = set(factorization(B))

    AB_fac = A_fac & B_fac
    print(len(AB_fac))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=110;
char a[N],s[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    scanf("%s",s+1);
    int n=strlen(s+1),ans=1<<30;
    for(int i=0;i<26;i++) {
	memcpy(a,s,sizeof(a));
	int m=n;
	while(1) {
	    int t=0;
	    for(int j=1;j<=m;j++)
		if(a[j]-'a'!=i) ++t;
	    if(t==m) break;
	    if(!t) {ans=min(ans,n-m);break;}
	    for(int j=1;j<m;j++)
		if(a[j]-'a'!=i) a[j]=a[j+1];
	    --m;
	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())

adj=[set() for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    adj[A].add(B)
    adj[B].add(A)

blk=[{*()} for _ in range(N)]
for _ in range(K):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    blk[A].add(B)
    blk[B].add(A)

#print(adj)
#print(blk)

colors=[-1]*N
ct={}
color=-1
for u in range(N):
    if colors[u]!=-1:
        continue
    color+=1
    colors[u]=color
    stk=[u]
    while stk:
        u=stk.pop()
        ct[color]=ct.get(color,0)+1
        for v in adj[u]:
            if colors[v]==-1:
                colors[v]=color
                stk.append(v)


ans=[0]*N
for u in range(N):
    c=colors[u]
    k=ct[c]-1-len(adj[u])
    for v in blk[u]:
        if colors[v]==c:
            k-=1
    ans[u]=k

print(*ans)


Measured memory_bytes: 147476
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n - 1) { sc.nextInt() }
    val count = Array(n) { 0 }
    for (i in 0 until n - 1) {
        count[a[i] - 1]++
    }
    println(count.joinToString("\n"))
}

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: 64156
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    vector<bool> vec(N, true);
    rep(i, N) {
        if (S[i] == '#') {
            vec[i] = false;
        }
    }
    if (C > D) {
        bool flag1 = false;
        for(ll i = A-1; i < C-1; i++) {
            if (!vec[i] && !vec[i+1]) {
                flag1 = true;
            }
        }
        for(ll i = B-1; i < D-1; i++) {
            if (!vec[i] && !vec[i+1]) {
                flag1 = true;
            }
        }
        bool flag2 = false;
        for(ll i = B-2; i < D-1; i++) {
            if (i+2 >= N) break;
            if (i < 0) break;
            if (vec[i] && vec[i+1] && vec[i+2]) {
                flag2 = true;
            }
        }
        if (!flag1 && flag2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        bool flag = false;
        for(ll i = A-1; i < C-1; i++) {
            if (!vec[i] && !vec[i+1]) {
                flag = true;
            }
        }
        for(ll i = B-1; i < D-1; i++) {
            if (!vec[i] && !vec[i+1]) {
                flag = true;
            }
        }
        if (flag) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();

	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
	return 0;
}

Measured memory_bytes: 384
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        board: [chars; 3],
    }
    println!("{}{}{}", board[0][0], board[1][1], board[2][2]);
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] n = Input.ScanIntArray();
          List<int[]> points = new List<int[]>();
          for(int i=0;i<n[0];i++){
              points.Add(Input.ScanIntArray());
          }

          int res = 0;
          for(int i=0;i<n[0]-1;i++){
              for(int k=i+1;k<n[0];k++){
                  if(Distance(points[i],points[k],n[1])) res++;
              }
          }
          
          Out(res);
        }

        static public bool Distance(int[] a, int[] b, int dim){
            int sum = 0;
            for(int i=0;i<dim;i++)
            sum += (a[i]-b[i])*(a[i]-b[i]);
            int r = (int)Math.Floor(Math.Sqrt((double)sum));
            return r*r == sum;
        }

        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int N = T.size();
    S += S;
    bool frag;
    for (int i = 0; i < N; i++){
        frag = true;
        for (int j = 0; j < N; j++){
            if (S[i+j] != T[j]) {
                frag = false;
            }
        }
        if (frag) {
            cout << "Yes" << endl;
            break;
        }
    }
    if (not frag) {
        cout << "No" << endl;
    }
}


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

int main(){
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double det = a*e-b*d;
		double x = 1/det*(c*e - b*f);
		double y = 1/det*(-c*d + a*f);	
        if(x == -0.0) x=0;
        if(y == -0.0) y=0;

		cout << fixed << setprecision(3) << x << ' ' << y <<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
string s,s2,s3;
cin>>s;
cin>>s2;
cin>>s3;
char ch1=s[0];
ch1=ch1-32;
char ch2=s2[0];
ch2=ch2-32;
char ch3=s3[0];
ch3=ch3-32;
cout<<ch1<<ch2<<ch3;
return 0;
}

Measured memory_bytes: 256
N,C = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
V = [0 for _ in range(N)]
Vm = [0 for _ in range(N)]
V[0] = A[0][1]-A[0][0]
Vm[0] = V[0]
for i in range(1,N):
    V[i] = V[i-1]+A[i][1]-(A[i][0]-A[i-1][0])
    Vm[i] = max(V[i],Vm[i-1])
U = [0 for _ in range(N)]
Um = [0 for _ in range(N)]
U[0] = A[-1][1]-(C-A[-1][0])
Um[0] = U[0]
for j in range(2,N+1):
    U[j-1] = U[j-2]+A[-j][1]-(A[-(j-1)][0]-A[-j][0])
    Um[j-1] = max(U[j-1],Um[j-2])
ans = V[N-1]
for i in range(N-1):
    ans = max(ans,V[i],V[i]-A[i][0]+Um[N-2-i])
ans = max(ans,U[N-1])
for j in range(N-1):
    ans = max(ans,U[j],U[j]-(C-A[-(j+1)][0])+Vm[N-2-j])
print(max(ans,0))

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++){
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++){
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;

//等差数列の和を求める(初項,項数,公差)
long long int arith_sum1(long long int a,long long int n,long long int d){
    return n*(2*a+(n-1)*d)/2;
}
//等差数列の和を求める(初項,末項,項数)
long long int arith_sum2(long long int a,long long int l,long long int n){
    return n*(a+l)/2;
}
//初項1，末項n，項数1の数列の和を求める
long long int series_sum(long long int n){
    return n*(n+1)/2;
}
//各桁の数の和を求める
template <typename T>
T digitsum(T n){
    string s=to_string(n);
    T sum=0;
    T d=1;
    for(T e=0;e<s.length();e++){
        sum+=(n/d)%10;d*=10;
    }
    return sum;
}
template <typename T>
bool isPrime(T n){
    if(n<=1)return false;
    if(n==2||n==3)return true;
    if(n%2==0||n%3==0)return false;
    for(T q=5;q*q<=n;q+=4){
        if(n%q==0)return false;
        q+=2;
        if(n%q==0)return false;
    }
    return true;
}
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    T tmp=0;
    if(n%2==0){
        tmp=0;while(n%2==0){tmp++;n/=2;}
        ret.push_back(make_pair(2, tmp));
    }
    if(n%3==0){
        tmp=0;while(n%3==0){tmp++;n/=3;}
        ret.push_back(make_pair(3, tmp));
    }
    for (T i=5;i*i<=n;i+=4) {
        if(n%i==0){
            tmp=0;while(n%i==0){tmp++;n/=i;}
            ret.push_back(make_pair(i,tmp));
        }
        i+=2;
        if(n%i==0){
            tmp=0;while(n%i==0){tmp++;n/=i;}
            ret.push_back(make_pair(i,tmp));
        }
    }
    if(n!=1)ret.push_back(make_pair(n,1));
    return ret;
}
long long int intpow(long long int x,long long int n){
    long long int ans=1;
    for(int i=0;i<n;i++){
        ans*=x;
    }
    return ans;
}
template <typename T>T intlog(T x){
    string a=to_string(x);
    return a.length()-1;
}
long long int combination(long long int a,long long int b){
    queue<long long int> bunsi,bunbo;
    long long int ans=1;
    b=min(b,a-b);
    for(int i=0;i<b;i++){
        bunsi.push(a-i);
        if(b-i>=2)bunbo.push(b-i);
    }
    while(bunsi.size()!=0||bunbo.size()!=0){
        ans*=bunsi.front();
        bunsi.pop();
        if(ans%bunbo.front()==0){
            ans/=bunbo.front();
            bunbo.pop();
        }
    }
    return ans;
}

int main(){
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ulli;

ulli pow(int n, int p){
  ulli res = 1;
  for (int i = 0; i < p; i++) {
    res *= n;
    if(res > 1e9) throw "error";
  }
  return res;
}


int main(int argc, char *argv[]){
  int n, t;
  string s;
  cin >> n >> t >> s;
  vector<int> p;
  for (int i = 2; i < s.length(); i+=4) {
    char tmp = s[i];
    p.push_back(atoi(&tmp));
  }
  ulli ans = 0;

  for (int i = 0; i < p.size(); i++) {
    try{
      ans += pow(n, p[i])*t;
      if(ans > 1e9)throw "error";
    }catch(const char* s){
      std::cout << "TLE" << std::endl;
      return 0;
    }
  }
  std::cout << ans << std::endl;

  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

template< typename T,typename L=T >
struct LazySegmentTree {
	using F=function< T(T,T) >;
	using G=function< T(T,L) >;
	using H=function< L(L,L) >;
	using P=function< L(L,int) >;

	int sz;
	vector<T> node;
	vector<L> lazy;
	const F f;
	const G g;
	const H h;
	const P p;
	const T NODE_INIT;
	const L LAZY_INIT;

	LazySegmentTree(int n,const F f,const G g,const H h,const P p,
					const T &NODE_INIT,const L &LAZY_INIT):
		f(f),g(g),h(h),p(p),NODE_INIT(NODE_INIT),LAZY_INIT(LAZY_INIT) {
		sz=1;
		while(sz<n) sz<<=1;
		node.assign(2*sz-1,NODE_INIT);
		lazy.assign(2*sz-1,LAZY_INIT);
	}

	void set(int k,const T &x) {
		node[k+sz-1]=x;
	}

	void build() {
		for(int i=sz-2;i>=0;i--) {
			node[i]=f(node[i*2+1],node[i*2+2]);
		}
	}

	void eval(int k,int len) {
		if(lazy[k]!=LAZY_INIT) {
			if(k<sz-1) {
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			node[k]=g(node[k],p(lazy[k],len));
			lazy[k]=LAZY_INIT;
		}
	}

	T update(int a,int b,const T &x,int k,int l,int r) {
		eval(k,r-l);
		if(r<=a||b<=l) return node[k];
		else if(a<=l&&r<=b) {
			lazy[k]=h(lazy[k],x);
			eval(k,r-l);
			return node[k];
		}
		else {
			eval(k,r-l);
			node[k]=f(update(a,b,x,2*k+1,l,(l+r)/2),update(a,b,x,2*k+2,(l+r)/2,r));
			return node[k];
		}
	}

	T update(int a,int b,const T &x) {
		return update(a,b,x,0,0,sz);
	}

	T query(int a,int b,int k,int l,int r) {
		eval(k,r-l);
		if(r<=a||b<=l) return NODE_INIT;
		else if(a<=l&&r<=b) return node[k];
		else return f(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
	}

	T query(int a,int b) {
		return query(a,b,0,0,sz);
	}

	void show() {
		for(int i=0;i<sz*2-1;i++) cout<<node[i]<<' ';
		cout<<endl;
	}
};


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

	auto add=[](ll a,ll b){ return a+b; };
	auto multiply=[](ll a,ll b){ return a*b; };

	int n,q;cin>>n>>q;
	LazySegmentTree<ll> tree(n,add,add,add,multiply,0,0);
	while(q--) {
		int type,s,t;ll x;
		cin>>type>>s>>t;
		s--,t--;
		if(type==0) {
			cin>>x;
			tree.update(s,t+1,x);
			//tree.show();
		}
		else {
			cout<<tree.query(s,t+1)<<endl;
			//tree.show();
		}
	}

	return 0;
}



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

using namespace std;

bool search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[10000 + 1], q, key, sum = 0;
  scanf("%d", &n);

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

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (search(A, n, key)) {
      sum++;
    }
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 3244
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b = map(int, input().split())

n = b - a

print(n*(n+1)//2 - b)




Measured memory_bytes: 9148
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, r;
  cin>>n>>r;
  if(n >= 10){
    cout<<r<<endl;
    return 0;
  }
  int ans = r + 100 * (10 - n);
  cout<<ans<<endl;
  return 0;
}


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

namespace abc_168_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();

            int b = Convert.ToInt32(a);

            int N = b % 10;

            if (N == 3)
            {
                Console.WriteLine("bon");
            }
            else if (N == 0 || N == 1 || N == 6 || N == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

            Console.Read();
        }
    }
}


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

const int MAXN = 1e5 + 100;
const int inf = 0x3f3f3f3f;
int n, k;
int a[MAXN], dp[MAXN];

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	memset(dp, 0x3f, sizeof dp);
	dp[1] = 0;
	dp[2] = abs(a[1] - a[2]);
	for(int i = 1; i < n; i++){
		for(int j = 1; j <= k; j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		}
	}
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		long[] number = new long[a];
		for(int i=0;i<a;i++) {
			number[i] = sc.nextLong();
		}
		long result = 0;
		result = number[0];
		boolean flag = true;
		for(int i=0;i<a;i++) {
			if(number[i] == 0) {
				System.out.println(0);
				return;
			}
		}
		
		for(int i=1;i<a;i++) {
			
			if(number[i] > 1000000000000000000l / result) {
				System.out.println(-1);
				flag = false;
				break;
			}else {
				result = result*number[i];
			}
			
		}
		
		if(flag == true) {
			System.out.println(result);
		}
		
		
			
		

	}

}


Measured memory_bytes: 61168