akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
const int N = 2e5+5;
int n,x[N],ans;
ll m;bool vis[N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>x[i],x[i]--;
	int now=0,cnt=0;
	if(m<=n)
	{
		while(m--)
		{
			ans=x[ans];
		}
		cout<<ans+1<<"\n";
		return 0;
	}
	while(!vis[now])
	{
		vis[now]=true;
		now=x[now];
		cnt++;
	}
	int rem=now;
	m-=cnt;cnt=1;
	now=x[now];
	while(rem!=now)
	{
		now=x[now];
		cnt++;
	}
	m%=cnt;
	ans=rem;
		while(m--)
		{
			ans=x[ans];
		}
		cout<<ans+1<<"\n";

	return 0;
}

Measured memory_bytes: 4600
#include<iostream>
int main()
{
	while (true)
	{
		int hit = 0, blow = 0;
		int num[2][4];
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				std::cin >> num[i][j];
			}
		}
		if (std::cin.eof())
		{
			break;
		}
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				if (num[0][i] == num[1][j])
				{
					if (i == j)
					{
						hit++;
					}
					else
					{
						blow++;
					}
				}
			}
		}
		std::cout << hit << ' ' << blow << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  double T,X;
  cin >>T>>X;
  cout<< T/X<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  scanf("%d",&N);
  long long L[87];
  L[0]=2LL;L[1]=1LL;
  for(int i=2;i<=N;i++) L[i]=L[i-2]+L[i-1];
  printf("%lld\n",L[N]);
}

Measured memory_bytes: 3756
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

int main()
{
    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        xyh.append((x, y, h))

    for cx in range(101):
        for cy in range(101):
            i = 0
            while True:
                x, y, h = xyh[i]
                if h == 0:
                    i += 1
                    continue
                else:
                    H = h + abs(x - cx) + abs(y - cy)
                    break

            for x, y, h in xyh:
                tmp = max(H - abs(x - cx) - abs(y - cy), 0)
                if tmp == h:
                    continue
                else:
                    break
            else:
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,d;
    cin>>d>>n;
    int ans = n;
    if(n==100) ans=101;
    
    for(int i = 0; i < d; i++)
    {
        ans*=100;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
c=[None]*3
c=[list(map(int,input().split())) for i in range(3)]

flag=True
order=[(0,1), (1,2), (2,0)]
for i in order:
    for j in order:
        if c[i[0]][j[0]]-c[i[1]][j[0]]!=c[i[0]][j[1]]-c[i[1]][j[1]]:
            flag=False
        if c[j[0]][i[0]]-c[j[0]][i[1]]!=c[j[1]][i[0]]-c[j[1]][i[1]]:
            flag=False
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**9)

def readInt():
    return list(map(int, input().split()))

n, m = readInt()

root = [-1] * n

def r(x):
    # print("root[x]=",root[x])
    if root[x] < 0:
        # print("r(x)=",x)
        return x
    else:
        root[x] = r(root[x])
        # print(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x
    # print(root)

def size(x):
    x = r(x)
    # print(x, root[x])
    return -root[x]

for i in range(m):
    x, y = readInt()
    x -= 1
    y -= 1
    unite(x, y)

max_size = 0

for i in range(n):
    max_size = max(max_size, size(i))

print(max_size)

Measured memory_bytes: 96744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_Beginner_Contest_167
{
    class B
    {
        static void Main(string[] args)
        {
			var abck = ReadIntArray(4);
			var a = abck[0];
			var b = abck[1];
			var c = abck[2];
			var k = abck[3];

			var aCount = Math.Min(a, k);
			var max = aCount;
			k -= aCount;
			var bCount = Math.Min(b, k);
			k -= bCount;
			Console.WriteLine(max - k);

#if HELLO
			Console.ReadKey();
#endif
		}

		private static List<int> ReadIntListFrom_StringSplit(string s)
		{
			return
				s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
				.Select(int.Parse)
				.ToList();
		}

		///////////////

		private static int[] ReadIntArray() => ReadIntArrayFrom_StringSplit(Console.ReadLine());

		private static int[] ReadIntArray(int size) => ReadIntArrayFrom_FixedSize(Console.ReadLine(), size);

		private static int[] ReadIntArrayFrom_StringSplit(string s) =>
				s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
				.Select(int.Parse)
				.ToArray();


		private static int[] ReadIntArrayFrom_FixedSize(string s, int size)
		{
			var sLen = s.Length;
			var res = new int[size];
			var resIdx = 0;
			var start = 0;
			string ss;

			for (int i = 1; i <= sLen; i++)
			{
				if ((i == sLen || s[i] == ' '))
				{
					ss = s.Substring(start, i - start);
					{
						res[resIdx++] = int.Parse(ss);
						start = i + 1;
					}
				}
			}
			return res;
		}

		//////////////////

		private static int ReadInt(string s) => int.Parse(s);

		private static int ReadInt() => int.Parse(Console.ReadLine());

		/////////

		static int Mod(int A, int n)
		{
			var a = A / n;
			if (A < 0)
			{
				return A - a * n + n;
			}
			else
			{
				return A - a * n;
			}
		}
	}
}


Measured memory_bytes: 27480
N = gets.to_i
as = gets.split.map(&:to_i)
#N = 100
#as = (0...100).to_a

ans = 10**10
(-100..100).each do |t|
    sum = 0
    as.each do |a|
        sum += (a - t) ** 2
    end
    ans = sum if ans > sum
end
puts ans

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int n;cn(n)
  co((n+1)/2)
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int x; cin >> x;
	vector<int> kyu = {400, 600, 800, 1000, 1200, 1400, 1600, 1800};

	int j = prev(upper_bound(kyu.begin(), kyu.end(), x)) - kyu.begin();

	cout << 8 - j;

	return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		int a;
		int b;
		int c;
		int d=0;
		Scanner scan =new Scanner(System.in);
		
	 a=scan.nextInt();
	 b=scan.nextInt();
	 c=scan.nextInt();
		for(int i=a;i<=b;i++){
			if(c%i==0)
				d++;
			
			
		}
		System.out.println(d);
	}

}


