akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s,t;cin>>s>>t;
  bool flag=true;
  int n=s.size();
  vector<vector<int>> memo(n+1,vector<int>(30,0));
  rep(i,n){
    int sn=s[i]-'a'+1;
    int tn=t[i]-'a'+1;
    char S=s[i];char T=t[i];
    if(s[i]!=t[i]){
      if(memo[0][sn]==0&&memo[0][tn]==0){
        //memo[0][sn]=1;
        memo[0][tn]=1;
        rep(j,n){
          if(s[j]==S){
            s[j]=T;
          }
          else if(s[j]==T){
            s[j]=S;
          }
        }
      }
      else{
        //cout<<i<<endl;
        flag=false;
      }
    }
  }
  	if(flag){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
    //cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 55304
use v5.18;
use warnings;
use List::Util qw( sum0 );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my ($n, $m) = splited_read_line;
my @x = sort { $a <=> $b } splited_read_line;
my $aida = aida(\@x);
pop @$aida for 1 .. $n - 1;
say sum0 @$aida;

sub aida {
  my $points = shift;
  my @ary;
  for my $i (0 .. $#$points - 1) {
    my ($x1, $x2) = ($points->[$i], $points->[$i + 1]);
    push @ary, abs($x2 - $x1);
  }
  [ sort { $a <=> $b } @ary ];
}


Measured memory_bytes: 25376
n = int(input())

d = list(map(int, input().split()))

#print(d[2])

s = 0

for i in range(n):
	for j in range(n):
		if i == j:
			pass #ifで何もしない時は明示的にpassと書かないとエラーになる
		else:
			s = s + d[i]*d[j]
			
print(int(s/2))


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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=1e5+8;
char a[N];
int main()
{
    int n,k;
    int r,s,p;
    cin>>n>>k;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    int sum=0;
    for(int i=0;i<k;i++){
        if(t[i]=='r'){
            a[i]='p';
            sum+=p;
        }
        if(t[i]=='p'){
            a[i]='s';
            sum+=s;
        }
        if(t[i]=='s'){
            a[i]='r';
            sum+=r;
        }
    }
    for(int i=k;i<n;i++){
        if(t[i]=='r'){
                if(a[i-k]!='p'){
                    sum+=p;
                    a[i]='p';
                }
        }
        if(t[i]=='p'){
                if(a[i-k]!='s'){
                    sum+=s;
                    a[i]='s';
                }
        }
        if(t[i]=='s'){
                if(a[i-k]!='r'){
                    sum+=r;
                    a[i]='r';
                }
        }
    }
    cout<<sum;
}


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

int main(){
  int N;cin>>N;
  long long A[100];
  
  long long money=1000;
  long long stock=0;
  
  
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  for(int i=0;i<N-1;i++){
    if(A[i]<A[i+1] && stock==0){
      stock = money/A[i];
      money = money%A[i];
    }
    else if(A[i]>A[i+1]){
      money += stock * A[i];
      stock = 0;
    }
  }
  money += stock*A[N-1];
  cout<<money<<endl;
}
  
  

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

using namespace std;

#define int long long

int solve(string s) {
	int n = (int) s.length();
	vector<int> z (n);
	for (int i=1, l=0, r=0; i<n; ++i) {
		if (i <= r)
			z[i] = min (r-i+1, z[i-l]);
		while (i+z[i] < n && s[z[i]] == s[i+z[i]])
			++z[i];
		if (i+z[i]-1 > r)
			l = i,  r = i+z[i]-1;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
    {
        if (z[i] <= i && z[i] > ans)
        {
            ans = z[i];
        }
    }
    return ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t = s[n - i - 1] + t;
        ans = max(ans, solve(t));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
number_classmate = list(map(int, input().split()))

classmate = [[0] * 2 for i in range(N)]

for i in range(len(number_classmate)):
    classmate[i][0] = number_classmate[i]
    classmate[i][1] = i+1

classmate.sort(key=lambda s: s[0])

mapped_list = map(str, list(i[1] for i in classmate))
first_index = ' '.join(mapped_list)

print(first_index)



Measured memory_bytes: 27748
// https://atcoder.jp/contests/abc054/tasks/abc054_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M;
  cin >> N >> M;

  VVL edge_mat(N, VL(N));
  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edge_mat[a][b] = 1;
    edge_mat[b][a] = 1;
  }

  ll res = 0;
  VL nodes(N);
  rep(i, N) nodes[i] = i;

  do {
    unless(nodes.front() == 0) continue;

    ll ok = true;

    rep(i, N - 1) { unless(edge_mat[nodes[i]][nodes[i + 1]]) ok = false; }

    if (ok) res++;
  } while (next_permutation(all(nodes)));

  cout << res << endl;
}

ll dfs(ll u, V<bool>& visited, VVL& edge_list) {
  if (all_of(all(visited), [](ll v) { return v; })) return 1;

  ll res = 0;

  for (auto v : edge_list[u]) {
    if (visited[v]) continue;
    visited[v] = true;

    res += dfs(v, visited, edge_list);
    visited[v] = false;
  }

  return res;
}

void solve2() {
  ll N, M;
  cin >> N >> M;

  VVL edge_list(N, VL(N));
  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edge_list[a].emplace_back(b);
    edge_list[b].emplace_back(a);
  }

  V<bool> visited(N);
  visited[0] = true;

  ll res = dfs(0, visited, edge_list);

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self,size):
        self.table=[-1]*size
    def root(self,x):
        while self.table[x]>=0:
            x=self.table[x]
        return x
    def unite(self,x,y):
        s1=self.root(x)
        s2=self.root(y)
        if s1!=s2:
            if self.table[s1]>self.table[s2]:
                s1,s2=s2,s1
            self.table[s1]+=self.table[s2]
            self.table[s2]=s1
        return
    def same(self,x,y):
        return self.root(x)==self.root(y)
    def size(self,x):
        return -self.table[self.root(x)]
