akhauriyash/Code-Regression huggingface dataset:
(function() {
  var isInRange, isNum, reader;

  isNum = function(n) {
    return n.match(/(-|)\d{1,4}/);
  };

  isInRange = function(n) {
    return n >= -1000 && n <= 1000;
  };

  reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  reader.on('line', function(line) {
    var a, b, sp;
    sp = line.split(/\s/);
    a = isNum(sp[0]) ? parseInt(sp[0], 10) : void 0;
    b = isNum(sp[1]) ? parseInt(sp[1], 10) : void 0;
    if (isInRange(a) && isInRange(b)) {
      if (a > b) {
        return console.log("a > b");
      } else if (a < b) {
        return console.log("a < b");
      } else {
        return console.log("a == b");
      }
    }
  });

}).call(this);

Measured memory_bytes: 15880
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(A: int, V: int, B: int, W: int, T: int):
    if V<=W:
        print(NO)
        return

    if abs(A-B) / (V-W) <= T:
        print(YES)
    else:
        print(NO)
    return 

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, V, B, W, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int n = 0, max = 0;
    for(int i = 0; i < S.length(); i++){
      if(S.charAt(i) == 'A' || S.charAt(i) == 'C'
        	|| S.charAt(i) == 'G' || S.charAt(i) == 'T'){
        n++;
      }else{
        n = 0;
      }
      
      max = n > max ? n : max;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

ll f(ll n)
{
  ll mask = 1;
  ll c = n + 1;
  ll val = 0;
  int k = 0;
  if (c % 4 == 2 || c % 4 == 3)
  {
    val++;
  }
  k = 1;
  while ((n >> (k - 1)) > 0)
  {
    ll tmp = (c % (mask << (k + 1))) - (mask << k);

    if (tmp > 0 && tmp % 2 == 1)
    {
      val += (mask << k);
    }
    k++;
  }
  return val;
}

int main()
{
  ll mask = 1;
  // a,bは40桁で抑えられる
  ll a, b;
  cin >> a >> b;
  if (a == b)
  {
    cout << a << endl;
    return 0;
  }
  cout << (f(a - 1) ^ f(b)) << endl;
}

Measured memory_bytes: 256
S=str(input())  #文字列の入力
S=S.replace("A","x")
S=S.replace("T","x")
S=S.replace("G","x")
S=S.replace("C","x")
for i in range(0,2,1):
  if S.count("xxxxxxxxxx")!=0:
    print(10)
    break
  elif S.count("xxxxxxxxx")!=0:
    print(9)
    break
  elif S.count("xxxxxxxx")!=0:
    print(8)
    break
  elif S.count("xxxxxxx")!=0:
    print(7)
    break
  elif S.count("xxxxxx")!=0:
    print(6)
    break
  elif S.count("xxxxx")!=0:
    print(5)
    break
  elif S.count("xxxx")!=0:
    print(4)
    break
  elif S.count("xxx")!=0:
    print(3)
    break
  elif S.count("xx")!=0:
    print(2)
    break
  elif S.count("x")!=0:
    print(1)
    break
  else:
    print(0)
    break

Measured memory_bytes: 3064
#include <stdio.h>
#define N 100001
int n;
int A[N];
int num[N];
char B[N];
int Partition(int, int);
void Quick_Sort(int, int);
int main(){
	int i;
	int p;
	int tmp=1;
	int r;
	scanf("%d\n", &n);
	for( i=0; i<n; i++ ){
		scanf("%c %d\n", &B[i],&A[i]);
		num[i]=i+1;
	}
	p=0;
	r=n-1;
	Quick_Sort(p, r);
	for( i=1; i<n; i++ ){
		if( A[i] == A[i-1] && num[i] < num[i-1] ){
			tmp = 0;
			break;
		}
	}
	if( tmp == 1 )printf("Stable\n");
	else if( tmp == 0 ) printf("Not stable\n");
	for( i=0; i<n; i++ ) printf("%c %d\n",B[i], A[i]);
	return 0;
}
int Partition(int p, int r){
	int i;
	int j;
	int tmp1;
	int tmp3;
	char tmp2;
	int x;
	x=A[r];
	i=p-1;
	for( j=p; j<=r-1; j++ ){
		if( A[j] <= x ){
			i++;
			tmp1=A[j];
			A[j]=A[i];
			A[i]=tmp1;

			tmp2=B[j];
			B[j]=B[i];
			B[i]=tmp2;

			tmp3 = num[j];
			num[j]=num[i];
			num[i]=tmp3;
		}
	}
	tmp1=A[r];
	A[r]=A[i+1];
	A[i+1]=tmp1;

	tmp2=B[r];
	B[r]=B[i+1];
	B[i+1]=tmp2;

	tmp3=num[r];
	num[r]=num[i+1];
	num[i+1]=tmp3;
	return i+1;
}
void Quick_Sort(int p, int r){
	int q;
	if( p < r ){
		q = Partition(p,r);
		Quick_Sort(p, q-1);
		Quick_Sort(q+1, r);
	}
}

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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (s.at(i) == s.at(j)) {
        cnt++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (s.at(i) == t.at(j)) {
        cnt--;
      }
    }
    if (ans < cnt) {
      ans = cnt;
    }
    cnt = 0;
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] march = new int[5];
        
        for (int i = 0; i < n; i++) {
            String s = br.readLine();
            if (s.charAt(0) == 'M') march[0]++;
            if (s.charAt(0) == 'A') march[1]++;
            if (s.charAt(0) == 'R') march[2]++;
            if (s.charAt(0) == 'C') march[3]++;
            if (s.charAt(0) == 'H') march[4]++;
        }
        
        long ans = 0;
        for (int i = 0; i < 5; i++) {
            for (int j = i+1; j < 5; j++) {
                for (int k = j+1; k < 5; k++) {
                    ans += (long)march[i]*march[j]*march[k];
                }
            }
        }
        
        System.out.println(ans);
    }
}





