akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int INF=100000000;
int h,w;
char c[25][25];
int sx,sy;
int gx,gy;
int d[25][25];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int bfs(int sx,int sy,int gx,int gy){
    queue<pair<int,int>> que;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j]=INF;
        }
    }
    que.push(pair<int,int>(sx,sy));
    d[sx][sy]=0;
    while(que.size()){
        pair<int,int> p=que.front();
        que.pop();
        if(p.first==gx && p.second==gy) break;
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<h && 0 <=ny && ny<w && c[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(pair<int,int>(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gx][gy];
}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
        }
    }
    int ans=-1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=i;k<h;k++){
                for(int l=0;l<w;l++){
                    if(c[i][j]=='.' && c[k][l]=='.'){
                        ans=max(ans,bfs(i,j,k,l));
                        for(int x=0;x<25;x++){
                            for(int y=0;y<25;y++){
                                d[x][y]=INF;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        while(true){
	            int m = sc.nextInt();
	            int f = sc.nextInt();
	            int r = sc.nextInt();

	            if(m == -1 && f == -1 && r == -1 ) break;

	            if( m == -1 || f == -1 ){
	                System.out.println("F");
	            } else if(m+f >= 80){
	                System.out.println("A");
	            } else if(m+f >= 65){
	                System.out.println("B");
	            } else if(m+f >= 50 || r >= 50){
	                System.out.println("C");
	            } else if(m+f >= 30){
	                System.out.println("D");
	            } else {
	                System.out.println("F");
	            }
	        }
	    }
	}



Measured memory_bytes: 26384
#include<iostream>
#include<vector>


using namespace std;

int main(void){

    int n, t, min = 10000, index;
    cin >> n >> t;

    vector<pair<int, int>> data;

    for(int i = 0;i < n;i++){
        int a, b; cin >> a >> b;
        data.push_back(make_pair(a, b));
    }

    for(int i = 0;i < n;i++){
        if(data[i].second <= t){
            if(min > data[i].first){
                min = data[i].first;
            }
        }
    }

    if(min == 10000){
        cout << "TLE" << endl;
    }else{
        cout << min << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var hw = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var all = hw[0] * hw[1];
            var grid = new int[all];
            var graph = new List<int>[all].Select(x => new List<int>()).ToArray();
            for (var y = 0; y < hw[0]; y++)
            {
                var s = Console.ReadLine();
                for (var x = 0; x < s.Length; x++)
                {
                    var current = hw[1] * y + x;
                    grid[current] = s[x] == '.' ? 0 : 1;
                    var right = current + 1;
                    var down = current + hw[1];
                    if (right % hw[1] != 0) graph[current].Add(right);
                    if (down < all) graph[current].Add(down);
                }
            }
            var queue = new Queue<int>();
            queue.Enqueue(0);
            var depths = Enumerable.Repeat(-1, all).ToArray();
            depths[0] = 0;
            var costs = Enumerable.Repeat(all, all).ToArray();
            costs[0] = grid[0];
            while (queue.Any())
            {
                var current = queue.Dequeue();
                foreach (var next in graph[current])
                {
                    depths[next] = depths[current] + 1;
                    if (costs[next] == all)
                        queue.Enqueue(next);

                    var tmp = 1;
                    if (grid[next] == 1)
                    {
                        if (grid[current] == 1) tmp = 0;
                    }
                    else
                    {
                        tmp = 0;
                    }
                    costs[next] = Math.Min(costs[next], costs[current] + tmp);
                }
            }
            Console.WriteLine(costs[costs.Length - 1]);
        }
    }
}


Measured memory_bytes: 14176
m,f,r = map(int,input().split())
score = 0

while m!=-1 or f!=-1 or r!= -1:
    score = m+f
    if m==-1 or f ==-1:
        grade = "F"
    elif score >= 80:
        grade = "A"
    elif score < 80 and score >= 65:
        grade = "B"
    elif score < 65 and score >= 50:
        grade = "C"
    elif score < 50 and score >= 30:
        if r>=50:
            grade = "C"
        else:
            grade = "D"
    else:
        grade = "F"

    print(grade)
    m,f,r = map(int,input().split())

Measured memory_bytes: 7644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h)cin >> s[i];

    int ans = 1000000;
    for(int b = 0; b < (1 << h - 1); b++){
        int cut = 0;
        map<int, int> m;
        int idx = 0;
        m[0] = idx;
        rep(i, h - 1){
            if(b & (1 << i)){
                cut++;
                idx++;
            }
            m[i + 1] = idx;
        }

        vector<int> cnt(idx + 1, 0);
        bool valid = true;
        rep(i, h){
            if(s[i][0] == '1')cnt[m[i]]++;
            if(cnt[m[i]] > k)valid = false;
        }
        if(!valid)continue;

        int l = 1;
        for(int i = 1; i < w; i++){
            bool v = true;
            rep(j, h){
                if(s[j][i] == '1')cnt[m[j]]++;
                if(cnt[m[j]] > k)v = false;
            }
            l++;

            if(!v){
                cut++;
                l = 1;
                rep(j, h)cnt[m[j]] = 0;
                rep(j, h){
                    if(s[j][i] == '1')cnt[m[j]]++;
                    if(cnt[m[j]] > k){
                        valid = false;
                        break;
                    }
                }
                if(!valid)break;
            }
        }

        if(!valid)continue;

        ans = min(cut, ans);

    }
    cout << ans << endl;
}

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

