akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=200010;
char s[maxn];
int n,nxt[maxn][26],f[maxn],t[maxn],r[maxn];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=n;i>=0;i--)
		for(int c=0;c<=25;c++)
		{
			if(s[i]-'a'-c==0) nxt[i][c]=i;
			else if(i==n) nxt[i][c]=n+1;
			else nxt[i][c]=nxt[i+1][c];
		}
	/*for(int i=0;i<=n;i++)
	{
		for(int c=0;c<=25;c++)
			cout<<nxt[i][c]<<' ';
		cout<<endl;
	}*/
	f[n+1]=1;
	for(int i=n;i>=0;i--)
	{
		f[i]=maxn;
		for(int c=0;c<=25;c++)
			if(f[nxt[i][c]+1]+1<f[i])
			{
				
				f[i]=f[nxt[i][c]+1]+1;
				t[i]=nxt[i][c]+1;
				r[i]=c;
				//cout<<i<<' '<<c<<' '<<f[i]<<' '<<t[i]<<endl;
			}
	}		
	int pnt=0;			
	while (t[pnt]!=0) {printf("%c",r[pnt]+'a');pnt=t[pnt];}		
	return 0;
}

Measured memory_bytes: 23040
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){

    string s;
    cin>>s;

    
    for(int i=0;i<s.length();i=i+2){
        if(s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(int i=1;i<s.length();i=i+2){
        if(s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;

}

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

using namespace std;
int main() {
	int D, N,ans;
	cin >> D >> N;
	if (N == 100) {
		ans = 101;
		if(D==0)
		cout << 101  << endl;
		else {
			for (int i = 1; i <= D; i++) {
				ans *= 100;
			}
			cout << ans << endl;
		}
	}
	else{
		ans = N;
			if (D == 0)
				cout << ans << endl;
			else {
				for (int i = 1; i <= D; i++) {
					ans *= 100;
				}
				cout << ans << endl;
			}
		}
	
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
bool prime(int n){
	if(n==2) return true;
	for(int i = 2; i <= sqrt(n); i++){
		if(n%i==0) return false;
	}
	return true;
}
int main(){
	long long n;
	cin >> n;
	while(!prime(n)){
		n++;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
// atcoder/abc142/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    double odd = 0;
    for (int i = 1; i <= n; ++i) {
      if (i % 2) ++odd;
    }
    printf("%.10lf\n", odd / n);
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (lint i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define N 45000
int main()
{
    vi s(N + 1, 1);
    lint l, r;
    cin >> l >> r;
    s[0] = s[1] = 0;
    vi count(r - l + 1, 0);
    vi num(r - l + 1);
    rep(i, r - l + 1)
    {
        num[i] = l + i;
    }
    rep(i, N + 1)
    {
        if (s[i] == 1)
        {
            lint p = i;
            for (int j = p + p; j <= N; j = j + p)
            {
                s[j] = 0;
            }
            while (p <= r)
            {
                for (int j = (l + p - 1) / p * p; j <= r; j += p)
                {
                    num[j - l] /= i;
                    count[j - l]++;
                }
                p *= i;
            }
        }
    }
    lint ans = 0;
    rep(i, r - l + 1)
    {
        if (num[i] != 1)
        {
            count[i]++;
        }
        if (s[count[i]])
        {
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18936
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <algorithm>
using namespace std;
typedef tuple<int, int, int> T;

int main() {
	int N, M;
	while(cin >> N >> M && (N || M)){
		int r;
		cin >> r;
		vector<T> vec[M + 1];
		int t, n, m, s;
		for(int i = 0; i < r; ++i){
			cin >> t >> n >> m >> s;
			vec[m].push_back(make_tuple(t, n, s));
		}
		int q;
		cin >> q;
		int ts, te, mt;
		for(int i = 0; i < q; ++i){
			cin >> ts >> te >> mt;
			
			int ls[1001] = {0};
			bool l[1270];
			fill(l, l + 1270, false);
			for(auto it = vec[mt].begin(); it != vec[mt].end(); ++it){
				int first = get<0>((*it));
				int second = get<1>((*it));
				int third = get<2>((*it));
				
				if(third){
					ls[second] = max(first, ts);
				}
				else if(ls[second] != 0){
					int e = min(first, te);
					if(e - ls[second] <= 0){
						ls[second] = 0;
							continue;
					}
					for(int j = ls[second]; j <= e; ++j)
						l[j] = true;
					ls[second] = 0;
				}
				
			}
			int ans = 0;
			for(int j = 0; j < 1270; ++j){
				if(l[j]){
					int k = j;
					for(; k < 1270; ++k){
						if(!l[k])
							break;
					}
					ans += (k - j - 1);	
					j = (k - 1);
				}
			}
				
			cout << ans << endl;
		}
		
		
	}
	return 0;
}

Measured memory_bytes: 1448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
vector<int> a;

void mainmain(){
    cin >> n;
    static int sum = 0;
    for (int i = 0;i < n; i++){
        int m;
        cin >> m;
        a.push_back(m);
        sum += m;
    }
    int avrg = (int)round((double)sum/n);
    //cout << avrg <<endl;
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += (avrg - a[i])*(avrg - a[i]);
    }
    cout << ans << endl;
}

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

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];


	cin>>n;

	m=sqrt(n);

	cout<<m*m<<endl;


}


Measured memory_bytes: 256
s = input()
s_len = len(s)
n = 2019
mod_list = [0] * n
mod_list[0] = 1

p = 1
d = 0
for t in reversed(s):
    d += int(t) * p
    m = d % n
    mod_list[m] += 1
    p *= 10
    p %= 2019

result = sum(i * (i - 1) // 2 for i in mod_list)
print(result)

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, m, x, y, z, a[10][1100], res;
int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < n; i++) {
        cin >> x >> y >> z;
        for (ll j = 0; j < 2; j++) {
            for (ll k = 0; k < 2; k++) {
                for (ll l = 0; l < 2; l++) {
                    a[j * 4 + k * 2 + l][i] = x * (j ? 1 : -1) + y * (k ? 1 : -1) + z * (l ? 1 : -1);
                }
            }
        }
    }
    for (ll i = 0; i < 8; i++) {
        sort(a[i] , a[i] + n);
        reverse(a[i], a[i] + n);
    }
    for (ll i = 0; i < 8; i++) {
        ll ans = 0;
        for (ll j = 0; j < m; j++) {
            ans += a[i][j];
        }
        res = max(res, ans);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(void){
    int H,W,N;
    scanf("%d",&H);
    scanf("%d",&W);
    scanf("%d",&N);
    int count = 0;
    if(H>W){
        if(N%H!=0) count =1;
        printf("%d",N/H+count);
        return 0;
    }else{
        if(N%W!=0) count =1;
        printf("%d",N/W+count);
        return 0;
    }
    return 0;
    
}

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

int main() {
	int N;
	cin >> N;
	int D, X;
	cin >> D >> X;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		X += (D - 1) / A.at(i) + 1;

	}
	cout << X << endl;
}

Measured memory_bytes: 3560
fn input1<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn min(a: usize, b: usize) -> usize {
    if a < b { a } else { b }
}

fn main() {
    let n: usize = input1().unwrap();
    let mut result = [100000; 100];
    for (i, b) in input_arr::<usize>().into_iter().enumerate() {
        result[i] = min(result[i], b);
        result[i + 1] = min(result[i + 1], b);
    }

    println!("{}", result.iter().take(n).sum::<usize>());
}


Measured memory_bytes: 4352
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    """
    道を全部張った後に最小全域木を求めれば良いー＞プリム
    """
    N = int(input())
    city_x = defaultdict(list)
    city_y = defaultdict(list)
    indexes_x = set()
    indexes_y = set()
    for v in range(N):
        x, y = map(int, input().split())
        city_x[x].append(v)
        city_y[y].append(v)
        indexes_x.add(x)
        indexes_y.add(y)
    indexes_x = list(indexes_x)
    indexes_y = list(indexes_y)
    indexes_x.sort()
    indexes_y.sort()

    # 必要な道のみに間引く
    repn = [[] for _ in range(N)]
    pre_x = -1
    for x in indexes_x:
        pre_v = city_x[x][0]
        for i, v in enumerate(city_x[x]):
            if i == 0: continue
            repn[v].append((0, pre_v))
            repn[pre_v].append((0, v))
            pre_v = v
        if pre_x != -1:
            repn[city_x[pre_x][0]].append((x - pre_x, pre_v))
            repn[pre_v].append((x - pre_x, city_x[pre_x][0]))
        pre_x = x
    pre_y = -1
    for y in indexes_y:
        pre_v = city_y[y][0]
        for i, v in enumerate(city_y[y]):
            if i == 0: continue
            repn[v].append((0, pre_v))
            repn[pre_v].append((0, v))
            pre_v = v
        if pre_y != -1:
            repn[city_y[pre_y][0]].append((y - pre_y, pre_v))
            repn[pre_v].append((y - pre_y, city_y[pre_y][0]))
        pre_y = y
    # for i in range(N): print(repn[i])

    # プリム
    unvisited = set([i for i in range(1, N)])
    ans = 0
    q = []
    for cost, v in repn[0]: heappush(q, (cost, v))
    while q:
        cost, v = heappop(q)
        if v not in unvisited: continue
        ans += cost
        unvisited.remove(v)
        if not unvisited: break
        for next_cost, u in repn[v]:
            if u not in unvisited: continue
            heappush(q, (next_cost, u))
    print(ans)





if __name__ == "__main__":
    main()


Measured memory_bytes: 165012
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
    }
    //inputend;
    bool flagout=0;
    REP(i,N){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                flagout=1;
            }
        }
    }
    if(flagout){
        cout<<"DENIED"<<endl;
    }else{
        cout<<"APPROVED"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
long long dp[1000010][2][2];
const long long mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	dp[1][0][0] = 8;
	dp[1][1][0] = 1;
	dp[1][0][1] = 1;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k] * 8) % mod;
				dp[i + 1][j | 1][k] = (dp[i + 1][j | 1][k] + dp[i][j][k]) % mod;
				dp[i + 1][j][k | 1] = (dp[i + 1][j][k | 1] + dp[i][j][k]) % mod;
			}
		}
	}
	cout << dp[n][1][1];
	return 0;
}

