akhauriyash/Code-Regression huggingface dataset:
package main

import (
  "fmt"
)

type Evaluator func(a, b interface{}) interface{}

func Max(a, b interface{}) interface{} {
  if a.(int) < b.(int) { return b }
  return a
}

func Min(a, b interface{}) interface{} {
  if a.(int) < b.(int) { return a }
  return b
}

type SegmentTree struct {
  size  int
  data  []interface{}
  inf   interface{}
  eval  Evaluator
}

func CreateSegmentTree(A *[]interface{}, inf interface{}, eval Evaluator) *SegmentTree {
  N := len((*A))
  size := 1
  for size < N {
    size *= 2
  }
  S := make([]interface{}, size * 2)
  for i, a := range (*A) {
    S[size + i] = a
  }
  for i := N; i < size; i++ {
    S[size + i] = inf
  }
  for i := size - 1; i > 0; i-- {
    S[i] = eval(S[2 * i], S[2 * i + 1])
  }
  return &SegmentTree{
    size: size,
    data: S,
    inf:  inf,
    eval: eval,
  }
}

func (ST *SegmentTree) Update(index int, value interface{}) {
  idx := ST.size + index
  ST.data[idx] = value
  for idx > 0 {
    parent := idx / 2
    ST.data[parent] = ST.eval(ST.data[2 * parent], ST.data[2 * parent + 1])
    idx = parent
  }
}

func (ST *SegmentTree) Get(from, to, index, left, right int) interface{} {
  if to <= left || right <= from { return ST.inf }
  if from <= left && right <= to { return ST.data[index] }
  m := (left + right) / 2
  lval := ST.Get(from, to, 2 * index, left, m)
  rval := ST.Get(from, to, 2 * index + 1, m, right)
  return ST.eval(lval, rval)
}

func (ST *SegmentTree) Query(from, to int) interface{} {
  return ST.Get(from, to, 1, 0, ST.size)
}

func Create(P *[]int, inf int, eval Evaluator) *SegmentTree {
  V := make([]interface{}, len((*P)))
  for i, p := range (*P) {
    V[i] = interface{}(p)
  }
  return CreateSegmentTree(&V, inf, eval)
}

func main() {
  var N, K int
  fmt.Scan(&N, &K)
  P := make([]int, N)
  for i := range P {
    fmt.Scan(&P[i])
  }
  MaxST := Create(&P, 0, Max)
  MinST := Create(&P, 200001, Min)
  unsort := -1
  inc := 0
  for i := 0; i < N - 1; i++ {
    if P[i] < P[i + 1] {
      inc += 1
    } else {
      inc = 0
    }
    if inc == K - 1 { unsort += 1 }
  }
  if unsort < 0 { unsort = 0 }
  cnt := N - K + 1
  for i := 0; i < N - K; i++ {
    min := MinST.Query(i, i + K).(int)
    max := MaxST.Query(i, i + K).(int)
    if min == P[i] && max < P[i + K] {
      cnt -= 1
    }
  }
  fmt.Println(cnt - unsort)
}

Measured memory_bytes: 30380
A, B = map(int, input().split())

a = A // 0.08
b = B // 0.1
a_ = (A+1)//0.08
b_ = (B+1)//0.1

for i in range(int(max(a, b)),int(min(a_, b_))+1):
    if A==int(i*.08)and B==int(i*.1):
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 38256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

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

int main(void) {
    int N;
    cin >> N;
    cout << 180*(N-2) << endl;

    return 0;
}

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

using ld = long double;
const ld eps = 1e-8, pi = acos(-1.0);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

using Point = complex<ld>;
class Line {
public:
	Point a, b;
};
ld dot(Point a, Point b) {
	return real(conj(a) * b);
}

ld cross(Point a, Point b) {
	return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c) {
	b -= a, c -= a;
	if (cross(b, c) > eps) return 1;	// a,b,c??????????¨???¨???
	if (cross(b, c) < -eps) return -1;	// a,b,c???????¨???????
	if (dot(b, c) < 0) return 2;		// c,a,b????????§??´???
	if (norm(b) < norm(c)) return -2;	// a,b,c???????????´???
	return 0;							// a,c,b???????????´???
}


