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

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

  int s = 0, m = n;
  while (m > 0) {
    s += m % 10;
    m /= 10;
  }

  if (n % s == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------

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

  cin >> a >> p;

  p += a * 3;
  cout << p / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 250
#define MAX_R 1050
#define INF 1e8
 
int G1[MAX][MAX], G2[MAX][MAX];
int dp[MAX_R][MAX];
 
int main(){
    int N, M;
 
    while(cin >> N >> M ,(N | M)){
	fill(G1[0], G1[MAX], INF);
	fill(G2[0], G2[MAX], INF);
 
	int x, y, t;
	char ch;
	for(int i = 0 ; i < M ; i++){
	    cin >> x >> y >> t >> ch;
	    x--, y--;
	    if(ch == 'L'){
		G1[x][y] = G1[y][x] = t;
	    }else{
		G2[x][y] = G2[y][x] = t;
	    }
	}
     
	for(int i = 0 ; i < N ; i++){
	    G1[i][i] = G2[i][i] = 0;
	}
     
	for(int k = 0 ; k < N ; k++){
	    for(int i = 0 ; i < N ; i++){
		for(int j = 0 ; j < N ; j++){
		    G1[i][j] = min(G1[i][j], G1[i][k]+G1[k][j]);
		    G2[i][j] = min(G2[i][j], G2[i][k]+G2[k][j]);
		}
	    }
	}
 
	int R, z[MAX_R];
	for(int i = 0 ; i < MAX_R ; i++){
	    for(int j = 0 ; j < MAX ; j++){
		dp[i][j] = INF;
	    }
	}
 
	cin >> R;
	for(int i = 0 ; i < R ; i++){
	    cin >> z[i]; z[i]--;
	}
 
	int now = z[0];
	dp[0][now] = 0;
	for(int r = 1 ; r < R ; r++){
	    int next = z[r];
	    for(int j = 0 ; j < N ; j++){
		for(int i = 0 ; i < N ; i++){
		    dp[r][j] = min(dp[r][j], dp[r-1][i] + G1[now][i] + G2[i][j] + G1[j][next]);
		}
		dp[r][j]=min(dp[r][j], dp[r-1][j] + G1[now][next]);
	    }
	    now = next; 
	}
 
	int ans = INF;
	for(int i = 0 ; i < N ; i++){
	    ans = min(ans, dp[R-1][i]);
	}
	cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 4492
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,k,l,a,b;
  char str[1001],info[11],temp,p[1001];
  scanf("%s",str);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",info);
    if(strcmp(info,"print")==0){
      scanf("%d",&a);
      scanf("%d",&b);
      for(j=a;j<=b;j++){
	printf("%c",str[j]);
      }
      printf("\n");
    }
    else if(strcmp(info,"reverse")==0){
      l=0;
      scanf("%d",&a);
      scanf("%d",&b);
      for(j=a;j<b;j++){
	for(k=a;k<b-l;k++){
	  temp=str[k];
	  str[k]=str[k+1];
	  str[k+1]=temp;
	}
	l++;
      }
    }
    else if(strcmp(info,"replace")==0){
      k=0;
      scanf("%d",&a);
      scanf("%d",&b);
      scanf("%s",p);
      for(j=a;j<=b;j++){
	str[j]=p[k];
	k++;
      }
    }
  }
  return(0);
}

Measured memory_bytes: 572
import sys
import math

A, B, C, X, Y = map(int, input().split())

ans = 10**15
a = []

for i in range(max(X, Y)+1):
    if X-i < 0:
        money = B*(Y-i) + 2 * C * i
    elif Y-i < 0:
        money = A*(X-i) + 2 * C * i
    else:
        money = A*(X-i) + B*(Y-i) + 2*C*i
    a.append(money)


print(min(a))

Measured memory_bytes: 12704
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin >> x;
	if(x>=30) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
ans = 1
tmp = "0"
for i in range(n-1):
  if a[i] < a[i+1]:
    if tmp == "-":
      ans += 1
      tmp = "0"
    else:
      tmp ="+"
  elif a[i] > a[i+1]:
    if tmp == "+":
      ans += 1
      tmp = "0"
    else:
      tmp = "-"      

print(ans)

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

int main() {
  
  vector<int> S(5);

  for(int i = 0;i < 5;++i){
    cin >> S[i];
  }
  
  int num;
  int num2 = 13;
  int num3 = 0;
  int num4;
  int num5;
  int num7 = 0;
  
  for(int i = 0;i < 5;++i){
    num4 = S[i] / 10;
    
    if(S[i] % 10 > 0){
      if(S[i] % 10 < num2){
        num5 = num4;
      }
      num2 = min(S[i] % 10,num2);
    }
     
  }
  
  int num6 = num5 * 10 + num2;
  
  
  for(int i = 0;i < 5;++i){
    if(S[i] == num6 && num7 == 0){
      num3 = num3 + num6;
      num7++;
    }
    else if(S[i] % 10 == 0){
      num3 = S[i] + num3;
    }
    else{
      num3 = ((S[i] / 10 + 1) * 10) + num3;
    }
  }
  
  cout << num3 << endl;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long D;
long long a[200005];
pair<long long,int> co1[200005],co2[200005];
struct Node{
	int v,u;
	long long cost;
	Node(int xv=0,int xu=0,long long xcost=0){
		v=xv;u=xu;cost=xcost;
	}
	bool operator <(const Node &a) const{
		return cost<a.cost;
	}
};
vector<Node> edge;
void solve(int l,int r){
	if(l>=r) return;
	int mid=l+r>>1;
//	cout<<l<<" "<<r<<endl;
	solve(l,mid);solve(mid+1,r);
	sort(co1+l,co1+mid+1);sort(co2+mid+1,co2+r+1);
	for(int i=l;i<=mid;i++){
		edge.push_back(Node(co1[i].second,co2[mid+1].second,co1[i].first+co2[mid+1].first));
	}
	for(int i=mid+1;i<=r;i++){
		edge.push_back(Node(co1[l].second,co2[i].second,co1[l].first+co2[i].first));
	}
}
int pa[200005];
int find(int x){
	return (pa[x]==x)?x:pa[x]=find(pa[x]);
}
void merge(int x,int y){
	x=find(x);y=find(y);
	pa[x]=y;
}
int main(){
	scanf("%d %lld",&n,&D);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		co1[i]=make_pair(a[i]-(i+1)*D,i);
		co2[i]=make_pair(a[i]+(i+1)*D,i);
	}
	solve(0,n-1);
	sort(edge.begin(),edge.end());
//	cout<<"lala"<<endl;
	for(int i=0;i<=n;i++) pa[i]=i;
	long long res=0;
	for(int i=0;i<edge.size();i++){
		int v=edge[i].v,u=edge[i].u;
		long long co=edge[i].cost;
//		cout<<u<<" "<<v<<" "<<co<<endl;
		if(find(v)!=find(u)){
			merge(v,u);
			res+=co;
		}
	}
	cout<<res;
}

Measured memory_bytes: 75744
#include<stdio.h>
int main()
{
int ara[11];
int i,j,t;
for(i=0;i<10;i++){
scanf("%d",&ara[i]);
}
for(i=0;i<10;i++){
for(j=i+1;j<10;j++){
  if(ara[i]>ara[j]){
  t=ara[i];
  ara[i]=ara[j];
  ara[j]=t;
    }
  }
 }

 for(i=9;i>6;i--){
 printf("%d\n",ara[i]);
 }
 return 0;

}

Measured memory_bytes: 1028
import copy

n = int(input())
s = list(input())

cnt = [[0]*n for i in range(3)]
r, g, b = 0, 0, 0
for i in range(n-1, -1, -1):
    
    if s[i] == 'R':
        r += 1
        cnt[0][i] = copy.deepcopy(r)
        cnt[1][i] = copy.deepcopy(g)
        cnt[2][i] = copy.deepcopy(b)
    if s[i] == 'G':
        g += 1
        cnt[0][i] = copy.deepcopy(r)
        cnt[1][i] = copy.deepcopy(g)
        cnt[2][i] = copy.deepcopy(b)
    if s[i] == 'B':
        b += 1
        cnt[0][i] = copy.deepcopy(r)
        cnt[1][i] = copy.deepcopy(g)
        cnt[2][i] = copy.deepcopy(b)
        

ans = 0
t = ['R', 'G', 'B']
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j] :
            continue
        if s[i] != 'R' and s[j] != 'R':
            k = 0
        elif s[i] != 'G' and s[j] != 'G':
            k = 1
        else:
            k = 2
        if 2*j - i < n and s[2*j - i] == t[k]:
            ans += cnt[k][j+1] - 1
        else:
            ans += cnt[k][j+1]