Measured memory_bytes: 26180
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int R;
	cin>>R;

	cout<<R*2* 3.141592653589793<<endl;
}

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

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> 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(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans = 0;
	rep(i,n){
		ll d = b[i];
		auto it1 = lower_bound(a.begin(),a.end(),d) - a.begin();
		auto it2 = upper_bound(c.begin(),c.end(),d) - c.begin();
		ans += it1 * (n-it2);
 	}
 	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2688
import math



def main():
    N, D = list(map(int, input().split(" ")))
    right_cover = 0
    left_cover = N+1
    count = 0
    while(True):
        # push right
        right_cover = right_cover + 2*D + 1
        count = count + 1

        if right_cover >= N or right_cover >= left_cover - 1:
            break

        #push left
        left_cover = left_cover - (2*D + 1)
        count = count + 1

        if left_cover <= right_cover + 1:
            break
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    long double a,b;
    cin>>a>>b;
    long double ans=a*b;
    cout<<ll(ans)<<endl;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>

using namespace std;

int main()
{
  long long n; cin >> n;
  
  int ans = 1;
  if (n != 2) ++ans;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 1) ans += (i * i == n-1 ? 1 : 2);
    if (n % i == 0) {
      long long tmp = n;
      while (tmp % i == 0) tmp /= i;
      if (tmp % i == 1) ++ans;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int cnt=0;
    string res="";
    int s_size=s.size();
    int t_size=t.size();
    for(int i=s_size-t_size;i>=0;i--){
        for(int k=0;k<i;k++){
            if(s[k]=='?'){
                res+="a";//文字列の配列に追加
            }else{
                res+=s[k];
            }
        }
        for(int j=0;j<t_size;j++){
            if(s[j+i]=='?')
                res+=t[j];
            else if(s[j+i]==t[j])
                res+=t[j];       
            else{
                res="";
                goto B;//Bのとこへ行く
            }    
        }
        for(int k=i+t_size;k<s_size;k++){
            if(s[k]=='?')res+="a";//?だったらa
            else res+=s[k];//?でなければs[]
        }
        cout<<res<<"\n";
        return 0;
        B:;
    }
    cout<<"UNRESTORABLE"<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        // 入力(a b)
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a + b) % 24);
        sc.close();
    }
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int main(){
    int n,m;
    cin>>n>>m;
    if(n%2!=0){
        int l=1;
        int r=n;
        fori(m){
            cout<<l<<" "<<r<<endl;
            l++;
            r--;
        }
    }
    else{

        int odd = (m + 1) / 2;
        for (int i = 1; i <= odd; i++)
            cout << i << ' ' << n - i + 1 << '\n';
        for (int i = odd + 1; i <= m; i++)
            cout << i << ' ' << n - i << '\n';
    }

}


Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	  long long x;
	  cin>>x;
	  int a,b;
	  a=x/500;
	  b=(x-500*a  )/5;
	  cout<<a*1000+5*b<<endl;
	  return 0;                               
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int n;
map< pair<int, string>, s64 > dp;

