akhauriyash/Code-Regression huggingface dataset:
// Digit Sums

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

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

    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }

    if (org % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    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);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = -1;
		for (int i = 1; i <= 1009; i++) {
			if (Math.floor(i * 0.08) == a && Math.floor(i * 0.1) == b) {
				ans = i;
				break;
			}
		}

		System.out.println((int) ans);

		sc.close();
	}
}

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

alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

n = int(input())
s = input()

s_shift_n = ''
for i in range(len(s)):
    s_shift_n += alphabet[(alphabet.index(s[i])+n)%26]

print(s_shift_n)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define N 100000
int head = 0, tail = 0;
typedef struct data
{
	char name[100];
	int  time;

}Data;
Data assigment[N];//数组个数特别多要全局定义，原因还没查
int check(int time_each, int as_time)//比较两者数据
{
	return (as_time > time_each ? time_each : as_time);//返回较小的那个数
}
void enqueue(Data x)//插入队列
{
	assigment[tail] = x;//将数据插入到tail的位置
	tail = (tail + 1) % N;//得出的余数为tail的新位置，若余数为0则表示队列满了，tail到队列头第0个位置.犹如一个环形
}
Data dequeue()//将结构数据取出来
{
	Data x = assigment[head];
	head = (head + 1) % N;//同上
	return x;
}
int main()
{
	int total = 0, time_each = 0,count=1,count_time=0,margin=0;
	cin >> total >> time_each;
	Data move;
	while (count <= total)//输入数据,第0个数据不输入
	{
		cin >> assigment[count].name >> assigment[count].time;
		count++;
	}
	head = 1, tail = total + 1;//总数的后一位，空的
	while (head != tail)//当两者相等则没有了
	{
		move = dequeue();//提取数据
		margin = check(time_each, move.time);//得出较少时间的那个
		move.time -= margin;//多于或少于
		count_time += margin;//统计总时间
		if (move.time> 0)//大于时间切片
			enqueue(move);//插入后面
		else
			cout << move.name << " " << count_time << endl;

	}
	return 0;
}


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

int main(){
	int W, H;
	string o = "";
	while (true){
		cin >> H >> W;
		if (W == 0 && H == 0){
			break;
		}
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				o += (i == 0 || i == H-1 || j == 0 || j == W-1) ? "#" : ".";
			}
			o += "\n";
		}
		o += "\n";
	}
	cout << o;
	cin >> W;
}

