akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main {
    static int solve(int[] arr, int s, HashMap<Integer, Integer> map) {
        if(s >= arr.length - 1)
            return 0;
        if(map.containsKey(s))
            return map.get(s);
        
        int msum = Integer.MAX_VALUE;
        int i = s + 1;
        if(i < arr.length)
            msum = Math.min(msum, solve(arr, i, map) + Math.abs(arr[s] - arr[i]));
        i++;
        if(i < arr.length)
            msum = Math.min(msum, solve(arr, i, map) + Math.abs(arr[s] - arr[i]));
        
        map.put(s, msum);
        return msum;
    }
    public static void main(String args[]) {
        int n = 0;
        int[] arr = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            arr = new int[n];
            for (int i=0; i < n; i++) {
                arr[i] = scanner.nextInt();
            }
        }
        // System.out.println(Arrays.toString(arr));
        HashMap<Integer, Integer> map = new HashMap();
        int ret = solve(arr, 0, map);
        // System.out.println(map);
        System.out.println(ret);
    }
}

Measured memory_bytes: 83864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>vec[15];
int w[15];
int main(){
	cin>>n>>m;
	rep(i,m){
	int a; cin>>a;
	rep(j,a){
	int x; cin>>x; x--; vec[i].pb(x);
	}}
	rep(i,m)cin>>w[i];
	int ans=0;
	rep(i,(1<<n)){
		rep(j,m){
			int x=0;
			rep(k,vec[j].size()){
				int a = vec[j][k];
				if(((i>>a)&1)) x^=1;
			}
			if(x != w[j]) goto f;
		}
		ans++; f:;
	}
cout<<ans<<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

int n, m;
vector<pair<int, P>> G; // {cost, {vertex_1, vertex_2}}



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

    while(cin >> n >> m){
        if(n == 0 and m == 0) break;
    
        G.resize(m);

        for(int i = 0; i < m; i++){
            int a, b, cost;
            cin >> a >> b >> cost;
            G[i] = {cost, {a, b}};
        }

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

        UnionFind uf(n);

        int ans = 0;
        for(int i = 0; i < m; i++){
            pair<int, P> A = G[i];
            int c = A.first;
            int u = A.second.first;
            int v = A.second.second;
            if(uf.root(u) == uf.root(v)) continue;

            ans += c;
            uf.unite(u, v);
        }

        cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll n, s;
	cin >> n >> s;

	auto result = -1ll;

	if (n == s)
	{
		result = n + 1;
	}

	if (result < 0)
	{
		for (auto i = 2ll; i * i <= n; ++i)
		{
			auto temp = n;
			auto sum = 0ll;
			while (temp > 0)
			{
				sum += temp % i;
				temp /= i;
			}

			if (sum == s)
			{
				result = i;
				break;
			}
		}
	}

	if (result < 0)
	{
		for (auto i = (ll)sqrtf(n); i > 0; --i)
		{
			if ((n - s) % i != 0)
			{
				continue;
			}
			
			auto x = (n - s) / i + 1;
			if (x <= 1)
			{
				continue;
			}

			auto temp = n;
			auto sum = 0ll;
			while (temp > 0)
			{
				sum += temp % x;
				temp /= x;
			}

			if (sum == s)
			{
				result = x;
				break;
			}
		}
	}

	cout << result << endl;

	return 0;
}

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





typedef long long ll;
typedef long double ld;


ll a[2019];





int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll ans = 0;
    int n = s.size();
    int x = 1;
    int mod = 0;
    a[0] = 1;
    for(int i = n-1;i >= 0;i--){
    	mod = (x*(s[i]-'0') + mod) % 2019;
    	x = (x*10) % 2019;
    	a[mod]++;
	}
	for(int i = 0;i < 2019;i++){
		ans += (a[i]-1) * a[i] / 2;
	}
	cout<<ans<<endl;
    return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    bool echo = true;

    if (N % 2 != 0) cout << "No" << endl;
    else {
        for (int i = 0; i < (N / 2); i++){
            if(S.at(i) != S.at((N / 2) + i)) echo = false;
        }
    if (!echo)cout << "No" << endl;
    else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
#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 int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b;
  cout <<max(0,a-2*b);
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
  int a, b;
  scanf("%d", &a);
  
  b = (a+1)/2;
  b *= b;
  if ( a % 2 ) {
    b -= (a+1)/2;
  }
    
  
  printf("%d\n", b);
  return 0;
}

Measured memory_bytes: 128
'use strict';
function main(input) {
  const arr = input.trim().split(' ');
  const minimum = String(Math.min(arr[0], arr[1]));
  const maximum = Number(Math.max(arr[0], arr[1]));

  console.log(minimum.repeat(maximum));
}

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

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long double a,b, ans;
    cin>>a>>b;
    ans = a*b;
    ll x = (ans);
    cout<<x;

}   