input=open(0).readline
n,m=map(int,input().split())
*p,=map(int,input().split())
u=UnionFind(n+1)
for _ in range(m):
    u.unite(*map(int,input().split()))
print(sum(u.same(p[i],i+1)for i in range(n)))

Measured memory_bytes: 14516
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def get_comb_operator(s, lim):
    lst = [""]
    next_lst = []
    for i in range(lim):
        next_lst = [ch + item for ch in s for item in lst]
        lst = next_lst
    return lst

def get_comb(lst):
    def sub(ans, comb, rest):
        if not rest:
            if not comb in ans:
                ans.append(comb)
        else:
            for i in range(len(rest)):
                sub(ans, comb + rest[i], rest[:i] + rest[i+1:])
    ans = []
    sub(ans, "", lst)
    return ans

def comb_all(nums, operators, expr = ""):
    if nums == "":
        yield expr + operators
    elif operators == "":
        yield expr + nums
    else:
        for item in comb_all(nums[1:], operators, expr + nums[0]):
            yield item
        for item in comb_all(nums, operators[1:], expr + operators[0]):
            yield item

def get_success_item(nums, operators):
    for expr in comb_all(nums, operators):
        if is_success(expr):
            return expr
    return ""

def is_success(expr):
    stack = []
    for i in xrange(len(expr)):
        if expr[i] in "*+-":
            if len(stack) < 2:
                return False
            else:
                first = stack.pop()
                second = stack.pop()
                if expr[i] == "*":
                    stack.append(second * first)
                elif expr[i] == "-":
                    stack.append(second - first)
                else:
                    stack.append(second + first)
        else:
            stack.append(int(expr[i]))
    return stack[0] == 10

def to_infix(expr):
    stack = []
    for i in xrange(7):
        if expr[i] in "+*-":
            first = stack.pop()
            second = stack.pop()
            stack.append("(%s %s %s)" % (second, expr[i], first))
        else:
            stack.append(expr[i])
    return stack[0]

def get_result(nums):
    for comb_num in get_comb(nums):
        for comb_operator in get_comb_operator("+*-", 3):
            success_item = get_success_item(comb_num, comb_operator)
            if success_item:
                return to_infix(success_item)
    return "0"

def solve():
    while True:
        comb_operator = get_comb_operator("+*-", 3)
        nums = sys.stdin.readline().strip().replace(" ", "")
        if nums != "0000":
            print get_result(nums)
        else:
            sys.exit()

