akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

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

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int sum(int x)
{
	int r = 0;
	for (; x > 0; x /= 10)
	{
		r += x % 10;
	}

	return r;
}

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

	int res = inf;
	for (int i = 1; i < n ; i++)
	{
		int j = n - i;

		res = min(res, sum(i) + sum(j));
	}

	println(res);
}


Measured memory_bytes: 256
k = gets.to_i

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

p a[k - 1]


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

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();

type Result = "AC" | "WA" | "TLE" | "RE";

{
  const n = nCin();
  const ss = range(n).map(() => cin() as Result);
  const map = (() => {
    const map: {
      [R in Result]: number;
    } = {
      AC: 0,
      WA: 0,
      TLE: 0,
      RE: 0,
    };
    ss.forEach((s) => map[s]++);
    return map;
  })();
  (Object.keys(map) as Result[]).map((s) => `${s} x ${map[s]}`).forEach((msg) => console.log(msg));
}


Measured memory_bytes: 42192
#include <iostream>

using namespace std;

const int N = 1e5+20;

typedef long long ll;

ll n;
ll a[N];

int main()
{
    cin >> n;

    for (int i = 1; i <= n; i ++ ) cin >> a[i];

    ll sum1 = 0,sum2 = 0;//前i项和
    ll cnt1 = 0,cnt2 = 0;//操作次数

    if(a[1] == 0)
    {
        sum1 = 1;
        sum2 = -1;
        cnt1 = 1;
        cnt2 = 1;
    }
    else if(a[1] > 0)
    {
        sum1 = a[1];
        sum2 = -1;
        cnt2 = a[1] + 1;
    }
    else if(a[1] < 0)
    {
        sum1 = 1;
        sum2 = a[1];
        cnt1 = abs(a[1]) + 1;
    }//判断a[1]的符号

    for (int i = 2; i <= n; i ++ )
    {
        if(sum1 > 0)//上一个和为sum1
        {
            if(sum1+a[i] < 0)
            {
                sum1 += a[i];
            }
            else
            {
                cnt1 += abs(sum1+a[i])+1;
                sum1 = -1;
            }
        }
        else//sum1 < 0的情况
        {
            if(sum1+a[i] > 0)
            {
                sum1 += a[i];
            }
            else
            {
                cnt1 += abs(sum1+a[i]) + 1;
                sum1 = 1;
            }
        }
    }

    for (int i = 2; i <= n; i ++ )
    {
        if(sum2 > 0)//上一个和为sum2
        {
            if(sum2+a[i] < 0)
            {
                sum2 += a[i];
            }
            else
            {
                cnt2 += abs(sum2+a[i])+1;
                sum2 = -1;
            }
        }
        else//sum2 < 0的情况
        {
            if(sum2+a[i] > 0)
            {
                sum2 += a[i];
            }
            else
            {
                cnt2 += abs(sum2+a[i]) + 1;
                sum2 = 1;
            }
        }
    }
    cout << min(cnt1,cnt2) <<endl;
    return 0;
}

Measured memory_bytes: 1024
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a < b < c:
    print('Yes')
elif a < c < b:
    print('No')
elif b < a < c:
    print('No')
elif b < c < a:
    print('No')
elif c < a < b:
    print('No')
else:
    print('No')

Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef long long int ll;

ll n;

ll fblen(ll n){
	ll d=10;
	ll ans = 0;
	ll under = 0;
	for(ll i=1;under < n;i++){
		ll to;
		if((under+1)*10-1 <= n) to = (under+1)*10-1;
		else to = n;
		ll FizzBuzz = to/15 - under/15;
		ll Fizz = to/3 - under/3 - FizzBuzz;
		ll Buzz = to/5 - under/5 - FizzBuzz;
		ll normal = to - under - Fizz - Buzz - FizzBuzz;
		ans += Fizz*4 + Buzz*4 + FizzBuzz*8 + normal*i;
		under = to;
	}
	return ans;
}
string toStr(ll n){
	return n ? (toStr(n/10) + (char)(n%10+'0')) : "";
}
main(){
	while(cin >> n){
		ll l=1,r=n;
		while(l<r-1){
			ll mid = (r+l)/2;
			if(fblen(mid) < n) l = mid;
			else r = mid;
		}
		string s="";
		for(ll i=l;i<l+20;i++) s += i%15 ? (i%3 ? (i%5 ? toStr(i) : "Buzz") : "Fizz") : "FizzBuzz";
		cout << s.substr(n-fblen(l-1)-1, 20) << endl;
	}
	return 0;
}

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

