akhauriyash/Code-Regression huggingface dataset:
/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static ll s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    for (int i = 1;i <= n;++i)
        s[i] += s[i - 1];
    ll answer = 1e18;
    for (int cs = 0;cs < 2;++cs)
    {
        int now = cs;
        ll ss = 0;
        ll ans = 0;
        for (int i = 1;i <= n;++i)
        {
            if (now)
            {
                if (s[i] + ss >= 0)
                    ans += (s[i] + ss) + 1,ss -= (s[i] + ss) + 1;
            }
            else
            {
                if (s[i] + ss <= 0)
                    ans += 1 - (s[i] + ss),ss -= (s[i] + ss) - 1;
            }
            now ^= 1;
        }
        smin(answer,ans);
    }
    fo << answer << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 1024
<?php
$N = (int) trim(fgets(STDIN));
$A = explode(' ', trim(fgets(STDIN)));
// var_dump($A);
$A_arr = [];
foreach ($A as $value) {
 $A_arr[] = (int) $value;
}
// var_dump($A_arr);
$max = -10000000000;
for ($i = 0; $i < $N; $i++) {
 // 配列の中身どうしで１回ずつ引き算するやり方 => これ知りたい
 // maxはforでも使える
 for ($j = 0; $j < $N; $j++) {
  //  echo $A_arr[$j];
  $A_subtraction_abs = abs($A_arr[$i] - $A_arr[$j]);
  //  echo $A_subtraction_abs . "\n";
  $max = max($max, $A_subtraction_abs);
  // echo $max . "\n";
 }
}
echo $max;

Measured memory_bytes: 4728
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int a,b,k;
        cin >> a >> b >> k;
        set<int>s;
        int cn = 0;
        for(int i = a;i<=b;i++){
                if(cn==k)break;
                s.insert(i);
                cn++;
        }

            int cnt  = 0;
            for(int i = b; i>=a; i--){
                if(cnt==k)break;
                s.insert(i);
                cnt++;
            }
            for(auto x: s)cout<<x<<endl;

return 0;
}



Measured memory_bytes: 256
//Welcome to AtCoder

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<bool,int> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n,m;cin>>n>>m;
    vector<p>wwaa(n+1);
    rep(i,0,n+1)wwaa[i]={false,0};
    int ac=0,wa=0;
    rep(i,0,m){
        int c;string s;cin>>c>>s;
        if(wwaa[c].first==false){
            if(s=="AC"){
                ac++;
                wwaa[c].first=true;
            }else{
                wwaa[c].second++;
            }
        }
    }
    rep(i,1,n+1){
        if(wwaa[i].first)wa+=wwaa[i].second;
    }
    cout<<ac<<spa<<wa<<nnn;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
B = input().split()
S = B[:]

for i in range(N):
    for j in range(N-1, i, -1):
        if B[j][1] < B[j-1][1]:
            B[j], B[j-1] = B[j-1], B[j]
    
    m = i
    for j in range(i, N):
        if S[m][1] > S[j][1]:
            m = j
    S[m], S[i] = S[i], S[m]

print(*B)
print('Stable')
print(*S)
print(['Not s', 'S'][B==S] + 'table')

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


int main() {

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j += 2) {
            if (i % j == 0) ++cnt;
        }
        if (cnt == 8) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#author : dokueki

import sys
from math import log
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    a = int(sys.stdin.readline())
    p = 100
    cnt = 0
    while p < a:
        p += p // 100
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 62972
H, N = map(int, input().split())
INF = 10 ** 12

M = []
for i in range(N):
    A, B = map(int, input().split())
    M.append((A, B))

dp = [INF for j in range(H+10**4+1)]
dp[0] = 0

for i in range(N):
    for j in range(1, H+10**4+1):
        if j - M[i][0] >= 0:
            dp[j] = min(dp[j], dp[j-M[i][0]] + M[i][1])

ans = INF
for i in range(10**4+1):
    ans = min(ans, dp[H+i])
print(ans)


Measured memory_bytes: 43228
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/
 
 
int main(){
	int a, b;
	cin >> a >> b;
	if(a < b)
		cout << "a < b\n";
	else if(a == b)
		cout << "a == b\n";
	else if(a > b)
		cout << "a > b\n";
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << ((a%3==0 || b%3==0 || (a+b)%3==0) ? "Possible" : "Impossible" ) << endl;
  return 0;
}


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

constexpr double INF = 1e9;
constexpr double eps = 1e-8;

