akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static long mod = (long) (1e9+7);
	public static long[] fac,inv;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for(int i=0;i<n;++i) set.add(sc.nextInt());
		if(set.size() == n) out.print("YES");
		else out.print("NO");
	    out.close();

	}
	

}


Measured memory_bytes: 57280
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	bulbs := [][]int{}
	for i := 0; i < m; i++ {
		ss := scanFlexIntSlice()
		bulbs = append(bulbs, ss)
	}
	conditions := scanIntSlice(m)

	count := 0
	for s := 0; s < 1<<n; s++ {
		ok := true
		for b := 0; b < m; b++ {
			ok = ok && check(b, conditions[b], bulbs[b], s)
		}
		if ok {
			count++
		}
	}

	fmt.Printf("%d\n", count)
}

func check(bulb, condition int, switches []int, state int) bool {
	count := 0
	for _, s := range switches {
		if (state>>(s-1))%2 == 1 {
			count++
		}
	}
	return (count % 2) == condition
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}

func scanFlexIntSlice() []int {

	var size int
	fmt.Scanf("%d", &size)

	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}

	return input
}


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

int main() {
  int n;
  cin >> n;

  vector<ll> list_a;
  unordered_map<ll, int> candidates;

  rep(i, n) {
    int a;
    cin >> a;
    list_a.push_back(a + i + 1);
    candidates[i + 1 - a]++;
  }

  ll count = 0;

  rep(i, n) { count += candidates[list_a[i]]; }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 20052
#import random
#import time
from collections import defaultdict, Counter

def main():
    #N = 20
    #A = [random.randint(1, int(1e6)) for _ in range(int(N))]
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    #t1 = time.time()
    dup_cnt = Counter(A)
    dup = set(x for x in dup_cnt if dup_cnt[x] > 1)
    A_set = set(A)
    A = list(A_set)
    A.sort()
    N = len(A)
    max_A = A[-1]
    prime = [True]*(max_A+1)
    ans = 0
    for x in A:
        if not prime[x]:
            continue
        else:
            for y in range(2*x, max_A+1, x):
                prime[y] = False
            if not x in dup:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 144604
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, T = MAP()
A = LIST()

lis = []
tmp = A[0]
tmp_max = 0
for i in range(N):
	if A[i] < tmp:
		tmp = A[i]
		lis.append(tmp_max)
		tmp_max = 0
	else:
		tmp_max = max(tmp_max, A[i]-tmp)
lis.append(tmp_max)

print(lis.count(max(lis)))

Measured memory_bytes: 21768
#include <iostream>
#include <string>
#include <queue>
#include <map>
using namespace std;

string replace_all(const string &str,const string &from,const string &to){
	string r;
	for(int i=0;i<str.size();){
		if(str.substr(i,from.size())==from)r+=to,i+=from.size();
		else r+=str[i++];
	}
	return r;
}

int main(){
	int n;
	for(;cin>>n,n;){
		vector<pair<string,string> >v(n);
		for(int i=0;i<n;i++)cin>>v[i].first>>v[i].second;
		string start,goal;
		cin>>start>>goal;
		queue<string>q;
		q.push(start);
		map<string,int>m;
		m[start]=0;
		for(q.push(start);!q.empty();){
			for(int i=0;i<v.size();i++){
				string nxt=replace_all(q.front(),v[i].first,v[i].second);
				if(nxt.size()<=goal.size() && m.find(nxt)==m.end()){
					q.push(nxt);
					m[nxt]=m[q.front()]+1;
				}
				if(nxt==goal){
					cout<<m[nxt]<<endl;
					goto NEXT;
				}
			}
			q.pop();
		}
		cout<<-1<<endl;
		NEXT:;
	}
}

Measured memory_bytes: 1400
#include<iostream>
#include<map>
using namespace std;
void make_map();
map < char,string> t;
map <string,char> u;

int main(){
  make_map();
  int x;
  string str,A,B;
  while(getline(cin,str)){
    A="";
    for(int i=0;i<(int)str.size();i++){
      A+=t[str[i]];
    }
    x=0;B="";
    while(x<(int)A.size()){
      B.push_back(A[x]);
      if(u[B]!='\0'){
	cout<<u[B];
	B="";
      }
      x++;
    }
    cout<<endl;
  }
  return 0;
}

void make_map(){
  t['A']="00000";
  t['B']="00001";
  t['C']="00010";
  t['D']="00011";
  t['E']="00100";
  t['F']="00101";
  t['G']="00110";
  t['H']="00111";

  t['I']="01000";
  t['J']="01001";
  t['K']="01010";
  t['L']="01011";
  t['M']="01100";
  t['N']="01101";
  t['O']="01110";
  t['P']="01111";  

  t['Q']="10000";
  t['R']="10001";
  t['S']="10010";
  t['T']="10011";
  t['U']="10100";
  t['V']="10101";
  t['W']="10110";
  t['X']="10111";
  
  t['Y']="11000";
  t['Z']="11001";
  t[' ']="11010";
  t['.']="11011";
  t[',']="11100";
  t['-']="11101";
  t['\'']="11110";
  t['?']="11111";

  u["101"]=' ';
  u["000000"]='\'';
  u["000011"]=',';
  u["10010001"]='-';
  u["010001"]='.';
  u["000001"]='?';
  u["100101"]='A';
  u["10011010"]='B';
  u["0101"]='C';
  u["0001"]='D';
  u["110"]='E';
  u["01001"]='F';
  u["10011011"]='G';
  u["010000"]='H';
  u["0111"]='I';
  u["10011000"]='J';
  u["0110"]='K';
  u["00100"]='L';
  u["10011001"]='M';
  u["10011110"]='N';
  u["00101"]='O';
  u["111"]='P';
  u["10011111"]='Q';
  u["1000"]='R';
  u["00110"]='S';
  u["00111"]='T';
  u["10011100"]='U';
  u["10011101"]='V';
  u["000010"]='W';
  u["10010010"]='X';
  u["10010011"]='Y';
  u["10010000"]='Z';
  

}

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

int main(){
  
  vector<int>vec(3);
  for (int i = 0; i< 3;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(0)*vec.at(1)/2<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

void printArray(int A[], int N) {
    rep(i,N-1)
        printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
}

void selectSort(int A[], int N) {
    int count = 0;
    
    for(int i = 0; i < N-1; i++) {
        int min_j = i;
       // 線形探索で、最小値がある要素の添え字を、見つける
        for(int j = i+1; j < N; j++) {
            if( A[j] < A[min_j]) {
                min_j = j;
            }
        }
        if(min_j != i) {
            int work;
            work = A[i]; A[i] = A[min_j]; A[min_j] = work;
            count++;
        }
    }
    printArray(A,N);
    printf("%d\n", count);

}
int main() {
    int A[100];
    int N;

    scanf("%d", &N);
    rep(i,N)
        scanf("%d", &A[i]);
    
    selectSort(A,N);
    
    return 0;
}





Measured memory_bytes: 2732
#include<stdio.h>
int main(void){
  int R,G,B,N;
  int r,g,ans=0;
  scanf("%d %d %d %d",&R,&G,&B,&N);
  for(r=0;r<=N/R;r++){
    for(g=0;g<=(N-R*r)/G;g++){
      if((N-R*r-G*g)%B==0){
        ans+=1;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
bool prime (ll x )
{
    for (int i=2 ; i<sqrt(x); i++)
        if (x%i==0)
        return false ;
    return true ;
}
int main()
{
    ll n , ans ;
    cin>>n ;
    for (int i = n ; ; i++)
    {
        if (prime(i))
            return cout<<i, 0 ;
    }
}




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

using namespace  std;

int height[100000+5];
int dp[100000+5];

int main() {
    int N;
    memset(dp, 0x3f3f3f3f, sizeof(dp));
    scanf("%d",&N);
    for(int i = 0 ;i < N; ++i) {
        scanf("%d",&height[i]);
    }
    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);
    for(int i = 2; i < N; ++i ){
        dp[i] = min(dp[i], dp[i-1] + abs(height[i] - height[i-1]));
        dp[i] = min(dp[i], dp[i-2] + abs(height[i] - height[i-2]));
    }
    printf("%d\n", dp[N-1]);
    return 0;
}

Measured memory_bytes: 4576
n,m = map(int, input().split())
py = []
for i in range(m):
    p,y = map(int, input().split())
    py.append((p,y,i))
py.sort()
li = [[0]*2 for i in range(m)]
s = 0
t = 0
for p,y,i in py:
    #もしs!=pならその県は初めてなので1番目、違うならそこから+1
    if s != p:
        s = p
        t = 1
    else:
        t += 1
    li[i][0] = s
    li[i][1] = t
for i in range(m):
    print(str(li[i][0]).zfill(6) + str(li[i][1]).zfill(6))

Measured memory_bytes: 35208
#include<iostream>
using namespace std;
int main() {
    int n, i;
    int pm, pe, pj;
    while (1) {
        cin >> n;
        if (n == 0) break;
        for (i = 0; i < n; i++) {
            cin >> pm >> pe >> pj;
            if (pm == 100 || pe == 100 || pj == 100)
                cout << "A" << endl;
            else if ((pm + pe) / 2 >= 90)
                cout << "A" << endl;
            else if ((pm + pe + pj) / 3 >= 80)
                cout << "A" << endl;
            else if ((pm + pe + pj) / 3 >= 70)
                cout << "B" << endl;
            else if ((pm + pe + pj) / 3 >= 50 && pm >= 80 || pe >= 80)
                cout << "B" << endl;
            else
                cout << "C" << endl;
       }
   }
    return 0;
}


Measured memory_bytes: 3132
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int num=Integer.parseInt(buf.readLine());
        int[] h=new int[num];
        String[] str=buf.readLine().split(" ");
        
        for(int i=0;i<num;i++){
            h[i]=Integer.parseInt(str[i]);
        }
        
        int cnt=0;
        for(int i=0;i<h.length-1;i++){
            for(int j=h.length-1;j>i;j--){
                if(h[j-1]>h[j]){
                    int tmp=h[j];
                    h[j]=h[j-1];
                    h[j-1]=tmp;
                    cnt=cnt+1;
                }
            }
        }
        System.out.print(h[0]);
        for(int i=1;i<h.length;i++){
            System.out.print(" "+h[i]);
        }
        System.out.println();
        System.out.println(cnt);
    }
}

Measured memory_bytes: 24268
(defun calc (n text)
  (loop with r = 0
        with g = 0
        with b = 0
        for i below n
        do (case (schar text i)
             (#\R (incf r))
             (#\G (incf g))
             (#\B (incf b)))
        finally (return (* r g b))))

(defun minus (n text)
  (loop with x = 0
        for i below n
        do (loop for j from (1+ i) below n
                 if (< (- (* 2 j) i) 
                       n)
                 do (if (and (not (equal (schar text i)
                                         (schar text j)))
                             (not (equal (schar text j)
                                         (schar text (- (* 2 j) i))))
                             (not (equal (schar text i)
                                         (schar text (- (* 2 j) i)))))
                        (incf x)))
        finally (return x)))

(let ((n (read))
      (text (read-line)))
     (format t "~A" (- (calc n text)
                       (minus n text))))

Measured memory_bytes: 24432
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for v in a:
        if v % 2 == 1:
            cnt += 1
    if cnt % 2 == 1:
        print("NO")
    else:
        print("YES")

if __name__ == "__main__":
    main()

Measured memory_bytes: 14108
#include <iostream>
#include <deque>

#define pb push_back

using namespace std;

int main(void)
{
	int n,k,m;
	int i;

	while(1){
		cin>>n>>k>>m;
		if(n+k+m==0) break;

		deque<int> dq;
		for(i=0;i<n;i++) {
			dq.pb(i+1);
		}

		m=(m-1)%dq.size();
		while(dq.size()>1){
			dq.erase(dq.begin()+m);
			m=(m+k-1)%dq.size();
			/*for(deque<int>::iterator it=dq.begin();it!=dq.end();it++){
				cout<<(*it)<<" ";
			}
			cout<<endl;*/
		}
		cout<<dq.front()<<endl;
	}
	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()

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

int h,w,d;
char s[4]={'R','Y','G','B'};
char c[500][500];

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

	cin>>h>>w>>d;
	REP(i,h) {
		REP(j,w) {
			int y=i+j;
			int x=i-j+h+w;
			int color=y/d%2*2 + x/d%2;
			c[i][j]=s[color];
		}
	}

	REP(i,h) {
		REP(j,w) {
			cout<<c[i][j];
		}
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    
    if(k%2==0){
        if(a-b>1e18) cout << "Unfair";
        else cout << a-b << endl;
    }else{
        if(b-a>1e18) cout << "Unfair";
        else cout << b-a << endl;
    }
}


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

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  set<ll> st;
  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] < 3200) st.insert(a[i] / 400);
    else cnt++;
  }
  cout << max(1ll, (ll)st.size()) << " " << st.size() + cnt << endl;
}

Measured memory_bytes: 256
def bfs(k):
    p=k
    level={1:1}
    frontier=[1]
    while frontier:
        next=[]
        for u in frontier:
            if u==1:
                l=k-1
            else:
                l=k-2
            i=0
            for v in adj[u]:
                if v not in level:
                    level[v]=1
                    p=(p*(l-i))%(10**9+7)
                    i+=1
                    next.append(v)
        frontier=next
    return p
n,k=map(int,input().split())
adj={}
for i in range(n-1):
    a,b=map(int,input().split())
    if a not in adj:
        adj[a]=[b]
    else:
        adj[a].append(b)
    if b not in adj:
        adj[b]=[a]
    else:
        adj[b].append(a)
if n==1:
  print(k)
else:
  print(bfs(k))

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



int main(){

	int v;
	int modmin=10,time=0;

	for(int i=0;i<5;i++){
		cin>>v;
		time += v/10*10;
		if(v%10 !=0){
			time +=10;
			if(modmin>v%10)modmin=v%10;
		}
	}
	if(modmin!=10)time-=(10-modmin);
	cout<<time;
}


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if (a>b) swap(a,b);
    if (b>c) swap(b,c);
    if (a>b) swap(a,b);

    cout <<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[200200],y[200200];
string s,str;
char ch;
int main(){
  cin>>k>>n;
  ll ax[n];
  for(int i=0;i<n;i++){
    cin>>ax[i];
  }
  sort(ax,ax+n);
  for(int i=0;i<n-1;i++){
    a=ax[i+1]-ax[i];
    if(ans<a)ans=a;
  }
  if(ans<k-ax[n-1]+ax[0])ans=k-ax[n-1]+ax[0];
      
  cout<<k-ans;
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	vector<string>vec(N);
	for (int i = 0;i < N;i++)cin >> vec[i];
	sort(vec.begin(), vec.end());

	string ans = "";
	for (int i = 0;i < N;i++) {
		ans += vec[i];
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
from scipy.sparse import*;f=csgraph.dijkstra;n,m,l,*t=map(int,open(0).read().split());d=f(f(csr_matrix((t[2:m*3:3],(t[:m*3:3],t[1:m*3:3])),(n+1,n+1)),0)<=l);d[d>n]=0;print(*d[t[m*3+1::2],t[m*3+2::2]]-1,sep='\n')

Measured memory_bytes: 40780
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    cout << (n+1)/2;
    return 0;
}

Measured memory_bytes: 256
a=[]
ans = 0
for i in range(5):
  e = int(input())
  if e%10==0:
    ans+=e
  else:
    ans+=e+10-(e%10)
    a.append(e)

a.sort(key=lambda x:x%10)
if len(a)>0:
  ans-=(10-a[0]%10)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n, k;
    cin >> n >> k;
    vi h(n);
    vi d(n-1);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    rep(i, n-1) d[i] = h[i+1] - h[i];

    
    int tmp = 0;
    rep(i, k-1) tmp += d[i];
    int mini = tmp;

    for(int i=0;i<n-k;i++){
        tmp -= d[i];
        tmp += d[i+k-1];
        mini = min(mini, tmp);
    } 

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k,p,q;
    cin>>n>>m;
    string big[n+1],small[m+1];
    string tmp;
    for(i=1;i<=n;i++)
    cin>>big[i];
    for(i=1;i<=m;i++)
    cin>>small[i];
    int flag = 0;
    for(i=1;i<=n-m+1;i++)
    for(j=0;j<=n-m;j++)
    {
        tmp = big[i].substr(j,m);
        if(tmp==small[1])
        {
            for(p=2;p<=m;p++)
            {
                tmp = big[p+i-1].substr(j,m);
                
                if(small[p]!=tmp)
                break;
            }
            if(p==m+1)
            flag = 1;
        
            if(flag)
            break;
        }
    }
    if(flag)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
       
}

Measured memory_bytes: 256
findl = ->rxs{->q{rxs.bsearch{|x| x <= q}}}
findr = ->xs{->q{xs.bsearch{|x| x >= q}}}

a, b, q = gets.split.map(&:to_i)
ss = a.times.map{gets.to_i}
ts = b.times.map{gets.to_i}
fsl = findl[ss.reverse]
fsr = findr[ss]
ftl = findl[ts.reverse]
ftr = findr[ts]

q.times{
    x = gets.to_i
    sl = fsl[x]&.-(x)&.abs
    sr = fsr[x]&.-(x)&.abs
    tl = ftl[x]&.-(x)&.abs
    tr = ftr[x]&.-(x)&.abs
    p [sl && tl && [sl, tl].max, sl && tr && (sl + tr + [sl, tr].min), sr && tl && (sr + tl + [sr, tl].min), sr && tr && [sr, tr].max].compact.min
}

Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
using Graph = vector<bitset<10>>;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
 
//繰り返し二乗法
ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
  
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N),B(N),C(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,N){
    cin >> B[i];
  }
  rep(i,N){
    cin >> C[i];
  }
  sort(A.begin(),A.end());
  sort(C.begin(),C.end());

  ll ans = 0;
  rep(i,N){
    ll k = B[i];
    auto itr1 = lower_bound(A.begin(),A.end(),k);//Aの中でB[i]以上の最小の要素
    ll c1 = distance(A.begin(),itr1);//Aの中でB[i]未満の要素数

    auto itr2 = upper_bound(C.begin(),C.end(),k);//Cの中でB[i]より大きい最小の要素
    ll c2 = N - distance(C.begin(),itr2);//Cの中でB[i]より大きい要素数

    ans += c1*c2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

ll gcd(ll x, ll y) {
	while (y) {
		x %= y;
		swap(x, y);
	}
	return x;
}

int main(){
	ll A, B;
	cin >> A >> B;
	ll C = gcd(A, B);

	ll c = sqrt(C);
	vector<ll> W = { 1 };
	for (ll i = 2;i <= c;i++) {
		if (C%i == 0) {
			W.push_back(i);
		}
		while (C%i == 0) {
			C /= i;
		}
	}
	if (C != 1)W.push_back(C);
	cout << W.size() << endl;
}

Measured memory_bytes: 256
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif (m + f) >= 80:
        print("A")
    elif (m + f) >= 65:
        print("B")
    elif (m + f) >= 50:
        print("C")
    elif (m + f) >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



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

int main(){
    int N,T,*t,i,sum=0,dis;
    cin >> N >> T;
    t = new int[N];
    for(i=0;i<N;i++){
        cin >> t[i];
    }
    for(i=1;i<N;i++){
        dis = t[i] - t[i-1];
        if(dis<T){
            sum += dis;
        }else{
            sum += T;
        }
    }
    sum += T;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
//watch

#include<iostream>
using namespace std;
int main()
{
long sum;
int h,m,s;
cin >> sum ;
h=sum/3600;
m=(sum-h*3600)/60;
s=sum-h*3600-m*60;
cout<<h<<":"<<m<<":"<<s<<endl;

return 0;
}

Measured memory_bytes: 1168
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, k = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)
MOD = 10**9+7
INF = 10**10
dp = [INF]*n


def dfs(v, parent, x):
    dp[v] = x
    if parent == -1:
        next_x = k-1
    else:
        next_x = k-2
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v, next_x)
        next_x -= 1


dfs(0, -1, k)
ans = 1
for x in dp:
    ans = ans*x % MOD
print(ans)


Measured memory_bytes: 91440
import Control.Monad
import Data.Function
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as U

solve n m s lines exchanges = ans where
  ans =
    map (minimum . map snd)
    . tail
    . groupBy ((==) `on` fst)
    . ((1,0):)
    . map (\((v, _), (t, _)) -> (v, t))
    . M.toAscList
    $ dijkstra suc (1, min 2450 s)
  suc (u, s) = ex ++ [((v,s-a), b) | (v,a,b) <- adj M.! u, s>=a] where
    ex = [((u, s+c), d) | s+c <= 2450]
    (c,d) = U.fromListN n exchanges U.! (u-1)
  adj = foldr addL (M.fromList . zip [1..n] $ repeat []) lines
  addL (u,v,a,b) = M.adjust ((v,a,b):) u . M.adjust ((u,a,b):) v

main = do
  [n, m, s] <- readWords
  lines <- replicateM m $ (\[a,b,c,d]->(a,b,c,d)) <$> readWords
  exchanges <- replicateM n $ (\[a,b]->(a,b)) <$> readWords
  mapM_ print $ solve n m s lines exchanges

readWords = map read . words <$> getLine

dijkstra suc st = M.delete st res where
  res = go (M.singleton st (0, st), S.singleton (0, st))
  go (res, que)
    | S.null que = res
    | otherwise = go $ foldl' f (res, S.deleteMin que) (suc u)
    where
      (du, u) = S.findMin que
      f (res, que) (v, cost)
        | v `M.member` res && fst (res M.! v) <= alt = (res, que)
        | otherwise = (M.insert v (alt, u) res, S.insert (alt, v) que)
        where alt = du + cost

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

using ll = long long;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, m, a, b;
vector<int> g[100001];

/* 二部グラフ判定 */
/* グラフはvector<int> g[MAX_V]; */
/* isBipartiteGraph(0, 1) で呼ぶ*/
int color[100001];

bool isBipartiteGraph(int v, int c) {
	color[v] = c;

	int si = g[v].size();
	for (int i = 0; i < si; ++i) {
		int nxt = g[v][i];
		if (color[nxt] == c) return false;
		if (color[nxt] == 0 and !isBipartiteGraph(nxt, -c)) return false;
	}

	return true;
}
/***************/

int main() {
	init();

	cin >> n >> m;
	rep(i,m) {
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	// 奇数長の閉路がない = 二部グラフ
	if (isBipartiteGraph(0, 1)) {
		a = b = 0;
		rep(i,n) {
			if (color[i] == 1) a++;
			else b++;
		}
		cout << a * b - m << endl;
	}
	// あれば完全グラフになりうる
	else {
		cout << (n * (n - 1) / 2 - m) << endl;
	}

  return 0;
}

Measured memory_bytes: 6528
import math

A, B, H, M = map(int, input().split())

h = (H / 12) * 360 + (M / 60) * 30 
m = (M / 60) * 360

tmp = math.radians(h - m)

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(tmp))
print(ans)

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<char> vec(W);
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;  
  for(int i = 0; i < H; i++){
    cout <<"#";
    for(int k = 0; k < W; k++){
  	  cin >> vec.at(k);
      cout << vec.at(k);
    }
    cout << "#" <<endl;
  }
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    string s;
    lli k;
    cin2(s,k);
    lli len = s.length();
    char str[len];
    char sorted_str[len];
    REP(i,0,len) {
        str[i] = s[i];
        sorted_str[i] = s[i];
    }
    sort(sorted_str, sorted_str+len);
    char cur_char = '.';
    set<string> ans;
    REP(i,0,len) {
        if (cur_char == sorted_str[i])
            continue;

        cur_char = sorted_str[i];
        // cur_char の場所のvectorを作る
        // どれが一番いいかを見て、あればそれで終わり
        REP(j,0,len) {
            if (str[j] != cur_char)
                continue;

            // [j, j+k-1] を得る
            REPE(l,1,k) {
                if (j+l-2>=len)
                    continue;
                if (ans.find(s.substr(j, l)) == ans.end()) {
                    ans.insert(s.substr(j, l));
                    //cout1(s.substr(j, l));
                }
            }
        }
        //cout1(ans.size());
        if (ans.size() >= k)
            break;
    }
    auto it = ans.begin();
    REP(i,1,k) {
        it++;
    }
    cout << *it << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <set>
#include <cstdlib>
#define INT long long
using namespace std;

set<int> s;

int main()
{
    for(int i = 0, t ; i < 3 ; i++ )
        cin>>t, s.insert(t);
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,i,r,q,flag,p,m,n;
    scanf("%d %d",&a,&b);
    if(a>=b)
    {
        m=a;
        n=b;
    }
    else
    {
        m=b;
        n=a;
    }
    for(i=n;i<=m;i++)
    {
        r=a-i;
        q=b-i;
        if((r==q) || (r==-q) || (-r==q) || (-r==-q))
        {
            flag=0;
            p=i;
            break;
        }
        else flag=1;
    }
    if(flag==1) printf("IMPOSSIBLE");
    else printf("%d",p);
}


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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

ll gcd(ll a, ll b) {
    while (true) {
        if (a < b) swap(a, b);
        if (b == 0) {
            break;
        }
        a %= b;
    }
    return a;
}

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

int main(void) {
    int N;
    cin >> N;
    ll t, ans;
    cin >> ans;
    if (N == 1) {
        cout << ans << endl;
        return 0;
    }

    cin >> t;
    ans = lcm(ans, t);
    if (N == 2) {
        cout << ans << endl;
        return 0;
    }

    FOR (i, 2, N) {
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;

    return 0;
}

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

int gcb(int big,int small){
	int d;

	if(big < small)swap(big,small);
	d = big % small;

	// 再帰関数の終了条件
	if(d == 0)return small;

	return gcb(small,d);
}

int main(){
	int a,b;

	cin >> a;
	cin >> b;

	cout << gcb(a,b) <<endl;
	
	return 0;
}


Measured memory_bytes: 3100
package main

import "fmt"

func getCount(str string) int {
	flag := make(map[rune]bool)
	cnt := 0
	for _, c := range str {
		if _, ok := flag[c]; !ok {
			cnt++
			flag[c] = true
		}
	}
	return cnt
}

func main() {
	var n int
	fmt.Scan(&n)

	standards := make(map[int][]string, 0)
	standards[1] = append(standards[1], "a")
	for i := 2; i <= n; i++ {
		for _, standard := range standards[i-1] {
			cnt := getCount(standard)
			for j := 0; j <= cnt; j++ {
				c := 'a' + j
				standards[i] = append(standards[i], standard+string(c))
			}
		}
	}
	for _, v := range standards[n] {
		fmt.Println(v)
	}
}


Measured memory_bytes: 11904
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    char c = sc.next().charAt(0);
    sc.close();
    
    if (Character.isUpperCase(c)) {
    	System.out.println("A");
    } else {
    	System.out.println("a");
    }
    
  }
}


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

using namespace std;

vector < pair<int,int> > s, c;
int ans[100];

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	for (int i = 0; i < N; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		s.push_back(make_pair(x, y));
	}
	for (int i = 0; i < M; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		c.push_back(make_pair(x, y));
	}
	for (int i = 0; i < N; i++){
        int min = 1000000000;
        int pos = 0;
        for (int j = 0; j < M; j++){
            if(min > abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second)){
                min = abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second);
                pos = j + 1;
            }
        }
        ans[i] = pos;
    }
    for(int i = 0; i < N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
int num[100005];
int main()
{
    int n,x;
    while(~scanf("%d %d",&n,&x))
    {
        for (int i = 1; i <= n; i++)
        {
            scanf("%d",&num[i]);
        }
        ll ans = 0;
        for (int i = 1; i <= n; i++)
        {
            if(i == 1 && num[i] > x)
            {
                ans += (num[i] - x);
                num[i] = x;
                continue;
            }
            if(num[i] + num[i - 1] > x)
            {
                ans += (num[i] + num[i - 1] - x);
                num[i] -= (num[i] + num[i - 1] - x);
            }
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){

  long long int N; cin >> N;
  vector<int> keta;
  while(true){
    keta.push_back(N % 10);
    N /= 10;
    if(N == 0)break;
  }

  reverse(keta.begin(),keta.end());

  long long ans = keta[0];
  bool flag = true;
  for(int i = 1;i < keta.size();i++){
    if(keta[i] != 9)flag = false;
  }


  if(flag)cout << ans + 9 * (keta.size() - 1) << endl;
  else cout << (ans - 1) + 9 * (keta.size() - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define debug cout << "here!"
#define pii pair<int , int>
#define pdd pair<double , double>
#define F first
#define S second
const int maxn = 1e5 * 5 + 10 , inf = 1e9 , pi = 3.14159265;
int x[maxn] , y[maxn] , n;
void solve(){
    
}
void in(){
    cin >> n;
    for (int i = 0; i < n;i ++){
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n - 2; i ++){
        if (x[i] == y[i] && x[i + 1] == y[i + 1] && x[i + 2] == y[i + 2]){
            cout << "Yes"; return ;
        }
    }
    cout << "No";
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    in();
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{return *(int*)b - *(int*)a;}

int main(){

	int data[100];
	int i;

	for (i = 0; i < 10; i++) scanf("%d", &data[i]);
	qsort(data, 10, sizeof(int), compare_int);

	for (i = 0; i < 3; i++) printf("%d\n", data[i]);

	return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define mod		1000000007
#define inf     1000000000000000000
#define MX1		100005
#define MX2		10000004
#define pi		acos(-1)
#define pb      push_back
#define vlli    vector<lli>
#define plli    vector<pair<lli,lli> >
#define mp      make_pair
#define all(v)  v.begin(),v.end()
#define setbits(n) __builtin_popcount(n)
#define test    int t;cin>>t;
lli gcd(lli a, lli b){return b?gcd(b,a%b):a;}
lli power(lli a,lli b){lli ans=1;while(b){if(b&1){ans=(ans*a)%mod;}a=(a*a)%mod;b>>=1;}return ans;}
int main()
{
	opt;
	lli i,j,k,l;
	string s,s1;
	cin>>s;
	for(i=1;i<=s.length();i++)
	{
		if(i%2==1)
		s1+=s[i-1];
	}
	cout<<s1<<"\n";
	return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main (){
    int n;
    cin >> n;
	for(int i = 0; i <= n; i += 4){
        if((n - i) % 7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cctype>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

bool startswith(const std::string& s, const std::string& t) {
  // s: hoge, t: ho => true
  // s: hoge, t: hogera => false

  if (s[0] != t[0]) return false;
  if (s.length() < t.length()) return false;
  return s.compare(0, t.length(), t) == 0;
}

std::vector<std::string> pf(const std::vector<std::string>& vs) {
  std::vector<std::string> res;
  for (size_t i=vs.size(); i--;) {
    std::string s=vs[i];

    if (res.empty()) {
      res.push_back(s);
      continue;
    }

    if (!startswith(res.back(), s)) {
      res.push_back(s);
    }
  }
  return res;
}

int testcase_ends() {
  std::string s;
  std::getline(std::cin, s);
  if (!std::cin) return 1;

  std::string t;
  for (char ch: s)
    if (isalpha(ch)) t += toupper(ch);

  std::vector<std::string> odd, even;

  {
    /* odd */
    for (size_t i=1; i<t.length(); ++i) {
      std::string cur(1, t[i]);
      for (size_t j=1; i+j<t.length(); ++j) {
        if (!(i-j < t.length())) break;
        if (t[i+j] != t[i-j]) break;
        cur += t[i+j];
      }
      if (cur.length() > 1) {
        // fprintf(stderr, "odd: %s\n", cur.c_str());
        odd.emplace_back(cur);
      }
    }
    std::sort(odd.begin(), odd.end());
  }
  {
    /* even */
    for (size_t i=2; i<t.length(); ++i) {
      if (t[i-1] != t[i]) continue;
      std::string cur(1, t[i]);
      for (size_t j=1; i+j<t.length(); ++j) {
        if (!(i-j-1 < t.length())) break;
        if (t[i+j] != t[i-j-1]) break;
        cur += t[i+j];
      }
      if (cur.length() > 1) {
        // fprintf(stderr, "even: %s\n", cur.c_str());
        even.emplace_back(cur);
      }
    }
    std::sort(even.begin(), even.end());
  }

  std::vector<std::string> podd=pf(odd), peven=pf(even);
  std::string sep="";
  for (const auto& ss: podd) {
    std::string tt=ss;
    std::reverse(tt.begin(), tt.end());
    tt.pop_back();
    std::cout << sep << tt << ss;
    sep = " ";
  }
  for (const auto& ss: peven) {
    std::string tt=ss;
    std::reverse(tt.begin(), tt.end());
    std::cout << sep << tt << ss;
    sep = " ";
  }
  std::cout << "\n";
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  vector<int> p(n);
  for ( int i = 0; i < n; i++ ) {
      cin >> p.at(i);
  }
  
  int A = 0;
  for ( int i = 0; i < n - 2; i++ ) {
      if ( p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2) ){
          A++;
      }
      else if ( p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2) ){
          A++;
      }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=200000+50;
int   a[maxn],n,m;
int b[maxn],c[maxn],d[maxn];

int main()
{
	
	cin>>n>>m;
	
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		memset(c,0,sizeof(c));
		memset(d,0,sizeof(d));
		long i;
		for(i=0;i<m;i++)
		{
			cin>>a[i];
			cin>>b[i];
			if(a[i]==1)
				c[b[i]]++;
			if(b[i]==1)
				c[a[i]]++;
			if(a[i]==n)
				d[b[i]]++;
			if(b[i]==n)
				d[a[i]]++;
		}
		for(i=1;i<=n;i++)
		{
			if(c[i]!=0&&d[i]!=0)
			{
				cout<<"POSSIBLE"<<endl;
				break;
			}
			if(i==n)
				cout<<"IMPOSSIBLE"<<endl;
		}
	
	//cout<<n<<m<<endl;
	
		return 0;
}

Measured memory_bytes: 3328
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
		
		if($s[0] < $s[2] &&
		$s[2] < $s[1]){
			echo "Yes\n";
		}else if($s[1] < $s[2] &&
		$s[2] < $s[0]){
			echo "Yes\n";
        }else{
			echo "No\n";
		}
	}
}
?>


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    double n,m,d;
    cin>>n>>m>>d;
    if(d==0){
        cout<<fixed<<setprecision(10)<<(m-1)/n<<endl;
    }
    else{
        cout<<fixed<<setprecision(10)<<(m-1)*2*(n-d)/(n*n)<<endl;
    }
}

Measured memory_bytes: 256
x=[0]*4
y=[0]*4

x[0], y[0], x[1], y[1] = map(int, input().split())

xdist = x[1]-x[0]
ydist = y[1]-y[0]

x[2] = x[1]-ydist
y[2] = y[1]+xdist

x[3] = x[2]-xdist
y[3] = y[2]-ydist
    
print(x[2], y[2], x[3], y[3])

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){
	int a,b,h,m;
	double jiao=0;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	double ans=0;
	jiao+=30*h+m*30/60.0;
	jiao-=6*m;
	if(jiao<0) jiao=-jiao;
	//jiao%=360;
	if(jiao>=180) jiao=360-jiao;
	ans+=a*a+b*b-2*a*b*cos(jiao*3.14159265358979323846/180.0);
	//printf("%.20lf\n",ans);
	
	ans=sqrt(ans);
	printf("%.20lf",ans);
	return 0;
}





Measured memory_bytes: 4264
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//virtual participate
int main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> table(h,vector<char>(w));
    int black = 0;
    rep(i,h){
        rep(j,w){
            cin >> table[i][j];
            if(table[i][j] == '#')black++;
        }
    }
    ll res = 0;
    for(int h_bit = 0;h_bit < (1LL << h);h_bit++){
        for(int w_bit = 0;w_bit < (1LL << w);w_bit++){
            ll cnt = 0;
            rep(i,h){
                rep(j,w){
                    if(!(h_bit & (1 << i)) && !(w_bit & (1 << j)) && table[i][j] == '#')cnt++;
                }
            }
            if(cnt == k)res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N;
    cin>>N;
    cout<<180*(N-2)<<endl;
    return 0;
}

Measured memory_bytes: 256