akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,W=map(int,input().split())
    w,v=[0]*N,[0]*N
    for i in range(N):
        w[i],v[i]=map(int,input().split())
    if w[0]>3*N:
        w0=w[0]
        W=min(W//w0*(3*N+1)+min(W%w0,3*N),(3*N+4)*N)
        for i in range(N):
            w[i]-=w0
            w[i]+=3*N+1
    dp=[[0]*(W+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(W+1):
            dp[i+1][j]=max(dp[i+1][j],dp[i][j])
            if j-w[i]>=0:
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i])
    print(dp[-1][-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 64240
<?php
list($m, $d) = explode(" ", fgets(STDIN));
$c = 0;
for($i = 1; $i <= $m; $i++){
    for($j = 20; $j <= $d; $j++){
        $j1 = floor($j / 10);
        $j2 = $j % 10;
        if($j2 > 1 && $j1*$j2 == $i){
            $c++;
        }
    }
}
echo $c,"\n";

Measured memory_bytes: 4728
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        if (s.Length != 26)
        {
            char[] c = s.ToArray();
            bool[] isUsed = new bool[26];
            for (int i = 0; i < c.Length; i++) isUsed[c[i] - 'a'] = true;
            for (int i = 0; i < 26; i++)
            {
                if (!isUsed[i])
                {
                    Console.WriteLine($"{s}{char.ConvertFromUtf32(i + 'a')}");
                    break;
                }
            }
        }
        else if (s == "zyxwvutsrqponmlkjihgfedcba")
        {
            Console.WriteLine(-1);
        }
        else
        {
            Console.WriteLine(nextString(s));
        }
    }
    static string nextString(string s)
    {
        List<char> c = s.ToList();
        bool[] isUsed = new bool[26];
        for (int i = 0; i < c.Count; i++) isUsed[c[i] - 'a'] = true;
        for (int i = c.Count - 1; i >= 0; i--)
        {
            char item = c[i];
            for (int j = item - 'a'; j < isUsed.Length; j++)
            {
                if (!isUsed[j])
                {
                    c[i] = char.ConvertFromUtf32(j + 'a')[0];
                    goto end;
                }
            }
            isUsed[item - 'a'] = false;
            c.RemoveAt(c.Count - 1);
        }
        end:;
        return string.Join("", c);
    }
    static bool isTasai(string s) => s.Distinct().Count() == s.Count();
}

Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
    static void swap(long[] A, int i, int j) {
        long tmp = A[i];
        A[i] = A[j];
        A[j] = tmp;
    }

    static void maxHeapfy(long[] A, int i, int n) {
        int left = i * 2;
        int right = i * 2 + 1;

        int largest = i;
        if (left <= n && A[left] > A[i])
            largest = left;
        if (right <= n && A[right] > A[largest])
            largest = right;

        if (largest != i) {
            swap(A, i, largest);
            maxHeapfy(A, largest, n);
        }
    }

    static void buildMaxHeap(long[] A, int n) {
        for (int i = n / 2; i > 0; i--) {
            maxHeapfy(A, i, n);
        }
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            final int n = Integer.parseInt(in.readLine());
            long[] A = new long[n + 1];

            String[] line = in.readLine().split(" ");
            for (int i = 0; i < n; i++) {
                A[i + 1] = Long.parseLong(line[i]);
            }

            buildMaxHeap(A, n);

            System.out.println(" " + Arrays.stream(A).skip(1).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

vector <ll> input;

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

	ll i,j,k,l,m,n,t;

	cin >> n;

	for(i=0;i<n;i++)
	{
		cin >> k;
		input.push_back(k);
	}

	sort(input.rbegin(),input.rend());

	ll ans = input[0];

	l = 0;
	for(i=2;i<n;i++)
	{
		if(i%2 == 0)
			l++;
		ans += input[l];


	}

	cout << ans << '\n';
	

}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;

int ganha(char c){
	if(c == 'r') return 2;
	else if(c == 's') return 0;
	return 1;
}

int idx(char c){
	if(c == 'r') return 0;
	else if(c == 's') return 1;
	return 2;
}
ll v[3];
ll dp[100007];

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

	int n, k; cin >> n >> k;
	cin >> v[0] >> v[1] >> v[2];
	string t; cin >> t;

	ll ans = 0;

	FOR(i, k){
		dp[i] = v[ganha(t[i])];
		int j;
		for(j = i+k; j < n; j+=k){
			if(ganha(t[j]) != ganha(t[j-k]))
				dp[j] = dp[j-k] + v[ganha(t[j])];
			else if(j-2*k >= 0)
				dp[j] = max(dp[j-k], dp[j-2*k] + v[ganha(t[j])]);
			else
				dp[j] = max(dp[j-k], v[ganha(t[j])]);
		}
		j-=k;
		ans += dp[j];
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1232
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int score = 0;
		for(int i = 0; i < s.length(); i++) {
			if(i%2 == 0 && s.charAt(i) == 'p')
				score--;
			else if(i%2 == 1 && s.charAt(i) == 'g')
				score++;
		}
		System.out.println(score);
	}
}

Measured memory_bytes: 13736
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	ans = 0
	d1,d2 = defaultdict(int),defaultdict(int)
	L = []
	for i in range(n):
		L.append([l[i],i])
	ans = 0
	L = sorted(L)
	# print('L:',L)
	for j in range(n):
		i = L[j][1]
		zz = L[j][0]
		# print(L[j],i,zz)
		d1[i-zz] += 1
		d2[i+zz] += 1
	# print(dict(d1))
	# print(dict(d2))
	for i in d1:
		ans += d1[i]*d2[i]
	return ans

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 179808
from collections import Counter
s = input()
memo = [100] * 26
d = Counter(s)
for key in d.keys():
    index = [i for i, x in enumerate(s) if x == key]
    asc = ord(key) - 97
    memo[asc] = max(index[0], len(s) - 1 - index[-1])
    if len(index) >= 2:
        for i in range(1, len(index)):
            memo[asc] = max(memo[asc], index[i] - index[i-1] - 1)
print(min(memo))


Measured memory_bytes: 66512
import copy
n,w = map(int,input().split())
b = [0]*(w+1)
a = [0]*(w+1)
for _ in range(n):
  wi,vi = map(int,input().split())
  a = copy.copy(b)
  for i in range(min(wi,w+1),w+1):
    a[i] = max(b[i-wi]+vi,b[i])
  b = a
print(max(b))

Measured memory_bytes: 66128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<int> v(n,-1);
    vector<int> a(n),path;
    for(auto&i:a ) cin>>i,--i;
    int p{};
    while(v[p]==-1){
        v[p]=path.size();
        if(v[p]==k) return cout<<p+1<<endl,0;
        path.push_back(p);
        p=a[p];
    }
    int u=path.size();
    (k-=v[p])%=u-v[p];
    cout<<path[v[p]+k]+1<<endl;
}

