akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
 
int main()
{
	char text[100];
	scanf("%s", text);
 
	int text_len = strlen(text);
 
	int is_text_palindrome = 0;
	for (int i = 0; i < text_len / 2; i++)
	{
		if (text[i] != text[text_len - i - 1])
			break;
		else if (i == text_len / 2 - 1)
			is_text_palindrome = 1;
	}
 
	int is_beforetext_palindrome = 0;
	for (int i = 0; i < ((text_len - 1) / 2 + 1) / 2; i++)
	{
		if (text[i] != text[(text_len - 1) / 2 - i - 1])
			break;
		else if (i == ((text_len - 1) / 2 +1) / 2 - 1)
			is_beforetext_palindrome = 1;
	}
 
	int is_aftertext_palindrome = 0;
	int count = 0;
	for (int i = (text_len + 3) / 2 - 1; i < text_len - (text_len - 1) / 4 ; i++)
	{
		if (text[i] != text[text_len - count - 1])
			break;
		else if (i == text_len - (text_len -1) / 4 - 1)
			is_aftertext_palindrome = 1;
		else
			count += 1;
	}
 
	printf("%s", is_text_palindrome && is_beforetext_palindrome && is_aftertext_palindrome
		? "Yes\n" : "No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 10 == 3) {
		cout << "bon";
	}
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		cout << "pon";
	}
	else {
		cout << "hon";
	}
}

Measured memory_bytes: 3640
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

a,b,c = map(int,input().split())
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)

Measured memory_bytes: 3316
import fractions

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

l = [0]
r = [0]

for i in range(n):
    l.append(fractions.gcd(l[i], a[i]))
    r.append(fractions.gcd(r[i], a[n - i - 1]))

ans = 0
for i in range(n):
    ans = max(ans, fractions.gcd(l[i], r[n-i-1]))

print(ans)

Measured memory_bytes: 16700
factor = int(input())
numbers = list(map(int, input().split()))

def bublesort(array, n):
    counter = 0
    flag = 1
    while(flag):
        i=0
        flag=0
        temp = 0
        for j in range(len(array)-1, i, -1):
            if array[j] < array[j-1]:
                temp = array[j]
                array[j] = array[j-1]
                array[j-1] = temp
                flag = 1
                counter += 1
        i += 1
    return counter


repetition = bublesort(numbers, factor)
print(" ".join(list(map(str,numbers))))
print(repetition)



Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    int n; cin >> n;
    int a[n]; rep(i, n) cin >> a[i];
    ll ans1 = 0, ans2 = 0, sum = 0;
    rep(i, n) {
        sum += a[i];
        if (i % 2 == 0 && sum <= 0) {ans1 += 1 - sum; sum = 1;}
        else if (i % 2 != 0 && sum >= 0) {ans1 += sum + 1; sum = -1;}
    }
    sum = 0;
    rep(i, n) {
        sum += a[i];
        if (i % 2 == 0 && sum >= 0) {ans2 += sum + 1; sum = -1;}
        else if (i % 2 != 0 && sum <= 0) {ans2 += 1 - sum; sum = 1;}
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 640
def count(hp,bp)
  if(hp%bp!=0)
    return hp/bp+1
  end
  return hp/bp
end

A,B,C,D = gets.split()
if(count(A.to_i(),D.to_i())>=count(C.to_i(),B.to_i()))
  puts('Yes')
else
  puts('No')
end

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

#define int long long int
#define MOD 1000000007

struct knap
{
    int val ;
    int w ;
};

int32_t main()
{
    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        int n, w ;
        cin >> n >> w ;
        knap a[n] ;
        for(int i = 0 ; i < n ; i++)
        {
            cin >> a[i].w >> a[i].val ;
        }
        int dp[n+1][w+1] ;
        memset(dp, 0, sizeof(dp)) ;
        for(int i = 1 ; i <= n ; i++)
        {
            for(int j = 1 ; j <= w ; j++)
            {
                if(j >= a[i-1].w)
                {
                    dp[i][j] = max(a[i-1].val + dp[i-1][j-a[i-1].w], dp[i-1][j]) ;
                }
                else
                {
                    dp[i][j] = dp[i-1][j] ;
                }
            }
        }
        cout << dp[n][w] ;
    }
    return 0 ;
}