bool ok(string& s)
{
    bool ret = true;
    if (s[0] == 'A' && s[2] == 'G' && s[3] == 'C') ret = false;
    else if (s[0] == 'A' && s[1] == 'G' && s[3] == 'C') ret = false;
    return ret;
}

s64 dfs(int l, string s)
{
    s64 ret = 0;

    if (s == "AGC" || s == "ACG" || s == "GAC") return 0;
    if (dp[make_pair(l, s)] > 0) return dp[make_pair(l, s)];
    if (l == n)
    {
        return 1;
    }

    static string cand = "ACGT";
    rep (i, cand.size())
    {
        string t = s + cand[i];
        if (ok(t))
        {
            ret += dfs(l + 1, t.substr(1, 3));
            ret %= MOD;
        }
    }
    dp[make_pair(l, s)] = ret;

    return ret;
}

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

    cin >> n;

    cout << dfs(0, "TTT") << "\n";
    return 0;
}



Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int a, b, c, tmp;

	scanf("%d%d%d", &a, &b, &c);

	if (a > b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c)
	{
		tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}


Measured memory_bytes: 2064
import java.util.*; 
import java.io.*; 

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(); 
        int k = scan.nextInt(); 
        if(n > 10) System.out.println(k); 
        else System.out.println(k + 100*(10-n));
        }
}

Measured memory_bytes: 21716
import sys


def main():
    n = int(sys.stdin.readline().strip())
    poll = dict()
    max_num = 1
    for _ in range(n):
        p = sys.stdin.readline().strip()
        if p in poll:
            poll[p] += 1
            if max_num < poll[p]:
                max_num = poll[p]
        else:
            poll[p] = 1
    array = []
    for v in poll:
        if poll[v] == max_num:
            array.append(v)
    array.sort()
    for s in array:
        print(s)


if __name__ == '__main__':
    main()


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

int main() {
    int n; cin >> n;
    int res = 0;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i];
    }
    c[n-1] = 0;
    for (int i = 0; i < n; i++) {
        res += b[a[i]];
        if (i < n - 1 && a[i] + 1 == a[i+1]) {
            res += c[a[i]];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N;
	int amin = 1000, amax = -1000;
	scanf("%d", &N);
	double *A = (double *)malloc(sizeof(double)*N);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &A[i]);
		if (amin > A[i]) {
			amin = A[i];
		}
		if (amax < A[i]) {
			amax = A[i];
		}

	}

	double tmp;
	double *f = (double *)malloc(sizeof(double)*(amax - amin + 1));
	double fmin = 5000000;

	for (int j = amin; j <= amax; j++) {
		tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp += pow(j - A[i], 2.0);
		}
		f[j - amin] = tmp;
		//printf("f[%d] : %f\n", j-amin, f[j]);

		if (f[j - amin] < fmin) {
			fmin = f[j - amin];
		}
	}




	printf("%.0f\n", fmin);

#ifdef DEBUGF
		getch();
#endif
	return 0;
}

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