Measured memory_bytes: 29700
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>

int main()
{
long long int n;
std::vector<long long int> a;
std::cin >> n;
for(long long int i = 0; i < 3 * n; i++){
    long long int aa;
    std::cin >> aa;
    a.push_back(aa);
}
std::sort(a.begin(), a.end());
long long int count = 0;
for(long long int i = n; i < 3 * n; i += 2){
    count += a[i];
}
std::cout << count << std::endl;
return 0;
}

Measured memory_bytes: 6256
from collections import deque
n, m = map(int, input().split())
e = [[] for _ in range(n+1)]
lndmrk = [-1] * (n + 1)
for i in range(m):
	a, b = map(int, input().split())
	e[a].append(b)
	e[b].append(a)

q = deque()
lndmrk[1] = 0
q.append(1)
while(len(q) != 0):
	v = q.popleft()
	for i in e[v]:
		if lndmrk[i] != -1:
			continue
		lndmrk[i] = v
		q.append(i)
f = 1
for i in range(2, n+1):
	if lndmrk[i] == -1:
		f = 0
if f:
	print("Yes")
	for i in range(2, n+1):
		print(lndmrk[i])
else:
	print("No")

Measured memory_bytes: 34204
#include<bits/stdc++.h>
using namespace std;
int minimum_weight_matching(const vector<vector<int>>& weight) {
  const int INF = 1e9;
  vector<int> dp(1 << weight.size(), INF);
  dp[0] = 0;
  for(int bit = 0; bit < (1 << weight.size()); ++bit)
    for(int u = 0; u < weight.size(); ++u) if(!((bit >> u) & 1))
      for(int v = 0; v < weight.size(); ++v) if(!((bit >> v) & 1))
        dp[bit | (1 << u) | (1 << v)] = min(dp[bit | (1 << u) | (1 << v)], dp[bit] + weight[u][v]);
  return dp[(1 << weight.size()) - 1];
}
struct Edge {int from, to, weight;};
int chinese_postman_problem(const vector<vector<Edge>>& edge) {
  const int NIL = -1;
  const int INF = 1e9;
  int total = 0;
  vector<int> odd, odd_index(edge.size(), NIL);
  for(int v = 0; v < edge.size(); ++v) {
    for(const auto& e: edge[v]) total += e.weight;
    if(edge[v].size() & 1) {
      odd_index[v] = odd.size();
      odd.push_back(v);
    }
  }
  // Warshall-Floyd
  vector<vector<int>> wf(edge.size(), vector<int>(edge.size(), INF));
  for(int v = 0; v < edge.size(); ++v) for(const auto& e: edge[v]) wf[e.from][e.to] = min(wf[e.from][e.to], e.weight);
//   for(int v = 0; v < edge.size(); ++v) wf[v][v] = 0;
  for(int k = 0; k < edge.size(); ++k)
    for(int i = 0; i < edge.size(); ++i)
      for(int j = 0; j < edge.size(); ++j)
        wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
  // make odd vertices graph
  vector<vector<int>> weight(odd.size(), vector<int>(odd.size(), INF));
  for(const auto& u: odd) for(const auto& v: odd) if(u != v) weight[odd_index[u]][odd_index[v]] = wf[u][v];
  // minimum weight matching
  return total / 2 + minimum_weight_matching(weight);
}
int main() {
  int V, E;
  cin >> V >> E;
  vector<vector<Edge>> edge(V);
  for(int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    edge[s].push_back({s, t, d});
    edge[t].push_back({t, s, d});
  }
  cout << chinese_postman_problem(edge) << endl;
}

