akhauriyash/Code-Regression huggingface dataset:
import collections
n, *v = map(int, open(0).read().split())

v1 = [0] * (n // 2)
v2 = [0] * (n // 2)

for i in range(n // 2):
    v1[i] = v[2 * i]
    v2[i] = v[2 * i + 1]

v1_cnt = collections.Counter(v1)
v2_cnt = collections.Counter(v2)

v1_cnt_l = sorted(list(v1_cnt.values()))
v2_cnt_l = sorted(list(v2_cnt.values()))

#print(v1_cnt_l, v2_cnt_l)

if max(v1_cnt, key=v1_cnt.get) == max(v2_cnt, key=v2_cnt.get):
    if 1 < len(v1_cnt_l) and 1 < len(v2_cnt_l):
        #print('1 1')
        num1 = sum(v1_cnt_l) - v1_cnt_l[-1]
        num1 += sum(v2_cnt_l) - v2_cnt_l[-2]
    
        num2 = sum(v1_cnt_l) - v1_cnt_l[-2]
        num2 += sum(v2_cnt_l) - v2_cnt_l[-1]
    
        num = min(num1, num2)
    elif 1 < len(v1_cnt_l):
        #print('2 2')
        num = sum(v1_cnt_l) - v1_cnt_l[-2]
        num += sum(v2_cnt_l) - v2_cnt_l[-1]
    elif 1 < len(v2_cnt_l):
        #print('3 3')
        num = sum(v1_cnt_l) - v1_cnt_l[-1]
        num += sum(v2_cnt_l) - v2_cnt_l[-2]
    else:
        #print('4 4')
        num = n // 2
        
else:
    num = sum(v1_cnt_l) - v1_cnt_l[-1]
    num += sum(v2_cnt_l) - v2_cnt_l[-1]

print(num)

Measured memory_bytes: 18912
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
  LLI x, ans = 0, mod;
  cin >> x;
  ans += 2 * ( x / 11 );
  ans += ( x - ( x/11 ) * 11 + 5 ) / 6;
  cout << ans;
}

Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

std::vector< std::vector<int> > g(100010);
int cnt[100010], dp[100010];

int main()
{
    int n, m;
    std::cin >> n >> m;

    while (m--)
    {
        int x, y;
        std::cin >> x >> y;
        --x;
        --y;

        g[x].push_back(y);
        ++cnt[y];
    }

    std::stack<int> zeroIn;
    for (int i = 0; i < n; ++i)
    {
        if (cnt[i] == 0)
            zeroIn.push(i);
    }

    int ans = 0;
    while (zeroIn.empty() == false)
    {
        int cur = zeroIn.top();
        zeroIn.pop();

        for (int j = 0; j < g[cur].size(); ++j)
        {
            int nxt = g[cur][j];
            dp[nxt] = std::max(dp[nxt], dp[cur] + 1);
            --cnt[nxt];
            if (cnt[nxt] == 0)
                zeroIn.push(nxt);

            ans = std::max(ans, dp[nxt]);
        }
    }

    std::cout << ans;
}


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

void solve(){
    string s; cin >> s;
    for(int i = 0; i < s.size()-1; ++i){
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i + 2 << endl;
            return;
        }
        if(s[i] == s[i + 2]) {
            cout << i+1 << " " << i + 3 << endl;
            return;
        }
    }
    cout << -1 << " " << -1 << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, b;
      cin >> a >> b;
     
      if (a * b % 2 == 1) {
        cout << "Odd" << endl;
      }
      else{
        cout << "Even" << endl;
      }
    }

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  int count = 1;
  vector<vector<int>> res = {{1}, {1}};
  int next = 1;

  for (int i = 2; i <= n; ++i) {
    if(res.size()-1 == count){
      count=0;
      next++;
      res.push_back({});
    }
    res[count].push_back(i);
    res[next].push_back(i);
    count++;
  }

  if(res.size()-1 != count){
    cout << "No" << endl;
    exit(0);
  }

  cout << "Yes" << endl;
  cout << res.size() << endl;
  for(auto a : res){
    cout << a.size() << ' ';
    for(auto val : a) cout << val << ' ';
    cout << endl;
  }
}


Measured memory_bytes: 4556
from collections import defaultdict
d = defaultdict(int)

h,w,n = map(int, input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i],b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
    
## 左上のマスを(0,0)とする
## 正方形の左上のマスを(j,i)とする
sq_i = []
sq_j = []

for x in range(n):
    for k in range(3):
        for l in range(3):
            i = a[x]-k ; j = b[x]-l
            if i<0 or i+3>h or j<0 or j+3>w:
                continue
            d[(j,i)] += 1

