akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long n, std::vector<long long> a){
    vll s(n+1, 0), sori(n+1, 0);
    ll cost1=0, cost2=0;
    REP(i, n){sori[i+1] = sori[i]+a[i];}
    REP(i, n){
        ll delta = 0, sum = s[i]+sori[i+1];
        if(i % 2 == 0){
            if(sum <= 0){
                cost1 += abs(1-sum);
                s[i+1] = 1 - sum;
                s[i+1] += s[i];
            }else{
                s[i+1] = s[i];
            }
        } else{
            if(sum >= 0){
                cost1 += abs(sum+1);
                s[i+1] = -1 - sum;
                s[i+1] += s[i];
            }else{
                s[i+1] = s[i];
            }
        }
    }
    fill(ALL(s), 0);
    REP(i, n){
        ll delta = 0, sum = s[i]+sori[i+1];;
        if(i % 2 != 0){
            if(sum <= 0){
                cost2 += abs(1-sum);
                s[i+1] = 1 - sum;
                s[i+1] += s[i];
            }else{
                s[i+1] = s[i];
            }
        } else{
            if(sum >= 0){
                cost2 += abs(sum+1);
                s[i+1] = -1 - sum;
                s[i+1] += s[i];
            }else{
                s[i+1] = s[i];
            }
        }
    }
    cout<<min(cost1, cost2)<<endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long a;
	char b[15];
	int c=0;
	cin>>a>>b;
	for(int i=0;i<4;i++)
	{
		if(b[i]=='.')
			continue;
		if(i!=0)
			c+=(b[i]-'0')*pow(10,3-i);
		else
			c+=(b[i]-'0')*pow(10,2);
	}
	cout<<(a*c/100)<<endl;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,k,m,t;
  cin>>n>>k;

  //m=-1;
  for(int i=1;i<=n;i++){
    cin>>t;
    //if(t==1) m=i;
  }
  if(n==k) cout<<1<<endl;
  else {
    n-=k;
    k--;
    cout<<1+(n+k-1)/k<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        (&mut $iter).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let (n, d, a): (usize, usize, isize) = parse!(iter, 3);
    let mut s = 0;
    let mut xhs: Vec<(usize, isize)> = (0..n).map(|x| parse!(iter, 2)).collect();
    xhs.sort();
    let mut s = 0;
    let mut ret = 0;
    let mut attacks = VecDeque::new();
    for (x, mut h) in xhs {
        while attacks.len() > 0 {
            let (xr, p) = attacks[0];
            if xr < x {
                attacks.pop_front();
                s -= p;
            } else {
                break;
            }
        }
        h -= s;
        if h > 0 {
            let pi = h / a + if h % a == 0 { 0 } else { 1 };
            ret += pi;
            s += pi * a;
            attacks.push_back((x + 2 * d, pi * a));
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 16632
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n);
	VEC(int, smp, 3);
	sort(ALL(smp));
	VEC(int,l,n);

	int ans = INF;
	FOR(i,1,n-1){
		FOR(j,1,n-i){
			FOR(k,1,n-i-j+1){
				vector<int> par;
				REP(ii,i) par.push_back(0);
				REP(jj,j) par.push_back(1);
				REP(kk,k) par.push_back(2);
				REP(ll,n-i-j-k) par.push_back(3);

				do {
					int tmp=0;
					vector<int>a(3,0);
					REP(i,par.size()){
						if(par[i] == 0) {
							if(a[0]>0) tmp+=10;
							a[0]+=l[i];
						}
						if(par[i] == 1) {
							if(a[1]>0) tmp+=10;
							a[1]+=l[i];
						}
						if(par[i] == 2) {
							if(a[2]>0) tmp+=10;
							a[2]+=l[i];
						}
					}
					
					sort(ALL(a));
					REP(i,3){
						tmp += abs(a[i]-smp[i]);
						//debug(a[i]);
						//debug(tmp);
					}
					ans = min(ans,tmp);
					
				}while(next_permutation(ALL(par)));
			}
		}
	}
	OUT(ans)BR;
	
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
long long A[999999],W[999999];
long long M(int l,int r){
	if(l+1>=r)return 0;
	if(l+2==r){
		if(A[l]<=A[l+1])return 0;
		long long z=A[l];A[l]=A[l+1];A[l+1]=z;
		return 1;
	}
	int m = (l+r)/2,i=l, j=m, k=l;
	long long cl=M(l, m),cr=M(m,r),c=0;
	while(i<m&&j<r){
		if(A[i]<=A[j])W[k++]=A[i++];
		else{
			W[k++]=A[j++];
			c+=m-i;
		}
	}
	while(i<m)W[k++]=A[i++];
	while(j<r)W[k++]=A[j++];
	for(i=l;i<r;i++)A[i]=W[i];
	return cl+cr+c;
}
int main(){
	int T,i,N;
	//PKU2299,aizu0167: バブルソートの交換回数
	//for(;scanf("%d",&N),N;printf("%lld\n",M(0,N)))for(i=0;i<N;i++)scanf("%d",A+i);
	//hackerrank~runningtime,aizuALDS1~5D
	//scanf("%d",&N);for(i=0;i<N;i++)scanf("%d",A+i);printf("%lld\n",M(0,N));
	//hackerrank~30-sorting
	//scanf("%d",&N);for(i=0;i<N;i++)scanf("%d",A+i);printf("Array is sorted in %lld swaps.\n",M(0,N)),printf("First Element: %d\nLast Element: %d\n",A[0],A[N-1]);
	//spojINVCNT,hackerrank~insertionsort
	//for(scanf("%d",&T);T--;printf("%lld\n",M(0,N)))for(scanf("%d",&N),i=0;i<N;++i)scanf("%d",A+i);
	//codeiq4322: 光線の交差数
	//for(N=0;~scanf("%d",A+N);N++);printf("%lld\n",M(0,N));
	//kcs1009K: Nパズルの可解性
	//for(i=0;~(N=getchar());)if('0'<N&&N<'9')A[i++]=N-'0';
	//puts(M(0,i)%2?"lmpossible":"Possible"); //"l"? lol!
	//atcoderutpc2014F: パリティ
	//for(scanf("%d",&T),getchar();T--;printf("%lld\n",M(0,N)%2))for(N=0;~(A[N]=getchar())&&A[N]!='\n';N++);
	//kcs1031A
	//scanf("%d%d",&N,&T);for(i=0;i<N;i++)scanf("%d",A+i);N=M(0,N)-T;printf("%d\n",N>0?N:0);
	//atcoderARC075E: 算術平均がT以上
	scanf("%d%d",&N,&T);for(i=1;i<=N;i++)scanf("%d",&A[i]);for(i=1;i<=N;i++)A[i]+=A[i-1]-T;printf("%lld\n",(long long)N*-~N/2-M(0,N+1));
	return 0;
}

Measured memory_bytes: 5760
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

ll N;

int f (ll A) {
    ll B = N / A;
    int ans = 1;
    while(B > 9) {
        B /= 10;
        ans++;
    }
    return ans;
}

int main() {
    cin >> N;
    int ans = -1;
    for (ll i = floor(sqrt(N)); i > 0; i--) {
        if (N % i == 0) {
            ans = f(i);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3712
n, m = map(int, input().split())
p = 10**9 + 7
a = 1
fct = [a]
for i in range(1, m + 1):
    a = (a * i) % p
    fct.append(a)
b = pow(fct[-1], p - 2, p)
inv = [b]
for i in range(1, m + 1)[::-1]:
    b = (b * i) % p
    inv.append(b)
inv.reverse()
ans = (fct[m] * inv[m - n]) % p

tmp = 0
for i in range(1, n + 1):
    tmp += ((-1)**(i - 1) * fct[n] * inv[n - i] *
            inv[i] * fct[m - i] * inv[m - n]) % p
    tmp %= p
tmp = (fct[m] * inv[m - n] - tmp) % p
print((ans * tmp) % p)


Measured memory_bytes: 116312
# coding: utf-8
from collections import deque
s=input()
n=len(s)
A=deque()
for i in range(n):
    if s[i]=="S":
        A.append(s[i])
    else:
        if len(A)==0:
            A.append(s[i])
        elif A[-1]=="S":
            A.pop()
        else:
            A.append(s[i])
print(len(A))

Measured memory_bytes: 77864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int i=1;
		while(sc.hasNext()) {
		int a = sc.nextInt();
		if(a==0) 	break;
				
			System.out.printf("Case %d: %d\n",i,a);
			i++;
		}
	}
}



Measured memory_bytes: 67480
# Remainder Minimization 2019

L, R = map(int,input().split())
a = []

for i in range(L, R):
    for j in range(i+1,R+1):
        a.append((i*j)%2019)
        if (i*j)%2019 == 0:
            print("0")
            exit()

print(min(a))

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

int knapsack(int n, int W, int v[], int w[]){
	int dp[101][100001];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=W;j++){
			dp[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		int vl=v[i];
		int wt=w[i];
		for(int j=0;j<=W;j++){
			if(j<wt){
				dp[i+1][j]=dp[i][j];
			}else{
				dp[i+1][j]=max(dp[i][j],dp[i][j-wt]+vl);
			}
		}
	}
	return dp[n][W];
}
int main(){
	int n, W, v[100],w[100];
	cin >> n;
	cin >> W;
	for(int i=0;i<n;i++){
		cin >> v[i];
		cin >> w[i];
	}
	int ans = knapsack(n,W,v,w);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 7460
def solve(inputstr):
  list=inputstr.split(" ")
  a=int(list[0])
  b=int(list[1])
  ea = (a % 2 == 0)
  eb = (b % 2 == 0)
  if ea | eb:
    ans = "Even"
  else:
    ans = "Odd"
  return ans
 
if __name__ == '__main__':
  inputstr = input()
  ans = solve(inputstr)
  print(ans, flush=True)

Measured memory_bytes: 3064
#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>;

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

  int result = 1;
  char tmp = s[0];
  for (int i = 1; i < n; i++) {
    if (tmp != s[i]) {
      result++;
    }
    tmp = s[i];
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] bingo = new int[3][3];
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				bingo[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			int tmp = sc.nextInt();
			for(int j =0; j < 3; j++){
				for(int k = 0; k < 3; k ++){
					if(bingo[j][k] == tmp){
						bingo[j][k] = 0;
					}
				}
			}
		}
		for(int i = 0; i < 3; i++){
			if(bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0){
				System.out.println("Yes");
				break;
			}
			if(i == 2){
				System.out.println("No");
			}
		}
 	}
}




Measured memory_bytes: 35724
from math import sqrt, gcd
import sys


def osk_a(M):
    p = [i for i in range(M+1)]
    for x in range(2, int(sqrt(M))+1):
        if p[x] == x:
            for y in range(2*x, M+1, x):
                if p[y] == y:
                    p[y] = x
    return p


def g(a):
    g = 0
    for x in a:
        g = gcd(g, x)
    return g


def main():
    n = int(sys.stdin.buffer.readline())
    a = list(map(int, sys.stdin.buffer.readline().split()))
    if g(a) > 1:
        print("not coprime")
        exit()
    p = osk_a(10**6)
    chk = set()
    while a[0] > 1:
        chk.add(p[a[0]])
        a[0] //= p[a[0]]
    for x in a[1:]:
        tmp = set()
        while x > 1:
            tmp.add(p[x])
            x //= p[x]
        if not chk.isdisjoint(tmp):
            print("setwise coprime")
            exit()
        chk |= tmp
    print("pairwise coprime")


if __name__ == "__main__":
    main()


Measured memory_bytes: 113032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int64_t> edge[26];
int main() {
	string s, t; cin>>s>>t;
	int64_t sn=s.size();
	for(int i=0;i<sn;++i){
		char c=s[i];
		edge[c-'a'].push_back(i);
	}
	int64_t ans=0,mul=0;
	for(char c:t){
		if(edge[c - 'a'].size() == 0) {
			cout<<-1<<endl;
			return 0;
		}
		auto itr=lower_bound(edge[c-'a'].begin(), edge[c-'a'].end(), ans%sn);
		if(itr!=edge[c-'a'].end()){
			ans=*itr;
			// cerr<<ans<<endl;
		}else{
			mul++;
			ans=edge[c-'a'].front();
			// cerr<<ans<<endl;
		}
		ans++;
		if(ans>=sn){
			mul++;
			ans%=sn;
		}
	}
	cout<<ans+sn*mul<<endl;
	return 0;
}

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

namespace Program
{
    public class ABC096D
    {
        static public void Main(string[] args)
        {
            var N = NextInt;
            var prime = Prime(55555).ToList();
            if(prime.Last() > 55555) {
                prime.RemoveAt(prime.Count - 1);
            }
            prime = prime.Where(e => e % 10 == 9).ToList();

            Console.WriteLine(string.Join(" ", prime.Take(N)));
        }

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

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 13448
l = map(int, raw_input().split())
n = l[0]
m = l[1]
x = l[2]

a = map(int, raw_input().split())

# print a

for i in xrange(0,m):
	if a[i] > x:
		if m - i < i:
			print m - i
			break
		else:
			print i
			break

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,dp[3005][3005],a[3005],mod=1e9+7,inv=5e8+4,x,y,ans,f=1;
int ag(int x,int y){return 1ll*(x+y)*inv%mod;}
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (i!=j) dp[i][j]=(a[i]>a[j]);
	while (m--)
	{
		(f*=2)%=mod;
		scanf("%d%d",&x,&y);
		dp[x][y]=dp[y][x]=ag(dp[x][y],dp[y][x]);
		for (i=1;i<=n;i++) if (i!=x&&i!=y)
		{
			dp[x][i]=dp[y][i]=ag(dp[x][i],dp[y][i]);
			dp[i][y]=dp[i][x]=ag(dp[i][y],dp[i][x]);
		}
	}
	for (i=1;i<=n;i++) for (j=i+1;j<=n;j++) (ans+=dp[i][j])%=mod;
	cout<<(1ll*ans*f)%mod<<endl;
	return 0;
}

Measured memory_bytes: 35456
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int popcnt(int x) {
    int r = 0;
    foreach (i; 0 .. 22) if (x & (1 << i)) r++;
    return r;
}

void main() {
    int N, Hx, Hy, Dx, Dy;
    int[] Y, X;
    bool input() {
        scanf("%d %d %d %d %d\n", &N, &Hx, &Hy, &Dx, &Dy);
        if (N == 0) return false;
        Y = new int[N + 2];
        X = new int[N + 2];
        Y[0] = Hy;
        X[0] = Hx;
        foreach (i; 1 .. N + 1) {
            scanf("%d %d\n", &X[i], &Y[i]);
        }
        Y[N + 1] = Dy;
        X[N + 1] = Dx;
        return true;
    }
    double Distance(int a, int b) {
        double dy = Y[a] - Y[b],
               dx = X[a] - X[b];
        return sqrt(dy * dy + dx * dx);
    }
    void solve() {
        static double[int] cache[22];
        cache.clear;
        bool dfs(int v, int used, double t) {
            //writefln("%d %0" ~ (N + 2).to!string ~ "b %f", v, used, t);
            if (used == (1 << (N + 1)) - 1) return true;
            if (cache[v].get(used, 1e4) <= t) return false;
            if (v <= N - 8) {
                cache[v][used] = t;
            }
            foreach (i; 1 .. N + 1) {
                if (used & (1 << i)) continue;
                if (Distance(v, i) + t >= Distance(N + 1, i)) return false;
            }
            foreach (i; 1 .. N + 1) {
                if (used & (1 << i)) continue;
                if (dfs(i, used | 1 << i, t + Distance(v, i))) return true;
            }
            return false;
        }
        writeln(dfs(0, 1, 0) ? "YES" : "NO");
    }
    while (input) solve;
}

Measured memory_bytes: 55400
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int arr[]=new int[100000];
        for(int i=1;i<=100;++i) {
            for(int j=1;j<=100;++j) {
                for(int k=1;k<=100;++k) {
                    int t=i*i+j*j+k*k+i*j+j*k+k*i;
                    arr[t]++;
                }
            }
        }
        for(int i=1;i<=N;++i) {
            System.out.println(arr[i]);
        }
    }
}

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

int main() {
  int n;
  cin >> n ;
  int s1 = (n - n % 100) / 100;
  int s2 = (n - (n - n % 100) - n % 10) / 10;
  int s3 = n % 10; 
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<char> S(3);
  vector<char> T(3);
  cin>>S[0]>>S[1]>>S[2]>>T[0]>>T[1]>>T[2];
  reverse(T.begin(),T.end());
  
  if(S==T){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3576
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

int c[100010];

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

  int n;
  cin >> n;
  int a[n];
  int s = 0;
  for (int i = 0 ; i < n; i++){
    cin >> a[i];
    s += a[i];
    c[a[i]]++;
  }

  int q;
  cin >> q;
  int b[q], cc[q];
  
  for (int i = 0; i < q; i++)
    cin >> b[i] >> cc[i];

  for (int i = 0; i < q; i++){
    s += - c[b[i]] * b[i] + c[b[i]] * cc[i];
    c[cc[i]] += c[b[i]];
    c[b[i]] = 0;
    cout << s << endl;
  }
  

  
}


Measured memory_bytes: 6744
import sys
input = sys.stdin.readline

import math

def main():
    k = int(input())

    ans = 0

    for a in range(1, k+1):
        for b in range(1, k+1):
            for c in range(1, k+1):
                ans += math.gcd(math.gcd(a,b),c)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <stdio.h>

#define MAX			(14)
#define POINT(x, y)	(data[x + 2][y + 2])

void jud(int x, int y, int size, int data[MAX][MAX]);

int main(void)
{
	int map[MAX][MAX];
	int i, j;
	int input_x, input_y, input_size;
	int max = 0;
	int zero_count = 0;
	
	for (i = 0; i < MAX; i++){
		for (j = 0; j < MAX; j++){
			if(i == 0 || j == 0 || i + 1 == MAX || j + 1 == MAX || i == 1 || j == 1 || i + 2 == MAX || j + 2 == MAX) map[i][j] = -1;
			else map[i][j] = 0;
		}
	}
	while (scanf("%d%*c%d%*c%d", &input_x, &input_y, &input_size) != EOF)jud(input_x, input_y, input_size, map);
	for (i = 0; i < MAX; i++){
		for (j = 0; j < MAX; j++){
			if (max < map[i][j]) max = map[i][j];
			if (!(map[i][j])) zero_count++;
		}
	}
	
	printf("%d\n%d\n", zero_count, max);
	return (0);
}

void jud(int x, int y, int size, int data[MAX][MAX])
{
	if (POINT(x + 1, y) != -1) POINT(x + 1, y)++;
	if (POINT(x, y) != -1) POINT(x, y)++;
	if (POINT(x - 1, y) != -1) POINT(x - 1, y)++;
	if (POINT(x, y + 1) != -1) POINT(x, y + 1)++;
	if (POINT(x, y - 1) != -1) POINT(x, y - 1)++;
	if (size > 1){
		if (POINT(x + 1, y + 1) != -1) POINT(x + 1, y + 1)++;
		if (POINT(x - 1, y + 1) != -1) POINT(x - 1, y + 1)++;
		if (POINT(x + 1, y - 1) != -1) POINT(x + 1, y - 1)++;
		if (POINT(x - 1, y - 1) != -1) POINT(x - 1, y - 1)++;
		if (size > 2){
			if (POINT(x + 2, y) != -1) POINT(x + 2, y)++;
			if (POINT(x - 2, y) != -1) POINT(x - 2, y)++;
			if (POINT(x, y + 2) != -1) POINT(x, y + 2)++;
			if (POINT(x, y - 2) != -1) POINT(x, y - 2)++;
		}
	}
}

Measured memory_bytes: 0
#[allow(unused_imports)]
use proconio::input;

// C - Sum of gcd of Tuples (Easy)
fn main() {
    input! {
        k: i32,
    }
    let mut sum = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    println!("{}", sum);
}

fn gcd(mut a: i32, mut b: i32) -> i32 {
    if a < b {
        let tmp = a;
        a = b;
        b = tmp;
    }
    if b == 0 {
        return a;
    }
    gcd(a % b, b)
}

Measured memory_bytes: 2112
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;

int main() {
	int N, K;
	cin >> N >> K;
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		cnt[A]++;
	}
	vector<int> v;
	for (auto p : cnt) v.push_back(p.second);
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i < max((int)v.size() - K, 0); i++) ans += v[i];
	cout << ans << endl;
}

Measured memory_bytes: 10748
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
#define ll long long
ll a[100005];
int main()
{
    stack<int>s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(!s.empty())
        {
            if(a[i]==s.top())
            {
                s.pop();
            }
            else
                s.push(a[i]);
        }
        else
        {
           s.push(a[i]);
        }
    }
    int num=s.size();
    cout<<num<<endl;
    return 0;
}


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