int main()
{
	ld x1, x2, x3, xp, y1, y2, y3, yp;
	Point p1, p2, p3, P;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		p1 = Point(x1, y1);
		p2 = Point(x2, y2);
		p3 = Point(x3, y3);
		if (ccw(p1, p2, p3) == -1) {
			swap(p2, p3);
		}
		P = Point(xp, yp);
		cout << (ccw(p1, p2, P) == 1 && ccw(p2, p3, P) == 1 && ccw(p3, p1, P) == 1 ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<int, ll> i_ll;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 10;
double EPS = 1e-10;
double PI2 = M_PI * 2;

int main() {
	int K, S; cin >> K >> S;
	int ans = 0;
	for (int X = 0; X <= K; X++)
		for (int Y = 0; Y <= K; Y++) {
			int Z = S - X - Y;
			if (0 <= Z && Z <= K) ans++;
		}
	cout << ans << endl;
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,a,b;
  cin >> n >> a >> b;

  int ans = n;
  REP(_,n){
    int x;
    cin >> x;
    if(range(x,a,b)) ans--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#line 1 "c.cpp"
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/03/20 01:08:28
// -----------------------------------

#include <bits/stdc++.h>
#line 3 "/mnt/c/Users/tkmma/competitive_programming/CPBF/library/include/segment_tree.hpp"

template <typename M>
class SegmentTree {
 private:
  size_t size_;
  std::vector<M> tree_;

 public:
  explicit SegmentTree(size_t size) : size_(size), tree_(size*2) {}

  template <typename Iter>
  explicit SegmentTree(Iter begin, Iter end) : SegmentTree(end-begin) {
    for (auto it = begin; it != end; ++it)
      tree_[size_ + it - begin] = *it;
    for (size_t i = size_-1; i > 0; i--)
      tree_[i] = tree_[i * 2] * tree_[i * 2 + 1];
  }

  M operator[](size_t index) const {
    return tree_[size_ + index];
  }

  void set(size_t index, M val) {
    auto i = size_ + index;
    tree_[i] = val;
    i >>= 1;
    while (i > 0) {
      tree_[i] = tree_[i*2] * tree_[i*2+1];
      i >>= 1;
    }
  }

  M query(size_t l, size_t r) const {
    M lhs,rhs;
    for (auto _l = l+size_, _r = r+size_; _l < _r; _l>>=1, _r>>=1) {
      if (_l&1) lhs = lhs * tree_[_l++];
      if (_r&1) rhs = tree_[--_r] * rhs;
    }
    return lhs * rhs;
  }

};

#line 9 "c.cpp"

using namespace std;
using ll = long long;

struct Min {
  int x;
  Min(int x=1e9): x(x) {}
  Min operator*(const Min& r) const {return min(x,r.x);}
  Min& operator*=(const Min& r) {return *this = *this * r;}
};
using Rmq = SegmentTree<Min>;

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

  int n,x; cin>>n>>x;
  vector<int> A(n); for (auto& a:A) cin>>a;
  Rmq rmq(A.begin(), A.end());

  vector<long long> dp(n);
  {
    for (int i = 0; i < n; i++) {
      dp[i] = A[(n-i)%n];
      if (i > 0)
        dp[i] = min(dp[i], dp[i-1]);
    }
  }
  constexpr ll INF = 1e18;
  for (int i = 1; i < n; i++) {
    auto nxt = dp;
    for (int j = 0; j < n; j++) {
      auto mina = rmq.query(max(i-j, 0), i+1).x;
      if (i-j < 0)
        mina = min(mina, rmq.query(i-j+n, n).x);
      nxt[j] = dp[j] + mina;
      if (j > 0)
        nxt[j] = min(nxt[j], nxt[j-1]);
    }
    dp = nxt;
  }
  ll ans = INF;
  for (int i = 0; i < n; i++) {
    ans = min(ans, dp[i] + (ll)x * i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3720
a,b = map(int, input().split())
l = list(map(int, input().split()))
L = []

for i in range(a):
  l2 = [l[i],l[i] + b]
  L.append(l2)
  
L = sorted(L, key = lambda x:x[1])
#print(L)

ri = 0
sum = 0

for x,y in L:
#  print(x,y)
  if ri > x:
    sum += y - ri
  else:
    sum += b
  ri = y
#  print("sum:" + str(sum), "ri:" + str(ri))

print(sum)


Measured memory_bytes: 41836
#include<iostream>

int main () {
    int K;
    std::cin >> K;
    std::string S;
    std::cin >> S;

    std::string ans = S;

    if (S.length() > K) {
        ans = S.substr(0,K) + "...";
    }

    std::cout << ans ;
    return 0;
}

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

namespace ABC146F
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Cin.String();
            if (s == "SAT")
            {
                Console.WriteLine(1);
                return;
            } else if (s == "FRI")
            {
                Console.WriteLine(2);
                return;
            }
            else if (s == "THU")
            {
                Console.WriteLine(3);
                return;
            }
            else if (s == "WED")
            {
                Console.WriteLine(4);
            }
            else if (s == "TUE")
            {
                Console.WriteLine(5);
                
            }else if (s == "MON")
            {Console.WriteLine(6);}else {Console.WriteLine(7);}
        }
    }

    class Solver
    {
        public Solver()
        {

        }

        public IConvertible Solve()
        {
            return 0;
        }
    }

    internal static class Cin
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(String());
        }

        public static int[] IArr()
        {
            return Split().Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(String());
        }

        public static long[] LArr()
        {
            return Split().Select(long.Parse).ToArray();
        }

        public static double Double()
        {
            return double.Parse(String());
        }

        public static double[] DArr()
        {
            return Split().Select(double.Parse).ToArray();
        }

        private static IEnumerable<String> Split()
        {
            return String().Split(' ');
        }
    }
}

Measured memory_bytes: 11092
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N = int(input().strip())
    S = []
    for i in range(N):
        S.append(input().strip())
    return N, S


def solve(N, S):
    words = defaultdict(int)
    for s in S:
        key = "".join(list(sorted(s)))
        words[key] += 1
    
    ans = 0
    for key in words:
        n = words[key]
        if n >= 2:
            ans += n * (n-1) // 2
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 29572
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;


int main()
{
    int n;
    scanf("%d",&n);
    bool ok=false;
    while(n){
        int buf=n%10;
        if(buf==9){
            ok=true;
            break;
        }
        n/=10;
    }
    if(ok) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
l=[lnii() for i in range(n)]

ans=0
for i in [1,-1]:
  for j in [1,-1]:
    for k in [1,-1]:
      t_num=0
      t_l=[]
      for x,y,z in l:
        t_num=x*i+y*j+z*k
        t_l.append(t_num)
      t_l.sort(reverse=True)
      ans=max(ans,sum(t_l[:m]))

print(ans)

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	//n倍すると余りはループする。そのループ内になければNo
	int rest_first = A % B;
	int i = 1;
	int tmp_rest;
	if (rest_first == C) {
		cout << "Yes";
	}
	else {
		while (true) {
			i++;
			tmp_rest = A * i % B;
			if (tmp_rest == C) {
				cout << "YES";
				return 0;
			}
			if (tmp_rest == rest_first) {
				cout << "NO";
				return 0;
			}
			else {
				continue;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/abc076/tasks/abc076_c

s=input()
t=input()
ls=len(s)
lt=len(t)
if ls<lt:
    print("UNRESTORABLE")
    exit()
for i in range(ls-lt,-1,-1):#後ろから考える
    for j in range(lt):
        flag=0
        if (s[i+j]!=t[j])&(s[i+j]!="?"):
            flag=1
            break
    if flag==0:
        ans=s[:i]+t+s[i+lt:]
        #print(ans)
        print(ans.replace("?","a"))
        exit()

print("UNRESTORABLE")


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  if ( (100*r+10*g+b)%4 == 0 ){
    cout << "YES" << endl; 
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
k = gets.chomp.to_i

diffs = [e - d, e - c, e - b, e - a, d - c, d - b, d - a, c - b, c - a, b - a]
if diffs.all? { |x| x <= k }
  puts 'Yay!'
else
  puts ':('
end


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

const double EPS = 1e-10;

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}

	Point operator + (Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator * (double k) {
		return Point(k * x, k * y);
	}
	Point operator / (double k) {
		return Point(x / k, y / k);
	}

	double norm() {
		return x * x + y * y;
	}
	double abs() {
		return sqrt(norm());
	}

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2): p1(p1), p2(p2) {};

	Point project(Point p) {
		Vector a = Vector(p.x - p1.x, p.y - p1.y);
		Vector b = Vector(p2.x - p1.x, p2.y - p1.y);
		return p1 + (p2 - p1) * (dot(a, b) / b.norm());
	}

	Point refrect(Point p) {
		Point pro = project(p);
		return pro * 2 - p;
	}
};

Point crossPoint(Segment s1, Segment s2) {
	Point c1 = s2.project(s1.p1);
	Point c2 = s2.project(s1.p2);
	double a = (c1 - s1.p1).abs();
	double b = (c2 - s1.p2).abs();
	return s1.p1 + (s1.p2 - s1.p1) * (a / (a + b));
}

int main() {
	int q;
	cin >> q;
	int x0, y0, x1, y1, x2, y2, x3, y3;
	for (int i = 0; i < q; i++) {
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Segment s1 = Segment(Point(x0, y0), Point(x1, y1));
		Segment s2 = Segment(Point(x2, y2), Point(x3, y3));
		Point p = crossPoint(s1, s2);
		cout << fixed << setprecision(10) << p.x << ' ' << p.y << endl;
	}
	return 0;
}

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

Measured memory_bytes: 256
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W = i2nn()
    SS = ii2ss(H)
    D = [[0] * W for _ in range(H)]
    for i in range(H):
        c = 0
        j0 = 0
        for j in range(W):
            s = SS[i][j]
            if s == '.':
                c += 1
            else:
                for k in range(j0, j):
                    D[i][k] += c
                c = 0
                j0 = j + 1
        for k in range(j0, W):
            D[i][k] += c
    #print(D)
    for j in range(W):
        c = 0
        i0 = 0
        for i in range(H):
            s = SS[i][j]
            if s == '.':
                c += 1
            else:
                for k in range(i0, i):
                    D[k][j] += c
                c = 0
                i0 = i + 1
        for k in range(i0, H):
            D[k][j] += c
    #print(D)
    n = 0
    for d in D:
        t = max(d)
        if t > n:
            n = t
    print(n-1)

main()


Measured memory_bytes: 93788
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];
  const T = input[1][0];

  return T.slice(0, -1) === S ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29696
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
const ll MOD=1000000007;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}

int main()
{
  ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
  ll n;
  cin>>n;
  F (i,1,1e5,1) {
    if (pwr(i,2LL) +i >=2*n) {
      cout<<i; break;
    }
  }

return 0;
}




Measured memory_bytes: 3668
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main(){
  string s; cin >> s;
  ll r = s.size()-1;
  ll l = 0;
  ll ans = 0;
  while(l<r){
    if(s[l]==s[r]){
      l++; r--;
      continue;
    }
    if(s[l] != 'x' && s[r] != 'x'){
      cout << -1 << endl;
      return 0;
    }
    ans++;
    if(s[l]=='x') l++;
    else r--;
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}

const int N = 3002;
ll dp[N][N][2];
int n, m;

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int x, y;
	scanf("%d%d%d%d", &x, &y, &n, &m);
	dp[x][y][0] = 1;
	for (x = 1; x <= n; x++)
		for (y = 1; y <= m; y++) {
			for (int f = 0; f < 2; f++) {
				if (y < m) {
					dp[x][y + 1][1] = add(dp[x][y + 1][1], mult(dp[x][y][f], x));
				}
				if (x < n) {
					if (f == 0)
						dp[x + 1][y][0] = add(dp[x + 1][y][0], mult(dp[x][y][f], y));
					else
						dp[x + 1][y][0] = add(dp[x + 1][y][0], dp[x][y][f]);
				}
			}
		}
	printf("%lld\n", add(dp[n][m][0], dp[n][m][1]));

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007
#define EPS 1e-3

typedef vector<double> vec;
typedef vector<vec> mat;

vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      B[i][j]=A[i][j];
    }
    B[i][n]=b[i];
  }

  for(int i=0;i<n;i++){
    int piv=i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i])>abs(B[piv][i]))piv=j;
    }
    swap(B[i],B[piv]);
    if(abs(B[i][i])<EPS)return vec();
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
      for(int j=0;j<n;j++){
        if(i!=j){
          for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
        }
    }
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