ll n,k,a,b,c;
string s,t;

int main() {
  cin >> n >> a >> b;
  if(!(b-a&1))
  cout << (b-a)/2 << endl;
  else 
  cout << min(a+(b-a)/2,n-b+(b-a+1)/2) << endl;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);


typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

/*Goto end for warnings*/

const ll INF = 1e15;

int main()
{
	IOS;
	ll n,W,i,j;
	cin >> n >> W;
	ll w[n + 1],v[n + 1];
	ll sum_val = 0;
	forn(1,n + 1,i){
		cin >> w[i] >> v[i];
		sum_val += v[i];
	}

	vvl dp(n + 1,vl(sum_val + 1,INF));
	forn(0,n + 1,i)
		dp[i][0] = 0;
	for(i = 1; i <= n; i++){
		for(j = 0;j <= sum_val; j++){
			if(j >= v[i]){
				dp[i][j] = min(dp[i][j],dp[i - 1][j - v[i]] + w[i]);
			}
			dp[i][j] = min(dp[i][j],dp[i - 1][j]);
		}	
	}
	for(i = sum_val; i>= 0;i--)
	{
		if(dp[n][i] <= W)
		{
			cout << i << '\n';
			return 0;
		}
	}
}


/*
	Warnings:
	1. Always use ll, I repeat always.
	2. Check for out of bound index. (While prefix sum do i - 1 only if i > 0)
	3. Don't make too many cases, try to generalize the problem.
	4. Define limits of binsearch properly (0,n or 0,n - 1 or 1,n etc...)
	5. Declare arrays of size n + 10 to avoid segfault
*/


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5+5;
map<int, int> mp;
int N, ans, x;
set<int> st;

int main(int argc, char ** argv) {
	set<int> :: iterator it;
	scanf("%d", &N);
	rep(i, 0, N) { 
		scanf("%d", &x); x = -x;
		it = st.upper_bound(x);
		if(it != st.end()) {
			mp[*it]--;
			if(!mp[*it]) st.erase(it);
		}
		st.insert(x);
		mp[x]++;
	}
	for(it = st.begin(); it != st.end(); it++)
		ans += mp[*it];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 9472
import fractions
from functools import reduce
def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)
N,X=map(int,input().split())
x=list(int(i) for i in input().split())
for i in range(N):
  x[i]=abs(X-x[i])
print(gcd_list(x))

Measured memory_bytes: 16304
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long h, long long w){
    if(h == 1 || w == 1)
        cout << 1 << endl;
    else
        cout << (h * w + 1) / 2 << endl;
}


signed main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll t,n,m,x,z,c,s,a[100001],b[100001];
int main()
{
    fast;
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        st ss;
        cin>>s>>ss;
        if(ss=="WA" && b[s]==0)
        {
            a[s]++;
        }
        else b[s]=1;
    }
    for(int i=1; i<=n; i++)
    {
        if(b[i]==1)
        {
            x++;
            z+=a[i];
        }
    }
    cout<<x<<" "<<z<<endl;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, V, P := getInt(), getInt(), getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})

	th := a[P-1]
	l := 0
	r := N
	for l+1 != r {
		m := (l + r) / 2
		val := a[m] + M
		cnt := M * (V - 1)
		if val < th {
			r = m
			continue
		}
		for i, v := range a {
			if i == m {
				continue
			}
			if i < P && v != th {
				cnt -= M
			} else {
				cnt -= min(M, val-v)
			}
		}
		if cnt <= 0 {
			l = m
		} else {
			r = m
		}
	}
	out(l + 1)
}