Measured memory_bytes: 34840
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int par[100005];
int rnk[100005];

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rnk[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

set<int> F[100005];
set<int> B[100005];

int main() {
  ios::sync_with_stdio(false);
  int N, M, K, a, b;
  cin >> N >> M >> K;
  init(N+1);
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    unite(a, b);
    F[a].insert(b);
    F[b].insert(a);
  }
  for (int i=0; i<K; i++) {
    cin >> a >> b;
    B[a].insert(b);
    B[b].insert(a);
  }
  map<int, ll> m;
  for (int i=1; i<=N; i++) {
    m[find(i)]++;
  }
  for (int i=1; i<=N; i++) {
    ll d = m[find(i)];
    ll ret = d - 1;
    ret -= F[i].size();
    for (set<int>::iterator it = B[i].begin(); it != B[i].end(); ++it) {
      if (same(i, *it)) ret--;
    }
    cout << ret;
    if (i < N) cout << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 35584
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    let (a, b) = (sc.next::<u32>(), sc.next::<u32>());
    let r = (a..b + 1)
        .filter(|i| {
            let s = i.to_string();
            let s = s.as_bytes();
            let n = s.len();
            for j in 0..n {
                if s[j] != s[n - j - 1] {
                    return false;
                }
            }
            true
        })
        .count();
    println!("{}", r);
}

struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}

trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

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

#define fr first
#define sc second

int main(){
	static int N;
	static int a[300010];
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d",&a[i]);
	}
	
	static int sumA[300010],sumB[300010];
	sumA[0] = 0;
	sumB[0] = 0;
	for(int i = 1 ; i <= N ; i ++){
		sumA[i] = sumA[i-1];
		sumB[i] = sumB[i-1];
		if(i%2 == 1)sumA[i] += a[i];
		else sumB[i] += a[i];
	}
	
	int ret = max(sumA[N],sumB[N]);
	if(N%2 == 1){
		int l = 0, r = 1000000000;
		while(l<r){
			int m = (l+r+1)/2;
			int sum = 0;
			for(int i = 1 ; i <= N ; i ++){
				if(i%2 == 1)sum += a[i];
				else{
					if(sum < a[i] && sum >= m)sum = 0;
					else sum -= a[i];
				}
			}
			if(sum >= m)l = m;
			else r = m-1;
		}
		ret = max( ret , sumB[N]+l );
	}
	
	cout << ret << " " << sumA[N]+sumB[N]-ret << endl;
}
	



Measured memory_bytes: 3712
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    in_arr(int, a, n);
    sort(a.begin(), a.end());
    x -= accumulate(a.begin(), a.end(), 0);
    cout << x / a[0] + n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	//int b;
	//int c;
	//int d;
	int e;
	cin >> a;
	//string s;
	//std::cin >> s;
	cout << 48 - a << "\n";
	std::cin >> e;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int func(int a, int b)
{
    int r;

    r = a % b;
    while (r != 0){
         a = b;
         b = r;
         r = a % b;
    }
    return (b);
}