ans =[0]*10
for k,v in d.items():
    ans[v] += 1
ans[0] = (h-2)*(w-2)-sum(ans)

for i in range(10):
    print(ans[i])

Measured memory_bytes: 174812
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const int Nmax = 40, ABmax = 10;

int a[Nmax], b[Nmax], c[Nmax];
int dp[Nmax + 1][Nmax * ABmax + 1][Nmax * ABmax + 1];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	rep(i, 0, N) cin >> a[i] >> b[i] >> c[i];


	rep(i, 0, Nmax + 1) rep(j, 0, Nmax * ABmax + 1) rep(k, 0, Nmax * ABmax + 1) dp[i][j][k] = 1e9;

	
	dp[0][0][0] = 0;

	rep(i, 0, N) {
		rep(j, 0, Nmax * ABmax + 1) {
			rep(k, 0, Nmax * ABmax + 1) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				if(j - a[i] >= 0 && k - b[i] >= 0) {
					dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
				}
			}
		}
	}
	
	int ans = 1e9;
	rep(i, 1, Nmax * ABmax + 1) rep(j, 1, Nmax * ABmax + 1) if(i * Mb == j * Ma) ans = min(ans, dp[N][i][j]);

	if(ans == 1e9) cout << -1 << endl;
	else cout << ans << endl;

}