double calc(const vec& b,double x){
  double res=0;
  int n=b.size();
  rep(i,n){
    res+=b[i]*pow(x,(double)(n-1-i));
  }
  return res;
}

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    n++;
    vector<double> a(n+2);
    rep(i,n+2){
      cin>>a[i];
    }
    int ans=-1;
    rep(i,n+2){ // mismatch
      int last;
      if(i==n+1)last=n;
      else last=n+1;
      mat A(n,vec(n));
      vec B(n);
      int kk=0;
      rep(k,n+2){
        if(k==i||k==last)continue;
        rep(l,n){
          A[kk][l]=pow((double)k,(double)(n-1-l));
        }
        B[kk]=a[k];
        kk++;
      }
      vec res=gauss_jordan(A,B);
      if(res.size()==0)continue;
      if(abs(calc(res,i)-a[i])>EPS&&abs(calc(res,last)-a[last])<EPS){
        ans=i;
        break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3352
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int num = scan.nextInt();

		int result = (num / 500) * 1000 + (num % 500) / 5 * 5;

		System.out.println(result);
	}
}

Measured memory_bytes: 23764
import math
n=int(input())
a=list(map(int, input().split() ) )
b=[0]*n
b[1]=int(math.fabs(a[0]-a[1]))
for i in range(2, n):
    b[i]=int(min(b[i-1]+math.fabs(a[i]-a[i-1]), b[i-2]+math.fabs(a[i]-a[i-2]) ) )
