akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main()
{
    std::string S;
    std::cin >> S;

    int64_t count = 0;
    for (int64_t i = 1; i < S.size(); ++i) {
        char prev_c = S.at(i-1);
        char curr_c = S.at(i);
        if (prev_c != curr_c) count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  int A, B;
  cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
public class Main {
	
	
	
	public static void main(String[] args) {
		
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int d[][]=new int[n][2];
		int c=0;
		int flag=0;
		for(int i=0;i<n;i++)
		{
			d[i][0]=fs.nextInt();
			d[i][1]=fs.nextInt();
			if(d[i][0]==d[i][1])
				{
					c++;
					if(c==3)
						flag=1;
				}
			else
			{
				if(c==3)
					{
						flag=1;
					}
				else
					c=0;
			}
			
		}
		if(flag==1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
	
	
	static class FastScanner 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	

}


Measured memory_bytes: 32832
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/





int main() {

	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		string t = to_string(i);
		if ((t.size() % 2) == 1) {
			ans++;
		}
	}
	cout << ans << endl;





	return 0;
}


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

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

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='?')
			s[i]='D';	
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	long long X;
	cin >> N >> X;
	vector<long long> a(N);
	for (auto& x : a) cin >> x;
	auto b = a;
	long long r = 0;
	for (auto& x : a) r += x;
	for (int i = 1; i < N; ++ i) {
		for (int j = 0; j < N; ++ j) {
			b[j] = min(b[j], a[(j-i+N)%N]);
		}
		long long rr = 0;
		for (auto& x : b) rr += x;
		r = min(r, rr + X * i);
	}
	cout << r << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()

li = []
for i in range(n):
    if s[i]=="W":
        li.append(-1)
    else:
        li.append(1)

cumsum = [li[0]]
for i in range(n-1):
    cumsum.append(cumsum[i] + li[i+1])

l = cumsum.index(max(cumsum))
w_to_e = 0
e_to_w = 0

for i in range(n):
    if i < l:
        if li[i]==-1:
            w_to_e += 1
    elif i > l:
        if li[i]==1:
            e_to_w += 1
print(e_to_w + w_to_e)

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

int main()
{
  string s;
  cin>>s;
  int count=0;
  int n=s.size();
  for(int i=0;i<(n/2);i++)
  {
    if(s[i]!=s[n-1-i])
       count++;
       }
       cout<<count;
       return 0;
       }


Measured memory_bytes: 384
#!/usr/bin/env python3
from itertools import accumulate
import numpy as np

n, m, q = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

data = [[0]*500 for i in range(500)]
# data = [[0]*10 for i in range(10)]

for l, r in lr:
    data[l-1][r-1] += 1


# for i in range(0, 500):
#     data[i] = list(accumulate(data[i]))

# print(data)
# for p, q in pq:
#     ans = 0
#     if p == 1:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]
#     else:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]-data[i][p-1-1]
#     print(ans)

data = np.array(data)

data = np.cumsum(data, axis=1)
data = np.cumsum(data, axis=0)

# print(data[:10, :10])
for p, q in pq:
    ans = 0
    if p == 1:
        ans = data[q-1][q-1]
    else:
        ans = data[q-1][q-1]-data[p-1-1][q-1]
    print(ans)
# for p, q in pq:
#     ans = 0
#     if p == 1:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]
#     else:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]-data[i][p-1-1]
#     print(ans)


Measured memory_bytes: 76164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VP = vector<P>;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

VP f(ll N) {
  VP v;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll exp = 0;
    while (N % a == 0) {
      ++exp;
      N /= a;
    }
    v.emplace_back(a, exp);
  }
  if (N != 1) v.emplace_back(N, 1);
  return v;
}

void solve() {
  ll n, ans = 0;
  cin >> n;
  VP v = f(n);
  if (v.size() == 0) {
    cout << 0 << endl;
    return;
  }
  for (const auto &p : v) {
    ll x = p.second;
    ll i = 1;
    while (x >= i) {
      ans++;
      x -= i++;
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;

#define ll long long 
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<ll,ll> 
#define fi first
#define se second

int n, ans[1000][1000];

void genEdge(int l, int r, int col){
	// Divide by two
	int mid = (l+r)/2;
	for(int i = l; i <= mid; ++i){
		for(int j = mid+1; j <= r; ++j){
			ans[i][j] = col;
		}
	}
	if(l < mid)
		genEdge(l, mid, col+1);
	if(mid+1 < r)
		genEdge(mid+1, r, col+1);
}

int main(){
	scanf("%d", &n);
	genEdge(1, n, 1);
	for(int i = 1; i < n; ++i){
		for(int j = i+1; j <= n; ++j){
			printf("%d ", ans[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    ll j = 0;
    rep(i, 9) {
        if("AKIHABARA"[i] == s[j]) {
            j++;
        }
        else if("AKIHABARA"[i] == 'A') {
            ;
        }
        else {
            out("NO");
            re0;
        }
    }

    if(j == s.size()) {
        out("YES");
    }
    else {
        out("NO");
    }
    
    re0;
}

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

using namespace std;

#define int long long

const int inf = 1e18;

const int maxN = 3000 + 100;

int dp[maxN][maxN];
pair<int, int> p[maxN][maxN];

int max(int &a, int b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    string s, t;
    cin >> s >> t;
    
    dp[0][0] = 0;
    
    for (int i = 1; i <= (int)s.size(); i++) {
        for (int j = 1; j <= (int)t.size(); j++) {
            if (max(dp[i][j], dp[i - 1][j])) {
                p[i][j] = {i - 1, j};
            }
            if (max(dp[i][j], dp[i][j - 1])) {
                p[i][j] = {i, j - 1};
            }
            if (s[i - 1] == t[j - 1]) {
                if (max(dp[i][j], dp[i - 1][j - 1] + 1)) {
                    p[i][j] = {i - 1, j - 1};
                }
            }
        }
    }
    
//    cout << dp[(int)s.size()][(int)t.size()];
    pair<int, int> now = {(int)s.size(), (int)t.size()};
    
    string ans;
    
    while (now.first != 0 && now.second != 0) {
        if (dp[now.first][now.second] == dp[p[now.first][now.second].first][p[now.first][now.second].second] + 1) {
            ans += s[now.first - 1];
        }
        now = p[now.first][now.second];
    }
    
    reverse(ans.begin(), ans.end());
    
    cout << ans;
    
    return 0;
    
}


Measured memory_bytes: 219392
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, m, a[100][100];
    int k[max], cnt[31]={0};
    int ans=0;
    
    scanf("%d%d", &n, &m);
    rep(i, n){
        scanf("%d", &k[i]);
        rep(j, k[i]){
            scanf("%d", &a[i][j]);
            cnt[a[i][j]]++;
        }
    }
    
    rep(i, 32){
        if (cnt[i]==n) {
            ans++;
        }
    }
    
    printf("%d", ans);
    
    return 0;
}


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

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

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

#define INF INT_MAX/3
#define MAX_N 1000000001

ll n;
ll a[100010], b[100010];
map<ll, ll> mp;

int main(){
    cin.sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(b, b + n);
    rep(i, n) mp[b[i]] = i % 2;

    ll ans = 0;
    rep(i, n) {
        if (i % 2 != mp[a[i]]) ans++;
    }

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

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);

		String line2 = sc.nextLine();
		String[] kari = line2.split(" ");
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(kari[i]);
		}

		int change = 0;

		for (int i = 0; i < n - 1; i++) {
			int min = num[i];
			int x = i;
			for (int j = i + 1; j < n; j++) {
				if (min > num[j]) {
					min = num[j];
					x = j;
				}
			}
			
			if (i != x) {
				int v = num[i];
				num[i] = num[x];
				num[x] = v;
				change++;
			}

		}

		StringBuilder str = new StringBuilder();

		for (int i = 0; i < n - 1; i++) {
			str.append(num[i]);
			str.append(" ");
		}
		str.append(num[n - 1]);

		System.out.println(str);
		System.out.println(change);

	}

}

Measured memory_bytes: 26128
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

// 特定の文字列を数える関数
size_t count(const string& str, const string& sub, const size_t ini = 0, const size_t fin = string::npos) {
	size_t pos = str.find(sub, ini);
	size_t cnt = 0;
	while (pos < fin) {
		cnt += 1;
		pos = str.find(sub, pos + sub.length());
	}
	return cnt;
}

int main() {

	int N;
	int A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;

	string S;
	cin >> S;

	int c1, c2;
	bool jdg = false;

	if (C < D) {
		c1 = count(S, "##", A, C);
		c2 = count(S, "##", B, D);
		if (c1 == 0 && c2 == 0) {
			jdg = true;
		}
	}
	else {
		int c3;
		c1 = count(S, "##", A, C);
		c2 = count(S, "##", B, D);
		c3 = count(S, "...", B - 1, D);
		if (c1 == 0 && c2 == 0 && c3 > 0) {
			jdg = true;
		}
	}

	if (jdg == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	
	vector<int> num(5);
	for(int i = 0; i < 5; i++){
		cin>>num[i];
	}
	int k;
	cin>>k;
	for(int i = 0; i < 4; i++){
		for(int j = i+1; j < 5; j++){
			if(num[j]-num[i]>k){
				cout<<":("<<endl;
				return 0;
			}
		}
	}
	cout<<"Yay!"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "./libb/lib.hpp"
#include <string>

using namespace std;
const uint64_t MOD = 1000000007;
const double PI = acos(-1);

int main()
{
    string ss;
    string tt;
    cin >> ss >> tt;

    if((tt.compare(0, ss.length(), ss) == 0) && ((ss.length() + 1) == tt.length())){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,ans=inf,cnt; cin>>n;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    for(int i=-100;i<=100;i++){
        cnt=0;
        rep(j,n){
            cnt+=(i-a[j])*(i-a[j]);
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

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

char map[102][102];

void fruit(int h, int w,char f){
	if(map[h][w]!=f)
		return;
	map[h][w]=' ';
	fruit(h-1,w,f);
	fruit(h,w-1,f);
	fruit(h+1,w,f);
	fruit(h,w+1,f);
}


int main(){
	int h,w;
	
	while(1){
		cin>>h>>w;
		if(h==0 && w==0)
			break;
		
		for(int i=1; i<=h; i++)
			for(int j=1; j<=w; j++)
				cin>>map[i][j];
				
		int people=0;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				if(map[i][j]=='@'){
					people++;
					fruit(i,j,'@');
				}
				else if(map[i][j]=='*'){
					people++;
					fruit(i,j,'*');
				}
				else if(map[i][j]=='#'){
					people++;
					fruit(i,j,'#');
				}
			}
		}
		cout<<people<<endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	
	int a, b;
	cin >> a >> b;
	int c = 0;
	
	if (a >= b) {
		c += a;
		a--;
	}
	else {
		c += b;
		b--;
	}
	if (a >= b) {
		c += a;
		a--;
	}
	else {
		c += b;
		b--;
	}
	PRI(c);
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

// 約数の列挙 O(√n)
vector<int> divisor(int n)
{
  vector<int> res;
  for (int i=1; i*i<=n; i++) {
    if (n%i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

void solve()
{
  int a,b,k; cin>>a>>b>>k;
  vector<int> div;
  div = divisor(__gcd(a,b));
  sort(div.rbegin(),div.rend());
  cout << div[k-1] << endl;
}

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


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

int main(void) {
	int K, A, B;
	scanf("%d %d %d", &K, &A, &B);
	bool ans = false;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) ans = true;
	}
	printf(ans ? "OK" : "NG");

	return 0;
}


Measured memory_bytes: 3668
#約数を列挙する巻数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#ここからメイン
N = int(input())

count=0
mitasuN=[]
for i in range(1,N+1,2):
    tmp_s = make_divisors(i)
    # print(tmp_s)
    if len(tmp_s)==8:
        count+=1
        mitasuN.append(i)
# print(mitasuN)
print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
  {
   long long int n,m,i;
   cin>>n>>m;
   while(m--)
     {
       cin>>i;
       n-=i;
     }
    if(n<0)
      cout<<-1<<endl;
    else
      cout<<n<<endl;
   return 0;
  }

Measured memory_bytes: 3572
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();
        long[] Hs = new long[N + 1];
        int[] t = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            Hs[i] = sc.nextLong();
            t[i] = i;
        }
        for (int i = 1; i <= M; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            long ha = Hs[A];
            long hb = Hs[B];
            if (ha < hb) {
                t[A] = 0;
            } else if (hb < ha) {
                t[B] = 0;
            } else {
                t[A] = 0;
                t[B] = 0;
            }
        }
        int count = 0;
        for (int i : t) {
            if (0 < i) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 61100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

map<ll, int> prime_factor(int64_t n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll n;
    cin >> n;
    auto ma = prime_factor(n);
    int ret = 0;
    for (auto x:ma) {
        int a = 0;
        while ((a + 1) * (a + 2) / 2 <= x.second)a++;
        ret += a;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

n,k = gsmi
xs = gsmi

ans = xs[n-1]-xs[0]+xs[0].abs
(n-k+1).times do |i|
  l = xs[i]
  r = xs[i+k-1]
  ans = min(ans,r-l+min(r.abs,l.abs))
end

puts ans


Measured memory_bytes: 21608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    string s;
    cin >> s;
    rep(i, s.size())
    {
        if(s[i] == '7'){
            cout << "Yes";
            return 0;
        }
    }
     cout << "No";
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#define INFTY 1000001
using namespace std;

int main(){
    int n, c[50] = {}, T[100000] = {};
    cin >> n;
    c[0] = 1;
    int a = 6,i=1;
    while (a <= n) {
        c[i] = a;
        a *= 6;
        i++;
    }
    int b = 9;
    while (b <= n) {
        c[i] = b;
        b *= 9;
        i++;
    }
    for (int k = 0; k <= n; k++) {
        T[k] = INFTY;
    }
    T[0] = 0;
    for (int j = 0;j < i;j++) {
        for (int k = 0; k <= n-c[j];k++) {
            T[k + c[j]] = min(T[k + c[j]], T[k] + 1);
        }
    }
    cout << T[n] << endl;
}

Measured memory_bytes: 640
s=input()
t=input()
sn=len(s)
tn=len(t)
ans=float('INF')
for i in range(sn-tn+1):
  cnt=0
  for j in range(tn):
    if s[i+j]!=t[j]:
      cnt+=1
  ans=min(ans,cnt)
print(ans)

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> p(m);
    int a,b;
    for (int i=0;i<m;i++) {
        cin >> a >> b;
        p[i]=make_pair(b-1,a);
    }
    sort(p.begin(),p.end());
    int r=p[0].first;
    int ans=1;
    for (int i=1;i<m;i++) {
        if (r<p[i].second) {
            ans++;
            r=p[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
N = int(input())
a = list(map(int,input().split()))
A = [0] + a + [0]
abl = []
sum = 0

for i in range(N+1):
  dis = abs(A[i+1] - A[i])
  sum += dis
  abl.append(dis)
#print(abl)

for i in range(N):
  ans = sum - abl[i] -abl[i+1] + abs(A[i+2] - A[i])
  print(ans)

Measured memory_bytes: 58348
import Control.Applicative
import Control.Monad
import Data.List

main = do
  n <- readLn
  replicateM_ n $ getLine >>= mapM_ putStrLn.searchAffineSentence ["this","that"]

affinA :: [Int]
affinA = filter (\x -> gcd x 26 == 1) [1..25]
affinB :: [Int]
affinB = [0..25]

toChar :: Int -> Char
toChar n = ['a'..'z'] !! n
toInt  :: Char -> Int
toInt  c = length $ takeWhile (/= c) ['a'..'z']

decAff :: Int -> Int -> Int -> Int
decAff a b g = (a*g - a*b) `mod` 26

decodeAffineChar :: Int -> Int -> Char -> Char
decodeAffineChar a b c
  | c == ' ' = ' '
  | otherwise = toChar.decAff a b.toInt $ c

decodeAffineStr :: Int -> Int -> String -> String
decodeAffineStr a b = map (decodeAffineChar a b)


searchAffineSentence :: [String] -> String -> [String]
searchAffineSentence strs code = filter cond $ map (\(a,b) -> decodeAffineStr a b code) [(a,b) | a <- affinA, b <- affinB]
  where cond c = or ((map isInfixOf strs)<*>[c])

Measured memory_bytes: 4012
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define mod 1000000007
#define PI acos(-1)
vector<int> adj[200005];
int main()
{
	IOS
	int n,m;
	cin>>n>>m;
	int i;
	int x,y;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	int level[n+1]={0};
	int vis[n+1]={0};
	queue<int> q;
	q.push(1);
	vis[1]=1;
	while(!q.empty())
	{
		int p=q.front();
		q.pop();
		for(i=0;i<adj[p].size();i++)
		{
			if(vis[adj[p][i]]==0)
			{
				vis[adj[p][i]]=1;
				level[adj[p][i]]=p;
				q.push(adj[p][i]);
			}
		}
		}
		for(i=2;i<=n;i++)
		{
			if(level[i]==0)
			{
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes\n";
		for(i=2;i<=n;i++)
		cout<<level[i]<<"\n";
	
}

Measured memory_bytes: 13204
import sys
n,m = map(int,input().split())
la = [input() for _ in range(n)]
lb = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        cnt = 0
        for k in range(m):
            for l in range(m):
                if la[i+k][j+l] == lb[k][l]:
                    cnt += 1
        if cnt == m**2:
            print("Yes")
            sys.exit()
print("No")

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

using namespace std;
mt19937_64 rng(58);
const int64_t MOD = 1e9 + 7;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = ""; for (const auto &x : v) { if (!first) res += ", "; first = false; res += to_string(x); } return "{" + res + "}"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    vector<int64_t> a(n); for (auto &ai : a) cin >> ai;
    vector<int64_t> s(n);
    s[n-1] = 0;
    for (int i = n-2; i >= 0; i--) s[i] = (s[i + 1] + a[i + 1]) % MOD;
    // debug(a);
    // debug(s);
    int64_t ans = 0;
    for (int i = 0; i<n; i++)
        ans = (ans + (a[i] * s[i]) % MOD) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 6328
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 505;
ll a[maxN][maxN];
ll dp[maxN][maxN];
ll in_minus[maxN][maxN];
ll in_ones[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j == i) continue;
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j] = 1e18;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            if (j > i) {
                in_ones[i][j] = in_ones[i][j - 1];
                in_minus[i][j] = in_minus[i][j - 1];
            }
            // delete all minus ones
            for (int k = i; k < j; k++) {
                in_minus[i][j] += a[k][j];
                in_ones[i][j] += a[j][k];
            }
        }
    }
    for (int last = 0; last < n; last++) {
        dp[0][last] = in_minus[0][last];
    }
    for (int i = 0; i < n; i++) {
        for (int last = 0; last <= i; last++) {
            for (int j = i + 1; j < n; j++) {
                // [last, i], [i + 1, j]
                ll total = in_minus[i + 1][j];
                ll minus_last = in_minus[last][j] - in_minus[last][i] - in_minus[i + 1][j];
                ll one_last = in_ones[last][j] - in_ones[last][i] - in_ones[i + 1][j];
                ll one_all = in_ones[0][j];
                one_all -= in_ones[0][i];
                one_all -= in_ones[i + 1][j];
                one_all -= one_last;
                total += one_all;
                dp[i + 1][j] = min(dp[i + 1][j], dp[last][i] + total);
            }
        }
    }
    ll best = 1e18;
    for (int i = 0; i < n; i++) best = min(best, dp[i][n - 1]);
    cout << best;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(ll i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    //解は(l,r]に存在
    ll l = -1e18, r = 1e18+1;
    while(l+1 < r){
        ll n = (l+r)/2;
        //n以下になるものが何個あるか判定
        ll sum = 0;
        rep(i, N){
            if(A[i] < 0){
                ll x = n/A[i];
                rep2(j, x-1, x+1){
                    if(A[i]*j <= n){
                        sum += A+N - lower_bound(A, A+N, j);
                        break;
                    }
                }
            }
            elif(A[i] == 0){
                if(n >= 0) sum += N;
            }
            else{
                ll x = n/A[i];
                rep3(j, x+1, x-1){
                    if(A[i]*j <= n){
                        sum += upper_bound(A, A+N, j)- A;
                        break;
                    }
                }
            }
            if(A[i]*A[i] <= n) sum--;
        }
        sum /= 2;
        if(sum < K) l = n;
        else r = n;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * Created by lyc on 2017/10/12.
 */
class Main{
    public static void main(String[] strings) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        if (s.indexOf("9") != -1) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }

    }
}

Measured memory_bytes: 23764
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	Int N, M; std::cin >> N >> M;
	std::vector<std::pair<Int, Int>> check(M);
	std::vector<std::pair<Int, Int>> student(N);
	rep(i, N)std::cin >> student[i].first >> student[i].second;
	rep(i, M)std::cin >> check[i].first >> check[i].second;

	std::vector<Int> ans(N);

	rep(i, N) {
		Int cur = -1, dist = INF;
		auto pos = student[i];
		rep(j, M) {
			auto tmp = std::abs(check[j].first - pos.first) + std::abs(check[j].second - pos.second);
			if (tmp < dist) {
				dist = tmp;
				cur = j + 1;
			}
		}
		ans[i] = cur;
	}
	rep(i, N)std::cout << ans[i] << "\n";

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = [[int(x) for x in input().split()] for _ in range(2)]
a_c_list = [[0] * (n + 1), [0] * (n + 1)]
for i in range(2):
    for j in range(1, n + 1):
        a_c_list[i][j] = a_list[i][j - 1] + a_c_list[i][j - 1]
ans = 0
for i in range(1, n + 1):
    temp = a_c_list[0][i] + (a_c_list[1][n] - a_c_list[1][i - 1])
    if temp > ans:
        ans = temp
print(ans)

Measured memory_bytes: 3064
#include<iostream>


using namespace std;

int f(int x){
	if(x>3){
		x++;
	}
	if(x>5){
		x++;
	}
	return x;
}

int main(){
	
	int n;
	int ans[20];
	int count;
	while(cin>>n,n){
		
		count=0;
		for(int i=0;n>0;i++){
			ans[i]=(n%8);
			n=n/8;
			count++;
		}
		
		
		while(count--){
			cout<<f(ans[count]);
		}cout<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
    	int a,b ; cin >> a >> b;

    	if(a%b==0){
    		cout << a/b << endl;
    	}else{
    		cout << a/b + 1 << endl;
    	}

    	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

string ab[10] = {"* = ****",
		"* =* ***",
		"* =** **",
		"* =*** *",
		"* =**** ",
		" *= ****",
		" *=* ***",
		" *=** **",
		" *=*** *",
		" *=**** "};
char ans[8][5];
int in;
bool endline = false;


void make(int num, int pos){
  for(int i = 0; i < 8; i++)
    ans[i][pos] = ab[num][i];

}
void solve(){
  for(int i = 4; i >= 0; i--){
    make(in%10,i);
      in/=10;
  }
}

void print(){
  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 5; j++)
      cout << ans[i][j];
    cout << endl;
  }

}

int main(){
  while(cin >> in){
    if(endline) cout << endl;
    solve();
    print();
    endline = true;
  }
  return 0;
}

Measured memory_bytes: 1200
def main():
    H, W, A, B = (int(i) for i in input().split())
    m = H + W + 3
    MOD = 10**9 + 7
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m

    def COMBinitialize(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COMB(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMBinitialize(m)
    ans = 0
    for x in range(W-B):
        if x == 0:
            p = COMB(H-A-1 + B+x, B+x)
        else:
            p = COMB(H-A-1 + B+x, B+x) - COMB(H-A-1 + B+x-1, B+x-1)
        q = COMB(A+W-1-B-x, A)
        ans += p*q
        ans %= MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44272
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner kbd = new Scanner(System.in);

    void run(){
	while(kbd.hasNext()){
	    String s = kbd.next();
	    solve(s);
	}
    }

    void solve(String s){
	String ans = "";
	for(int i=0; i<s.length(); i++){
	    String x = s.substring(i, i+1);
	    if(x.equals("@")){
		i++;
		int y = Integer.parseInt(s.substring(i, i+1));
		i++;
		String z = s.substring(i, i+1);
		while(y>0){
		    ans += z;
		    y--;
		}
	    }
	    else ans += x;
	}

	System.out.println(ans);
    }
}

Measured memory_bytes: 17148
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    string s;
    int n, times_of_trial,tmp;
    cin >> s;
    while(s!="-"){
        cin >> n;
        times_of_trial = 0;
        REP(i,n){
            cin >> tmp;
            times_of_trial += tmp;
        }

        REP(i,s.size()){
            cout << s[(i + times_of_trial)%s.size()];
        }
        cout << endl;
        cin >> s;

    }


    return 0;
}


Measured memory_bytes: 3160
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=0; i<=N/4; i++){
            for(int j=0; j<=N/7; j++){
                if(N==4*i+7*j){
                    System.out.println("Yes");
                    return; 
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22612
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int y = 700;
        for(char c : line.toCharArray()){
            if(c == 'o')    y += 100;
        }

        System.out.println(y);
    }
}

Measured memory_bytes: 21076
use std::io::stdin;

fn main() {
    let mut lines: Vec<[i32; 2]> = Vec::new();

    loop {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        if buf == "0 0\n".to_string() {
            break;
        }
        let mut elements = buf.trim().split_whitespace();
        let mut line = [0; 2];
        line[0] = elements.next().unwrap().parse::<i32>().unwrap();
        line[1] = elements.next().unwrap().parse::<i32>().unwrap();
        lines.push(line);
    }
    print!("{}", solve(lines));
}

fn solve(lines: Vec<[i32; 2]>) -> String {
    let mut result = String::new();
    for &line in lines.iter() {
        let mut counter = 0;

        for element_one in 1..line[0] - 1 {
            if element_one >= line[1] {
                continue;
            }

            for element_twe in element_one + 1..line[0] {
                if element_one + element_twe >= line[1] {
                    continue;
                }

                for element_three in element_twe + 1..line[0] + 1 {
                    if element_one + element_twe + element_three == line[1] {
                        counter += 1;
                    }
                }
            }
        }
        result.push_str(&format!("{}\n", counter));
    }
    result
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
int main(){
	cin>>a>>b>>c;
	ll t=4*a*b;
	ll tt=c*c+(a+b)*(a+b)-2*c*(a+b);
	if(t<tt&&(c-a-b)>0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    var (N,M)= ReadInts()
    if((N-M)*(N-M)>1){
        println(0)
        return
    }
    var mod = 1000000007
    var ans:Long=1
    for(i in 1..N){
        ans = (ans * i) % mod 
    }
    for(i in 1..M){
        ans = (ans * i) % mod 
    }
    if(N==M){
        ans *=2
    }
    println(ans % mod)



}



fun ReadInts():MutableList<Int>{
    return readLine()!!.split(" ").map{it.toInt()}.toMutableList()
}

fun ReadLongs():MutableList<Long>{
    return readLine()!!.split(" ").map{it.toLong()}.toMutableList()
}
fun ReadDoubles():MutableList<Double>{
    return readLine()!!.split(" ").map{it.toDouble()}.toMutableList()
}
fun input() : String{
    return readLine()!!

}

Measured memory_bytes: 37648
#include <cstdio>
#include <array>
#include <algorithm>

using namespace std;

int main(){
	int n;
	while(scanf("%d",&n),n){
		array<int,24*60*60> time;
		for(int i=0;i<24*60*60;i++) time[i] = 0;
		for(int i=0;i<n;i++){
			int h1,m1,s1,h2,m2,s2;
			scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
			
			int start = h1*60*60 + m1*60 + s1;
			int end = h2*60*60 + m2*60 + s2;
			for(int j=start;j<end;j++) time[j]++;
		}
		int ret = 0;
		for(int i=0;i<24*60*60;i++){
			ret = max(ret,time[i]);
		}
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ret = 0;
  for (int r=0; r*R<=N; r++) {
    for (int g=0; r*R+g*G<=N; g++) {
      int target = N - r*R - g*G;
      if (target < 0) continue;
      if (target % B != 0) continue;
      ret++;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(n + 1);
    for (int i = 2; i <= n; ++i) {
        int p = i;
        for (int j = 2; j * j <= p; ++j) {
            while (p % j == 0) {
                ++cnt[j];
                p /= j;
            }
        }
        if (p > 1) {
            ++cnt[p];
        }
    }
    vector<int> dp(76);
    dp[1] = 1;
    for (int i = 0; i <= n; ++i) {
        vector<int> nex(76);
        for (int j = 0; j <= cnt[i]; ++j) {
            for (int k = 1; (j + 1) * k < 76; ++k) {
                nex[(j + 1) * k] += dp[k];
            }
        }
        dp = nex;
    }
    cout  << dp[75] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    ll N, K = 0;
    cin >> N >> K;
    int a[N] = {0};
    REP(i, N)
    {
        cin >> a[i];
    }

    ll count = 0;
    REP(i, N - 1)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (a[i] > a[j])
            {
                count++;
            }
        }
    }
    ll countBw = 0;

    int n = N * 2;
    int b[n];
    for (int i = 0; i < n; i++)
    {
        b[i] = a[i % N];
    }
    REP(i, n - 1)
    {
        for (int j = i + 1; j < n; j++)
        {

            if (b[i] > b[j])
            {
                countBw++;
            }
        }
    }

    countBw -= 2 * count;
    cout << ((countBw * ((K * (K - 1) / 2) % bigNum)) % bigNum + K * (count)) % bigNum;
}


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

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	string s;
	cin>>s;
	int l=s.length();
	
	int c[l+1];
	for(int i=1;i<=l;i++)
		c[i]=(s[l-i]=='?' ? -1:s[l-i]-'0');
	int f[l+4][13];
	//f[i][j] = i th number that %13 == j
	memset(f,0,sizeof(f));
	
	if(c[1]!=-1)
		f[1][c[1]]++;
	else for(int i=0;i<10;i++)
		f[1][i]=1;
	
	for(int i=2;i<=l;i++) {
		if(c[i]!=-1) {
			int n=c[i],j;
			switch (i%6) {
				case 1:n*=1;break;
				case 2:n*=10;break;
				case 3:n*=100;break;
				case 4:n*=-1;break;
				case 5:n*=-10;break;
				case 0:n*=-100;break;
			};n%=13;
			if(n<0) n+=13;
			
			for(j=0;j+n<13;j++)
				f[i][j+n]=f[i-1][j];
			for(;j<13;j++)
				f[i][j+n-13]=f[i-1][j];
		}
		else {
			int k;
			switch (i%6) {
				case 1:k=1;break;
				case 2:k=10;break;
				case 3:k=100;break;
				case 4:k=-1;break;
				case 5:k=-10;break;
				case 0:k=-100;break;
			};k%=13;
			if(k<0) k+=13;
			
			for(int m=0;m<10;m++) {
				int n=k*m;
				n%=13;
				int j;
				long long big;
				for(j=0;j+n<13;j++) {
				//	f[i][j+n]+=f[i-1][j];
					big=(long long)f[i][j+n]+(long long)f[i-1][j];
					big%=1000000007;
					f[i][j+n]=(int)big;
				}
				for(;j<13;j++) {
				//	f[i][j+n-13]+=f[i-1][j];
					big=(long long)f[i][j+n-13]+(long long)f[i-1][j];
					big%=1000000007;
					f[i][j+n-13]=(int) big;
				}
			}
		}
	}
	
	cout<<f[l][5]<<endl;
	return 0;
}



Measured memory_bytes: 5888
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
x = len(set(A))
C = Counter(A)
L = C.most_common()[::-1]
ans = 0
for l in L:
  if K >= x:
    break
  ans += l[1]
  x -= 1
print(ans)

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



int main() 
{
	cin.tie(0);
	cin.sync_with_stdio(0);
	int n; 
	cin >> n;
	int ans = 0;
	
	for (int i = 1; i <= n; ++i) 
	{
		int nd = log10(i) + 1;
		if ((nd) % 2 == 1)ans++;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 256