Measured memory_bytes: 5856
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <cassert>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, s;
};

signed main() {

	int n;
	cin >> n;

	int ok[100001] = {};

	rep(i, 1, 500) {
		if ((i * (i - 1)) / 2 > 100000) break;
		ok[(i * (i - 1)) / 2] = i;
	}

	if (ok[n] == 0) {
		cout << "No" << endl;
		return 0;
	}

	vector<vector<int>> g(ok[n],vector<int>(ok[n]));

	int edc = 0;

	REP(i, ok[n]) {
		REP(j, ok[n]) {
			if (i <= j) break;

			edc++;
			g[i][j] = edc;
			g[j][i] = edc;

		}
	}

	printf("Yes\n%d\n", ok[n]);
	REP(i, ok[n]) {
		printf("%d", ok[n] - 1);
		REP(j, ok[n]) {
			if (g[i][j] == 0) continue;
			printf(" %d", g[i][j]);
		}
		printf("\n");
	}

	return 0;
}

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


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    s = str(N)
    print(YES if s[0] == s[2] else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    rep(i, m){
        cin >> b[i];
    }
    int a[n][m];
    rep(i, n){
        rep(j, m){
            cin >> a[i][j];
        }
    }

    int cnt = 0;
    rep(i, n){
        int tmp = 0;
        rep(j, m){
            tmp += b[j]*a[i][j];

        }
        if(tmp+c > 0) ++cnt;
    }
    ppp(cnt);

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main {

    public static void dfs(ArrayList<Integer>[] graph, int n, int u, 
        boolean[] visited, int[] dp) {
        visited[u] = true;

        for(int v : graph[u]) {
            if(!visited[v]) {
                dfs(graph, n, v, visited, dp);
            }
            dp[u] = Math.max(dp[u], dp[v] + 1);
        }
    }

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

        ArrayList<Integer>[] graph = new ArrayList[n + 1];
        boolean[] visited = new boolean[n + 1];
        int[] dp = new int[n + 1];

        for(int i = 0; i <= n; i++) {
            graph[i] = new ArrayList<>();
        }

        for(int i = 0; i < m; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            graph[x].add(y);
        }

        for(int i = 1; i <= n; i++) {
            if(!visited[i]) {
                dfs(graph, n, i, visited, dp);
            }
        }

        int result = 0;
        for(int i = 1; i <= n; i++) {
            result = Math.max(result, dp[i]);
        }

        System.out.println(result);
  }
}