Measured memory_bytes: 79104
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			String text = scanner.nextLine();
			while (true) {
				text = decode(text);
				if (text.contains("the") || text.contains("this") || text.contains("that")) {
					System.out.println(text);
					break;
				}
			}
		}
	}
	public static String decode(String text) {
		char[] c = text.toCharArray();
		for (int i = 0; i < c.length; i++) {
			char letter = c[i];
			if ('a' <= letter && letter <= 'z') {
				if (letter == 'z') letter = 'a';
				else letter++;
			}
			c[i] = letter;
		}
		return String.valueOf(c);
	}
}

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

int main(){
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)if(to_string(i).size()%2==1){
        ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
l,r = gets.chomp!.split(" ").map(&:to_i)

min = l % (2019 * 2)
max = r % (2019 * 2)

if min >= max
    puts 0
else
    ans = 9999999
    min.upto(max - 1) do |i|
        (i + 1).upto(max) do |j|
            x = (i * j) % 2019
            if x < ans
                ans = x
            end
        end
    end

    puts ans
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
     
#define int  long long
#define endl '\n'
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e6 + 10;

struct IOsetup{
  IOsetup(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
  int a, b;
  cin >> a >> b;
  int tot = 6;
  int rem = tot - (a + b);
  cout << rem << endl;
}


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

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    long long sum = 0;
    for (int i = 0; i < m; i++) {
    	cin >> a[i];
    	sum += a[i];
    }

    if (sum > (long long)n)
    	cout << -1 << "\n";
    else
    	cout << (long long)n - sum << "\n";
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string check="abcdefgh";
    int j=0;
    //2019/03/13みたいなｓが与えられるので、4番目と7番目の時だけcheckに入れない
    for(int i=0; i <10 ; i++){
        if(i==4||i==7){
            continue;
        }
        else if(i !=4 || i!=7){
            check.at(j)=s.at(i);
            j++;
        }
    }
    int C = 0;
    int b = 0;
    for(int i=7;i>=0;i--){
        int a = 0;
        a =  (check.at(b)-'0')*std::pow(10,i);
        C += a;
        b++;
    }
//    cout<<C<<endl;
    if(C<=20190430){
        cout<<"Heisei"<<endl;
    }
    else if (C>20190430){
        cout <<"TBD"<<endl;
    }
    }



Measured memory_bytes: 256
n,m = map(int,input().split())
a = [1]*(n+1)
b = [0]*(n+1)
for i in range(m):
  x,y = map(int,input().split())
  u = x
  while a[u]==0:
    u = b[u]
  v = y
  while a[v]==0:
    v = b[v]
  if u!=v:
    b[v] = u
    b[y] = u
    b[x] = u
    a[u] += a[v]
    a[v] = 0
print(max(a))

Measured memory_bytes: 77732
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var sw =Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();

      System.out.println(sw[0] <= sw[1] ? "unsafe" : "safe");
    }
  }
}


Measured memory_bytes: 34304
n, m = map(int, input().split())
k = []
tmp = [0] * m
for i in range(n):
    k.append(list(map(int, input().split())))
    k[i].pop(0)
ans = 0
cnt = 0
for i in k:
    for j in i:
        tmp[j-1] += 1

for i in tmp:
    if i == n:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void out(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void out(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);out<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';out<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T *a,int n){REP(i,n){if(i)cout<<',';cout<<a[i];}cout<<endl;}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>void output(T t){if(t<0)t=-t,putchar(45);static int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;putchar(c[--k]^48));}
template<class S,class ...T>void output(S a,T...t){output(a);putchar(' ');output(t...);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());t=10*t+c-48);t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