Measured memory_bytes: 3748
import sys
import bisect
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w, n = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(int)
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        a -= 1
        b -= 1
        for j in range(max(1, a - 1), min(h-1, a + 2)):
            for k in range(max(1, b - 1), min(w-1, b + 2)):
                d[j, k] += 1
    ls = [0] * 10
    for k, v in sorted(d.items(), key=lambda x: x[1]):
        ls[v] += 1
    ls[0] = (h - 3 + 1) * (w - 3 + 1) - sum(ls)
    for i in range(10):
        print(ls[i])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 189996
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <iomanip>
#include <ctime>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <cassert>

#define el_cucuy ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount
#define pii pair <int, int>
#define f first
#define s second

const llong mxn = 4 * 1e5 + 3;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

llong n, a[21][21], k, dp[1 << 21], sum[mxn], cnt = 0;

int main (){
    cin >> n;
    for (int i = 0; i < n; i ++){
        for (int j = 0; j < n; j ++){
            cin >> a[i][j];
        }
    }dp[0] = 1;
    for (int mens = 0; mens < (1 << n); mens ++){
        llong free = bpc(mens);
        for(int j = 0; j < n; j ++){
            if(a[free][j] == 1 && !(mens & (1 << j))){
                dp[mens ^ (1 << j)] += dp[mens];
                dp[mens ^ (1 << j)] %= mod;
            }
        }
//        cout << i << ' ' << mask << ' ' << dp[i][mask] << endl;
    }cout << dp[(1 << n) - 1];
    return 0;
}



Measured memory_bytes: 17664
POWER = {
  "yotta" => 24,
  "zetta" => 21,
  "exa" => 18,
  "peta" => 15,
  "tera" => 12,
  "giga" => 9,
  "mega" => 6,
  "kilo" => 3,
  "hecto" => 2,
  "deca" => 1,
  "deci" => -1,
  "centi" => -2,
  "milli" => -3,
  "micro" => -6,
  "nano" => -9,
  "pico" => -12,
  "femto" => -15,
  "ato" => -18,
  "zepto" => -21,
  "yocto" => -24,
}

gets.to_i.times do
  case (line = gets.split).size
    when 3
      number, prefix, unit = line
    else
      number, unit = line
  end

  power = prefix ? POWER[prefix] : 0

  if number.include?(".")
    while(number[0] == "0")
      number.slice!(0)
      if number[0] == "."
        number[0], number[1] = number[1], number[0]
        power -= 1
      end
    end
  else
    number += "."
  end

  until (i = number.index(".")) == 1
    number[i], number[i - 1] = number[i - 1], number[i]
    power += 1
  end

  number.slice!(-1) if number[-1] == "."

  puts "#{number} * 10^#{power} #{unit}"
end

Measured memory_bytes: 6280
n = int(input())
const, target = (int(x) for x in input().split())
h_lst = list(map(int, input().split()))

infinity = float('inf')
min_i = -1
min_abs = infinity

for i in range(n):
    if abs(target - const + h_lst[i]*0.006) < min_abs:
        min_i = i
        min_abs = abs(target - const + h_lst[i]*0.006)
    else:
        pass
print(min_i + 1)


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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

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

int a, b;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    cout << a * b << '\n';
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int> >adj1,adj2;
map<int,int>mm;
int vis[200005];
int vis2[200005];
vector<int>comp;
int ans[200005];
int parent[200005];

void dfs(int ver)
{
    comp.push_back(ver);
    vis[ver]=1;
    for(auto i:adj1[ver])
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
}
vector<int>temp;


