akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

void no(){
    cout << -1 << endl;
    exit(0);
}

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

    int n; cin >> n;

    vector<int> a(n), b(n);

    for (int j = 0; j < 2; ++j){
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        a.swap(b);
    }

    set<pii> s;

    for (int i = 0; i < n; ++i){
        s.insert(pii(-b[i], i));
    }

    int64 steps = 0;

    while (!s.empty()){
        auto x = *s.begin();
        s.erase(x);

        int v = -x.first;
        int p = x.second;

        if (v < a[p]){
            no();
        } else if (v == a[p]){
            continue;
        }

        int ri = b[(p - 1 + n) % n];
        int le = b[(p + 1) % n];
        int delta = ri + le;
        int k = (b[p] - a[p]) / delta;

        if (k <= 0) no();

        b[p] -= delta * k;
        steps += k;

        s.insert(pii(-b[p], p));
    }

    cout << steps << endl;

    return 0;
}

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

int main () {
  string S ;
  cin >> S ;
  int ans = 0 , ans1 = 0 ;
  char pre ;
  pre = S.at(0) ;
  for(int i = 1 ; i < S.size()  ; i++){
    if(S.at(i)==pre) {
      ans++ ;
      if(pre=='0') pre = '1' ;
      else pre = '0' ;
    }
    else {
      pre = S.at(i) ;
    }
  }
  reverse(S.begin(),S.end()) ;
  pre = S.at(0) ;
  for(int i = 1 ; i < S.size()  ; i++){
    if(S.at(i)==pre) {
      ans1++ ;
      if(pre=='0') pre = '1' ;
      else pre = '0' ;
    }
    else {
      pre = S.at(i) ;
    }
  }
  cout << min(ans,ans1) << endl ;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
using namespace std;
typedef long long ll;

int main(){
   
   int n;cin>>n;
   if(n<1200)cout<<"ABC";
   else if(n<2800)cout<<"ARC";
   else cout<<"AGC";
}

Measured memory_bytes: 256
/**********************************JAI SAI RAM*****************************************/
//HELP IN CODEFORCES ROUND 639 DIV 2
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef int ll;
ll MAX=1000000000;
ll MIN=-1*MAX;
const int sizes=200001;
const int BLK =800;
ll val[sizes];
vector<ll> adj[sizes];
ll ans[sizes];
ll vis[sizes];
ll segtree[5*sizes];
void update(ll idx,ll start,ll end,ll index,ll value)
{
      if(start>index||end<index||start>end)
      return;
      if(start==index&&end==start)
      {
          segtree[idx]=value;
      }
      if(start<end)
      {
         ll mid=(start+end)/2;
         update(2*idx+1,start,mid,index,value);
         update(2*idx+2,mid+1,end,index,value);
         segtree[idx]=max(segtree[2*idx+1],segtree[2*idx+2]); 
      }
}
ll query(ll idx,ll start,ll end,ll l,ll r)
{
           if(start>end)
           return 0;
           if(start>r||end<l)
           return 0;
           if(l<=start&&end<=r)
           {
               return segtree[idx];
           }
           ll mid=(start+end)/2;
           ll m1=query(2*idx+1,start,mid,l,r);
           ll m2=query(2*idx+2,mid+1,end,l,r);
           return max(m1,m2);
}
void dfs(ll src)
{
     vis[src]=1;
     ans[src]=query(1,0LL,(ll)sizes,0,val[src]-1)+1;
     ll prev=query(1,0LL,(ll)sizes,val[src],val[src]);
     update(1,0LL,(ll)sizes,val[src],ans[src]);// LIS ending at src was considered not above//
     ans[src]=segtree[1];
     for(ll i=0;i<adj[src].size();i++)
     {
         if(!vis[adj[src][i]])
             dfs(adj[src][i]);
     }
     update(1,0LL,(ll)sizes,val[src],prev);
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    memset(segtree,0,sizeof(segtree));memset(vis,0,sizeof(vis));
    ll i,j,k,l,m,n,o,p,q,r,s,t;
    cin>>n;
    set<ll> se;
    for(i=1;i<=n;i++)
    {
        cin>>val[i];
        se.insert(val[i]);
    }
     

    map<ll,ll> mp;
    k=1;
    for(auto it: se)
    {
        mp[it]=k;
        k++;
    }
    for(i=1;i<=n;i++)
    {
        val[i]=mp[val[i]];
    }
   // standard coordinatec compression

    for(i=0;i<n-1;i++)
    {
        cin>>j>>k;
        adj[j].push_back(k);
        adj[k].push_back(j);
    }
    dfs(1);
    for(i=1;i<=n;i++)
    cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef string str;

#define f(i, begin, end) for (auto i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(v) for (auto &x : v)
#define dis(v) trav(v) cout << x << " ";
#define deb(x) cerr << #x << ":" << x << "\n"
#define debv(v) trav(v) cerr << x << " ";
#define all(v) v.begin(), v.end()
#define nl cout << "\n"

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll a, b, n, m, i, j, k;
        str s1, s2;
        cin >> n;
        vector<ll> v(n);
        f(i, 0, n) cin >> v[i];
        k = -1;
        j = 0;
        f(i, 0, n)
        {
            if (v[i] == 1 && j == 0)
            {
                j = 1;
                k = 1;
            }
            else if (v[i] == j + 1)
            {
                ++k;
                ++j;
            }
        }
        if (k == -1)
            cout << k << "\n";
        else
            cout << n - k << "\n";
    }
    return 0;
}

