akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main() {

    int test, side1, side2, side3;

    scanf("%d",&test);
    for( int i = 1 ; i <= test ; i++ ) {
        scanf("%d %d %d",&side1,&side2,&side3);
        if(side1 == sqrt((side2)*(side2) + (side3)*(side3)))
            printf("YES\n");
        else if(side2 == sqrt((side1)*(side1) + (side3)*(side3)))
            printf("YES\n");
        else if(side3 == sqrt((side1)*(side1) + (side2)*(side2)))
            printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}

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

int main(){
  long N,T; cin >> N >> T;
  vector<long> t(N,0); for(int i = 0; i < N; i++) cin >> t.at(i);
  
  long ans = T;
  for(int i = 0; i < N - 1; i++){
    if(t.at(i) + T > t.at(i+1)) ans += t.at(i+1) - t.at(i);
    else ans += T;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAXN = 200005;

long long pow(int a, int b, int MOD) {
  long long x=1,y=a; 
  while(b > 0) {
    if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
  }
  return x;
}
 
long long InverseEuler(int n, int MOD) {
  return pow(n,MOD-2,MOD);
}
 
LL f[MAXN];
LL mod = 1000000007;
long long C(int n, int r, int MOD) {
  return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int n;
vector<int> G[MAXN];

int sizee[MAXN];
LL ans[MAXN];
LL wyn[MAXN];

void dfs(int w, int o) {
  sizee[w] = 1;
  int s = 0;
  LL ret = 1;
  for (auto u : G[w]) {
    if (u != o) {
      dfs(u, w);
      sizee[w] += sizee[u];
      s += sizee[u];
      ret *= ans[u];
      ret %= mod;
    }
  }

  for (auto u : G[w]) {
    if (u != o) {
      ret *= C(s, sizee[u], mod);
      ret %= mod;
      s -= sizee[u];
    }
  }
  ans[w] = ret;
}

void dfsPrz(int w, int o) {
  int s = 0;
  LL ret = 1;
  for (auto u : G[w]) {
    // if (u != o) {
      debug(w, sizee[u], ans[w], u);
      s += sizee[u];
      ret *= ans[u];
      ret %= mod;
    // }
  }

  for (auto u : G[w]) {
    // if (u != o) {
      ret *= C(s, sizee[u], mod);
      ret %= mod;
      s -= sizee[u];
    // }
  }
  wyn[w] = ret;

  LL pom = ans[w];
  ans[w] = ret;
  for (auto u : G[w]) {
    if (u != o) {
      LL oldS = sizee[w];
      LL oldAns = ans[w];

      sizee[w] = n - sizee[u];
      ans[w] *= InverseEuler(C(n - 1, sizee[u], mod), mod);
      ans[w] %= mod;

      ans[w] *= InverseEuler(ans[u], mod);
      ans[w] %= mod;
      
      dfsPrz(u, w);

      ans[w] = oldAns;
      sizee[w] = oldS;
    }
  }
  ans[w] = pom;
}

int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  f[0] = 1;
  f[1] = 1;
  for (int i = 2; i <= 200000; ++i) {
    f[i]= (f[i-1]*i) % mod;
  }

  dfs(1, -1);
  dfsPrz(1, -1);

  for (int i = 1; i <= n; ++i) {
    cout << wyn[i] << endl;
  }
}


Measured memory_bytes: 19444
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int W,H,N;
	pair<int,int> now;
	pair<int,int> point[1000];
	int result = 0;

	cin >> W >> H >> N;
	for(int a = 0;a<N;a++)
	{
		cin >> point[a].first >> point[a].second;
	}

	now = point[0];

	for(int a = 0;a<N;a++)
	{
		if(point[a].first >= now.first)
		{
			if(point[a].second >= now.second)
			{
				result += max(point[a].first-now.first,point[a].second-now.second);
			}
			else
			{
				result += point[a].first-now.first+now.second-point[a].second;
			}
		}
		else
		{
			if(point[a].second >= now.second)
			{
				result += now.first-point[a].first+point[a].second-now.second;
			}
			else
			{
				result += max(now.first-point[a].first,now.second-point[a].second);
			}
		}

		now = point[a];
	}

	cout << result << endl;

	/*getchar();
	getchar();*/

	return 0;
}

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

using namespace std;

int p_offset = 8150;

bool solve(vector<int> &va, int offset, int p, vector<vector<int>> &memo) {
  if (offset == va.size()) {
    return p == 0;
  }

  if (memo[offset][p + p_offset] == -1) {
    bool ans1, ans2;
    ans1 = solve(va, offset + 1, p - va[offset], memo);
    ans2 = solve(va, offset + 1, p + va[offset], memo);
    memo[offset][p + p_offset] = ans1 || ans2;
  }

  return memo[offset][p + p_offset];
}

int main(int argc, const char *argv[]) {
  string s;
  int x, y;
  cin >> s >> x >> y;

  s += 'T';

  int cnt = 0;
  bool is_x = true, skip = true;
  vector<int> x_mov, y_mov;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'F') {
      cnt++;
      continue;
    }

    if (is_x) {
      x_mov.push_back(cnt);
    } else {
      y_mov.push_back(cnt);
    }

    is_x = !is_x;
    cnt = 0;
  }

  vector<vector<int>> memo1(x_mov.size() + 1, vector<int>(p_offset * 2, -1)),
      memo2(y_mov.size() + 1, vector<int>(p_offset * 2, -1));
  bool ans_x, ans_y;

  ans_x = solve(x_mov, 1, x - x_mov.front(), memo1);
  ans_y = solve(y_mov, 0, y, memo2);

  if (ans_x && ans_y) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 509172
li = [int(input()) for i in range(5)]
al = []
ans = 0
for i in li:
  if i % 10 != 0:
    al.append(i % 10) 
  ans += i // 10
ans *= 10
if len(al) > 0:
  ans += min(al) + (len(al) - 1)*10
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INF 2100000000

int H,A[MAX+1];
void maxH(int i){
  int l,r,lst,cd;
  l = 2*i; r = 2*i+1;

  //左の子、自身、右の子で値が最大のノードを選ぶ。
  if(l <= H && A[l] > A[i]) lst = l;
  else lst = i;
  if(r <= H && A[r] > A[lst]) lst = r;

  if(lst != i){
    cd = A[i]; A[i] = A[lst]; A[lst] = cd;
    maxH(lst);
  }
}

int extract(){
  int maxN;
  if(H < 1) return -INF;
  maxN = A[1];
  A[1] = A[H--];
  maxH(1);
  return maxN;
}

void increkey(int h,int key){
  int cd;
  if(key < A[h]) return;
  A[h] = key;
  while(h>1 && A[h/2] < A[h]){
    cd = A[h/2]; A[h/2] = A[h]; A[h] = cd;
    h = h/2;
  }
}

void insert(int key){
  H++;
  A[H] = -INF;
  increkey(H,key);
}

int main(){
  int key;
  char cmd[10];

  while(1){
    scanf("%s",cmd);
    if(cmd[0] == 'e' && cmd[1] == 'n') break;
    if(cmd[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }else printf("%d\n",extract());
  }
  return 0;
}



Measured memory_bytes: 5608
<?php
$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$ans = 0;

for ($i = 1; $i < $n; $i++) {
    $t = 0;
    $x = [];

    for ($j = 0; $j < $i; $j++) {
        $y = [];
        if (isset($x[$s[$j]])) {
            continue;
        }

        $x[$s[$j]] = 1;

        for ($k = $i; $k < $n; $k++) {
            if (isset($y[$s[$k]])) {

                continue;
            }

            $y[$s[$k]] = 1;

            if ($s[$j] === $s[$k]) {
                $t++;
            }
        }
    }

    if ($t > $ans) {
        $ans = $t;
    }
}

echo $ans . PHP_EOL;

Measured memory_bytes: 4728
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N*3];
		for(int i=0; i<N*3; i++)
			a[i] = sc.nextInt();
		
		Arrays.sort(a);
		long ans = 0;
		
		for(int i=0; i<N; i++)
			ans += a[N*3-(i+1)*2];
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 91804
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();		
        Long b = sc.nextLong();	
		if(a>1 && b>1){System.out.println((a*b)/2 + (a*b)%2);}
        else{System.out.println(1);}
	}
}