int main(void)
{
    int x, y;

    scanf("%d %d", &x, &y);

    if (x < y){
        printf("%d\n", func(y, x));
    }
    else {
        printf("%d\n", func(x, y));
    }
    return (0);
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

double dist(vector<double>& x, vector<double>& y, int tmp, int to)
{
    double dx = x[to] - x[tmp];
    double dy = y[to] - y[tmp];
    return sqrt(dx*dx + dy*dy);
}

void dfs(vector<double>& x, vector<double>& y, int tmp, vector<bool>& vis, double& ans, double d)
{
    // static int c = 0;
    // for(int i=0; i<vis.size(); i++) cout << vis[i] << " ";
    // cout << endl;
    bool all = true;
    for(int i=0; i<vis.size(); i++){
        if(!vis[i]){
            all = false;
            vis[i] = true;
            dfs(x, y, i, vis, ans, d+dist(x, y, tmp, i));
            vis[i] = false;
        }
    }
    if(all){
        ans += d;
        // cout << c << endl;
        // c++;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    for(int i=0; i<N; i++) cin >> x[i] >> y[i];

    ll fact[9];
    fact[0] = 1;
    for(int i=1; i<9; i++) fact[i] = fact[i-1] * i;

    double ans = 0;
    vector<bool> vis(N, false);
    for(int i=0; i<N; i++){
        vis[i] = true;
        dfs(x, y, i, vis, ans, 0);
        vis[i] = false;
    }

    ans /= fact[N];
    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    
        
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll k,n,i;
    cin>>k>>n;
    int arr[n];
    for(i=0;i<n;i++)
    	cin>>arr[i];
    vector <pair <ll,ll> > dist;
    for(i=0;i<n-1;i++)
    {
    	dist.push_back(make_pair(abs(arr[i]-arr[i+1]),i));
    }
    dist.push_back(make_pair(abs(arr[0]+k-arr[n-1]),n-1));
    sort(dist.begin(),dist.end(),greater <pair<ll,ll> >());
    ll res1 = 0;
    for(i=1;i<dist.size();i++)
    	res1 = res1 + dist[i].first;
    cout<<res1<<endl;
    
    return 0;
}

Measured memory_bytes: 7152
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a;
  int x,y,z,o;
  cin >> a;
  x = a/1000;
  y = (a/100) % 10;
  z = (a/10) % 10;
  o = a % 10;
  if(x == y && y == z){
    cout << "Yes" << endl;
  }else if(y == z && z == o){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <string>

using ll = long long;

using namespace std;

ll calc_dist(ll n, ll x, ll y, ll first, ll second) {
    ll dist = second - first;
    dist = min(dist, abs(x - first) + 1 + abs(y - second));
    return dist;
}

void solve() {
    ll n, x, y;
    cin >> n >> x >> y;
    --x, --y;
    std::vector<int> answers(n, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ++answers[calc_dist(n, x, y, i, j)];
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << answers[i] << '\n';
    }
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define erep(i, a, b) for (int i = a; i <= (int)(b); ++i)
#define per(i, a, b) for (int i = (b); i > (a); --i)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; --i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
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;
vector<int> g[100005];
int distF[100005], distS[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    fill(distF, distF + n, INF);
    fill(distS, distS + n, INF);
    rep(i, 0, n-1)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    queue<int> que;
    que.push(0);
    distF[0] = 0;
    while (!que.empty())
    {
        int v = que.front();
        que.pop();
        for (int nxt : g[v])
        {
            if (distF[nxt] == INF)
            {
                distF[nxt] = distF[v] + 1;
                que.push(nxt);
            }
        }
    }

    queue<int> q;
    q.push(n-1);
    distS[n-1] = 0;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int nxt : g[v])
        {
            if (distS[nxt] == INF)
            {
                distS[nxt] = distS[v] + 1;
                q.push(nxt);
            }
        }
    }

    int ans = 0;
    rep(i, 0, n) {
        if (distF[i] <= distS[i]) ans++;
        else ans--;
        // cout << distF[i] << "  " << distS[i] << endl;
    }
    printf("%s\n", ans > 0 ? "Fennec" : "Snuke");
    return 0;
}


Measured memory_bytes: 6656
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using P = pair<int,int>;

const ll INF = 1LL<<60;

//#define __DBG__


void solve(void){

  int K, X;
  cin >> K >> X;

  puts(K*500>=X?"Yes":"No");

  return;
}

int main(int argc, const char * argv[]) {



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int h,w,K;
  cin >> h >> w >> K;
  vector<string> g(h);
  rep(i,h){
    cin >> g[i];
  }
  ll sum=0;
  ll ans=0;
  rep(i,(1<<h)){
    rep(j,(1<<w)){
      sum=0;
      rep(k,h){
        rep(l,w){
          if(((i&(1<<k))==0)&&((j&(1<<l))==0)&&g[k][l]=='#') sum++;
        }
      }
      if(sum==K) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <map>
#include <list>
#include <queue>
#include <cstdlib>
#define INF (1000000007)
#define distance(x1,y1,x2,y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
#define rep(i,N) for(ll i=0;i<N;i++)
#define rep2(i,j,k) for(ll i=j; i<k;i++)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vs=vector<string>;
using vvs=vector<vector<string>>;

template <typename T>
void print(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": "<<v[i]<<endl;}
}

template <typename T>
void print2(T v){
    for(size_t i=0;i<v.size();i++){
        cout<<i<<": ";
        for(size_t j=0;j<v[0].size();j++){
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }
}

template <typename T>
T slice(T v,ll left,ll right){
    T ret(0);
    copy(v.begin()+left,v.begin()+right,back_inserter(ret));
    return ret;
}

int main(){    
    char s;
    cin>>s;
    if(s=='A'){
        cout<<"T"<<endl;
    }
    else if(s=='T'){
        cout<<"A"<<endl;
    }
    else if(s=='C'){
        cout<<"G"<<endl;
    }
    else if(s=='G'){
        cout<<"C"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int n, m;
ll a[100001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= n; i++){a[i] += a[i-1]; a[i]%= m;}
    map<ll, ll> mp;
    ll res = 0;
    mp[0] = 1;
    for(int i = 1; i <= n; i++){
        res += mp[a[i]]; mp[a[i]]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 8160
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(HP,N);
    vector<int> A(N,0);
    ll sum = 0;
    rep(i,N)cin>>A[i],sum+=A[i];
    cout << ((sum>=HP)? "Yes":"No") << nn;
    return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int sum=0;
    for (int i=0; i<N; i++){
        int x;
        cin >> x;
        if(x<K-x) {sum+=x*2;}
        else {sum+=(K-x)*2;}
    }

    cout << sum << endl;
    
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
i64 elathos[(i64)(1e7) + 1];
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n;
cin >> n;
for(i32 i = 1; i <= n; i++){
    for(i32 j = 1; i * j <= n; j++){
        elathos[i * j]++;
    }
}
i64 ans = 0;
for(i32 i = 1; i <= n; i++){
    ans += i * elathos[i];
}
cout << ans << endl;
/*for(i32 i = 1; i <= n; i++){
    cout << elathos[i] << " \n"[i == n];
}*/
}

Measured memory_bytes: 81732
using System;
using System.Linq;
//using System.Collections.Generic;

class Test
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        Dice[] dice = new Dice[n];

        for (int i = 0; i < n; i++)
        {
            dice[i] = new Dice(Console.ReadLine().Split().Select(int.Parse).ToArray());
        }

        int flag = 0;
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (dice[i].CompareDice(dice[j]))
                {
                    Console.WriteLine("No");
                    flag = 1;
                    break;
                }
            }
            if (flag == 1) break;
        }

        if (flag == 0) Console.WriteLine("Yes");
    }
}

class Dice
{
    public int[] face = new int[6];

    public Dice(int[] num)
    {
        for (int i = 0; i < num.Length; i++)
        {
            this.face[i] = num[i];
        }
    }

    string r = "EEENNEEENEEENNEEEENEEENNEEE";
    public bool CompareDice(Dice j)
    {
        foreach (char x in r)
        {
            if (x == 'E')
            {
                int temp = this.face[0];
                this.face[0] = this.face[3];
                this.face[3] = this.face[5];
                this.face[5] = this.face[2];
                this.face[2] = temp;
            }
            if (x == 'N')
            {
                int temp = this.face[0];
                this.face[0] = this.face[1];
                this.face[1] = this.face[5];
                this.face[5] = this.face[4];
                this.face[4] = temp;
            };

            if (this.face[0] == j.face[0] && this.face[1] == j.face[1] && this.face[2] == j.face[2] && this.face[3] == j.face[3] && this.face[4] == j.face[4] && this.face[5] == j.face[5])
            {
                return true;
            }
        }
        return false;
    }
}


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

using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
       cin >> a[i];
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
       if(a[i]==a[i+1]){
           cout << "NO" << endl;  
           return 0;} 
        }
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4316
//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long
#define int unsigned long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {
    int n;
    cin>>n;int sum=0;
    repA(i,1,n)
    {
        if(i%3!=0&&i%5!=0&&i%15!=0)sum+=i;
    }
    cout<<sum<<endl;

  }



signed main()
{
   FAST
   
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 3648
import java.util.*;

class Main {
    boolean[][] MAP;
    int H, W;

    Main(){
        Scanner SC = new Scanner(System.in);
        H = Integer.parseInt(SC.next());
        W = Integer.parseInt(SC.next());

        MAP = new boolean[W][H];

        for(int y=0;y<H;y++){
            String S = SC.next();
            for(int x=0;x<W;x++){
                if(S.charAt(x) == '.'){
                    MAP[x][y] = true;
                } else {
                    MAP[x][y] = false;
                }
            }
        }

        int max=0;
        for(int x=0;x<W;x++){
            for(int y=0;y<H;y++){
                if(MAP[x][y]){
                    max = Math.max(max, BFS(x,y));
                }
            }
        }

        System.out.println(max);
    }

    class Node{
        int x,y,cost;

        Node(int x, int y, int cost){
            this.x = x;
            this.y = y;
            this.cost = cost;
        }
    }

    int BFS(int x, int y){
        ArrayList<Node> openList  = new ArrayList<Node>();
        boolean[][] isDone = new boolean[W][H];

        openList.add(new Node(x,y,0));
        isDone[x][y] = true;

        int max = 0;
        Node[] temp = new Node[4];
        while(!openList.isEmpty()){
            Node node = openList.get(0);

            max = Math.max(node.cost, max);

            temp[0] = new Node(node.x-1, node.y, node.cost+1);
            temp[1] = new Node(node.x+1, node.y, node.cost+1);
            temp[2] = new Node(node.x, node.y-1, node.cost+1);
            temp[3] = new Node(node.x, node.y+1, node.cost+1);

            for(int i=0;i<4;i++){
                if(temp[i].x < 0 || W <= temp[i].x)continue;
                if(temp[i].y < 0 || H <= temp[i].y)continue;
                if(MAP[temp[i].x][temp[i].y] && !isDone[temp[i].x][temp[i].y]){
                    openList.add(temp[i]);
                    isDone[temp[i].x][temp[i].y] = true;
                }
            }

            openList.remove(0);
        }

        return max;
    }

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

}


Measured memory_bytes: 37692
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false;
double sqrtNum = sqrt(num);
for(int i=3;i<=sqrtNum;i+=2){
if(num%i==0){
return false;
}
}
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}	
int q[10000000];
int w[10000000];
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b=0,c=0;
    cin>>a;
    for(int i=0;i<a;i++) cin>>q[i];
    for(int i=0;i<a;i++){
	if(q[i]!=i+1-b) b++;
    }
    if(b!=a) cout<<b<<"\n";
    else cout<<"-1\n";
}