print(b[-1])

Measured memory_bytes: 14104
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

int main() {

    int x,y;
    cin>>x>>y;
    if(x*4<y||x*2>y) {
        cout<<"No"<<endl;
    }
    else {
        if(y%2==0) {
            cout<<"Yes"<<endl;
        }
        else {
            cout<<"No"<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3600
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	ll n, k;
	cin >> n >> k;
	vi arr(n);
	forn(i, n) cin >> arr[i], arr[i]--;
	int len = 0;
	int index = 0;
	vi vis(n, 0);
	int pre = 0;
	while(vis[index] != 3){
		vis[index] += 1;
		if(vis[index] == 2) len++;
		else pre++;
		index = arr[index];
	}
	if(k >= pre){
		k = (pre + (k-pre) % len);
	}
	trace(pre, len);
	index = 0;
	while(k--){
		index = arr[index];
	}
	cout << index + 1;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 4780
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  if (a%2 == b%2)
    cout << (b-a)/2 << endl;
  else {
    ll add1, add2, a1 = a, a2 = a, b1 = b, b2 = b;
    add1 = a;
    a1 = 1;
    b1 -= add1;
    add2 = n-b+1;
    a2 += add2;
    b2 = n;
    cout << min(add1+(b1-a1)/2, add2+(b2-a2)/2) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (forM_, replicateM, when)
import           Control.Monad.ST      (ST)
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)
import           Data.Vector           (Vector, (!))
import qualified Data.Vector           as V
import           Data.Vector.Mutable   (STVector)
import qualified Data.Vector.Mutable   as MV

main :: IO ()
main = do
  n <- readLn
  abcs <- replicateM (n - 1) getInts
  [q, k] <- getInts
  xys <- replicateM q getInts
  putStr . unlines . map show $ solve n abcs q k xys

solve :: Int -> [[Int]] -> Int -> Int -> [[Int]] -> [Int]
solve n abcs q k xys = map query xys where
  query [x, y] = ds ! (x - 1) + ds ! (y - 1)
  ds = depth n tree k
  tree = V.create $ do
    tree' <- MV.replicate n [] :: ST s (STVector s [(Int, Int)])
    forM_ abcs $ \[a, b, c] -> do
      let a' = a - 1
          b' = b - 1
      MV.modify tree' ((a', c):) b'
      MV.modify tree' ((b', c):) a'
    return tree'