int main()
{
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	int N, M;
	scanf("%d%d", &N, &M);
	vvi graph(N);
	for (int i{}; i < M; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		u--; v--;
		graph[u].push_back(v);
	}
	int s, t;
	scanf("%d%d", &s, &t);
	s--; t--;
	using i3 = std::array<int, 3>;
	vvi dist(N, vi(3, 1 << 30));
	dist[s][0] = 0;
	std::priority_queue<i3, std::vector<i3>, std::greater<i3>> dij;
	// {dist, place, mod3}
	dij.push({0, s, 0});
	while (!dij.empty())
	{
		auto now{dij.top()};
		dij.pop();
		if (now[0] > dist[now[1]][now[2]]) continue;
		for (auto& e: graph[now[1]])
			if (now[0] + 1 < dist[e][(now[2] + 1) % 3])
			{
				dist[e][(now[2] + 1) % 3] = now[0] + 1;
				dij.push({now[0] + 1, e, (now[2] + 1) % 3});
			}
	}
	if (dist[t][0] == (1 << 30)) puts("-1");
	else printf("%d\n", dist[t][0] / 3);

	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class  Main {

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

		int firstSize = in.nextInt();
		int[] first = new int[firstSize];
		for (int i = 0; i < firstSize; i++) {
			first[i] = in.nextInt();
		}

		int secondSize = in.nextInt();
		int count = 0;
		for (int i = 0; i < secondSize; i++) {
			count += contains(in.nextInt(), first, 0, firstSize - 1);
		}
		System.out.println(count);
	}

	/**
	 * returns 1 if the given element is in the given list between the given indices
	 * and zero otherwise
	 */
	public static int contains(int ele, int[] nums, int low, int high) {

		int mid = low + (high-low)/2;
		if (low > high) {
			return 0;
		} else if (nums[mid] == ele) {
			return 1;
		} else if (nums[mid] < ele) {
			return contains(ele, nums, mid + 1, high);
		} else {
			return contains(ele, nums, low, mid - 1);
		}

	}

}


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

string key(int a, int b) {
  return to_string(a) + "-" + to_string(b);
}

bool find(set<string> &edges, int a, int b) {
  if (edges.count(key(a, b))) return true;
  if (edges.count(key(b, a))) return true;
  return false;
}