int main()
{
  vector<ll> M(2);
  vector<ll> D(2);
  for (int i=0; i<2; i++){
    cin >> M[i];
    cin >> D[i];
  }

  cout << M[1]-M[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

ll solve(int c[], int st, int en, int x, int a[][12], int m, int mask, vector<int> v){
	int comp = (1 << (en + 1)) - 1;
	bool f = true;
//	cout << st << " ";
	rep(i, 0, m){
//		cout << v[i] << " ";
		if(v[i] < x)
		f = false;
	}
//cout << endl;
	if(f)
		return 0;
	if(st > en){
		return INT_MAX;
	}
	
	ll so = solve(c, st + 1, en, x, a, m, mask, v);
	int  msk = mask;
	rep(i, 0, m){
		v[i] += a[st][i];
		if(v[i] >= x){
			msk = (mask | (1 << i));
		}
	}
	so = min(so, solve(c, st + 1, en, x, a, m, msk, v) + c[st]);
	return so;
}

int main() {
	FASTIO
	int n, m , x;
	cin >> n >> m >> x;
	int c[n];
	int a[12][12];
	for(int i = 0; i < n; i++){
		cin >> c[i];
		rep(j, 0, m)
			cin >> a[i][j];
	}
	int mask = 0;
	vector<int> v(m, 0);
	ll ans = solve(c, 0, n - 1, x, a, m, mask, v);
	if(ans >= INT_MAX)
		ans = -1;
	cout << ans;
	return 0;
}




Measured memory_bytes: 3652
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String ans = "";
        if(a==1)
            a=14;
        if(b==1)
            b=14;
        
        if(a>b)
            ans = "Alice";
        else if(a<b)
            ans = "Bob";
        else
            ans = "Draw";

        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

void dfs(int v, vvi &G, vector<bool> &seen){
  if(seen[v]) return;
  seen[v] = true;
  for(auto nv : G[v]) {
    dfs(nv, G, seen);
  }
}

int main(){
  int n,m,p; cin >> n >> m >> p;
  vvi G(n),rG(n);
  vector<tuple<int, int, int>> edges;
  rep(i,m) {
    int a,b,c; cin >> a >> b >> c;
    a--; b--;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    G[a].pb(b);
    rG[b].pb(a);
  }

  vector<bool> seen1(n,false);
  vector<bool> seen2(n,false);

  dfs(0, G, seen1);
  dfs(n-1, rG, seen2);

  vector<bool> ok(n);
  rep(i,n) ok[i] = seen1[i]&seen2[i];

  vi d(n,1e9);
  d[0] = 0;
  int step = 0;
  bool upd = true;
  while(upd){
    upd = false;
    rep(i,m) {
      int a,b,c;
      tie(a,b,c) = edges[i];
      if(!ok[a] || !ok[b]) continue;
      int newD = d[a] + c;
      if(newD < d[b]){
        upd = true;
        d[b] = newD;
      }
    }
    step++;
    if(step > n){
      cout << -1 << endl;
      return 0;
    }
  }
    
  int ans = -d[n-1];
  ans = max(ans,0);
  cout << ans << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define MAX 5115
signed main(){
  int n;
  cin>>n;
  int p[n],x[n];
  for(int i=1;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) cin>>x[i];
  vector<int> G[n];
  for(int i=1;i<n;i++){
    p[i]--;
    G[p[i]].push_back(i);
  }
  bool flg=1;
  int dp[2][MAX];
  function<int(int)> dfs=[&](int v){
    if(G[v].empty()) return 0;
    vector<int> a,b;
    int res=0;
    for(int u:G[v]){
      a.push_back(x[u]);
      b.push_back(dfs(u));
      res+=a.back()+b.back();
    }
    int m=G[v].size();
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<m;i++){
      int f=i%2;
      for(int j=0;j<MAX;j++) dp[!f][j]=0;
      for(int j=0;j<MAX;j++){
	if(j+a[i]<MAX) dp[!f][j+a[i]]|=dp[f][j];
	if(j+b[i]<MAX) dp[!f][j+b[i]]|=dp[f][j];
      }
    }
    int tmp=-1;
    for(int i=0;i<=x[v];i++)
      if(dp[m%2][i]) tmp=i;
    if(tmp<0) flg=0;
    return res-tmp;
  };

  
  dfs(0);

  
  if(flg) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 384
#ここまでテンプレ
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)
n = int(input())
point = 0
for i in range(1,n+1):
    if i % 3 != 0 and i % 5 != 0:
        point += i
print(point)

Measured memory_bytes: 9164
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    int H, W;
    int[][] B;
    int[] dx = {-1, 0, 1, 0};
    int[] dy = {0, -1, 0, 1};
    int BLACK = 0, WHITE = 1, VISITED = 2;

    void run() {
        Scanner sc = new Scanner(System.in);

        H = sc.nextInt();
        W = sc.nextInt();
        B = new int[H + 2][W + 2];

        Arrays.fill(B[0], VISITED);
        Arrays.fill(B[H + 1], VISITED);

        for (int i = 1; i <=H; i++) {
            Arrays.fill(B[i], VISITED);
            String l = sc.next();
            for (int j = 0; j < W; j++) {
                B[i][j + 1] = l.charAt(j) == '#' ? BLACK : WHITE;
            }
        }

        long ans = 0;
        for (int y = 1; y <= H; y++) for (int x = 1; x <= W; x++) {
            P c = solve(x, y);
            ans += 1L * c.bl * c.wh;
        }

        System.out.println(ans);
    }

    P solve(int x, int y) {
        int cell = B[y][x];
        B[y][x] = VISITED;

        P p = new P(0, 0);
        if (cell == BLACK) {
            p.bl += 1;
        } else if (cell == WHITE) {
            p.wh += 1;
        }

        for (int i = 0; i < 4; i++) if (B[y + dy[i]][x + dx[i]] == 1 - cell) {
            P next = solve(x + dx[i], y + dy[i]);
            p.bl += next.bl;
            p.wh += next.wh;
        }

        return p;
    }

    class P {
        int bl, wh;
        P(int bl, int wh) {
            this.bl = bl;
            this.wh = wh;
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 54360
def fctr(n):
    f = []
    c = 0
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            c+=1
            n = n//i
        if c!=0:
            f.append([i,c])
            c = 0

    if n!=1:
        f.append([n,1])

    return f

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

mod = 10**9 + 7
N,M = list(map(int,input().split()))
ans = 0
s = fctr(M)

for i in s:
    if ans == 0:
        ans = combination(N-1+i[1],i[1]) % mod
    else:
        ans = (ans*combination(N-1+i[1],i[1]))%mod

if M != 1:         
    print(ans)
else:
    print('1')

        
        
            


Measured memory_bytes: 3064
// aising2020_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int ans = 0;
    REP(i, N){
        if (i % 2 == 0 && A[i] % 2 == 1){
            ans++;
        }

    }
    print(ans);

    return 0;
}


Measured memory_bytes: 3608
from collections import defaultdict

def main():
    q = int(input())
    d = defaultdict(int)

    for _ in range(q):
        para = input().split()

        if para[0] == "0":
            d[para[1]] = int(para[2])

        elif para[0] == "1":
            print(d[para[1]])

        elif para[0] == "2":
            if para[1] in d.keys():
                del d[para[1]]
main()



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

int main(){
    int N;
    cin >> N;
    
    for(int h = 1; h <= 3500; h++){
        for(int n = 1; n <= 3500; n++){
            double c = (double)N * h * n;
            double p = (double)4 * h * n - N * h - N * n;
            if(p == 0)continue;
            double w = c / p;
            if(w == (int)w && w > 0){
                cout << h << " " << n << " " << (int)w << '\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
from itertools import permutations as per
tuples = per(range(1, N+1))
 
a = 0
b = 0
for i, t in enumerate(tuples):
    if t == P:
        a = i
    if t == Q:
        b = i
print(abs(a - b))


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

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int r = reader.nextInt();
    out.println(r * r);
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

vector<set<int>> e;
vector<bool> visited;
vector<int> s;
vector<int> candidate;

void dfs(int curr, int prev) {
    s.emplace_back(curr);
    visited[curr] = true;
    for (auto &to: e[curr]) {
        if (!candidate.empty()) return;
        if (visited[to]) {
            bool ok = false;
            for (auto &it: s) {
                if (it == to) ok = true;
                if (ok) candidate.emplace_back(it);
            }
        } else {
            dfs(to, curr);
        }
    }
    s.pop_back();
}


int main() {
    int n, m; cin >> n >> m;
    e.resize(n+1); visited.resize(n+1, false);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        e[a].insert(b);
    }

    for (int i = 1; i <= n; i++) {
        if (!visited[i] && candidate.empty()) {
            dfs(i, 0);
        }
    }

    if (candidate.empty()) {
        cout << -1 << endl;
        return 0;
    }

    while (true) {
        bool ok = true;
        vector<int> sw;
        for (int i = 0; i < candidate.size(); i++) {
            auto &curr = candidate[i];
            for (int j = 0; j < candidate.size(); j++) {
                if (j == (i+1) % candidate.size()) continue;
                auto &to = candidate[j];
                if (e[curr].find(to) != e[curr].end()) {
                    ok = false;
                    sw.emplace_back(curr); sw.emplace_back(to);
                    break;
                }
            }
            if (!ok) break;
        }
        if (ok) break;
        int sz = candidate.size();
        for (int i = 0; i < sz*2; i++) {
            if (candidate[i%sz] == sw.back()) sw.emplace_back(candidate[(i+1) % sz]);
            if (sw.front() == sw.back()) break;
        }
        sw.pop_back();
        swap(sw, candidate);
    }
    cout << candidate.size() << endl;
    for (auto &x: candidate) {
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES 
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);


int main() {
	int n, m, l, r, floor = 0, ceil = INF;
	cin >> n >> m;
	rep(i, m) {
		cin >> l >> r;
		floor = max(floor, l);
		ceil = min(ceil, r);
	}
	cout << max(0, ceil - floor + 1) << endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--;b--;c--;d--;
    REP(i,a,max(c,d)){
        if(s[i]=='#' && s[i+1]=='#'){cout<<"No"<<endl; return 0;}
    }
    if(d>c){cout<<"Yes"<<endl; return 0;}
    else{
        bool ok=false;
        REP(i,b,d+1){
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') ok=true;
        }
        YesNo(ok);
    }
    return 0;
}


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

namespace atcorder_BeginnerContest_123
{
    class Program
    {

        static void Main(string[] args)
        {

            int[] pointArr = new int[5];
            for (int i = 0; i < 5; i++)
            {
                pointArr[i] = int.Parse(Console.ReadLine());
            }

            int maxLen = int.Parse(Console.ReadLine());

            string ret = "Yay!";

            int cnt = 4;
            for(int i = 0; i < 4; i++)
            {
                bool endFlg = false;
                for (int j = 1; j <= cnt; j++)
                {
                    if (maxLen < (pointArr[i + j] - pointArr[i]))
                    {
                        ret = ":(";
                        endFlg = true;
                        break;
                    }
                }
                if (endFlg) break;
                cnt--;
            }

            Console.WriteLine(ret);

        }

    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> cnt;
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ans += cnt[i - a[i]];
    cnt[i + a[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 26516
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
const int primN = 3165000;
long long p[primN], hash[primN], pnum;
void mlist() {
    p[pnum++] = 2;
    for (int i=3; i<primN; i+=2)
        if (!hash[i]) {
            p[pnum++] = i;
            if (i<10000) for (int j=i*i; j<primN; j+=(2*i)) hash[j]=1;
        }
}
long long pf[60], pfnum = 0, lim[60];
void pfact(long long n) {
    pfnum = 0;
    if (n==1) {
        pfnum = 1;
        return;
    }
    for (int i=0; i<pnum&&p[i]*p[i]<=n;++i)
        if (n%p[i]==0) {
            lim[pfnum] = 0;
            while (n%p[i]==0) n/=p[i], ++lim[pfnum];
            pf[pfnum++] = p[i];
        }
    if (n!=1) lim[pfnum] =1, pf[pfnum++]= n;
}
void doit() {
    long long l;
    scanf("%lld", &l);
    if (l==0) exit(0);
 pfact(l);
    long long ans=1;
    for(int i=0;i<pfnum;i++)
    ans*=(2*lim[i]+1);
    ans=(ans+1)/2;
    printf("%lld\n", ans);
}

int main() {
    mlist();
    while (1) {
        doit();
    }
    return 0;
}

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

string data="NWSE";
int a[4];
int main(){
	string S;
	cin>>S;
	for(int i=0;i<S.size();i++){
		for(int j=0;j<4;j++)if(S[i]==data[j])a[j]++;
	}
	bool ans=(((a[0]>0)^(a[2]>0)) || ((a[1]>0)^(a[3]>0)));
	if(ans)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}	


Measured memory_bytes: 256
#[R,G,B,N] = list(map(int,input().split()))
N = int(input())
ans = 0
for i in range(1,int(N**(1/2))+1):
    if N % i == 0:
        if (N//i - 1) > i:
            ans += (N//i-1)
print(ans)

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

int M = 15000, N = 10;

int GetRandom(int min,int max){
	return min + (int)(rand()*(max-min+1.0)/(1.0+RAND_MAX));
}

int main(){
    // 入力
    int D;
    cin >> D;   // D = 365
    ll c[26];
    for(int i=0;i<26;i++)
        cin >> c[i];
    ll s[D][26];
    for(int i=0;i<D;i++)
        for(int j=0;j<26;j++)
            cin >> s[i][j];
    // 初期解t[D]
    int t[D];
    /*
    for(int i=0;i<D;i++)
        cin >> t[i];
    */
    for(int i=0;i<D;i++){
        //t[i] = GetRandom(1,26);   // 1<=, <=26
        t[i] = i%26 + 1;
        //cout << t[i] << endl; 
    }
    // クエリ
    // cin >> M;
    int d[M][N], q[M][N];
    /*
    for(int i=0;i<M;i++)
        cin >> d[i] >> q[i];
    */
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            d[i][j] = GetRandom(1,D);   // 1<=, <=365
            q[i][j] = GetRandom(1,26);   // 1<=, <=26
            //cout << d[i][j] << ' ' << q[i][j] << endl; 
        }
    }

    // 処理部
    ll v_best = 0;
    for(int query=0;query<M;query++){
        int last[26] = {}, q_[N];
        // コンテスト種別の変更（N個）
        for(int i=0;i<N;i++){
            q_[i] = t[d[query][i]-1];
            t[d[query][i]-1] = q[query][i];
        }
        // D日分
        ll v = 0;
        for(int i=1;i<=D;i++){
            // 満足度の増加分
            v += s[i-1][t[i-1]-1];
            last[t[i-1]-1] = i;
            // 満足度の低下分（コンテスト26種分）
            for(int j=0;j<26;j++)
                v -= c[j]*(i - last[j]);
        }
        // cout << v << endl;
        if(v < v_best){
            for(int i=0;i<N;i++){
                t[d[query][i]-1] = q_[i];
            }
        }else{
            v_best = v;
        }
    }

    // 答え出力
    for(int i=0;i<D;i++)
        cout << t[i] << endl;
    //cout << v_best << endl;

}


Measured memory_bytes: 4864
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    S = readline().rstrip()
    T = readline().rstrip()
    ans = 0
    for s, t in zip(S, T):
        if s == t:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188