depth :: Int -> Vector [(Int, Int)] -> Int -> Vector Int
depth n tree k = V.create $ do
  ds <- MV.new n :: ST s (STVector s Int)
  dfs ds tree (k - 1) (-1) 0
  return ds

dfs :: STVector s Int -> Vector [(Int, Int)] -> Int -> Int -> Int -> ST s ()
dfs ds tree v p d = do
  MV.write ds v d
  forM_ (tree ! v) $ \(w, c) -> do
    when (w /= p) .
      dfs ds tree w v $ d + c

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInts :: IO [Int]
getInts = map readInt . BS.words <$> BS.getLine


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, M; cin >> N >> M;
    vector<int> k(M), p(M);
    Graph s(M);
    for(int i = 0; i < M; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++) {
            int S; cin >> S;
            s[i].push_back(S);
        }
    }
    for(int i = 0; i < M; i++) cin >> p[i];
    ll ans = 0;
    for(int i = 0; i < (1 << 10); i++) {
        bitset<10> bit(i);
        if(i == (1 << N)) break;
        bool judge = true;
        for(int u = 0; u < M; u++) {
            int cnt = 0;
            for(auto v: s[u]) if(bit.test(v - 1)) cnt++;
            if(cnt % 2 != p[u]) judge = false;
        }
        if(judge) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
    int N;
    long long a[100010][3];
    long long dp[100010][3];
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long ans = 0;
    for(int i=0;i<3;i++) chmax(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  if(N==1) cout << "Hello World" << endl;
  if(N==2){
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;

  }



  return 0;
}


Measured memory_bytes: 256
def main():
    A,B,C,D,E,F = map(int,input().split())

    x_list = []
    for i in range(F+1):
        for j in range(F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                x_list.append(x)

    y_list = []
    for i in range(F+1):
        for j in range(F+1):
            y = i*C + j*D
            if y <= F:
                y_list.append(y)

    res = 0
    res_x = 0
    res_y = 0

    x_list = list(set(x_list))
    y_list = list(set(y_list))

    for x in x_list:
        for y in y_list:
            if x + y > F:
                continue

            if y == 0:
                tmp = 0
            else:
                tmp = y/(x+y)

            if tmp > E/(100+E):
                continue

            if res <= tmp:
                res = tmp
                res_x = x
                res_y = y


    print(res_x+res_y,res_y)

if __name__ == "__main__":
    main()




Measured memory_bytes: 12464
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    ll N; cin >> N;
    ll ans = 1;
    vector<ll> cnt(N+1, 2);
    FOR(i, 2, N+1){
       ans += i*cnt[i];
       for(ll j = i; j < N+1; j += i){
           cnt[j]++;
       }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81400
#include <stdio.h>

int main() {
  int t[101][101], r, c, i, j, sum, total=0;

  scanf("%d%d", &r, &c);

  for(i=0; i<r; i++) for(j=0; j<c; j++) scanf("%d", &t[i][j]);

  for(i=0; i<r; i++){
    sum = 0;
    for(j=0; j<c; j++){
      sum += t[i][j];
      total += t[i][j];
    }
    t[i][j] = sum;
  }

  for(j=0; j<c; j++){
    sum = 0;
    for(i=0; i<r; i++){
      sum += t[i][j];
    }
    t[i][j] = sum;
  }

  t[r][c] = total;

  for(i=0; i<=r; i++){
    for(j=0; j<c; j++){
      printf("%d ", t[i][j]);
    }
    printf("%d\n", t[i][j]);
  }

  return 0;
}



Measured memory_bytes: 2140
fun main(args: Array<String>) {

    val num = readLine()!!.toInt()

    // 10の階乗の場合
    if (num % 10 == 0)
        println(10)
    else
        println(devideUnit(num))


    // LOOK 正の整数は1以上
}

fun devideUnit(n: Int): Int {

    var loopTarget = n
    var sum = 0

    while (loopTarget > 0) {
        sum += loopTarget % 10
        loopTarget /= 10
    }

    return sum
}

Measured memory_bytes: 31796
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		for (int i = 0; i < n; i++) {
		    String city = scan.next();
		    int point = scan.nextInt();
		    sp[i] = city + "," + (1100- point) + "," + (i+1);
		}
		Arrays.sort(sp);
		for (String s: sp) {
		    String ans = s.split(",")[2];
		    System.out.println(ans);
		}
		
	}
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

signed main(){

  ll n;
  string s;
  cin>>n>>s;

  ll ans = 0;
  auto chk = [&](string const& key){
    bool one,two,three;
    one = two = three = false;
    for(auto c:s){
      if(c==key[0]&&(!one)&&(!two)&&(!three))one=true;
      else if(c==key[1]&&one&&(!two))two=true;
      else if(c==key[2]&&two)three=true;
    }
    return one&&two&&three;
  };
  for(int i=0;i<1000;++i){
    string key = to_string(i);
    while(key.size()<3)key = "0"+key;
    if(chk(key)){
      ans++;
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int sec;
    scanf("%d", &sec);

    int h = sec / 3600;
    sec -= h * 3600;
    int m = sec / 60;
    sec -= m * 60;
    printf("%d:%d:%d\n", h, m, sec);
    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
 
int main(void) {
    int i=0;
    int j;
    int N;
    int K;
    int D[100];
    int A[100][100]={};
    int frg[100]={};
    
    scanf("%d %d",&N,&K);
    
    int cpy=N;
    while(cpy>=0){
        frg[cpy]=1;
        cpy--;
    }
    
    for(i=0;i<K;i++){
        scanf("%d",&D[i]);
        for(j=0;j<D[i];j++){
            scanf("%d",&A[i][j]);
            frg[A[i][j]-1]=0;
        }
    }

    int cnt=0;
    for(i=0;i<N;i++){
        if(frg[i]!=0){
            cnt++;
        }
    }

    printf("%d",cnt);
    
    return 0;
}

Measured memory_bytes: 1740
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)5e3 + 7;
const int MAXN = (int)3e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	LD a, b, h, m;
	cin >> a >> b >> h >> m;
	LD a1 = 2 * PI * (60 * h + m) / 720.0;
	LD a2 = 2 * PI * m / 60.0;
	LD xa = a * cos(PI / 2 - a1), ya = a * sin(PI / 2 - a1);
	LD xb = b * cos(PI / 2 - a2), yb = b * sin(PI / 2 - a2);
	cout << sqrt(sqr(xa - xb) + sqr(ya - yb)) << endl;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3808
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X=sc.nextLong(), Y=sc.nextLong(),c=1;
    while(true) {
      X *= 2;
      if(X<=Y) {
        c++;
      } else break;
    }
    System.out.println(c);
  }
}

Measured memory_bytes: 35764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i < n; i++)cin >> a[i];
    reverse(a, a + n);
    for(int i=0; i< n;i++){
        if(i == n-1){
            cout << a[i] << endl;
            return 0;
        }
        cout << a[i] << ' ';
    }
}


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