int a[26];
int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++) a[s[i]-'a']++;
    int b=0;
    for(int i=0;i<26;i++){
        if(a[i]>0) b++;
    }
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    long long res=100000;
    for(int i=0;i<26;i++){
        if(a[i]>0){
            long long count=0;
            string str=s;
            while(1){
                count++;
                for(int j=0;j<s.size()-1;j++){
                    if(str[j]!='a'+i&&str[j+1]=='a'+i) str[j]='a'+i;
                }
                str[s.size()-count]='A';
                bool flag=true;
                for(int j=0;j<s.size();j++){
                    if(str[j]=='a'+i||str[j]=='A') continue;
                    else flag=false;
                }
                if(flag) break;
            }
            res=min(res,count);
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 1e3;

int gcd(int a, int b) {
    return !b ? a : gcd(b, a % b);
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        vector<int> a(3);
        for (int j = i + 1; j < n; j++) {
            if (s[j] == 'R') a[0]++;
            else if (s[j] == 'G') a[1]++;
            else a[2]++;
        }
        for (int j = i + 1; j < n; j++) {
            if (s[j] == 'R') a[0]--;
            else if (s[j] == 'G') a[1]--;
            else a[2]--;
            if (s[i] == s[j]) continue;
            int d = j - i;
            int id;
            if (s[i] != 'R' && s[j] != 'R') id = 0;
            else if (s[i] != 'G' && s[j] != 'G') id = 1;
            else id = 2;
            ans += a[id];
            if (j + d < n && s[j + d] != s[j] && s[j + d] != s[i]) ans--;
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

Measured memory_bytes: 3624
def count_div(n):
  res = 0
  for i in range(1, n + 1):
    if n % i == 0:
      res += 1
  return res
n = int(input())
ans = 0
for i in range(1, n + 1, 2):
  if count_div(i) == 8:
    ans += 1
print(ans)


Measured memory_bytes: 2940
import java.util.*;
import java.math.*;
import java.text.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int p = in.nextInt();
			int q = in.nextInt();
			int a = in.nextInt();
			int n = in.nextInt();
			if((p|q|a|n)==0) break;
			System.out.println(search(1,(double)p/(double)q,a,n));
		}
	}
	
	public static int search(int d1, double d2, int d3, int d4){
		int count=0;
		for(int x=d1; x<=d3 ; x++){
			if(d4>0 && Math.abs(d2-1/(double)x)<0.00000001){
				count++;
			}
			else if(d2 < 1/(double)x);
			else if(d4>0 && d3 >= x*x) count = count + search(x,d2-1/(double)x,d3/x,d4-1);
			else;
		}
		return count;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int lim = 1500;
const int offset = 600;
const int MAX_LIM = 1000100;

int cave[lim][lim];
int dp[lim][lim];
bool prime[MAX_LIM];
map<int, P> mp;

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


void make_cave(){
    int d = 0;
    //原点をずらす
    int y = offset;
    int x = offset;

    //辻褄合わせのため仕方なく入れた
//    mp[1] = {y, x};

    //範囲を指定
    int L = 0;

    int num = 1;
    while(num <= MAX_LIM){
        int Min = offset - L;
        int Max = offset + L;

        cave[y][x] = num;
        mp[num] = {y, x};

        int ny = y + dy[d];
        int nx = x + dx[d];
        
        if(nx > Max){
            d = (d + 1) % 4;
            L++;
        }
        else if(ny < Min || ny > Max){
            d = (d + 1) % 4;
            ny = y + dy[d];
            nx = x + dx[d];
        }
        else if(nx < Min){
            d = (d + 1) % 4;
            ny = y + dy[d];
            nx = x + dx[d];
        }

        y = ny;
        x = nx;

        num++;
        //足してから入れるとかいうのでバグらせた
        //mp[num] = {y, x};
    }
    return;
}


void make_prime(){
    fill(prime,prime+MAX_LIM,true);
    prime[0] = prime[1] = false;
    for(int i = 2 ; i*i <= MAX_LIM; i++){
        if(prime[i]){
            for(int j = i*2 ; j <= MAX_LIM; j+=i){
                prime[j] = false;
            }
        }
    }
    return;
}


void solve(int y, int x, int m){
    dp[y][x] = prime[cave[y][x]];
    
    for(int h=0; h<lim-1; h++){
        for(int w=1; w<lim-1; w++){
            if(dp[h][w] >= 0 && cave[h][w] <= m){
                if(cave[h+1][w-1] <= m) dp[h+1][w-1] = max(dp[h+1][w-1], dp[h][w] + prime[cave[h+1][w-1]]);
                if(cave[h+1][w] <= m) dp[h+1][w] = max(dp[h+1][w], dp[h][w] + prime[cave[h+1][w]]);
                if(cave[h+1][w+1] <= m) dp[h+1][w+1] = max(dp[h+1][w+1], dp[h][w] + prime[cave[h+1][w+1]]);
            }
        }
    }
    
    int res = 0;
    int num = 0;
    for(int i=0; i<lim; i++){
        for(int j=0; j<lim; j++){
            res = max(res, dp[i][j]);
            
        }
    }

    //これをやらなかったのがバグの原因だった
    for(int i=0; i<lim; i++){
        for(int j=0; j<lim; j++){
            if(prime[cave[i][j]] && res == dp[i][j]){
                num = max(num, cave[i][j]);
            }
        }
    }

    cout << res << " " << num << endl;
    
    return;
}


int main(){
    
    make_prime();
    make_cave();
    
    int m, s;
    while(true){
        cin >> m >> s;
        if(m == 0 && s == 0) return 0;
        memset(dp, -1, sizeof(dp));
        auto point = mp[s];
        solve(point.first, point.second, m);
    }
    return 0;
    
}


Measured memory_bytes: 81232
n, m = gets.split(" ").map(&:to_i)
s_2 = n * 2

if m < 2
  cnt = 0
elsif n >= m
  cnt = m / 2
else
  cnt = n
end

m -= s_2

if m < 0
  cnt += 0
else
  cnt += m / 4
end

p cnt

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
  
  
namespace io{
    const int L = (1 << 20) + 1;
     
    char buf[L], *S , *T, c;
      
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
     
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
         
        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
         
        if(x)
            *--outs = x;
         
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};
  
using io :: print;
using io :: inp;
using io :: inp_ll;
int a[4]; 
int main()
{
	for(int i=1;i<=3;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+4);
	printf("%d\n",a[3]*10 + a[1] + a[2]);
    return 0;
}

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



int main() {
    string s; cin >> s;

    int ans = 0;
    if(s[0] == '1') ans++;
    if(s[1] == '1') ans++;
    if(s[2] == '1') ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
 
int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[N];
  int largest = INT_MIN;
  int second = INT_MIN;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(i==0){
      largest = A[i];
    }else if(largest <= A[i]){
      second = largest;
      largest = A[i];
    }else if(second <= A[i]){
      second = A[i];
    }
  }
 
  for(int i = 0; i < N; i++){
    int ans;
    if(A[i] == largest){
      ans = second;
    }else{
      ans = largest;
    }
    cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int K,N;
	int t[100001];
	ll d[100001];
	vll pt[100001];
	vll dttop,dtless;
	scan(N);scan(K);
	rep(i,N){
		scan(t[i]);scan(d[i]);
		pt[t[i]].push_back(d[i]);
	}
	rep1(i,N) if(pt[i].size()) sort(pt[i].rbegin(),pt[i].rend());
	rep1(i,N){
		if(pt[i].size()){
			dttop.push_back(pt[i][0]);
			rep1(j,pt[i].size()-1){
				dtless.push_back(pt[i][j]);
			}
		}
	}
	sort(dttop.rbegin(),dttop.rend());
	sort(dtless.rbegin(),dtless.rend());
	ll dtlesssum[100001]={},dttopsum[100001]={};
	rep(i,K){
		if(i<dtless.size())	dtlesssum[i+1]=dtlesssum[i]+dtless[i];
		if(i<dttop.size()) dttopsum[i+1]=dttopsum[i]+dttop[i];
	}
	ll ans=0;
	for(ll i=1;i<=dttop.size();i++){
		if(0<=K-i&&K-i<=dtless.size()) ans=max(ans,dttopsum[i]+dtlesssum[K-i]+i*i);
	}
	prin(ans);
	return 0;
}


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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define INF 1e9

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 2e3+2;
const int M = 1e9+7;

int n, x, y, res[MAX];
vector<int> G[MAX];

queue<int> Q;
void BFS(int s)
{
    int dist[n+1];
    fill(dist, dist+n+1, INF);
    Q.push(s);
    dist[s] = 0;
    while(!Q.empty())
    {

        int v = Q.front();
        Q.pop();
         //cout<<v<<"\n";
        for(auto i : G[v])
            if(dist[i] > dist[v]+1)
            {
                //cout<<i<<" "<<v<<"\n";
                Q.push(i);
                dist[i] = dist[v]+1;
                res[dist[i]]++;
            }
    }
}
int main()
{
    _upgrade;
    cin>>n>>x>>y;
    FOR(i, 1, n)
    {
        G[i].pb(i+1);
        G[i+1].pb(i);
    }
    if(abs(x-y) != 1)
    {
        G[x].pb(y);
        G[y].pb(x);
    }
    FOR(i, 1, n+1)
        BFS(i);
    FOR(i, 1, n)
        cout<<res[i]/2<<"\n";
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3


def main():
    k, n = map(int, input().split())
    l = list(map(int,input().split()))

    l.insert(0, 0)
    l.append(k)
    dist_list = []
    for i in range(n+1):
        dist = l[i+1]-l[i]
        dist_list.append(dist)
    
    dist_list[0] = dist_list[0]+dist_list[-1]
    del dist_list[-1]
    print(sum(dist_list)-max(dist_list))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 26420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define _USE_MATH_DEFINES
#include <cmath>

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

using namespace std;
typedef long long ll;

int main() {
   int  n, cnt[26], num[100];
   char S[100];
   int  mans = 0;

   cin >> n;
   scanf("%s", S);


   rep(i, n) {
      num[i] = S[i] - 97;
   }
   rep(i, n) {
      int ans = 0;

      rep(i, 26) cnt[i] = 0;
      for (int j = 0; j <= i; j++) {
         if (cnt[num[j]] == 0) cnt[num[j]]++;
      }
      for (int k = i + 1; k < n; k++) {
         if (cnt[num[k]] == 1) {
            ans++;
            cnt[num[k]]++;
         }
      }
      mans = max(mans, ans);
   }
   cout << mans << endl;
   return(0);
}


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


def solve(N: int, K: int, h: "List[int]"):
    return len([hi for hi in h if hi >= K])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, h))


if __name__ == '__main__':
    main()


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


long long gcd(long long a, long long b){
    if (b == 0){
        return a;
    }
    return gcd(b, a%b);
}

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

int main(){

    int n;
    cin >> n;
    long long ans = 1LL, t = 1LL;
    for (int i = 0; i < n; i++){
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) cout << a[i].second + 1 << " \n"[i == n - 1];
	return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	double n, a;
	cin >> n >> a;
	double ans = 0;
	for(double i=1.0;i<n+1.0;i+=1.0){
		if (i >= a) {
			ans += 1.00 / n;
		}
		else {
			double cnt = 1.00 / n;
			double f = a;
			double m = i;
			while (f > m) {
				m *= 2;
				cnt *= 0.5;
			}
			ans += cnt;
		}
	}
	cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

N = input_one_number()
lst_a = input_multiple_number_as_list()

lst_a.sort(reverse=True)

alice = 0
bob = 0

if len(lst_a) %2 == 1:
    lst_a.append(0)

for i in range(len(lst_a)//2):
    alice += lst_a[i*2]
    bob += lst_a[i*2+1]

print(alice-bob)


Measured memory_bytes: 3192
n=int(input())
l=list(map(int,input().split()))
c=0
dp=[]
l.sort()
for i in range(n-2):
  k=i+2
  for j in range(i+1,n-1):
    while k<n and (l[i]+l[j])>l[k]:
      k+=1
    c+=k-j-1
print(c)

'''

1 2 3 4

1 < 2+3
2 < 1+3
3 < 1+2

6 - 1 = 5
6 - 2 = 4
6 - 3 = 3

'''

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const  double INF = 1e12;
const int MAX_N = 100000;
int n;
int x[MAX_N], y[MAX_N];
char c[MAX_N];

struct min_max {
  vector<double> l,r;
  min_max() : l(3,INF), r(3,-INF) {}
  void add(double v, int d) {
    d++;
    chmin(l[d],v);
    chmax(r[d],v);
  }

  double get(double t) {
    double a = min(l[0]-t,min(l[1],l[2]+t));
    double b = max(r[0]-t,max(r[1],r[2]+t));
    return b-a;
  }

  vector<double> epoch() {
    vector<double> res;

    if (l[0] > l[1]) res.push_back(l[0]-l[1]);
    if (l[1] > l[2]) res.push_back(l[1]-l[2]);
    if (l[0] > l[2]) res.push_back((l[0]-l[2])/2);

    if (r[0] > r[1]) res.push_back(r[0]-r[1]);
    if (r[1] > r[2]) res.push_back(r[1]-r[2]);
    if (r[0] > r[2]) res.push_back((r[0]-r[2])/2);

    return res;
  }
};

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  min_max u,r;
  cin >> n;
  forn(i,n) {
    cin >> x[i] >> y[i] >> c[i];
    if (c[i] == 'U') r.add(x[i],0), u.add(y[i],1);
    if (c[i] == 'D') r.add(x[i],0), u.add(y[i],-1);
    if (c[i] == 'R') r.add(x[i],1), u.add(y[i],0);
    if (c[i] == 'L') r.add(x[i],-1), u.add(y[i],0);
  }

  vector<double> epoch_x = r.epoch();
  vector<double> epoch_y = u.epoch();

  vector<double> epoch{0};
  epoch.insert(epoch.end(),epoch_x.begin(),epoch_x.end());
  epoch.insert(epoch.end(),epoch_y.begin(),epoch_y.end());

  double res = DBL_MAX;
  for (double t : epoch) {
    chmin(res, u.get(t) * r.get(t));
  }

  printf("%.10f\n", res);

  return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<iostream>

const int maxn=1e2+10;

int ans=0x7fffffff,n,a[maxn];

int main(){
    scanf("%d",&n);
    for(register int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(register int i=-100;i<=100;i++){
        int temp=0;
        for(register int j=1;j<=n;j++)
            temp+=((i-a[j])*(i-a[j]));
        ans=std::min(temp,ans);
    }
    std::cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
//#define int long long
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, s, a, b, ans;

  while(cin >> x >> y >> s, x | y | s) {
      ans = 0;
      for (int i = 1; i <= s; ++i) {
          for (int j = 1; j <= i; ++j) {
            a = i * (100.0 + x) / 100.0;
            b = j * (100.0 + x) / 100.0;
              if (a + b == s) {
                a = i * (100.0 + y) / 100.0;
                b = j * (100.0 + y) / 100.0;
                ans = max(ans, a+b);
              }
          }
      }
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#define ll long long
using namespace std;
  
int main()
{
  
	    
	    ll  i,j,k,l,d,r,n,m;
	    cin>>l>>r>>d;
	    ll count=0;
	   for(i=l;i<=r;i++)
	   {
	   	if(i%d==0)count++;
	   }
   
       cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3588
n,t = list(map(int,input().split()))

minc = -1
for i in range(n):
  ci,ti = list(map(int,input().split()))
  if ti <= t:
    if minc == -1:
      minc = ci
    else:
      minc = min(minc,ci)

if minc == -1:
  print("TLE")
else:
  print(minc)
    

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <algorithm> // sort
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <utility>

using namespace std;

typedef long long int lli;
typedef pair<lli,lli> p_ii;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl
int bug = 1;

int main(){
	IOS
	double w, h;
	double x, y;

	cin >> w >> h >> x >> y;

	double area;
	lli mult = 0;
	if(x == w/2.0 && y == h/2.0){
		mult = 1;
	}
	area = (w*h) / 2.0;

	cout << area << " " << mult << endl;
	
	return 0;
}


Measured memory_bytes: 256