Measured memory_bytes: 1284
#include <iostream>
#include <valarray>
using namespace std;
int main() {
    int N, M, C, cnt = 0;
    cin >> N >> M >> C;
    valarray<int> B(M);
    for (auto& b : B)
        cin >> b;
    for (int i = 0; i < N; i++){
        valarray<int> A(M);
        for (auto& a : A){
            cin >> a;
        }
        A *= B;
        if (A.sum() + C > 0)
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Iterator;
public class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int line=0;
		for(int i = 1;input.hasNext();i++){
			line = input.nextInt();
			if(line!=0){
				System.out.println("Case "+i+": "+line);
			}else{
				break;
			}
		}
	}
}
		

Measured memory_bytes: 42200
class SegTree:
    
    def __init__(self, A, intv, initialize = True):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        if initialize:
            self.data = [intv]*(self.N0-1) + A + [intv]*(self.N0 - self.N + 1)
            for i in range(self.N0-2, -1, -1):
                self.data[i] = max(self.data[2*i+1], self.data[2*i+2]) 
        else:
            self.data = [intv]*(2*self.N0)
    
    def segf(self, a, b):
        return max(a, b)
    
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0 :
            k = (k-1)//2
            self.data[k] = max(self.data[2*k+1], self.data[2*k+2])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = max(s, self.data[R-1])
            if L & 1:
                
                s = max(s, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s

N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))

dp = SegTree([0]*(max(H)+1), 0, False)

for h, a in zip(H, A):
    dp.update(h, a+dp.query(0, h))
print(dp.data[0])


Measured memory_bytes: 121040
N,M = [int(x) for x in input().strip().split()]

Knk=[]
for _ in range(N):
    Knk.append([int(x) for x in input().strip().split()])

ans = [0] * M

for i,Kn in enumerate(Knk):
    for n,A in enumerate(Kn):
        if n == 0:
            continue
        ans[A-1]+=1

print(len([x for x in ans if x == N]))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int main() {

	set<int> A;
	int x,y;
	vector<int> B;

		for (int i = 0; i < 28; i++) {
			int a;
			cin >> a;
			A.insert(a);
		}

		for (int i = 0; i < 30; i++) {
			int n;
			n = A.count(i+1);
			if (n == 0) {
				B.push_back(i+1);
			}
		}

		x = B[0];
		y = B[1];

		cout << min(x, y) << endl << max(x, y) << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000001
using vi=vector<int>;
using P=pair<int,vi>;
struct node{
    vi to;
};
vi ans;
void bfs(int start, vector<node> &nodes){
    vector<bool> visited(nodes.size(),false);
    queue<P> q;
    q.push(P(start,vi{start}));
    while(q.size()){
        int v=q.front().first;
        vi path=q.front().second;
        q.pop();
        visited[v]=true;
        for (int i = 0; i < nodes[v].to.size(); i++){
            int v_to=nodes[v].to[i];
            vi tmp_path=path;
            if(v_to!=start){
                if(visited[v_to])continue;
                tmp_path.push_back(v_to);
                q.push(P(v_to,tmp_path));
            }else if(ans.size()==0 || path.size()<ans.size()){
                ans=path;
                return;
            }else return;
        }
    } 
}
int main() {
    int N,M;
    cin>>N>>M;
    vector<node> nodes(N);
    for (int i = 0; i < M; i++){
        int u,v;
        cin>>u>>v; u--; v--;
        nodes[u].to.push_back(v);
    }
    for (int i = 0; i < N; i++){
        bfs(i,nodes);
    }
    if(ans.size()==0)cout<<-1<<endl;
    else{
        cout<<ans.size()<<endl;
        for(int x : ans)cout<<x+1<<endl;
    }
}

Measured memory_bytes: 3964
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int i,res=0;
  string s;
  cin >> s;
  for(i=0;i<s.size();i++)
    res+=(int)(s[i]-'0');
  if(res%9==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++)cin >> p[i];
    sort(p.begin(), p.end());

    int res = 0;
    for(int i = 0; i < k; i++)res += p[i];
    cout << res << endl;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    int ans=0,ch=0,n;
    string s;
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')ch++;
        else{
            ans=max(ans,ch);
            ch=0;
        }
        ans=max(ans,ch);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <functional>
#include <utility>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

struct node
{
    int x, y;
};

const int inf = 0x3f3f3f3f;

char s[60][60];
int l[60][60];
int k[60][60];
int g[60][60];
int rx[1010], ry[1010];
int vis[60][60];

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

int r, c, m;
int mx, my;
vector <node> a;
vector <node> z;

int dfs(int x, int y, int fx, int fy)
{
    if(x == mx && y == my)
        return 1;
    for(int i = 0; i < 4; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx < 0 || nx >= r || ny < 0 || ny >= c || s[nx][ny] == '#')
            continue;
        if(nx == fx && ny == fy)
            continue;
        if(dfs(nx, ny, x, y) == 1)
        {
            node xin;
            xin.x = nx, xin.y = ny;
            a.push_back(xin);
            return 1;
        }
    }
    return 0;
}