int main() {
double w,h,x,y;cin>>w>>h>>x>>y;
  
  cout<<w*h/2<<endl;
  
  if(2*x==w && 2*y==h)cout<<1<<endl;
  else cout<<0<<endl;
  
}


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

int main() {
  int N, M, max = 0, a = 0, b = 0;
  int64_t aT = 0, bT = 0, K;
  cin >> N >> M >> K;
  vector<int64_t> A(N), B(M);
  for (int64_t &x : A) {
    cin >> x;
  }
  for (int64_t &x : B) {
    cin >> x;
  }
  for (int i = 0; i < N; i++) {
    aT += A.at(i);
    a++;
    if (aT > K) {
      a--;
      aT -= A.at(a);
      break;
    }
  }
  do {
    for (int i = b; i < M; i++) {
      bT += B.at(i);
      b++;
      if (bT + aT > K) {
        b--;
        bT -= B.at(b);
        break;
      }
    }
    if (b == M && a == N) {
      max = a + b;
      break;
    }
    if (max < a + b) {
      max = a + b;
    }
    if (a != 0) {
      a--;
      aT -= A.at(a);
    }
    else {
      break;
    }
  } while(1);
  cout << max << endl;
}

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

#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

const int N = 2e5;
int n,x,y;
int a[N];

int main(){
	c_p_c();
	cin >> n >> x >> y;
	--x,--y;

	fo(i,n){
		Fo(j,i+1,n){
			int d = min(j-i,abs(i-x)+1+abs(j-y));
			++a[d];
		}
	}

	Fo(i,1,n) cout << a[i] << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split(' '))
array1 = []
array2 = []
for i in range(n):
    array1.append(list(map(int,input().split(' '))))
for i in range(m):
    array2.append(int(input()))

for i in range(n):
    printsum = 0
    for j in range(m):
        printsum += array1[i][j] * array2[j]
    print(printsum)


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

int main() {
    int X, N;
    cin >> X >> N;
    set<int> num_set;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        num_set.insert(x);
    }

    int min_diff = 1000;
    int min_value = -1;
    for (int i = 0; i <= 101; ++i) {
        if (num_set.find(i) != num_set.end()) {
            continue;
        }
        if (min_diff > abs(X - i)) {
            min_diff = abs(X - i);
            min_value = i;
        }
    }

    cout << min_value << endl;
}

Measured memory_bytes: 3640