Measured memory_bytes: 3056
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{    
  int S, W;
  cin >> S >> W;
  if (W >= S) 
  {
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
  
} 


Measured memory_bytes: 3620
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define inf 1LL<<61
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	int arr[13];
	memset(arr, 0, sizeof(arr));
	arr[1] = arr[3] = arr[5] = arr[7] = arr[10] = arr[8] = arr[12] = 1; 
	arr[4] = arr[6] = arr[9] = arr[11] = 2;
	arr[2] = 3;
	int x,y;
	cin >> x >> y;
	string out = (arr[x] == arr[y]) ? "Yes" : "No";
	cout << out;
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using ll = long long;
using namespace std;



void solve() {
   int n;
   cin >> n;
   vector <int> v(n);
   for(int i = 0; i < n; i++) {
      cin >> v[i];
   }
   sort(v.begin(), v.end());

   double ans = 0;
   long long f = 2;
   for(int i = n - 1; i >= 0; i--) {
      if(i == 0) f /= 2;
      ans += v[i] / (double) f;
      f *= 2;
   }

   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3764
IDENTIFICATION DIVISION.
PROGRAM-ID. A-GoodInteger.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP.
   03 N   PIC 9 OCCURS 4.
 
PROCEDURE DIVISION.
  ACCEPT INP.

  IF ((N(1) + N(2) + N(3)) / 3 = N(1)) OR
     ((N(2) + N(3) + N(4)) / 3 = N(2))
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF. 

  STOP RUN.


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n >> m;
  l = 0;
  vi vec;
  rep(i,0,n){
    ll a,b;
    cin >> a >> b;
    l = max(l,a);
    vec.pb(b);
  }
  sort(all(vec),greater<int>());
  ll ans = 0;
  rep(i,0,vec.sz){
    if(m <= 0)break;
    if(vec[i] > l){
      m -= vec[i];
      ans++;
    }else{
      break;
    }
  }
  if(m > 0){
    ans += m / l;
    if(m % l != 0)ans++;
  }
  print(ans);
  return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> puni(m);
	map<int, vector<int>> mp;
	for (auto &p : puni)
	{
		cin >> p.first >> p.second;
		mp[p.first].emplace_back(p.second);
	}
	for (auto &p : mp)
	{
		sort(p.second.begin(), p.second.end());
	}
	for (auto &p : puni)
	{
		cout << setw(6) << setfill('0') << p.first << setw(6) << setfill('0') << distance(mp[p.first].begin(), lower_bound(mp[p.first].begin(), mp[p.first].end(), p.second)) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 13184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        int count = 0;
        int minIndex = 0;
        int maxIndex = S.length()-1;
        
        while (minIndex < maxIndex) {
            if (S.charAt(minIndex++) != S.charAt(maxIndex--)) {
                count ++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{

    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineInt();
            Console.WriteLine((n*2)*Math.PI);
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define max_n 200005//changable
vector<int> par(max_n);
vector<int> ranks(max_n);
vector<int> sizes(max_n);

void init(int n)
{
  int i;
  for(i=0;i<n;i++)
  {
    par[i]=i;
    ranks[i]=0;
    sizes[i]=1;
  }
}

int find(int x)
{
  if(par[x]==x)
  {
    return x;
  }
  else
  {
    return par[x] = find(par[x]);
  } 
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if(x==y)return;
  if(ranks[x]<ranks[y])
  {
    par[x] = y;
    sizes.at(y)+=sizes.at(x);
  }
  else
  {
    par[y] = x;
    sizes.at(x)+=sizes.at(y);
    if(ranks[x]==ranks[y])ranks[x]++;
  }
}

int sizing(int x)
{
  return sizes.at(find(x));
}

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

#define Np 100000

int main()
{
  ll n;cin>>n;
  vector<ll> x(n);
  vector<ll> y(n);
  ll i,j;
  rep(i,n)cin>>x[i]>>y[i];
  rep(i,n)
  {
    x[i]--;
    y[i]--;
  }
  vector<vector<ll>> xloc(100000);
  vector<vector<ll>> yloc(100000);
  rep(i,n)
  {
    xloc[x[i]].emplace_back(y[i]);
    yloc[y[i]].emplace_back(x[i]);
  }
  rep(i,100000)
  {
    sort(all(xloc[i]));
    sort(all(yloc[i]));
  }
  init(200003);
  rep(i,100000)
  {
    if(yloc[i].size()<2)continue;
    rep(j,yloc[i].size()-1)
    {
      unite(yloc[i][0],yloc[i][j+1]);
    }
  }
  rep(i,100000)
  {
    if(xloc[i].size()<2)continue;
    rep(j,xloc[i].size()-1)
    {
      unite(Np+xloc[i][0],Np+xloc[i][j+1]);
    }
  }
  ll ans=0;
  rep(i,n)
  {
    if(same(x[i],200001)||same(Np+y[i],200001))
    {
      continue;
    }
    ll a1=sizing(x[i]);
    ll a2=sizing(Np+y[i]);
    ans+=a1*a2;
    unite(x[i],200001);
    unite(Np+y[i],200001);
  }
  cout<<ans-n<<endl;
}

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

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int N,cnt,ans=0;
    cin>>N;

    for(int i=1;i<=N;i+=2){
        cnt = 0;
        for(int j=1;j<=i;j+=2){
            if(!(i%j)) ++cnt;
        }
        if(cnt==8) ++ans;
    }

    put(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin  >> n >> k;
    int a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    int ret = 0;
    rep(i,k)ret += a[i];
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  double t,x;
  cin >> t >> x;
  printf("%.10f\n",t/x);
}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      int ans=0;
      for(int i=0;i<N;i++){
       int[] arr=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        ans+=arr[1]-arr[0]+1;
      }
      Console.WriteLine(ans);
    }
    
  }

}


Measured memory_bytes: 28448
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e17+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,c;cin>>a>>b>>c;
	cout<<(a+b>=c?"Yes":"No")<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,c=0,d=2;
    cin >> n;
    while (n>1)
    {
        long long nr = 0;
        while (n%d == 0)
        {
            n/=d;
            nr++;
        }
        long long st = 1, dr = 1e6, a = 0;
        while (st<=dr)
        {
            long long mj = (st+dr)/2;
            if ((mj*(mj+1))/2<=nr)
            {
                a = mj;
                st = mj+1;
            }
            else
                dr = mj-1;
        }
        c+=a;
        d++;
        if (d*d>n)
            d = n;
    }
    cout << c;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int x,a;
    cin>>x>>a;
    if(a>x) OUT(0);
    else OUT(10);
	return 0;
}

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

int n,m;
pair<int,int> p[100010];
int a[200010];
int b[200010];

int cmp(pair<int,int> q,pair<int,int> w)
{
	return q<w;
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for (int i=1;i<=m;i++) cin>>p[i].first>>p[i].second;
	sort(p+1,p+m+1,cmp);
	for (int i=1;i<=n;i++) a[i]=b[i]=i;
	for (int i=1;i<=m;i++) 
	{
		a[p[i].second]=min(a[p[i].second],a[p[i].second+1]);
		a[p[i].second+1]=min(a[p[i].second],a[p[i].second+1]);
		
		b[p[i].second]=max(b[p[i].second],b[p[i].second+1]);
		b[p[i].second+1]=max(b[p[i].second+1],b[p[i].second]);
	}
	cout<<b[1]-a[1]+1;
	for (int i=2;i<=n;i++) cout<<" "<<b[i]-a[i]+1;
	cout<<endl;
}

Measured memory_bytes: 5572
=begin
算数がわかっていないため下記のサイトで復習
rubyMathの使い方(http://rubytips86.hatenablog.com/entry/2014/03/24/072550)
面積の求め方(https://atarimae.biz/archives/24942)
平方根(https://atarimae.biz/archives/9568)
三角形の周長の求め方(https://oshiete.goo.ne.jp/qa/6663453.html)
=end

include Math
a, b, c = gets.split.map(&:to_f)
S = 0.5 * a * b * sin(c / 180.0 * PI)
L = a + b + sqrt(a**2 + b**2 - 2 * a * b * cos(c / 180.0 * PI))
h = b * sin(c / 180.0 * PI)

puts sprintf("%.4f", S)
puts sprintf("%.4f", L)
puts sprintf("%.4f", h)


Measured memory_bytes: 6960
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;


void solve(){
	int n;
	string s;
	cin>>n>>s;
	int ans=1;
	for(int i=0; i<n-1; i++){
		if(s[i] != s[i+1]){
			ans++;
		}
	}
	cout<<ans;
}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

struct edge { int to, cost; };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	ll sum[100010] = {};
	for(int i = 1; i <= s.size(); i++){
		sum[i] = sum[i-1];
		if(s[i-1] == 'A' && s[i] == 'C') sum[i]++;
	}
	for(int i = 0; i < q; i++){
		int l,r;
		cin >> l >> r;
		cout << sum[r-1] - sum[l-1] << endl;
	}
	return 0;	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 using namespace std;
 int N, A[3][3], b[10];
 bool appear[3][3];
 int main() {
 for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
 for(int i = 0; i < N; i++) cin >> b[i];
 for(int i = 0; i < N; i++) {
 for(int j = 0; j < N; j++) {
 appear[i][j] = false;
 for(int k = 0; k < N; k++) {
 if(A[i][j] == b[k]) appear[i][j] = true;
 }
}
 }
 string ANS = "No";
 for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
 }

Measured memory_bytes: 256
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=19260817;
int main()
{
	long long n,t,x,y;
	scanf("%d",&n);
	long long p1=0,p2=0;
	long long dis;
	long long tm=0;
	bool shit=false;
	for(long long i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t,&x,&y);
		dis=abs(p1-x)+abs(p2-y);
		if(tm+dis>t)
		{
			cout<<"No";
			return 0;
		}
		else
		{
			if((t-tm-dis)%2!=0)
			{
				cout<<"No";
				return 0;
			}
		}
		tm=t;
		p1=x;p2=y;
	}
	cout<<"Yes";
	return 0;
}

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

    int main(void){
        int n;
        cin >> n;
        if(n%2!=0){
            cout << "No" << endl;
            return 0;
        }
        vector<char> bf(n / 2 + 1), af(n / 2 + 1);
        for (int i = 0; i < n / 2; i++)
            cin >> bf.at(i);            
        for (int i = 0; i < n / 2; i++)
            cin >> af.at(i);
        puts(bf == af ? "Yes" : "No");
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define dl 998244853
lli maxi(lli a,lli b){
    if(a>=b)return a;
    return b;
}

int main() {
    int n,m;
    string s,t;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    vector<vector<lli>> a(n+1,vector<lli>(m+1,0));
    vector<vector<lli>> p(n+1,vector<lli>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                a[i][j]=a[i-1][j-1]+1;
                p[i][j]=1;
            }else{
                a[i][j]=maxi(a[i-1][j],a[i][j-1]);
                if(a[i-1][j]>=a[i][j-1]){
                    p[i][j]=2;
                }else{
                    p[i][j]=3;
                }
            }
        }
    }
    string ans;
    int lo=1;
    int fg= a[n][m];
    int i=n,j=m;
    while(i!=0 && j!=0){
        if(p[i][j]==1){
            ans=ans+s[i-1];
            i=i-1;
            j=j-1;
        }else if(p[i][j]==2){
            i=i-1;
        }else{
            j=j-1;
        }
    }
    // for(int i=1;i<=n;i++){
    //     for(int j=1;j<=m-fg+lo;j++){
    //         //cout<<a[i][j]<<" ";
    //         if(a[i][j]==lo){
    //             lo++;
    //             ans=ans+s[i-1];
    //             break;
    //         }
    //     }
    //     cout<<endl;
    // }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
const int MAXN = 1000024;

ll soinsu[MAXN+1];

void prime_factors(int n) {
    map<int, int> res;
    for(int i = 2; i*i <= n; ++i) {
        while(n % i == 0) {
            res[i]++; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n!=1) res[n]++;
    for(auto x:res){
        ll sosu=x.first,kosu=x.second;
        maxi(soinsu[sosu],kosu);
    }
}
ll modpow(ll a, ll n=MOD-2, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a  % mod;
        n >>= 1;
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    rep(i,N){
        prime_factors(A[i]);
    }
    ll ans=1;
    rep(i,MAXN){
        while(soinsu[i]!=0){
            --soinsu[i];
            ans*=i;
            ans%=MOD;
        }
    }
    ll ans2=0;
    rep(i,N){
        ans2+=modpow(A[i]);
        ans2%=MOD;
    }
    ans*=ans2;
    ans%=MOD;
    cout<< ans <<"\n";

}


//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 6656
#include <stdio.h>

int main(void){

  char s[11];
  scanf("%s", s);

  int count = 0;;
  int max = 0;
  for (int i = 0; i < 10; i++) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      count++;
      if (count > max) {
        max = count;
      }
    } else {
      count = 0;
    }
  }

  printf("%d\n", max);

  return 0;
}

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

int main(){
    int n;
    while (1){
        cin >> n;
        if (n == 0) break;
        int s[n];
        double sum=0, mean;
        for (int i=0; i<n; i++){
            cin >> s[i];
            sum += s[i];
        }
        mean = sum / n;
        sum = 0;
        for (int i=0; i<n; i++) sum += pow(s[i]-mean, 2);
        cout << fixed << setprecision(10) << sqrt(sum / n) << endl;
    }
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

vector<int> link[200010];
vector<int> cost;
void dfs(int v, int p = -1) {
    for (int u : link[v]) {
        if (u == p) continue;
        cost[u] += cost[v];
        dfs(u, v);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    rep(i, N-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        link[a].pb(b);
        link[b].pb(a);
    }
    cost.resize(N);
    rep(i, Q) {
        int p, x; cin >> p >> x;
        p--;
        cost[p] += x;
    }
    dfs(0);
    rep(i, N) cout << cost[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int dp[N][3];
int arr[N][3];
int n;
int func(int index,int prevActivity)
{
  if(index==n)
    return 0;
  int &ret = dp[index][prevActivity];
  if(ret!=-1)
    return ret;
  if(index==0)
    prevActivity = -1;
  ret = -2e9;
  for(int i=0;i<3;i++)
  {
    if(i!=prevActivity)
      ret = max(ret,arr[index][i]+func(index+1,i));
  }
  return ret;
}
signed main()
{
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      cin>>arr[i][j];
  memset(dp,-1,sizeof(dp));
  cout<<func(0,0);
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

ll modpow(ll a, ll n) {
    if(n == 0) return 1 ;
    if(n == 1) return a % mod ;
    if(n % 2) return (a*modpow(a, n-1)) % mod ;
    ll t = modpow(a, n/2) ;
    return (t * t)% mod ;
}
int main (){
    ll x, y ;
    cin >> x >> y ;
    ll a, b ;
    b = 2*x - y ;
    if(b % 3 != 0 || b < 0){
        cout << 0 << endl ;
        return 0 ;
    }
    b /= 3 ;
    a = x - 2 * b ;
    if(a < 0){
        cout << 0 << endl ;
        return 0 ;
    }
    ll t = a + b ;
    ll sum = 1 ;
    for(int i = 1 ; i <= t ; i++){
        sum *= i ;
        sum %= mod ; 
    }
    ll ta = 1 ;
    ll tb = 1 ;
    for(int i = 1 ; i <= a; i++){
        ta *= i ;
        ta %= mod ;
    } 
    for(int i = 1; i <= b ; i++){
        tb *= i ;
        tb %= mod ;
    }
    ll ans = (((sum * modpow(ta, mod - 2))%mod) * modpow(tb, mod - 2)) % mod ;
    cout << ans << endl ; 
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int M,D;
    cin >> M >> D;
    int ans = 0;
    REP(i,M) {
        REP(j,D) {
            int m = i+1;
            int d = j+1;
            int d1 = d%10;
            int d10 = d/10;
            if (d1>=2 && d10 >= 2 && d1 * d10 == m) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k;cin>>n>>k;
  V<int> v(n);
  rep(i,0,n)cin>>v[i];
  sort(all(v));
  
  ll ans=0;
  rep(i,0,k){
    ans+=v[i];
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long[][] A = new long[(int)(3)][(int)(3)];
        for(int i = 0 ; i < 3 ; i++){
                for(int j = 0 ; j < 3 ; j++){
                    A[i][j] = sc.nextLong();
                }
        }
        long N;
        N = sc.nextLong();
        long[] b = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                b[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(A, N, b);
    }
}

class Solver {
    public void solve(long[][] A, long N, long[] b) {
        boolean[][] hit = new boolean[(int)(3)][(int)(3)];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (A[j][k] == b[i]) {
                        hit[j][k] = true;
                    }
                }
            }
        }

        for (int i = 0; i < 3; i++) {
            if (hit[i][0] && hit[i][1] && hit[i][2]) {
                System.out.println("Yes");
                return;
            }
            if (hit[0][i] && hit[1][i] && hit[2][i]) {
                System.out.println("Yes");
                return;
            }
        }

        if (hit[0][0] && hit[1][1] && hit[2][2]) {
            System.out.println("Yes");
            return;
        }
        if (hit[0][2] && hit[1][1] && hit[2][0]) {
            System.out.println("Yes");
            return;
        }

        System.out.println("No");
    }
}



Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define H 30
int main(){
    int h,w,a[H][H];
    cin>>h>>w;
    lol(i,h)lol(j,w)cin>>a[i][j];
    ll ans=mod;
    lol(i,h)lol(j,w){
	ll sum=0;
	lol(f,h)lol(g,w){
	    sum+=min(abs(f-i),abs(g-j))*a[f][g];
	}
	ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    int max_h = -1;
    for(int i = 0; i < n; i++)
    {
        if(max_h - 1 > h[i])
        {
            cout << "No" << endl;
            return;
        }
        max_h = max(max_h, h[i]);
    }
    cout << "Yes" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 640
n = int(input())
arr = list(map(int, input().split()))
 
for i in range(n):
    if i == 0:
        continue
 
    if arr[i] < arr[i - 1]:
        print("No")
        exit()
 
    if arr[i] > arr[i - 1]:
        arr[i] -= 1
 
print("Yes")


Measured memory_bytes: 14396
from collections import Counter
import math
import statistics
import itertools
a,b=map(int,input().split())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
#g = [list(map(lambda x: '{}'.format(x), list(input()))) for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
lis=[input() for i in range(a)]
ra=a-1
for i in range(ra):
    for k in range(ra-i):
        if lis[k]>lis[k+1]:
            a=lis[k]
            lis[k]=lis[k+1]
            lis[k+1]=a
print("".join(lis))



Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

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

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


    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstdlib>
#include <set>
#include <algorithm>
#include <ctime>
using namespace std;

int n, l[110000], r[110000], tx[110000], ty[110000];
bool used[110000];
int now;
long long ans, ans1, prex[110000], prey[110000];

bool cmp1(int x, int y) {
	return l[x] > l[y];
}

bool cmp2(int x, int y) {
	return r[x] < r[y];
}

void go(int t) {
	// printf("%d\n", t);
	if (l[t] <= now && now <= r[t])
		return ;
	if (now < l[t])
		ans += l[t] - now, now = l[t];
	else
		ans += now - r[t], now = r[t];
	// cout << ans << endl;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &l[i], &r[i]);
	for (int i = 1; i <= n; i++)
		tx[i] = i, ty[i] = i;
	sort(tx + 1, tx + n + 1, cmp1);
	sort(ty + 1, ty + n + 1, cmp2);

	ans = 0;

	for (int i = 1; i <= n; i++)
		prex[i] = prex[i - 1] + l[tx[i]];
	for (int i = 1; i <= n; i++)
		prey[i] = prey[i - 1] + r[ty[i]];
	for (int i = 1; i <= n; i++) {
		ans = max(ans, 2 * prex[i] - 2 * prey[i]);
		ans = max(ans, 2 * prex[i - 1] - 2 * prey[i]);
		ans = max(ans, 2 * prex[i] - 2 * prey[i - 1]);
	}
	cout << ans << endl;
}


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

int N, dep[100005];
vector<int> adjlist[100005];
vector< pair<int, int> > edgelist;

int dfs(int x, int p) {
	int ans = 0;
	for (int i = 0; i < adjlist[x].size(); i++) if (adjlist[x][i] != p) ans ^= dfs(adjlist[x][i], x);
	return ans + 1;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	if (dfs(0, -1) == 1) printf("Bob\n");
	else printf("Alice\n");
}


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

int main(){
	int N;
	scanf("%d",&N);
	int num;
	for(int i=0; i<N;i++){
		num = sqrt(N-i);
		if(num*num == N-i){
			printf("%d\n",N-i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
	long long i,n,k,f=1;
	cin>>n>>k;
	long long qzh[n+2];//3	2		0123
	memset(qzh,0,sizeof(qzh));
	for(i=2;i<=n+1;i++)
	{
		qzh[i]=qzh[i-1]+f;
		f++;
		//cout<<i<<" "<<qzh[i]<<endl;
	}
	long long ans=0,fst,lst;
//	set<long long> q;
	for(i=k;i<=n+1;i++)
	{
		fst=qzh[i],lst=qzh[n+1]-qzh[n+1-i];
		//x=(long long)()%(long long)(1000000000+7);
		//q.insert(x);
		//cout<<i<<" "<<fst<<" "<<lst<<" "<<ans<<endl;
		ans = ( ans + ( lst - fst + 1 ) ) % ( long long ) ( mod ) ;
	}
	//cout<<q.size()<<endl;
	cout<<ans%(long long)(mod)<<endl;
    return 0;
}
	

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<double> x(N);
 
  for(int i = 0; i < N; i++){
    cin >> x.at(i);
    x.at(i) = (x.at(i) + 1);
  }
 
  double m = 0;
  double tmp = 0; 
  for(int i = 0; i < N; i++){
    if(i-K>=0) tmp -= x[i-K];
    tmp += x[i];
    if(tmp > m){
      m = tmp;
    }
  }
 
  cout << fixed << setprecision(10) << m / 2.0 << endl;
 
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int a[9][9];
bool f[9][9];
int main(){
  int n;
  cin>>n;
  while(n--){
    r(i,9)r(j,9){cin>>a[i][j];f[i][j]=false;}
    int c[10];
    r(i,9){memset(c,0,sizeof(c));r(j,9)c[a[i][j]]++;
      r(j,9)if(1<c[a[i][j]])f[i][j]=true;
    }
    r(j,9){memset(c,0,sizeof(c));r(i,9)c[a[i][j]]++;
      r(i,9)if(1<c[a[i][j]])f[i][j]=true;
    }
    for(int y=0;y<9;y+=3)for(int x=0;x<9;x+=3){
      memset(c,0,sizeof(c));
      r(i,3)r(j,3)c[a[y+i][x+j]]++;
      r(i,3)r(j,3)if(1<c[a[y+i][x+j]])f[y+i][x+j]=true;
    }
    r(i,9){r(j,9){
      if(f[i][j])cout<<'*';
      else cout<<' ';
      cout<<a[i][j];
    }
    cout<<endl;
  }
  if(n)cout<<endl;
}
}

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	vector<ll> A(N);
	map<ll, int> mp;

	rep(i, N)
	{
		cin >> A[i];

		if (mp.find(A[i]) != mp.end())
		{
			mp[A[i]]++;
		}
		else
		{
			mp[A[i]] = 1;
		}
	}


	if (N == 1)
	{
		cout << (ll)(A[0] / pow(2, M)) << endl;
		return 0;
	}

	rep(i, M)
	{
		auto last = (--mp.end());

		int r = last->first;
		int pnt = r / 2;

		if (pnt != 0)
		{
			if (mp.find(pnt) != mp.end())
			{
				mp[pnt]++;
			}
			else
			{
				mp[pnt] = 1;
			}
		}

		last->second--;
		if (last->second == 0)
		{
			mp.erase(last);
		}
	}

	ll ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++)
	{
		auto v = *it;
		ans += v.first * v.second;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
import sys
import numpy as np

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


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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    cumsum = np.cumsum(A)
    half = sum(A) // 2

    ans = INF
    for i in range(N - 1):
        left = cumsum[i]
        right = cumsum[-1] - cumsum[i]
        cost = abs(half - left) + abs(right - half)
        if cost < ans:
            ans = cost

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    a.at(i)-=i+1;
  }
  sort(a.begin(),a.end());
  int64_t s=0;
  for(int i=0,j=n-1;i<j;i++,j--)
    s+=a.at(j)-a.at(i);
  cout<<s<<endl;
}

Measured memory_bytes: 4040
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if n >= m {
		fmt.Println(0)
		return
	}

	xs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&xs[i])
	}
	sort.Ints(xs)

	distances := make([]int, m)
	for i := 1; i < m; i++ {
		distances[i] = xs[i] - xs[i-1]
	}
	sort.Ints(distances)

	length := len(distances) - int(n) + 1
	var sum int
	for _, d := range distances[:length] {
		sum = sum + d
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

enum Color { White, Black };

int prim(vector<vi> &M) {
  auto n = M.size();
  vi d(n, INF), p(n, -1);
  vector<Color> color(n, White);
  d[0] = 0;
  while (true) {
    auto minv = INF;
    auto u = -1;
    REP(i, n) {
      if (color[i] == White && d[i] < minv) {
        minv = d[i];
        u = i;
      }
    }
    if (u == -1) break;
    color[u] = Black;
    REP(i, n) {
      if (color[i] == White && M[u][i] != INF && M[u][i] < d[i]) {
        d[i] = M[u][i];
        p[i] = u;
      }
    }
  }
  int sum = 0;
  REP(i, n) if (p[i] != -1) sum += M[i][p[i]];
  return sum;
}

int main() {
  int n, e;
  cin >> n;
  vector<vi> M(n, vi(n, 0));
  REP(i, n) {
    REP(j, n) {
      cin >> e;
      M[i][j] = (e == -1) ? INF : e;
    }
  }

  auto ans = prim(M);
  cout << ans << endl;
}


Measured memory_bytes: 3172
s = input()
l = s[0]+s[1]
r = s[2]+s[3]
mm = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if mm.count(l) == 1 and mm.count(r) == 1:
    print('AMBIGUOUS')
elif mm.count(l) == 1 and mm.count(r) != 1:
    print('MMYY')
elif mm.count(l) != 1 and mm.count(r) == 1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long sum = 0;
		for(int i=N-1;i>=0;i--){
			if((A[i]+sum) % B[i] != 0) sum += B[i] - ((A[i]+sum) % B[i]);
		}
		Console.WriteLine(sum);
		
	}
	int N;
	long[] A,B;
	public Sol(){
		N = ri();
		A = new long[N];
		B = new long[N];
		for(int i=0;i<N;i++){
			var d = rla();
			A[i] = d[0]; B[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 8468
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define pb(x) push_back(x) 
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
	cout<<"Bad";
	else
	cout<<"Good";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			if (x == 3 || x == 5 || x == 7) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 22612
n=int(input())
c=input()
r=c.count('R')
w=c.count('W')
ans1=0
ans2=0
for i in range(r):
    if c[i]=='W':
        ans1+=1
for i in range(r,n):
    if c[i]=='R':
        ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int memo[44][444][444];
int n, ma, mb;
vi a, b, c;

int dp(int i, int s, int t) {
	if (s < 0 || t < 0)return INF;
	if (memo[i][s][t])return memo[i][s][t];
	if (i == 0 && s == 0 && t == 0)return 0;
	if (i == 0)return INF;

	int pre = dp(i - 1, s, t);
	int now = dp(i - 1, s - a[i - 1], t - b[i - 1]) + c[i - 1];
	memo[i][s][t] = min(pre, now);
	return memo[i][s][t];
}

int main() {

	cin >> n >> ma >> mb;
	a.resize(n);
	b.resize(n);
	c.resize(n);
	rep(i, n)cin >> a[i] >> b[i] >> c[i];

	int mma = ma, mmb = mb;
	int ans = INF;
	while (mma <= n * 10 && mmb <= n * 10) {
		ans = min(ans, dp(n, mma, mmb));
		mma += ma;mmb += mb;
	}

	if (ans == INF)ans = -1;
	cout << ans << endl;

}

Measured memory_bytes: 32128