Measured memory_bytes: 102800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n, m, sum = 0;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int ans = n;
	m = m - sum;
	ans += m/ *min_element(a.begin(), a.end());
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

char s[125252];
ll dp[125252][2];

int main(){
    scanf("%s",s);
    int n = strlen(s);
    dp[0][0] = 1;
    REP(i,n)REP(less,2){
        if(!less && s[i]=='0'){
            (dp[i+1][less] += dp[i][less]) %= MOD;
        }else{
            (dp[i+1][1] += dp[i][less]) %= MOD;
            (dp[i+1][less] += dp[i][less]) %= MOD;
            (dp[i+1][less] += dp[i][less]) %= MOD;
        }
    }
    ll ans = (dp[n][0]+dp[n][1]) % MOD;
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    rep(i, 0, s.size()){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map <int,int> ct;
	for (int i=0; i<n-1; i++) {
	int x; cin>>x;
		ct[x]++;
	}
	for (int i=1; i<=n; i++)
		cout<<ct[i]<<endl;
	return 0;
}


Measured memory_bytes: 13000
#include <stdio.h>
   
int main(void){
   
  int x;
  int i = 1;
   
  while(1){
    scanf("%d",&x);
    if(x == 0){
      break;
    }
    printf("Case %d: %d\n",i,x);
    i++;
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	cout << fixed << setprecision(10);
	long long int n=0,t[100050],a=0,b,o=0,h=0,y=0;
	string str,str2;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>t[i];
	}
	for(int i=1;i<=n;i++){
		if(i==t[t[i]]){a++;}
	}
	cout<<a/2<<endl;
}


Measured memory_bytes: 1024
'use strict'

function main(input){
  const NL = input.split(' ').map(x => parseInt(x));
  const N = NL[0];
  const L = NL[1];

  const apples = [];
  for(let i=1;i<=N;i++){
    apples.push(L+i-1)
  }

  const sum = apples.reduce( (a,b) => a+b,0 );

  let small_taste = apples.map(x => Math.abs(x) ).sort( (a,b) => a-b )[0]

  let smal_index = apples.findIndex(x => x==(small_taste)||x==(-1)*small_taste)
  let origin_small_number = apples[smal_index];

  let result = sum - origin_small_number;

  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,dp[1<<17],nm[101010],sum,cnt[22],ans,mk;
bool gd[1<<17];
int main()
{
	for(int i=0;i<(1<<16);i++)
	{
		sum=0;
		for(int j=0;j<16;j++)
		{
			if((i>>j)&1)
			{
				sum^=j;
			}
		}
		if(sum==0)
		{
			gd[i]=true;
		}
	}
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		nm[a]^=c;
		nm[b]^=c;
	}
	for(int i=0;i<n;i++)
	{
		if(nm[i])
		{
			cnt[nm[i]]++;
		}
	}
	for(int i=0;i<21;i++)
	{
		ans+=cnt[i]/2;
		cnt[i]%=2;
		if(cnt[i])
		{
			ans++;
			mk|=(1<<i);
		}
	}
	for(int i=0;i<=mk;i++)
	{
		for(int j=i;j;j=(j-1)&i)
		{
			if(gd[j])
			{
				dp[i]=max(dp[i],dp[i^j]+1);
			}
		}
	}
	cout<<ans-dp[mk]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int A, B, maior;

	scanf("%d %d", &A, &B);

	if ((A + B) > (A - B) && (A + B) > (A * B))
	{
		maior = (A + B);
	}
	else if ((A - B) > (A + B) && (A - B) > (A * B))
	{
		maior = (A - B);
	}
	else if ((A * B) > (A + B) && (A * B) > (A - B))
	{
		maior = (A * B);
	}
	else if ((A + B) == (A - B) && (A + B) == (A * B))
	{
		maior = (A + B);
	}

	printf("%d", maior);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  string s;
  cin >> s;
  
  if (s[1] == 'R')
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

  int N;cin>>N;
    string S;cin>>S;
    int Q;cin>>Q;
    vector<ll> cnt(N+1,0),appear(N+1,0);
    int mcnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='M') mcnt++;
        else if(S[i]=='C'){
            cnt[i+1]=mcnt;
            appear[i+1]=1;
        }
    }
    for(int i=1;i<=N;i++){
        cnt[i]+=cnt[i-1];
        appear[i]+=appear[i-1];
    }
    
    for(int i=0;i<Q;i++){
        int K;cin>>K;
        ll ans=0;
        int mdelete=0;
        for(int i=0;i<N;i++){
            if(S[i]=='M') mdelete++;
            else if(S[i]=='D'){
                int to=min(N,i+K);
                ans+=cnt[to]-cnt[i]-(appear[to]-appear[i])*mdelete;
            }
        }
        cout<<ans<<endl;
    }
    
}