print(ans)

Measured memory_bytes: 76008
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
a = l()
L = [[] for _ in range(N)]
ans = 0
for i in range(N):
    L[i].append(a[i])
    if i+1 in L[a[i]-1]:
        ans += 1
print(ans)

Measured memory_bytes: 24600
x, y = map(int, input().split());

MAX = 100000000000000;

# どれが最小かを考える
# そのまま近づける
a = y - x;
if (a < 0):
  a = MAX;
# xを反転させて近づける
b = y + x;
if (b < 0):
  b = MAX;
# yを反転
c = y * (-1) - x;
if (c < 0):
  c = MAX;
# xとyの両方を反転させて近づける
d = y * (-1) + x;
if (d < 0):
  d = MAX;

# 最小を求める
ans = min(a, b + 1, c + 1, d + 2);
print(ans);

Measured memory_bytes: 9112
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  map<string, ll> mp;
  ll ans;
  rep(i, n) {
    sort(s[i].begin(), s[i].end());
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout << ans << endl;

  return 0;
}


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

int main(void)
{
    ll n;
    cin >> n;
    map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;

        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto& p : mp) {
        int s = p.second;
        ans += (ll)s * (s - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


int r, c;
char arr[10][10];
bool done[10][10];



int main(){

    ios_base::sync_with_stdio(0);

    cin>>r>>c;
    for(int i=0;i<r;i++)
        cin>>arr[i];

    int x = 0, y = 0;
    done[x][y] = true;
    while(1){

        if(x+1<r && !done[x+1][y] && arr[x+1][y] == '#'){
            x++;
            done[x][y] = true;
        }
        else if(y+1<c && !done[x][y+1] && arr[x][y+1] == '#'){
            y++;
            done[x][y] = true;
        }
        else{
            break;
        }
    }
   
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            if(arr[i][j] == '#' && !done[i][j]){
                cout<<"Impossible";
                return 0;
            }

    cout<<"Possible";
    return 0;
}







Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N, K = map(int, input().rstrip().split())
ball = {}
for i in input().rstrip().split():
    if i not in ball:
        ball[i] = 1
    else:
        ball[i] += 1
ball_sort = sorted(ball.items(), key = lambda x: x[1])
if len(ball_sort) > K:
    cnt = 0
    for i in range(len(ball_sort) - K):
        cnt += ball_sort[i][1]
    print(cnt)
else:
    print(0)
    

Measured memory_bytes: 42268
//29/12/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;


int main(){
    _fastio
    ll a,b,k;
    cin>>a>>b>>k;

    if(a<=k){
        k-=a;
        a=0;
        if(b<=k){
            b=0;
        }
        else{
            b-=k;
        }
        cout<<a<<' '<<b<<endl;
    }
    else{
        a-=k;
        cout<<a<<' '<<b<<endl;
    }



    return 0;
}


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

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            double ans = 0;

            foreach(int aa in a)
            {
                ans += 1.0 / ((double)aa);
            }
            ans = 1 / ans;

            Console.WriteLine(ans);
        }

    }
}