int main() {
    double d;
    int n, b;
    cin >> d >> n >> b;
    vector<double> p(n), h(n);
    for(int i=0; i<n; ++i) {
        cin >> p[i] >> h[i];
    }
    double res = INF;
    for(int i=0; i<=b; ++i) {
        double interval = d / (i+1);
        bool neg = false;
        for(int j=0; j<=i; ++j) {
            for(int i=0; i<n; ++i) {
                neg |= abs(interval * j - p[i]) < eps;
            }
        }
        if(neg) {
            continue;
        }
        vector<double> vx, vy;
        vx.push_back(sqrt(interval / 2));
        vy.push_back(vx.back());
        for(int j=0; j<=i; ++j) {
            double now = interval * j;
            for(int k=0; k<n; ++k) {
                double pp = p[k] - now;
                if(0 < pp && pp < interval) {
                    vx.push_back(sqrt(1 / (2*h[k]) * pp * (interval - pp)));
                    vy.push_back(interval / (2 * vx.back()));
                }
            }
        }
        for(int j=0; j<vx.size(); ++j) {
            bool ok = true;
            for(int k=0; k<=i; ++k) {
                double now = interval * k;
                for(int l=0; l<n; ++l) {
                    double pp = p[l] - now;
                    if(0 < pp && pp < interval) {
                        double t = pp / vx[j];
                        double hh = vy[j] * t - 0.5 * t*t;
                        ok &= (hh - h[l]) >= -eps;
                    }
                }
            }
            if(ok) {
                res = min(res, hypot(vx[j], vy[j]));
            }
        }
    }
    cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 3332
#include <iostream>
using namespace std;
 
int main(){
	int x, y;

	do{
		cin >> x >> y;
		if(x==0 && y== 0) break;
		if(x>=y) cout << y << " " << x << endl;
		if(y>x) cout << x << " " << y << endl;
	} while(1);

}

Measured memory_bytes: 3000
/*
?????¬???????????????
??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????

##########
#........#
#........#
#........#
#........#
##########

?????????????????? 6 cm ?????? 10 cm ???????????¨?????????????????? 
*/
#include <iostream>

int main() {
	int h, w;
	while (1) {
		std::cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if(i == 0 || i == h-1 || j == 0 || j == w-1){
				std::cout << "#";
				}
				else {
					std::cout << ".";
				}

			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys


A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

flag = [[False]*3 for _ in range(3)]

for t in b:
    for i in range(3):
        for j in range(3):
            if A[i][j]==t:
                flag[i][j] = True
    
f = False
for i in range(3):
    tate = flag[i][0]
    yoko = flag[0][i]
    for j in range(1,3):
        tate = tate and flag[i][j]
        yoko = yoko and flag[j][i]
    f = f or tate or yoko
    
na1 = flag[0][0] and flag[1][1] and flag[2][2]
na2 = flag[0][2] and flag[1][1] and flag[2][0]

if f or na1 or na2:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}
ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a)%mod;
    return k%2 ? (a*n)%mod : a;
}