if __name__ == "__main__":
    solve()

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

int n, k;
string s, t, mx;

string get_min(string s)
{
    string ans = mx;
    for (int i = 0; i <= n; i++)
        ans = min(ans, s.substr(i, n));
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k >> s;
    for (int i = 0; i < n; i++)
        mx += 'z';
    k = min(k - 1, 13);
    t = s; reverse(t.begin(), t.end());
    s = get_min(s + t);
    while (k--)
    {
        t = s; reverse(t.begin(), t.end());
        s = get_min(t + s);
    }
    cout << s;
}


Measured memory_bytes: 384
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/
 
int main(){
	FIO
	
	int n,k,r,s,p;cin >> n >> k >> r >> s >> p;
	string t;cin >> t;
	int ans = 0;
	vector<char> moves;
	forn(i,k){
		if(t[i] == 'r'){
			ans+=p;
			moves.pb('p');
		}
		else if(t[i] =='p'){
			ans+=s;
			moves.pb('s');
		}
		else{
			ans+=r;
			moves.pb('r');
		}
	}
	for(int i = k ;i <t.size();i++){
		if(t[i] == 'r'){
			if(moves[i-k]!='p'){
				ans+=p;
				moves.pb('p');
			}
			else moves.pb('?');
		}
		else if(t[i] =='p'){
			if(moves[i-k]!='s'){
				ans+=s;
				moves.pb('s');
			}
			else moves.pb('?');
		}
		else{
			if(moves[i-k]!='r'){
				ans+=r;
				moves.pb('r');
			}
			else moves.pb('?');
		}
	}
	cout << ans;  
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int go[100005][20],ans[100005];
string s;int n;
int main(){
	cin>>s;n=s.size();
	rep(i,n){
		if(s[i]=='R') go[i][0] = i+1;
		else go[i][0] = i-1;
	}
	rep(j,19) rep(i,n){
		go[i][j+1] = go[go[i][j]][j];
	}
	rep(i,n)ans[go[i][19]]++;
	rep(i,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 8832
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
bi=[0]* N
children = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    bi[i]=b-1
    children[a-1].append(bi[i])

queue = deque([0])
colors = [0] * N
maxColor = 0
while queue:
    node = queue.popleft()
    nodeColor = colors[node]
    color = 1
    for child in children[node]:
        if color == nodeColor: color += 1
        colors[child] = color
        queue.append(child)
        color += 1
    maxColor = max(maxColor, color-1)

print(maxColor)
for i in range(N-1):
    print(colors[bi[i]])

Measured memory_bytes: 18668
#include<cstdio>
#include<algorithm>

using namespace std;

struct UnionFind{
	int par[1010];
	int sz[1010];
	void init(int N){
		for(int i=0;i<N;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		par[y]=x;
		sz[x]+=sz[y];
	}
};

UnionFind uf;

int oNum,eNum;

char ch[1010];

int dp[1010][1010][2][2];

int rec(int o,int e,int i,int p){
	if(dp[o][e][i][p]!=-1) return dp[o][e][i][p];
	int x1=-1,x2=-1,x3=-1;
	if(o>=2) x1=rec(o-2,e+1,i,p^1);
	if(e>=1) x2=rec(o,e-1,i^1,p^1);
	if(i==1) x3=rec(o,e,0,p^1);
	int res;
	if(p==0){
		if(x1==1||x2==1||x3==1) res=1;
		else res=0;
	}else{
		if(x1==0||x2==0||x3==0) res=0;
		else res=1;
	}
	dp[o][e][i][p]=res;
	return res;
}

int main(){
	int V,E=0;
	scanf("%d",&V);
	uf.init(V);
	for(int i=0;i<V;i++){
		scanf("%s",ch);
		for(int j=0;j<V;j++){
			if(ch[j]=='Y'){
				uf.unite(i,j);
				E++;
			}
		}
	}
	E/=2;
	int all=0;
	for(int i=0;i<V;i++){
		if(uf.par[i]==i){
			int a=uf.sz[i];
			all+=(a*(a-1))/2;
			if(a%2==1) oNum++;
			else eNum++;
		}
	}
	for(int i=0;i<1010;i++) for(int j=0;j<1010;j++){
		for(int k=0;k<2;k++) for(int m=0;m<2;m++) dp[i][j][k][m]=-1;
	}
	for(int i=0;i<=2;i++) for(int p=0;p<=1;p++){
		dp[i][2-i][0][p]=p;
	}
	int x=rec(oNum,eNum,(all-E)%2,0);
	if(x==0) printf("Hanako\n");
	else printf("Taro\n");
	return 0;
}

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

int array1[] = {1,3,5,7,8,10,12};
int array2[] = {4,6,9,11};

int hantei (int a, int b){
    switch(a){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            for(int i=0; i < 7; i++){
                if(b==array1[i]){
                    return 1;
                }
            }
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            for(int i=0; i < 4; i++){
                if(b==array2[i]){
                    return 1;
                }
            }
            break;
        case 2:
            if(b==2){
                return 1;
            }
    }
    return 0;
}

int main (){
    int x, y;
    cin >> x >> y;
    if(hantei(x,y)==1){
        cout << "Yes"  << endl;
    }else if(hantei(x,y)==0){
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define P2(A)   ((A)*(A))
using namespace std;
typedef long long ll;

int main(){
    int n;
    for(;;){
        scanf("%d\n",&n);
        if(n==0) break;
        vector<double> xs(n),ys(n);
        for(int i=0;i<n;i++){
            scanf("%lf,%lf\n",&xs[i],&ys[i]);
        }
        if(n==1){
            printf("1\n");
            continue;
        }
        int ma=1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double mx=(xs[i]+xs[j])/2,my=(ys[i]+ys[j])/2,vlen=sqrt(P2(xs[i]-xs[j])+P2(ys[i]-ys[j])),llen=sqrt(1-(P2(xs[i]-mx)+P2(ys[i]-my)));
                double p1x=mx+(ys[i]-ys[j])*(llen/vlen),p1y=my-(xs[i]-xs[j])*(llen/vlen);
                double p2x=mx-(ys[i]-ys[j])*(llen/vlen),p2y=my+(xs[i]-xs[j])*(llen/vlen);
                int now=0;
                for(int k=0;k<n;k++){
                    if(P2(xs[k]-p1x)+P2(ys[k]-p1y)<=1.00005) now++;
                }
                ma=max(now,ma);
                now=0;
                for(int k=0;k<n;k++){
                    if(P2(xs[k]-p2x)+P2(ys[k]-p2y)<=1.00005) now++;
                }
                ma=max(now,ma);
            }
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	ll x;
 	cin>>x;
 	if(x==0)
 		cout<<1;
 	else
 		cout<<0;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 3632
n,c,k=map(int,input().split())

x=[]
for i in range(n):
    x.append(int(input()))
        
    
x.sort()

count=1

bus_count=0

for j in range(n-1):
    bus_count+=1
    if(x[j+1-bus_count]+k<x[j+1] or bus_count==c):
        count+=1
        bus_count=0
        
print(count)

Measured memory_bytes: 7384
/*************************************************************************
  >         File: C.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Mon 10 Oct 2016 01:18:53 PM CST
*************************************************************************/
#include <bits/stdc++.h>

using LL = long long;
const int N = 111111;
int a[N], b[N]; 
LL prefix[N];

int main() {
  std::ios::sync_with_stdio(0);
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  for (int i = 0; i < m; ++i) std::cin >> b[i];
  LL ans = 0;
  ans += std::accumulate(a, a + n, 0LL);
  ans += std::accumulate(b, b + m, 0LL);
  std::sort(a, a + n);
  std::sort(b, b + m);
  for (int i = 0; i < m; ++i) prefix[i + 1] = prefix[i] + b[i];
  for (int i = 0; i < n; ++i) {
    auto pos = std::upper_bound(b, b + m, a[i]) - b;
    ans += 1LL * a[i] * (m - pos) + prefix[pos];
  }
  std::cout << ans << std::endl;


  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll N,A,B,C,D,E; cin >> N >> A >> B >> C >> D >> E;
    ll minall=min({A,B,C,D,E});
    //ll ans=((N+minall-1)/minall)+4;
    
    ll ans;
    if (N%minall==0) ans=4+(N/minall);
    else ans=5+(N/minall);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        //バスがあるか
        if((S.charAt(0) == S.charAt(1)) && (S.charAt(1) == S.charAt(2))) {  //すべて同じ鉄道会社であればNo
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        
    }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 220
// 44

using namespace std;

const int MAXN = (int) 2e5;

int v[MAXN + 1];
ll sp[MAXN + 1], xr[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n, i;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> v[i];
        sp[i] = sp[i - 1] + v[i];
        xr[i] = (xr[i - 1] ^ v[i]);
    }
    ll ans = 0;
    for(i = 1; i <= n; i++) {
        int res = i;
        for(int step = 1 << 18; step; step >>= 1) {
            if(res + step <= n && sp[res + step] - sp[i - 1] == (xr[res + step] ^ xr[i - 1]))
                res += step;
        }
        ans += (res - i + 1);
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 4224
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        int ans =0;
        int left = 0;
        int right = 0;
        while(right < n-1){
            left = right;
            while(right < n-1 && (a[right] - a[left]) * (a[right+1] - a[right]) >= 0)
                right++;
            ans++;
            right++;
        }
        if(right == n-1) ans++;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 62048
#include<iostream>

int main(void){
  int n, m, max=0;
  int price[1000];

  for(int t=0; t<10000; t++){

    max = 0;
    std::cin >> n;
    std::cin >> m;
    if(n == 0 && m == 0){
      break;
    }

    for(int i=0; i<n; i++){
      std::cin >> price[i];
    }

    for(int j=0; j<n; j++){
      for(int s=0; s<n; s++){
	if(j == s){
	  break;
	}
	if(price[j] + price[s] > max && price[j] + price[s] <= m){
	  max = price[j] + price[s];
	}
      }
    }
    if(max > 0){
      std::cout << max << "\n";
    }else{
      std::cout << "NONE\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3068
N = int(input())
A = [''] * 2
for i in range(2):
    A[i] = list(map(int, input().split()))

anslist = []
for i in range(N):
    ans = 0
    ans += sum(A[0][: i + 1])
    ans += sum(A[1][i :])
    anslist.append(ans)
print(max(anslist))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int N;
    int T;
    scanf("%d", &N);
    scanf("%d", &T);
    int i = 0;
    int c[N];
    int t[N];
    for(i=0; i<N; i++){
        scanf("%d", &c[i]);
        scanf("%d", &t[i]);
    }
    int choice[N];
    int check_tle = 0;
    int min = 10000;
    for(i=0; i<N; i++){
        if(t[i] <= T){
            if(min > c[i]){
                min = c[i];
            }
            check_tle = 1;
        }
    }

    if(check_tle == 0){
        printf("TLE");
    }else {
        printf("%d",min);
    }
    return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define endl '\n'


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

	int x, y;
	cin >> x >> y;
	while (x*2 != y && x!=0)
	{
		y -= 4;
		x--;
	}
	if (x)
		cout << "Yes" << endl;
	else
	{
		if(y)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
		
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 3648
/*author @dhanush*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first

int main()
{

  ll t;
  cin >> t;
  if (t >= 30)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

}





Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

int main(){
  ll n,ans=0;cin>>n;
  vll a(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n-1){
      if(a[i+1]<a[i]){
        ans+=a[i]-a[i+1];
        a[i+1]=a[i];
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4832
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt64(scanner)
	b := getNextString(scanner)
	bb := strings.Split(b, ".")
	x := stoi(bb[0])
	y := stoi(bb[1])
	fmt.Fprintln(writer, a*x+a*y/100)
}

func stoi(s string) int64 {
	var x int64
	n := len(s)
	for i := 0; i < n; i++ {
		x *= 10
		x += int64(s[i] - '0')
	}
	return x
}


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

namespace algorithm
{
	class Program
	{

		static void Main(string[] args)
		{

			int[] calc = { 0,0,0 };
			int[] c = Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();
			List<String> list = new List<string>();
			int ans = 0;
			for (int i = 0; i < 1 << calc.Length; i++)
			{
				ans = c[0];
				StringBuilder sb = new StringBuilder();
				for (int j = 0; j < calc.Length; j++)
				{
					sb.Append(c[j]);
					//iを右シフトして最下位ビットをチェック
					if ((i >> j & 1) == 1)
					{
						ans += c[j + 1];
						sb.Append("+");
					}else
					{
						ans -= c[j + 1];
						sb.Append("-");
					}
				}
				sb.Append(c[c.Length-1]);
				sb.Append("=7");
				if (ans == 7)
				{
					Console.WriteLine(sb.ToString());
					return;
				}

			}
			

		}


	}
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[3100][3100];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    //LCS
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    ll len = dp[s.size()][t.size()];
    ll i = s.size()-1;
    ll j = t.size()-1;
    string ans(len,' ');
    while(len > 0){
        if(s[i] == t[j]){
            ans[len-1] = s[i];
            i--;
            j--;
            len--;
        }
        else if(dp[i+1][j+1] == dp[i][j+1]){
            i--;
        }
        else {
            j--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

class Dice{
public:
    int number[6];   
    int work[6];

    void setLabel(int index,int num){
        number[index] = num; 
    };

    void roll(char tokn){
        for(int i=0;i<6;i++) work[i] = number[i];
        switch(tokn){
            case 'E':
                setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
                break;
                
            case 'S':
                setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
                break;
                
            case 'N':
                setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
                break;
                
            case 'W':
                setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
                break;
        }
    }
    int returnTop(){
        return number[0];
    }
    int returnFront(){
        return number[1];
    } 
    int returnRight(){
        return number[2];
    }
    int returnLeft(){
        return number[3];
    }
    int returnBack(){
        return number[4];
    }
    int returnBottom(){
        return number[5];
    }
    
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
};

bool compareDice(Dice a,Dice b){
    string tokn ="NNNNWNNNWNNNENNNENNNWNNN";
    for(int i=0;i<tokn.length();i++){
        a.roll(tokn[i]);
        for(int k=0;k<6;k++){
            if(a.number[k] != b.number[k]) break;
            if(k+1 == 6){
                // for(int p=0;p<6;p++){
                //     cout << b.number[p] << " ";
                // }
                // cout << endl;
                return true;
            }
        }
    }
    return false;
}
int main() {
    Dice Dice1,Dice2;
    int label;
    for(int i=0;i<6;i++) {
        cin >> label;
        Dice1.setLabel(i,label);
    }
    for(int i=0;i<6;i++) {
        cin >> label;
        Dice2.setLabel(i,label);
    }

    if(compareDice(Dice1,Dice2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int paramN = Integer.parseInt(scanner.nextLine());
        String[] paramsV = scanner.nextLine().split(" ");
        scanner.close();
        
        int[] values = new int[paramsV.length];

        for (int i = 0; i < paramsV.length; i++) {
            values[i] = Integer.parseInt(paramsV[i]);
        }

        Arrays.sort(values);

        double currentValue = values[0];

        for (int i = 0; i < values.length - 1; i++) {
            currentValue = (currentValue + (double)values[i + 1]) / (double)2;
        }

        System.out.println(currentValue);
    }
}

Measured memory_bytes: 21972
import java.util.*;

class Main{
    static int H;
    static int W;
    static HashMap<Long,Integer> used;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        int[] ans = new int[10];
        used = new HashMap<>();
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }
        for(int i=0;i<N;i++){
            int row = a[i];
            int col = b[i];
            for(int j=row;j<=row+2;j++){
                for(int k=col;k<=col+2;k++){
                    helper(j,k);
                }
            }
        }
        for(Long w:used.keySet()){
            ans[used.get(w)]++;
        }
        long all = ((long)W-2)*((long)H-2);
        for(int i=1;i<=9;i++) all-=ans[i];
        System.out.println(all);
        for(int i=1;i<=9;i++) System.out.println(ans[i]);

    }
    static void helper(int row, int col){
        // 考察以(row,col)为最右下的那个3*3单元
        if(row<=2||col<=2) return;
        if(row>H||col>W) return;
        long cur = ((long)row)*(W+1)+((long)col);
        if(!used.containsKey(cur)) {
            used.put(cur,1);
        }
        else{
            int now = used.get(cur);
            used.put(cur,now+1);
        }

    }
}


Measured memory_bytes: 135600
cnt = 0
for i in range(int(input())):
    c_num = int(input())
    if cnt == 0:
        r_min = c_num
    elif cnt == 1:
        p_max = c_num - r_min
        if c_num < r_min:
            r_min = c_num
    else:
        if p_max < c_num - r_min:
            p_max = c_num - r_min
        if c_num < r_min:
            r_min = c_num
    cnt += 1
print(p_max)



Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int[] l = new int[5];
            boolean[] t = new boolean[3];
            l[0] = sc.nextInt()-1;
            if (l[0] == -1) {
                break;
            }
            t[l[0]] = true;
            for (int i = 1; i < 5; i++) {
                l[i] = sc.nextInt()-1;
                t[l[i]] = true;
            }
            for (int i = 0; i < 5; i++) {
                if (t[0] ^ t[1] ^ t[2]) {
                    System.out.println(3);
                } else {
                    for(int j=0;j<3;j++) {
                        if(l[i]!=j&&t[l[i]]==t[j]) {
                           System.out.println((l[i]-j+3)%3==2?1:2);
                           break;
                        }
                    }
                }
            }
        }
    }
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll p[maxn], ma;

void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> p[i], p[i] += p[i - 1];
    for (int i = 1; i + k - 1 <= n; i++) ma = max(ma, p[i + k - 1] - p[i - 1]);
    cout << fixed << setprecision(12) << (ma + k) * 1.0 / 2 << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            int count = 0;
            for (int j = 0; j <= i; j++) {
                count += a[j];
            }
            for (int j = i; j < n; j++) {
                count += b[j];
            }
            if (max < count) {
                max = count;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22996
import math
a, b = map(int,input().split())
ansA = math.ceil(a / 0.08)
ansB = math.ceil(b / 0.1)
if ansA < ansB:
  rr = range(ansA, ansB + 1)
elif ansA > ansB:
  rr = range(ansB, ansA + 1)
else:
  print(ansA)
  exit()
  
for i in rr:
  if math.floor(i * 0.08) == a and math.floor(i * 0.10) == b:
    print(i)
    exit()
print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 1000001;

// structure to store queries
struct Query {
    int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y) {
    return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, vector<int> &bit, int n) {
    for (; idx <= n; idx += idx & -idx) bit[idx] += val;
}

// querying the bit array
int query(int idx, vector<int> &bit) {
    int sum = 0;
    for (; idx > 0; idx -= idx & -idx) sum += bit[idx];
    return sum;
}

void answeringQueries(vector<int> &arr, int n, vector<Query> &queries, int q) {
    // initialising bit array
    vector<int> bit(n + 1);

    // holds the rightmost index of any number
    // as numbers of a[i] are less than or equal to 10^6
    vector<int> last_visit(MAX, -1);

    // answer for each query
    vector<int> ans(q);
    int query_counter = 0;
    for (int i = 0; i < n; i++) {
        // If last visit is not -1 update -1 at the
        // idx equal to last_visit[arr[i]]
        if (last_visit[arr[i]] != -1) update(last_visit[arr[i]] + 1, -1, bit, n);

        // Setting last_visit[arr[i]] as i and updating
        // the bit array accordingly
        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        // If i is equal to r of any query store answer
        // for that query in ans[]
        while (query_counter < q && queries[query_counter].r == i) {
            ans[queries[query_counter].idx] =
                    query(queries[query_counter].r + 1, bit) -
                    query(queries[query_counter].l, bit);
            query_counter++;
        }
    }

    // print answer for each query
    for (int i = 0; i < q; i++) cout << ans[i] << endl;
}

// driver code
int main() {
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for (int i = 0; i < n; i++)cin >> c[i];
    vector<Query> queries(q);
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        queries[i] = {l - 1, r - 1, i};
    }

    sort(queries.begin(), queries.end(), cmp);
    answeringQueries(c, n, queries, q);
    return 0;
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}
vector<ll> div/*divisor*/(ll n){  vector<ll> res={1};for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll b=n/a;res.pb(b);if(b!=a) res.pb(a);}sort(all(res));return res;}

int main() {
  ll n,m;
  cin>>n>>m;
  auto pn=pf(n);
  auto pm=pf(m);
  ll ans=0;
  for(auto x:pn){
    for(auto y:pm){
      if(x.first==y.first) ans++;
    }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n;
ll k,sum=0;
ll a[N],b[N],f[N];
bool cmp(ll a,ll b)
{
	return a>b;
}

bool check (ll x)
{
	for (int i=1;i<=n;++i)
	{
		f[i]=x/b[i];
	}
	ll res=0;
	for (int i=1;i<=n;++i)
	{
		res+=max(0ll,a[i]-f[i]);
	}
	return res<=k;
}
ll BS()
{
	ll l=0;
	ll r=1e12;
	while (l+1<=r)
	{
		ll mid=l+r>>1;
		if (check(mid))
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	return r;
}

int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	for (int i=1;i<=n;++i)
	{
		cin>>b[i];
	}
	if (sum<=k)
	{
		cout<<"0";
		return 0;
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n,cmp);
	cout<<BS();
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  int count=0;
  int han=0;
  while (count<a.size()){
  char c=a.at(0);
  for (int i=0;i<a.size()-1;i++){
    a.at(i)=a.at(i+1);
  }
  a.at(a.size()-1)=c;
    count++;
    if(a==b){
      han++;
    }
  }
  if(han!=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
   
  

Measured memory_bytes: 256
a=sorted([int(input()) for _ in [0]*int(input())])
s1=-1
if sum(a) % 10 != 0:
    print(sum(a))
else:
    for i in range(len(a)): #リスト中の10の倍数でなく最小の数を探す
        if a[i] % 10 !=0:
            s1=i
            break
    if s1!=-1:
        a.pop(s1)
        print(sum(a))
    else:
        print(0)

Measured memory_bytes: 3060
lines = readlines.map(&:strip).map{|line| line.split.map(&:to_i)}

n, m = lines.shift
as = lines.shift.sort
bcs = lines


c_sorted_bcs = bcs.sort{|l,r|l[1]<=>r[1]}.reverse

nested_out_bc = []
c_sorted_bcs.each do |b, c|
  nested_out_bc.push(*([c]*b))
  break if nested_out_bc.size >= n
end
nested_out_bc = nested_out_bc.first(n)

#puts as.inspect
#puts nested_out_bc.inspect

as.size.times do |i|
  as[i] = [as[i], nested_out_bc[i]].compact.max
end


puts as.inject(:+)



Measured memory_bytes: 36080
from copy import deepcopy

def getval():
    n = int(input())
    return n

def main(n):
    mod = 10**9 + 7
    #A:0 C:1 G:2 T:3
    dp = [[[1 for i in range(4)] for i in range(4)] for i in range(4)]
    dp[0][2][1] = 0
    dp[0][1][2] = 0
    dp[2][0][1] = 0

    def pow4(arr):
        ans = 0
        for i in range(4):
            ans += arr[i]*(4**(3-i))
        return ans 

    p = []
    for i in range(4):
        p.append(pow4([0,2,1,i]))
        p.append(pow4([0,1,2,i]))
        p.append(pow4([2,0,1,i]))
        p.append(pow4([i,0,2,1]))
        p.append(pow4([i,0,1,2]))
        p.append(pow4([i,2,0,1]))
        p.append(pow4([0,i,2,1]))
        p.append(pow4([0,2,i,1]))

    it1 = iter(p)
    it2 = iter(p)
    co = 0
    di = dict(zip(it1,it2))
    for i in range(n-3):
        temp = [[[0 for i in range(4)] for i in range(4)] for i in range(4)]
        for a in range(4):
            for b in range(4):
                for c in range(4):
                    for d in range(4):
                        if pow4([a,b,c,d]) in di:
                            temp[b][c][d] += 0
                        else:
                            temp[b][c][d] += dp[a][b][c]
                            temp[b][c][d] %= mod
        dp = temp

    ans = 0
    if n>=4:
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    ans += temp[i][j][k]
    elif n==3:
        ans = 61
    ans %= mod
    print(ans)

if __name__=="__main__":
    n = getval()
    main(n)

Measured memory_bytes: 74768