Measured memory_bytes: 1792
H, W, D = map(int, input().split())

# W_max = (W)
fields = [0] * (W*H+1)
# 一列にして、保存しておこうか。
for i in range(H):
    rows = list(map(int, input().split()))
    for j,r in enumerate(rows):
        ind = i * W + j
        fields[r] = ind

def calc(l,r):
    indl = fields[l]
    hl = indl // W
    wl = indl % W
    indr = fields[r]
    hr = indr // W
    wr = indr % W
    d = abs(hl-hr) + abs(wl-wr)
    return d

# 累積
x = [[] for i in range(D)]  

for i in range(D):
    acc = 0
    x[i].append(0)
    for j in range(i, W*H+1, D):
        # print(j)
        acc += calc(j-D,j)
        x[i].append(acc)

# print(x)


### query
Q = int(input())
for _ in range(Q):
    L,R = map(int, input().split())
    amari = L%D
    print(x[amari][(R-amari)//D+1]-x[amari][(L-amari)//D+1])   

Measured memory_bytes: 66564
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

template<typename M, typename N>
istream& operator>>(istream&is, pair<M,N> & p){is >> p.fi >> p.se; return is;}
template<typename M>
istream& operator>>(istream&is, vector<M> & v){for(auto &it:v) is >> it; return is; }
template<typename M>
istream& operator>>(istream&is, vector<vector<M>> & v){for(auto &it:v) is >> it; return is; }
template<typename M, typename N>
ostream& operator<<(ostream&os, const pair<M,N> &p){os << p.fi << ' ' << p.se << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<M> &v){for(auto it: v)os << it << ' ';cout << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<vector<M>> &v){for(auto it: v)os << it;return os;}

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9;
//const int mod=1000000007;
const int mod=998244353;

int n,m,k;
const int N=2010;






int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    vll v(4);
    cin >> v[0] >> v[1] >> v[2] >> v[3];
    ll mx=-1e18;
    for(int i=0; i<2; i++){
        for(int j=2; j<4; j++){
            mx=max(v[i]*v[j],mx);
        }
    }
    cout << mx << el;
    return 0;
}







Measured memory_bytes: 3648
import math
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    op = sum(B) - sum(A)
    p = 0
    for i in range(N):
        if B[i] > A[i]:
            p += math.ceil((B[i] - A[i]) / 2)

    if p > op:
        print("No")
    else:

        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 10588
#include <stdio.h>

int main(void)
{
	int f;
	int i;
	int l, s, n;
	int b[10];
	int w, w2;
	int count;
	int num[4];
	
	while (scanf("%d", &n), n != 0){
		count = 0;
		f = 0;
		while (n != 6174){
			w = 1000;
			for (i = 0; i < 10; i++){
				b[i] = 0;
			}
			for (i = 0; i < 4; i++){
				num[i] = n / w;
				n %= w;
				w /= 10;
				b[num[i]]++;
			}
			
			w = 1000; w2 = 1;
			s = 0; l = 0;
			for (i = 0; i < 10; i++){
				while (b[i] > 0){
					s += i * w;
					w /= 10;
					l += i * w2;
					w2 *= 10;
					b[i]--;
				}
			}
			n = l - s;
			count++;
			if (n == 0){
				printf("NA\n");
				f = 1;
				break;
			}
		}
		if (f == 0){
			printf("%d\n", count);
		}
	}
	
	return (0);
}

Measured memory_bytes: 608
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class DIVERTA2019D
    {
        static public void Main(string[] args)
        {
            var N = NextLong;

            var ans = 0L;
            var cnt = 1;
            var sqrtN = Math.Sqrt(N);
            while (cnt < sqrtN)
            {
                var num = N / cnt;
                var num1 = (num - 1);
                if (N / num1 == N % num1)
                {
                    ans += num1;
                }
                ++cnt;
            }

            Console.WriteLine(ans);
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


Measured memory_bytes: 13268
import sys

s = input()
n = len(s)
center_num_pre = (n - 1) // 2

flag = "Yes"
for i in range(center_num_pre):
    #print("one")
    #print(s[i], s[(n - 1) - i])
    if s[i] != s[(n - 1) - i]:
        flag = "No"
        break

if flag == "No":
    print(flag)
    sys.exit()
    
for i in range(center_num_pre // 2):
    #print("two")
    #print(s[i], s[(center_num_pre - 1) - i])
    if s[i] != s[(center_num_pre - 1) - i]:
        #print("baka")
        flag = "No"
        break
    
if flag == "No":
    print(flag)
    sys.exit()
    
for i in range(center_num_pre // 2):
    #print("tree")
    #print(s[i],s[(n - 1) - i])
    if s[i] != s[(n - 1) - i]:
        flag = "No"
        break

if flag == "No":
    print(flag)
else:
    print(flag)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long v=n%1000;
    //cout<<v<<endl;
    if(v==0)
    {
        cout<<0<<endl;
    }
    else
        cout<<1000-v<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int H[100010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> H[i]; 
	}
	int dp[100010] = {}; 
	dp[2] = abs(H[2] - H[1]); 
	for(int i = 3; i <= N; i++){
		dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2])); 
	}
	cout << dp[N] << endl; 
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
        
int main(){
    ll x,y,z,n,m=0,k,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u1,u2;
    bool ok=true;
    cin >> n;
    VL a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    for(int i=n-1; i>=0; i--){
        if(a[i]!=0){
            a[i] += ans;
            if(i==0){
                if(a[i] > b[i]){
                    if(a[i]%b[i]!=0){
                        x = a[i]%b[i];
                        x = b[i]-x;
                        ans += x;
                    }
                }
                else if(a[i] < b[i]){
                    ans += b[i]-a[i];
                }
            }
            else {
                if(a[i] > b[i]){
                    if(a[i]%b[i]!=0){
                        x = a[i]%b[i];
                        x = b[i]-x;
                        ans += x;
                    }
                }
                else if(a[i] < b[i]){
                    ans += b[i]-a[i];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var m, n uint64

	fmt.Scan(&n, &m)
	edges := make([][]uint64, n)
	for i := uint64(0); i < m; i++ {
		var a, b uint64
		fmt.Scan(&a, &b)
		edges[a-1] = append(edges[a-1], b-1)
		edges[b-1] = append(edges[b-1], a-1)
	}

	fmt.Println(solve(edges))
}

func solve(edges [][]uint64) uint64 {
	cnt := uint64(0)

	for a := uint64(0); a < uint64(len(edges)); a++ {
		for _, b := range edges[a] {
			if a < b {
				if isBridge(a, b, edges) {
					cnt++
				}
			}
		}
	}

	return cnt
}

func isBridge(a uint64, b uint64, edges [][]uint64) bool {
	var q []uint64
	v := uint64(1) << a

	for _, c := range edges[a] {
		if c != b {
			q = append(q, c)
			v |= uint64(1) << c
		}
	}

	for len(q) > 0 {
		var c uint64
		c, q = q[0], q[1:]
		for _, d := range edges[c] {
			if d == b {
				return false
			}

			if (uint64(1)<<d)&v == 0 {
				q = append(q, d)
				v |= uint64(1) << d
			}
		}
	}

	return true
}


Measured memory_bytes: 512
// Problem : A - Divide a Cuboid
// Contest : AtCoder - AtCoder Grand Contest 004
// URL : https://atcoder.jp/contests/agc004/tasks/agc004_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll x=(a&1)?b*c:0;
    ll y=(b&1)?a*c:0;
    ll z=(c&1)?a*b:0;
    cout<<min(x,min(y,z));
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def low_func(array, value):
  ng = -1
  ok = len(array)
  #if value
  while ok - ng > 1:
    mid = (ok + ng)//2
    if array[mid] < value:
      ng = mid
    elif array[mid] >= value:
      ok = mid
  return ok

def up_func(array, value):
  ok = -1
  ng = len(array)
  #if value
  while abs(ok - ng) > 1:
    mid = (ok + ng)//2
    if array[mid] <= value:
      ok = mid
    elif array[mid] > value:
      ng = mid
  return ok

for b in B:
  a_idx = up_func(A, b - 1)
  if a_idx == -1:
    continue
  c_idx = low_func(C, b + 1)
  if c_idx == len(C):
    break
  ans += (a_idx + 1)*(len(C) - c_idx)
print(ans)

Measured memory_bytes: 23328
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
int n,k;
int L[10],R[10];
long long int ans[200005]={},ss[200005]={};
scanf("%d %d",&n,&k);
for(int i=0;i<k;i++)
{
	scanf("%d %d",&L[i],&R[i]);
}
ans[1]=ss[1]=1;
for(int i=2;i<=n;i++)
{
	for(int j=0;j<k;j++)
	{
		if(i-L[j]>=1)
		{
			if(i-R[j]<1){ans[i]+=ss[i-L[j]];}
			else{ans[i]=ans[i]+ss[i-L[j]]-ss[i-R[j]-1];}
		}
	ans[i] = (ans[i]+998244353)%998244353;
	}
	ans[i] %= 998244353;
	ss[i]=(ss[i-1]+ans[i])% 998244353;
}
printf("%lld",ans[n]);

}


Measured memory_bytes: 6956
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	cin>>s;
	int flag[26];
	int i;
	for (i=0;i<26;i++){
		flag[i]=0;
	}
	for (i=0;i<s.size();i++){
		flag[s[i]-'a']++;
	}
	for (i=0;i<26;i++){
		if (flag[i]>=2){
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> aList = new ArrayList<Integer>();
		while(scan.hasNext()){
			int t = scan.nextInt();
			if(t != 0){
				aList.add(t);
			}else{
				int size = aList.size();
				System.out.println(aList.get(size-1));
				aList.remove(size-1);
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>

using namespace std;
using int64 = long long;

vector<int64> _ryuka(90,-1);

int64 ryuka(int n) {
    if (_ryuka[n] != -1) return _ryuka[n];
    return _ryuka[n] = ryuka(n-1) + ryuka(n-2);
}


int main() {
    int n;
    cin >> n;
    _ryuka[0] = 2;
    _ryuka[1] = 1;

    cout << ryuka(n) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MIN(x,y) (((x)<(y))?(x):(y))

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


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

signed main(){
  int n,p[200000];  
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i];
  int c[200001]={},ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,c[p[i]]=c[p[i]-1]+1);
  }
  cout<<n-ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
object Main extends App {
  import scala.io.StdIn._


  val n = BigInt(readLine.trim)

  val half28 = (1 to 10).flatMap(digit ⇒ (0 until (1 << digit)).map(rank ⇒ make28(digit, rank))).filter(m ⇒ n % m == 0).toList

  println(solve(n, half28).let(i ⇒ if (i == 0) -1 else i))
  def solve(number: BigInt, factor: List[Long], count: Int = 0, max: Int = 0): Int = {
    if (number == 1) math.max(count, max)
    else {
      factor match {
        case Nil if number.is28 ⇒ math.max(count + 1, max)
        case Nil ⇒ max
        case h::t if number % h == 0 ⇒ solve(number, t, count, solve(number / h, factor, count + 1, max))
        case _::t ⇒ solve(number, t, count, max)
      }
    }
  }

  implicit class WrappedBigInt(val value: BigInt) extends AnyVal {
    def is28: Boolean = sub28(value)
    private[this] def sub28(value: BigInt): Boolean = {
      if (value == 0) true
      else (value % 10 == 8 || value % 10 == 2) && sub28(value / 10)
    }
  }

  def make28(digit: Int, rank: Int): Long = {
    (0 until digit).foldLeft(0){
      case (a, b) if ((1 << b) & rank) == 0 ⇒ a * 10 + 2
      case (a, _) ⇒ a * 10 + 8
    }
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


Measured memory_bytes: 97736
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	if((c-b)%2==0) {
		System.out.println("Alice");
	}
	else {
		System.out.println("Borys");
	}
	}
}


Measured memory_bytes: 23380
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n,m , sum , a , b;
double dp[3*mx3][3*mx3] , head[3*mx3] , tail[3*mx3] , ans;
string str;

 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n;
		fo(i,n)
		{
			cin>>head[i];
			tail[i]=1-head[i];
		}
		
		dp[0][n]=1;
		for(int i=n-1 ; i>=0 ; i--)
		{
			dp[0][i]=dp[0][i+1]*head[i];
			//cout << "0 " << i << " " << dp[0][i]<<"\n";
		}
		ans+=dp[0][0];
		for(int t=1 ; t<=n/2 ; t++)
		{
			dp[t][n-t]=dp[t-1][n-t+1]*tail[n-t];
			for(int pos = n-t-1 ; pos>=0 ; pos--)
			{
				dp[t][pos]=dp[t-1][pos+1]*tail[pos]+head[pos]*dp[t][pos+1];
			}
			ans+=dp[t][0];
			
		}
		
		cout<<fixed;
		cout<<setprecision(10)<<ans;
	}
	return 0;
}

Measured memory_bytes: 37120
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int A[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    cout << n * n * n;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<math.h>
#include<string.h>
ll ar1[5000005];
int main()
{
    ll a,b,c,d,test,i,j,k,l,m,o,p;
    cin>>a;
    ll n=0;
    c=1;
    for(i=1; i<=a; i++)
        cin>>ar1[i];
    n=0;
    for(i=1;i<=a;i++)
    {
        if(ar1[i]==c)c++;
        else n++;
    }
    if(a==n)printf("-1\n");
    else printf("%lld\n",n);
    return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int a1 = s[0] - '0';
  vector<int> a(3);
  REP(i,3) a[i] = s[i+1] - '0';
  
  int b;
  
  BREP(is,3){
    int sum = a1;
    REP(i,3){
      if((is>>i) & 1) sum += a[i];
      else sum -= a[i];
    }
    if(sum == 7) b = is;
  }
  
  cout << a1;
  REP(i,3){
    if((b>>i) & 1) cout << '+';
    else cout << '-';
    cout << a[i];
  }
  
  cout << "=7" << endl;
    

              
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin >> a>>b;
	if (a < b){
		cout << "a < b" << endl;
	}
	else if (a > b){
		cout << "a > b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#ABC128 B
from operator import itemgetter as ig
N = int(input())
S = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
    S[i], P[i] = (_ for _ in input().split())
SP = sorted([(i, S[i], int(P[i]))for i in range(N)], key = ig(2), reverse = True)
SP = sorted(SP, key = ig(1))
for i in range(N):
    print(SP[i][0] + 1)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int K;

	cin >> K;

	cout << (K/2) * ((K+1)/2) << endl;

	return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
cnt_5=0
cnt_7=0
for i in range(3):
  if a[i]==5:
    cnt_5=cnt_5+1
  elif a[i]==7:
    cnt_7=cnt_7+1

if cnt_5 == 2 and cnt_7 == 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
const ll M = 1e9+7;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
inline void add(ll &x,ll y){
    x += y;
    if(x>M) x-=M;
    if(x<0) x+=M;
}
ll qmul(ll a,ll b) {ll s=0;while(b){if(b&1)add(s,a);add(a,a);b>>=1;}return s; }
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=qmul(s,a);a=qmul(a,a);b>>=1;}return s; }
int n,a[3005],q,x,y;
ll f[3005][3005];

int main()
{
    fastio();
    cin>>n>>q;
    rep(i,1,n) cin>>a[i];
    rep(i,1,n) rep(j,1,n) f[i][j] = (a[i]>a[j]);
    ll inv2 = qpow(2,M-2);
    ll fc = qpow(2,q);
    while(q--){
        cin>>x>>y;
        rep(i,1,n){
            if(i!=x && i!=y){
                f[i][x] = f[i][y] = (f[i][x]+f[i][y])*inv2%M;
                f[x][i] = f[y][i] = (f[x][i]+f[y][i])*inv2%M;
            }
        }
        f[x][y] = f[y][x] = (f[x][y]+f[y][x])*inv2%M;
    }
    ll ans = 0;
    rep(i,1,n) rep(j,i+1,n) {
        add(ans, f[i][j]*fc%M);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 70656
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn a() {
    let (n, a, b) = read!(usize, usize, usize);
    println!("{}", min(n * a, b));
}

fn main() {
    a();
}


Measured memory_bytes: 4352
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n-1);
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    for (int i = 0; i < n; i++){
        cin >> B[i];
    }
    
    for (int i = 0; i < n-1; i++){
        cin >> C[i];
    }
    
    int sum = accumulate(B.begin(), B.end(), 0);
    
    for (int i = 0; i < n-1; i++){
        if(A[i+1] == A[i] + 1)sum += C[A[i]-1];
    }
    
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long int ll;

vector<int> g[100100];
map<int,pair<int,int>> mp;
map<pair<int,int>,int> ans;
int a[100100];

void dfs(int s,int p){
	int cnt=1;
	for(int q:g[s]){
		if(q==p)continue;
		if(cnt==a[s])cnt++;
		a[q]=cnt;
		ans[make_pair(min(s,q),max(s,q))]=cnt;
		dfs(q,s);
		cnt++;
	}
}


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	for(int i=0;i<n-1;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		if(x>y)swap(x,y);
		mp[i]=make_pair(x,y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	a[0]=0;
	dfs(0,-1);
	int ma=0;
	for(int i=0;i<n-1;i++){
		ma=max(ma,ans[mp[i]]);
	}
	cout << ma << endl;
	for(int i=0;i<n-1;i++){
		cout << ans[mp[i]] << endl;
	}
}

Measured memory_bytes: 18944
a, b, m = map(int, input().split())
lsa = list(map(int, input().split()))
lsb = list(map(int, input().split()))
cost = min(lsa) + min(lsb)
for i in range(m):
    x, y, c = map(int, input().split())
    cost2 = lsa[x - 1] + lsb[y - 1] - c
    if cost2 < cost:
        cost = cost2

print(cost)


Measured memory_bytes: 18612
#include<iostream>
#include<cstdio>
#define INF 1<<30
#define FinishFunction return 0
#define MAX 1000000
using namespace std;
        
struct edge {
  int from,to,cost,k;
};
      
edge es[MAX];
      
int main(){
  int n,u,k,E,c,v;
  E = 0;
  scanf("%d",&n);
      
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
         
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      es[E].from = u;
      es[E].to = v;
      es[E++].cost = c;
    }
  }
      
  // Ika berumanfo-do
  int d[MAX];
  for(int i=0;i<n;i++)d[i] = INF;
  d[0] = 0;
  while(true){
    bool update = false;
    for(int i=0;i<E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
    d[e.to] = d[e.from] + e.cost;
    update = true;
      }
    }
    if(!update)break;
  }
  for(int i=0;i<n;i++)cout << i << " " << d[i] << endl;
  FinishFunction;// return 0
}

Measured memory_bytes: 8700
#include <stdio.h>
#include <math.h>

int main(void){
	double r;
	int i;
	double area, circumference;
	
	scanf("%lf", &r);
	
	area = M_PI * pow(r, 2);
	circumference = 2 * M_PI * r;
	
	printf("%f %f\n", area, circumference);
	
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
/**
AHMAD;HASSAN;SAEED
*/
using namespace std;
bool isPrim(long long a){
    if(a==1ll)
        return false;
    for(long long i=2ll;i*i<=a;i++){
        if(a%i==0)
        return false;
    }
    return true;
}
int main()
{

    long long a;
    cin>>a;
    long long ans=0ll;
    long long tma=a;
    for(long long i=1ll;i*i<=tma;i++){

        if(isPrim(i)&&(a%i==0ll)){
            long long num=i;
            while(a%num==0){
                a/=num;
                ans++;
                num*=i;
            }
        }
        if(isPrim((tma/i))&&(a%(tma/i)==0ll)&&(a/i!=i)){
            long long num=(tma/i);
            while(a%num==0){
                a/=num;
                ans++;
                num*=(tma/i);
            }
        }
    }

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


Measured memory_bytes: 3640
n = gets.chomp.to_i
a1 = gets.chomp.split.map(&:to_i)
a2 = gets.chomp.split.map(&:to_i)

(1..(n-1)).each do |i|
  a1[i] = a1[i-1] + a1[i]
  a2[n-1-i] = a2[n-1-i] + a2[n-i]
end

max = 0
(0..(n-1)).each do |i|
  max = a1[i] + a2[i] if max < a1[i] + a2[i]
end

printf("%d\n",max)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define ci(n,a)   ll a[n]; rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main(int argc,char* argv[]) 
{
    auto pm = [](ll x) {return x/abs(x);};
    ll n,k,ans=INF;
    cin>>n>>k;
    ci(n,a);
    for(ll i=0;i+k-1<n;i++){
        ll l=a[i],r=a[i+k-1],x=abs(l),y=abs(r);
        if(l==0 || r==0) ans=min(ans,l+r);
        else if(pm(l)!=pm(r)) ans = min(ans,x+y+min(x,y));
        else ans = min(ans,max(x,y));
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
# from collections import Counter
INF = float("inf")


class MaxBit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s = max(s, self.tree[i])
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = max(self.tree[i], x)
            i += i & -i


class MinBit:
    def __init__(self, n):
        self.size = n
        self.tree = [n-1] * (n + 1)

    def sum(self, i):
        s = self.size-1
        while i > 0:
            s = min(s, self.tree[i])
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = min(self.tree[i], x)
            i += i & -i


def solve(N: int, P: "List[int]"):

    prev = MaxBit(N+2)
    foll = MinBit(N+2)
    seq = [0]*(N+2)

    inv = {p: i for i, p in enumerate(P)}
    # print(inv)
    # c = Counter()

    ans = 0
    for i in range(N, 0, -1):
        prev.add(inv[i]+2, inv[i]+1)
        foll.add(N-inv[i]+1, inv[i]+1)
        seq[inv[i]+1] = i

        # print("")
        # print("{}番目に{}を追加".format(inv[i]+1, i))
        # print("seq : ", seq)
        # print("prev: ", [prev.sum(j) for j in range(N+2)])
        # print("foll: ", [foll.sum(j) for j in range(N+2)][::-1])
        p = prev.sum(inv[i]+1)
        pp = prev.sum(p)
        f = foll.sum(N-inv[i])
        ff = foll.sum(N-f+1)
        # 前の数字との組み合わせ
        if p > 0:
            # (前、今) 前に伸ばす * 後ろに伸ばす
            ans += i*(p-pp)*(f-(inv[i]+1))
            # print("+ (A): ", i*(p-pp)*(f-(inv[i]+1)))
            # c[i] += (p - pp) * (f - (inv[i]+1))
        # 後ろの数字との組み合わせ
        if f < N+1:
            # (今、後) 前に伸ばす * 後に伸ばす
            ans += i*(inv[i]+1 - p) * (ff - f)
            # print("+ (B): ", i*(inv[i]+1 - p)*(ff-f))
            # c[i] += (ff - f) * ((inv[i]+1) - p)
    print(ans)
    # print([(i+1, c[i+1]) for i in range(N)])

    # guchoku = Counter()
    # for i in range(N):
    #     for j in range(i+1, N):
    #         guchoku[sorted(P[i:j+1])[-2]] += 1
    #         print(sorted(P[i:j+1])[-2], P[i:j+1])
    # print([(i+1, guchoku[i+1]) for i in range(N)])
    return


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
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int N=105;
ll a[N],inf=1e9+7;
int main() {
	int n,k;
  	cin>>n>>k;
  	for(int i=0;i<n;i++) {cin>>a[i];}
  	ll dp[k+1]={0};
  	dp[0]=1;
  	for(int i=0;i<n;i++) {
    	ll x[k+1];
      	x[0]=dp[0];
      	for(int j=1;j<=k;j++) {x[j]=(x[j-1]+dp[j])%inf;}
      	for(int j=0;j<=k;j++) {
        	if(j<=a[i]) {dp[j]=x[j];}
          	else {
            	dp[j]=(x[j]-x[j-a[i]-1]+inf)%inf;
            }
        }
    }
  cout<<dp[k]<<endl;
return 0;
}


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

class Program
{
	public static int Main(string[] args)
	{
        
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int i = int.Parse(str[1]);
        int answer = 0;

        answer = N + 1 - i;
        Console.WriteLine(answer);

		return 0;
	}
}


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

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

  for (int i = 0; i < s.size(); ++i)
    for (int j = i; j < s.size(); ++j) {
      if (s.substr(0, i) + s.substr(j, s.size() - j) == "keyence") {
        puts("YES");
        return 0;
      }
    }
  puts("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define int         long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl
const int INF = 1e12;
const int MOD = 1e9+7;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.x << ' ' << v.y; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.x << "=>" << i.y << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
 
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("jjj.txt", "w", stdout);
    #endif
}

const int N = 2e5+10;

void solve(){  

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int a1 = a*c;
    int a2 = a*d;
    int a3 = b*c;
    int a4 = b*d;


    cout << max({a1, a2, a3, a4}) << endl;

}              


int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,D;
    cin >> N >> D;
    ll i,j,k;
    ll X[N][D];
    for(i=0;i<N;i++){
        for(j=0;j<D;j++){
            cin >> X[i][j];
        }
    }
    ll tmp,a,ans=0;
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            tmp=0;
            for(k=0;k<D;k++){
                tmp+=pow(X[i][k]-X[j][k],2);
            }
             a=(int) sqrt(tmp);
             if(tmp==a*a)ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;

    vector<tuple<string, int, int>> data;

    for(int i=0; i<N; i++){
      string a;
      int b;
      cin >>a >>b;
      data.push_back(make_tuple(a, -b, i+1));
    }
    sort(data.begin(), data.end());
    
    for (tuple<string, int, int> t : data) {
      string s;
      int p, idx;
      tie(s, p, idx) = t;
      //cout << idx << " "<<s <<" "<< -p<< endl;
      cout << idx <<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 int main(){
    int i, j, k;
    int n, x;
    int count;
    while(1){
        scanf("%d %d ", &n, &x);
        if(n==0&&x==0)break;
        count=0;
        for(i=1;3*i+3<=x;i++){ 
           for(j=i+1;i+2*j+1<=x;j++){
                for(k=n;k>j;k--){ 
                   if(x==i+j+k){
                        count++;
                        break; 
                   }else if(x>=i+j+k){ 
                       break; 
                   } 
               }
            } 
       }  
      printf("%d\n", count);
    }  
  return 0;
 }


Measured memory_bytes: 2048
#include<stdio.h>

static const int N = 100000;

int isPrime(int x){
  int i;
  if ( x == 2 ) return 1;
  else   if ( x < 2 || x % 2 == 0) return 0;

  i = 3;
  while (i*i <= x){
    if ( x % i == 0 ) return 0;
    i = i + 2;
  }
  return 1;
}

  
int main(){
  int n, i, cnt;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  cnt=0;
  for (i = 1; i <= n; i++ ) {
    cnt +=isPrime(A[i]);
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    long long A,B;
    cin>>A;
    A--;
    cin>>B;

    long long sumA=0;
    long long sumB=0;

    bool Aeven=(A%2)==0;
    bool Beven=(B%2)==0;

    if(Aeven){
        sumA+=(A/2)%2+A;
    }else{
        sumA=((A+1)/2)%2;
    }
    if(Beven){
        sumB+=(B/2)%2+B;
    }else{
        sumB=((B+1)/2)%2;
    }
    long long ans=sumB^sumA;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
N,K = map(int,input().split())
tree_list = [int(input()) for _ in range(N)]
tree_list = sorted(tree_list)
ans = 10**9
for i in range(N-K+1):
    compare = tree_list[i+K-1]-tree_list[i]
    if ans > compare:
        ans = compare
print(ans)
    

Measured memory_bytes: 8280
#include <iostream>
#include <map>
#include <vector>
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
 
    int n, id; long long p, q;
    while (cin >> n && n) {
        map<int, int> ids;
        vector<pair<int, long long>> sum;
        for (int i=0; i<n; ++i) {
            cin >> id >> p >> q;
            if (ids.count(id)) {
                sum[ids[id]].second += p * q;
            } else {
                sum.push_back(make_pair(id, p * q));
                ids[id] = sum.size() - 1;
            }
        }
        bool na = true;
        for (auto x : sum) {
            if (1000000 <= x.second) {
                cout << x.first << endl;
                na = false;
            }
        }
        if (na) {
            cout << "NA" << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>

using namespace std;

int V[100];
int C[100];
int f[100];

int main()
{
    int n;

    cin>>n;

    for(int i=0;i<n;i++)
        cin>>V[i];
    for(int i=0;i<n;i++)
        cin>>C[i];
    for(int i=0;i<n;i++)
        f[i] = V[i] - C[i];
    int sum = 0;
    for(int i=0;i<n;i++)
        if(f[i]>0)
            sum = sum +f[i];
    cout<<sum;
}

Measured memory_bytes: 256