Measured memory_bytes: 17028
import math
# from functools import reduce
# from fractions import gcd
def main():
    n = int(input())
    # def gcd(*numbers):
    #     return reduce(math.gcd, numbers)

    c = 0
    for i in range(n):
        for j in range(n):
            for k in range(n):
                temp = math.gcd(i+1,j+1)
                c += math.gcd(temp,k+1)

    print(c)

main()

Measured memory_bytes: 70452
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EBinaryProgramming {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;

      string t; cin >> t;
      int n = t.size();
      vector<int> zero(1);
      vector<int> one;
      ll dup = 0;
      ll sumzero = 0;
      rep(i, n) {
        if (t[i] == '0') {
          zero.back()++;
          sumzero++;
        } else {
          if (zero.size() == 1 || zero.back() != 0) {
            zero.push_back(0);
            one.push_back(i);
          } else {
            zero.pop_back();
            one.pop_back();
            dup++;
          }
        }
      }
      ll x = dup*(sumzero+1);

      ll L = 0;
      int zs = zero.size();
      debug(zs);
      rep(i, zs-1) {
        L += zero[i];
        ll R = sumzero - L;

        if (one[i]%2 == 0) {
          x += (L+2)/2;
        } else {
          x += (L+1)/2;
        }
        x += R;
      }
      debug(x);

      ll onecnt = n - sumzero - 1;
      ll d = (onecnt+1)/2;
      x += d*(d+1);
      if (onecnt%2==1) {
        x -= d;
      }
      debug(x);
      cout << x << endl;

    }
};

signed main() {
  EBinaryProgramming solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 4556
#include <iostream>
#include <vector>
using namespace std;
typedef vector<vector<int>> tree;

void dfs(tree& t, vector<int>& dists, int node, int dist) {
  if (dists[node] < 0) {
    dists[node] = dist;
    for (int next : t[node]) {
      dfs(t, dists, next, dist+1);
    }
  }
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  tree t(n);
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  vector<int> udists(n, -1), vdists(n, -1);
  dfs(t, udists, u, 0);
  dfs(t, vdists, v, 0);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (udists[i] < vdists[i]) {
      if (udists[i] + vdists[i] == 1) continue;
      ans = max(ans, vdists[i]-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h> 
using namespace std; 
#define rep(i,n) for(i=0;i<n;i++) 
int main(){ 
  int a[4],p[4]={0},i;
char x[10];
cin>>x;
 rep(i,4){a[i]=x[i]-'0';} if(a[0]+a[1]+a[2]+a[3]==7){ printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]); return 0; } if(a[0]-a[1]+a[2]+a[3]==7){ printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]); return 0; } if(a[0]+a[1]-a[2]+a[3]==7){ printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]); return 0; } if(a[0]+a[1]+a[2]-a[3]==7){ printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]); return 0; } if(a[0]+a[1]-a[2]-a[3]==7){ printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]); return 0; } if(a[0]-a[1]+a[2]-a[3]==7){ printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]); return 0; } if(a[0]-a[1]-a[2]+a[3]==7){ printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]); return 0; } }


Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, a := nextInt(), nextInt()
	puts(n*n - a)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	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 nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#約数を求める
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N = int(input())