const int N = 500002;
ll x[N], y[N];
int id[N];
ll closest_pair(int l, int r) {
  if (l+1>=r) return 1LL<<50;
  int m = l+r>>1;
  int tx = x[id[m]];
  ll d = min(closest_pair(l,m),closest_pair(m,r));
  inplace_merge(id+l,id+m,id+r,[&](int i, int j){return y[i]<y[j];});
  vector<int> v;
  for (int i=l; i<r; ++i) {
    int a = id[i];
    if ((x[a]-tx)*(x[a]-tx) >= d) continue;
    for (int j=v.size()-1; j>=0; --j) {
      ll dx = x[a] - x[v[j]];
      ll dy = y[a] - y[v[j]];
      if (dy*dy >= d) break;
      chmin(d, dx*dx+dy*dy);
    }
    v.push_back(a);
  }
  return d;
}

int main() {
  int n;
  while(cin >> n) {
    ll mx = INF;
    REP(i,n) {
      scanf("%lld%lld", x+i,y+i);
    }
    iota(id,id+n,0);
    sort(id,id+n,[&](int i, int j){return x[i]<x[j];});
    cout << closest_pair(0,n) << endl;
  }
}

Measured memory_bytes: 12272
N,M = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(M)]
Flag = True
# [穴埋め,1桁目、2桁目、3桁目]
R = [-1,-1,-1,-1]

for i,j in L:
    if R[i] == -1:
        R[i] = j
    elif R[i] != j:
        Flag = False

if (N>1) and (R[1] == 0):
    Flag = False

if (not Flag):
    print(-1)
else:
    # 条件が無い場合
    if M ==0:
        if N == 1:
            print(0)
        elif N == 2:
            print(10)
        else:
            print(100)
    else:
        if N == 1:
            print(R[1])
        elif N == 2:
            if R[1] == -1:
                R[1] = 1
            if R[2] == -1:
                R[2] = 0
            print(R[1]*10+R[2])
        else:
            if R[1] == -1:
                R[1] = 1
            if R[2] == -1:
                R[2] = 0
            if R[3] == -1:
                R[3] = 0
            print(R[1]*100+R[2]*10+R[3])


Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long a, b, c;
    readlnTo(a, b, c);
    auto x = [a, b, c];
    x.sort();

    bool[long[]] used;
    long ans;
    while(x.all!(a => a % 2 == 0)) {
        if((x in used) !is null) {
            ans = -1;
            break;
        }
        ++ans;
        used[x.idup] = true;
        x = [(x[0]+x[1])/2, (x[1]+x[2])/2, (x[2]+x[0])/2];
        x.sort();
    }
    writeln(ans);
}



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

int main() {
 set<UL> S;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c,x; scanf("%u%u",&c,&x);
  if(c==0){
   S.insert(x);
   printf("%u\n",S.size());
  }
  if(c==1){
   printf("%u\n",S.count(x));
  }
  if(c==2){
   S.erase(x);
  }
 }
 return 0;
}




Measured memory_bytes: 12548
#include<stdio.h>

#define MATRIX_SIZE (100)