int main() {
  int N, M;
  cin >> N >> M;
  set<string> edges;
  vector<int> nodes(N);
  for (int i = 0; i < N; i++) {
    nodes.at(i) = i + 1;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    edges.insert(key(a, b));
  }
  int path = 0;
  sort(nodes.begin(), nodes.end());
  do {
    int reached = 0;
    for (int i = 1; i < N; i++) {
      if (find(edges, nodes.at(i - 1), nodes.at(i))) reached++;
    }
    if (nodes.at(0) == 1 && reached+1 >= N) path++;
  } while (next_permutation(nodes.begin(), nodes.end()));
  cout << path << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define nmax 200010

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007
#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int n, d, a;
ll sum[nmax];
pii h[nmax];

int find_hgh(int l, int r, ll val)
{
    int sol = l;

    while (l <= r)
    {
        int m = (l + r) / 2;

        if (h[m].fst <= val) { sol = m; l = m + 1; }
        else
            r = m - 1;
    }

    return sol;
}

int main()
{
    scanf("%d %d %d", &n, &d, &a);

    for (int i = 1; i <= n; i++) {

        scanf("%d %d", &h[i].fst, &h[i].snd);

        h[i].snd = (h[i].snd / a) + (h[i].snd % a > 0);
    }

    sort(h + 1, h + n + 1);

    ll answer = 0;
    ll cur_sum = 0;

    for (int i = 1; i <= n; i++) {

        ll cent = h[i].fst + d;
        int r = find_hgh(i, n, cent + d);

        cur_sum += sum[i];

        ll val = max(0LL, h[i].snd - cur_sum);

        if (val > 0) {

            answer += val;
            cur_sum += val;

            sum[r + 1] -= val;
        }
    }

    printf("%lld", answer);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

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

int main(){
  int n,k,r,s,p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  int ans=0;
  for(int i=0;i<n;i++){
    if(i<k){
      if(t[i]=='r') ans+=p;
      else if(t[i]=='s') ans+=r;
      else ans+=s;
    }
    else{
      if(t[i]!=t[i-k]){
        if(t[i]=='r') ans+=p;
        else if(t[i]=='s') ans+=r;
        else ans+=s;
      }
      else if(i<n-k){
        if(t[i]==t[i+k]) t[i]='c';
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int a,b;
    cin >> a >> b;
    cout << (b + (a - 3)) / (a - 1) << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

int par[1000];

struct Edge {
  int s, t, c;
};

bool operator<(const Edge &a, const Edge &b) {
  return a.c < b.c;
}

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

void unite(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return;

  par[u] = v;
}

int main(){
  cin.sync_with_stdio(false);
  int n, m;
  while(cin >> n >> m, n | m) {
    iota(par, par + n, 0);
    vector<Edge> e(m);
    rep(i, m) {
      cin >> e[i].s >> e[i].t >> e[i].c;
      e[i].s--, e[i].t--;
    }

    sort(all(e));

    vector<int> cost;
    rep(i, m) {
      if (find(e[i].s) != find(e[i].t)) {
        unite(e[i].s, e[i].t);
        cost.pb(e[i].c);
      }
    }

    cout << cost[cost.size() / 2] << endl;
  }

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  float ans;
  if (N%2 == 0)
    ans = 0.5;
  else{
    ans = N+1;
    ans /= 2*N;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3760
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    print(A.back() - A.front());
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(int argc, char const *argv[])
{
    long N,M;

    cin>>N>>M;

    long ans=1;

    for(int i=1;i<=N;++i){
        ans*=i;
        ans=ans%(long)(1e9+7);
    }

    for(int i=1;i<=M;++i){
        ans*=i;
        ans=ans%(long)(1e9+7);
    }


    if(N==M){
        cout<<(ans*2)%(long)(1e9+7)<<endl;
    }else if(N-1==M||N+1==M){
        cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }




    return 0;
}


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

using namespace std;

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

	for (double x = 1.0; x <= 50000; x += 1.0) {
		int X = floor(x * 1.08);
		if (X == N) {
			cout << int(x) << endl;
			return 0;
		}
	}
	cout << ":(" << endl;

	return 0;
}


Measured memory_bytes: 256
def is1974(n1: int, n2: int, n3: int, n4: int) -> bool:
    a = sorted([n1, n2, n3, n4])
    return a[0] == 1 and a[1] == 4 and a[2] == 7 and a[3] == 9


if __name__ == "__main__":
    n1, n2, n3, n4 = [int(s) for s in input().split()]

    if is1974(n1, n2, n3, n4):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std; void solve(); int main()
{ cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }
typedef long long ll;
template<class T>bool chmin(T &a, const T &b)
{ if (a<b) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b)
{ if (b<a) { a=b; return true; } return false; }
//----------------------------------------------------------------

int gcd(int m, int n)
{
    if(m>n) swap(m,n);
    if(m==0) return n;
    return gcd(n%m, m);
}

void solve()
{
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int g=gcd(a,b);
    if(n>2)
    {
        int c; cin >> c;
        g=gcd(g,c);
    }
    vector<int> ans;
    for(int i=1; i*i<=g; i++)
    {
        if(g%i==0)
        {
            ans.push_back(i);
            if(i*i!=g ) ans.push_back(g/i);
        }
    }
    sort(ans.begin(), ans.end());
    for (auto n : ans) cout << n << "\n";
}


Measured memory_bytes: 3212
package main

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

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())
  counters := make([][]int, n)
  for i:=0; i<n; i++ {
    counters[i] = make([]int, 26)
    sc.Scan()
    txt := sc.Text()
    for _, v := range txt {
      counters[i][byte(v)-[]byte("a")[0]] +=1
    }
  }
  for i := 0; i < 26; i++ {
    min := 50
    for j := 0; j < n; j++ {
      min = minInt(counters[j][i], min)
    }
    for j := 0; j < min; j++ {
      fmt.Print(string(byte(i)+[]byte("a")[0]))
    }
  }
  fmt.Println()
}


Measured memory_bytes: 640
S=input()

if S.startswith("keyence") or S.endswith("Keyence"):
  print("YES")
elif S.startswith("k") and S.endswith("eyence"):
  print("YES")
elif S.startswith("ke") and S.endswith("yence"):
  print("YES")
elif S.startswith("key") and S.endswith("ence"):
  print("YES")
elif S.startswith("keye") and S.endswith("nce"):
  print("YES")
elif S.startswith("keyen") and S.endswith("ce"):
  print("YES")
elif S.startswith("keyenc") and S.endswith("e"):
  print("YES")
else:
  print("NO")
  

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

int main()
{
	string a, s, c;

	cin >> a >> s >> c;
	cout << "A" << s[0] << "C" << endl;
}

Measured memory_bytes: 256
while True:
    h, w = list(map(int, input().split()))
    if h==0 and w==0:
        break
    s0 = '#'*w
    print(s0)
    for i in range(1,h-1):
        s = '#'+'.'*(w-2)+'#'
        print(s)
    print(s0)
    print()
    


Measured memory_bytes: 5608
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        for(int i=n;i<=10000000000;i++)
        {
        	ll x=i;
        	ll w=0;
        	for(int j=2;j<=sqrt(x);j++)
        	{
        		if(x%j==0)
        			w=1;
        	}
        	if(w==0)
        	{
        		cout<<x<<endl;
        		return 0;
        	}
        }
    }
    return 0;
}

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

const int MOD = 1e9 + 7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


const int MAX = 2000; // 二項係数を求める最大の自然数
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 combination(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() {
  int s;
  cin >> s;

  comInit();

  mint ans = 0;
  for (int i = 1; i <= s/3; i++) {
    ans += combination(s - 2*i - 1, i - 1);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
signed main(){

  int n,li[3]={};
  cin>>n;

  for(int i=0;i<n;i++){

    int a;
    cin>>a;

    li[a%3]++;

  }

  if(!(li[1]>0 || li[2]>0)){

    cout<<1<<endl;
    return 0;
  }

  int ans=li[0];

  if(li[1]==li[2]){

    ans+=li[1]*2;

  }

  else if(li[1]>li[2]){

    ans+=li[2]*2;
    li[1]-=li[2];
    ans+=min(li[1],3);

  }

  else if(li[1]<li[2]){

    ans+=li[1]*2;
    li[2]-=li[1];
    ans+=min(li[2],3);

  }

  cout<<ans<<endl;

  return 0;

}



Measured memory_bytes: 3092
#include<cstdio>
using namespace std;
int n,a[105],ans[105],m;
int main()
{
	scanf("%d",&n);m=n;for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=n;i;--i) {
		for(int j=n;j;--j)
			if(a[j]==j) {for(int k=j;k<n;++k) a[k]=a[k+1];--n;ans[i]=j;goto loop;}
			else if(a[j]>j) {printf("-1");return 0;}
		printf("-1");return 0;
		loop:;
	}
	for(int i=1;i<=m;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 128
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // 入力を受け取る
    let mut antennas: Vec<usize> = Vec::with_capacity(5);
    for i in 0..5 {
        let mut tmp: usize = iter.next().unwrap().parse().unwrap();
        antennas.push(tmp);
    }
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mut isConnection: bool = true;
    for i in 0..4 {
        for j in (i+1)..(4+1) {
            if (antennas[j] - antennas[i]) > k {
                isConnection = false;
            }
        }
    }

    if isConnection {
        println!("{}", "Yay!");
    } else {
        println!("{}", ":(");
    }
}

Measured memory_bytes: 4352
let quick_sort (a : (int * char * int) array) cmp =
  let rec partition p r =
    let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec exchange i j =
      if j >= r then (swap (i + 1) r; i + 1)
      else if cmp a.(j) a.(r) <= 0 then (swap (i + 1) j; exchange (i + 1) (j + 1))
      else exchange i (j + 1)
    in exchange (p - 1) p
  and doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let stable_p (a : (int * char * int) array) n =
  let rec doit i =
    if i = n - 1 then true
    else if (fun (xi, _, xd) (yi, _, yd) -> xd = yd && xi > yi) a.(i) a.(i+1) then false
    else doit (i + 1)
  in doit 0

let () =
  let n = read_int () in
  let a = Array.init n (fun i -> Scanf.scanf "%c %d\n" (fun c d -> (i, c, d))) in
  quick_sort a (fun (_, _, x) (_, _, y) -> compare x y);
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 8776
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<lint> s(1 << n);
  for(int i = 0; i < (1 << n); i++) cin >> s[i];
  sort(RALL(s));
  s.push_back(-1); //番兵
  priority_queue<lint> pq;
  pq.push(1 << n); //連結成分の個数が大きい順に入っている

  int id = 0;
  while(s[id] != -1) {
    int num = s[id];
    int cnt = 0;
    while(s[id] == num) {
      cnt++;
      id++;
    }

    if(cnt > pq.size()) {
      cout << "No" << endl;
      return 0;
    }
    
    vector<lint> cs;
    while(cnt--) {
      lint c = pq.top();
      cs.push_back(c);
      pq.pop();
    }

    for(int i = 0; i < cs.size(); i++) {
      lint c = cs[i] / 2;
      while(c) {
        pq.push(c);
        c /= 2;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 7292
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

signed main() {
	string S;
	cin >> S;

	int ret = INT_MAX;
	rep(i, S.size() - 2) {
		int tmp = stoi(S.substr(i, 3));
		ret = min(ret, abs(753 - tmp));
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int k, a ,b;
    cin>>k>>a>>b;
    for(int i = k ; i <= b ; i+=k ) {
        if(i  >=a && i <=b) {
            cout<<"OK\n";
            return 0;
        }
    }
    cout<<"NG\n";
    return 0;
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N;
  cin >> N;
  ll T = N;
  ll P = 0;
  string ans;
  while (N > 26) {
    N = N / 26;
    P++;
  }
  ll MOD = 0;
  for (ll i = 1; i < P; i++) {
    ll tmp = 1;
    for (ll j = 1; j <= i; j++) {
      tmp *= 26;
    }
    MOD += tmp;
  }
  // cout << P << " " << MOD << " " << T << endl;

  while (T > 26) {
    int m = T % 26;
    if (m == 0) {
      ans += 'z';
      T--;
    } else
      ans += 'a' + (m - 1);
    T /= 26;
  }
  if (T == 0)
    ans += 'z';
  else
    ans += 'a' + (T - 1);

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3628
N = int(input())

dicts = {}
for i in range(N):
    key, value = input().split()
    value = int(value)
    if key not in dicts:
        dicts[key] = [[value, i+1]]
    else:
        dicts[key].append([value, i+1])

dicts = sorted(dicts.items())
for values in dicts:
    for item in sorted(values[1], reverse=True):
        print(item[1])


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int INF = 1000000;



int N, u, v;
vector<vector<int>> to(100001);    
vector<int> dist(100001, INF);  //! dist from node u

void dfs(int c) 
{
    for (int n: to[c]) {
        if (dist[n] == INF) {
            dist[n] = dist[c] + 1;
            dfs(n);
        }
    }
}

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

    cin >> N >> u >> v;

    rep(i, N-1) {
        int A, B;
        cin >> A >> B;
        to[A].push_back(B);
        to[B].push_back(A);
    }

    dist[u] = 0;
    dfs(u);

    int preX = -1;
    int x = u; //! mid point between Mr Takakashi and Mr Aoki, where Mr Takahashi goes first
    int preMove = 0;
    int postMove = 0;
    if (dist[v] % 2 == 0) {
        postMove = 1;
    }
    if (2 < dist[v]) {
        //! if dist is greater than 2, Mr Takahashi goes to the mid point first
        preMove = (dist[v]-1) / 2;
        x = v;
        while (preMove < dist[x]) {
            for (int n : to[x]) {
                if (dist[n] < dist[x]) {
                    preX = x;
                    x = n;
                    break;
                }
            }
        }
    }

    if (preX < 0) {
        while (dist[x] < dist[v]) {
            for (int n : to[v]) {
                if (dist[n] < dist[v]) {
                    preX = v;
                    v = n;
                    break;
                }
            }
        }
    }

    dist = vector<int>(100001, INF);
    dist[x] = 0;
    dist[preX] = 0;
    dfs(x);

    int longest = 0;
    for (int n = 1; n <= N; ++n) {
        if (dist[n] != INF) {
            longest = max(longest, dist[n]);
        }
    }

    LL ans = preMove + longest + postMove;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8576
/*
ID: jayyesh
LANG: C++                 
*/

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int a = s.length();
    for(int i=0;i<a;i++)
        cout << "x";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    string tate,yoko;
    while(h!=0){
    
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
        cout << "#";
    }
    cout <<endl;
    }
    cout << endl;
    cin >> h >> w;
}
return 0;
}



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

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

using Int = long long;
const int mo = 1e9+7;

int N;
int counter[65]; // counter[i] := 右からi bit目の1の数

signed main()
{
    cin >> N;

    rep(i, N) {
        Int A; cin >> A;
        rep(j, 61) {
            if ((A >> j) & 1) counter[j]++;
        }
    }

    Int ans = 0;

    rep(i, 61) {
        ans += (1ll << i) % mo * counter[i] % mo *  (N - counter[i]);
        ans %= mo;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1};
int dy[]={0,1,0,-1,1,1,};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int ans=h2*60+m2-(h1*60+m1);
  ans-=k;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] sArray = S.toCharArray();
		StringBuffer ans = new StringBuffer();
		for (int i = 0; i < sArray.length; i++) {
			if ((i + 1) % 2 != 0) {
				ans.append(sArray[i]);
			}
		}
		System.out.println(ans.toString());
		sc.close();
	}
}

Measured memory_bytes: 26196
O=input("")
E=input("")
s=[]
lo=len(O)
le=len(E)
if(lo<le):
    p=lo
else:
    p=le
for i in range(p):
    s.append(O[i])
    s.append(E[i])

if(lo==le):
    print(''.join(s))
elif(lo<le):
    s.append(E[le-1])
    print(''.join(s))
else:
    s.append(O[lo-1])
    print(''.join(s))


Measured memory_bytes: 3064
#![allow(unused)]

use std::{cell, cmp, collections, fmt, ops};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[cfg(feature = "debug")]
macro_rules! dbg {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! dbgln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! dbg {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! dbgln {
    ($($args:tt)*) => {};
}

mod num {
    //
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

mod bits {
    pub fn is_high(bits: u64, pos: u64) -> bool {
        bits & (1 << pos) != 0
    }
}

fn main() {
    input!(s: String);
    let ans = if s.len() == 2 {
        s.chars().collect::<String>()
    } else {
        s.chars().rev().collect()
    };
    println!("{}", ans);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


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

typedef long long ll;
typedef pair<int, int> pii;

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

	int n;
	cin >> n;

	vector<int> deg(n);

	for (int i = 1; i < n; i++) {
		int x;
		cin >> x;

		deg[x - 1]++;
	}

	for (int i = 0; i < n; i++) {
		cout << deg[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>

int main(int argc, char *argv[]) {
    int Distance, Time , Speed;
    scanf("%d %d %d", &Distance, &Time, &Speed);
    if(Distance <=Time*Speed){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;cin>>k>>n;
  int tmp;
  int ans=0;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
    tmp=a.at(i+1)-a.at(i);
    ans=max(ans,tmp);
  }
  tmp=a.at(n-1)-a.at(0);
  if(tmp>k/2)
    tmp=k-tmp;
  ans=max(ans,tmp);
  cout <<k-ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    char pic[500][500], rpic[500][500], bpic[500][500];
    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            cin >> pic[i][j];
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            if((i%2==0 && j<w-1)||j==0)rpic[i][j]='#';
            else rpic[i][j]='.';
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            if((i%2==1 && j>0)||j==w-1)bpic[i][j]='#';
            else bpic[i][j]='.';
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            if(pic[i][j]=='#'){
                rpic[i][j]='#';
                bpic[i][j]='#';
            }
        }
    }

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            cout << rpic[i][j];
        }
        cout << endl;
    }
    cout << endl;

    for(int i=0; i<h;i++){
        for(int j=0; j<w;j++){
            cout << bpic[i][j];
        }
        cout << endl;
    }
    cout << endl;
}


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

int lowerBounds(int* a,int key,int length){
    // 存在しない場合
    if(a[length - 1] < key) return length;
    int left = 0;
    int right = length;
    int center;
    int targetIndex = 0;
    
    while(1){
        center = (left + right) / 2;
        if(a[center] == key){
            targetIndex = center;
            break;
        }
        else if(a[center] > key){
            right = center;
        }else{
            left = center + 1;
        }
        if(left >= right){
            targetIndex = right;
            break;
        }
    }

    while(targetIndex > 0){
        if(a[targetIndex - 1] < key){
            break;
        }
        targetIndex--;
    }

    return targetIndex;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,n2,key;
    cin >> n;
    int a[n];
    for (int i = 0;i < n;++i) {
        cin >> a[i];
    }
    cin >> n2;
    for(int i = 0;i < n2;++i){
        cin >> key;
        cout << lowerBounds(a,key,n) << endl;
    }
}



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

long a[222222];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        scanf("%ld", a + i + 1), a[i + 1] += a[i];
    long r = a[n];
    for(int i = 0; i <= n; i++)
        r = min(r, abs(a[i] * 2 - a[n]));
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int n = getInt();
		int m = getInt();
		Console.WriteLine((n-1) * (m-1));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int getInt(){ return int.Parse(getArg()); }
	public static long getLong(){ return long.Parse(getArg()); }
	public static double getDouble(){ return double.Parse(getArg()); }
	public static string getString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
using Graph = vector<vector <int>>;


int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    vector<long long> hi;
    for(int i=0; i<n; i++){
        long long h;
        cin >> h;
        hi.push_back(h);
    }
    Graph G(n);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> mh(n, true);
    for(int i=0; i<n; i++){
        long long max = hi[i];
        for(auto ni : G[i]){
            if(hi[ni] >= max){
              mh[i] = false;
              break;
            }
        }
    }
    for(int i=0; i<n; i++){
        if(mh[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9236
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(input.readLine());
	long x=1;

	for(int i=n;i>0;i--)
	    {
		
		x*=i;
	    }
	
	System.out.println(x);
    }
}

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

int main()
{
    string s;
    cin >> s;
    bool ok = true;
    for (int i = 1; i <= s.size(); i++)
    {
        char c = s.at(i - 1);
        if (c == 'U' || c == 'D')
        {
            continue;
        }
        if (i % 2 && c != 'R')
        {
            ok = false;
        }
        if (i % 2 == 0 && c != 'L')
        {
            ok = false;
        }
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[15],str2[15],str3[15];
	scanf("%lld%lld%lld",&n,&m,&k);
	
	if (m - n == k - m) {
		printf("YES");
		return 0;
	}
	printf("NO");
}


Measured memory_bytes: 128
#include<stdio.h>
int b[1000];
int c[1000];
int d[1000];
int e[1000];
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<a;i++)scanf("%d%d%d%d",b+i,c+i,d+i,e+i);
        int p,q,r,s;
        scanf("%d%d%d%d",&p,&q,&r,&s);
        bool ok=false;
        for(int i=0;i<a;i++){
            if(c[i]<=p&&d[i]<=q&&e[i]<=r&&4*c[i]+9*d[i]+4*e[i]<=s){
                ok=true;
                printf("%d\n",b[i]);
            }
        }
        if(!ok)printf("NA\n");
    }
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#ifdef LOCAL
#define debug(x) cerr << '[' << #x << " = " << (x) << "]\n"
#else
#define debug(x)
#endif
ll dp[100001];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,w;cin>>n>>w;
	rep(i,0,n){
		int a,b;cin>>a>>b;
		per(j,1,w+1){
			if(j-a>=0)dp[j]=max(dp[j],b+dp[j-a]);
			else break;
		}
	}
	cout<<dp[w]<<'\n';
}

Measured memory_bytes: 4408
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cctype>
#include <vector>
#include <algorithm>
#include <string>

std::vector<std::string> ops = {"+-", "*"};

intmax_t parse_int(std::string const& s, size_t& i) {
  intmax_t res = s[i]-'0';
  while (isdigit(s[++i])) res = res*10 + s[i]-'0';
  return res;
}

intmax_t parse(std::string const& s, size_t& i, size_t preced = 0) {
  if (preced == ops.size()) {
    if (isdigit(s[i])) return parse_int(s, i);
    assert(false);
  }

  intmax_t res = parse(s, i, preced+1);
  while (i < s.length()) {
    char op = s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    intmax_t tmp = parse(s, ++i, preced+1);
    if (op == '+') {
      res += tmp;
    } else if (op == '-') {
      res -= tmp;
    } else if (op == '*') {
      res *= tmp;
    }
  }
  return res;
}

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s = buf;

  intmax_t d;
  scanf("%jd", &d);

  intmax_t res1, res2;
  {
    size_t i = 0;
    res1 = parse(s, i);
  }
  ops = std::vector<std::string>{"+-*"};
  {
    size_t i = 0;
    res2 = parse(s, i);
  }

  // fprintf(stderr, "%jd %jd\n", res1, res2);

  if (res1 == d) {
    if (res2 == d) {
      puts("U");
    } else {
      puts("M");
    }
  } else {
    if (res2 == d) {
      puts("L");
    } else {
      puts("I");
    }
  }
}



Measured memory_bytes: 2800
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n; cin >> n;
  double res = 0;
  for(int i = 0; i < n; i++) {
    double t; cin >> t;
    t = 1.0 / t;
    res += t;
  }
  res = 1.0 / res;
  cout << fixed << setprecision(10) << res << "\n";
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $S);
if ($S === 'SUN') {
    echo(7).PHP_EOL;
} elseif ($S === 'MON') {
    echo(6).PHP_EOL;
} elseif ($S === 'TUE') {
    echo(5).PHP_EOL;
} elseif ($S === 'WED') {
    echo(4).PHP_EOL;
} elseif ($S === 'THU') {
    echo(3).PHP_EOL;
} elseif ($S === 'FRI') {
    echo(2).PHP_EOL;
} elseif ($S === 'SAT') {
    echo(1).PHP_EOL;
}


Measured memory_bytes: 4604
/**
   _           _
  / /         \ \
 / /  _   _  _ \ \
< < (_) (_) (_) > >
 \ \           / /
  \_\         /_/

    Nerede Gitsen Çukur Orda
**/

#include<bits/stdc++.h>
#include<fstream>
///#include<conio.h>
///#include "windows.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define Zohiri_dzd cout.tie(NULL);
#define Belafz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define quluq return 0;
using namespace std ;

    const ll N = 1e4 + 0.000001 ;

int main ()
{
    Zohiri_dzd
    Belafz
    CODER
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///4294967295
    ///4294967295
    map < ll , ll > mp ;
    for (ll i = 1 ; i <= 101 ; i ++ )
    {
        for (ll j = 1 ; j <= 101 ; j ++ )
        {
            for (ll k = 1 ; k <= 101 ; k ++ )
            {
                ll cnt ;
                cnt = i * i + j * j + k * k ;
                cnt += i * j + i * k + j * k ;
                mp[cnt] ++ ;
            }
        }
    }
    ll n ;
    cin >> n ;
    for (ll i = 1 ; i <= n ; i ++ )
        cout << mp[i] << endl ;
}
///MaaN studios
///Eco students


Measured memory_bytes: 6056
def main():
    h, w, m = map(int, input().split())
    lsh = [0] * h
    lsw = [0] * w

    bom = set()
    for _ in range(m):
        m1, m2 = map(int, input().split())
        lsh[m1 - 1] += 1
        lsw[m2 - 1] += 1
        bom.add((m1-1, m2-1))

    lshmax = max(lsh)
    lswmax = max(lsw)

    hin = [i for i in range(h) if lsh[i] == lshmax]
    win = [i for i in range(w) if lsw[i] == lswmax]

    for i in hin:
        for j in win:
            if (i, j) not in bom:
                print(lshmax + lswmax)
                exit(0)
    else:
        print(lshmax + lswmax -1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 83484
def m():
    S = input()
    a = 'keyence'
    x = 0
    if S[0] == 'k':
        for i in range(len(S)):
            if S[i] == a[x]:
                x += 1
                continue
            else:
                break
        if S[-7+x:] == a[-7+x:]:
            return 'YES'
        else:
            return 'NO'


    else:
        if a == S[-7:]:
            return 'YES'
        else:
            return 'NO'



print(m())

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

int main(void) {
	double PI = atan(1) * 4;
	double x = 0, y = 0;
	int X;
	int angle = 0;
	int K = 0;
	if (scanf("%d", &X) != 1) return 1;
	do {
		angle = (angle + X) % 360;
		x -= sin(angle * PI / 180);
		y += cos(angle * PI / 180);
		K++;
	} while (fabs(x * x + y * y) > 1e-7);
	printf("%d\n", K);
	return 0;
}


Measured memory_bytes: 2468