int main(){
    ll N; cin>>N;
    ll ans=ruijou(10,N);
    Add(ans,ruijou(8,N));
    Add(ans,mod-ruijou(9,N));
    Add(ans,mod-ruijou(9,N));
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T; cin >> N >> T;
    int mincost = -1;
    rep(i, N) {
        int c, t;
        cin >> c >> t;
        if (T >= t) {
            if (mincost == -1) {
                mincost = c;
            } else {
                if (mincost > c) {
                    mincost = c;
                }
            }
        }
    }
    if (mincost == -1) {
        cout << "TLE" << endl;
        return 0;
    }
    cout << mincost << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int h,w;cin>>h>>w;
    vector<string>a(h);
    rep(i,h)cin>>a[i];
    map<char,int>st;
    map<int,int>me;
    rep(i,h)rep(j,w)st[a[i][j]]++;
    bool f[h][w];
    rep(i,h)rep(j,w)f[i][j]=true;
    rep(i,(h+1)/2)rep(j,(w+1)/2){
        int cnt=0;
        if(f[i][j]){
            f[i][j]=false;
            cnt++;
        }
        if(f[i][w-j-1]){
            f[i][w-j-1]=false;
            cnt++;
        }
        if(f[h-i-1][j]){
            f[h-i-1][j]=false;
            cnt++;
        }
        if(f[h-i-1][w-j-1]){
            f[h-i-1][w-j-1]=false;
            cnt++;
        }
        //cout<<cnt<<' '<<i<<' '<<j<<endl;
        me[cnt]++;
    }
    for(auto x:st){
        int w =x.second;
        while(w>=4){
            if(me[4]==0)break;
            if(w==0)break;
            w-=4;
            me[4]--;
        }
        while(w>=2){
            if(me[2]==0)break;
            if(w==0)break;
            w-=2;
            me[2]--;
        }
        if(w&&me[1]){
            me[1]--;
            w--;
        }
        if(w){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
 
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(c/b+(c%b?1:0) > a/d+(a%d?1:0))
    printf("No");
  else
    printf("Yes");
  
  return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
int a[100030]={0};

    int X;
    while(N--){
        cin>>X;
        a[X]++;
        a[X-1]++;
        a[X+1]++;
    }

int max_value=0;
        for(int i=0;i<=100000;++i){
            if(max_value<a[i])max_value=a[i];
        }
cout<<max_value;

}



Measured memory_bytes: 3552
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	s := getNextString(scanner)
	seg := Segment{}
	seg.init(n + 1)
	for i := 0; i < n+1; i++ {
		seg.minimize(i, int(s[i]-'0'))
	}
	dp := make([]int, n+1)
	for i := 0; i < n; i++ {
		k := i + 1 - m
		if k < 0 {
			k = 0
		}
		pz := seg.nextZero(k - 1)
		if pz >= i+1 {
			fmt.Println(-1)
			return
		}
		dp[i+1] = pz
	}
	ans := make([]int, 0)
	for i := n; i > 0; i = dp[i] {
		ans = append(ans, i-dp[i])
	}
	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Fprint(writer, ans[i])
		if i > 0 {
			fmt.Fprint(writer, " ")
		}
	}

	writer.Flush()
}

// Segment ...
type Segment struct {
	n, h, i, chunk, inf int
	unit                []int
	bucket              [][]int
}

func (seg *Segment) init(n int) {
	seg.n = n
	seg.unit = make([]int, 1)
	seg.unit[0] = 1
	seg.bucket = make([][]int, 1)
	seg.bucket[0] = make([]int, n)

	chunk := 8
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		seg.bucket = append(seg.bucket, make([]int, n))
		seg.unit = append(seg.unit, seg.unit[i]*chunk)
	}
	seg.h = len(seg.unit)
	seg.chunk = chunk
	seg.inf = math.MaxInt32
}

func (seg *Segment) minimize(index, value int) {
	seg.bucket[0][index] = value
	for seg.i = 0; seg.i < seg.h-1; seg.i++ {
		s := index - index%seg.chunk
		t := s + seg.chunk
		if t > len(seg.bucket[seg.i]) {
			t = len(seg.bucket[seg.i])
		}
		parent := index / seg.chunk
		min := seg.inf
		for i := s; i < t; i++ {
			if min > seg.bucket[seg.i][i] {
				min = seg.bucket[seg.i][i]
			}
		}
		seg.bucket[seg.i+1][parent] = min
		index /= seg.chunk
	}
}

func (seg *Segment) nextZero(index int) int {
	for index = index + 1; index < seg.n; index += seg.unit[seg.i] {
		for seg.i = 0; seg.i < seg.h-1 && index%seg.unit[seg.i+1] == 0; seg.i++ {
			if seg.bucket[seg.i+1][index/seg.unit[seg.i+1]] == 0 {
				break
			}
		}
		if seg.bucket[seg.i][index/seg.unit[seg.i]] == 0 {
			return index
		}
	}

	return seg.n
}


Measured memory_bytes: 7808
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let hs: Vec<usize> = sc.vec(n);
    let mut max_height = 0;
    let result = hs.iter().fold(0, |sum , &x| {
        if x >= max_height {
            max_height = x;
            return sum + 1
        }
        sum
    });
    println!("{}", result);

}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

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

  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> tr(n, vector<int>(n + 1));
  int l, r;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r;
    tr[--l][--r]++;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; 0 < j; --j) {
      tr[j - 1][i] += tr[j][i];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n; ++j) {
      tr[i][j] += tr[i][j-1];
    }
  }

  int f, t;
  for (int i = 0; i < q; ++i) {
    cin >> f >> t;
    cout << tr[--f][--t] << "\n";
  }
}


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

