akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ac,ab,bc;
	ac = a-c;
	bc = b-c;
	ab = a-b;
	if(ac<0) ac = 0 - ac;
	if(bc<0) bc = 0 - bc;
	if(ab<0) ab = 0 - ab;
	if(ac<=d) cout<<"Yes"<<endl;
	else if(ab<=d&&bc<=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    float ans = 0;
    REP(i, N)
    {
        float x; cin >> x;
        string u; cin >> u;
        if(u == "BTC") x *= 380000;
        ans += x;
    }
    cout << ans << endl;
}
    
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
//package src.com.jetman.atcoder;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @description:
 * @author: Jetman
 * @create: 2020-08-29 14:39
 **/
public class Main {

    Scanner sc = new Scanner(System.in);

    private void slove() {
        long d = sc.nextLong();
        long t = sc.nextLong();
        long s = sc.nextLong();



        System.out.println((double)d/s > t  ? "No":"Yes");
    }

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


Measured memory_bytes: 35704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    vector<pair<int,int>> xy(N);
    rep(i,N) cin >> xy[i].first >> xy[i].second;
    sort(all(xy));
    
    int ans = 10000;
    if(N==1) ans = 1;
    
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int x = xy[j].first - xy[i].first;
            int y = xy[j].second - xy[i].second;
            
            int an = 0;
            vector<bool> f(N, true);
            
            pair<int, int> a,b;
            
            for (int k = 0; k < N; k++) {
                if(f[k]){
                    an++;
                    f[k] = false;
                    a = xy[k];
                    for (int l = k+1; l < N; l++) {
                        if(f[l]){
                            b = xy[l];
                            if(a.first+x == b.first && a.second+y == b.second){
                                f[l] = false;
                                a = b;
                            }
                        }
                        
                    }
                }
                
            }
            ans = min(an,ans);
            
        }
    }
    cout << ans << endl;
    
    return 0;
}



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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

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



void func(long long N, long long K){

    lli ans=1;

    REP(i,0,N){
        if(i==0)ans*=K;
        else ans*=(K-1);
    }

    cout<<ans<<endl;


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    func(N, K);
    return 0;
}


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