Measured memory_bytes: 21844
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
ts = []
for i in range(n):
    a, b = map(int, readline().split())
    ts.append((b, a))
ts = sorted(ts, key=lambda x:(x[0], -x[1]))

now = 0
for t in ts:
    now += t[1]
    if now > t[0]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 66648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> str(n);
  rep(i,n) cin >> str[i];
  
  sort(str.begin(),str.end());
  
  int ans=n;
  rep(i,n-1){
    if(str[i]==str[i+1]){
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9544
#include <iostream>
#include <algorithm>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
#include <string>
#include <cmath>
#include <vector>
using namespace std;



/*
5 25000
1 20 1000 -> 20で20*100+1000 =  3000
2 40 1000 -> 40で40*200+1000 =  9000
3 50 1000 -> 50で50*300+1000 = 16000
4 30 1000 -> 30で30*400+1000 = 13000
5  1 1000  ->  1で 1*500+1000 =  1500

400*15 = 6000
300*35 = 9000+1500
つまり4を30回3を35回5を1回で66回
66回らしい
*/




int main(int argc, char const *argv[]) {
    int D, G;
    int p[10];
    int c[10];
    int bonus[10];
    cin >> D >> G;
    vector<int> v(D);
    for (int i = 1; i <= D; i++){
        cin >> p[i] >> c[i];
    }
    for (int i = 1; i <= D; i++){
        bonus[i] = i*100*p[i] + c[i];
        v[i-1] = i;
    }


    int min = 1000000;
    do {
        int cnt = 0;
        int sum = 0;
        int last_i = -1;
        for(int i = 0; i < v.size(); i++){
            if (sum + bonus[v[i]] <= G){
                sum += bonus[v[i]];
                cnt += p[v[i]];
                //cout << sum << "," << cnt << endl;
                last_i = i;
            } else {
                last_i = i;
                //cout << last_i << endl;
                break;
            }
        }
        if (last_i >= 0){
            for (int i = 0; i < p[v[last_i]]; i++){
                if (sum + v[last_i]*100 <= G){
                    sum += v[last_i]*100;
                    cnt++;
                    //cout << sum << ":" << cnt << endl;
                } else {
                    if(sum < G){
                        sum += v[last_i]*100;
                        cnt++;
                    }
                }
            }
            if (min > cnt) min = cnt;
        }
    } while(next_permutation(v.begin(), v.end()));

    cout << min << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)


int main() {
	lint N, K;
	cin >> N >> K;
	vector<lint>P(N);
	rep(i, N) {
		cin >> P[i];
	}
	P.push_back(0);
	reverse(P);
	vector<lint>S(N+1);
	S[0] = P[0];
	for (int i = 1; i < N+1; i++) {
		S[i] = S[i - 1] + P[i];
	}
	lint ans = 0;
	lint sum = 0;
	for (int i = 0; i < N - K + 1;i++) {
		sum = S[i + K] - S[i];
		ans = max(ans, sum);
	}
	ans += K;
	if (ans % 2 == 0) {
		cout << ans / 2 << endl;
	}
	else {
		cout << ans / 2 << ".5" << endl;
	}
}

Measured memory_bytes: 4964
a = list(map(int, input().split()))
a.sort()
b = (a[2]-a[0])//2
c = (a[2]-a[1])//2

if (a[2]-a[0])%2 == 0 and (a[2]-a[1])%2 == 0:
    print(b+c)
if (a[2]-a[0])%2 != 0 and (a[2]-a[1])%2 != 0:
    print(b+c+1)
if (a[2]-a[0])%2 == 0 and (a[2]-a[1])%2 != 0:
    print(b+c+2)
if (a[2]-a[0])%2 != 0 and (a[2]-a[1])%2 == 0:
    print(b+c+2)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1 << endl;
	}
	else {
		cout << a * b << endl;
	}
}