Measured memory_bytes: 4196
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  ll h[N];
  for(int i=0;i<N;++i) cin>>h[i];
  ll maxh = 0;
  for(int i=0;i<N;++i) maxh = max(maxh, h[i]);
  ll l=1, r=maxh/B+1, m;
  ll tmp;
  while(l<r) {
    m = (l+r)/2;
    tmp = 0;
    for(int i=0;i<N;++i) {
      if(h[i]-B*m<=0) continue;
      if((h[i]-B*m)%(A-B)==0) tmp += (h[i]-B*m)/(A-B);
      else tmp += (h[i]-B*m)/(A-B)+1;
    }
    if(tmp<=m) r = m;
    else l = m+1;
  }
  cout<<l<<endl;
}



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

ll gcd(ll a, ll b) {
  ll r;
  if (a < b) swap(a, b);

  while (b > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  ll ans = a.at(0);
  for (int i = 0; i < n; i++) {
    ans = gcd(ans, a.at(i));
  }
  cout << ans << endl;
}


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

s1 = input()
s2 = input()

len_1 = len(s1)
len_2 = len(s2)

dp = [[INF]*(len_2+1) for _ in range(len_1+1)]
dp[0][0] = 0

for i in range(1, len_2+1):
	dp[0][i] = dp[0][i-1] + 1

for i in range(1, len_1+1):
	dp[i][0] = dp[i-1][0] + 1



for i in range(len_1):
	for j in range(len_2):
		if s1[i] == s2[j]:
			dp[i+1][j+1] = min(dp[i][j], dp[i+1][j]+1, dp[i][j+1]+1)
		else:
			dp[i+1][j+1] = min(dp[i][j]+1, dp[i+1][j]+1, dp[i][j+1]+1)

#for i in range(len_1 + 1):
#	print(dp[i])

print(dp[len_1][len_2])


Measured memory_bytes: 43192
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, x, min, max;
    cin >> a >> b >> c; 
    if(b < a){
        x = a;
        a = b;
        b = x;
    }
    if(c < b){
        x = b;
        b = c;
        c = x;
    }
    if(b < a){
        x = a;
        a = b; 
        b = x;
    }
    cout << a << " " << b << " " << c;
    cout << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class UndirectedWeightedTree {
  struct Edge {
    int dest, weight;
  };
  struct Result {
    int dest, distance;
  };

  int _E, _V;
  vector<vector<Edge>> adjacentList;

 public:
  int E() { return _E; }

  int V() { return _V; }

  UndirectedWeightedTree(){};
  UndirectedWeightedTree(int V) : _V(V) { adjacentList.resize(V); }

  void addEdge(int u, int v, int w) {
    adjacentList[u].push_back(Edge{v, w});
    adjacentList[v].push_back(Edge{u, w});
    ++_E;
  }

  int diameter() {
    //assert(_E == _V - 1);

    function<Result(int, int)> dfs = [&](int previous, int current) {
      Result r = {current, 0};
      for (Edge& e : adjacentList[current])
        if (e.dest != previous) {
          Result t = dfs(current, e.dest);
          t.distance += e.weight;
          if (r.distance < t.distance) r = t;
        }
      return r;
    };

    Result r = dfs(-1, 0);
    Result t = dfs(-1, r.dest);
    return t.distance;
  }

  void scanFrom(std::istream& strm) {
    strm >> _V;
    adjacentList.resize(_V);
    for (int i = 0; i < _V - 1; ++i) {
      int u, v, w;
      strm >> u >> v >> w;
      addEdge(u, v, w);
    }
  }
};

inline std::istream& operator>>(std::istream& strm, UndirectedWeightedTree& t) {
  t.scanFrom(strm);
  return strm;
}

int main() {
  UndirectedWeightedTree t;
  cin >> t;
  cout << t.diameter() << endl;
  return 0;
}



Measured memory_bytes: 17496
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)



// const ll MOD = 1e18+7; // modification needed.
// const int MAX = 1e5; // modification needed.

// ll fac[MAX], finv[MAX], inv[MAX];