int main()
{
    while(~scanf("%d%d%d", &r, &c, &m))
    {
        memset(vis, -1, sizeof(vis));
        for(int i = 0; i < r; i++)
            scanf("%s", s[i]);
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &l[i][j]);
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &k[i][j]);
        for(int i = 0; i < r; i++)
            for(int j = 0; j < c; j++)
                scanf("%d", &g[i][j]);
        for(int i = 0; i < m; i++)
            scanf("%d%d", &rx[i], &ry[i]);
        z.clear();
        node qi;
        qi.x = rx[0], qi.y = ry[0];
        z.push_back(qi);
        for(int i = 1; i < m; i++)
        {
            a.clear();
            if(rx[i] == rx[i - 1] && ry[i] == ry[i - 1])
                continue;
            mx = rx[i], my = ry[i];
            dfs(rx[i - 1], ry[i - 1], -1, -1);
            for(int j = a.size() - 1; j >= 0; j--)
            {
                node aa = a[j];
                z.push_back(aa);
            }
        }
//        printf("\n\n");
//        for(int i = 0; i < z.size(); i++)
//        {
//            printf("%d %d\n", z[i].x, z[i].y);
//        }
        long long sum = 0;
        int i;
        for(i = 0; i < z.size(); i++)
        {
            int nx = z[i].x;
            int ny = z[i].y;
            sum += k[nx][ny] + g[nx][ny];
            //cout << sum << endl;
            if(vis[nx][ny] == -1)
            {
                vis[nx][ny] = i;
                continue;
            }
            if((long long)(i - vis[nx][ny]) * l[nx][ny] <  k[nx][ny] + g[nx][ny])
            {
               // printf("%d\n", (k[nx][ny] + g[nx][ny]) - (i - vis[nx][ny) * l[nx][ny]);
                sum -= (k[nx][ny] + g[nx][ny]) - (i - vis[nx][ny]) * l[nx][ny];
            }
            //printf("\n");
            vis[nx][ny] = i;
        }
        //sum += g[rx[i]][ry[i]];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 19532
