akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<int> solve(int n){
	vector<int> res;
	if(n == 3){
		res = {2, 5, 63};
	}
	else{
		rep(i,5000){
			int x = (3 * i + 1) * 2;
			if(x <= 30000) res.push_back(x);
			x = (3 * i + 2) * 2;
			if(x <= 30000) res.push_back(x);
			x = (4 * i + 1) * 3;
			if(x <= 30000) res.push_back(x);
			x = (4 * i + 3) * 3;
			if(x <= 30000) res.push_back(x);
			if(n - (int)res.size() <= 3){
				break;
			}
		}
		int m = n - res.size();
		for(int i = 1; i <= m; ++i){
			res.push_back(6 * i);
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> ans = solve(n);
	cout << ans[0];
	for(int i = 1; i < n; ++i){
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005
#define lim 10000
using namespace std;
 
typedef long long ll;

int n,temp;
string s;

int main()
{
	cin >> n;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
	{
		temp = s[i] - 'A';
		temp = (n + temp) % 26;
		s[i] = 'A' + temp;
	}
	cout << s;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+100;

int main()
{
    string s;
    cin >> s;
    ll n=s.length();
    rep(i,n){
        cout << 'x';
    }
    cout << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b&&b!=c)cout<<b<<endl;
    if(a!=b&&a!=c)cout<<a<<endl;
    if(a!=c&&b!=c)cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3664
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, '=7', sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, '=7', sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, '=7', sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, '=7', sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, '=7', sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, '=7', sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, '=7', sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, '=7', sep='')


Measured memory_bytes: 3064
using System;
using System.Linq;

class CinaRec
{
    static void Main()
    {
        var st = Console.ReadLine();
        int a = int.Parse(st.Split(' ')[0]);
        int b = int.Parse(st.Split(' ')[1]);
        int c = int.Parse(st.Split(' ')[2]);
        int d = int.Parse(st.Split(' ')[3]);
        int e = int.Parse(st.Split(' ')[4]);
        if (c + e <= a && e <= c)
        {
            if (d + e <= b && e <= d)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 19600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

bool checkStackPermutation(int ip[], int op[], int n) 
{ 
    // Input queue 
    queue<int> input; 
    for (int i=0;i<n;i++) 
        input.push(ip[i]); 
  
    // output queue 
    queue<int> output; 
    for (int i=0;i<n;i++) 
        output.push(op[i]); 
  
    // stack to be used for permutation 
    stack <int> tempStack; 
    while (!input.empty()) 
    { 
        int ele = input.front(); 
        input.pop(); 
        if (ele == output.front()) 
        { 
            output.pop(); 
            while (!tempStack.empty()) 
            { 
                if (tempStack.top() == output.front()) 
                { 
                    tempStack.pop(); 
                    output.pop(); 
                } 
                else
                    break; 
            } 
        } 
        else
            tempStack.push(ele); 
    } 
  
    // If after processing, both input queue and 
    // stack are empty then the input queue is 
    // permutable otherwise not. 
    return (input.empty()&&tempStack.empty()); 
} 

int main()
{
  fastio();

 
 int T;
T=1;
//cin>>T;
while(T--)
{
ll int n,i,k;
ll int s,w;
cin>>s>>w;
if(w>=s)
  cout<<"unsafe"<<endl;
else
  cout<<"safe"<<endl;

}

    return 0;
}

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

public class Hello{
    public static void Main(){
        List<Index> Indexes = new List<Index>();
        string InputData;
        string[] Data;
        
        while((InputData = Console.ReadLine()) != null){
            Data = InputData.Split(' ');
            string InputWord = Data[0];
            int AppearPage = int.Parse(Data[1]);
            
            if(Indexes.Count <= 0){
                Indexes.Add(new Index(InputWord, AppearPage));
            }
            else{
                int n = Indexes.FindIndex(item => item.Word == InputWord);
                if(n < 0){
                    Indexes.Add(new Index(InputWord, AppearPage));
                }
                else{
                    Indexes[n].AddPage(AppearPage);
                }
            }
        }
        Indexes.Sort((a, b) => String.Compare(a.Word, b.Word));
    
        for(int i = 0; i < Indexes.Count; i++){
            Indexes[i].Print();
        }
    }
}

public class Index
{
    public string Word{set;get;}
    public List<int> Pages{set;get;}
    
    public Index(string InputWord, int Page){
        Pages = new List<int>();
        
        Word = InputWord;
        Pages.Add(Page);
    }
    
    public void AddPage(int Page){
        Pages.Add(Page);
    }
    
    public void Print(){
        Pages.Sort((a, b) => a - b);
        Console.WriteLine(Word);
        Console.WriteLine(string.Join(" ", Pages.Select(x => x.ToString()).ToArray()));
    }
}

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

int main() {
	int n, a[10100], ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 380
import itertools
n = int(input())
alps = [chr(i) for i in range(97, 97+26)]
ans = {}
for al in alps:
    ans[al] = 10e9
for _ in range(n):
    temp  = input()
    for al in alps:
        co =  temp.count(al)
        if co < ans[al]:
            ans[al] = co
for al in alps:
    if ans[al] != 10e9:
        print(al * ans[al],end="")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    double x1, y1, x2, y2, x3, y3, xm1, ym1, xm2, ym2, xc, yc;
    cin >> n;
    while(n--){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        xm1=(x1+x2)/2.0;
        ym1=(y1+y2)/2.0;
        xm2=(x1+x3)/2.0;
        ym2=(y1+y3)/2.0;
        //cout << xm1 << " "<< ym1 << " " << xm2 << " " << ym2 <<"\n";
        if(y2==y1 && y3!=y1){
            double a2=-(x3-x1)/(y3-y1);
            xc=xm1;
            yc=a2*(xc-xm2)+ym2;
            double r=sqrt((x1-xc)*(x1-xc)+(y1-yc)*(y1-yc));
            printf("%.3f %.3f %.3f\n", xc, yc, r);
        }
        else if(y2!=y1 && y3==y1){
            double a1=-(x2-x1)/(y2-y1);
            xc=xm2;
            yc=a1*(xc-xm1)+ym1;
            double r=sqrt((x1-xc)*(x1-xc)+(y1-yc)*(y1-yc));
            printf("%.3f %.3f %.3f\n", xc, yc, r);
        }
        else{
            double a1=-(x2-x1)/(y2-y1);
            double a2=-(x3-x1)/(y3-y1);
            xc=(a1*xm1-a2*xm2-ym1+ym2)/(a1-a2);
            yc=a1*(xc-xm1)+ym1;
            double r=sqrt((x1-xc)*(x1-xc)+(y1-yc)*(y1-yc));
            printf("%.3f %.3f %.3f\n", xc, yc, r);
        }
    }
    
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int       long long
#define w(x)      int x;cin >> x;while (x--)
#define rep(d,a,n)  for(int d=a;d<=n;d++)
#define rep_(d,a,n)  for(int d=a;d>=n;d--)
#define nl        "\n" 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define oj  freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int inf=1e18;

void fun(){
    int a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a);
}
int32_t main()
{
   
    fast_io;
    fun();
    
    return 0;
}

Measured memory_bytes: 3544
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

p, q, r = wi()

print(min(p + q, r + q, p + r))

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

bool isEvenString(string s, int length){
  if(length%2 != 0) return false;
  for(int i = 0; i < length/2; i++){
    if(s[i] != s[i+length/2]) return false;
  }
  return true;
}

int main(void){
  string s;
  cin >> s;
  for(int i = 2; i < (int)s.length(); i += 2){
    if(isEvenString(s, s.length()-i)){
      cout << s.length()-i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Prison
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	sc.Split(bufio.ScanWords)

	var L, R int
	var l int = 0
	var r int = 100000
	//ans := make(map[int]int, N)
	var flag int
	for i := 0; i < M; i++ {
		L = nextInt()
		R = nextInt()
		if r < L || R < l {
			flag = 1
		}
		if l < L {
			l = L
		}
		if R < r {
			r = R
		}
		/*
			for j := L; j <= R; j++ {
				ans[j]++
			}
		*/
	}

	//fmt.Println(l, r)
	if flag == 0 && r-l+1 > 0 {
		fmt.Println(r - l + 1)
	} else {
		fmt.Println("0")
	}
}

/*
	var count int
	for _, v := range ans {
		if v == M {
			count++
		}
	}

	fmt.Println(count)
*/


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

int main() {
    int N;
    cin >> N;
    int A, B, C, D, E, F, G, H, Y;
    int a, b, c, d, e, f, g, h, y;
    A = N / 100000000;
    a = N % 100000000;
    B = a / 10000000;
    b = a % 10000000;
    C = b / 1000000;
    c = b % 1000000;
    D = c / 100000;
    d = c % 100000;
    E = d / 10000;
    e = d % 10000;
    F = e / 1000;
    f = e % 1000;
    G = f / 100;
    g = f % 100;
    H = g / 10;
    h = g % 10;
    Y = h / 1;
    y = h / 1;

    if (N % (A + B + C + D + E + F + G + H + Y) == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int a,b,n,count,ans,num,flag;
	while(1){
		count = 0;
		cin >> a >> b >> n;
		if(a == 0 && b == 0)break;
		num = a;
		while(1){
			flag = 0;
			if(count == n)break;
			if(num == 1){
				num += b;
				continue;
			}
			else if(num == 2){
				count++;
				ans = 2;
			}
			else if(num == 3){
				count++;
				ans = 3;
			}
			else if(num % 2 == 1){
				for(int i = 3;i <= sqrt(num);i+=2){
					if(num % i == 0)flag = 1;
				}
				if(flag == 0){
					count++;
					ans = num;
				}
			}
			num += b;
		}
		cout << ans <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void)
{
    char W[10], T[1000];
    int count=0, i;
 
    // 一回目の単語読み取り
    scanf("%s", W);
 
    // 二回目以降の単語読み取り、EOFが現れるまで読み取り続ける
    while(1){
        scanf("%s", T);
 
        if(strcmp(T, "END_OF_TEXT") == 0) {
            break;
        }
        
        for(i = 0; T[i] != '\0'; i++){
            T[i] = tolower(T[i]);
        }
        if(strcmp(T, W) == 0) {
            count++;
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int h,w,n;
    cin>>h>>w>>n;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    int masu[h][w];
    rep(i,h){rep(j,w){masu[i][j]=0;}}

   int p = 0;


    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                if(v[p]==0){
                    p++;
                    v[p]--;
                    masu[i][j]=p+1;
                }else{
                    v[p]--;
                    masu[i][j]=p+1;
                }
            }

        }else{
            for(int j=w-1;j>=0;j--) {
                if(v[p]==0){
                    p++;
                    v[p]--;
                    masu[i][j]=p+1;
                }else{
                    v[p]--;
                    masu[i][j]=p+1;
                }
            }
        }
    }

    rep(i,h){
        rep(j,w){
            cout<<masu[i][j]<<" ";
        }
        cout<<endl;
    }







    return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict,Counter
def dfs(ans, cnts):
    L = []
    d = defaultdict(list)
    heads = defaultdict(int)
    for s,c in cnts:
        if len(s)==1:
            L.append(s[0])
        else:
            for k,v in c.items():
                if v>0:
                    heads[k] += 1
            t = s[-1]
            c[t] -= 1
            s.pop()
            d[t].append([s,c])
    for h in L:
        ans += heads[h]
    for v in d.values():
        if len(v)<=1:
            continue
        ans = dfs(ans, v)
    return ans

N = int(input())
S = [list(input()) for _ in range(N)]
cnts = []
for s in S:
    cnts.append([s,Counter(s)])
ans = dfs(0, cnts)
print(ans)

Measured memory_bytes: 273716
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
            String s = sc.nextLine();
            String p = sc.nextLine();

            int slen = s.length();
            int plen = p.length();
            int j = 0,i;
            for( i = 0; i<slen; i++ ) {
                if( p.charAt( 0 ) == s.charAt( i ) ) {
                    int k = i;
                    for( j = 0; j<plen; j++ ) {
                        k = ( i+j ) % slen;
                        if( p.charAt( j ) != s.charAt( k ) ) break;
                    }
                }
                if( plen == j ) break;
            }

            if( plen == j ) {
                System.out.println( "Yes" );            
            } else {
                System.out.println( "No" );
            }
    }
}


Measured memory_bytes: 26300
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll temp;
    ll c=0,d=0;
    for(int i=0;i<3;i++)
    {
        cin>>temp;
    if(temp==5)
    c++;
    else if(temp==7)
    d++;
    }
    if(c==2 && d==1)
    cout<<"YES";
    else
    cout<<"NO";


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;

public class Main{
  static final long INF = Long.MAX_VALUE / 2;
  static int n;
  static long k;
  static int[] a;

  static final boolean DEBUG = false;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    k = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    long[] b = new long[n + 1];
    for(int i = 1; i <= n; i++){
      b[i] = b[i - 1] + a[i - 1] - k;
    }

    if(DEBUG){
      System.out.println(Arrays.toString(b));
    }

    long sum = 0;
    for(int i = 1; i <= n; i++){
      if(b[i] >= 0){
        ++sum;
      }
    }

    if(DEBUG){
      System.out.println("sum = " + sum);
    }

    long[] c = Arrays.copyOf(b, b.length);

    Arrays.sort(b, 1, n + 1);

    Map< Long, Integer > map = new HashMap< >();
    int count = 1;
    for(int i = 1; i <= n; i++){
      if(b[i - 1] != b[i]){
        ++count;
      }
      map.put(b[i], count);
    }

    for(int i = 1; i <= n; i++){
      b[i] = map.get(c[i]);
    }

    if(DEBUG){
      System.out.println(Arrays.toString(b));
    }

    if(DEBUG){
      for(int i = 1; i <= n; i++){
        assert 0 < b[i];
        assert b[i] <= n;
      }
      System.out.println(Arrays.toString(b));
    }

    long diff = 0;
    BinaryIndexedTree bit = new BinaryIndexedTree(n + 2);
    for(int i = 1; i <= n; i++){
      sum += bit.sum((int)(b[i] + 0));
      if(DEBUG){
        diff += bit.sum((int)(b[i] + 1));
        System.out.println("diff = " + diff);
      }
      bit.add((int)b[i], 1);
      if(DEBUG){
        System.out.println("sum = " + sum);
      }
    }

    if(DEBUG){
      System.out.println("diff = " + diff);
    }

    System.out.println(sum);
  }
}

class BinaryIndexedTree {
  int n;
  long[] bit;

  BinaryIndexedTree(int n){
    this.n = n;
    this.bit = new long[n + 1];
  }

  long sum(int i){
    long s = 0;
    while(i > 0){
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, long x){
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }
}


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

int main() {
  int64_t x,a,b,A=0;
  cin>>x;
  for(int64_t i=-120;i<=120;i++){
    for(int64_t j=-120;j<i;j++){
      int64_t p=i*i*i*i*i;
      int64_t q=j*j*j*j*j;
      if(p-q<x){
        break;
      }
      if(p-q==x){
        a=i,b=j;
        A++;
        break;
      }
    }
    if(A==1){
      break;
    }
  }
  cout<<a<<" "<<b<<endl;
      
}



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

int main() {
	int N;
  	cin >> N;
  
  	int copy = N;
  
  	int rest = 0;
  	for(int i = 0; i <= 8; i++) {
    	rest += copy % 10;
      	copy /= 10;
    }
  
  	if(N % rest == 0) {
    	cout << "Yes" << endl;
    }else {
    	cout << "No" << endl;
    }
}

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

int n, k;
int a[505];

bool test(int x) {
    int           v = 0;
    multiset<int> s;
    for (int i = 1; i <= n; i++) {
        if (a[i] % x)
            s.insert(a[i] % x);
    }
    while (s.size()) {
        // cout << s.size() << endl;
        auto it1 = s.begin();
        auto it2 = s.end();
        --it2;
        int v1 = *it1, v2 = *it2;
        // printf("%d: %d, %d\n", x, v1, v2);
        int d = min(v1, x - v2);
        s.erase(it2);
        s.erase(s.begin());
        v1 -= d, v2 += d;
        v += d;
        if (v1 != 0)
            s.insert(v1);
        if (v2 != x)
            s.insert(v2);
        // printf("%d, %d\n", v1, v2);
    }
    // printf("%d: %d, RT %d\n", x, v, v <= k);
    return v <= k;
}

int main() {
    int sum = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 1;
    for (int i = 1; i * i <= sum; i++) {
        ll cost = 0;
        if (sum % i == 0) {
            if (test(i))
                ans = max(ans, i);
            if (test(sum / i))
                ans = max(ans, sum / i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = input()
    a = 0
    b = 0
    while(a < 15):
        b = 0
        while(b < 26):
            if(7 * a + 4 * b == n):
                print 'Yes'
                quit()
            b += 1
        a += 1
    print 'No'


Measured memory_bytes: 2568
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  ll n = s.size();


  vector<ll> d1 (n);
  ll l=0, r=-1;
  for (ll i=0; i<n; ++i) {
    ll k = i>r ? 1 : min (d1[l+r-i], r-i+1);
    while (i+k < n && i-k >= 0 && s[i+k] == s[i-k])  ++k;
    d1[i] = k;
    if (i+k-1 > r)
      l = i-k+1,  r = i+k-1;
  }

  vector<ll> d2 (n);
  l=0, r=-1;
  for (ll i=0; i<n; ++i) {
    ll k = i>r ? 0 : min (d2[l+r-i+1], r-i+1);
    while (i+k < n && i-k-1 >= 0 && s[i+k] == s[i-k-1])  ++k;
    d2[i] = k;
    if (i+k-1 > r)
      l = i-k,  r = i+k-1;
  }

  ll num = accumulate(d1.begin(), d1.end(), 0LL);
  num += accumulate(d2.begin(), d2.end(), 0LL);

  ll result = n * (n + 1) / 2;
  if (num > 1) result -= num - 1;

  vector<ll> letters(26);
  for (char c : s) letters[c - 'a']++;
  ll num2 = 0;
  for (ll l : letters) num2 += l * (l - 1) / 2;

  result -= num2;

  for (ll x : d1) result += x - 1;
  for (ll x : d2) result += x;

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3716
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int ans = (a + b) * h / 2;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

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

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

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

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

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

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

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


Measured memory_bytes: 21844
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let w:Vec<i32> = (0..n).map(|_| read()).collect();
    let mut ans = 1000;
    for i in 0..n {
        let first:i32 = w[0..i].iter().sum();
        let second:i32 = w[i..n].iter().sum();
        ans = min(ans, (first - second).abs());
    }
    println!("{}", ans);
}

Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define siz 10000000

char buf[siz], *bit = buf;

inline int nextInt(void) {
	register int ret = 0;
	register int neg = false;

	for (; *bit < '0'; ++bit)
		if (*bit == '-')neg ^= true;

	for (; *bit >= '0'; ++bit)
		ret = ret * 10 + *bit - '0';

	return neg ? -ret : ret;
}

#define inf 2147483647

int n, m;

int tag[400005];

int find(int t, int l, int r, int p) {
	if (~tag[t])
		return tag[t];
	int mid = (l + r) >> 1;
	if (p <= mid)
		return find(t << 1, l, mid, p);
	else
		return find(t << 1 | 1, mid + 1, r, p);
}

void update(int t, int l, int r, int x, int y, int k) {
	if (l == x && r == y)
		tag[t] = k;
	else {
		int mid = (l + r) >> 1;
		if (~tag[t])
			tag[t << 1] = tag[t << 1 | 1] = tag[t], tag[t] = -1;
		if (y <= mid)
			update(t << 1, l, mid, x, y, k);
		else if (x > mid)
			update(t << 1 | 1, mid + 1, r, x, y, k);
		else {
			update(t << 1, l, mid, x, mid, k);
			update(t << 1 | 1, mid + 1, r, mid + 1, y, k);
		}
	}
}

signed main(void) {
	fread(buf, 1, siz, stdin);

	n = nextInt();
	m = nextInt();

	for (int i = 0; i < (n << 2); ++i)
		tag[i] = inf;

	for (int i = 1; i <= m; ++i) {
		int c = nextInt();
		if (c)	// find(x)
			printf("%d\n", find(1, 1, n, nextInt() + 1));
		else {
			int x = nextInt();
			int y = nextInt();
			int k = nextInt();
			update(1, 1, n, x + 1, y + 1, k);
		}
	}

	//system("pause");
}

Measured memory_bytes: 5740
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,a[200000],ans=0,minv=INF;
int x=0,sum=0;
bool z=false;
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int lcm(int x,int y){
    int n=gcd(x,y);
    return (x/n)*y;
}
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        minv=min(minv,abs(a[i]));
        if(a[i]<0)x++;
        if(a[i]==0)z=true;
        sum+=abs(a[i]);
    }
    if(x%2==0||z==true)cout<<sum<<endl;
    else cout<<sum-minv*2<<endl;
    return 0;
}

Measured memory_bytes: 1024
/*
 * 16-07-09_AGC017_A.cpp
 *
 *  Created on: 2017/07/09
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

int N,P;
int A[60];
int odd,even;
int main(){
	cin >> N >>P;
	for(int i=0;i<N;i++){
		cin >> A[i];
		if(A[i]%2==0){
			even++;
		}
		else{
			odd++;
		}
	}
	long long ans=(1ll<<even);
	if(P==0){
		if(odd>0){
			ans *= 1ll<<(odd-1);
		}
		cout << ans<<endl;
	}
	else{
		ans *= ((odd>0)? (1ll<<(odd-1)):0);
		cout <<ans<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int h, w;
	static char[][] fruitFarm;
	static int[] dx = {-1, 0, 1, 0};
	static int[] dy = {0, -1, 0, 1};
	static Deque<int[]> stack;
	
	public static void main(String args[]){
		while (true) {
			h = sc.nextInt();
			w = sc.nextInt();
			if (h == 0 && w == 0) break;
			fruitFarm = new char[h][w];
			for (int i = 0; i < h; i++) {
				String s = sc.next();
				for (int j = 0; j < w; j++) {
					fruitFarm[i][j] = s.charAt(j);
				}
			}
			int answer = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (fruitFarm[i][j] != '.') {
						stack = new ArrayDeque<int[]>();
						stack.offer(new int[]{i, j});
						while (!stack.isEmpty()) {
							int xy[] = stack.poll();
							int x = xy[0];
							int y = xy[1];
							dfs(x, y);
						}
						answer++;
					}
				}
			}
			System.out.println(answer);
		}
	}
	
	static void dfs(int x, int y) {
		char target = fruitFarm[x][y];
		fruitFarm[x][y] = '.';
		for (int k = 0; k < 4; k++) {
			int nx = x + dx[k];
			int ny = y + dy[k];
			if (target != '.' && nx >= 0 && nx <= h - 1 && ny >= 0 && ny <= w - 1 && fruitFarm[nx][ny] == target) {
				stack.offer(new int[]{nx, ny});
			}
		}
	}
}


Measured memory_bytes: 25072
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N + 6);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int ans = 0;
 // int A = 0;
 // int B = 0;
  for(int i = 0;i < N; i += 2){
      ans += vec.at(i);
   }
  for(int i = 1; i < N; i += 2){
      ans -= vec.at(i);
  }
//  ans = A - B;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2550;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    string t = "FESTIVAL";
    for (int i = 0; i < s.length() - t.length(); i++) cout << s[i];
}


Measured memory_bytes: 256
s = input()
k = int(input())
count = []
now = 1
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        now += 1
    else:
        count.append(now)
        now = 1
count.append(now)
if len(count) == 1:
    ans = (count[0] * k) // 2
else:
    if s[0] == s[-1]:
        temp = 0
        for i in count:
            temp += i // 2
        ans = (temp * k) - ((count[0] // 2) + (count[-1] // 2)  - ((count[0] + count[-1]) // 2)) * (k - 1)
    else:
        ans = sum([c // 2 for c in count]) * k
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<int> h(N);
    for (auto &hi: h) cin >> hi;

    vector<int> dp(N, INF);
    dp[0] = 0;
    for (size_t i = 0; i < N; ++i) {
        for (size_t j = 1; j <= 2; ++j) {
            if (i + j < N) {
                chmin(dp[i + j], abs(h[i + j] - h[i]) + dp[i]);
            }
        }
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    if(n%2==1){
        cout << n/2 + 1 << endl;
    }else{
        cout << n/2 << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int H, W;
int c[10][10];
vector<P> G[20]; // cost, to

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

	cin >> H >> W;

	for (int i = 0;i < 10;i++){
		for (int j = 0;j < 10;j++){
			cin >> c[i][j];
			G[j].push_back(P(c[i][j], i));
		}
	}

	int dist[10]; fill(dist,dist+10,INT_MAX);
	priority_queue<P, vector<P>, greater<P> > que; // dist, node
	que.push(P(0,1));
	dist[1] = 0;

	while(que.size()){
		P p = que.top(); que.pop();
		int d = p.first; int from = p.second;
		if(dist[from] < d ) continue;
		for (int i = 0;i < G[from].size();i++){
			int to = G[from][i].second;
			int cost = G[from][i].first;
			if(dist[to] > d+cost){
				dist[to] = d+cost;
				que.push(P(d+cost, to));
			}
		}
	}

	int ans = 0;

	for (int i = 0;i < H;i++){
		for (int j = 0;j < W;j++){
			int A; cin >> A;
			if(A == -1) continue;
			ans += dist[A];
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

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

	ll x; cin >> x;
	ll i = 1;
	while(i*(i+1)/2 < x) i++;
	cout << i << endl;
}



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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int W,H;
char data[30][30];
bool come[30][30];
int human_h,human_w;

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

int canGo(int w,int h){
	if(w < 0 || h < 0 || w >= W || h >= H) return 0;
	if(data[h][w] == '#') return 0;
	if(come[h][w]) return 0;
	come[h][w] = true;
	int ret = 1;
	ret += canGo(w+1,h);
	ret += canGo(w-1,h);
	ret += canGo(w,h+1);
	ret += canGo(w,h-1);
	return ret;
}

signed main(){
	// your code goes here
	while(true){
		W=read(),H=read();
		if(W==0 || H==0) break;
		REP(i,H){
			REP(j,W){
				come[i][j] = false;
				cin >> data[i][j];
				if(data[i][j] == '@'){
					human_h = i;
					human_w = j;
				}
			}
		}
		cout <<	canGo(human_w,human_h) << endl;
	}

}

Measured memory_bytes: 3236
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        string ss;
        int x, y;

        while ((ss = Console.ReadLine()) != "0 0")
        {
            x = ss.Split().Select(int.Parse).ToArray()[0];
            y = ss.Split().Select(int.Parse).ToArray()[1];

            Console.WriteLine(x < y ? x + " " + y : y + " " + x);
        }
    }
}


Measured memory_bytes: 16156
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N-1,0);
    vector<ll> b(N-1,0);
    for(ll i=0;i<N-1;++i){cin>>a[i]>>b[i];a[i]--;b[i]--;}
    vector<vector<ll>> G(N, vector<ll>(0));
    for(ll i=0;i<N-1;++i){
        G[a[i]].emplace_back(b[i]);
        G[b[i]].emplace_back(a[i]);
    }
    vector<ll> c(N,0);
    for(ll i=0;i<N;++i)cin>>c[i];
    sort(c.rbegin(), c.rend());
    vector<ll> vec(N,0);
    vector<ll> check(N,0);
    check[0]=1;
    queue<ll> que;
    que.emplace(0);
    ll now=0;
    while(!que.empty()){
        ll x=que.front();
        que.pop();
        vec[x]=c[now];
        now++;
        for(auto p: G[x]){
            if(!check[p]){
                check[p]=1;
                que.emplace(p);
            }
        }
    }
    ll sum=0;
    for(ll i=0;i<N;++i)sum+=c[i];
    prt(sum-c[0]);
    for(ll i=0;i<N;++i)cout<<vec[i]<<" ";cout<<endl;fl

    

    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
  public static void main(String[] args ) throws Exception {
	  Scanner scan = new Scanner(System.in);
	  int N = scan.nextInt();
	  int[] hoge = new int[N];
	  int max = 0;
	  int sum = 0;
	  for( int i = 0; i < N; i++  ) {
		 hoge[i] = scan.nextInt();
	  }

	  for( int i = 0; i < N; i++  ) {
		 sum += hoge[i];
	  }
	  for( int i = 0; i < N; i++  ) {
		 if( max < hoge[i] ) {
			 max = hoge[i];
		 }
	  }

	  if( max < sum - max ) {
		  System.out.println("Yes");
	  }else {
		  System.out.println("No");
	  }
  }
}


Measured memory_bytes: 23764
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=1000010,mod=1e9+7;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,sum,f[maxn];
inline int pls(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int main()
{
	read(n);
	f[1]=n;f[2]=(ll)n*n%mod;
	sum=(ll)(n-1)*(n-1)%mod;
	for(rg int i=3;i<=n;i++)
	{
		sum=pls(sum,f[i-3]);
		f[i]=pls(f[i-1],pls(sum,n-i+2));
	}
	printf("%d\n",f[n]);
	return 0;
}

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


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

    ll a, b;
    cin >> a >> b;
    if(b < 0){
      if((b-a)%2 == 0){
        cout << "Negative" << endl;
      }else{
        cout << "Positive" << endl;
      }
    }else if(a > 0){
      cout << "Positive" << endl;
    }else{
      cout << "Zero" << endl;
    }
}


Measured memory_bytes: 256
from math import floor
def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v=A[i]
        j=i-g
        while j>=0 and A[j]>v:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
        
def shellSort(A,n):
    global G
    for i in G:
        insertionSort(A,n,i)
cnt=0
N=int(input())
A=[int(input())for i in range(N)]
G=[1]
for i in range(99):
    if N<1+3*G[-1]:
        break
    G.append(1+3*G[-1])
G.reverse()
shellSort(A,N)
print(len(G)," ".join(list(map(str,G))),cnt,sep="\n")
for i in A:
    print(i)


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int N;
vector<vector<int>> G;
vector<Pi> edges;
vector<int> color;

void dfs(int v, int pre, int col) {
  int ct = 1;
  for (int e : G[v]) {
    Pi edge = edges[e];
    if (edge.second == v) swap(edge.first, edge.second);
    if (edge.second != pre) {
      if (col == ct) ct++;
      color[e] = ct;
      dfs(edge.second, v, ct);
      ct++;
    }
  }
}

int main() {
  cin.tie(0);
  cin >> N;
  G.resize(N);
  color.resize(N - 1);
  FOR(i, N - 1) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(i);
    G[b - 1].push_back(i);
    edges.push_back(Pi(a - 1, b - 1));
  }
  dfs(0, -1, 0);
  cout << *max_element(ALL(color)) << endl;
  for (int c : color) cout << c << endl;
  return 0;
}

Measured memory_bytes: 8824
#pragma GCC optimize ("O3")
///#include<bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;



/// Info.
///****************************************************************************************************************************************///
/// Coder               : BAHAA El_DEEN OSAMA SAYED.
/// Problem name        : F - Remaining Balls
/// Method              : IM-string
/// Date                : 23/2/2020
///****************************************************************************************************************************************///


#define rep0(i,x)         for(int i=0; i<=x ;++i)
#define all(v)           ((v.begin()),((v.end())
#define mm(v,d)          memset(v,d,sizeof(v))
#define lp(i,v)          for(int i=0;i<sizeof(v);++i)
#define lpi(i,j,n)       for(int i=(j);i>=(int)n;++i)
#define lpd(i,j,n)       for(int i=(j);i>=(int)n;--i)
#define MP               make_pair
#define SZ(v)            ((int) ( (v).size() ) )
#define ull              unsigned long long
#define ll               long long
#define pi               3.1415926536
#define oo               1e9
#define OO               1e18
#define Fx(n)            fixed<<setprecision(n)
#define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define RE0              return 0
#define RE1              return 1
#define mp(a,b)          make_pair(a,b)
#define X                first
#define Y                second
#define pii              pair(int a, int b)
#define rep1(i,x)        for(int i=1;i<x;++i)
#define rep2(i,x)        for(int i=2;i<x;++i)
#define RE               return
//#define LD               long double
#define all(v) ((v).begin()),((v).end())


const  int  N   = (int) 1e5+100;
const  int  M   = (int) 1e4+4;
const  int  INF = (int) 0x3f3f3f3f;
///const double ESP = 1e-7;
///const ll MOD=1e8+9;


string str1,str2,str3;
int a=0,b=0;

int main()
{
FasterIO;

cin>> str1 >> str2 ;
cin >> a   >> b;
cin >> str3;
(str1==str3) ? --a : --b;
cout << a << " " << b;



 RE0;}


Measured memory_bytes: 384