// void cominit(){

//     fac[0]  = fac[1]  = 1;
//     finv[0] = finv[1] = 1;
//     inv[1]  = 1;

//     for(int i=2; i<MAX; i++){
//         fac[i] = fac[i-1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i-1] * inv[i] % MOD;
//     }
// }


// ll com(int n, int k){
//     if(n < k) return 0;
//     if(n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
// }



int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll sum[n+1];
    sum[0] = 0;
    rep(i, n){
        sum[i+1] = sum[i] + a[i];
    }

    // rep(i, n+1){
    //     cout << sum[i] << endl;
    // }

    map<ll, ll> mp;
    rep(i, n+1){
        // cout << sum[i] % m << endl;
        mp[sum[i] % m]++;
    }

    for(auto x : mp){
        // cout << x.first << " " << x.second << endl;
    }

    ll ans = 0;
    for(auto x : mp){

        // cout << x.first << " " << x.second << endl;
        if(x.second < 2) continue;

        ans += x.second*(x.second - 1)/2;
    }    

    cout << ans << endl;

    return 0;
}

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


int main(){
	string S, T;
	cin >> S >> T;
	int N = S.size();
	rep(i,N){
		string U;
		rep(j,N) U += S[(i+j)%N];
		if(U == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;



}










Measured memory_bytes: 3636
l, r = map(int, input().split())

if r//2019 != l//2019:
    print(0)

else:
    lm = list()
    for i in range(l, r):
        for j in range(i+1, r+1):
            lm.append((i*j)%2019)
    print(min(lm))

Measured memory_bytes: 75428
i[100012],d[100012],s,w,n,a,x,y;
main()
{
  for(w=scanf("%d",&n);a++<n;d[y]++)
      scanf("%d%d",&x,&y),i[x]++;
  for(a=2;a<=n+1;w-=d[a++])
    {
      w+=i[a],w>=a?s=a-1:0;
    }
  printf("%d\n",s);
  exit(0);
}

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

int main() {
    int N;
    cin >> N;
    vector <int> l(N);
    vector <int> r(N);
    for (int i=0; i<N; i++) {
        cin >> l.at(i);
        cin >> r.at(i);
    }
    int cnt=0;
    for (int i=0; i<N; i++) {
        cnt = cnt + (r.at(i)-l.at(i));
    }
    cnt += N;
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,x,t,ans;
    scanf("%d%d%d",&n,&x,&t);
    if(n%x==0) ans=(n/x)*t;
    else ans=(n/x+1)*t;
    printf("%d\n",ans);
    return 0;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}

ll judge(ll t, lvec &a){
    ll cnt=0;
    ll cntij=0;
    for (int i = 0; i < a.size(); i++)
    {
        ll s=-1,e=a.size();
        ll j;
        if(a[i] == 0) {
            if (t > 0) {
                cnt+=a.size();
                cntij++;
            }
            continue;
        }
        if(a[i] < 0) swap(s, e);
        while(abs(e-s)>1){
            ll ind = (s+e)/2;
            if(a[i]*a[ind] < t) s=ind;
            else e=ind;
        }
        if(a[i] > 0) {
            cnt+=s+1;
            if(i <= s) cntij++;
        }
        else {
            cnt+=a.size()-s;
            if(i>= s) cntij++;
        }
    }
    return (cnt-cntij)/2;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    lvec a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll s=-1*infll, e=infll;
    ll v;
    while(e-s>1){
        ll t = (e+s)/2;
        v = judge(t, a);
        if(v<k) s=t;
        else e=t;
    }
    
    cout << s << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int N, K;
  int count = 0;

  scanf("%d %d", &N, &K); //NをＫ進数で表す
  while(N > 0){
    N = N/K;
    count++;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll i=0;
	while(a>0 && c>0){
		if(i%2==0){
			c-=b;
		}else{
			a-=d;
		}
		i++;
	}

	if(a<=0){
		cout<< "No";
	}else if(c<=0){
		cout << "Yes";
	}
}

Measured memory_bytes: 3632
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

N,k = inpm()

def solve(n):
    if n <= k:
        return min(n,k-n)
    else:
        return solve(n % k)

ans = solve(N)

print(ans)

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

int main(){
    long long h, n;
    cin >> h >> n;
    long long a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    long long ans[h+1];
    ans[0] = 0;
    for(long long i = 1; i <= h; i++){
        ans[i] = ans[max(i-a[0], 0ll)] + b[0];
        for(int j = 1; j < n; j++){
            ans[i] = min(ans[i],
                    ans[max(i-a[j],0ll)] + b[j] );
        }
    }
    cout << ans[h] << '\n';
}


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

using namespace std;

int k;

void process()
{
    if (k==1 || k==7)
    {
        cout<<1;
        return;
    }
    int s=7;
    for (int i=1;i<=2e8;++i)
    {
        if (s==0)
        {
            cout<<i;
            return;
        }
        s=((s*10)+7)%k;
    }
    cout<<-1;
}

int main()
{
    scanf("%d",&k);
    process();
    return 0;
}


Measured memory_bytes: 3760
#include<cstdio>

int main() {
	//N4记录4的倍数；N2记录2的倍数且不等于4；N1记录其他
	int N=0, N1 = 0, N2 = 0, N4 = 0;
	int tmp;
	scanf("%d", &N);

	for (int i = 0;i < N;i++) {
		scanf("%d", &tmp);
		if (tmp % 4 == 0)
			N4++;
		else if (tmp % 2 == 0) //是2但不是4的倍数
			N2++;
		
	}
	N1 = N - N2 - N4;
	if ((N2 == 0 && N4 >= N1 - 1) || (N2 > 0 && N4 >= N1))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
def read(): return list(map(int, input().split()))


h, w = read()
n = int(input())
A = read()

s = []
for i, a in enumerate(A):
    for j in range(a):
        s.append(str(i + 1))

for i in range(h):
    out = s[i * w: i * w + w]
    if i & 1:
        out = list(reversed(out))

    print(" ".join(out))

Measured memory_bytes: 3828
#include<iostream>
#include<complex>
#include<cstdio>
using namespace std;
typedef complex<double> Point;
typedef complex<double> Vector;

#define EPS 0.00001

Point A, B, C;

void getR(double alpha, double beta, double l, double r, double R, double &ans, bool &suc){
    double a, b, c;
    a = 1.0/((tan(beta)*tan(beta)));
    b = 2*r/(tan(alpha)*tan(beta)) - 2*l/tan(beta) - 4*r;
    c = l*l - 2*r*l/tan(alpha) + r*r/(tan(alpha)*tan(alpha));
    double rr1 = (-b - sqrt(b*b-4*a*c))/(2*a);
    double rr2 = (-b + sqrt(b*b-4*a*c))/(2*a);
    suc = false;
    if ( 0 <= rr1 && rr1 <= R ) { ans = rr1; suc = true;}
    if ( 0 <= rr2 && rr2 <= R ) { ans = rr2; suc = true;}
}

void compute(){
    double a = abs(B - C), b = abs(A-C), c = abs(A-B), r1, r2, r3;
    double s = (a + b + c)/2.0;
    double R = sqrt(s*(s-a)*(s-b)*(s-c))/s;
    double X = acos((c*c + b*b - a*a)/(2*c*b));
    double Y = acos((c*c + a*a - b*b)/(2*c*a));
    double Z = acos((a*a + b*b - c*c)/(2*a*b));
    double l = 0, r = 2*R;
    bool suc1, suc2;
    while(1){
	r1 = (l + r)/2.0;
	getR(X/2, Y/2, c, r1, R, r2, suc1);
	getR(X/2, Z/2, b, r1, R, r3, suc2);
	Vector v1 = A - B;
	Vector v2 = A - C;
	v1 = polar(r2/sin(Y/2), arg(v1) - Y/2) + B; 
	v2 = polar(r3/sin(Z/2), arg(v2) + Z/2) + C; 
	double d = abs(v1 - v2);
	if ( fabs(d - (r2+r3)) < EPS ) break;
	if ( d < r2+r3 || !suc1 || !suc2) l = r1;
	else r = r1;
    }
    
    printf("%.5lf %.5lf %.5lf\n", r1, r2, r3);
}

main(){
    while(1){
	cin >> A.real() >> A.imag();
	cin >> B.real() >> B.imag();
	cin >> C.real() >> C.imag();
	if ( A.real() == 0 && A.imag() == 0 && 
	     B.real() == 0 && B.imag() == 0 && 
	     C.real() == 0 && C.imag() == 0 ) break;
	compute();
    }
}

Measured memory_bytes: 996
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2<< endl;
    return 0;
}

Measured memory_bytes: 256
function main()
  N,K,C=map(x->parse(Int,x),split(readline()))
  S=chomp(readline())
  R=zeros(Int,N)
  i=N
  now=K
  while i>=1
    if S[i]=='o'
      R[i]=now
      now-=1
      i-=C
    end
    i-=1
  end
  now=0
  i=1
  while i<=N
    if S[i]=='o'
      now+=1
      if R[i]==now
        println(i)
      end
      i+=C
    end
    i+=1
  end
end
main()

Measured memory_bytes: 167412
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, a = LI()
    if x < a:
        print(0)
    else:
        print(10)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

int main(){
    int H,W;
    cin >> H >> W;
    while (H!=0 && W!=0){
        for(int i=0;i<H;i++){
            if(i==0 || i==H-1){
                for(int j=0;j<W;j++){
                cout << "#";
            }
                
            }
            else{
                for(int j=0;j<W;j++){
                    if(j==0 || j==W-1){
                        cout << "#";
                    
                    }
                    else{
                        cout << ".";
                    }
                }
                
            }
          	cout << endl;
            
        
    }
    cout << endl;
    cin >> H >> W;
}
  
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int char_to_int(char c) {
    return c - '0';
}

int main() {
    int n, m;
    cin >> n >> m;
    vi s(m);
    vi c(m);
    rep(i, m) {
        cin >> s[i] >> c[i];
    }
    int ans = -1;
    if (n == 1) {
        bool ok = true;
        string num = "0";
        rep(j, m) {
            if (s[j] != 1 || c[j] != 0) ok = false;
        }
        if (ok) {
            ans = 0;
            out(ans);
            return 0;
        }
    }

    repeat(i, pow(10, n - 1), pow(10, n)) {
        bool ok = true;
        string num = to_string(i);
        rep(j, m) {
            if (char_to_int(num[s[j] - 1]) != c[j]) ok = false;
        }
        if (ok) {
            ans = i;
            break;
        }
    }
    out(ans);

    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= new int[a];
        int con;

        for(int k=0;k<a;k++){
             b[k] = sc.nextInt();
        }

        for (int i = 0; i < a/2; i++) {
            con = b[i];
            b[i]=b[a-i-1];
            b[a-i-1]=con;
        }
        for(int j=0;j<a;j++){
           if(j<a-1){
            System.out.print(b[j]+" ");
         }
         if(j==a-1){
                System.out.println(b[j]);
            }
        
        }
        sc.close();

    }  
}


Measured memory_bytes: 26196
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,k=get_i
l=get_i
l.sort!.reverse!
ans=0
k.times do|i|
  ans+=l[i]
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
#include<math.h>

#define TRUE 1
#define FALSE -1

int PrimeNum(int); /*素数判定*/

int main(){
  int i,n,count=0,data;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data);
    if(PrimeNum(data)==TRUE) count++;
  }

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

  return 0;

}
    
int PrimeNum(int data){
  int a;
  
  if(data==2) return TRUE;
    
  else if(data%2==0) return FALSE;

  else{
    a=3;
    while(a<=sqrt(data)){
      if(data%a==0) return FALSE;
      a+=2;
    }
    
  }

  return TRUE;
  
}



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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    ll a,b,c;
    cin >> a >> b >> c;

    ll count=0;
    while(a%2==0 && b%2==0 && c%2==0){
        ll na,nb,nc;
        na=b/2+c/2;
        nb=a/2+c/2;
        nc=b/2+a/2;
        count++;

        if(na%2==1 || nb%2==1 || nc%2==1){
            break;
        }

        if(na==nb && nb==nc){
            count=-1;
            break;
        }

        a=na;
        b=nb;
        c=nc;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    vector<ll> sum(N+1);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum[i+1] = (sum[i] + a[i]) % M;
    }
    // (A_l + ... + A_r) = (A_0 + .. + A_r) - (A_0 + ... + A_{l-1}) mod M == 0;
    // <=> (A_0 + .. + A_r) = (A_0 + ... + A_{l-1}) (mod M)
    map<ll, ll> mp;
    for (int i = 0; i < N+1; i++) mp[sum[i]]++;
    ll ans = 0;
    for (auto m : mp) ans += m.second * (m.second - 1) / 2;
    cout << ans << '\n';
}


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