void dfs2(int ver,int dest)
{
    parent[ver]=dest;
    vis2[ver]=1;
    for(auto i:adj2[ver])
    {
        if(!vis2[i])
            dfs2(i,dest);
    }
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,k,l;
    cin>>n>>k>>l;
    int x,y;
    adj1.resize(n+1);
    adj2.resize(n+1);
    for(int i=0;i<k;i++)
    {
        cin>>x>>y;
        adj1[x].push_back(y);
        adj1[y].push_back(x);
    }
    for(int i=0;i<l;i++)
    {
        cin>>x>>y;
        adj2[x].push_back(y);
        adj2[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis2[i])
            dfs2(i,i);
    }

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            comp.clear();
            mm.clear();
            dfs(i);
            for(auto j:comp)
            {
                mm[parent[j]]++;
            }
            for(auto j:comp)
            {
                ans[j]=mm[parent[j]];
            }
        }
    }

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


} 



Measured memory_bytes: 26612
d,m=1e9+7,p[10001][200]={1};i,j,k,x,I;char s[11111];main(L){scanf("%s%d",s,&d);for(;j<2?:(j=0,++i<strlen(s));j++)for(L=j?9:s[i]-48,x=k=0;k<d?:(k=0,x++<L);k++)p[i+1][I=(j|x<L)*d+(k+x)%d]+=p[i][j*d+k],p[i+1][I]%=m;printf("%d",(*p[i]+p[i][d]-1+m)%m);}

Measured memory_bytes: 7936
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int


class DGraph:
    def __init__(self, n, edges):
        self._vertice = [{} for _ in range(n)]
        for e in edges:
            self._vertice[e[0]][e[1]] = e[2] if len(e) == 3 else 1

    def __len__(self):
        return len(self._vertice)

    def edges(self, n=None):
        srcs = range(len(self)) if n is None else [n]
        return sum([[(s, d, c) for d, c in self._vertice[s].items()] for s in srcs], [])

    def transpose(self):
        tedges = [(t, f, c) for f, t, c in self.edges()]
        return DGraph(len(self), tedges)

    def cost(self, src, dst):
        return self._vertice[src].get(dst, float('inf'))

class Graph(DGraph):
    def __init__(self, n, edges):
        nd_edges = edges + [(d, s, c) for s, d, c in edges]
        super().__init__(n, nd_edges)

    def transpose(self):
        return self


def perm_mod(n, m, M):
    ret = 1
    for i in range(n, n - m, -1):
        ret = (ret * i) % M
    return ret


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    es = [(ca-1, cb-1, 1) for ca, cb in zip(a, b)]
    g = Graph(N, es)

    ret = K
    visited = [False] * N
    q = deque([(0, K)])
    while 0 < len(q):
        cv, k = q.popleft()
        if visited[cv]:
            contains
        visited[cv] = True

        cs = [d for _, d, _ in g.edges(cv) if not visited[d]]
        ck = max(K - 2, k - 1)
        if 0 < len(cs):
            ret = (ret * perm_mod(ck, len(cs), MOD)) % MOD
        for c in cs:
            q.append((c, ck))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    result = solve(N, K, a, b)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 75844
#include<stdio.h>

int main(void){
    int h,w;
    int i,j;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}



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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll A, B, C, K;
  scanf("%lld %lld %lld %lld", &A, &B, &C, &K);

  ll ans = 0;

  ll k = K;

  if (k > 0) {
    ans += min(k, A);
    k -= min(k, A);
  }

  if (k > 0) {
    k -= min(k, B);
  }

  if (k > 0) {
    ans -= min(k, C);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<int> ans;

void solve(int N, int M) {
    int r; cin >> r;
    vector<vector<int>> imos(M+1, vector<int>(1261));
    for (int i = 0; i < r; i++) {
        int t, n, m, s; cin >> t >> n >> m >> s;
        if (s) imos[m][t]++;
        else imos[m][t]--; 
    }
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j < 1261; j++) {
            imos[i][j] += imos[i][j-1];
        }
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int s, e, m; cin >> s >> e >> m;
        int cnt = 0;
        for (int j = s; j < e; j++) {
            if (imos[m][j]) cnt++;
        }
        ans.push_back(cnt);
    }
}