Measured memory_bytes: 25984
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func gcd(m, n int) int {
	if m < n {
		m, n = n, m
	}
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aa := getIntList(scanner)
	dp := make([]int, n+2)
	dp2 := make([]int, n+2)
	dp[0] = 0
	dp2[0] = 0
	for i := 0; i < n; i++ {
		dp[i+1] = gcd(dp[i], aa[i])
		dp2[i+1] = gcd(dp2[i], aa[n-1-i])
	}
	max := 0
	var ans int
	for i := 1; i <= n; i++ {
		ans = gcd(dp[i-1], dp2[n-i])
		if max < ans {
			max = ans
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 10880
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;
  cin >> N;
  int S = 0;
  int I = 0;
  for (int i = 0; i < N+1; i++)
  {
    S += i;
    if (S >= N)
    {
      I = i;
      break;
    }

  }
  // DEBUG(S);
  int X = S - N;
  // DEBUG(I);
  for (int i = 1; i < I+1; i++)
  {
    if (i == X)
      continue;
    cout << i << endl;
  }

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


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

int n, t;
vector<int> d;
vector<int>::iterator it;
long long ans = 1;

int main(){
	cin >> n >> t;
	rep(i,n){
		int tmp; cin >> tmp;
		d.push_back(tmp);
	}
	sort(d.begin(),d.end());
	rep(i,n){
		it = lower_bound(d.begin(),d.end(),d[i]-t);
		int x = i-(it-d.begin())+1;
		ans = ans*x;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1676
S = list(input())
Q = int(input())
is_reversed = False
append_first = []
my_first = append_first.append
append_end = []
my_end = append_end.append

for i in range(Q):
  q = list(input())
  if q[0] == '1':
    is_reversed = True if is_reversed == False else False
  else:
    if q[2] == '1' and is_reversed:
      append_end.append(q[4])
    elif q[2] == '1': 
      append_first.append(q[4])
    elif is_reversed:
      append_first.append(q[4])   
    else:
      append_end.append(q[4])
      
append_first.reverse()
append_first.extend(S) 
append_first.extend(append_end)

if is_reversed:
  append_first.reverse()
print(''.join(append_first))

Measured memory_bytes: 7696
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());
		int line[] = new int[n];
		int temp = 0;
		int exchange = 0;

		for(int i=0; i<n; i++){
			line[i] = Integer.parseInt(std.next());
		}
		boolean flag = true;
		while (flag){
			flag = false;
			for(int j=(n-1); j>0; j--){
				if (line[j] < line[j-1]){
					temp = line[j]; line[j] = line[j-1]; line[j-1] = temp;
					exchange++;
					flag = true;
				}
			}
		}
		String outsd = Integer.toString(line[0]);
		for(int i=1; i<n; i++){
			outsd += " "+line[i];
		}
		System.out.println(outsd);
		System.out.println(exchange);
	}
}

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

using namespace std;

int main()
{
	
	int n;

	cin >> n;

	int l[n];

	for(int i = 0; i < n ; i++)
	{

	   cin >> l[i];

	}
    
    int ans = 0;

	sort (l, l + n);
    
   for ( int i = n-1; i >= 1; i--)
   { 
        
        int k = 0, m = i-1;

        while( k < m)
        { 
            if( l[k] + l[m] > l[i])
            { 
            
                ans += m - k ;   
            
                m--;   
            
            } 
            else 
            
                k++;   
        } 
    } 
    cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
 
int dp[100005][64];
int prev[100005][64];

void solve()
{
    int n, a, b, c;
    scanf("%d%d%d%d", &n, &a, &b, &c);
    ll sum = (ll)a + b + c;

    vector<int> v;
    int i, j;
    for (i = 0; i < n; i++) {
        char str[5] = { 0 };
        scanf("%s", str);
        if (strcmp(str, "AB") == 0) {
            v.push_back(0);
        }
        else if (strcmp(str, "AC") == 0) {
            v.push_back(1);
        }
        else {
            v.push_back(2);
        }
    }

    vector<int> ans;
    for (i = 0; i < n; i++) {
        if (v[i] == 0) {
            int flag = (a >= b ? 1 : 0);
            if (a == b) {
                if (i < n - 1 && v[i + 1] == 1) {
                    flag = 0;
                }
            }
            if (flag) {
                ans.push_back(1);
                a--; b++;
            }
            else {
                ans.push_back(0);
                a++; b--;
            }
        }
        else if (v[i] == 1) {
            int flag = (a >= c ? 1 : 0);
            if (a == c) {
                if (i < n - 1 && v[i + 1] == 0) {
                    flag = 0;
                }
            }
            if (flag) {
                ans.push_back(2);
                a--; c++;
            }
            else {
                ans.push_back(0);
                a++; c--;
            }
        }
        else {
            int flag = (b >= c ? 1 : 0);
            if (b == c) {
                if (i < n - 1 && v[i + 1] == 0) {
                    flag = 0;
                }
            }
            if (flag) {
                ans.push_back(2);
                b--; c++;
            }
            else {
                ans.push_back(1);
                b++; c--;
            }
        }
        if (a < 0 || b < 0 || c < 0) {
            printf("No\n"); return;
        }
    }

    printf("Yes\n");
    for (i = 0; i < n; i++) {
        char str0[5] = { 0 };
        str0[0] = 'A' + ans[i];
        printf("%s\n", str0);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 3800
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

i = 0
cnt = 0
loop_cnt = 0
loop_l = []
l = [1]
check = [0]*n
check[0] = 1
(n*2).times do
  i = a[i] - 1
  l.push i+1
  cnt += 1
  if check[i] == 1
    cnt -= 1
    loop_l = l[l.index(i+1)..-2]
    loop_cnt = loop_l.size
    loop_l.rotate!(-1)
    break
  else
    check[i] = 1
  end
end

if k < cnt
  puts l[k]
else
  k = k - cnt
  puts loop_l[k%loop_cnt]
end

Measured memory_bytes: 31948
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            
            System.out.println(A*B - (A+B-1));
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32336
$GroupA = [1,3,5,7,8,10,12]
$GroupB = [4,6,9,11]
 
str = STDIN.gets
ary = str.split(" ")
x = ary[0].to_i
y = ary[1].to_i
 
if(x >= y)
    puts "No"
elsif(x == 2 || y == 2)
    puts "No"
elsif(($GroupA.include?(x) && $GroupA.include?(y)) || ($GroupB.include?(x) && $GroupB.include?(y)))
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
N=10**7
llist=[0]*(N+1)
for i in range(1,N+1):
  for j in range(i,N+1,i):
    llist[j]+=1
dp=[0]*(N+1)
for i in range(1,N+1):
  dp[i]=dp[i-1]+llist[i]*i
N=int(input())
print(dp[N])

Measured memory_bytes: 224328
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define     M_PI   3.14159265358979323846    /* pi */

int main()
{
    double pi = 3.14159265358979323846;
    double ang_to_rad = M_PI / 180;
    double now_angle = 90;
    double x = 0, y = 0;
    double distance = 0, angle = 0;
    int final_x, final_y;

    while (1)
    {
        scanf("%lf,%lf", &distance, &angle);

        if (distance == 0 && angle == 0)
            break;
        if (distance < 0 || distance > 100 || angle < -180 || angle > 180)
            continue;

        x += distance * cos(now_angle * ang_to_rad);
        y += distance * sin(now_angle * ang_to_rad);
        now_angle -= angle;
    }
    //printf("%4.0f\n%4.0f\n", x, y);
    //printf("%d\n%d\n", (int)x, (int)y);
    final_x = x;
    final_y = y;
    printf("%d\n%d\n", final_x, final_y);


    return 0;
} 

Measured memory_bytes: 632
import math

N,D = map(int, raw_input().split())
ans = 0
X = []

for i in range(0, N):
    x = map(int, raw_input().split())
    X.append(x)
    for j in range(0, i):
        d = 0
        for k in range(0, D):
            d += (X[i][k] - X[j][k]) ** 2
        dx = math.sqrt(d)
        if dx.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 2568
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<stack>
#include<cmath>
#include<map>
#include<vector>
#define ll long long
#define inf 0x3f3f3f3f
#define bug1 cout<<"bug1"<<endl;
#define bug2 cout<<"bug2"<<endl;
#define bug3 cout<<"bug3"<<endl;
using namespace std;

int main(){
    char a,b;
    scanf("%s%s",&a,&b);
    if(a=='H'&&b=='H'||a=='D'&&b=='D')cout<<'H'<<endl;
    else cout<<'D'<<endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] string = new String[n];

        ArrayList<String> a = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            a.add(scan.next());
        }

        Collections.reverse(a);
        for(int i = 0; i < a.size(); i++){
            if(i < a.size()-1){
                System.out.print(a.get(i) + " ");
            }else{
                System.out.print(a.get(i));
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 26160
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        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)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Sarray();
            var Fi = Sarray();
            Array.Sort(Ai);
            Array.Sort(Fi); Array.Reverse(Fi);
            costs = new Tuple<long, long, long>[N];
            for (var i = 0; i < N; ++i)
                costs[i] = Tuple.Create(Ai[i], Fi[i], Ai[i] * Fi[i]);
            Array.Sort(costs, (l, r) => { var res = l.Item3 - r.Item3; return res > 0 ? 1 : res < 0 ? -1 : 0; });
            var min = -1L;
            var max = costs[N - 1].Item3;
            while (1 < max - min)
            {
                var mid = (min + max) / 2;
                if (check(mid, K))
                    max = mid;
                else
                    min = mid;
            }
            WriteLine(max);
        }
        static Tuple<long, long, long>[] costs;
        static bool check(long x, long k)//k回以下の操作でcostをx以下にできる？
        {
            var N = costs.Length;
            var num = 0L;
            for (var i = N - 1; 0 <= i; --i)
            {
                var c = costs[i].Item3;
                if (c <= x) break;
                var f = costs[i].Item2;
                num += (c - x + f - 1) / f;
                if (k < num) return false;
            }
            return true;
        }
    }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    vector<int> a(26, false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char s;
        cin >> s;
        a[s - 'A'] = true;
    }
    int cnt = 0;
    for (bool x : a) if (x) cnt++;
    cout << (cnt == 3 ? "Three" : "Four") << '\n';
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

struct Flow{//Dinic

 struct edge{
  ll to,cap,rev;//行先，容量，逆辺の場所
  edge(){}
  edge(ll to,ll cap,ll rev):to(to),cap(cap),rev(rev){}
 };

 ll n;
 vector<vector<edge> > g;//隣接リスト
 vector<ll> level,iter;

 Flow(){}
 Flow(ll n):n(n){ 
  g.resize(n);
  level.resize(n);
  iter.resize(n);
 }

 void add_edge(ll from,ll to,ll cap){
  edge e1(to,cap,g[to].size());
  edge e2(from,0,g[from].size());
  g[from].push_back(e1);
  g[to].push_back(e2);
 }

 void bfs(ll s){
  fill(level.begin(),level.end(),-1);
  queue<ll> q;
  q.push(s);
  level[s] = 0;
  while( !q.empty() ){
   ll tmp = q.front();
   q.pop();
   for(auto &e:g[tmp]){
    if(e.cap>0 && level[e.to] < 0 ){
     level[e.to] = level[tmp]+1;
     q.push(e.to);
    }
   }
  }
 }

 //増加パスを探す
 ll dfs(ll v,ll t,ll f){
  if( v == t ) return f;//シンク
  for(ll &i=iter[v]; i<g[v].size();i++){
   edge &e = g[v][i];
   
   if( e.cap > 0 && level[v]  < level[e.to] ){//level[v] +1 == level[e.to] と同じ意味になっている
    ll d = dfs(e.to, t , min(f,e.cap) );
    if( d > 0 ){
     e.cap -= d;//
     g[e.to][e.rev].cap += d;//逆変を増やす
     return d;
    }
   }
  }
  return 0;
 }


 //s to t の最大流
 ll max_flow(ll s,ll t){
  ll flow = 0;
  while(1){
   bfs(s);
   if(level[t] < 0 ) return flow;
   fill(iter.begin(),iter.end(),0);
   for(ll f = dfs(s,t,inf); f > 0 ; f = dfs(s,t,inf) ) flow += f;
  }
 }

};


int main(){
 ll v,e;
 cin>>v>>e;
 Flow f(v);
 for(ll i=0;i<e;i++){
  ll u,v,c;
  cin>>u>>v>>c;
  f.add_edge(u,v,c);
 }

 cout<<f.max_flow(0,v-1)<<endl;
    return 0;
}



Measured memory_bytes: 3196
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    int ans= 0;
    for (int i = 0; 1; i++)
    {
        for (int j = 0; j < n; j++){
            if(a[j]%2 ==1){ cout << ans << endl;
            return 0;
        }
            else a[j]/=2;    
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    long long x;
    scanf("%lld",&x);
    long long i;
    long long y=100;
    for(i=0;y<x;i++)
    {
        y=y+y*0.01;
    }
    printf("%lld\n",i);
    return 0;
}


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

int main (void){
    char str[256];
    char *tp;
    int d[3];
    int i=0;
    scanf("%s", str);
    tp = strtok( str, "/" );
    d[i] = atoi(tp);
    i++;
    while ( tp != NULL ) {
        tp = strtok( NULL,"/" );
        if ( tp != NULL ){
            d[i] = atoi(tp);
            i++;
        }
    }
    //printf("%d ", d[0]);
    //printf("%d ", d[1]);
    //printf("%d ", d[2]);

    if(d[0] >= 2019){
        if(d[1] == 4){
            if(d[2] >= 31){
                printf("TBD\n");
                return 0;
            }
        }
        if(d[1] > 4){
            printf("TBD\n");
            return 0;
        }
    }
    printf("Heisei\n");
    return 0;
}


Measured memory_bytes: 128
def lscan; gets.split.map(&:to_i); end

n = gets.to_i

aa = lscan
bb = lscan
cc = lscan

total = bb[aa[0]-1]
aa.each_cons(2) do |i,j|
    i -= 1
    j -= 1
    total += bb[j]
    total += cc[i] if i+1 == j
end


p total

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

struct node{
  node* right;
  node* left;
  int key,pri;
};

node* rightRotato(node* t) {
    node* s = t->left;
    t->left = s->right;
    s->right = t;
    return s;
}

node* leftRotato(node* t) {
    node* s = t->right;
    t->right = s->left;
    s->left = t;
    return s;
}

node* insert(node* t, int key, int pri) {
    if(t == NULL) {
        node* t = new node;
        t->left=NULL; t->right = NULL;
        t->key = key; t->pri = pri;
        return t;
    }
    if(key == t->key) return t;

    if(key < t->key) {
        t->left = insert(t->left, key, pri);
        if(t->pri < t->left->pri) t = rightRotato(t);
    }
    else {
        t->right = insert(t->right, key, pri);
        if(t->pri < t->right->pri) t = leftRotato(t);
    }
    return t;
}

node* erase(node* t, int key){
    if(t == NULL) return NULL;

    if(key == t->key) {
        if(t->left == NULL && t->right == NULL) return NULL;
        else if(t->left == NULL) t = leftRotato(t);
        else if(t->right == NULL) t = rightRotato(t);
        else {
            if(t->left->pri > t->right->pri) t = rightRotato(t);
            else t = leftRotato(t);
        }
        return erase(t,key);
    }
    if(key < t->key) t->left = erase(t->left, key);
    else t->right = erase(t->right, key);
    return t;
}

void find(node* t, int key) {
    while(t != NULL && key != t->key) {
        if(key < t->key) t = t->left;
        else t = t->right;
    }
    if(t == NULL) cout << "no" << endl;
    else cout << "yes" << endl;
}

void inorder(node* t) {
    if(t==NULL) return;
    inorder(t->left);
    cout << " " << t->key;
    inorder(t->right);
}

void preorder(node* t) {
    if(t == NULL) return;
    cout << " " << t->key;
    preorder(t->left);
    preorder(t->right);
}

int main() {
    node* root=NULL;
    int n,key,pri;
    string s;

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> s;
        if(s == "insert") {
            cin >> key >> pri;
            root = insert(root, key, pri);
        }
        else if(s == "delete") {
            cin >> key;
            root = erase(root, key);
        }
        else if(s == "find") {
            cin >> key;
            find(root, key);
        }
        else {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 9360
//ITP1_2_C
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a = 0;
  int b = 0;
  int c = 0;
  int arr[3]  = {0};
while(cin >> arr[0] >> arr[1] >> arr[2]){
	sort(arr,arr+3);
	for (int i = 0; i < 3; ++i)
	{
		cout <<	arr[i] ;
		if(i!=2){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	memset(arr,0,sizeof(arr));
}

    return 0;
}


Measured memory_bytes: 3112
import math
from itertools import accumulate


N, Q = list(map(int, input().split()))
S = input()

ans = []

for i in range(len(S) - 1):
    if S[i:i+2] == 'AC':
        ans.append(1)
    else:
        ans.append(0)

# print(ans)

L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

ans = list(accumulate([0] + ans))
# print(ans)
for i in range(Q):
    # print(i, R[i], L[i])
    print(ans[R[i] - 1] - ans[L[i] - 1])

Measured memory_bytes: 16884
#include "bits/stdc++.h"

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int N, M;
   cin >> N >> M;
   int L, R;
   vector<int> up(N, 0);
   vector<int> down(N, 0);
   for (int i = 0; i < M; i++)
   {
      cin >> L >> R;
      up[L - 1]++;
      down[R - 1]++;
   }
   int num = up[0];
   int count = 0;
   if (num == M)
      count++;
   for (int i = 1; i < N; i++)
   {
      num += up[i];
      num -= down[i - 1];
      if (num == M)
         count++;
   }
   std::cout << count << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
 
int a[1000010], n;
 
bool binarysearch(int key)
{
    int left = 0;
    int right = n;
    int mid;
    while(left < right)
    {
        mid = (left + right) / 2;
        if(key == a[mid])
        {
            return true;
        }
        else if(key < a[mid])
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }
 
    return false;
}
 
int main()
{
    int i, q, k, sum=0;
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
 
    sort(a, a + n);
 
    scanf("%d", &q);
    for(i = 0; i < q; i++)
    {
        scanf("%d", &k);
        if(binarysearch(k))
        {
            sum++;
        }
    }
 
    printf("%d\n", sum);
 
    return 0;
}


Measured memory_bytes: 3184
N = int(input())
H = list(map(int, input().split()))

ch = [0]
ans = 0
for i in range(N-1):
    if H[i] < H[i+1]:
        ch.append(i+1)
    if i == N-2:
        ch.append(i+2)
    if len(ch) > 1:
        ans = max(ans, ch[-1]-ch[-2]-1)
print(ans)


Measured memory_bytes: 14224
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    nt, nx, ny = map(int, input().split())
    km = abs(nx-x) + abs(ny-y)
    if km > (nt-t) or (km - (nt-t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y = nt, nx, ny
print("Yes")

Measured memory_bytes: 69312
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 59;
ll st,n,m,i,comp,sz,ans,A,B;
ll visit[N],a[N],b[N];
vector<vi> adj;
void dfs(ll v)
{
    visit[v] = st; comp++;
    for(auto &it: adj[v]) if(visit[it] != st and !((v == A and it == B) or (v == B and it == A))){
      dfs(it);
    }
}
int main()
{
   std::ios_base::sync_with_stdio(false); cin.tie(NULL);
   cin>>n>>m;
   adj.rs(n);
   rep(i,0,m){
       cin>>a[i]>>b[i];
       a[i]--; b[i]--;
       adj[a[i]].pb(b[i]); adj[b[i]].pb(a[i]);
   }
   rep(i,0,m){
       comp = 0;
       st++;  A = B = -1;
       dfs(a[i]);
       sz = comp;
       st++;
       A = a[i]; B = b[i];
       comp = 0;
       dfs(a[i]);
       if(comp != sz) ans++;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
a = s[:((n-1)//2)]
b = s[((n+3)//2-1):]

ans = 'Yes'

for i in range(n // 2):
    if s[i] == s[-1*(i+1)]:
        continue
    else:
        ans = 'No'
        break

for j in range(len(a)//2):
    if a[j] == a[-1*(j+1)]:
        continue
    else:
        ans = 'No'
        break
        
for k in range(len(b)//2):
    if b[k] == b[-1*(k+1)]:
        continue
    else:
        ans = 'No'
        break
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
bool sortdes(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasc(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;} 
int gcd(int x,int y){return __gcd(x,y);}
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];
// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

void test_case(){
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for(int i=a;i<=b;++i){
        if(i%k==0){
            flag=1;
            break;
        }
    }
    if(flag){
        test("OK");
    }
    else{
        test("NG");
    }
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <set>
#include <cstring>

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

using namespace std;

using ll = long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

template<typename T> struct WeightedUnionFind {
	vector<T> par, rank, diff_weight;
	WeightedUnionFind( T n )
	{
		par.resize( n, -1 );
		rank.resize( n, 0 );
		diff_weight.resize( n, 0 );
	}

	T find( T x ) {
		if ( par[x] < 0 ) return ( x );
		else
		{
			T r = find( par[x] );
			diff_weight[x] += diff_weight[par[x]];
			return ( par[x] = r );
		}
	}

	T weight( T x ) {
		find( x );
		return ( diff_weight[x] );
	}

	T diff ( T x, T y ) { return ( weight( y ) - weight( x ) ); }

	bool unite( T x, T y, T w ) {
		w += weight( x ); w -= weight( y );
		x = find( x ); y = find( y );
		if ( x == y ) return ( false );
		if ( rank[x] < rank[y] ) { swap( x, y ); w *= -1; }
		if ( rank[x] == rank[y] ) ++rank[x];
		par[x] += par[y];
		par[y] = x;
		diff_weight[y] += w;
		return ( true );
	}

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

	T size( T x ) { return ( -par[find( x )] ); }
};

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

	WeightedUnionFind<ll> wuf( N + 1 );
	rep( i, M )
	{
		ll l, r, d;
		cin >> l >> r >> d;
		wuf.unite( l, r, d );
		if ( wuf.diff( l, r ) != d )
		{
			cout << "No" << endl;
			return ( 0 );
		}
	}

	cout << "Yes" << endl;

	return ( 0 );
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    int n;
    cin>>n;
    int len=to_string(n).length();
    if(n%2==0 || n%5==0){
        cout<<"-1\n";
        return 0;
    }
    int k=7;
    int cnt=1;
    while(true){
        if(k%n==0){
            cout<<cnt<<"\n";
            break;
        }
        else if(cnt>=n){
            cout<<"-1\n";
            break;
        }
        k=(k%n)*10+7;
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 3712
n, k = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
mc = [0]
for i in range(1,n):
    ans = 1e9
    for j in range(max(i-k, 0), i):
        ans = min(ans, mc[j]+abs(h[i]-h[j]))
    mc.append(ans)
print(ans)

Measured memory_bytes: 57952
n = int(input())
l_list = list(map(int, input().split()))
# print(l_list)
count = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l_list[i] == l_list[j] or l_list[j] == l_list[k] or l_list[k] == l_list[i]:
                continue
            else:
                total = l_list[i] + l_list[j] + l_list[k]
                max_l = max(l_list[i], l_list[j], l_list[k])
                # print(total)
                # print(max_l)
                if total - max_l*2 > 0:
                    count += 1

print(count)


Measured memory_bytes: 68532
// atcoder/abc125/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

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

using namespace std;

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

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

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

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

  int n;
  while (cin >> n) {
    vector<int> v(n);
    vector<int> c(n);
    cin >> v >> c;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += max(0, v[i] - c[i]);
    }
    cout << sum << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
  int n, len;
  char S[10010];

  cin >> n;
  cin >> S;

  len = strlen(S);
  for(int i=0; i<len; i++) {
    int x = S[i] - 'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
  cout << endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string o, e; cin >> o >> e;
  int n = o.size() + e.size();
  int oi = 0, ei = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      cout << o[oi];
      oi++;
    }
    else{
      cout << e[ei];
      ei++;
    }
  }
  cout << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;
long long gcd(long a,long b,long c){
while(b){
 long long rem=a%b;
  a=b;
  b=rem;  
}
  while(a)
  {
   long long ren=c%a;
    c=a;
    a=ren;
  }
  return c;
}
int main()
{
  
  long k;cin>>k; unsigned long long sum=0;
 for(long i=1;i<=k;i++)
 {
   for(long j=1;j<=k;j++)
 {
     for(long m=1;m<=k;m++)
 {
     sum+=gcd(i,j,m);
       //cout<<endl;
 }
   
 }
   
 }
 cout<<sum<<"\n";
return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
int k;
int main(){
    scanf("%d",&k);
    if(k==1){puts("1");puts("1");return 0;}
    int n=(k+3)/4*2;
    printf("%d\n",n);
    rep(i,0,n-1){
        rep(j,0,n-1){
            int t=(i+j)%n+1;
            if(i&1) t+=n;
            if(t>k) t-=n;
            printf("%d ",t);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1152
x,n = map(int,input().split())
ps = list( map(int,input().split()))
prob = [True]*103

for p in ps:
    prob[p+1] = False

ans = 200

for i in range(102,-1,-1):
    if prob[i]:
        if abs(ans - x) >= abs(i-1-x):
            ans = i-1

print(ans)

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int j = 0;
		int b = sc.nextInt();
		
		int min = b;
        int max = b;
        long sum = b;
        
		for(j=0;j<n-1;j++){
			int a = sc.nextInt();
			
			 sum =sum+a;
			 
		int i = 0;

		     min = Math.min(min,a);
		     max = Math.max(max,a);   	

		}
		System.out.println(min + " " +max+ " " +sum);
	}
	

}


Measured memory_bytes: 41352
(* 配列版素集合データ構造 *)
module RawUnionFind : sig
  type t
  type class_

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> class_
  (* 与えられた要素が属する集合同士を合併する *)
  val unite : t -> int -> int -> unit

  val compare_class : class_ -> class_ -> int
end = struct
  type t = { rank : int array; parent : int array }
  type class_ = int

  let make n =
    { rank = Array.make n 0;
      parent = Array.init n (fun c -> c) }

  let rec find uf x =
    if x = uf.parent.(x) then x
    else begin
      let y = find uf uf.parent.(x) in
      uf.parent.(x) <- y; y
    end

  let unite uf i j =
    let x = find uf i in
    let y = find uf j in
    if x <> y then begin
      if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y
      else begin
        uf.parent.(y) <- x;
        if uf.rank.(x) = uf.rank.(y) then
          uf.rank.(x) <- 1 + uf.rank.(x)
      end
    end

  let compare_class = compare
end

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let ls = Array.make m [] in
  for i = 0 to n - 1 do
    Scanf.scanf "%d " @@ fun k ->
      for j = 0 to k - 1 do
        Scanf.scanf "%d " @@ fun l ->
          ls.(l - 1) <- i :: ls.(l - 1)
      done
  done;
  let uf = RawUnionFind.make n in
  Array.iter (function
    | [] -> ()
    | x :: xs -> List.iter (RawUnionFind.unite uf x) xs) ls;
  print_endline @@
  if
    List.for_all (fun x ->
      RawUnionFind.compare_class
        (RawUnionFind.find uf 0)
        (RawUnionFind.find uf x) = 0) @@
    Array.to_list @@
    Array.init n @@ fun i -> i
  then "YES"
  else "NO"



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

#define SYNC ios::sync_with_stdio(0);
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 58;
const ll mod = 1000000007;



int main() {
    SYNC
    int n[5], ans = 0;
    int idx = 0, maxi = 0;
    for (int i = 0; i < 5; ++i) {
        cin >> n[i];
        //cout << "dif: " << abs(n[i]%10 - 10)%10 << endl;
        if (maxi < abs(n[i]%10 - 10)%10) {
            maxi = abs(n[i]%10 - 10)%10;
            idx = i;
        }
        ans += n[i] + abs(n[i]%10 - 10)%10;
        //cout << "ans: " << ans << endl;
    }
    //cout << idx << endl;
    ans -= abs(n[idx]%10 - 10)%10;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val a = s"0 $readLine 0".split(" ").map(_.toInt)
  val (sum, _) = a.foldLeft((0, 0)) { (acc, i) =>
    (acc._1 + math.abs(acc._2 - i), i)
  }
  for (i <- 1 to n) {
    println(
      sum - math.abs(a(i) - a(i - 1)) - math.abs(a(i + 1) - a(i)) + math
        .abs(a(i + 1) - a(i - 1))
    )
  }

}


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

using namespace std;
typedef long long ll;

int main()
{
    ll h,w;
    cin>>h>>w;

    char a[h][w];
    for(ll i=0; i<h; i++)
        for(ll j=0; j<w; j++)
            cin>>a[i][j];

    for(ll i=-1; i<=h; i++){
        if(i == -1 || i == h){
            for(ll j=0; j<=w+1; j++) cout<<"#";
            cout<<endl;
        }
        else{
            cout<<"#";
            for(ll j=0; j<w; j++) cout<<a[i][j];
            cout<<"#"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=105;
char s[maxn],t[7];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	scanf("%s",s); int n=strlen(s);
	int i=0,j=0;
	t[0]='k'; t[1]='e'; t[2]='y'; t[3]='e'; t[4]='n'; t[5]='c'; t[6]='e';
	while(s[i] == t[i] && i <= 7) i++;
	while(s[n-1-j] == t[6-j]) j++;
	if(i+j >= 7) puts("YES");
	else puts("NO");
	return 0;
}//Faze


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

int main() {
	int h, w; cin >> h >> w;
	char a[100][101], b[102][102];
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			b[i][j] = '#';
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			b[i + 1][j + 1] = a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			printf("%c", b[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In = Console.ReadLine().Split(' ');
            long n = long.Parse(In[0]);
            long a = long.Parse(In[1]);//青//こっちを数える
            long b = long.Parse(In[2]);//赤
            long sum = 0;

            long x = a + b;
            long mult = n/x;
            if (mult != 0)
            {
                sum += a * mult;
            }
            long y = n - (x * mult);
            if (y != 0)
            {
                if (y < a) sum += y;
                else if (a <= y) sum += a;
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11092