Measured memory_bytes: 2304
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce


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


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    ans = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans += gcd(gcd(i, j), k)
    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.end()
#define inf 1e9
#define Puts(x) puts(x? "YES":"NO")
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  vvi a(2, vi(n));
  rep(i, 0, 2) rep(j, 0, n) cin >> a[i][j];

  vvi dp(3, vi(n + 1, 0));
  rep(i, 1, 3) rep(j, 1, n + 1) dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i - 1][j - 1];
  cout << dp[2][n] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NUM_THINKING 4


int main(void) {
   int value = 0;
   char S[NUM_THINKING+1];


   if(fgets(S, NUM_THINKING+1, stdin) == NULL || S[0] == '\n'){
       return EXIT_FAILURE;
   }

   for(int i = 0; i < NUM_THINKING; i++){
       if(S[i] == '+'){
           value++;
       }
       else if(S[i] == '-'){
           value--;
       }
   }

   printf("%d", value);

   return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	cin>>n;
	int dp[110][30]={};
	int a[110]={};
	rep(i,0,n) cin>>a[i];

	dp[1][a[0]]=1;
	rep(i,1,n-1){
		rep(j,0,21){
			if(dp[i][j]){
				int tmp1=j+a[i];
				int tmp2=j-a[i];
				//o(i<<" "<<j<<" "<<tmp1<<" "<<tmp2<<" "<<dp[i][j]);
				if(tmp1<=20) dp[i+1][tmp1]+=dp[i][j];
				if(0<=tmp2) dp[i+1][tmp2]+=dp[i][j];
			}
		}
	}
	int ans=dp[n-1][a[n-1]];
	o(ans);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vel A(N); rep(i,N) cin >> A[i];
    vel r(N); r[0] = 0LL;
    rep(i,N) {
        if(i % 2 == 0) r[0] += A[i];
        else r[0] -= A[i];
    }
    rep1(i,N) {
        r[i] = 2 * A[i - 1] - r[i - 1];
    }
    rep(i,N-1) cout << r[i] << " ";
    cout << r[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

vector<int> path[100016];
int maxPath[100016];

int func(int v) {
	if(path[v].empty()) {
		return 0;
	}
	if(maxPath[v]==0) {
		int p = 0;
		for(int n : path[v]) {
			p = max(p, func(n)+1);
		}
		maxPath[v] = p;
	}
	return maxPath[v];
}

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i=0; i<M; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		path[x-1].emplace_back(y-1);
	}
	int result = 0;
	for(int i=0; i<N; ++i) {
		result = max(result, func(i));
	}
	printf("%d\n", result);

	return 0;
}


Measured memory_bytes: 8192
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
#define endl		"\n"
#define EPS		    1e-9
//#define MOD         1e9 + 7	    
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { -1, 1, 0, 0, 1, -1, 1, -1 };

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	fast();
	int a, b, c;
	cin >> a >> b >> c;
	int mx = a - b;
	cout << max(0, c - mx);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <limits>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;


const int INF = 1e9;

struct Edge {
    int s, t, d;
};


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

    int V, E, r;
    cin >> V >> E >> r;
    vector<Edge> edge(E);
    FOR(i, E) {
        auto &e = edge[i];
        cin >> e.s >> e.t >> e.d;
    }

    vector<int> dist(V, INF);
    dist[r] = 0;

    int i = 0;
    for (; i < V; ++i) {
        bool updated = false;
        for (auto &e: edge) {
            if (dist[e.s] != INF &&
                dist[e.s] + e.d < dist[e.t]) {
                dist[e.t] = dist[e.s] + e.d;
                updated = true;
            }
        }
        if (!updated) break;
    }
    if (i == V) {
        cout << "NEGATIVE CYCLE" << endl;
    }
    else {
        for (auto &d: dist) {
            if (d == INF) cout << "INF";
            else cout << d;
            cout << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 1232