int main() {
  string left,right,select;
  int a,b;
  cin>>left>>right;
  
  cin>>a>>b;
  cin>>select;
  if(select==left)
    a--;
  else
    b--;
  cout<<a<<' '<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 200000

int main() {
	static int aa[N], bb[N];
	int n, i, j, x, y, m;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (i = n - 1; i > 0; i--)
		if (aa[i] == 1) {
			j = i + 1;
			for (x = 1; x * x <= j; x++)
				if (j % x == 0) {
					y = x - 1;
					aa[y] = (aa[y] + 1) % 2;
					if (x > 1 && x * x != j) {
						y = j / x - 1;
						aa[y] = (aa[y] + 1) % 2;
					}
				}
		}
	m = 0;
	for (i = 0; i < n; i++)
		if (aa[i] == 1)
			bb[m++] = i;
	printf("%d\n", m);
	for (i = 0; i < m; i++)
		printf("%d ", bb[i] + 1);
	if (m > 0)
		printf("\n");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    int count = 0;
    cin >> a >> b;
    for(int i = 0; i < a.length(); i++){
        if(a[i] != b[i]){
            count++;
        }
    }
    cout << count << endl;
}


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

bool isPrime(int m, int n) {
  int r = m*m + n*n;
  if(r > 1); else return false;
  int cnt = 0;
  for(int a = 0; a*a <= r; a = -a + (a <= 0)) {
    for(int b = 0; a*a + b*b <= r; b = -b + (b <= 0)) {
      int c = a*a + b*b;
      if(c > 0); else continue;
      if((a*m + b*n) % c == 0 && 
         (a*n - b*m) % c == 0) {
        ++cnt;
      }
    }
  }
  return cnt == 8;
}

int main() {
  int T; cin >> T;
  while(T--) {
    int m, n; cin >> m >> n;
    cout << (isPrime(m, n) ? "P" : "C") << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,n;
    cin>>k>>n;
    vector<int> vec(n);
for(int i=0;i<n;i++){
  cin>>vec.at(i);
}
sort(vec.begin(), vec.end());
priority_queue<int> pq;
for(int i=0;i<n-1;i++){
    pq.push(vec.at(i+1)-vec.at(i));
}
pq.push(vec.at(0)+k-vec.at(n-1));
pq.pop();
int s=0;
while(!pq.empty()){
    s+=pq.top();
    pq.pop();
}
cout<<s<<endl;
}

Measured memory_bytes: 2296
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include <cstring>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  double t,x;
  cin >> t >> x;
  cout << t / x;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		String str = sc.next();
		boolean isBlack[] = new boolean[num];
		for(int i = 0; i < num; i ++) {
			isBlack[i] = str.charAt(i) == '#';
		}
		int countBlack[] = new int[num];
		int countWhite[] = new int[num];
		countBlack[0] = isBlack[0] ? 1 : 0;
		countWhite[0] = 1 - countBlack[0];
		for(int i = 1; i < num; i ++) {
			countBlack[i] = countBlack[i - 1] + (isBlack[i] ? 1 : 0);
			countWhite[i] = i + 1 - countBlack[i];
		}
		int numBlack = countBlack[num - 1];
		int numWhite = countWhite[num - 1];
		int need[] = new int[num + 1];
		need[0] = numWhite;
		for(int i = 1; i < num; i ++) {
			need[i] = countBlack[i - 1] + numWhite - countWhite[i];
		}
		need[num] = numBlack + numWhite - numWhite;

		int min = need[0];
		for(int i = 0; i <= num; i ++) {
			min = Math.min(min, need[i]);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 30052
r[9],t,o;
main(n)
{
  char s[9];
  scanf("%d",&n);
  while(n)
    {
      scanf("%s",s);
      if(s[1]=='I')
	{
	  if(r[3]==1)
	    {
	      t++;
	      r[3]=0;
	    }
	  if(r[2]==1)
	    {
	      r[3]=1;
	      r[2]=0;
	    }
	  if(r[1]==1)
	    {
	      r[2]=1;
	    }
	  r[1]=1;
	}
      else if(s[1]=='U')
	{
	  o++;
	  if(o>2)
	    {
	      printf("%d\n",t);
	      n--;
	      r[3]=r[2]=r[1]=o=t=0;
	    }
	}	
      else
	{
	  if(r[3]==1)
	    {
	      t++;
	      r[3]=0;
	    }
	  if(r[2]==1)
	    {
	      t++;
	      r[2]=0;
	    }
	  if(r[1]==1)
	    {
	      t++;
	      r[1]=0;
	    }
	  t++;
	}
    }
  exit(0);
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int N, m;
int Array[100005];
int DP[5][5], M[5][5], T[5][5];
int Aux[5][5];
const int MOD = 1000000007;
void Read()
{
    cin >> N >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> Array[i];
        ++Array[i];
    }
}
void initialize(int a, int b, int c)
{
    DP[1][1] = a;
    DP[1][2] = b;
    DP[1][3] = c;
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            M[i][j] = 0;
    M[1][1] = M[3][1] = 1;
    M[1][2] = M[3][2] = 2;
    M[2][2] = 1;
    M[2][3] = M[3][3] = M[1][3] = 1;
    M[3][3] = 2;
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            T[i][j] = M[i][j];
}
inline void Add(int& x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}
void mul(int A[][5], int B[][5])
{
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
        {
            Aux[i][j] = 0;
            for(int k = 1; k <= 3; k++)
                Add(Aux[i][j], (1LL * A[i][k] * B[k][j]) % MOD);
        }
}
void copy(int A[][5])
{
    for(int i = 1; i <= 3; i++)
        for(int j = 1; j <= 3; j++)
            A[i][j] = Aux[i][j];
}
void powLog(int p)
{
    while(p)
    {
        if(p % 2 == 1)
        {
            mul(DP, M);
            copy(DP);
        }
        mul(M, T);
        p /= 2;
        copy(M);
        copy(T);
    }
}
void Solve()
{
    initialize(1, 2, 1);
    int last = 1;
    Array[++m] = N + 1;
    for(int i = 1; i <= m; i++)
    {
        int power = Array[i] - last - 1;
        powLog(power);
        if(Array[i] < N + 1)
        {
            int a = DP[1][1], b = DP[1][2], c = DP[1][3];
            DP[1][1] = a;
            DP[1][2] = 0;
            DP[1][3] = 0;
            Add(DP[1][2], b);
            Add(DP[1][2], a);
            Add(DP[1][2], a);
            Add(DP[1][3], c);
            Add(DP[1][3], b);
            Add(DP[1][3], a);

            //Add(DP[1][3], c);
            initialize(DP[1][1], DP[1][2], DP[1][3]);
        }
        last = Array[i];
    }
    cout << DP[1][3] << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	vector<int> x(9);
	for (int i = 0; i < 9; i++) cin >> x[i];
	vector<int> p = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	int ret = 0;
	do {
		bool flag = true;
		for (int i = 0; i < 9; i++) {
			if (x[i] != -1 && x[i] != p[i]) flag = false;
		}
		if (!flag) continue;
		if (p[0] + p[1] * 10 + p[2] + p[3] * 100 + p[4] * 10 + p[5] == p[6] * 100 + p[7] * 10 + p[8]) ret++;
	} while (next_permutation(p.begin(), p.end()));
	cout << ret << endl;
	return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int N,ans=0;
  cin >> N;
  VVI q(10,VI(10));
  
  REP(i,N){
    string S = toString(i+1);
    int a = S.at(0)-'0', b = S.at(SZ(S)-1)-'0';
    q.at(a).at(b)++;
  }
  REP(i,9){
    REP(j,9){
      ans += q.at(i+1).at(j+1) * q.at(j+1).at(i+1);
    }
  }
  cout << ans << endl;;
  
}


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

using namespace std;
using ll = long long;

int n;
int ans[200005];
int val[200005], tree[800005];
vector<int> edge[200005];

int query(int x, int y, int l=0, int r=200004, int idx=1){
    if(y<l || x>r || y<x){
        return 0;
    }
    if(x<=l && r<=y){
        return tree[idx];
    }
    int mid = (l+r)/2;
    return max(query(x, y, l, mid, idx*2), query(x,y,mid+1,r,idx*2+1));
}

void upd(int targ, int v, int l=0, int r=200004, int idx=1){
    if(targ<l || targ>r) return;
    if(l==r){
        tree[idx] = v;
        return;
    }
    int mid = (l+r)/2;
    upd(targ, v, l, mid, idx*2);
    upd(targ,v, mid+1, r, idx*2+1);
    tree[idx] = max(tree[idx*2], tree[idx*2+1]);
}

void dfs(int cur, int par) {
    int get_max_val = query(0, val[cur] - 1);
    int org_val = query(val[cur], val[cur]);
    upd(val[cur], max(org_val, get_max_val + 1));
    ans[cur] = query(0, 200003);
    for (auto k: edge[cur]) {
        if (k == par) continue;
        dfs(k, cur);
    }
    upd(val[cur], org_val);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=0;i<n;i++) cin>>val[i];
    set<int> s;
    for(int i=0;i<n;i++){
        s.insert(val[i]);
    }
    map<int, int> mapping;
    int cnt = 0;
    for(int k: s){
        mapping[k] = cnt++;
    }
    for(int i=0;i<n;i++){
        val[i] = mapping[val[i]];
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        --u;--v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(0, -1);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<'\n';
    return 0;
}

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

namespace BeginnerContest136
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            int result = Math.Max(0, C-(A-B));
            Console.Write(result);
        }
    }
}


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

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

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int n,m;

  cin >> n;
  vector<int> t(n);
  int sum=0;
  REP(i,n){
    cin >> t[i];
    sum += t[i];
  }
  cin >> m;
  REP(i,m){
    int p,x;
    cin >> p >> x;
    p--;
    cout << sum - t[p] + x << endl;
  }
  

}