Measured memory_bytes: 3656
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    S = args[1]

    A = ord('A')
    AtoZ = ord('Z')-A+1

    ret = ''
    for c in S:
        ret += chr(((ord(c)-A+n) % AtoZ)+A)
    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    int ans[4][3][10] = {0};
    rep(i, 0, n) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        ans[b - 1][f - 1][r - 1] += v;
    }
    rep(i, 0, 4) {
        rep(j, 0, 3) {
            rep(k, 0, 10) {
                cout << " " << ans[i][j][k];
            }
            cout << endl;
        }
        if (i <= 2) {
            rep(l, 0, 20) cout << '#';
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3096
#include "iostream"

using namespace std;

long long int X, A, B;

int main(){
	cin >> X >> A >> B;
	if (A >= B) {
		cout << "delicious" << endl;
	}
	else if (A < B && B<= A + X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b, c, x;
  int j, k, l;
  int cout = 0;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &x);
  
  for(j=0; j<=a; j++){
    for(k=0; k<=b; k++){
      for(l=0; l<=c; l++){
    if((x/50) == 10*j + 2*k + l) 
          cout++;
      }
    }
  }
  printf("%d\n", cout);
  return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main()
{
    string sa, sb, sc;
    cin >> sa;
    cin >> sb;
    cin >> sc;
    
    const char a = 'a';
    const char b = 'b';
    const char c = 'c';
    map<char, int> m;
    m[a] = 0;
    m[b] = 0;
    m[c] = 0;
    map<char, string> ss;
    ss[a] = sa;
    ss[b] = sb;
    ss[c] = sc;
    char t = a;
    map<char, char> ret;
    ret[a] = 'A';
    ret[b] = 'B';
    ret[c] = 'C';
    
    while(true)
    {
        if(m[t] >= ss[t].length())
        {
            cout << ret[t] << endl;
            return 0;
        }
        int index = m[t];
        string current = ss[t];
        m[t]++;
        t = current[index];
    }
    return 0;
}

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

int main() {
	int n, k, ans;
    cin >> n >> k;
    map<int, int> m;
    while(n--){
        int t;
        cin >> t;
        m[t]++;
    }
    
    ans = 0;
    if(m.size() > k){
        vector<int> v;
        for(auto c:m){
            v.push_back(c.second);
        }
        sort(v.begin(), v.end());
        for(int i=0; i<m.size()-k; i++){
            ans += v[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  vector<string> input = {
    "dream",
    "dreamer",
    "erase",
    "eraser"
  };

  reverse(all(S));
  REP(i, input.size()) reverse(all(input[i]));

  int pos = 0;
  string ans = "YES";
  bool flag = false;
  while(true) {
    flag = false;
    for(int i = 0; i < input.size(); ++i) {
      if(input[i] == S.substr(pos, input[i].size())) {
        pos += input[i].size();
        flag = true;
      }
    }
    if(flag == false) {
      ans = "NO";
      break;
    }
    if(pos >= S.size()) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
typedef long long int ll;

ll min(ll a, ll b){return a>b?b:a;}

int main(void){
    int n;
    scanf("%d", &n);
    ll h[n];
    for(int i=0; i<n; i++){scanf("%lld", &h[i]);}

    ll dp[n];
    for(int i=0; i<n; i++){dp[i] = LLONG_MAX;}

    // 貰うdp
    // for(int i=0; i<n; i++){
    //     if(i == 0){
    //         dp[i] = 0;
    //     }
    //     if(i == 1){
    //         dp[i] = llabs(h[i]-h[i-1]);
    //     }
    //     if(i > 1){
    //         dp[i] = min(dp[i], dp[i-1]+llabs(h[i]-h[i-1]));
    //         dp[i] = min(dp[i], dp[i-2]+llabs(h[i]-h[i-2]));
    //     }
    // }

    // 配るdpで解く
    dp[0] = 0;
    for(int i=0; i<n-1; i++){
        dp[i+1] = min(dp[i+1], dp[i]+llabs(h[i]-h[i+1]));
        if(i < n-2){
            dp[i+2] = min(dp[i+2], dp[i]+llabs(h[i]-h[i+2]));
        }
    }

    printf("%lld\n", dp[n-1]);
    return 0;
}

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

int main(void){
    int flag = 1;
    char a, b, c; cin >> a >> b >> c;
    char d, e, f; cin >> d >> e >> f;
    
    if(a != f){
        flag = 0;
    }

    if(b != e) flag = 0;

    if(c != d) flag = 0;
    if(flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a;
int main()
{
    cin >> a;
    ll t = 1, n = a, s = 0;
    while(n / 10){
        n /= 10;
        t *= 10;
        s += 9;
    }
    if((n + 1)*t - 1 <= a){
        s += n;
    }
    else s+= (n - 1);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  ll a,b,x;
  cin >> a >> b >> x;
  ll l = (a+x-1)/x;
  ll r = b/x;
  cout << r-l+1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	for(int i=1;i<S.length();i++) {

    		String buf=S.substring(0,S.length()-i);

    		if(Judge(buf)==true) {
    			System.out.println(S.length()-i);
    			return;
    		}

    	}

    }

    public static boolean Judge(String str) {


    	String[] buf=str.split("");

    	if(buf.length%2==1) {
    		return false;
    	}else {

    		for(int i=0;i<buf.length/2;i++) {

    			if(!buf[i].equals(buf[i+buf.length/2])) {
    				return false;
    			}
    		}

    	}

    	return true;

    }

}



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

//1
//1 1
//1 2 1
//1 3 3 1
//1 4 6 4 1
//
//aC0 = 1
//aCa = 1
//aCb = a-1Cb + a-1Cb-1


int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<long long> v(N);
    for(int i=0; i<N; i++) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());
 
    long long ans = 0;
    for(int i=0; i<A; i++) ans += v[i];
    cout << fixed << setprecision (32) << static_cast<double>(ans) / A << endl;

    long long comb[100][100];
    for(int i=0; i<=50; i++){
        comb[i][0] = 1;
        comb[i][i] = 1;
    }
    for(int i=1; i<=50; i++)
        for(int j=1; j<i; j++)
            comb[i][j] = comb[i-1][j] + comb[i-1][j-1];

    int cnt1 = 0, cnt2 = 0;
    if(v[0] != v[A-1]){
        for(int i=0; i<A; i++)
            if(v[i] == v[A-1])
                cnt1++;
        for(int i=0; i<N; i++)
            if(v[i] == v[A-1])
                cnt2++;
        cout << comb[cnt2][cnt1] << endl;
        return 0;
    }else{
        for(int i=0; i<N; i++)
            if(v[i] == v[A-1])
                cnt2++;
        long long num = 0;
        for(int i=A; i<=B; i++)
            num += comb[cnt2][i];
        cout << num << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL GCD(LL a, LL b) {
	if (b == 0)return a;
	return GCD(b, a % b);
}

int main(void)
{
	LL N, X;
	cin >> N >> X;
	vector<LL>dif;
	for (int i = 0; i < N; ++i) {
		LL x;
		cin >> x;
		dif.push_back(abs(x - X));
	}
	LL ans = dif[0];
	for (int i = 0; i < N; ++i) {
		ans = GCD(ans, dif[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }

        vector<vector<int>> v;
        for (int i = 0; i < n; ++i) {
            int m;
            cin >> m;
            vector<int> t;
            for (int j = 0; j < m; ++j) {
                int p;
                cin >> p;
                t.push_back(p);
            }
            sort(begin(t), end(t));
            v.push_back(t);
        }
        int k;
        cin >> k;
        vector<int> ks;
        for (int i = 0; i < k; ++i) {
            int l;
            cin >> l;
            ks.push_back(l);
        }
        sort(begin(ks), end(ks));

        int count = 0;
        int id = -1;
        for (int i = 0; i < n; ++i) {
            if (includes(begin(v[i]), end(v[i]), begin(ks), end(ks))) {
                count += 1;
                id = i;
            }
        }

        if (count == 1) {
            cout << (id + 1) << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

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


Measured memory_bytes: 3640
use std::io::*;

fn read() -> String {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
	b
}

fn main() {
	let s = read();
	let ss = s.chars();
	let mut arr = [false; 3];

	for c in ss.into_iter() {
		match c {
			'a' => arr[0] = true,
			'b' => arr[1] = true,
			'c' => arr[2] = true,
			_ => ()
		}
	}
	if arr[0] && arr[1] && arr[2] {
		println!("Yes");
	} else {
		println!("No");
	}
}


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

int main() {
	int h, w; cin >> h >> w;
	vector<vector<char> > s(h + 1, vector<char>(w + 1));
	REP(i, h) REP(j, w)
		cin >> s[i+1][j+1];

	vector<vector<int> > dp(h + 1, vector<int>(w + 1, INT_MAX));
	dp[1][1] = (s[1][1] == '#');
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) {
		if (j != 1)
			dp[i][j] = min(dp[i][j], dp[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#'));
		if (i != 1)
			dp[i][j] = min(dp[i][j], dp[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#'));
	}
	cout << dp[h][w] << '\n';
	return 0;
}

Measured memory_bytes: 3700
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MAGIC_MAX		1000									// 最大魔法数
#define D_HP_MAX		20005									// 最大HP
#define D_USE_MAX		10000									// 最大消費

// 内部構造体 - 魔法情報
typedef struct Magic {
	int miDmg;													// ダメージ
	int miUse;													// 消費
} Magic;

// 内部変数
static FILE *szpFpI;											// 入力
static Magic sz1Magic[D_MAGIC_MAX];								// 魔法
static int siMCnt;												// 魔法数
static int si1Use[D_HP_MAX];									// 消費[HP]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// HP・魔法数 - 取得
	int liHP;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liHP, &siMCnt);

	// 魔法 - 取得
	for (i = 0; i < siMCnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &sz1Magic[i].miDmg, &sz1Magic[i].miUse);
	}

	// 消費[HP] - 初期値
	si1Use[0] = 0;
	for (i = 1; i < D_HP_MAX; i++) {
		si1Use[i] = D_HP_MAX * D_USE_MAX;
	}

	// 消費[HP] - セット
	for (i = 0; i < siMCnt; i++) {
		for (j = 0; j < D_HP_MAX - sz1Magic[i].miDmg; j++) {
			int liTo = j + sz1Magic[i].miDmg;
			int liUse = si1Use[j] + sz1Magic[i].miUse;
			if (si1Use[liTo] > liUse) {
				si1Use[liTo] = liUse;
			}
		}
	}

	// 最小値 - 取得
	int liMin = INT_MAX;
	for (i = liHP; i < D_HP_MAX; i++) {
		if (liMin > si1Use[i]) {
			liMin = si1Use[i];
		}
	}

	return liMin;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 256
import Control.Monad

merge :: String -> String -> String
merge [] ys = ys
merge (x:xs) ys = x : merge ys xs

line :: String
line = merge (repeat '#') (repeat '.')

solve :: [Int] -> IO ()
solve [h, w] = do
    mapM_ (\i -> putStrLn $ if i `mod` 2 == 0 then take w (drop 1 line) else take w line) [1 .. h]
    putStrLn ""

main :: IO ()
main = getContents >>= mapM_ solve . takeWhile (\[h, w] -> h /= 0 || w /= 0) . map (map read . words) . lines

Measured memory_bytes: 4920
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        StringBuilder S = new StringBuilder(sc.next());
        int count = 0;

        for (int i = 1; i < S.capacity() - 16; i++) {
            if (S.charAt(i) == S.charAt(i - 1)) {
                count++;
            }
        }

        System.out.println(Math.min(count + K * 2, N - 1));
    }
}

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

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

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

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

/// /////////////////////////////////////////////
/// <summary> 
/// 10桁の整数を、桁ごとに分解する
/// </summary> 
/// /////////////////////////////////////////////
int a[10] = { 0 };
void abc(
	int x//10桁の整数
) {
	a[0] = x % 10;
	for (int i = 1; i < 10; i++) {
		a[i] = (int)(x / pow(10, (double)i)) % 10;
	}
}

int main() {
	int N, A, B;
	int n;
	int sum = 0;//各桁の和
	int cnt = 0;
	int ans = 0;
	scanf("%d%d%d", &N, &A, &B);

	for (n = 1; n <= N; n++) {
		sum = 0;
		//abc(765);
		abc(n);
		for (int i = 0; i < 5; i++) {
			//printf("%d\t", a[i]);
			sum += a[i];
		}
		if (A <= sum && B >= sum) {
			cnt += n;
		}
	}
	ans = cnt;
	printf("%d\n", ans);


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

Measured memory_bytes: 384
N,K=gets.split.map(&:to_i)
steps=gets.split.map(&:to_i)
dp = []
dp << 0
dp << (steps[0] - steps[1]).abs
pos = 2
while pos < N
    k = 1
    min = nil
    while k <= K
        break if (pos - k) < 0
        tmp = dp[pos-k] + (steps[pos] - steps[pos-k]).abs
        min = tmp if min.nil?
        min = tmp if tmp < min
        k += 1
    end

    dp << min
    pos += 1
end
puts dp[N-1]


Measured memory_bytes: 8964
h, w = map(int, input().split())
s = [input() for _ in range(h)] 

d = {(i, j):c for i, row in enumerate(s) for j, c in enumerate(row)}

def next_to_black(i, j):
    directions = ((-1, 0), (1, 0), (0, -1), (0, 1))
    surroundings = ((i + a, j + b) for a, b in directions)
    colors = (d.get(cell, '.') for cell in surroundings)
    return any(color == '#' for color in colors)

black_coords = (coord for coord, c in d.items() if c == '#')
paintable = all(next_to_black(*coord) for coord in black_coords)
print('Yes' if paintable else 'No')

Measured memory_bytes: 3316
#include<bits/stdc++.h> 
#include<string>
#include<math.h>
using namespace std; 
#define ll long long int
int main() 
{ 
 ll n;
 cin>>n;
 ll z;
 z=n%500;
 ll z1;
 z1=z/5;
 cout<<(n/500)*500*2+z1*5;

 return 0;
} 



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll c,a,b;
    cin >> c;
    if(c==1){cout << "Hello World"<< endl;}
    if(c==2){
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int X;
  cin >> X;
  vector<bool> directions(180, true);
  long double x = 0;
  long double y = 0;
  long double PI = acos(-1);
  int ans = 0;
  int theta = 0;
  rep(i, 500)
  {
    x += cos(theta * PI / 180);
    y += sin(theta * PI / 180);
    ans++;
    theta += X;
    if (x < 0.000000000001 && y < 0.000000000001)
      break;
  }
  cout << ans << endl;
  return 0;
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=2e5+5;
unordered_map<int,int>c;
int a[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	rep(i,1,n)++c[a[i]=read()];
	int ans=0;
	per(j,30,0)
	{
		rep(i,1,n)
		{
			int x=a[i],y=(1<<j)-x;
			if(y>=0&&x>=y&&c[x]&&c[y]>(x==y))
			{--c[x];--c[y];++ans;}
		}
	}
	cout<<ans;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>>data(M);
  for(int i=0;i<M;i++){
    int L;
    cin >> L;
    for(int j=0;j<L;j++){
      int x;
      cin >> x;
      x--;
      data.at(i).push_back(x);
    }
  }
  
  vector<int>tukuka(M);
  for(int i=0;i<M;i++){
    cin >> tukuka.at(i);
  }
  
  int ans=0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bool a=true;
    for(int j=0;j<M;j++){
      int count=0;
      for(int k=0;k<data.at(j).size();k++){
        if(((1<<data.at(j).at(k))&tmp)!=0) count++;
      }
      if(count%2!=tukuka.at(j)){
        a=false;
      }
    }
    if(a){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef vector<vector<ll>> matrix;
const ll INF = 1e18;
const int MAX = 2e5+4;
const int MOD = 1e9+7;
//vector<int> dp(MAX);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x,a;
	cin >> x >> a;
	if(x<a) cout << 0;
	else cout << 10;
	return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B;
    cin >> A >> B;
    if(10 <= A + B) {
        cout << "error" << endl;
    }else{
        cout << A + B << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(size_t i = 0; i < 3; i++) {
        ans += S[i] == T[i] ? 1 : 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);

#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>

#define loop(l, r) for(int i = l;i <= r;++i)
#define loopj(l, r) for(int j = l;j <= r;++j)
#define loopStep(l, r, step) for(int i = l;(step >= 0 ? (i <= r) : (i >= r));i += step)
#define loopStepj(l, r, step) for(int j = l;(step >= 0 ? (j <= r) : (j >= r));j += step)
#define loopRange(el, container) for(auto &el : container)

#define test int t;cin >> t; while(t--)

#define ENDL << "\n"

using namespace std;

int main()
{
	fast;

	set<int> si;
	loop(1, 9)	
		loopj(1, 9)
			si.insert(i*j);

	int n;
	cin >> n;

	(si.find(n) != si.end()) ? cout << "Yes\n" : cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> c(m,0);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            c[a-1]++;
        }
    }
    int ans=0;
    rep(i,m){
        if(c[i]==n){
            ans++;
        }
    }
    
    cout << ans;
    
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,d;
  cin>>n>>d;
  ll ans=0;
  REP(i,n){
    ll x,y;
    cin>>x>>y;
    ld dist=sqrt(x*x+y*y);
    if(dist<=ld(d))
      ans++;
  }

  cout<<ans<<endl;
}



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

int main()
{
	int a;
	long long int kaijou[21];

	for (int i = 0; i < 21; i++) kaijou[i] = 1;

	cin >> a;
	for (int i = 1; i <= a; i++)
	{
		kaijou[i] = kaijou[i - 1] * i;
	}
	cout << kaijou[a] << endl;
	return 0;
}


Measured memory_bytes: 3096
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << a + 1 - b << endl;
  return 0;
}


Measured memory_bytes: 256
def f(b,n):
    ans = 0
    if n<b:
        return n
    else:
        return f(b,n//b)+n%b
def main():
    n=int(input())
    s=int(input())
    if n==s:
        return n+1
    if n <s:
        return -1

    nsq=int(n**0.5+1)
    for b in range(2,nsq+1):
        if f(b,n)==s:
            return b
    m=n-s
    msq=int(m**0.5+1)
    for p in range(msq,0,-1):
        if m%p:
            continue
        b=m//p+1
        if f(b,n)==s:
            return b
    return -1

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int t[] = new int[n + 1];
		int x[] = new int[n + 1];
		int y[] = new int[n + 1];

		for (int i = 1; i <= n; i++) {
			t[i] = scanner.nextInt();
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
		}

		for (int i = 0; i < n; i++) {
			int time = t[i + 1] - t[i];
			int dis = Math.abs(x[i + 1] - x[i]) + Math.abs(y[i + 1] - y[i]);
			if (dis <= time && dis % 2 == time % 2)
				continue;
			else {
				System.out.println("No");
				return;
			}
		}

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


Measured memory_bytes: 92956
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,fl=0 ; cin>>a>>b>>c ;
    /*for(int x=1 ; x<=100000 ; x++)
    {
        if((b*x+c)%a==0) {fl=1 ; break ;}
    }
    if(fl) cout<<"YES"<<endl ;
    else cout<<"NO"<<endl ;*/
        if(c%__gcd(a,b)==0) cout<<"YES"<<endl ;
    else cout<<"NO"<<endl ;
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		c();
	}
		
	private static void c() {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] candies = new int[n];
		int res = Integer.MAX_VALUE;
 		for (int i = 0; i < n; i++) {
 			candies[i] = sc.nextInt();
		}
 		
 		for (int i = 0; i < n - k + 1; i++) {
 			int left = Math.abs(candies[i]) + (candies[i + k - 1] - candies[i]);
 			int right = Math.abs(candies[i + k - 1]) + (candies[i + k - 1] - candies[i]);
 			int tmp = Math.min(left, right);
 			res = Math.min(res, tmp);
 		}
 		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36500
/*
=============================================================

------------------Welcome To My Code-------------------------

---------Ankit Kumar || IIITBH || CSE || 2018-2022-----------

=============================================================
*/

#include <bits/stdc++.h>
using namespace std;

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
map<ll, ll>::iterator itr;
vector<ll>::iterator it, it1;
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;


        ll k,x,y,z,a;

        cin>>x>>k>>a;
        x=abs(x);

        if(k<=x/a)
        {
            z=x-(k*a);
        }

        else
        {
            y=x/a;
            k=k-y;
            x=x-(a*y);

            if(k%2==0)
                z=x;
            else
                z=x-a;
        }

        cout<<abs(z);
        nl;


}


Measured memory_bytes: 3596