akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s.at(i) == '1') {
            s.at(i) = '9';
        }else if (s.at(i) == '9'){
            s.at(i) = '1';
        }
    }
    cout << s << endl;
    
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>

using namespace std;
 


 
const long long B = 61;
long long a, b;
long long p;
long long ans;
 
int main()
{
    cin >> a >> b;
    if (a == b) 
    {
        cout << 1 << endl;
        exit(0);
    }
    for (long long i = B - 1; i >= 0; i--)
    {
        if ((b & (1ll << i)) && !(a & (1ll << i)))
        {
            p = i;
            for (long long k = p - 1; k >= 0; k--)
            {
                if (b & (1ll << k))
                {
                    b |= ((1ll << (k + 1)) - 1);
                    break;
                }
            }
            break;
        }
    }
    long long l = a + (1ll << p);
    long long r = a | ((1ll << (p + 1)) - 1);
    ans += max(0ll, b - a + 1);
    ans += max(0ll, r - l + 1);
    ans -= max(0ll, b - l + 1);
    cout << ans << '\n';
}






Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	char a[102];
	int b = 0;
	for (int i = 0; i < 102; i++){
		a[i] = NULL;
	}
	scanf("%s", a);
	for (int i = 0; i < 100; i++){
		if (b == 0){
			if (a[i] == 'C')b++;
		}
		if (b == 1){
			if (a[i] == 'F')b++;
		}
	}
	if (b==2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long int n,a,b;
	cin>>n>>a>>b;
	long long int ans=0;
	ans+=(n/(a+b))*a;
	n=n%(a+b);
	if(n<=a) ans+=n;
	else ans+=a;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<vector>
#include<queue>
#define N 500010
using namespace std;
typedef long long ll;
int main()
{
    ll a,b;
  cin>>a>>b;
  if (a==b||a%b==0)
     cout << "-1" << endl;
 else
 {
     for (int i=2;;i++)
     {
         if (a*i%b!=0)
          {
              cout << a*i << endl;
              break;
          }
          if (a*i>1000000000000000000)
          {
              cout << "-1" << endl;
              break;
          }
     }
 }
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
def resolve():
    from collections import deque
    a = deque(input())
    b = deque(input())
    c = deque(input())
    turn = a

    while True:
        if len(turn) == 0:
            if next == "a":
                print("A")
                exit()
            if next == "b":
                print("B")
                exit()
            if next == "c":
                print("C")
                exit()
        next = turn.popleft()
        if next == "a":
            turn = a
        elif next == "b":
            turn = b
        elif next == "c":
            turn = c


resolve()

Measured memory_bytes: 38384
#include<stdio.h>
main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(i=1;i<=H;i++){
      for(j=1;j<=W;j++){
        printf("#");
      }
      printf("\n");
    }
printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

class FermatCombination{
public:
  vector<ll> factrial; // 階乗
  vector<ll> inverse; // 逆元
  FermatCombination(int size){
    factrial.resize(size+1);
    inverse.resize(size+1);
    factrial[0] = 1;
    inverse[0] = 1;
    for(int i = 1; i < size+1; i++){
      factrial[i] = factrial[i-1] * i % DIV;
      inverse[i] = pow(factrial[i],DIV-2,DIV);
    }
  }
  ll combination(int n, int k){
    if(n < k) return 0; 
    return factrial[n]* inverse[k] % DIV * inverse[n - k] % DIV;
  }
  ll permutation(int n, int k){
    if(n < k) return 0; 
    return factrial[n] * inverse[n-k] % DIV;
  }
  ll multi_choose(int n, int k){
    if(n == 0 && k == 0) return 1;
    else return combination(n+k-1,k);
  }
};
int main(){
  ll n,m; cin >> n >> m;
  if(abs(n-m) > 1){cout << 0 << endl; return 0;}
  FermatCombination fc(300000);
  cout << ((n==m)?2:1) * fc.factrial[n]*fc.factrial[m]%DIV << endl;
}

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

using namespace std;
using i64 = int64_t;

int main()
{
    string s;
    cin >> s;
    int a = 0;
    int aa = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
            aa++;
        else
        {

            a = max(a, aa);
            aa = 0;
        }
    }
    a = max(a, aa);
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(void) {
    int A[3];
    int max;
    int min;
    for (int i = 0; i < 3; i++) {
        scanf("%d", &A[i]);
    }
    max = min = A[0];
    for (int i = 1; i < 3; i++){
        if (max < A[i]){
            max = A[i];
        }
        else if (min > A[i]){
            min = A[i];
        }
    }
    printf("%d\n", max - min);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

ll k;
ll cnt = 0;
bool isOk = false;
ll result = 0;

void counter(int n, int keta)
{
  if (keta == 1) {
    cnt++;
    if (cnt == k) {
      isOk = true;
      result += n;
    }
    return;
  } else {
    if (n - 1 >= 0) {
      counter(n-1, keta-1);
      if (isOk) {
        result += n * pow(10, keta-1);
        return ;
      }
    } 
    counter(n, keta-1);
    if (isOk) {
      result += n * pow(10, keta-1);
      return ;
    }
    if (n + 1 < 10) {
      counter(n+1, keta-1);
      if (isOk) {
        result += n * pow(10, keta-1);
        return ;
      }
    }
  }
}

int main()
{
  cin >> k;

  ll now = 1;
  ll keta = 1;
  while (1) {
    ll tmp = now;
    for (int i = 1; i <= 9; i++) {
      now += tmp;
      counter(i, keta);
      if (result != 0) {
        cout << result << endl;
        return 0;
      }
    }
    now *= 10;
    keta++;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N,max=0;
    
    
    map<string ,int> smap;
    cin >> N;
    vector<string> S(N);
    REP(i,N){
        cin >> S[i];
    }
    sort(ALL(S));
    REP(i,N){
        if(smap.count(S[i])){
            smap[S[i]]++;
            if(max < smap[S[i]]){
                max = smap[S[i]];
            }
        }else{
            smap[S[i]]=1;
            if(max < smap[S[i]]){
                max = smap[S[i]];
            }
        }
    }
    for(auto i = smap.begin();i !=smap.end();++i) {

        if(i->second==max){cout << i->first << endl;}
    }

    
    return 0;
}

Measured memory_bytes: 25472
#include<stdio.h>
int main(void)
{
	int t, n, i, s, e, zen=0;
	while (1)
	{
		scanf("%d", &t);
		if (t == 0)
			break;
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d %d", &s, &e);
			zen += e - s;
		}
		if (zen >= t)
			printf("OK\n");
		else
			printf("%d\n", t - zen);
		zen = 0;
	}
	return 0;
}

Measured memory_bytes: 612
<?php
while(1) {
    $stdin = trim(fgets(STDIN));
    $number = explode(" ", $stdin);
    $x = $number[0];
    $y = $number[1];
    if ($x == 0 && $y == 0) {
        break;
    }
    if ($x >= $y) {
        echo "$y $x\n";
    } else {
        echo "$x $y\n";
    }
}

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

int main(){
	long long n,m;
	cin>>n>>m;
	
	if(n==1&&m==1) cout<<1<<endl;
	else if(n==1||m==1){
		if(n>2) cout<<n-2<<endl;
		else if(m>2) cout<<m-2<<endl;
		else cout<<0<<endl;
	}
	else{
		cout<<(n-2)*(m-2)<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
dp = [[0 for j in range(len(T)+1)] for i in range((len(S)+1))]

for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1], dp[i+1][j])

ans = ""
row = len(S)
col = len(T)
while row > 0 and col > 0:
    if dp[row][col] == dp[row-1][col]:
        row -= 1
    elif dp[row][col] == dp[row][col-1]:
        col -= 1
    else:
        ans += S[row - 1]
        row -= 1
        col -= 1

print(ans[::-1])

Measured memory_bytes: 120796
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 400000;

vector<bool> prime(N, true);

void makePrime(){
    prime[0] = false;
    prime[1] = false;
    for(int i = 2; i < N; i++){
        if(!prime[i]) continue;
        if(i % 7 != 1 && i % 7 != 6){
            prime[i] = false;
            continue;
        }
        for(int j = i + i; j < N; j += i) prime[j] = false;
    }
}

int main(){
    makePrime();
    double n;
    while(cin >>n && n != 1.0){
        vector<int> ans;
        REP(i, n + 1) if(prime[i] && n / i == (int)(n / i)){
            ans.push_back(i);
        }
        cout <<n <<":";
        REP(i, ans.size()) cout <<" " <<ans[i];
        cout <<endl;
    }
    return 0;
}

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

int main(){
  int A,B,T;
  cin >> A >> B >> T;
  double t = T + 0.5;
  for(int i = 1; i < 100; i++){
    if(i * A > t ){
      cout << B * (i-1) << endl;
      return 0;
    }
  }
}

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

using namespace std;

string str = "CODEFESTIVAL2016";

string a;

int main() {
  cin >> a;
  int ans = 0;
  for (int i = 0; i < a.length(); i++) {
    ans += a[i] != str[i];
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int X;
    cin >>X;
    vector <bool > expo(X+1);
    expo[1] = 1;
    for(int b=2;b<=X;b++){
        int v = b*b;
        while(v<=X){
            expo[v] = 1;
            v *= b;
        }
    }
    for(int i=X;i>=1;i--){
        if(expo[i]){
            cout <<i<<endl;
            return 0;
        }
    }
}

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

int main(){
    char s[1001];
    cin >> s;
    for(int i=0;s[i]!='\0';i++){
        if(s[i] >= 'D' && s[i] <= 'Z'){
            printf("%c",s[i] - 3);
        }
        else if(s[i] >= 'A' && s[i] <= 'C'){
            printf("%c",s[i] + 23);
        }
    }
    cout << endl;
}

Measured memory_bytes: 1128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int k = Integer.parseInt(sc.next());
        
        long ans = 0;
        int x = 1;
        for(int i = 1; i < s.length(); i++){
            if(s.charAt(i) == s.charAt(i-1)){
                x++;
                if(i == s.length()-1){
                    ans += x/2;
                }
            }else{
                ans += x/2;
                x = 1;
            }
        }
        
        ans *= k;
        
        if(s.length() == 1){
            ans = k/2;
        }
        
        if(s.length() >= 3 && s.charAt(0) == s.charAt(s.length()-1)){
            char c = s.charAt(0);
            
            if(s.length() % 2 != 0){
                for(int i = 1; i < s.length(); i++){
                    if(s.charAt(i) != c) break;
                    if(i == s.length()-1){
                        ans += k/2;
                        System.out.println(ans);
                        return;
                    }
                }
            }
            
            for(int i = 1; i < s.length(); i++){
                if(s.charAt(i) != c){
                    if(i%2 == 0) break;
                    for(int j = 1; j < s.length(); j++){
                        if(s.charAt(s.length() -1 -j) != c){
                            if(j%2 == 0) break;
                            ans += k-1;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>





using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    int d;
    cin >> d;

    cout << "Christmas " ;
    for (int i=0; i < 25-d; i++){
        cout << "Eve " ;
    }
    cout << endl;
    





    return 0;
}




//              g++ -std=c++1z  

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



using namespace std;

typedef long long ll;

#define drobucs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
	drobucs;

	int n, l;
	cin >> n >> l;
	int sum1 = 0, minap = 1e9;
	int minans = 0;
	for (int i = 1; i <= n; ++i) {
		sum1 += l + i - 1;
		if (minap > abs(l + i - 1)) {
			minap = abs(l + i - 1);
			minans = l + i - 1;
		}
	}
	
	cout << sum1 - minans << "\n";

	return 0;
}
		

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
print(n//3)


Measured memory_bytes: 10164
#include <iostream>
#include <set>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
  multiset<int>max;
  int N;
  cin >> N;
  int c;
  for(int i = 1; i <= N; i++){
    int M;
    cin >> M;
    for(int j = 1; j <= M; j++){
      cin >> c;
      max.insert(c);
      if(i < max.size())max.erase(max.begin());
    }
  } 
  unsigned long long ans = 0;
  for(auto it = max.begin(); it != max.end(); it++) ans += *it;
  cout << ans << endl;
}




Measured memory_bytes: 17060
#include<stdio.h>
#define Gray 0
#define White 1
#define Black 2
int time;
int d[101],f[101],color[101],Adj[101][101];  
int n;

void DFS_Visit(int u){
  int i;  
  color[u]=Gray;
  d[u]=++time;
  for(i=1;i<=n;i++){
    if(color[i]==White && Adj[u][i]==1) DFS_Visit(i);
  }
  color[u]=Black;
  f[u]=++time;
}

void DFS(){
  int i;
  for(i=1;i<=n;i++){
    color[i]=White;
  }
  time=0;
  for(i=1;i<=n;i++){
    if(color[i]==White) DFS_Visit(i);
}
}

main(){
  
  int k,i,j,t,g;

  scanf("%d",&n);
    for(i=0;i<=n;i++){
      for(j=0;j<=n;j++){
	Adj[i][j]=0;
      }
    } 
    
    for(i=1;i<=n;i++){
      scanf("%d",&g);    
      scanf("%d",&k);
      for(j=1;j<=k;j++){
	scanf("%d",&t);
	Adj[g][t]=1;   
      }
    } DFS();
    
    for(i=1;i<=n;i++){
   
      printf("%d %d %d\n",i,d[i],f[i]);
    }
    return 0;
}

Measured memory_bytes: 1064
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
query = [list(map(int, input().split())) for _ in range(q)]

MAXH = 300
MAXW = 300

pos = [[] for _ in range(MAXH*MAXW+10)]
for i in range(h):
    for j in range(w):
        s = a[i][j]
        pos[s] = [i, j]

score = [0 for _ in range(MAXH*MAXW+10)]
for i in range(1, d+1):
    n = i
    while n+d <= h*w:
        x, y = pos[n]
        nx, ny = pos[n+d]
        score[n+d] += score[n]+abs(nx-x)+abs(ny-y)
        n += d

for loop in range(q):
    l, r = query[loop]
    print(score[r]-score[l])


Measured memory_bytes: 82140
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */
// for(auto && i : Range(l,r))
// -> i = [l..r)
class Range {
private: struct It{ int x; int operator*(){return x;}
 bool operator!=(It& lhs){ return x<lhs.x;} void operator++(){++x;} }; It l,r;
public: Range(int n):l({0}),r({n}){} Range(int i,int n):l({i}),r({n})
 {}It& begin(){return l;} It& end(){return r;} };

void solve(istream& cin) {
    ll L;
    while(cin >> L){
        vector<int> u, v, w;
        int N, M;
        int now_n = 1;
        auto set = [&u,&v,&w] (int a, int b, int c){
            u.push_back(a);
            v.push_back(b);
            w.push_back(c);
        };
        ll d = 1;
        while(L >= 2*d){
            set(now_n, now_n+1, 0);
            set(now_n, now_n+1, d);
            now_n++;
            d *= 2;
        }
        N = now_n;
        for (int t = N-1; t >= 1; --t) {
            ll k = 1 << (t-1);
            if(L - k >= d){
                set(t, N, L - k);
                L -= k;
            }
            k /= 2;
        }

        if(v.size() >= 60 || N > 20){
            cerr << "damedacore\n";
        }
        else {
            cout << N << ' ' << v.size() << '\n';
            for (int i = 0; i < v.size(); ++i) {
                cout << u[i] << ' ' << v[i] << ' ' << w[i] << '\n';
            }
        }

    }
}

int main(int argc, char *argv[]) {
    string FileName("D"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = "sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}

Measured memory_bytes: 256
def prefix_and_suffix():
	n = int(raw_input())
	s = str(raw_input())
	t = str(raw_input())
	
	for i in range(n):
		sub_s = s[i:]
		sub_t = t[:n-i]
		if sub_s==sub_t:
			print n+i
			return
	print 2*n

if __name__ == "__main__":
	prefix_and_suffix()

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()


int main(){
	ll K;
	cin >> K;
	ll ans = 0;
	for(int i=1;i<=K;i++) {
		for(int j=1;j<=K;j++) {
			for(int k=1;k<=K;k++) {
				ans += gcd(gcd(i,j), k);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << a - (d - b) + (c - a) << " "
         << b + (c - a) + (d - b) << " "
         << a - (d - b) << " "
         << b + (c - a) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int M = 0;
	static int[] A;
	static int[] B;
	static int N = 0;
	static int c = 0;
	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    N = Integer.parseInt(scanner.next());
	    M = Integer.parseInt(scanner.next());
	    A = new int[M];
	    B = new int[M];
	    for (int i = 0; i < M; i++) {
	        A[i] = Integer.parseInt(scanner.next());
	        B[i] = Integer.parseInt(scanner.next());
	    }

	    int now = 1;
	    f(1, "1");
        System.out.print(c);
	}

	public static void f(int now, String s) {
		if (s.length() == N) {
		    c++;
		    return;
		}
        for (int i = 0; i < M; i++) {
	        if (now == A[i] && !s.contains(String.valueOf(B[i]))) {
	        	f(B[i], s + String.valueOf(B[i]));
	        } else if (now == B[i] && !s.contains(String.valueOf(A[i]))) {
	        	f(A[i], s + String.valueOf(A[i]));
	        }
	    }
	}
}

Measured memory_bytes: 46124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (a == 0 && b == 0)
        return 0;
    if (a < b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    if (b == 0)
        return a;
    
    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(void){
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++)
        cin >> A[i] >> B[i];
    
    map<pair<ll, ll>, int> mp;
    vector<pair<ll, ll>> save_pair;
    for (int i = 0; i < N; i++) {
        bool minus_flag = false;
        ll a = A[i], b = B[i];
        if (a < 0) {
            minus_flag = !minus_flag;
            a = -1 * a;
        }
        if (b < 0) {
            minus_flag = !minus_flag;
            b = -1 * b;
        }
        ll waru = gcd(a, b);
        if (waru == 0) {
            if (mp[make_pair(0, 0)] == 0) {
                save_pair.push_back(make_pair(0, 0));
            }
            mp[make_pair(0, 0)]++;
        }
        else {
            a /= waru;
            b /= waru;
            if (a == 0 || b == 0) {
                if (b == 0)
                    a = -1;
            }
            else
                if (minus_flag)
                    a *= -1;
            if (mp[make_pair(a, b)] == 0) {
                save_pair.push_back(make_pair(a, b));
            }
            mp[make_pair(a, b)]++;
        }
    }
    
    ll ans = 1;
    ll zero_ans = 0;
    map<pair<ll, ll>, int> tansaku_flag;
    for (int i = 0; i < int(save_pair.size()); i++) {
        ll a = save_pair[i].first, b = save_pair[i].second;
        if (tansaku_flag[make_pair(a, b)] == 0) {
            if (a == 0 && b == 0) {
                zero_ans = mp[make_pair(0, 0)];
                tansaku_flag[make_pair(a, b)] = 1;
            }
            else {
                ll a2, b2;
                if (a < 0) {
                    a2 = b;
                    b2 = -a;
                }
                else {
                    a2 = -b;
                    b2 = a;
                }
                ll baai = (modpow(2, mp[make_pair(a, b)], MOD) + modpow(2, mp[make_pair(a2, b2)], MOD)) % MOD;
                baai -= 1;
                if (baai < 0)
                    baai += MOD;
                ans = (ans * baai) % MOD;
                tansaku_flag[make_pair(a, b)] = 1;
                tansaku_flag[make_pair(a2, b2)] = 1;
            }
        }
    }
    ans = (ans + zero_ans) % MOD;
    ans = (ans-1) % MOD;
    if (ans < 0)
        ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 59348
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//---------------------------------//

int d[112345];
int N;
vector<int> g[112345];
bool done[112345];

void dfs(int u, int prev, int dep) {
	d[u] = dep;
	
	REP(i, g[u].size()) {
		int v = g[u][i];
		if (v == prev) continue;
		dfs(v, u, dep + 1);
	}
}

int main() {
	cin >> N;
	REP(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	dfs(0, -1, 0);
	
	int snuke = -1;
	
	queue<int> que;
	que.push(N - 1);
	done[N - 1] = true;
	
	while (!que.empty()) {
		int u = que.front(); que.pop();
		snuke++;
		
		REP(i, g[u].size()) {
			int v = g[u][i];
			
			if (!done[v] && d[u] > d[v] && (d[N - 1] + 1) / 2 > d[N - 1] - d[v]) {
				que.push(v);
				done[v] = true;
			}
			if (!done[v] && d[u] < d[v]) {
				que.push(v);
				done[v] = true;
			}
		}
	}
	
	int fenec = N - 2 - snuke;
	
	bool win = true;
	if (fenec == snuke) win = false;
	else if (fenec > snuke) win = true;
	else win = false;
	
	puts(win ? "Fennec" : "Snuke");
	return 0;
}


Measured memory_bytes: 12800
def start(k, n, a):
    max_distance=0
    for i in range(n-1):
        if(a[i+1]-a[i]>max_distance):
            max_distance = a[i+1]-a[i]
    if(k-a[-1]+a[0]>max_distance):
        max_distance = k-a[-1]+a[0]
    print(k-max_distance)

k,n = map(int, input().split())
a = list(map(int, input().split()))
start(k, n, a)


Measured memory_bytes: 26420
#include<cstdio>
#include<algorithm>
using namespace std;
long long Mod = 998244353, F[10100], InvF[10100], po[10100];
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r*a%Mod;
		a = a*a%Mod; b >>= 1;
	}
	return r;
}
long long Comb(int a, int b) {
	if (a >= b&&b >= 0)return F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
	return 0;
}
long long Get(int a, int b) {
	return Comb(a + b - 1, b);
}
long long Go(int n, int p, int c) {
	if (n == 0)return 1;
	int i;
	long long r = 0;
	for (i = 0; i <= p; i++) {
		if (n < i)continue;
		r = (r + Get(i + c, n - i) * Comb(p,i)%Mod * po[i]) % Mod;
	}
	return r;
}
int main() {
	int i, n, K;
	scanf("%d%d", &K,&n);
	F[0] = InvF[0] =po[0] = 1;
	for (i = 1; i <= 10000; i++) {
		F[i] = F[i - 1] * i%Mod;
		InvF[i] = Pow(F[i], Mod - 2);
		po[i] = po[i - 1] * 2 % Mod;
	}
	for (i = 2; i <= K + K; i++) {
		if (i % 2 == 0) {
			long long t = min(i - 1, K + K + 1 - i);
			printf("%lld\n",(Go(n, t / 2, K - t) + Go(n - 1, t / 2, K - t)) % Mod);
		}
		else {
			long long t = min(i - 1, K + K + 1 - i);
			printf("%lld\n",Go(n, t / 2, K - t));
		}
	}

}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;

int main() {

	int R, G, B, N;

	cin >> R >> G >> B >> N;

	int r=0, g=0, b=0;

	int count = 0;

	for (r = 0; true; r++) {
		for (g = 0; true; g++) {
			if ((N - R * r - G * g) % B == 0 && R * r + G * g <= N)
				count++;

			if (R * r + G * g >= N) {
				g = 0;
				break;
			}
		}

		if (R * r + G * g >= N) {
		break;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = [chr(i) for i in range(ord("a"), ord("z")+1)]
ans = []
while n > 26:
    ans.append(x[n%26-1])
    if n%26 == 0:
        n = n//26 -1
    else:n //= 26
ans.append(x[n-1])
print("".join(ans[::-1]))

Measured memory_bytes: 9188
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        long n = in.nextLong();
        long st = 100;
        int c = 0;
        while(st < n){
            st += (st / 100);
            c++;
        }
        System.out.println(c);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

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

#define MAX_N 20010

ll pi[MAX_N];
ll sum_pi[MAX_N];
ll a[MAX_N];
ll b[MAX_N];

int N;
int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    
    REP(i,N) {int t;cin >> t;pi[t-1]=i;}
    
    REP(i,N) {
        sum_pi[i+1] = sum_pi[i] + pi[i];
        a[i]=i+1;
        b[i]=N-i;
    }
    
    REP(i,N) {
        a[i]+=sum_pi[i+1];
        b[N-1-i]+=sum_pi[N]-sum_pi[N-1-i];
    }
    
    REP(i,N-1) cout << a[i] << " ";
    cout << a[N-1] << endl;
    REP(i,N-1) cout << b[i] << " ";
    cout << b[N-1] << endl;
    
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(){
  int n,d;
  scanf("%d%d",&n,&d);
  int ans,sum;
  sum=2*d+1;
  if(n%sum==0)ans=n/sum;
  else ans = n/sum +1;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define db(a) cout << a << endl
#define adb(a) for(auto i:a) cout << i << " "
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 200010
using namespace std;

int main()
{
    fastIO;
    int a, b;
    cin >> a >> b;

    int soc = 1, ps = 0;
    while(soc < b)
    {
        soc += (a-1);
        ps++;
    }
    
    cout << ps << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n, 0);
    REP(i, n) {
        cin >> a[i];
    }
    sum[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--) {
        sum[i] = (sum[i+1] + a[i]) % MOD;
    }

    ll res = 0;
    for(int i = 0; i < n-1; i++) {
        res += (a[i] * sum[i+1])%MOD;
        cerr << a[i] << " " << sum[i+1] << endl;
    }

    cout << res % MOD << endl;
    


    return 0;
}

Measured memory_bytes: 7804
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int n;
    cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];

    sort(l, l + n, greater<int>());

    int num = l[0];
    int sum = 0;
    for(int i = 1; i < n; i++){
        sum += l[i];
    }

    if(num < sum){
        p("Yes");
    }else{
        p("No");
    }
}


Measured memory_bytes: 256
/* ex 9_2
   cy_an  */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100000

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    node *first = NULL;
    char arr[SIZE+1];
    int i = 0, count = 0;
    
    //スタックにデータを追加
    scanf("%s", arr);
    for(i=0; arr[i] != '\0'; i++){
        // スタックが空のとき、またはスタックのトップと一致するとき
        if(first == NULL || first->elem == arr[i]){
            push(&first, arr[i]);
        }else{
            pop(&first);
            count += 2;
        }
    }
    // 出力
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 4872
import re
# 文字列S'（s）および文字列Tを入力する
s = input()
T = input()
# sの"?"を"."に置き換え、新たな文字列（pattern）とする
pattern = s.replace("?", ".")
# sとTの長さの差をNとする
N = len(s) - len(T)
# Sを設定する（初期状態 =  "UNRESTORABLE"）
S = "UNRESTORABLE"
# 0〜Nまでの整数iについて繰り返す
for i in range(N + 1):
    # patternの先頭N - i文字をTの先頭につけ、patternの後方i文字をTの後方につけた文字列を作成する（text）
    text = pattern[:N - i] + T + pattern[::-1][:i][::-1]
    # patternが正規表現としてtextに一致するかを調べる
    matchOB = re.match(pattern, text)
    # 一致する場合
    if matchOB:
        # textの"."を"a"に置き換える
        text = text.replace(".", "a")
        # Sが初期状態のままである場合、もしくはSよりもtextの方が辞書順で小さい場合
        if S == "UNRESTORABLE" or text < S:
            # Sを更新する
            S = text
# Sを出力する
print(S)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = 0; i < 1000; i++) {
        if (a <= i * k && i * k <= b) {
            cout << "OK" << '\n';
            return 0;
        }
    }
    cout << "NG" << '\n';
    return 0;
}

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

#define int long long 
const int N=1e5+5;
int dp[102][N],val[102],w[102];

int ks(int n,int W)
{
  if(n<1 or W<=0)
    return 0;

  if(dp[n][W]!=-1)
    return dp[n][W];
  
  int maxval;
  if(w[n]<=W)
    maxval=max(val[n]+ks(n-1,W-w[n]),ks(n-1,W));
  else
    maxval=ks(n-1,W);

  return dp[n][W]=maxval;
}
int32_t main()
{
  int n,W;
  cin>>n>>W;
  
  for(int i=1;i<=n;i++)
    cin>>w[i]>>val[i];

  memset(dp,-1,sizeof(dp));

  cout<<ks(n,W);

  return 0;  
}   

Measured memory_bytes: 80000
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdio>
using namespace std;
#define N 1000000
#define INF 0x3f3f3f3f
#define MOD 998244353 
#define LL long long
int rd()
{
	LL x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f*x;
}
int n,m;
LL fac[N+5],inv[N+5];
LL ksm(LL a,LL b)
{
	LL res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
void Init()
{
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[N]=ksm(fac[N],MOD-2);
	for(int i=N-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%MOD;
}
LL c(int a,int b)
{
	return fac[a]*inv[b]%MOD*inv[a-b]%MOD;
}
int main()
{
	Init();
	n=rd(),m=rd();
	if(n<m) swap(n,m);
	LL ans=0;
	for(int i=1;i<=m;i++)
		ans=(ans+c(n-i+m-i,m-i)*c(2*i,i)%MOD)%MOD;
	ans=ans*ksm(2ll/*1/2的贡献*/*c(n+m,m)%MOD,MOD-2)%MOD;
	ans=(ans+n)%MOD;
	printf("%lld\n",ans);
    return 0;
}

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

int main(){

    string a;
    bool b=true;
    
    cin >> a;

    for(int i=0;i<a.size()/2;i++){
        if(a[i]!=a[a.size()-1-i]){
            b=false;
        }
    }
    if(b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A[SIZE];

  scanf("%d", &N);

  for (int i=0; i<N; i++)
    scanf("%d", A+i);

  sort(A, A+N);

  bool ok = true;

  for (int i=0; i<N-1; i++)
    ok &= A[i] != A[i+1];

  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(ll i=0;i<n;i++)
#define inf 999999999
const int mod = 1000000007;
ll cnt = 0;


int main(){
    int dp[100];
    dp[0]=1;
    dp[1]=1;
    int n;  cin >> n;
    for(int i=2;i<=n;i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;

}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

const int MAX_N = 50;

vector<int> g[MAX_N];

void dfs(int u, P ng, bool c[]) {
    for (auto x : g[u]) {
        if (P(x, u) == ng || P(u, x) == ng) continue;
        if (c[x] == 0) {
            c[x] = 1;
            dfs(x, ng, c);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < g[i].size(); j++) {
            bool c[n] = {}, flag = false;
            dfs(i, P(i, g[i][j]), c);
            for (int k = 0; k < n; k++) {
                if (c[k] == 0) flag = true;
            }
            if (flag) ans++;
        }
    }
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    for (int i = 0; i < n;i++){
        cin >> b[i];
        ans += b[i];
    }
    for (int i = 0; i < n - 1;i++){
        cin >> c[i];
    }
    for (int i = 0; i < n - 1;i++){
        if(a[i] == a[i + 1] - 1){
            ans += c[a[i] - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
* @Author: Arextre
* @Date:   2020-05-02 20:18:03
* @Last Modified by:   Arextre
* @Last Modified time: 2020-05-02 20:31:53
*/
#include<cmath>
#include<cstdio>

#define rep(i,__l,__r) for(signed i=(__l),i##_end_=(__r);i<=i##_end_;++i)
#define fep(i,__l,__r) for(signed i=(__l),i##_end_=(__r);i>=i##_end_;--i)
#define writc(a,b) fwrit(a),putchar(b)
#define mp(a,b) make_pair(a,b)
#define ft first
#define sd second
#define LL long long
#define ull unsigned long long
#define uint unsigned int
#define pii pair< int,int >
#define Endl putchar('\n')
// #define FILEOI
// #define int long long
// #define int unsigned
// #define int unsigned long long

#ifdef FILEOI
# define MAXBUFFERSIZE 500000
inline char fgetc(){
    static char buf[MAXBUFFERSIZE+5],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,MAXBUFFERSIZE,stdin),p1==p2)?EOF:*p1++;
}
# undef MAXBUFFERSIZE
# define cg (c=fgetc())
#else
# define cg (c=getchar())
#endif
template<class T>inline void qread(T& x){
    char c;bool f=0;
    while(cg<'0'||'9'<c)f|=(c=='-');
    for(x=(c^48);'0'<=cg&&c<='9';x=(x<<1)+(x<<3)+(c^48));
    if(f)x=-x;
}
inline int qread(){
    int x=0;char c;bool f=0;
    while(cg<'0'||'9'<c)f|=(c=='-');
    for(x=(c^48);'0'<=cg&&c<='9';x=(x<<1)+(x<<3)+(c^48));
    return f?-x:x;
}
template<class T,class... Args>inline void qread(T& x,Args&... args){qread(x),qread(args...);}
template<class T>inline T Max(const T x,const T y){return x>y?x:y;}
template<class T>inline T Min(const T x,const T y){return x<y?x:y;}
template<class T>inline T fab(const T x){return x>0?x:-x;}
inline int gcd(const int a,const int b){return b?gcd(b,a%b):a;}
inline void getInv(int inv[],const int lim,const int MOD){
    inv[0]=inv[1]=1;for(int i=2;i<=lim;++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
}
template<class T>void fwrit(const T x){
    if(x<0)return (void)(putchar('-'),fwrit(-x));
    if(x>9)fwrit(x/10);
    putchar(x%10^48);
}
inline LL mulMod(const LL a,const LL b,const LL mod){//long long multiplie_mod
    return ((a*b-(LL)((long double)a/mod*b+1e-8)*mod)%mod+mod)%mod;
}

inline LL mpow(LL a,int n){
	for(int i=1;i<=n;++i)a=(double)a*1.01;
	return a;
}

LL x;

signed main(){
#ifdef FILEOI
    freopen("file.in","r",stdin);
    freopen("file.out","w",stdout);
#endif
   	scanf("%lld",&x);
   	int l=0,r=4165,mid,ans;
   	while(l<=r){
   		mid=(l+r)>>1;
   		if(mpow(100,mid)<x)l=mid+1;
   		else ans=mid,r=mid-1;
   	}
   	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3256
import sys

def main():
  input = sys.stdin.readline
  X = int(input())
  cur = 0
  for i in range(2, 11):
    for j in range(1, X+1):
      if int(j**i) <= X:
        cur = max(cur, int(j**i))
  print(cur)



if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}

using vi = vector<int>;

#define P (1'000'000'007)

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(b<a){a=b;return 1;}return 0;}

signed main() {
    capi(n);

    vi vf;
    for (int i = 2; i <= sqrt(n); ++i) {
        if (n % i == 0) vf.push_back(i);
    }

    int ans = 0;
    for (auto f: vf) {
        int a = n;

        while (a >= 1) {
            if (a % f == 0) {
                a /= f;
            } else if (a % f == 1) {
                ++ans;
                break;
            } else {
                break;
            }
        }
    }

    vi va;
    int x = n - 1;
    int r = 1;
    for (int i = 2; i <= sqrt(n - 1); ++i) {
        int rep = 1;
        while (x % i == 0) {
            x /= i;
            ++rep;
        }

        r *= rep;
    }

    if (x > 1) r *= 2;

    cout << ans + r;

    return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	
  stack<char> st;
  string s;cin >> s;
  for(int i=0;i<s.size();i++){
  	
    if(st.size() == 0) st.push(s[i]);
    else if(s[i] != st.top()){
    	st.pop();
    }
    else st.push(s[i]);
  }
  cout << s.size()-st.size();
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
 
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
        
    if(A + B + C >= 22){
      //22以上ならbust
      System.out.println("bust");
    }else{
      //それ以外
       System.out.println("win");
    }
  }
 }

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

ll N, u, v; 
vector<vector<ll>> G;
vector<ll> du, dv;

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> u >> v;
	--u, --v;

	G.resize(N);
	du.assign(N, -1);
	dv.assign(N, -1);

	REP(i, N-1)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<ll> que;
	que.push(v);
	dv[v] = 0;

	while (que.size())
	{
		ll now = que.front();
		que.pop();

		for (auto &nv : G[now])
		{
			if (dv[nv] != -1) continue;
			dv[nv] = dv[now] + 1;
			que.push(nv);
		}
	}

	que.push(u);
	du[u] = 0;

	while (que.size())
	{
		ll now = que.front();
		que.pop();

		for (auto &nv : G[now])
		{
			if (du[nv] != -1) continue;
			du[nv] = du[now] + 1;
			que.push(nv);
		}
	}

	ll res{0};
	REP(n, N)
	{
		if (du[n] < dv[n])
		{
			res = max(res, dv[n] - 1);
		}
	}

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


Measured memory_bytes: 11056