Measured memory_bytes: 11220
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5 + 5;
ll n, k, ans, a[N];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    int  i = 0, j = k - 1;
    ans = 1e18;
    for(j; j < n; j++, i++)
        ans = min(ans, a[j] - a[i]);
    cout << ans ;
    return 0;
}


Measured memory_bytes: 1024
s = gets.chomp.split
stack = Array.new
s.each do |op|
  if op =~ /\d/ then
    stack.push op
  else
    op1 = stack.pop
    op2 = stack.pop
    buf = eval "(#{op2})#{op}(#{op1})"
    stack.push buf
  end
end
puts stack.pop

Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d[i];

  sort(d.begin(), d.end());
  int l = d[N/2-1];
  int r = d[N/2];
  cout << r - l << endl;
}


Measured memory_bytes: 640
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ok = {}
for i in range(401):
    ok[i**2] = True

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if sum([(x[i][k] - x[j][k])**2 for k in range(d)]) in ok:
            ans += 1
print(ans)

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

int main(){
  int a, b, c;
  cin >>a >> b>>c;
  if(a<=c && c<=b) cout << "Yes" <<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //昇順
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  string s, t;
  cin >> s >> t;
  vector<char> S(s.length());
  vector<char> T(t.length());
  rep_i(i, s.length()){
    S[i] = s[i];
  }
  rep_i(i, t.length()){
    T[i] = t[i];
  }

  sort_v(S);
  d_sort_vi(T);
  int min_len = min(s.length(), t.length());
  rep_i(i, min_len){
    if (S[i] == T[i]){
      continue;
    }else if(S[i] < T[i]){
      say("Yes");
      return 0;
    }else{
      say("No");
      return 0;
    }
  }

  if (s.length() < t.length()){
    say("Yes");
  }else{
    say("No");
  }
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
a = list('abcdefghijklmnopqrstuvwxyz')
S = list(input())
b = list(set(S))
for tmp in b:
    a.pop(a.index(tmp))
if len(a) == 0:
    print("None")
else:
    print(a.pop(0))

Measured memory_bytes: 3956
def merge(A, l, m, r):
    cnt = 0  
    n1 = m-l 
    n2 = r-m  

    L = A[l:m]  
    L.append(float("inf")) 
    R = A[m:r]
    R.append(float("inf")) 

    i_l, i_r = 0, 0  
    for k in range(l, r):
        if L[i_l] <= R[i_r]:
            A[k] = L[i_l]
            i_l += 1
        else:
            A[k] = R[i_r]
            i_r += 1
            cnt += n1 - i_l  
    return cnt


def merge_sort(A, l, r):
    if l + 1 >= r:  
        return 0

    m = (l+r)//2
    ans1 = merge_sort(A, l, m)  
    ans2 = merge_sort(A, m, r)
    ans3 = merge(A, l, m, r)  

    return ans1 + ans2 + ans3


n = int(input())
A = list(map(int, input().split()))
print(merge_sort(A, 0, n))


Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    int ans = 0;
    int ba = 0;
    int b = 0;
    int a = 0;
      
    for(int i = 0; i < n; i++)
    {
        string cand = s[i];
        for(int j = 1; j < cand.size(); j++)
        {
            if(cand[j-1] == 'A' && cand[j] == 'B')
            {
                ans++;
            }
        }
        if(cand[0] == 'B' && cand[cand.size()-1] == 'A')
        {
            ba++;
        }
        else if(cand[cand.size()-1] == 'A')
        {
            a++;
        }
        else if(cand[0] == 'B')
        {
            b++;
        }
    }
  
    if(ba > 0)
    {
        ans += ba - 1;
        if(a > 0)
        {
            ans++;
            a--;
        }
        if(b > 0)
        {
            ans++;
            b--;
        }
        ans += min(a, b);
        cout << ans << endl;
        return 0;
    }
    else
    {
        ans += min(a, b);
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
	int w, h, n;
	scanf("%d %d %d", &w, &h, &n);
	int bx, by, ex, ey;
	scanf("%d %d", &bx, &by);
	int ans = 0;
	for(int i=1; i<n; i++){
		scanf("%d %d", &ex, &ey);
		if((ex - bx) * (ey - by) > 0){
			ans += max(abs((ex - bx)), abs((ey - by)));
		}else{
			ans += abs(ex - bx) + abs(ey - by);
		}
		bx = ex;
		by = ey;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int k = sc.nextInt();
		long ans = 1;
		while(n > 0) {
			n /= k;
			if(n > 0)
				ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
a,b=map(str,input().split())
ans=0
for j in range(int(a),int(b)+1,1):
    i=str(j)
    x=i[0]
    y=i[1]
    z=i[3]
    w=i[4]
    if x==w and y==z:
        ans+=1
print(ans)

Measured memory_bytes: 3060
/**
 * Distance.cpp
 * Create:20180502
 * Description:標準偏差を求めるプログラム
 */
#include <iostream>
#include <cmath>
#include <vector>

/**
 * 平均を求める関数
 * @param  vec 点数を格納した配列
 * @return     平均値
 */
double average(std::vector<int> vec){
  double sum = 0;
  for (int i:vec){
    sum += (double)i;
  }
  double ave = sum / vec.size();
  return ave;
}

/**
 * 標準偏差を求める関数
 * @param  vec 点数を格納した配列
 * @return     標準偏差
 */
double deviation(std::vector<int> vec){
  double ave = average(vec);
  double dev = 0.0;
  for (int i:vec){
    double tmp = (double)i - ave;
    dev += pow(tmp, 2);
  }
  dev = dev / vec.size();
  return sqrt(dev);
}

int main(int argc, char* argv[]){
  std::vector<double> result;

  while (true){
    int count;
    std::cin >> count;
    if (count == 0)
      break;

    std::vector<int> points;
    for (int i = 0; i < count; i++){
      int point;
      std::cin >> point;
      points.push_back(point);
    }

    double dev = deviation(points);
    result.push_back(dev);
  }

  for (double d:result){
    printf("%.8f\n", d);
  }

  return 0;
}


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


int main(){
    const ll mod =1000000007;
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >>a.at(i);
    ll ans =0;
    ll b = 0;
    rep(i,n){
        ans = (ans+a.at(i) * b)%mod;
        b = (b+a.at(i))%mod;
    }
    cout << ans << endl;
    return 0;


}

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

using namespace std;

const int maxn=1e5+10;

int n,k;
int x[maxn];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	
	int l,r;	
	for(l=0;x[l+1]<0&&l<n;l++);
	for(r=n+1;x[r-1]>0&&r>1;r--);
	
	long long ans=2e18;
	k-=r-l-1;
	for(int i=max(0,k-(n-r+1));i<=l&&i<=k;i++)
	{
		long long ll=(i?(-x[l-i+1]):0),rr=((k-i)?x[r+(k-i)-1]:0);
		ans=min(ans,ll+rr+min(ll,rr));
	}
	
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	vll A(N);
	rep(i, 0, N) {
		std::cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<ll>());

	ll ans = 0;
	rep(i, 1, N) {
		ans += A[i / 2];
	}

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


Measured memory_bytes: 4788
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')

int N;
int A;
int m[114514];

int main()
{
	scanf("%d",&N);
	rep(i,N)scanf("%d",&A),m[A+10]++;
	int res=0;
	repn(i,1,114510)MAX(res,m[i]+m[i-1]+m[i+1]);
	printf("%d\n",res);
}

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int flag=0;
  char temp;
  for(int i=0;i<4;i++){
    if(i>0){
      if(s.at(i)==temp){
        flag=1;
      }
    }
    temp=s.at(i);
  }
  if(flag==1){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x = ni()
for a in range(-120, 120):
    for b in range(-120, 120):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            exit(0)

Measured memory_bytes: 9188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	while (1)
	{
		int N = 0; cin >> N;
		if (N == 0) { break; }
		vector<int> num(N, 0);
		int ans = 0;
		rep(i, N){ num[i] = i + 1; }
		rep(i, N)
		{
			for(int j = i; j<N; j++)
			{
				if (accumulate(num.begin() + i, num.begin() + j, 0) == N)
				{
					ans += 1;
				}
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
int main()
{
	int n,tmp=0,maxx=0;
	char c;
	cin>>n;
	while(cin>>c){
		if(c=='I') tmp++;
		else tmp--;
		maxx=max(maxx,tmp);
	}
	cout<<maxx;
	return 0;
}
/*

*/


Measured memory_bytes: 256
#include<stdio.h>
int H,W,A,B,fac[222222];
#define mod 1000000007
int add(int x,int y){
	return (x+=y)<mod?x:x-mod;
}
int mul(int x,int y){
	return (int)((long long int)x*y%mod);
}
int pw(int x,int y){
	int r=1;
	while(1){
		if(y&1)r=mul(r,x);
		if(y>>=1)x=mul(x,x);else
			break;
	}
	return r;
}
int inv(int x){
	return pw(x,mod-2);
}
int c(int x,int y){
	--x;--y;
	return mul(fac[x+y],inv(mul(fac[x],fac[y])));
}
int main(){
	fac[0]=1;
	for(int i=1; i<222222; i++)
		fac[i] = mul(fac[i-1],i);
	scanf("%d%d%d%d",&H,&W,&A,&B);
	int res = 0;
	for(int i=B+1; i<=W; i++)
		res = add(res, mul(c(H-A,i),c(A, W-i+1)));
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

  class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
  
      int n = sc.nextInt();
      int k = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      
      int price = 0;
      
      if(n>k){
        price = x*k + (n - k)*y;
      }else{
        price = x*n;
      }
      
      System.out.println(price);
  }
}

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

int main()
{
        ll N;
        cin>>N;
        ll A[N]={},B[N]={},C[N]={};
        ll i,j,k;

      ll  bal[N][3]={};


        for(i=0;i<N;i++){
                        cin>>A[i]>>B[i]>>C[i];

                for(j=0;j<3;j++){
                                if(i==0){
                                        if(j==0)bal[i][0]=bal[i][0]+A[i];
                                        else if(j==1)bal[i][1]=bal[i][1]+B[i];
                                        else bal[i][2]=bal[i][2]+C[i];
                                }
                                else {
                                        for(k=0;k<3;k++){
                                                if(j==k)continue;
                                                else if(j==0){
                                                            bal[i][j]=max(bal[i][j],bal[i-1][k]+A[i]);
                                                                }
                                                else if(j==1){
                                                          bal[i][j]=max(bal[i][j],bal[i-1][k]+B[i]);
                                                }
                                                else{
                                                        bal[i][j]=max(bal[i][j],bal[i-1][k]+C[i]);
                                                }
                                        }
                                }
                }
        }
        //cout<<bal[N-1][0]<<" "<<bal[N-1][1]<<" "<<bal[N-1][2];

        ll xx=max(bal[N-1][0],bal[N-1][1]);
        xx=max(xx,bal[N-1][2]);

        cout<<xx<<endl;
        return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int h,w;
char a[110][110];
bool x[110],y[110];
signed main(){
    cin>>h>>w;
    rep(i,h)x[i]=true;
    rep(i,w)y[i]=true;
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                x[i]=false;
                y[j]=false;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(x[i]==true)continue;
            if(y[j]==true){
                if(j+1==w)cout<<endl;
                continue;
            }
            cout<<a[i][j];
            if(j+1==w)cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys


def main():
    input = sys.stdin.buffer.readline
    h_1, m_1, h_2, m_2, k = map(int, input().split())
    min = h_2 * 60 + m_2 - (h_1 * 60 + m_1)
    print(min - k)


if __name__ == '__main__':
    main()

Measured memory_bytes: 61636
(* Vicfred
 * https://atcoder.jp/contests/abc147/tasks/abc147_a
 * implementation
 * *)
open Printf
open Scanf

let main = scanf "%d %d %d" @@ fun a b c ->
    if a+b+c >= 22 then
        printf "bust\n"
    else
        printf "win\n"



Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>

using namespace std;

int partition(int A[],int p,int r)
{
	int x = A[r];
	int i = p - 1;

	for (int j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			int tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}

	int tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;

	return i + 1;
}

int main(void)
{
	int A[100000];
	int n;
	int q;

	cin >> n;

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

	q = partition(A, 0, n - 1);

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

		if (i > 0) {
			putchar(' ');
		}

		if (i == q) {
			cout << '[' << A[i] << ']';
		}
		else {
			cout << A[i];
		}
	}

	putchar('\n');

	return 0;
}

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

int main() {
	int x,a,b;
  	cin>>x>>a>>b;
  
  	if(abs(a-x)<abs(b-x)){
 	   cout<<"A"<<endl;
    }else{
       cout<<"B"<<endl;
    }
}
 

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

int main(){
   int a,b;
    cin>>a>>b;
   int count=0;
   for(int i = a;i<=b;i++){
       int s=i%10;
       int t=i/10%10;
       int u=i/1000%10;
       int v=i/10000%10;
     if(s==v&&t==u){
       count++;
     }
   }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a;
    cin >> a;

    if(a == 7 or a == 5 or a == 3) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int desc(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}

int main(){
  int n;
  scanf("%d",&n);
  int a[100001];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  qsort(a,n,sizeof(a[0]),desc);
  int temp=1000000001;
  int flg=0,num=0;
  for(int i=0;i<n;i++){
    if(temp!=a[i]){
      flg=0;
      num+=1;
      temp=a[i];
    }
    else{
      if(flg==0){
        flg=1;
        num-=1;
      }
      else{
        flg=0;
        num+=1;
      }
    }
  }
  printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

const int MAX_N=1e5;

int N,A[MAX_N];

int main(){
	cin>>N;
	ll sum=0;
	REP(i,N){
		cin>>A[i];
		sum+=A[i];
	}
	sort(A,A+N);
	int ans=1;
	REP(i,N-1){
		sum-=A[N-i-1];
		if (sum*2>=A[N-i-1]){
			ans++;
		}else{
			break;
		}
	}
	cout<<ans<<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++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n + 1);
	REP(i, n) {
		cin >> a[i];
	}
	while (k--) {
		vector<ll> imos(n+2);
		bool exist = true;
		REP(i, n) {
			if (a[i] != n) exist = false;
		}
		if (exist) break;
		REP(i, n) {
			imos[max(1LL, i - a[i])]++;
			imos[min(n+1, i + a[i] + 1)]--;
		}
		REP(i, n) {
			if (i > 0) imos[i] += imos[i-1];
			a[i] = imos[i];
		}
	}
	REP(i, n) {
		cout << a[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6424
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;

  int n,m,v;
  set<int> a,b;
  cin >> n;

  for(ii=0;ii<n;ii++){
    cin >> v;
    a.insert(v);
  }

  cin >> m;

  for(ii=0;ii<m;ii++){
    cin >> v;
    b.insert(v);
  }

  set<int>::iterator it;
  set<int> c;
  it = a.begin();

  while(it != a.end()){
    if(b.find(*it) == b.end()){
      c.insert(*it);
    }
    it++;
  }

  it = c.begin();
  
  while(it != c.end()){
    cout << *it << endl;
    it++;
  }
  
  return 0;
  
}



Measured memory_bytes: 31224
def main():
    S = input()
    s = set()
    for i in range(2**len(S)):
        tmp = S[0]
        for j in range(1,len(S)):
            if (i >> j) & 1:
                tmp += '+' + S[j]
            else:
                tmp += S[j]
        s.add(tmp)
    ans = 0
    for a in s:
        ans += eval(a)
    print(ans)



if __name__ == "__main__":
    main()

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

int h[3][100005], a[100005], b[100005], c[100005];

int main(){

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

    h[0][1] = a[1];
    h[1][1] = b[1];
    h[2][1] = c[1];

    for(int i = 2; i <= n; i++){
        h[0][i] = max({h[0][i - 2] + a[i], h[1][i-1] + a[i], h[2][i-1] + a[i]});
        h[1][i] = max({h[1][i - 2] + b[i], h[0][i-1] + b[i], h[2][i-1] + b[i]});
        h[2][i] = max({h[2][i - 2] + c[i], h[0][i-1] + c[i], h[1][i-1] + c[i]});
    }

    cout << max({h[0][n], h[1][n], h[2][n]}) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a;i<(ll)b;i--)
#define Fi fiest
#define Se second
const ll MAX = 1000000;
const char ENDL = '\n';

ll i, j, N, Q, M, k, n = 0, A[MAX], B[MAX], p[MAX], x[MAX];
ll Ans = 0, sub = 0, judge = 0;
string T;
vector<char> S;
char vec[10];

//vector<pair<cc, cc>>pairs(N);

ll to_lli(char c) {
	return c - 'a';
}

ll sx, sy, tx, ty;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> sx >> sy >> tx >> ty;

	rep(i, ty - sy)
		S.push_back('U');
	rep(i, tx - sx)
		S.push_back('R');
	rep(i, ty - sy)
		S.push_back('D');
	rep(i, tx - sx)
		S.push_back('L');

	S.push_back('L');
	rep(i, ty - sy + 1)
		S.push_back('U');
	rep(i, tx - sx + 1)
		S.push_back('R');
	S.push_back('D');
		
	S.push_back('R');
	rep(i, ty - sy + 1)
		S.push_back('D');
	rep(i, tx - sx + 1)
		S.push_back('L');
	S.push_back('U');

	rep(i,S.size())
	cout << S[i];

	cout << ENDL;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        String[] points = point.split(" ");
        int n = Integer.parseInt(points[0]);
        int d = Integer.parseInt(points[1]);

        int d2 = d * 2 + 1;

        //きりあげ
        double kiriage = Math.ceil((double)n / d2);

        System.out.println((int)kiriage);
    }
}

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

void print(auto x) {
    cout << x << endl;
}

ll sum(auto x) {
    return accumulate(x.begin(), x.end(), 0LL);
}

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    string x = string(A, '0') + string(W-A, '1');
    for (int i = 0; i < B; i++) cout << x << endl;
    x = string(A, '1') + string(W-A, '0');
    for (int i = B; i < H; i++) cout << x << endl;
}


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

int main(int argc, const char * argv[]) {
    uint64_t X;
    cin >> X;
    uint64_t ans = 0;
    
    uint64_t x;
    x = X / 500;
    ans += 1000 * x;
    X = X - 500 * x;
    
    x = X / 5;
    ans += 5 * x;

    cout << ans;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

//a * b > 1e18
// a > 1e18 / b
const lli limit = 1000000000000000000LL;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    lli ans = 1, a;
    for (int i = 0; i < n; i++)
    {
      scanf("%lld", &a);
      if (a == 0)
      {
        ans = 0;
        continue;
      }
      if (ans > limit / a)
        ans = -1;
      else if (ans != -1)
        ans *= a;
      if (ans > limit)
        ans = -1;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

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

s = []
for i in range(2, int(n**0.5)+1):
  t = 0
  while n%i == 0:
    n //= i
    t += 1
  s.append(t)
  if n == 1: break

if n > 1: s.append(1)
  
ans = 0
for i in s:
  for j in range(1, i+1):
    if i >= j:
      i -= j
      ans += 1
    else:
      break
print(ans)

Measured memory_bytes: 17140
#include<iostream>
#include<cstdio>
#include<cstring>

namespace ShengXianTi
{
	const int N=301000,MOD=1000000007;
	inline void inc(int a,int &b){b=(a+b)%MOD;}

	int f[N][2][3][3];
	char s[N];
	int n;

	void dp()
	{
		s[n+1]='1',f[0][1][0][0]=1;

		for(int p=0;p<=n;p++)
			for(int r=0;r<2;r++)
				for(int k=0;k<3;k++)
					for(int sta=0;sta<3;sta++)
					{
						int v=f[p][r][k][sta];
						if(s[p+1]=='?' || s[p+1]=='0')
						{
							if(k==0)inc(v,f[p+1][r][1][sta]);
							else inc(v,f[p+1][r][k^3][sta]);
						}
						if(s[p+1]=='?' || s[p+1]=='1')
						{
							if(sta==2)
								inc(v,f[p+1][r^(k!=1)][0][sta]);
							else if(sta==1)
								inc(v,f[p+1][r^(k!=1)][0][sta+(r==0 && k==0)]);
							else if(sta==0)
								inc(v,f[p+1][r^(k!=1)][0][sta+(r==1 && k==0)]);
						}
					}
	}

	void solve()
	{
		scanf("%s",s+1);
		n=strlen(s+1);
		dp();

		int ans=0;
		inc(f[n+1][0][0][2],ans);
		inc(f[n+1][1][0][2],ans);
		printf("%d\n",ans);
	}
}

int main()
{
	ShengXianTi::solve();
	return 0;
}


Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll sum=0,m=inf;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		sum+=x;
		if(x%10!=0){
			m=min(m,x);
		}
	}
	if(sum%10!=0){
		cout<<sum;
		return 0;
	}
	cout <<max(ll(0),sum-m);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char str[200];
	int i;
	
	fgets(str, 200, stdin);
	
	for (i = 0; str[i] != '\0'; i++){
		str[i] = toupper(str[i]);
	}
	
	printf("%s", str);
	
	return (0);
}

Measured memory_bytes: 520
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef long long ll;
const int mod=998244353;
#define IO cin.tie(0),ios::sync_with_stdio(false);
#define pi acos(-1)
#define PII pair<ll,ll>
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()
/** keep hungry and keep calm! **/


int Sheryang(){
    ll a=read,b=read;
    if(b%a){
        printf("%lld\n",b-a);
    }else{
        printf("%lld\n",b+a);
    }

    return 0;
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt powmod(lnt a, lnt p, lnt m){
	lnt res = 1, tmp = a;
	while(p != 0){
		if(p % 2) res = (res*tmp) % m;
		tmp = (tmp*tmp) % m;
		p >>= 1;
	}
	return res;
}

int main(){
	summon_tourist;

	lnt K; cin >> K;
	lnt cnt = 0, num = 0;
	while(1){
		if(cnt == 1000000){
			cout << -1 << ln;
			break;
		}
		num += 7 * powmod(10, cnt, K);
		num %= K;
		if(num == 0){
			cout << cnt+1 << ln;
			break;
		}
		cnt++;
	}
}

Measured memory_bytes: 3656
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[10];
    cin>>s;
    sort(s,s+4);
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])
    cout<<"Yes\n";
    else
    cout<<"No\n";
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}


//---------------------------------------------------------------

int main(){
  ll N;
  cin>>N;
  ll count = 1;
  ll c = 0;
  while(1){
    if(count%3==0||count%5==0){
      c+=0;

    }else {
      c+=count;
    }
    if(count==N){
      break;
    }
      count++;
  }


  cout<<c<<endl;












}


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

//Compiler version g++ 6.3.0

int main()
{
    long long a,b,c;
    cin>>a>>b;
    if(a>b)
    {
      if(a%b==0)
      {
        c=a/b;
        cout<<c;
        return 0;
        
      }
      else
      {
        c=a/b + 1;
        cout<<c;
        return 0;
      }
      
    }
    
    else
    {
      cout<<"1";
    }
  }

Measured memory_bytes: 256
import math
N = int(input())

nlist=[""]*N
d={}
for i in range(N):
    t=str(input())
    t=''.join(sorted(t))
    if d.get(t,None)==None:
        d[t]=1
    else:
        d[t]+=1 
ans=0

#print(d.keys(),d.values())
for i in d.values():
    ans += i*(i-1)/2
print(int(ans))


Measured memory_bytes: 18700