int main(void)
{
        int n, m, l;
        int mat_a[MATRIX_SIZE][MATRIX_SIZE], mat_b[MATRIX_SIZE][MATRIX_SIZE];
        int row, column, row_column;
        long long sum;


        scanf("%d%d%d", &n, &m, &l);

        for(row=0; row < n; row++){
                for(column=0; column < m; column++){
                        scanf("%d", &mat_a[row][column]);
                }
        }

        for(row=0; row < m; row++){
                for(column=0; column < l; column++){
                        scanf("%d", &mat_b[row][column]);
                }
        }

        for(row=0; row < n; row++){
                for(column=0; column < l; column++){
                        sum = 0;
                        for(row_column=0; row_column < m; row_column++){
                                sum += mat_a[row][row_column] * mat_b[row_column][column];
                        }
                        printf("%lld", sum);
                        if(column < l - 1) printf(" ");
                }
                printf("\n");
        }

        return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<utility>
#include<map>
#include<set>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<sstream>
#include<cstring>
#include<bitset>
#include<stack>
using namespace std;

string n;
long long ans;

pair<long long,int> solve(int l,int r,int t)
{
	long long sum=0;
	int tim=0;
	if(t==0)
	{
		for(int i=l;i<=r;i++)
		{
			sum=sum*10+n[i]-48;
		}
		return make_pair(sum,1);
	}
	
	for(int i=l;i<=r;i++)
	{
		int j=0;
		if(i-l<j || r-i-1<t-j-1)continue;	
		pair<long long,int>pp=solve(i+1,r,t-j-1);
		tim+=pp.second;
		long long x=solve(l,i,j).first*pp.second+pp.first;
		//cout<<l<<" "<<i<<" "<<j<<" "<<i+1<<" "<<r<<" "<<t-j-1<<" "<<x<<endl;
		sum+=x;
	}
	return make_pair(sum,tim);
}

int main()
{
	cin>>n;
	for(int i=0;i<n.size();i++)
	{
	    long long x=solve(0,n.size()-1,i).first;
		ans+=x;
		//printf("%d\n",ans);
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

ll n;
ll res = 1000000000000000000ll;

int main()
{
    cin >> n;
    for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
        ll j = n / i;
        res = min(res, i - 1ll + j - 1ll);
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 112345;
vector<int> g[MAX_N];

int ord[MAX_N]; // 訪れた順につける番号
int low[MAX_N]; // DFS 木の葉方向の辺を 0 回以上、後退辺を 1 回以下でたどり着ける ord の最小値
bool isArticulation[MAX_N];

void dfs(int u, int p, int &ordc) {
  low[u] = ord[u] = ordc++;
  int deg = 0;
  bool isa = false;
  for (int v : g[u]) if (v != p) {
    if (ord[v] == -1) { // まだ訪れてない
      deg++;
      dfs(v, u, ordc);
      low[u] = min(low[u], low[v]);
      if (ord[u] <= low[v]) isa = true;
    } else { // まだ (u,v) を使ってない
      // このとき (u,v) は後退辺
      low[u] = min(low[u], ord[v]);
    }
  }

  // 頂点 u が関節点 <=> u が DFS 木の根なら次数 > 1 かどうか、uがそれ以外なら ord[u] <= low[v] なる u の子 v が存在するかどうか
  isArticulation[u] = (p == -1 ? deg >= 2 : isa);
}
void lowlink(int N) {
  CLR(ord, -1);
  CLR(isArticulation, 0);
  int ordc = 0;
  REP(u, N) if (ord[u] == -1) {
    dfs(u, -1, ordc);
  }
}
// DFS 木の辺 e(u, v) が橋 <=> ord[u] < low[v]
bool isBridge(int u, int v) {
  if (ord[u] > ord[v]) swap(u, v);
  return ord[u] < low[v];
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt();
    int b = nextInt();
    g[a].push_back(b);
    g[b].push_back(a);
  }

  lowlink(N);

  REP(i, N) if (isArticulation[i]) printf("%d\n", i);

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 7992
h,w = map(int,input().split())
inf = 10**8
dist = [[inf for i in range(h*w)] for j in range(h*w)]

G = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if G[i][j] == '.':
            dist[i * w + j][i * w + j] = 0
            for dx,dy in [[-1,0],[1,0],[0,1],[0,-1]]:
                if 0<=i+dx<h and 0<=j+dy<w and G[i+dx][j+dy] == '.':
                    dist[i * w + j][(i + dx) * w + j + dy] = 1
                    dist[(i + dx) * w + j + dy][i * w + j] = 1

for i in range(h*w):
    for j in range(h*w):
        for k in range(h*w):
            dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k])

ans = 0
for i in range(h*w):
    for j in range(h*w):
        if dist[i][j] < inf:
            ans = max(ans,dist[i][j])

print(ans)

Measured memory_bytes: 45848
import math
a,b,x = map(int,input().split())
ans_taiseki = a**2*b - x
ans_hen2 = ans_taiseki/(a*a)*2

ans_hen = x/(a*b)*2
if ans_hen < a:
    ans = math.degrees(math.atan(b/ans_hen))
else:
    ans = math.degrees(math.atan(ans_hen2/a))

print(ans)

Measured memory_bytes: 38384
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a[300030], ans = 0;
	cin >> n;
	for (int i = 0; i < 3*n; i++)cin >> a[i];
	sort(a, a + 3*n);
	for (int i = 3 * n - 2; i >= n; i -= 2)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	int k = read.to!int;
	
	n -= (k - 1);
	
	int ans;
	if(k == 1) ans = 0;
	else ans = n - 1;
	
	ans.writeln;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

x=int(input())
cnt=1
while cnt*x%360!=0:
    cnt+=1
print(cnt)

Measured memory_bytes: 68152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    int ans=0;
    for(int i=0;i<n;i++) cin >> h[i];
    int f=0;
    for(int i=0;i<n;i++){
        if(f>=h[i]) f=h[i];
        else {
            ans+=h[i]-f;
            f=h[i];
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int A[100];
int main(){
  int i, res=1073709056, tmp, x;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(x=(-100);x<(101);x++){
    tmp = 0;
    for(i=0;i<(N);i++){
      tmp +=pow2_L((A[i]-x));
    }
    chmin(res, tmp);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// int N, A[100];
// {
//   int i, x, res = int_inf, tmp;
//   rd(N,A(N));
//   rep(x,-100,101){
//     tmp = 0;
//     rep(i,N) tmp += (A[i]-x)**2;
//     res <?= tmp;
//   }
//   wt(res);
// }


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

int main() {
  int n;
  cin >> n;
  if(n >= 64){
    cout << 64 << endl;
  }else if(n >= 32){
    cout << 32 << endl;
  }else if(n >= 16){
    cout << 16 << endl;
  }else if(n >= 8){
    cout << 8 << endl;
  }else if(n >= 4){
    cout << 4 << endl;
  }else if(n >= 2){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
n_i = str(n)
if n % 2 == 0:
    print('No')

else:
    for i in range(len(n_i) // 2):
        if n_i[i] != n_i[len(n_i) -1 - i]:
            print('No')
            exit()
    print('Yes')


Measured memory_bytes: 9164
import java.util.*;


public class Main {
    static void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c10000 = 0;
        int c5000 = 0;
        int c1000 = 0;

        boolean solved = false;
        for(int i = 0; i <= n; i++) {
            c10000 = i;
            for (int j = 0; j <= n - i; j++) {
                c5000 = j;
                c1000 = n-j-i;
                int cm = m -10000*c10000 -5000*c5000 -1000*c1000;
                if(cm == 0){
                    solved = true;
                    break;
                }
            }
            if(solved){
                break;
            }else if(i == n){
                c10000 = -1;
                c5000 = -1;
                c1000 = -1;
            }
        }

        System.out.println(c10000 + " " + c5000 + " " + c1000);
    }

    public static void main(String[] args) {
        solve();
    }
}


Measured memory_bytes: 23252
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
map<string,int> me;
int main()
{
	int n,ma=0;string s;vector<string> out;
	cin>>n;
	rep(i,n){
		cin>>s;me[s]++;
	}
	map<string,int>::iterator it=me.begin();
	while(it!=me.end()){
		ma=max(ma,(*it).se);it++;
	}
	it=me.begin();
	while(it!=me.end()){
		if(ma==(*it).se) out.pb((*it).fi);it++;
	}
	sort(All(out));
	rep(i,out.size()) cout<<out[i]<<endl;
}


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

int main()
{
    map<string,int> m;
    string s;
    int n;
    cin>>n;
    while(n-->0) {
        cin>>s;
        m[s]=1;
    }
    int w=m.size();
    cout<<w<<endl;
    return 0;
}


Measured memory_bytes: 19180
//#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
//#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

//#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);
//mt19937_64 gen(41);

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int k = 1;
	while (a > 0 && c > 0) {
		if (k) 
			c -= b;
		else
			a -= d;
		k ^= 1;
	}
	if (c <= 0)
		cout << "Yes";
	else
		cout << "No";
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,a[58],t;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;cout<<2*n-1<<'\n';
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	t=1;
	for(int i=2;i<=n;++i){
		if(abs(a[i])>abs(a[t])){
			t=i;
		}
	}
	for(int i=1;i<=n;++i){
		cout<<t<<' '<<i<<'\n';
	}
	if(a[t]>0){
		for(int i=1;i<n;++i){
			cout<<i<<' '<<i+1<<'\n';
		}
	}
	else{
		for(int i=n;i>=2;--i){
			cout<<i<<' '<<i-1<<'\n';
		}
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  if(a <= b*2){ 
    cout << 0 << endl;
  }
  else{
    cout << a-b*2 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	LL ans=0;
	REP(i,N){
		int x=i+1;
		int c=0;
		while(x!=0){
			c++;
			x/=10;
		}
		if(c%2==1){
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (abs(B - A) % 2) {
		cout << "Borys" << endl;
	}
	else {
		cout << "Alice" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool b[110];
int main()
{
	int X, N;
	cin >> X >> N;
	int ans = mod;
	int num = mod;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		b[A] = true;
	}
	for (int i = -100; i <= 200; i++) {
		if (i >= 0) {
			if (!b[i]) {
				if (num > abs(X - i)) {
					ans = i;
					num = abs(X - i);
				}
			}
		}
		else {
			if (num > abs(X - i)) {
				ans = i;
				num = abs(X - i);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	prime := primeTable(55555)
	var ans []int
	for i := 2; i <= 55555; i++ {
		if i%5 == 1 && prime[i] {
			ans = append(ans, i)
		}
	}

	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, ans[i])
	}
	fmt.Fprintln(wtr)
}

func primeTable(n int) map[int]bool {
	prime := make(map[int]bool)
	for i := 0; i <= n; i++ {
		prime[i] = true
	}
	prime[0] = false
	prime[1] = false
	for i := 2; i*i <= n; i++ {
		if !prime[i] {
			continue
		}
		for j := i + i; j <= n; j += i {
			prime[j] = false
		}
	}
	return prime
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
bool snuke[105];
int main(){
  int n , k , d , s; 
  cin>>n>>k;
  for(int i=1;i<=k;i++){
    cin>>d;
    for(int j=1;j<=d;j++){
      cin>>s;
      snuke[s] = true;
    }
  }
  int ans = 0;
  for(int i=1;i<=n;i++)if(!snuke[i])ans++;
  cout<<ans<<endl;
}

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

using namespace std;
#define ll long long int
#define ed "\n"


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string a;
	ll p = 0;


	cin>>a;
ll n = a.length();

	for(ll i =0;i<n;i++)
	{
		if(a[i]=='7')
		{
			p=1;
			break;
		 } 
	}
	if(p==1)
	{
		cout<<"Yes"<<ed;
	}
	else
	{
		cout<<"No"<<ed;
	}
	
	return 0;


 } 

Measured memory_bytes: 3644
input_str = input().split()
N = input_str[0]
A = int(input_str[1])
B = int(input_str[2])

sum_ans= 0
for n in range(1, int(N)+1 ):
  sum_n = 0
  for i in range(0,len(str(n))):
    sum_n += int(str(n)[i])
  if A <= sum_n and sum_n <= B:
    sum_ans += n

print(sum_ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X;
    cin >> X;
    ll res = 0;
    res += (X / 500) * 1000;
    X %= 500;
    res += (X / 5) * 5;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll inf = 1e9+7;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b){
  return (a/gcd(a,b))*b;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  if(w*h %3 == 0){cout << 0 << "\n"; return 0;}
  ll ans = inf;
  ll k = max(h, w);
  ll l = min(h, w);
  for(ll i = 1; i < k; ++i){
    ll s1[3], s2[3];
    s1[0] = i*l; s1[1] = (k-i)*(l/2); s1[2] = (k-i)*((l+1)/2);
    sort(s1, s1+3);
    ans = min(ans, s1[2]-s1[0]);
    s2[0] = i*l; s2[1] = l*((k-i)/2); s2[2] = l*((k-i+1)/2);
    sort(s2, s2+3);
    ans = min(ans, s2[2]-s2[0]);
  }
  swap(k, l);
  for(ll i = 1; i < k; ++i){
    ll s1[3], s2[3];
    s1[0] = i*l; s1[1] = (k-i)*(l/2); s1[2] = (k-i)*((l+1)/2);
    sort(s1, s1+3);
    ans = min(ans, s1[2]-s1[0]);
    s2[0] = i*l; s2[1] = l*((k-i)/2); s2[2] = l*((k-i+1)/2);
    sort(s2, s2+3);
    ans = min(ans, s2[2]-s2[0]);
  }
  
  cout << ans << "\n";
  return 0;
}   

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);

        HashSet<Integer> set = new HashSet<>();
        set.add(scanner.nextInt());
        set.add(scanner.nextInt());
        set.add(scanner.nextInt());

        System.out.println(set.size() == 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 22228
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    System.out.println(s.substring(0,3) + "8" + s.substring(4,10));
  }
}

Measured memory_bytes: 36808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            var s = Line;
            var array = Enumerable.Repeat(0, 26).ToArray();
            foreach (var item in s)
            {
                array[item - 'A']++;
            }

            if (array.Count(x => x == 2) == 2)
            {
                System.Console.WriteLine("Yes");
            }
            else
            {
                System.Console.WriteLine("No");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  ll N;cin>>N;
  ll ans=0;
  map<ll,ll> m;
  rep(i,N){
    ll a;cin>>a;
    m[a]++;
  }
  for(auto& x:m){
    if(x.second>=x.first) ans+=x.second-x.first;
    else ans += x.second;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6272
a,b,c,d=map(int,input().split())

if  b<=d and c<=a:
            print(b-a)
elif a<=c and c<b<=d:
            print(b-c)
elif b<=c:
            print(0)
elif c<=a<d and d<=b:
            print(d-a)
elif d<=a:
            print(0)
elif d<=b and a<=c:
            print(d-c)
else:
            print(b-a)
            


Measured memory_bytes: 3060
@1=map$-=$_-2,@0=1..<>+2;--$0[-1];map{$p=$_;$\+=$p*($$_[$$_[$i=$_[$p]]]-($$_[$P=${1-$_}[$i]]=$$_[$i]))*($i-$P)for 0,1}map$_[$_]=++$i,glob<>;print

Measured memory_bytes: 43940
import math

def distance(a, b):
  square_dist = 0
  for i in range(len(a)):
    square_dist += (a[i] - b[i]) * (a[i] - b[i])
  return math.sqrt(square_dist)

n, d = map(int, input().split(" "))
points = []

for i in range(n):
  x = [int(i) for i in input().split(" ")]
  points.append(x)

count = 0
for i in range(len(points)):
  for j in range(i+1, len(points), 1):
    dist = distance(points[i], points[j])
    if dist.is_integer():
      count += 1
print(count)

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

int main(){
  int n;cin>>n;
  int dp[3]={};
  cin>>dp[0]>>dp[1]>>dp[2];
  int a,b,c,x,y,z;
  fol(i,n-1){
    cin>>a>>b>>c;
    a += max(dp[1],dp[2]),
    b +=max(dp[0],dp[2]),
    c +=max(dp[0],dp[1]),
    dp[0] = a, dp[1] = b, dp[2] = c;
  }
  printf("%d\n",max({dp[0],dp[1],dp[2]}));
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,W,w[100];
    long dp[100001]={},v[100];
    scanf("%d %d",&n,&W);
    for(int i=0;i<n;i++){
        scanf("%d %ld",&w[i],&v[i]);
        for(int j=W-w[i];j>=0;j--){
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    printf("%ld\n",dp[W]);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int main(){
    int N; cin>>N;
 //   vec_int u(N),v(N),w(N);

    vector<vector<P>> G(N+1);
    rep(i,N){
        int u,v,w;
        cin>>u>>v>>w;
        G.at(u).push_back(make_pair(v,w));
        G.at(v).push_back(make_pair(u,w));
    }


    //木だから全部つながっていると思ってよい
    //0から幅優先探索で次のノードとの距離がぐうすうだったら同じ色、奇数だったら違う色を塗る

    vec_int visited(N+1,0);
    vec_int color(N+1);
    //幅優先探索だからqueを使う
    queue<T> q;
    //T: next_node, distance, current_color
    q.push(make_tuple(1,0,0));
    while(!(q.empty())){
        T pos = q.front();q.pop();
        int node, distance,prev_color;
        tie(node,distance,prev_color) = pos;
        if(visited.at(node)==1)continue;
        visited.at(node)=1;
        //色を付ける
        color.at(node) = distance%2==0 ? prev_color : (prev_color==1? 0 : 1);

        for(int i=0;i<G.at(node).size();i++){
            P temp = G.at(node).at(i);
            int next_pos, next_distance;
            tie(next_pos,next_distance) = temp;
            if(visited.at(next_pos)==1)continue;
            q.push(make_tuple(next_pos,next_distance,color.at(node)));
        }
    }

    for(int i=1;i<N+1;i++){
        cout<<color.at(i)<<endl;
    }









    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin>>s;
	ll r=1000;
	ll p[20]={0};
	rep(i,0,s.length()) p[i]=(ll)s[i]-48;
	rep(i,0,s.length()-2){
		r=min(r,abs(753-100*p[i]-10*p[i+1]-p[i+2]));
	}
	cout<<r;
}

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

int main() {
  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int type[4];
	char fal[2];
	
	for (i = 0; i < 4; i++){
		type[i] = 0;
	}
	
	while (scanf("%d,%c%c", &i, &fal[0], &fal[1]) != EOF){
		if (fal[0] == 'A' && fal[1] == 'B'){
			type[2]++;
			fal[1] = 0;
		}
		else if (fal[0] == 'A'){
			type[0]++;
		}
		else if (fal[0] == 'B'){
			type[1]++;
		}
		if (fal[0] == 'O'){
			type[3]++;
		}
	}
	for (i = 0; i < 4; i++){
		printf("%d\n", type[i]);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll x, a, b;

int main()
{
  std::cin >> x >> a >> b;

  ll da = llabs(x-a), db = llabs(x-b);

  puts( da < db ? "A" : "B" );

  return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}


signed main(){
    CIN(a,b,c);
    printf("%d %d %d\n",c,a,b);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<vector<int>> A(2, vector<int>(101, 0));

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d", &A[0][i]);
    for(int i = 0; i < N; ++i) scanf("%d", &A[1][i]);
    
    vector<int> top, down;
    int sum = 0;
    for(int i = 0; i < N; ++i) sum += A[0][i], top.push_back(sum);
    sum = 0;
    for(int i = 0; i < N; ++i) sum += A[1][i], down.push_back(sum);
    
    int ans = 0;
    for(int i = 0; i < N; ++i){
        int temp = (i) ? down.back() - down[i - 1] : down.back();
        ans = max(ans, top[i] + temp);
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256