s = list(input())
n = len(s)
if n % 2 == 0:
    for i in range(n//2):
        a = s[n // 2]
        if s[n // 2 - 1 - i] != a or s[n // 2 + i] != a:
            print(n // 2 + i)
            exit()
else:
    for i in range(1, (n - 1) // 2 + 1):
        b = s[(n-1)//2]
        if s[(n - 1) // 2 - i] != b or s[(n - 1) // 2 + i] != b:
            print((n-1)//2+i)
            exit()
print(n)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    ll n; cin>>n;
    ll ans=1;
    rep(i,0,n){
        ll x; cin>>x;
        ans=x/__gcd(ans,x) *ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int t,x;cin>>t>>x;
  double ans=(double)t/x;
  
  coutd(ans);
 
  return 0;
}

Measured memory_bytes: 125568
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll q; cin >> q;
    vector<ll> a(q), b(q);
    rep(i,q)cin >> a[i] >> b[i];
    rep(i,q){
        if(a[i] == b[i]){
            cout << a[i] + b[i] - 2 << "\n";
            continue;
        }
        if(abs(a[i] - b[i]) == 1){
            cout << a[i] + b[i] - 3 << "\n";
            continue;
        }

        ll c = sqrt(a[i] * b[i]);
        if(c * c == a[i] * b[i])c--;
        if(c * (c+1) < a[i] * b[i]){
            cout << 2 * c - 1 << "\n";
        }
        else{
            cout << 2 * c - 2 << "\n";
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a;
  ll c;
  string b;
  cin >> a;
  cin >> b;
  c = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
  ll res = a * c / 100LL;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    double o,e;
    cin>>N;
    o=floor(N/2);
    e=floor(N/2);

    if(N%2==1){
        o+=1;
        cout<<o/(o+e)<<endl;
    }else{
        cout<<e/(e+o)<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c=LI()
  sm=a+b+c

  if sm>=22:
    return 'bust'
  return 'win'

# main()
print(main())


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

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    int ans = 0;
    char a[h][w];
    
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) 
        cin >> a[i][j];
    }
    int black;
    for(int i=0; i < (1<<h) ; i++){
        for(int j = 0; j < (1<<w) ; j++ ) {
             black = 0;
            for(int m=0;m<h;m++) {
                for(int n=0;n<w;n++) {
                    if(((i >> m) & 1) && ((j >> n) & 1) && a[m][n] == '#')
                    black++;
                }
            }
            if(black == k)
            ans ++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    bool takashi=true;
    while(A>0 &&C>0)
    {
        if(takashi)
        {
            C-=B;
        }
        else
        {
            A-=D;
        }
        takashi = !takashi;
    }

    if(A<=0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
   	int a, b, c, d;
   	cin >> a >> b >> c >> d;
   	cout << min(a, b) + min(c, d);
}

Measured memory_bytes: 3640
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
a = []
for i in range(N):
    s,p = map(str, input().split())
    p = int(p)
    a.append([s,p,i])

a.sort(key = lambda x: (x[0],-x[1]))
for i in range(N):
    print(a[i][2]+1)

Measured memory_bytes: 38384
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        s: String,
        t: String,
    }
    println!("{}", if s == t[..t.len() - 1] { "Yes" } else { "No" });
}


Measured memory_bytes: 2172
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n, m; cin >> n >> m;
	if (abs(n - m) > 1) {
		printf("0"); return 0;
	}
	int ans = 1;
	rep(i, 1, n+1) {
		ans = 1LL * ans * i % mod;
	}
	rep(i, 1, m + 1) {
		ans = 1LL * ans * i % mod;
	}
	if (n == m) ans = ans * 2LL % mod;
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s,t;
    cin >> s >> t;
    int n=s.size();
    rp(i,n){
        if(s==t){
            print("Yes");
            return;
        }
        s=s.substr(1,n-1)+s[0];
    }
    print("No");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100100
using namespace std;
struct seg{
	int a,b,x;
	bool operator<(seg rhs)const{return x<rhs.x||x==rhs.x&&b<rhs.b;}
}p[N];
long long gcd(long long x,long long y){
	while(y){
		x%=y;
		x^=y^=x^=y;
	}
	return x;
}
bool ca(seg x,seg y){
	return x.a<y.a;
}
int main(){
	int n,f=0,cur;
	long long tx=0,ty=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&p[i].a,&p[i].b);
		p[i].x=max(p[i].a,p[i].b);
	}
	long long pre=0;
	for(int i=0;i<n;i++){
		if(p[i].a<p[i].b){
			pre+=p[i].a-p[i].b;
		}
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		if(pre+p[i].x<=0){
			pre+=p[i].x;
			f++;
		}
		else{
			cur=i;
			break;
		}
	}
	for(int i=0;i<n;i++){
		if(i<cur){
			if(pre-p[i].x+p[cur].x+max(p[i].a-p[i].b,0)<=0){
				long long cx=pre-p[i].x+p[cur].x+max(p[i].a-p[i].b,0);
				long long cy=p[i].b;
				if(-cx*ty>tx*cy){
					tx=-cx;
					ty=cy;
				}
			}
		}
		else{
			if(pre+max(p[i].a-p[i].b,0)<=0){
				long long cx=pre+max(p[i].a-p[i].b,0);
				long long cy=p[i].b;
				if(-cx*ty>tx*cy){
					tx=-cx;
					ty=cy;
				}
			}
		}
	}
	long long x=1LL*f*ty+tx;
	long long y=1LL*n*ty;
	long long g=gcd(x,y);
	printf("%lld %lld\n",x/g,y/g);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll x[N] , v[N];
pair<ll,ll> maxRightAnswer[N],maxLeftAnswer[N];
int main(){
 	ll n, c;
 	cin>>n>>c;
 	ll ans = 0;
 	for(int i = 0 ; i < n ;++i)
 		cin>>x[i]>>v[i];
 	pair<ll,ll> ans1 , ans2;
 	ll k = 0,k2=0;
 	for(int i = 0 ; i < n ;++i){
 		k+=v[i];
 		k2+=v[n-i-1];
 		// cout<<k<<" "<<k2<<endl;
 		if(ans1.first<k - x[i])
 			ans1 = {k-x[i],x[i]};
 		if(ans2.first<k2 - (c-x[n-i-1]))
 			ans2 = {k2 - (c - x[n-i-1]) , c - x[n-i-1]};
 		 // cout<<ans1.first<<" "<<k<<"\n"<<k2<<" "<<ans2.first<<endl<<endl;
 		maxLeftAnswer[i]=ans1;
 		maxRightAnswer[n-i-1]=ans2;
 		ans=max(ans,max(ans1.first , ans2.first));
 	}
 	// cout<<ans<<endl;
 	for(int i = 0 ; i < n ;++i){
 		pair<ll,ll> r, l = maxLeftAnswer[i];
 		r = maxRightAnswer[i+1];
 		ans = max(ans ,l.first+r.first - min(l.second , r.second));
 	}
 	cout<<ans<<endl;
}

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

int main()
{
    int a[3];
    int b[3];
    bool x = true;
    for(int i = 0; i < 3; i++)
    {
        cin >> a[i] >> b[i];
    }
    for(int j = 1; j < 5; j++)
    {
        int count = 0;
        for(int i = 0; i < 3; i++)
        {
            if(a[i] == j && b[i] == j)
            {
                count += 2;
            }
            else if(a[i] == j || b[i] == j)
            {
                count++;
            }
        }
        if(count > 2)
        {
            cout << "NO";
            x = false;
        }
    }
    if(x)
    {
        cout << "YES";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int l,r;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='A')  
        {
            l=i;
            break;
        }       
    } 
    for(int i=a.size()-1;i>=0;i--)
    {
        if(a[i]=='Z') 
        {
            r=i;
            break;
        }
    }
    cout<<r-l+1<<endl;  
    return 0;
}

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

int main() {
  int n,m; cin >>n >>m;
  vector<int> x(m),d(m-1);
  rep(i,m) cin >>x[i];
  sort(x.begin(), x.end());
  rep(i,m-1) d[i]=x[i+1]-x[i];
  sort(d.begin(), d.end());
  int ans = 0;
  rep(i,m-n) ans+=d[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
int n;

long long count(vector<vector<long long> > &dp, vector<vector<int> > &v, int pos, int xr, int parent){
    if((v[pos].size()==1 && parent != -1) || v[pos].size()==0)
        return 1;

    if(dp[pos][xr] != -1)
        return dp[pos][xr];
    long long ans = 0, one = 1, zero = 1;
  
    for(int a=0; a<v[pos].size(); a++){

        if(v[pos][a] != parent){ 
        long long tt = count(dp,v, v[pos][a],0, pos);
        if(xr == 0)
            tt += count(dp,v, v[pos][a],1,pos);
            tt %= mod;
            one = (one*tt)%mod;
        }
    }
  //  cout<<"dd "<<pos<<" "<<xr<<" "<<one<<endl;
    return dp[pos][xr] = one;
}

int main()
{
   cin>>n;

    std::vector<vector<int> > v(n+1);
    for(int a=1; a<n; a++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

   std::vector<vector<long long> > dp(n+1, vector<long long> (2, -1));
   long long ans = count(dp,v,1,0, -1) + count(dp,v,1,1, -1);

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


Measured memory_bytes: 19584
function Main(input) {
	inp = input.split(" ")
	var x = parseInt(inp[0])
	var y = parseInt(inp[1])
	var a = [1,3,5,7,8,10,12]
	var b = [4,6,9,11]

	if (a.indexOf(x)>=0 && a.indexOf(y)>=0){
		console.log("Yes")
	}
	else if (b.indexOf(x)>=0 && b.indexOf(y)>=0){
		console.log("Yes")
	}
	else{
		console.log("No")
	}
	
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int count;
    count = N/X;
    if(N%X != 0) {
        count++;
    }
    int ans = count * T;
    cout << ans << endl;
}

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

int main() {
	int a, b, c ,d, ans_a, ans_b;
	cin >> a >> b >> c >> d;
	ans_a = (c / b) + ((c % b == 0) ? 0 : 1);
	ans_b = (a / d) + ((a % d == 0) ? 0 : 1);
	// cout << ans_a << " " << ans_b << "\n";
	if (ans_a <= ans_b) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}
	return 0;
}


Measured memory_bytes: 3572
h, w = (int(i) for i in input().split())
s = [input() for i in range(h)]
ans = []
dx = [-1,0,1,-1,1,-1,0,1]
dy = [-1,-1,-1,0,0,1,1,1]

for i in range(h):
    for j in range(w):
        count = 0
        for k in range(len(dx)):
            x = j+dx[k]
            y = i+dy[k]
            if 0<=x and x<w and 0<=y and y<h and s[y][x] == '#':
                count += 1

        if s[i][j] != '#':
            s[i] = s[i].replace('.',str(count),1)
                
for i in range(h):
    print(s[i])


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

int main(void){

    int N,ans = 0;
    cin >> N;
    int p[N];
    for (int i = 0; i < N; i++){
        cin >> p[i];
    }

    for (int i = 1; i < N-1; i++){
        if(p[i-1]<=p[i]&&p[i]<=p[i+1]){
            ans++;
            continue;
        }else if(p[i-1]>=p[i]&&p[i]>=p[i+1]){
            ans++;
            continue;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

void bsort(int m[]){
  for(int i=9;i>0;i--){
    for(int j=0;j<i;j++){
      if(m[j] < m[j+1]){
	int tmp = m[j];
	m[j] = m[j+1];
	m[j+1] = tmp;
      }
    }
  }
  
}

int main(){
  int i,mou[10];
  
  for(i=0;i<10;i++)  cin >> mou[i];

  bsort(mou);
  
  cout << mou[0] << endl << mou[1] << endl << mou[2] << endl;
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  ll ans, tmpans;
  if(N%2==0) {
    ans = 0;
    for(int i=0;i<N;++i) {
      if(i<N/2) {
        if(i==N/2-1) ans -= A[i];
        else ans -= A[i]*2;
      }
      else {
        if(i==N/2) ans += A[i];
        else ans += A[i]*2;
      }
    }
  }
  else {
    ans = 0;
    for(int i=0;i<N;++i) {
      if(i<N/2) ans -= A[i]*2;
      else {
        if(i==N/2 || i==N/2+1) ans += A[i];
        else ans += A[i]*2;
      }
    }
    tmpans = 0;
    for(int i=0;i<N;++i) {
      if(i>N/2) tmpans += A[i]*2;
      else {
        if(i==N/2 || i==N/2-1) tmpans -= A[i];
        else tmpans -= A[i]*2;
      }
    }
    ans = max(ans, tmpans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >>N >>M;
  long long ans=0;
  ans+=(N-M)*100+M*1900;
  for(int i=0; i<M; i++){
    ans*=2;
  }
  cout <<ans <<endl;
}


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

public class AtCoderD
{
    static void Main()
    {
        int mod = 1000000007;
        int x;
        int y;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            x = int.Parse(words[0]);
            y = int.Parse(words[1]);
        }

        if ((x + y) % 3 != 0)
        {
            Console.WriteLine(0);
            return;
        }

        int m = (2 * x - y) / 3;
        int n = x - 2 * m;

        if (m < 0 || n < 0)
        {
            Console.WriteLine(0);
            return;
        }

        long answer = Combination(n + m, m, mod);

        Console.WriteLine(answer);
    }

    // Comnibation（mod版）
    private static long Combination(int n, int k, int d)
    {
        long answer = 1;
        for (int i = n; i > n - k; i--)
        {
            answer = Mul(answer, i, d);
        }
        for (int i = 1; i <= k; i++)
        {
            answer = Div(answer, i, d);
        }
        return answer;
    }

    // 掛け算（mod版）
    private static long Mul(long a, long b, long c)
    {
        return ((a % c) * (b % c)) % c;
    }

    // 割り算（mod版）
    private static long Div(long a, long b, long c)
    {
        return Mul(a, Pow(b, c - 2, c), c);
    }

    // べき乗（mod版）
    private static long Pow(long a, long b, long c)
    {
        if (b == 0)
        {
            return 1;
        }
        else if (b == 1)
        {
            return a % c;
        }
        else if (b % 2 == 0)
        {
            long d = Pow(a, b / 2, c);
            return d * d % c;
        }
        else
        {
            return a * Pow(a, b - 1, c) % c;
        }
    }
}

Measured memory_bytes: 13140
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};
// function build2DArray(r,u,a){for(var f=a||0,n=[],o=0;o<r;o++){for(var h=[],i=0;i<u;i++)h.push(f);n.push(h)}return n}
 
const mod = 998244353;
function main(input) {
  var o = new I(input);
 
  var n = o.a();
  var a = [];
  for (var i = 0; i<n; i++) {
    a.push(o.a());
  }
 
  var sum = a.reduce((acc, cur) => acc + cur, 0);
 
  var total = 1;
  for (var i = 0; i < n; i++) {
    total = (total * 3) % mod;
  }
 
  var ans1 = 0; // R >= S/2

  var dp1 = [1];
  var dp3 = [1];
 
  for (var i = 1; i <= n; i++) {
    var dp2 = Array(dp1.length+a[i-1]).fill(0);
    var dp4 = Array(dp3.length+a[i-1]).fill(0);

    for (var j = 0; j < dp1.length; j++) {
      dp2[j] += dp1[j] * 2;
      dp2[j] %= mod;
      dp4[j] += dp3[j];
      dp4[j] %= mod;

      var next = j + a[i - 1];
      if (next <= sum) {
        dp2[next] += dp1[j];
        dp4[next] += dp3[j];
      }
    }
    dp1 = dp2;
    dp3 = dp4;
  }

  for (var j = Math.ceil(sum/2); j <= sum; j++) {
    ans1 += dp1[j];
  }
 
  var ans2 = 0;
  if (sum % 2 === 0) {
    ans2 = dp3[sum/2];
  }
 
  let ans = (total - ans1 * 3 + ans2 * 3) % mod;
  ans = (ans + mod) % mod;
 
  console.log(ans);
}
 
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 61872
#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
void dfs(long long n, int k) {
    if(k==11) return;
    v.push_back(n);
    long long a = n%10;
    if(a>=0 && 9>a)  dfs(n*10+a+1,k+1);
    if(a>=0 && 9>=a) dfs(n*10+a,k+1);
    if(a>0 && 9>=a)  dfs(n*10+a-1,k+1);
    return;
}
int main() {
    long long int n;
    cin >> n;
    for(int i=1;i<10;i++) dfs(i,1);
    sort(v.begin(),v.end());
    cout << v[n-1] << endl;
}


Measured memory_bytes: 5272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const long long mod = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n){
    cin >> h[i];
  }
  vector<ll> dp(n + 1, 1000000000000000);
  dp[0] = 0;
  for (int now = 0; now < n; now++){
    if(now + 1 < n){
      dp[now + 1] = min(dp[now + 1], dp[now] + abs(h[now + 1] - h[now]));
    }
    if(now + 2 < n){
      dp[now + 2] = min(dp[now + 2], dp[now] + abs(h[now + 2] - h[now]));
    }
    
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1920
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let X = read int

    let a = X % 100
    let b, r1 = a / 5, a % 5
    let c, r2 = r1 / 4, r1 % 4
    let d, r3 = r2 / 3, r2 % 3
    let e, r4 = r3 / 2, r3 % 2
    let f = r4

    let g = b + c + d + e + f
    if g * 100 <= X then
        printfn "1"
    else
        printfn "0"

    0

Measured memory_bytes: 13648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

ll f(ll n) {
  return n*(n+1)/2;
}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rrep(i, n) {
    ll r = n/i;
    ans += f(r)*i;
  }
  cout << ans << endl;
}

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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        String S = sc.next();
        String T = sc.next();

        int[] dsx = new int[N], dsy = new int[N];
        int[] dtx = new int[N], dty = new int[N];

        for (int i = 0; i < N; i++) {
            dsx[i] = S.charAt(i) == 'U' ? -1 : S.charAt(i) == 'D' ? 1 : 0;
            dsy[i] = S.charAt(i) == 'L' ? -1 : S.charAt(i) == 'R' ? 1 : 0;
            dtx[i] = T.charAt(i) == 'U' ? -1 : T.charAt(i) == 'D' ? 1 : 0;
            dty[i] = T.charAt(i) == 'L' ? -1 : T.charAt(i) == 'R' ? 1 : 0;
        }

        if (ok(H, sx, N, dsx, dtx) || ok(W, sy, N, dsy, dty)) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

    boolean ok(int L, int S, int N, int[] ds, int[] dt) {
        int s = S;
        for (int i = 0; i < N; i++) {
            if (ds[i] > 0) s++;
            if (s == L + 1) return true;
            if (dt[i] < 0 && s > 1) s--;
        }
        s = S;
        for (int i = 0; i < N; i++) {
            if (ds[i] < 0) s--;
            if (s == 0) return true;
            if (dt[i] > 0 && s < L) s++;
        }
        return false;
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 32652
import math
a,b,h,m=map(int,input().split())
tyok=h*30+m*0.5
tank=m*6
sa=0

if abs(tyok-tank)>180:
  sa=abs(tyok-tank)-360
else:
  sa=abs(tyok-tank)
  
c=a**2+b**2-2*a*b*math.cos(math.radians(sa))
print(math.sqrt(c))


Measured memory_bytes: 9440