int main() {
int N;
cin >> N;
vector<int64_t> vec(N);
for (int i = 0;i < N;i++)  cin >> vec.at(i);

int64_t max = -1,min = 1000000000;
for (int i = 0;i < N;i++) {
    if (vec.at(i) > max) max = vec.at(i);
    if (vec.at(i) < min) min =vec.at(i);
}
cout << max - min << endl;
return 0;
}

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

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

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0,c = a-1,d = b-1;
  ans = max(ans,a+a-1);
  ans = max(ans,a+b);
  ans = max(ans,b+b-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

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

	int k, n;
	cin >> k >> n;
	vector<int> arr(n), a(n);
	for (int i = 0; i < n; ++i) cin >> arr[i];
	arr.push_back(k + arr[0]);
	for (int i = 0; i < n; ++i) {
		a[i] = arr[i + 1] - arr[i];
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	int min_k = sum;
	for (int i = 0; i < n; ++i) {
		min_k = min(min_k, sum - a[i]);
	}
	cout << min_k;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll C[100005]={};
int n,m;
vector<int> v[100005];
int main() {
	int n,a,b,p[101],k[3]={};
	cin>>n;
	cin>>a>>b;
	rep(i,0,n){
		cin>>p[i];
		if(p[i]<=a)++k[0];
		if(p[i]>a&&p[i]<=b)++k[1];
		if(p[i]>b)++k[2];
	}
	cout<<min(min(k[0],k[1]),k[2])<<endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    double sum = 0.0;
    for (int i = 0; i < N; i++) {
      sum += a[i];
    }
    double mean = sum / N;
    double min = 1000.0;
    int idx = -1;
     for (int i = 0; i < N; i++) {
       double tmp = Math.abs(mean - a[i]); 
       if (tmp < min) {
         min = tmp;
         idx = i;
       }
    }
    System.out.println(idx);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int N;
pair<P, int> points[201]; // x, y, color
bool is_used[201];

int main(void){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> points[i].first.first >> points[i].first.second;
		points[i].second = 0;
	}
	for(int i = 0; i < N; i++){
		cin >> points[i+N].first.first >> points[i+N].first.second;
		points[i+N].second = 1;
	}

	sort(points, points+2*N);

	int res = 0;

	for(int i = 2*N-1; i >= 0; i--){
		if(points[i].second == 1) continue;
		int x = points[i].first.first, y = points[i].first.second;
		int idx = -1, min = INF;
		for(int j = i+1; j < 2*N; j++){
			if(points[j].second == 0 or is_used[j] == true) continue;
			int nx = points[j].first.first, ny = points[j].first.second;
			if(x<nx and y<ny){
				// printf("match: (%d, %d) - (%d, %d)\n", x, y, nx, ny);
				if(min > ny){
					min = ny;
					idx = j;
				}
			}
		}
		if(idx != -1){
			is_used[idx] = 1;
			res++;
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<iostream>
using namespace std;

#define N (200001)

int n, m;
vector<int> g[N];

queue<int> q;
bool inq[N];
int d[N];

void spfa() {
	for(int i = 1; i <= n; i++) d[i] = 0x7fffffff;
	d[1] = 0;
	
	q.push(1);
	inq[1] = 1;
	while(!q.empty()) {
		int u = q.front(); q.pop();
		inq[u] = 0;
		for(int i = 0; i < g[u].size(); i++) {
			int v = g[u][i];
			if(d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				if(!inq[v]) q.push(v), inq[v] = 1;
			}
		}
	}
	if(d[n] != 2) printf("IM");
	printf("POSSIBLE\n");
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	spfa();
	return 0;
}

Measured memory_bytes: 13424
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,K;
    cin >> N >> K;
    vector<ll> a(N),S1(N+1),S2(N+1);
    rep(i,N){
        cin >> a[i];
        S1[i+1] = S1[i] + a[i];
        S2[i+1] = S2[i] + (a[i]>=0?a[i]:0);
    }
    ll ans = 0;
    for(int i= 0;i+K<=N;i++){
        int left = i, right = i + K;
        long long t = (S2[left] - S2[0]) + max(0LL, S1[right] - S1[left]) + (S2[N] - S2[right]);
        ans = max(ans,t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
m, n = gi()
l = gi()
if (sum(l) > m):
	print(-1)
else:
	print(m - sum(l))

Measured memory_bytes: 10188
/*
ID: Aman Raj
LANG: C++
TASK: castle
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;


int main()
{
     ll n;cin>>n;
      vector<vector<ll> > v(n);
      for(ll i=0;i<n;i++)
      {
          v[i].resize(3);
          for(ll j=0;j<3;j++)cin>>v[i][j];
      }
      vector<vector<ll> > dp(n);
      dp[0]=v[0];
      for(ll i=1;i<n;i++)
      { dp[i].resize(3);
         dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
         dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
         dp[i][2]=max(dp[i-1][1],dp[i-1][0])+v[i][2];

      }
      cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


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

int main(){
   int N;
   cin>>N;
   vector<int> vec(N);
   bool ans=true;
  
   for(int i=0;i<N;i++){
   cin>>vec.at(i);
   }
  
   sort(vec.begin(),vec.end());
   for(int i=0;i<N-1;i++){
      if(vec.at(i)==vec.at(i+1)){
         ans=false;
      }
   }
  
   if(ans==true){
   cout<<"YES"<<endl;
   }
  
   if(ans==false){
   cout<<"NO"<<endl;
   }
}

Measured memory_bytes: 1024
#include <stdio.h>

int exp(int x, int p) {
	int i;
	int ret;

	for(ret = 1, i = 0; i < p; i++) {
		ret *= x;
	}

	return ret;
}

int main() {
	long n;
	int five;
	int tmp_five;
	int i;

	scanf("%ld", &n);

	while(n) {
		for(i = 1, five = 0; tmp_five = n / exp(5, i); i++) {
			five += tmp_five;
		}

		printf("%d\n", five);
		fflush(stdout);
		scanf("%ld", &n);
	}

	return 0;
}

Measured memory_bytes: 600
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 3005, M = 1000005;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n;
double p[N],dp[N][N];

double calc(int i,int j) {
    if(i==n)
        return (j > n-j ? 1.0 : 0.0);
    double &r = dp[i][j];
    if(r > -1)
       return r;
    r = calc(i+1, j+1) * p[i];
    r += calc(i+1, j) * (1.0 - p[i]);
    return r; 
}

int main() {
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%lf",p+i);
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
            dp[i][j] = -100;
    printf("%.9lf\n", calc(0,0));
    return 0;
}

Measured memory_bytes: 70784
n,k = map(int,input().split())
X = list(map(int, input().split()))

ans = 10**10
for i in range(n-k+1):
  d1 = abs(X[i]) + abs(X[i] - X[i+k-1])
  d2 = abs(X[i+k-1]) + abs(X[i] - X[i+k-1])
  if ans > min(d1, d2):
    ans = min(d1,d2)
if ans == 10**10:
  print(0)
else:
  print(ans)




Measured memory_bytes: 85044
using System;
using System.Collections.Generic;


class A
{
	public static void Main ()
	{

		int[] output = new int[26];


		while (true) {
			string s = Console.ReadLine ();

			if (s == null|| s.Length == 0)
				break;
			string s2 = s.ToUpper ();


			for (int i=0; i	<s2.Length; i++) {
				if (s2 [i] >= 'A' && s2 [i] <= 'Z') {
					output [(int)s2 [i] - 'A']++;
				}
			}

		}

		for (int i =0; i<output.Length; i++) {
			Console.WriteLine ("{0} : {1}", Convert.ToChar (i + 'a'), output [i]);
		}
	}
}

Measured memory_bytes: 9136
#include <stdio.h>

int main(void)
{
  int n = 0;
  int m = 0;
  int l = 0;
  int a[101][101];
  int b[101][101];
  int i, j, k;
  long sum = 0;
  
  scanf("%d %d %d", &n, &m, &l);

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

  for(i = 0; i < m; i++){
    for(j = 0; j < l; j++)
      scanf("%d ", &b[i][j]);
  }
    
  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      for(k = 0; k < m; k++)
	sum += a[i][k] * b[k][j];
      if(j == l -1)
	printf("%ld\n", sum);
      else
	printf("%ld ", sum);
      sum = 0;
    }
  }

  return 0;
}

Measured memory_bytes: 684
def main():
    N,M = map(int,input().split())
    if N == 1 or M == 1:
        if N == M:
            print(1)
        else:
            print(N*M-2)
    else:
        print(N*M-2*(N+M-2))

if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;


const int MOD = 998244353;

class Edge{
public:
    ll from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int main(){
    int N;cin >> N;
    vector<pair<int, int>> vec;
    for(int i = 0;i < N;i++){
        int a,b;cin >> a >> b;
        vec.push_back({a, b});
    }
    sort(vec.begin(), vec.end());
    long double ans = 0;
    do{
        pair<int, int> p = vec.front();
        for(int i = 1;i < N;i++){
            ans += sqrt(pow(p.first-vec.at(i).first, 2) + pow(p.second-vec.at(i).second, 2));
        }
    }while(next_permutation(vec.begin(), vec.end()));
    ll a = 1;
    for(int i = 2;i <= N;i++)a *= i;
    cout<<setprecision(20)<<ans / a<<endl;
}


Measured memory_bytes: 256
from collections import Counter
from functools import reduce
import bisect
import copy
import fractions
import math
# import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

n, s = II(), LS()
print("Four") if len(set(s)) == 4 else print("Three")


Measured memory_bytes: 5256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>

using namespace std;


void p(vector<int> v){
	for(int j = 0; j < v.size(); j++){
		cout << v[j] << " ";
	}
	cout << endl;
}

void p(vector<vector<int> > v){
	for(int i = 0; i < v.size(); i++){
		p(v[i]);
	}
}

vector<int> tsort(vector<vector<int> > v){
	vector<int> ret;
	for(int i = 1; i < v.size(); i++){	// 正方2次元配列なのでv.size
		bool ishead = true;
		for(int j = 1; j < v.size() && ishead; j++){
			// 縦に見る、縦が全て0ならば先頭の可能性あり
			ishead &= (v[j][i] == 0);
		}
		if(ishead == true){
			ret.push_back(i);
			// iに繋がっているものを消す
			for(int j = 1; j < v.size(); j++){
				v[i][j] = 0;
			}
			v[i][i] = 2;	// 縦が全て0になるのを防止
			i = 0; // 最初からやり直し
			//cout << endl;
			//p(v);
		}
	}
	return ret;
}

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

	m++;
	vector<vector<int> > v(m);

	for(int i = 0; i < m; i++){
		v[i].resize(m, 0);
	}

	while(n--){
		int x, y;
		cin >> x >> y;
		v[x][y] = 1;
	}

	//p(v);
	vector<int> sorted = tsort(v);

	//p(v);
	//p(sorted);

	for(int i = 0; i < sorted.size(); i++){
		cout << sorted[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;



int main(void) {
	int n, m, c;
	int cnt = 0;
	int a[205], b[205];
	cin >> n >> m >> c;
	REP(i, m) cin >> b[i];
	REP(i, n) {
		REP1(j,m){
			cin >> a[j];
		}
		int sum = 0;
		for (int z = 0; z < m; z++) {
			sum += (a[z] * b[z]);
		}
		if ((sum + c) > 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int64_t n;
    int k;
    cin>>n>>k;
    int64_t ans=0;
    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }
    for(int b=k+1;b<=n;b++){
        int p;//aをbで割ったあまりの数列の個数
        p = n/b;
        //1この塊のなかに、条件に合うのはb-k
        int amari = n%b;
        //切れ端amari個の中で条件に合うのはamari-k+1個
        //amari = 5 => 1,2,3,4,5  k = 3だったらその中の3,4,5 が条件にあう
        //amari=3 -> 1,2,3 k=5だったら、amari-k+1が負になるので、その場合はつまり0
        ans += p*(b-k) + max(amari-k+1,0);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        if((N-1) % (K-1) == 0){
            System.out.println((N-1)/(K-1));
        } else {
            System.out.println((N-1)/(K-1) + 1);
        }

    }

}

Measured memory_bytes: 23636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, d := nextInt(), nextInt()
	nn := make([][]int, n, n)

	for i := 0; i < n; i++ {
		nn[i] = make([]int, d, d)
		for index := 0; index < d; index++ {
			nn[i][index] = nextInt()
		}
	}

	var re int
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i == j {
				continue
			}
			var v float64
			for index := 0; index < d; index++ {
				v += math.Pow(math.Abs(float64(nn[i][index]-nn[j][index])), 2)
			}

			vv := fmt.Sprintf("%v", math.Sqrt(v))

			if !strings.Contains(vv, ".") {
				re++
			}
		}
	}

	fmt.Println(re)
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool black = false;
  vector<int> sum(n + 1, 0);
  for(int i = 0; i < n; i++) {
    if(s[i] == '#') {
      sum[i + 1] = sum[i] + 1;
      black = true;
    } else {
      sum[i + 1] = sum[i];
    }
  }
  int mini = 1001001001;
  for(int i = 0; i <= n; i++) {
    int pre = sum[i];
    mini = min(mini, n - i - (sum[n] - pre) + pre);
  }
  cout << mini << endl;

  return 0;
}

Measured memory_bytes: 1412
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

int a,b; 

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(a);in(b);
    out(b+max(0,100*(10-a)));
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 256
/*
maximize: floor(Ax/B) - A * floor(x/B)
maximize: floor(Ax/B - A * floor(x / B))
floor前を最大化しても解は変化しない
maximize: Ax/B - A * floor(x / B)
maximize: A(x/B -  floor(x / B))
maximize: x/B -  floor(x / B)
 */

use std::io::Read;

fn main() {
    let mut line = String::new();
    std::io::stdin().read_to_string(&mut line);
    let mut iter = line.split_whitespace();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();
    let n: i64 = iter.next().unwrap().parse().unwrap();
    if b <= n {
        let x = b - 1;
        println!("{}", a * x / b - a * (x / b))
    } else {
        let x = n;
        println!("{}", a * x / b - a * (x / b))
    }

}


Measured memory_bytes: 2152
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
	string S,L="qwertasdfgzxcvb";
	while(cin>>S,S[0]!='#') {
		vector<bool> v;
		for(int i=0;i<S.size();i++) {
			bool b=0;
			for(int j=0;j<L.size();j++) {
				if(S[i]==L[j]) b=1;
			}
			v.push_back(b);
		}
		int sum=0;
		for(int i=1;i<v.size();i++) {
			if(v[i-1]!=v[i]) sum++;
		}
		cout<<sum<<endl;
	}
}

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

int main(void){
    ll N; cin >> N;
    int ans = 100;
    for(ll A = 1; A * A <= N; A++){
        if(N % A == 0){
            ll B = N/A;
            int t = 0;
            while(B > 0){
                B /= 10;
                t++;
            }
            ans = min(ans, t);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
sx, sy, tx, ty=map(int, input().split())
ans=[]

for i in range(abs(ty-sy)):
	ans.append("U")
for i in range(abs(tx-sx)):
	ans.append("R")
for i in range(abs(ty-sy)):
	ans.append("D")
for i in range(abs(tx-sx)):
	ans.append("L")

ans.append("L")
for i in range(abs(ty-sy)+1):
	ans.append("U")
for i in range(abs(tx-sx)+1):
	ans.append("R")
ans.append("D")

ans.append("R")
for i in range(abs(ty-sy)+1):
	ans.append("D")
for i in range(abs(tx-sx)+1):
	ans.append("L")
ans.append("U")

print(''.join(ans))

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int amin = a[0];
        int aMax = a[n - 1];

        for (int i = 0 ; i < m ; i++) {
            b[i] = sc.nextInt();

        }
        Arrays.sort(b);

        int bmin = b[0];
        int bmax = b[m - 1];
        if (aMax < bmin && bmin > x && aMax < y) {
            System.out.println("No War");
        } else {
            System.out.println("War");
        }


    }
}


Measured memory_bytes: 22996
d=list(map(int,input().split()))
o=[]
for i in input():
	o.append(i)
for i in range(len(o)):
	if o[i]=='N':
		d[0],d[1],d[4],d[5]=d[1],d[5],d[0],d[4]
	elif o[i]=='S':
		d[0],d[4],d[5],d[1]=d[4],d[5],d[1],d[0]
	elif o[i]=='E':
		d[0],d[3],d[5],d[2]=d[3],d[5],d[2],d[0]
	elif o[i]=='W':
		d[0],d[2],d[5],d[3]=d[2],d[5],d[3],d[0]
print(d[0])
	


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=p[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	long long n;
	cin >> n;
	long long ans = (n - 1) * n / 2;

	cout << ans << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
n = int(input())
S = sorted(set(list(map(int, input().split()))))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
for t in T:
    l, r = 0, len(S)
    while l < r:
        m = (l+r) // 2
        if S[m] == t:
            cnt += 1
            break
        elif t < S[m]:
            r = m
        else:
            l = m+1
print(cnt)

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

vector<pair<int,int> > nei[1000005];
map<pair<int,int>,vector<int> > ne;
vector<int> cit[1000005];
vector<int>comp;
int col[1000005];
bool vis[1000005];
vector<int>newnei[1000005];
int dp[1000005];
int main()
{
	int n,m;
	cin>>n>>m;
	memset(col,-1,sizeof col);
	for(int i=0;i<m;i++)
	{
		int x,y,c;
		cin>>x>>y>>c;
		x--,y--,c--;
		ne[make_pair(x,c)].push_back(y);
		ne[make_pair(y,c)].push_back(x);
		cit[c].push_back(x);
		cit[c].push_back(y);
		comp.push_back(c);
	}
	sort(comp.begin(),comp.end());
	comp.erase(unique(comp.begin(),comp.end()),comp.end());
	int newci=n;
	for(int i=0;i<comp.size();i++)
	{
		int cmp=comp[i];
		for(int j=0;j<cit[comp[i]].size();j++)
		{
			int v=cit[comp[i]][j];
			if(col[v]==cmp) continue;
			queue<int> q;
			q.push(v);
			col[v]=cmp;
			vector<int> ciin;
			while(!q.empty())
			{
				v=q.front();
				ciin.push_back(v);
				q.pop();
				for(int k=0;k<ne[make_pair(v,cmp)].size();k++)
				{
					int u=ne[make_pair(v,cmp)][k];
					if(col[u]==cmp) continue;
					col[u]=cmp;
					q.push(u);
				}
			}
			for(int k=0;k<ciin.size();k++)
			{
				int v=ciin[k];
				newnei[v].push_back(newci);
				newnei[newci].push_back(v);
			}
			newci++;
		}
	}
	queue<int>q;
	for(int i=0;i<newci;i++) dp[i]=-2;
	dp[0]=1;
	q.push(0);
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int k=0;k<newnei[v].size();k++)
		{
			int u=newnei[v][k];
			if(dp[u]==-2)
			{
				dp[u]=dp[v]+1;q.push(u);
			}
			
		}
	}
	cout<<dp[n-1]/2;
}

Measured memory_bytes: 138996
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] i = Console.ReadLine().Split();
            int w = int.Parse(i[0]),
                h = int.Parse(i[1]),
                x = int.Parse(i[2]),
                y = int.Parse(i[3]),
                r = int.Parse(i[4]);
            string arranged = "Yes";

            if (x < r || x > w-r || y < r || y > h-r)
            {
               arranged = "No";
            }
            Console.WriteLine(arranged);
        }
    }
}


Measured memory_bytes: 8972
#include <cstdio>
#include <string>

using namespace std;

int main() {
    char S[3][128];
    for (int i=0; i<3; ++i)
        scanf("%s", S[i]);

    size_t pos[3]={};
    int next=0;
    while (true)
        if (S[next][pos[next]]) {
            next = S[next][pos[next]++]-'a';
        } else {
            return !printf("%c\n", next+'A');
        }
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
// RRLLLLRLRRLL
// 1122226799
int main(){
  string S;
  cin >> S;
  int N = S.length();

  vector<int> idx(N);
  int i = 0;
  while(i < N) {
    if(S[i] == 'R') {
      int j = i;
      while(S[j] == 'R') ++j;
      for(int k = i; k < j; ++k) idx[k] = j;
      i = j;
    }else{
      int j = i;
      while(S[j] == 'L') ++j;
      for(int k = i; k < j; ++k) idx[k] = i - 1;
      i = j;
    }
  }

  vector<int> ret(N, 0);
  REP(i, N) {
    if(S[i] == 'R') {
      int j = idx[i];
      if((j - i) % 2 == 0) ++ret[j];
      else ++ret[j - 1];
    }else{
      int j = idx[i];
      if((i - j) % 2 == 0) ++ret[j];
      else ++ret[j + 1];
    }
  }

  REP(i, N) {
    if(i) cout << " ";
    cout << ret[i];
  }
  cout << endl;
  return 0;
}



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

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

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

using namespace std;

const int len = 100010;
int n,a[len];

int main() {
	ios :: sync_with_stdio(0);
	cin >> n;
	for (int i=1;i<=n;i++) {
		cin >> a[i];
	}
	int sum = 0;
	for (int i=1;i<=n;i++) {
		if (a[i] == i) {
			swap(a[i],a[i+1]);
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}
const int INF=1001001001001001001ll;
const int SIZE=100000;

int N,M,C;
vpint G[SIZE];
int dist[SIZE];
int sum;
bool used[SIZE];

signed main(){
    scanf("%lld%lld%lld",&N,&M,&C);
    rep(i,M){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--;b--;
        G[a].pb(pint(b,c));
        G[b].pb(pint(a,c));
        sum+=c;
    }

    priority_queue<pint,vpint,greater<pint> >que;que.push(pint(0,0));
    fill_n(dist,N,INF);dist[0]=0;
    while(que.size()){
        int v=que.top().se,c=que.top().fi;que.pop();
        if(dist[v]<c)continue;
        rep(i,G[v].size()){
            pint &e=G[v][i];
            if(dist[e.fi]<=c+e.se)continue;
            dist[e.fi]=c+e.se;
            que.push(pint(dist[e.fi],e.fi));
        }
    }
    vpint vec;
    rep(i,N)vec.pb(pint(dist[i],i));
    int ans=sum;
    sort(all(vec));
    rep(i,N){
        int v=vec[i].se,c=vec[i].fi;
        rep(j,G[v].size()){
            pint &e=G[v][j];
            if(used[e.fi]){
                sum-=e.se;
            }
        }
        used[v]=true;
        chmin(ans,c*C+sum);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 17220
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(n);
    multiset<int> st;
    REP(i,n){
        p[i].first = in();
        p[i].second = in();
        st.insert(p[i].second);
    }
    sort(ALL(p));

    int l = 0;
    REP(i,n){
        if (l < p[i].first && l <= m) l++;
    }

    priority_queue<int> que;
    int j = n;
    FORR(i,l,1){
        while (j > 0 && p[j - 1].first >= i){
            que.push(p[j - 1].second);
            j--;
        }
        int x = que.top();
        que.pop();
        st.erase(st.find(x));
    }
    
    int r = m + 1;
    for (auto itr = st.rbegin(); itr != st.rend(); itr++){
        if (*itr < r && r - 1 > l) r--;
    }

    cout << n - (l + (m - r + 1)) << endl;


    return 0;
}

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

# その数自身
ans = 1
# 1以外のn-1の約数
ans += len(make_divisors(n-1)) - 1

d = make_divisors(n)
for k in range(1,(len(d)+1)//2):
    i = d[k]
    j = n//i
    while j % i == 0:
        j //= i
    if j % i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 65512
/*
 * Lang  : C++ 17
 * Author: little_angel
 * Date  : 04-07-2020 10:40 04
 */

#include<bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i:a)cin >> i;
    sort(a.begin(), a.end());
    int pos = n - 1, ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += a[pos];
        pos -= i & 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4720
<?php
/*
    Problem URL : http://agc003.contest.atcoder.jp/tasks/agc003_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%s", $S);
$arrS = str_split($S);
$arr = array();

for ($i = 0; $i < count($arrS); $i++) {
    $arr[$arrS[$i]] = 1;
}

$arrX = $arr['N'] - $arr['S'];
$arrY = $arr['W'] - $arr['E'];

if ($arrX === 0 && $arrY === 0) {
    echo "Yes\n";
} else {
    echo "No\n";
}


Measured memory_bytes: 3960
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int INF = 1000000000 + 8;

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

    int na, nb, m;
    cin >> na >> nb >> m;

    vector<int> a(na);
    for (int i = 0; i < na; i++) cin >> a[i];
    vector<int> b(nb);
    for (int i = 0; i < nb; i++) cin >> b[i];

    int ans = INF;

    ans =
        min(*min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end()),
            ans);

    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;

        const int pay = a[x - 1] + b[y - 1] - c;
        ans = min(pay, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC164C
int compare_lli(const void *a, const void *b) {
  long *A = (long long *)a;
  long *B = (long long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int main(void) {
  int num, k,  cou=1, tmp[10], t;
  long long j,i;
  scanf(" %d", &num);
  char c[10];
  long long s[num];
  for(i=0; i < num; i++){
    s[i]=0;
    scanf(" %s", c);
    //printf("\n");
    for(j=0; c[j] != '\0'; ++j){
      s[i]=s[i]+(long long)(c[j] - 64) * pow(27, j);
      //printf("%d\n",s[i]);
    }
  }

  qsort(s, num, sizeof(long long), compare_lli); //sort

  for(i=0; i < num - 1; i++){
    if(s[i]!=s[i+1])cou++;
    //printf("%lld\n", s[i]);
  }
  //printf("%lld\n", s[num-1]);
  printf("%d", cou);
  return 0;
}

Measured memory_bytes: 5460
S = list(input())

blacks = []
for i in range(len(S)):
    if S[i] == "B":
        blacks.append(i)

# print(blacks)

for i in range(len(blacks)):
    blacks[len(blacks) - i - 1] = len(S) - i - 1 - blacks[len(blacks) - i - 1]

print(sum(blacks))


Measured memory_bytes: 12708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N;
ll T, X[Nmax];

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

	ll sum = 0;
	for(int i=1; i<N; i++){
		sum += min(T, X[i]-X[i-1]);
	}
	sum += T;

	cout << sum << endl;

	return 0;
}


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

int main() {

  // load: blue
  int n;
  cin >> n;
  vector <string> blue(n);
  for (int i = 0; i < n; i++)
    cin >> blue.at(i);

  // load: red
  int m;
  cin >> m;
  vector <string> red(m);
  for (int i = 0; i < m; i++)
    cin >> red.at(i);

  // count up score
  int max_score = 0; // if minus score, say another word which not in blue.
  for (int i = 0; i < n; i++) {
    int score = 0;
    string word = blue.at(i);
    if (word == "")
      continue;

    // inclease score
    for (int j = i; j < n; j++) {
      if (blue.at(j) == word) {
        score++;
        blue.at(j) = "";
      }
    }

    // declease score
    for (int k = 0; k < m; k++) {
      if (red.at(k) == word)
        score--;
    }

    // update high-score
    if (max_score < score)
      max_score = score;
  }

  // output
  cout << max_score << endl;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    int root = pow(n, 0.5);
    for(int i = 1; i <= n; i++) {
        int ans = 0;
        for(int x = 1; x < root; x++) {
            for(int y = x; y < root; y++) {
                for(int z = y; z < root; z++) {
                    ll rel = x*x + y*y + z*z + x*y + y*z + z*x;
                    if(rel > i) break;
                    else if(rel == i) {
                        if(x == y && y == z) {
                            ans++;
                        }
                        else if(x == y && y != z) {
                            ans += 3;
                        }
                        else if(y == z && x != y) {
                            ans += 3;
                        }
                        else ans += 6;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4036
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (stdIn.hasNext()) {
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if (n != 0 ||m != 0) {
				int a[] = new int[n];
				for (int i = 0; i < n; i++) {
					a[i] = stdIn.nextInt();
				}
				for (int i = 0; i < a.length - 1; i++) {
					for (int j = i + 1; j < a.length; j++) {
						if (a[j] > a[i]) {
							int temp = a[i];
							a[i] = a[j];
							a[j] = temp;
						}
					}
				}
				for (int i = 1; i < n + 1; i++) {
					if (i % m == 0) {
						a[i - 1] = 0;
					}
				}
				int b = 0;
				for (int i = 0; i < n; i++) {
					b += a[i];
				}
				System.out.println(b);
			}
		}
	}
}

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

using namespace std;
using ll = long long;
using pii = std::pair<int, int>;

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

const int mn = 2e5 + 5;

int n, k;
int a[mn];
int s[mn];

map<int, int> h;

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &k);
    ll ans = 0;
    h[0] = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        s[i] = (s[i - 1] + a[i]) % k;
        int v = ((s[i] - i) % k + k) % k;
        if (i >= k) {
            int u = a[i - k];
            h[u]--;
        }
        a[i] = v;
        ans += h[v];
        //printf("%d %d %d\n", i, v, h[v]);
        h[v]++;

    }
    printf("%lld\n", ans);


    return 0;
}

Measured memory_bytes: 11136
using System;

public class Hello
{
    public static void Main()
    {
        string L;
        for (; (L = Console.ReadLine()) != null;)
        {
            string[] line = L.Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var n = int.Parse(line[2]);
            a %= b;
            var ret = 0;
            for (int i = 0; i < n; i++)
            {
                a *= 10;
                ret += a / b;
                a %= b;
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 9144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
#define mod 1000000007
#define maxn 200010
LL sum,mn[maxn],mx[maxn];
int main(){
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n+1;i++)mn[i]=mn[i-1]+i-1,mx[i]=mx[i-1]+n-i+1;
	for(i=k;i<=n+1;i++)sum=(sum+mx[i]-mn[i]+1)%mod;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    string s;
    cin >> s;
    set<char> su;
    if(len(s) == 1 && s[0] == 'a') {
        cout << "None";
        return 0;
    }
    for(char c: s){
        su.insert(c);
    }
    if(len(su) == 26){
        cout << "None" ;
        return 0;
    }
    for(char c = 'a'; c <= 'z'; ++c){
        if(!su.count(c)){
            cout << c ;
            return 0;
        }
    }
}

Measured memory_bytes: 3716
import copy
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
ma =max(a)
cn =0
for i in range(n):
  if a[i]==ma and cn<2:
    b=copy.deepcopy(a)
    b[i]=0
    print(max(b))
    cn +=1
  else:
    print(ma)

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

using namespace std;

using ll = long long;

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

    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> drinks(n);
    for (auto &d : drinks)
        cin >> d.first >> d.second;
    sort(drinks.begin(), drinks.end());

    ll num = 0, money = 0;
    for (const auto &d : drinks) {
        ll res = m - num;
        if (res <= d.second) {
            money += res * d.first;
            break;
        }
        else {
            num += d.second;
            money += d.second * d.first;
        }
    }
    cout << money << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    int k, a, b;
    cin >> k >> a >> b;
    bool ans = false;
    for (int i = 0; i * k <= b; ++i) {
        if (k * i >= a && k * i <= b) {
            ans = true;
            break;
        }
    }
    if (ans) {
        cout << "OK\n";
    } else {
        cout << "NG\n";
    }

    return 0;
}


Measured memory_bytes: 3600