cnt = 0
for i in range(N+1):
    divisors = make_divisors(i)
    if len(divisors) == 8 and i % 2:
        cnt += 1

print(cnt)

Measured memory_bytes: 3188
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import java.io.*;
import java.math.BigInteger;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		long ok = 0, ng = (long) 2e5 + 1;
		while (ng - ok > 1) {
			long middle = (ok + ng) / 2;
			if (check(A, middle)[0] >= M) {
				ok = middle;
			} else {
				ng = middle;
			}
		}
		long[] get = check(A, ok);
		System.out.println(get[1] - (get[0] - M) * ok);
	}

	long[] check(long[] A, long middle) {
		int N = A.length;
		int t = 0;
		long sz = 0;
		long sum = 0;
		long add = 0;
		for (int i = 0; i < N; ++i)
			add += A[i];
		for (int i = N - 1; i >= 0; --i) {
			add -= A[i];
			while (t < N && A[i] + A[t] < middle) {
				add -= A[t];
				++t;
			}
			if (t > i)
				break;
			sz += 2 * (i - t + 1) - 1;
			sum += 2 * add + 2 * (i - t + 1) * A[i];
		}
		return new long[] { sz, sum };
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 61620
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  string s;
  cin >> s;
  bool OK = true;
  if(s.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0;i < s.size(); i += 2) {
    if(s[i] == 'h' && s[i + 1] == 'i') {
    }
    else {
      OK = false;
    }
  }
  if(OK) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;

using ll = long long;

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


Measured memory_bytes: 256
N=int(input())
a=list(map(int, input().split()))
nums=[0, 0, 0]
for i in range(N):
  if a[i]%4==0:
    nums[0]+=1
  elif a[i]%2==1:
    nums[1]+=1
  else:
    nums[2]+=1
    
if nums[2]==0:
  if nums[0]+1>=nums[1]:
    print('Yes')
  else:
    print('No')
else:
  if nums[0]>=nums[1]:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll ans = 0;
  REP(i, n-1){
    ll d = a[i] - a[i+1];
    if(d > 0){
      ans += d;
      a[i+1] += d;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4832
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define LARGE_PRIME_NUM 1000000007
typedef long long ll;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

int getReq(int i, int k) {
	if (i == 0) {
		return 0;
	}
	int ans = 0;
	int i0 = i;
	while (i0 < k) {
		i0 *= 2;
		ans++;
	}
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	double ans = 0;
	rep(i, n) {
		int r = getReq(i + 1, k);
		ans += 1.0 / n * pow(0.5, r);
	}
	cout << std::setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,a[N];
int dfs(int x){
	int sm=0,i;
	for(i=1;i<=n;i++)
		sm^=a[i]&1;
	if(sm!=(n&1))return x;
	for(i=1;i<=n;i++)
	if(a[i]&1&&a[i]>1)break;
	a[i]--;
	sm=a[1];
	for(i=2;i<=n;i++)sm=__gcd(a[i],sm);
	if(sm&1)return !x;
	for(i=1;i<=n;i++)a[i]/=sm;
	return dfs(!x);
}
int main(){
	//freopen("1.out","w",stdout);
	int i;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	puts(dfs(1)?"First":"Second");
	return 0;
}

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

int main() {
    
    int n,m;
    cin>>n>>m;
    
    int S[n][n];
    const int INF = 10e8;
    int a[m],b[m],c[m];
    
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            S[i][j] = INF;
            if (i==j) S[i][j]=0;
        }
    }
    
    for (int i=0; i<m; i++) {
        int s,t,w;
        cin>>s>>t>>w;
        S[s-1][t-1] = w;
        S[t-1][s-1] = w;
        a[i] = s-1;
        b[i] = t-1;
        c[i] = w;
    }
    
    for(int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                S[i][j] = min(S[i][j], S[i][k] + S[k][j]);
            }
        }
    }
    
    int out = m;
    for (int x=0; x<m; x++) {
        for (int i=0; i<n; i++) {
            if (S[i][a[x]] + c[x] == S[i][b[x]]) {
                out--;
                break;
            }
        }
    }
    
    cout << out << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//セグメント木
//全て添字で扱うこと
struct segment_tree {
  ll n; //vのサイズ
  ll m = 1;
  vector<bool> v;

  //初期化関数
  void init(vector<bool> a) {
    while (m < a.size()) m *= 2;
    n = 2 * m - 1;
    vector<bool> w(n);
    v = w;
    for (ll i = 0; i < a.size(); i++) v[m - 1 + i] = a[i];
    for (ll i = a.size(); i < m; i++) v[m - 1 + i] = false;
    for (ll i = m - 2; i >= 0; i--) v[i] = (v[2 * i + 1] || v[2 * i + 2]);
    return;
  }

  //値の更新
  void change(ll a, bool b) {
    a += m - 1;
    v[a] = b;
    while ((a - 1) / 2 != a) {
      a = (a - 1) / 2;
      v[a] = (v[a * 2 + 1] || v[a * 2 + 2]);
    }
    return;
  }

  //区間和用の補助関数
  bool subsub(ll a, ll b, ll cur, ll l, ll r) {
    if (v[cur] == false) return v[cur];
    if (a <= l && r <= b) return v[cur];
    if (r < a || b < l) return false;
    if (l < r) {
      return (
        subsub(a, b, 2 * cur + 1, l, (l + r) / 2)
        ||
        subsub(a, b, 2 * cur + 2, (l + r) / 2 + 1, r)
      );
    }
  }

  //区間[a, b]の和
  bool subsum(ll a, ll b) {
    if (a == b) return v[m - 1 + a];
    bool ans = false;
    ll cur = 0, l = 0, r = m - 1;
    ans = (ans || subsub(a, b, cur, l, r));
    return ans;
  }
};

int main() {
  ll n, q;
  string s;
  cin >> n >> s >> q;

  map<char, vector<bool>> m;
  for (char c = 'a'; c <= 'z'; c++) {
    vector<bool> v(n, false);
    for (ll i = 0; i < n; i++) {
      if (s[i] == c) v[i] = true;
    }
    m[c] = v;
  }

  map<char, segment_tree> mm;
  for (char c = 'a'; c <= 'z'; c++) {
    segment_tree seg;
    seg.init(m[c]);
    mm[c] = seg;
  }

  for (ll i = 0; i < q; i++) {
    ll x;
    cin >> x;

    if (x == 1) {
      ll y;
      char c;
      cin >> y >> c;

      if (s[y - 1] == c) continue;

      mm[s[y - 1]].change(y - 1, false);
      mm[c].change(y - 1, true);
      s[y - 1] = c;
    }
    else {
      ll l, r;
      cin >> l >> r;

      ll cnt = 0;
      for (char c = 'a'; c <= 'z'; c++) {
        if (mm[c].subsum(l - 1, r - 1)) cnt++;
      }
      cout << cnt << endl;
    }
  }
}

Measured memory_bytes: 6020
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n): parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

  private:

  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll N, M;
  cin >> N >> M;

  vector<ll> A;
  vector<ll> B;
  for (ll i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    A.push_back(--a);
    B.push_back(--b);
  }

  ll ans = N * (N-1)/2;
  vector<ll> res;
  UnionFind uni = UnionFind(N);
  for (ll i = M - 1; i >= 0; i--) {
    res.push_back(ans);
    ll a = A[i];
    ll b = B[i];

    if (uni.issame(a, b)) continue;

    ans -= uni.size(a) * uni.size(b);
    uni.merge(a, b);
  }

  for (ll i = M-1; i >= 0; i--) {
    cout << res[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4588
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

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

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }

inline ll Msq(ll x){ return (x*x) %MOD; }
inline ll Mpot(ll x, ll e){
	if(!e) return 1;
	return Msq(Mpot(x, e>>1)) * (e & 1 ? x : 1)%MOD;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 1e5+5;

int n, a[MAXN];

int dist(int x, int y){
	return min( abs(x/2 - y), abs((x+1)/2 - y) );
}

int main(){
	scan(n);
	for(int i=0; i<n; i++) scan(a[i]);
	sort(a, a+n);
	int x = a[--n];
	int y = a[0];
	for(int i=0; i<n; i++){
		if(dist(x, a[i]) < dist(x, y)) y = a[i];
	}
	printf("%d %d\n", x, y);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    string s;
    cin >> n >> s;
    s = "0" + s + "0";
    n += 2;
    int prev[n];
    for(int p=-1, i=0; i<n; ++i){
        prev[i] = p;
        if(s[i] == '0') p = i;
    }

    int dp[n+1];
    memset(dp, 0, sizeof(dp));
    For(i, 3, n+1){
        dp[i] = dp[i-1];
        if(s[i-1] == '1'){
            int p = prev[i-1] - 1;
            if(p >= 0 && s[p] == '1'){
                chmax(dp[i], dp[p] + i - (prev[i-1]+1));
            }
            if(s[i-2] == '0'){
                for(int j=i-3; j>=0 && s[j]=='1'; --j){
                    chmax(dp[i], dp[j] + i-2-j);
                }
            }
        }
    }
    printf("%d\n", dp[n]);
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){long long c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    ll ANS=A[0];
    for(ll i=1;i<N;i++){
        ANS=GCD(ANS,A[i]);
    }
    cout<<ANS<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 1024
<?php
 
// $str = trim(fgets(STDIN));
$iro = explode(" ", trim(fgets(STDIN)));
$cnt = 1 ;
sort($iro);

if($iro[0]!==$iro[1]){
  $cnt++;
}

if($iro[1]!==$iro[2]){
  $cnt++;
}

echo $cnt;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> buttons(N);
  for (int i = 0; i < N; i++)
    cin >> buttons.at(i);
  int t = 0;
  int count = 0;
  while(1) {
    if (buttons.at(t) != -1){
	count++;
      if (buttons.at(t) != 2){
        int tmp;
	tmp = buttons.at(t);
        buttons.at(t) = -1;
        t = tmp - 1;
      } else {
        cout << count;
        break;
      }
    } else {
      cout << -1;
      break;
    }
  }
}


Measured memory_bytes: 640
import sys
N = int(sys.stdin.readline().rstrip())
H = list(map(int, sys.stdin.readline().rstrip().split()))
for k in range(2,N+1):
    if H[-k] <= H[-k+1]:
        continue
    elif H[-k] == H[-k+1] + 1:
    	H[-k] -= 1
    else:
        print("No");exit()
print("Yes")

Measured memory_bytes: 14396
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				int a[] = new int[10];
				for (int i=0;i<10;i++) {
					a[i] = Character.getNumericValue(buf.charAt(i));
				}
				for (int i=9;i>=2;i--) {
					int b[] = new int[i];
					for (int j=0;j<i;j++) {
						b[j] = (a[j]+a[j+1])%10;
					}
					for (int j=0;j<i;j++) a[j] = b[j];
				}
				System.out.println((a[0]+a[1])%10);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16868
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		while(scan.hasNext()){
			int c1 = scan.nextInt();
			int c2 = scan.nextInt();
			int c3 = scan.nextInt();
			double bunbo = 0;
			double bunsi = 0;
			for(int i = 0 ; i < 10 ; i++){
				if(c1 != i+1 && c2 != i+1 && c3 != i+1){
					++bunbo;
					if(c1+c2+i+1 <=20){
						++bunsi;
					}
				}
			}
			if((bunsi/bunbo)*100 >=50){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 26236
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var ABi = new List<Tuple<long, long>>();
            for(var i=0;i<M;++i)
            {
                var ab = Sarray();
                ABi.Add(Tuple.Create(ab[0], ab[1]));
            }
            ABi.Sort((l, r) => (int)(l.Item2 - r.Item2));
            var ans = 0L;
            var nextB = 0L;
            foreach(var ab in ABi)
            {
                if (ab.Item1 < nextB) continue;
                nextB = ab.Item2;
                ++ans;
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int k;
        cin>>k;
        string s;
        cin>>s;
        if(s.size()>k){
            for(int i=0;i<k;i++)
                cout<<s[i];
            cout<<"...";
        }
        else
            cout<<s;
        return 0;
    }


Measured memory_bytes: 3588
from collections import *
n,m=map(int,input().split())

d=defaultdict(list)

for s in m*[0]:
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)

#print(d)

#dはdefaultdict!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

def DFS_dict(point,TFlist):
#    print(TFlist)
#    print(d[point])
    if not False in TFlist:
        return 1
    ans=0
    for i in d[point]:
        if TFlist[i-1]:
            continue  #探索済みなら処理せず
        TFlist[i-1]=True #探索したのでTFlistをTrue
        ans+=DFS_dict(i,TFlist)
        TFlist[i-1]=False
    return ans

TFlist=[True]+[False]*(n-1)
print(DFS_dict(1,TFlist))

Measured memory_bytes: 3316