Measured memory_bytes: 256
import java.util.Scanner;

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

		String s = sc.next();
		int n = s.length();

		for(int i = n - 2; i > 0; i-=2)  {
			if(s.substring(0, i / 2).equals(s.substring(i / 2, i))) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 23764
str = gets.chomp!.split('')

x = 0
tmp = 0
str.each do |c|
  if 'ATGC'.include?(c)
    tmp += 1
  else
    if x < tmp
      x = tmp
    end
    tmp = 0
  end
end

if x < tmp
  x = tmp
end

puts x


Measured memory_bytes: 3836
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}


int n;
int a[55];

int main(){
	cin>>n;
	cin>>a[0];
	int max=abs(a[0]);
	int imax=0;
	for(int i=1;i<n;i++){
		cin>>a[i];
		if(abs(a[i])>max){
			max=abs(a[i]);
			imax=i;
		}
	}
	cout<<2*n-1<<endl;
	for(int i=0;i<n;i++){
		a[i]=a[i]+a[imax];
		cout<<imax+1<<" "<<i+1<<endl;
	}
	if(a[imax]>0){
		for(int i=1;i<n;i++){
			cout<<i<<" "<<i+1<<endl;
		}
	}else{
		for(int i=n;i>1;i--){
			cout<<i<<" "<<i-1<<endl;
		}
	}
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5+10
#define M 5050
using namespace std;
ll dis[M][M],sco[M],step[M];
int vis[M],pos[M];
int main()
{
	ios::sync_with_stdio(0);
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>pos[i];
	for(int i=1;i<=n;i++)
		cin>>sco[i];
	for(int i=1;i<=n;i++)
	{
		MM(vis,0);
		int t=pos[i],idx=0;
		while(!vis[t])
		{
			vis[t] = 1;
			idx++;
			dis[i][idx]=dis[i][idx-1]+sco[t];
			t=pos[t];
		}
		step[i]=idx;
	}
	ll res=-1e18;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=step[i];j++)
		{
			ll t=dis[i][j];
			if(k<j) break;
			if(dis[i][step[i]]>=0)
				t+=(k-j)/step[i]*dis[i][step[i]];
			res = max(res,t);
		}
	}
	cout<<res;
	return 0;
} 