int solve(int N) {
    int ret = 0;
    vector<vector<int>> field(N, vector<int>(6));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 5; j++) {
            cin >> field[i][j];
        }
        field[i][5] = 0;
    }

    int flag;
    do {
        flag = 0; 
        for (int i = N-1; i >= 0; i--) {
            int cnt = 1;
            for (int j = 1; j < 6; j++) {
                if (field[i][j] != 0 && field[i][j] == field[i][j-1]) {
                    cnt++;
                } else {
                    if (cnt >= 3) {
                        flag = 1;
                        ret += cnt * field[i][j-1];
                        for (int k = j-cnt; k < j; k++) {
                            field[i][k] = 0;
                        }
                    }
                    cnt = 1;
                }
            }
        }
        for (int k = 0; k < 10; k++) {
            for (int i = N-1; i >= 1; i--) {
                for (int j = 0; j < 5; j++) {
                    if (field[i][j] == 0) {
                        field[i][j] = field[i-1][j];
                        field[i-1][j] = 0;
                    }
                }
            }
        }
    } while (flag);
    return ret;
}

int main(void) {
    int N;
    vector<int> ans;
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}   


Measured memory_bytes: 3044
//ABC 064 A - RGB Cards
#include <iostream>

int main(void){
  int n,r,g,b;
  std::cin >> r >> g >> b;
  n = 100*r + 10*g + b;
  std::cout << ((n%4 == 0) ?"YES" :"NO" ) << std::endl;

  return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<usize> = get_vec();
    let h = v[0];
    let w = v[1];

    let mut mat : Vec<String> = Vec::new();
    mat.push(std::iter::repeat("#").take(w+2).collect::<String>());
    for _i in 0..h {
        let s : String = get_one();
        mat.push("#".to_owned() + &s + "#")
    }
    mat.push(std::iter::repeat("#").take(w+2).collect::<String>());
    for hi in mat.iter() {
        println!("{}", hi);
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> a(n);
  rep(i,n) {
    string S;
    int P;
    cin >> S >> P;
    a.at(i) = make_tuple(S,-1*P,i+1);
  }
  sort(a.begin(), a.end());
  for(auto b : a) {
    string x;
    int y, z;
    tie(x, y, z) = b;
    cout << z << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		
		a += b;
		int c = Integer.parseInt(a);
		if((double)Math.sqrt(c) == (int)Math.sqrt(c)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22228
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	l := iScan()
	r := iScan()
	d := iScan()
	ans := 0
	for i := 1; i < 1000; i++ {
		if d*i >= l && d*i <= r {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <stdio.h>

char s[1000000];

int main(void) {
	int i;
	if(scanf("%999999s",s)!=1)return 1;
	for(i=0;s[i]!=0;i++) {
		if(s[i+1]==s[i]) {
			printf("%d %d\n",i+1,i+2);
			return 0;
		} else if(s[i+2]==s[i]) {
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}

/*
同じ文字が2個連続→アンバランス
同じ文字が2個連続しない
→abaはアンバランス
abca、abcda、…はアンバランスでない
abcba→bcbがアンバランス
abcab→アンバランスでない
ababはアンバランスでない(abaがアンバランス)
同じ文字が2個連続しないとき、文字aを最も多くするには
a.a.a.a.a.a.a.a.a…となる(.は任意の1文字)
→a.aをとれば良い
.がa以外だと、この時aの数は半分または半分+0.5
→少しでもこのパターンから外れれば過半数にならない
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int solve(int* arr,int n,int k){
	int* dp = new int[n];
	dp[0] = 0;
	for(int i=1;i<n;i++){
		dp[i] = INT_MAX;
		for(int j=i-1;j>=(i-k)&&j>=0;j--){
			dp[i] = min(dp[i],(dp[j]+abs(arr[i]-arr[j])));
		}
	}
	int ans = dp[n-1];
	delete[] dp;
	return ans;
}
int main(){
	int n,k;
	cin >> n >> k;
	int* arr = new int[n];
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	cout << solve(arr,n,k) << "\n";
	delete[]arr;
}



Measured memory_bytes: 1024
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String str = s.next();
        String list = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
        List<Character> lists = new ArrayList<>();
        for (int i = 0; i < list.length(); i++)
            lists.add(list.charAt(i));
        List<Character> ans = new ArrayList<>();
        for (int i = 0; i < str.length(); i++)
            ans.add(str.charAt(i));
        for (int i = 0; i < ans.size(); i++)
            ans.set(i, (lists.get(lists.indexOf(ans.get(i)) + n)));
        for (int i = 0; i < ans.size(); i++)
            System.out.print(ans.get(i));
    }
}


Measured memory_bytes: 25684
def solve(n, a):
    for i in range(n):
        if a[i] % 2 == 0:
            if not 0 in [a[i] % 3, a[i] % 5]:
                return "DENIED"
    return "APPROVED"

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

Measured memory_bytes: 3060
<?php
    fscanf(STDIN, "%d %d %d %d %d %d", $a, $b, $c, $d, $e, $f);
    $ag = $a * 100;
    $bg = $b * 100;
    $a_max = intval($f / $ag);
    $b_max = intval($f / $bg);
    $c_max = intval(($f - min($ag, $bg)) / $c);
    $d_max = intval(($f - min($ag, $bg)) / $d);
    $solution_limit = $e / ($e + 100);
    $suger_limit = $f * $e / ($e + 100);
    $solution_max = -1;
    $weight_max = 0;
    $suger_max = 0;
    for ($i = 0; $i <= $a_max; $i++) {
        for ($j = 0; $j <= $b_max; $j++) {
            $water = $ag * $i + $bg * $j;
            if ($water == 0) { continue; }
            if ($water > $f) { break; }
            for ($k = 0; $k <= $c_max; $k++) {
                for ($l = 0; $l <= $d_max; $l++) {
                    if ($k == 0 && $l == 0 ) { continue; }
                    $suger = $c * $k + $d * $l;
                    $weight = $water + $suger;
                    if ($suger == 0) { continue; }
                    if (($weight > $f) || ($suger > $suger_limit)) { break; }
                    $solution = $suger / $weight;
                    if (($solution > $solution_max) && ($solution <= $solution_limit)) {
                        $solution_max = $solution;
                        $weight_max = $weight;
                        $suger_max = $suger;
                    }
                }
            }
        }
    }
    if ($solution_max == -1) {
        $weight_max = $ag * $a_max;
        $suger_max = 0;
    }
    echo $weight_max . " " . $suger_max . "\n";
?>


Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n;
int a[1000001];
int cmp(int x,int y){return x<y;}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+1+n,cmp);
cout<<a[n]-a[1];
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 10000
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;


int main(void) {
    ll n, m;
    cin >> n >> m;
    ll t, a, s[100001]={0};
    ll i, ans=0;
    map<ll, ll> map;
    set<ll> set;
    vector<ll> vec;
    for(i=1; i<=n; i++) {
        cin >> a;
        s[i]=s[i-1]+a;
        map[s[i]%m]++;
        set.insert(s[i]%m);
    }
    
    for(auto itr=set.begin(); itr!=set.end(); itr++) {
        t=map[*itr];
        ans+=t*(t-1)/2;
    }
    ans+=map[0];
    cout << ans << endl;
}


Measured memory_bytes: 7936
import math
A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, math.ceil(N**0.5)+1):
    Aflag = False
    Bflag = False
    if tA%i==0:
        Aflag = True
        while tA%i==0:
            tA //= i
    if tB%i==0:
        Bflag = True
        while tB%i==0:
            tB //= i
    if Aflag == True and Bflag == True:
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)

# print(prime)
print(len(prime)+1)

Measured memory_bytes: 3064
k = int(input())
li=[1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
print(li[k-1])

Measured memory_bytes: 9376
s = list(input())
count = 0
if s[0]==s[1]:
	count += 1
if s[0]==s[2]:
	count += 1
if s[0]==s[3]:
	count += 1
if s[1]==s[2]:
	count += 1
if s[1]==s[3]:
	count += 1
if s[2]==s[3]:
	count += 1
print("Yes" if len(set(s))==2 and count==2 else "No")


Measured memory_bytes: 3064
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const a = parseInt(args[1][0], 10)
	console.log(n * n - a)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21192
n,t=map(int,input().split())
A=[int(i) for i in input().split()]
A=A[::-1]
B,C=[0]*n,[0]*n
B[0]=A[0]
cur=A[0]
for i in range(1,n):
  cur=max(cur,A[i])
  B[i]+=cur
for i in range(n):
  C[i]=B[i]-A[i]
m=max(C)
ans=0
for i in range(n):
  if C[i]==m:
    ans+=1
print(ans)

Measured memory_bytes: 15828
#include <bits/stdc++.h>
using namespace std;
const int N=2000;
typedef long long ll;
typedef pair<ll,ll>lpa;
vector<ll>ve[5];
int main() {

    ll n,W,w1,w,v;
    cin>>n>>W;
    cin>>w1>>v;
    for(int i=0;i<=3;i++) ve[i].push_back(0);
    ve[w1-w1].push_back(v);
    for(int i=1;i<n;i++){
        cin>>w>>v;
        ve[w-w1].push_back(v);
    }
   // cout<<"3"<<endl;

    for(int i=0;i<=3;i++){
        sort(ve[i].begin()+1,ve[i].end(),greater<ll>());
    }

    //cout<<"3"<<endl;
    for(int i=0;i<=3;i++){
        for(int j=2;j<ve[i].size();j++){
             ve[i][j]=ve[i][j-1]+ve[i][j];
        }
    }
    ll ans=0;
    for(int i=0;i<ve[0].size();i++){
        for(int j=0;j<ve[1].size();j++){
            for(int r=0;r<ve[2].size();r++){
                for(int k=0;k<ve[3].size();k++){
                    if(i*w1+j*(w1+1)+r*(w1+2)+k*(w1+3)<=W)
                     ans=max(ans,ve[0][i]+ve[1][j]+ve[2][r]+ve[3][k]);

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




Measured memory_bytes: 3548
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

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

const int MOD = 1000000007;

signed main()
{
    int n;
    cin >> n;
    
    vi a(n+2), b(n+2);
    rep(i, n) cin >> a[i+1];
    rep(i, n) cin >> b[i+1];
    a[n+1] = a[n];
    b[0] = b[1];
    
    vi h(n+2, 0);
    rep(i, n){
        if(a[i+1] > a[i]) h[i+1] = a[i+1];
    }
    
    int m = 0;
    
    for(int i=n+1; i>0; --i){
        if(b[i-1] > b[i]){
            if(h[i-1] != 0 && h[i-1] != b[i-1]){
                cout << 0 << endl;
                return 0;
            }
            h[i-1] = b[i-1];
        }
        if(b[i] < m){
            cout << 0 << endl;
            return 0;
        }
        m = max(m, h[i-1]);
    }
    
    int ans = 1;
    reps(i, 1, n+1){
        if(h[i] == 0){
            ans = (ll(ans) * min(a[i], b[i])) % MOD;
        }
    }
    
    cout << ans << endl;
}


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

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    priority_queue<ll> diff;
    rep(i,n) {
        ll d = b[i]-a[i]; 
        if(d == 0) continue;
        diff.push(d);
    }
    ll cnt = 0;
    while(diff.size()>0 && diff.top() > 0){
        ll d = diff.top(); diff.pop();
        cnt += (d+1)/2;
        if(d&1){
            diff.push(-1);
        }
    }
    if(diff.size() == 0){
        cout<<"Yes"<<endl;
        return 0;
    }
    ll rem = 0;
    while(diff.size()>0){
        ll d = diff.top(); diff.pop();
        rem += -d;
    }
    if(cnt>=rem){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <vector>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    long long a[n][m];
    long long b[m][l];
    long long res[n][l];
    REP(i, n)
        REP(j, l)
            res[i][j] = 0;
    REP(i, n)
        REP(j, m)
            cin >> a[i][j];
    REP(i, m)
        REP(j, l)
            cin >> b[i][j];
    REP(i, n)
        REP(j, l)
            REP(k, m)
                res[i][j] += (a[i][k] * b[k][j]);

    REP(i, n){
        REP(j, l-1)
            cout << res[i][j] << " ";
        cout << res[i][l-1] << endl;
    }


    return 0;
}

Measured memory_bytes: 1396
def kukan(n, a):
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = a[i]
    for i in range(n - 2, -1, -1):
        g0 = dp[i]
        g1 = dp[i + 1]
        for j in range(i + 1, n):
            L = a[i] - g1[j]
            R = a[j] - g0[j - 1]
            dp[i][j] = L if L > R else R
    return dp[0][n - 1]


n = int(input())
a = list(map(int, input().split()))
print(kukan(n, a))

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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    bool ok=0;
    int n;
    cin >> n;

    for (int i=1; i<=9; ++i)
        for (int j=1; j<=9; ++j)
            if (i*j==n) {
                ok=1;
                break;
            }

    cout<<(ok?"Yes":"No")<<endl;
}



Measured memory_bytes: 256
char W[9],V[9];Z[8],S,N,T,P,M;main(){
	int i,j,k,l,r,d;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.10f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?2:1;
		d=24*60*(*W=='A'?1:7);
		if(*V=='A')for(i=0;i<l;i++)Z[i*4]=Z[i*4+1]=Z[i*4+2]=Z[i*4+3]=1;
		if(*V=='D')for(i=0;i<l;i++)Z[i*4+1]=Z[i*4+2]=1;
		if(*V=='N')for(i=0;i<l;i++)Z[i*4]=Z[i*4+3]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++){
			if(k+S<48*60)l+=Z[(k+S)%(48*60)/360]&Z[k/360];
			k=(k+T)%d;
		}
}exit(0);}

Measured memory_bytes: 692
A = []
for _ in range(3):
    a = list(map(int, input().split()))
    A.append(a)

import numpy as np
A = np.array(A)

N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))

ans = [[False] * 3 for _ in range(3)]
ans = np.array(ans)

for b in B:
    temp = (A == b)

    ans = np.logical_or(ans, temp)


if ans[0, :].all() or ans[1, :].all() or ans[2, :].all():
    print("Yes")

elif ans[:, 0].all() or ans[:, 1].all() or ans[:, 2].all():
    print("Yes")

elif ans[0, 0] and ans[1, 1] and ans[2, 2]:
    print("Yes")
elif ans[0, 2] and ans[1, 1] and ans[2, 0]:
    print("Yes")
else:
    print("No")




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

int main(){
 	long long n, a, b;
  	cin >> n >> a >> b;
  	if((a+b)%2==0){
     	cout << (b-a)/2 << endl;
    }
  	else{
     	cout << min(a-1,n-b)+1+(b-a-1)/2 << endl; 
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

const ll N_MAX = 200005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

    ll n, k;
    cin >> n >> k;

    ll ub = min(k, n-1);

    ll res = 0;

    for(int i=0;i<=ub;i++){
    	ll tmp = combination(n, i);
    	tmp *= combination(n-1, n-i-1);
    	tmp %= mod;
    	res += tmp;
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  long long answer = 0;
  for (int i = 0; i < (1 << (S.length()-1)); i++) {
    long long sum = 0;
    for (int j = 0; j < S.length(); j++) {
      sum *= 10;
      sum += S[j]-'0';
      if ((1 << j) & i || j == S.length()-1) {
        answer += sum;
        sum = 0;
      }
    }
  }
  cout << answer;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }
struct Edge {
	int from, to, cost;
	Edge(){}
	Edge(int from, int to, int cost) :from(from), to(to), cost(cost) {}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<Edge>edges(M);
	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		edges[i].from = a;
		edges[i].to = b;
		edges[i].cost = -c;
	}
	vector<int>d(N, INF);
	d[0] = 0;
	rep(i, 0, N - 1) {
		rep(j, 0, M) {
			Edge e(edges[j]);
			if (d[e.from] == INF)continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
	int ans = -d[N - 1];

	vector<int>neg(N, 0);
	rep(i, 0, N) {
		rep(j, 0, M) {
			Edge e(edges[j]);
			if (d[e.from] == INF)continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				neg[e.to] = 1;
			}

			if (neg[e.from])neg[e.to] = 1;
		}
	}
	if (neg[N - 1])cout << "inf" << endl;
	else cout << ans << endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	cout << accumulate(as.begin(), as.end(), 0) - n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char 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;}

int main() {
  int a, b;
  cin >> a >> b;
  int diff = b - a;
  ll  sum  = 0;
  for (int i = 1; i < 1000; i++) {
    sum += i;
    if (i == diff) {
      P(sum - b);
      break;
    }
  }
  return 0;
}



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

int main(){
    int n,d,counter=0;
    cin >> n >> d;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        if(pow(x,2) + pow(y,2) <= pow(d,2)){
            counter++;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 3644
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define ls(x) t[x].ls
#define rs(x) t[x].rs
#define mid (l+r>>1)
#define N 400010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct node{int ls,rs,mx;}; int poi;
void upd(int &x,int y){x=x<y?y:x;}
struct sgt
{
	int rt[N]; node t[N*20];
	void insert(int &x,int lt,int l,int r,int d,int v)
	{
		x=++poi; t[x]=t[lt]; t[x].mx=max(t[x].mx,v);
		if(l==r)	return;
		if(d<=mid)	insert(t[x].ls,t[lt].ls,l,mid,d,v);
		else	insert(t[x].rs,t[lt].rs,mid+1,r,d,v);
	}
	int query(int x,int l,int r,int LL,int RR)
	{
		if(!x)	return 0; if(l>=LL&&r<=RR)	return t[x].mx; int ans=0;
		if(LL<=mid)	upd(ans,query(t[x].ls,l,mid,LL,RR));
		if(RR>mid)	upd(ans,query(t[x].rs,mid+1,r,LL,RR));
		return ans;
	}
}T[2];
int suf[N],pre[2],mx[2],n,a[N],prx[N],remx[2];
bool check(int b,int x)
{
	int val=pre[b]-pre[b^1]+suf[x]; if(val<0)	return 0;
	return T[val&1].query(T[val&1].rt[x],1,n,mx[b^1]+1,n)>=val;
}
int ans[N];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)	a[i]=read(),prx[i]=max(prx[i-1],a[i]);
	for(int i=n;i;i--)	suf[i]=suf[i+1]+(prx[i]==a[i]);
	for(int i=n;i;i--)
	{
		int mx0=T[0].query(T[0].rt[i+1],1,n,a[i]+1,n),mx1=T[1].query(T[1].rt[i+1],1,n,a[i]+1,n);
		if(a[i]==prx[i])
		{
			T[0].insert(T[0].rt[i],T[0].rt[i+1],1,n,a[i],mx0+2); T[1].rt[i]=T[1].rt[i+1];
			if(mx1) T[1].insert(T[1].rt[i],T[1].rt[i+1],1,n,a[i],mx1+2);
		} 
		else
		{
			T[1].insert(T[1].rt[i],T[1].rt[i+1],1,n,a[i],mx0+1); T[0].rt[i]=T[0].rt[i+1];
			if(mx1)	T[0].insert(T[0].rt[i],T[0].rt[i+1],1,n,a[i],mx1+1);
		}
	}
	memset(ans,-1,sizeof(ans));
	for(int i=1;i<=n;i++)
	{
		remx[0]=mx[0],remx[1]=mx[1];
		for(int b=0;b<2;b++)
		{
			mx[b]=max(mx[b],a[i]),pre[b]+=(mx[b]==a[i]);
			if(check(0,i+1)||check(1,i+1)){ans[i]=b; break;}
			pre[b]-=(mx[b]==a[i]),mx[b]=remx[b];
		}
		if(ans[i]==-1)	return puts("-1"),0;
	}
	for(int i=1;i<=n;i++)	printf("%d",ans[i]); 
	return 0;
}

Measured memory_bytes: 188800
//“Do. Or do not. There is no try.” – Yoda
#include<iostream>
#include<limits.h>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
#include<vector>
#include<stdio.h>
#include<string>
#include<utility>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#include<fstream>
#include<stack>
#include<unordered_map>
using namespace std;
#define PI 3.14159265
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pid pair<int,double>
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define ld long double
#define ull unsigned long long
#define SIZE 10010
#define MOD 1000000007
#define BIG 999999937
#define pq priority_queue
#define maxpq priority_queue<int>
#define minpq priority_queue<int,vector<int>,greater<int> >
#define endl '\n'
#define FOI(i, a, n) for(int i = int(a); i <= int(n); i++)
#define FOD(i, a, n) for(int i = int(a); i >= int(n); i--)
#define ALL(t) t.begin(),t.end()
#define DBG(c) cout << #c << " = " << c << endl;
#define MSET(tabl,i) memset(tabl, i, sizeof(tabl))


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++) {
        x = r*x - d;
        cout<<x<<endl;
    }


    
}

Measured memory_bytes: 256