int main() {

    long long n, m;
    cin >> n >> m;
    long long arr[n];
    for (long long i=0; i<n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    vector<pair<long long, long long> > vc;
    for (long long i=0; i<m; i++) {
        long long b, c;
        cin >> b >> c;
        vc.push_back(make_pair(c, b));
    }
    sort(vc.begin(), vc.end(), greater<pair<long long, long long> >());
    long long pos = 0;
    bool needmore = true;
    for (long long i=0; i<vc.size() && needmore; i++) {
        // current update
        pair<long long, long long> upd = vc[i];
        long long to = upd.first, num = upd.second;
        for (long long curr = pos; curr < pos + num && curr < n; curr++) {
            if (arr[curr] < to) {
                arr[curr] = to;
            }
        }
        pos += num;
        if (pos >= n) {
            needmore = false;
        }
    }
    long long sm = 0;
    for (long long i=0; i<n; i++) {
        sm += arr[i];
    }
    cout << sm;

}

Measured memory_bytes: 3188
D = int(input())#D=365
c = [0] + list(map(int, input().split()))#0<=c<=100
s = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [0] + [int(input()) for _ in range(D)]

M = int(input())
dq = [list(map(int, input().split())) for _ in range(M)]


held = [[0] for _ in range(27)]
def culc_value(t):
    last = [0] * 27
    value = 0
    for d in range(1, D+1):
        type = t[d]
        held[type].append(d)
        value += s[d][type]
        last[type] = d
        for i in range(1, 27):
            value -= c[i] * (d - last[i])
    for i in range(1, 27):
        held[i].append(D+1)
    #print(held)
    return value


v_lastday = []
value = culc_value(t)

for d, q in dq:
    value += - s[d][t[d]] + s[d][q]

    # 変換前のt[d-1]のマイナス計算を直す
    ind = held[t[d]].index(d)
    r = held[t[d]][ind+1]
    l = held[t[d]][ind-1]
    x = r - l
    value -= ((x + 1) * x // 2) * c[t[d]]
    y = d - l
    z = r - d
    value += (((y + 1) * y // 2) + (z + 1) * z // 2) * c[t[d]]

    del held[t[d]][ind]
    t[d] = q
    held[q].append(d)
    held[q] = sorted(held[q])
    #print(held[q])

    # qに変換後のマイナス計算
    ind = held[q].index(d)
    r = held[q][ind+1]
    l = held[q][ind-1]
    x = r - l
    value += ((x + 1) * x // 2) * c[q]
    y = d - l
    z = r - d
    value -= (((y + 1) * y // 2) + (z + 1) * z // 2) * c[q]

    v_lastday.append(value)

for ans in v_lastday:
    print(ans)


Measured memory_bytes: 26300
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

// Convenience function to read a vector of values from standard input
template <typename T>
auto readVector(T N) {
    vector<T> A;
    for (T i = 0; i < N; i++) {
        T Ai;
        cin >> Ai;
        A.push_back(Ai);
    }
    return A;
}

size_t findFirstLess(const vector<int>& current, const vector<int>& h) {
    for (auto i = 0u; i < current.size(); i++) {
        if (current[i] < h[i]) {
            return i;
        }
    }
    return current.size();
}

int solve(const vector<int>& h) {
    auto current = vector<int>(h.size(), 0);
    int n = 0;
    while (current != h) {
        auto l = findFirstLess(current, h);
        while (current[l] < h[l]) {
            current[l]++;
            l++;
        }
        n++;
    }
    return n;
}


// Read parameters from standard input and call main solution function
int main() {
    int N;
    cin >> N;
    auto h = readVector(N);
    cout << solve(h) << endl;
    return 0;
}

Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve()
{
    long double a,b,h,m;cin>>a>>b>>h>>m;
    h+=m/60;
    long double ang1=30.0*h;
    long double ang2=m*6.0;
    long double dif1=abs(ang1-ang2);
    long double dif2=360.0-dif1;
    long double dif=min(dif1,dif2)*1.0;
//    cout<<"dif= "<<dif<<endl;
    double ans2=a*a+b*b-2.0*a*b*cos(dif*PI/180.0);
//    cout<<"ans2= "<<ans2<<endl;
    double ans=sqrt(ans2*1.0);
    cout<<fixed<<setprecision(18)<<ans<<endl;
    return;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
        solve();
    return 0;
}


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

class Main{
    static String ans = "";
    public static void main(String[] args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        char[] c = str.toCharArray();
        for(int i=0;i<c.length;i++){
           solve(c[i]);
        }
        System.out.println(ans);
    }

    static void solve(char x){
        switch(x){
        case '0':
            ans += "0";
            break;
        case '1':
            ans += "1";
            break;
        case 'B':
            if(ans.length() == 0)break;
            ans = ans.substring(0,ans.length()-1);
        }
    }
}

Measured memory_bytes: 8020
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 n: integer;
 r: integer;
begin
 get(n);
 get(r);
 if n>=10 then
  put(r);
 else
  put(r+100*(10-n));
 end if;
end hoge;

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
vector<int> a;
bool search(int sum, int count)
{
    if(count >= a.size())
    {
        return !sum;
    }
    else
    {
        return search(sum, count + 1) || search(sum - a[count], count + 1);
    }
}

int main()
{
    int n, q, b;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        a.push_back(0);
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &b);
        if(search(b, 0))
        {
            printf("yes\n");
        }
        else
        {
            printf("no\n");
        }
        
    }
}


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

int main()
{
    ll n;
    cin>>n;
    ll sum=0,sum3=0,sum5=0,sum15=0;
    sum=(1+n)*n/2;
    if(n>=3) sum3=3*(n/3)+(n/3)*(n/3-1)*3/2;
    if(n>=5) sum5=5*(n/5)+(n/5)*(n/5-1)*5/2;
    if(n>=15) sum15=15*(n/15)+(n/15)*(n/15-1)*15/2;
    sum-=sum3;
    sum-=sum5;
    sum+=sum15;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll            long long
#define pb            emplace_back
#define fi            first
#define se            second
#define mp            make_pair
//#define int           int64_t

using namespace std;

typedef pair<ll, int> pii;
const int N = (int)5e3 + 5;
const ll inf = (ll)1e18;

int n, A, B, a[N], pos[N];
ll f[N][N], mn;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define FileName      "test"
    if(fopen(FileName".inp", "r")) {
       freopen(FileName".inp", "r", stdin);
       freopen(FileName".out", "w", stdout);
    }
    cin >> n >> A >> B;
    fill_n(&f[0][0], N * N, inf);
    for(int i = 1; i <= n; ++i) cin >> a[i], pos[a[i]] = i - 1;
    ///(0, 1], (1, 2], (2, 3], ..., (n - 1, n], (n, n + 1]
    ///to the right A, to the left B
    for(int i = 0; i <= n; ++i) f[1][i] = (i == pos[1]? 0: (i < pos[1]? B: A));
    for(int i = 2; i <= n; ++i) { /// f(i, j) = sort 1 -> i, pos(i) in range (j, j + 1]
        mn = inf;
        for(int j = 0; j <= n; ++j) {
            /// f(i, j) min f(i - 1, k) k < j
            mn = min(mn, f[i - 1][j]);
            f[i][j] = mn + (j == pos[i]? 0: (j < pos[i]? B: A));
        }
    }
    cout << *min_element(f[n], f[n] + n + 1);
}


Measured memory_bytes: 195968
#include <stdio.h>

int main(void){
	int i,j,k,l,m,n;
	while(scanf("%d",&i),i){
		m=n=0;
		for(j=0;j<i;j++){
			scanf("%d%d",&k,&l);
			if(k<l)
				n += k+l;
			else if(k==l)
				m += l, n+= k;
			else
				m += k+l;
		}
		printf("%d %d\n",m,n);
	}
	return 0;
}

Measured memory_bytes: 600
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	ll l = (n * ll(m)) / __gcd(n, m);
	for (int i = 0; i < n; ++i) {
		if ((i * ll(m)) % n == 0) {
			ll j = (i * ll(m)) / n;
			if (j >= 0 and j < m and s[i] != t[j]) {
				cout << "-1";
				return 0;
			}
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S;
ll cnt[2020];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	int N = S.length();

	ll ans = 0;
	cnt[0] = 1;
	int tot = 0;
	int p = 1;
	rrep(i, N - 1, 0) {
		tot = (tot + (S[i] - '0') * p) % 2019;
		
		ans += cnt[tot];

		p = (p * 10) % 2019;
		cnt[tot]++;
	}
	cout << ans << endl;
}







Measured memory_bytes: 3752