Measured memory_bytes: 201032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(n), y(n), z(n);
  rep(i, n) cin >> x[i] >> y[i] >> z[i];

  int ans = -INF;
  rep(i, (1 << 3)) {
    vector<int> a;
    rep(j, n) {
      int tmp = 0;
      tmp += (i & (1 << 0) ? 1 : -1) * x[j];
      tmp += (i & (1 << 1) ? 1 : -1) * y[j];
      tmp += (i & (1 << 2) ? 1 : -1) * z[j];
      a.push_back(tmp);
    }

    sort(all(a), greater<int>());

    int sum = 0;
    rep(j, m) sum += a[j];
    cmax(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  while(cin >> a >> b >> c){
    TSTART();
    
    string ans;
    if(a[SZ(a)-1] == b[0] && b[SZ(b)-1] == c[0])ans = "YES";
    else ans = "NO";
    
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N, M;
	HashSet<int>[] es;
	void Solve()
	{
		var I = G();
		N = I[0];
		M = I[1];
		es = new HashSet<int>[N];
		for (int i = 0; i < N; i++) es[i] = new HashSet<int>();
		var rs = new Tuple<int, int>[M];
		for (int i = 0; i < M; i++)
		{
			I = G();
			int a = I[0] - 1, b = I[1] - 1;
			es[a].Add(b);
			es[b].Add(a);
			rs[i] = new Tuple<int, int>(a, b);
		}
		var s = 0;
		foreach (var e in rs)
		{
			int a = e.Item1, b = e.Item2;
			es[a].Remove(b);
			es[b].Remove(a);
			if (!Connected()) s++;
			es[a].Add(b);
			es[b].Add(a);
		}
		WriteLine(s);
	}
	bool[] used;
	bool Connected()
	{
		used = new bool[N];
		DFS(0);
		foreach (var x in used) if (!x) return false;
		return true;
	}
	void DFS(int u)
	{
		foreach (var v in es[u])
			if (!used[v])
			{
				used[v] = true;
				DFS(v);
			}
	}
}


Measured memory_bytes: 13408
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int flag = 1;
  int count = 0;
  while (flag){
    flag = 0;
    for (int i = N-1; i > 0; i--){
      if (A.at(i) < A.at(i-1)){
        using std::swap;
        swap (A.at(i-1), A.at(i));
        flag = 1;
        count++;
      }
    }
  }
  for (int j=0; j < N ; j++) cout << A.at(j) << (j == N-1?'\n':' ');
  cout << count << endl;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};

bool prime[56500];
void eratos ( int n){
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2){
		if(!prime[i]) continue;
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
}


int main()
{
 	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	eratos(56000);
	VI pr;
	rep(i, 55556) if(prime[i]) pr.push_back(i);
	
	int c=0;
	for(auto x: pr){
		if(c>=n) break;
		if(x%5 == 3){
			cout << x <<" ";
			c++;
		}
	}
	cout<<"\n";
	//for(auto x :pr) printf("%d, ",x); puts("");
	return 0;
}


Measured memory_bytes: 384
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array.Unboxed
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve n <$> replicateM n (getl toInt) >>= print
    main
    
solve :: Int -> [Int] -> Int
solve n xs = fst $ bsort n iar
  where
    iar = listArray (1,n) xs :: UArray Int Int

idxlst :: Int -> [Int]
idxlst m = foldl (\ls x -> ls ++ take x ls) [1..m-1] [m-2,m-3..1]

bsort :: Int -> UArray Int Int -> (Int, UArray Int Int)
bsort n ar = foldl f (0,ar) (idxlst n)
  where
    f (x,a) i
      | a ! i > a ! (i+1) = (x+1,a // [(i, a ! (i+1)),(i+1, a ! i)])
      | otherwise = (x,a)

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 14352
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll ans = 1e18;
  for (ll i = 1; i*i <= N; ++i) {
    if (N%i != 0) continue;
    ll j = N/i;
    ans = min(ans, i+j-2);
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define inf 0x3f3f3f3f3f3f3f3fLL

using namespace std;

typedef long long ll;

struct Point {
  ll x,y;
  Point() {}
  Point(ll a,ll b):x(a),y(b) {}
  Point operator - (Point b) {return Point(x-b.x,y-b.y);}
};

ll cross(Point x,Point y) {
  return x.x*y.y-x.y*y.x;
}

int q[300005];
Point p[300005];

inline ll calc(int x,int y,ll *sum) {
  return p[x].y-sum[y]+(ll)y*(y+1)-(ll)(2*y+1)*x;
}

ll a[300005],b[300005];

ll f[300005],g[300005],h[300005];
ll now[300005];

void solve(int l,int r,int n) {
  if (l==r) {
  	h[l]=max(h[l],f[l-1]+g[l+1]+1LL-(a[l]-a[l-1]));
  	return;
  }
  int m=((l+r)>>1);
  int top=0;
  q[++top]=l-1;
  p[l-1]=Point(l-1,f[l-1]+a[l-1]+(ll)(l-1)*(l-1));
  for(int i=l;i<=m;i++) {
  	p[i]=Point(i,f[i-1]+a[i]+(ll)i*i);
  	while (top>1&&cross(p[i]-p[q[top]],p[q[top]]-p[q[top-1]])<=0) top--;
  	q[++top]=i;
  }
  for(int i=m+1;i<=r;i++) {
  	while (top>1&&calc(q[top],i,a)<=calc(q[top-1],i,a)) top--;
  	now[i]=calc(q[top],i,a)+g[i+1];
  }
  for(int i=r-1;i>m;i--) now[i]=max(now[i],now[i+1]);
  for(int i=m+1;i<=r;i++) h[i]=max(h[i],now[i]);
  top=0;
  q[++top]=n-(r+1)+1;
  p[n-(r+1)+1]=Point(n-(r+1)+1,g[r+1]+b[n-(r+1)+1]+(ll)(n-(r+1)+1)*(n-(r+1)+1));
  for(int i=r;i>m;i--) {
  	p[n-i+1]=Point(n-i+1,g[i+1]+b[n-i+1]+(ll)(n-i+1)*(n-i+1));
  	while (top>1&&cross(p[n-i+1]-p[q[top]],p[q[top]]-p[q[top-1]])<=0) top--;
  	q[++top]=n-i+1;
  }
  for(int i=m;i>=l;i--) {
  	while (top>1&&calc(q[top],n-i+1,b)<=calc(q[top-1],n-i+1,b)) top--;
  	now[i]=calc(q[top],n-i+1,b)+f[i-1];
  }
  for(int i=l+1;i<=m;i++) now[i]=max(now[i],now[i-1]);
  for(int i=m;i>=l;i--) h[i]=max(h[i],now[i]);
  solve(l,m,n);
  solve(m+1,r,n);
} 

int num[300005];

void pre(int n) {
  for(int i=1;i<=n;i++) a[i]=a[i-1]+2LL*num[i];
  for(int i=n;i>0;i--) b[i]=b[i+1]+2LL*num[i];
  reverse(b+1,b+n+1);
  int top=0;
  q[++top]=0;
  p[0]=Point(0,0);
  for(int i=1;i<=n;i++) {
  	p[i]=Point(i,f[i-1]+a[i]+(ll)i*i);
  	while (top>1&&cross(p[i]-p[q[top]],p[q[top]]-p[q[top-1]])<=0) top--;
  	q[++top]=i;
  	while (top>1&&calc(q[top],i,a)<=calc(q[top-1],i,a)) top--;
  	f[i]=calc(q[top],i,a);
  }
  top=0;
  q[++top]=n-(n+1)+1;
  p[n-(n+1)+1]=Point(n-(n+1)+1,0);
  for(int i=n;i>0;i--) {
  	p[n-i+1]=Point(n-i+1,g[i+1]+b[n-i+1]+(ll)(n-i+1)*(n-i+1));
  	while (top>1&&cross(p[n-i+1]-p[q[top]],p[q[top]]-p[q[top-1]])<=0) top--;
  	q[++top]=n-i+1;
  	while (top>1&&calc(q[top],n-i+1,b)<=calc(q[top-1],n-i+1,b)) top--;
  	g[i]=calc(q[top],n-i+1,b);
  }
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&num[i]);
  pre(n);
  for(int i=1;i<=n;i++) h[i]=-inf;
  solve(1,n,n);
  int m;
  scanf("%d",&m);
  for(int i=1;i<=m;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	printf("%lld\n",max(h[x]-(2LL*y-2LL*num[x]),f[x-1]+g[x+1])>>1);
  }
  return 0;
} 

Measured memory_bytes: 22912
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll X;
    cin>>X;
    vll ans(401,0);
    //0-199: (-200)^5 to (-1)^5
    for(int i=0;i<=400;i++){
        ll v=i-200;
        ans[i]=v*v*v*v*v;
    }
    bool ok=false;
    for(int i=0;i<=400;i++){
        for(int j=0;j<400;j++){
            if(ans[i]-ans[j]==X){
                cout<<(i-200)<<" "<<(j-200)<<endl;
                ok=true;break;
            }
        }
        if(ok)break;
    }
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    REP(n, N) {
        ll i, r;
        cin >> i >> r;
        ans += r-i+1;
    }
    cout << ans << "\n";
}


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

using namespace std;

int main() {

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a >= k){
    cout << k;
  }else if(a + b >= k){
    cout << a;
  }else{
    cout << a - min(k - a - b, c);
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;


void yes(){
   cout<<"Yes";
   // exit(0);
}

void no(){
   cout<<"No";
   // exit(0);
}


int n, m;
string s, t;

int32_t main(){_
   

   int x;
   cin >> n >> m >> x;

   int ok = (n + m - 1) / m;

   cout<<ok * x;


   return 0;
}

Measured memory_bytes: 3608
import queue
import copy
import math
from collections import deque
import bisect

# そのまま入力文字列の入力
k = int(input())

# 2つの入力を空白で分割し、数値化
a, b = map(int, input().split())

for x in range(a, b+1):
    d, m = divmod(x, k)

    if m == 0:
        print("OK")
        exit(0)

print("NG")

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

void dfs(string s, map<pair<string, string>, ll>& r, string a, string b) {
  int i = a.size() + b.size();
  if (i == s.size() / 2) {
    r[{a, b}]++;
    return;
  }
  dfs(s, r, a + s[i], b);
  dfs(s, r, a, b + s[i]);
}

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

  map<pair<string, string>, ll> u, v;
  dfs(s, u, "", "");
  reverse(begin(s), end(s));
  dfs(s, v, "", "");

  ll m = 0;
  for (auto e : u) {
    m += e.second * v[e.first];
  }
  cout << m << endl;
}


Measured memory_bytes: 104192