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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
/*
struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> size;

    //こいつがいわゆるコンストラクタ
    //初期化している
    UnionFind(int N) : par(N),rank(N),size(N){
        for(int i=0;i<N;i++){
            par[i]=i;
            size[i]=1;
            rank[i]=0;
        }
    }

    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }


    void unite(int x, int y){
        int rx,ry;
        rx = find(x);
        ry = find(y);
        if(rx == ry){
            return;
        }
        else{
            if(rank[rx]<rank[ry]){
                par[rx]=ry;
                size[ry]+=size[rx];
            }
            else{
                par[ry]=rx;
                size[rx]+=size[ry];
                if(rank[rx]==rank[ry]){
                    rank[rx]++;
                }
            }
        }
    }


    bool same(int x,int y){
        return find(x) == find(y);
    }
};
*/
ll inf =1000000000+7;
int main(){
    ll S;
    cin>>S;
    vector<ll> A(S,0);
    vector<ll> B(S,0);
    if(S>2){
        A.at(2)=1;
        B.at(2)=1;
    }
    if(S>3){
        for(ll i=3;i<S;i++){
            A.at(i)=B.at(i-3)+1;
            B.at(i)=A.at(i)+B.at(i-1);
            A.at(i) =A.at(i)%inf;
            B.at(i) = B.at(i)%inf;
        }
    }
    cout<<A.at(S-1)<<endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <stdio.h>

//?????\?????????

const int MAX = 100;

using namespace std;

//?????????????´?????????????????????????
void trace(int a[],int n){
    for (int i=0;i<n;i++){
        if(i>0){cout << " ";}
        cout << a[i];
    }
    cout << endl;
}

int BubbleSort(int a[],int n){
    bool flag=true;
    int num=0;
    while(flag){
        flag=false;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                flag=true;
                num++;
            }
        }
    }
    trace(a, n);
    return num;
}

int main(){
    int A[MAX],n;
    cin >> n;
    for(int i=0;i<n;i++){
        scanf("%d", &A[i]);
    }
    cout << BubbleSort(A, n)<<endl;

    return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a,b;
  int c,d;
  cin >> a >> b >> c >> d;
  string judge;
  cin >> judge;
  if(judge==a){
    cout << c-1 << " " << d << endl;
  }
  else{
   cout << c << " " <<  d-1 << endl;
  }
}


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


ld length(pair<ld,ld> XYi,pair<ld,ld> XYj) {
	ld ans = pow(pow(XYi.first - XYj.first, 2) + pow(XYi.second - XYj.second, 2), 0.5);
	return ans;
}

int main() {
	ld N;
	cin >> N;
	vector<pair<ld, ld>>XY(N);
	rep(i,N) {
		ld x, y;
		cin >> XY[i].first >> XY[i].second;
	}
	sort(XY.begin(),XY.end());
	int count = 0;
	ld all = 0;
	do {
		for (int i = 0; i<N-1; ++i) {
			all += length(XY[i], XY[i+1]);
		}
		count++;
	} while (next_permutation(XY.begin(),XY.end()));

	ld ans =all/count;
	cout <<fixed<< setprecision(10) << ans << endl;
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int k,t; cin >> k >> t;
  int a = 0;
  for(int i = 0; i < t; ++i){
    int x; cin >> x;
    ChangeMax(a, x);
  }
  cout << max(2*a-k-1,0) << endl;
}


Measured memory_bytes: 3620
N=int(input())
a=list(map(int,input().split()))

f=1 in a
if f:
    ans=0
    i=1;j=0
    while j<N:
        if a[j]==i:
            i+=1
            j+=1
        else:
            ans+=1
            j+=1

print(ans if f else -1)

Measured memory_bytes: 77516
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int>vec(N);
	for (int ia = 0; ia < N; ia++) {
		cin >> vec.at(ia);
	}

	int IB = 0;
	for (int ib = 0; ib < N; ib++) {
		if (vec.at(ib) == 1) {
			IB = ib;
		}
	}
	if (IB <= K || (N - IB) <= K) {
		if ((N - 1) % (K - 1)) {
			cout << (N - 1) / (K - 1) + 1 << endl;
		}
		else {
			cout << (N - 1) / (K - 1) << endl;
		}
	}
	else {
		if ((IB - 1) % (K - 1) != 0 && (N - IB) % (K - 1) != 0) {
			cout << (IB - 1) / (K - 1) + 1 + (N - IB) / (K - 1) + 1 << endl;
		}
		if ((IB - 1) % (K - 1) != 0 && (N - IB) % (K - 1) == 0) {
			cout << (IB - 1) / (K - 1) + 1 + (N - IB) / (K - 1) << endl;
		}
		if ((IB - 1) % (K - 1) == 0 && (N - IB) % (K - 1) != 0) {
			cout << (IB - 1) / (K - 1) + (N - IB) / (K - 1) + 1 << endl;
		}
		if ((IB - 1) % (K - 1) == 0 && (N - IB) % (K - 1) == 0) {
			cout << (IB - 1) / (K - 1) + (N - IB) / (K - 1) << endl;
		}
	}
}



	


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

class dice{
	public:
	int d[6];
	void rolls(string str){
		for(int i = 0; str[i] != '\0'; i++)
			roll(str[i]);
	}
	void roll(char in){//4 2 1 6 5 3
		int direc[4][6]={
			{1,5,2,3,0,4},//n
			{3,1,0,5,4,2},//e
			{4,0,2,3,5,1},//s
			{2,1,5,0,4,3}//w
		};
		int news;
		int temp_d[6];
		if(in =='N')news = 0;
		if(in =='E')news = 1;
		if(in =='S')news = 2;
		if(in =='W')news = 3;
		for(int i = 0;i < 6;i++)
			temp_d[i] = d[direc[news][i]];
		for(int i = 0;i < 6;i++)
			d[i] = temp_d[i];
	}
	void print(void){
		for(int i = 0;i < 6; i++){
			cout << d[i];
			if(i==6-1)cout << endl;
			else cout << " ";
		}
	}
};

int main(){
	dice d1;
	int q;
	string str;
	int ue, mae;
	int index;
	for(int i = 0;i < 6; i++)
		cin >> d1.d[i];
	cin >> q;
	for(int t = 0; t < q; t++){
		cin >> ue >> mae;
		for(int i = 0;i < 6; i++){
			if(d1.d[i] == ue)index = i;
		}
		char cmd[6][4]={"", "N", "W", "E", "S", "SS"};
		d1.rolls(cmd[index]);
		for(int i = 0;i < 6; i++){
			if(d1.d[i] == mae)index = i;
		}
		char cmd2[6][5]={"", "", "ENW", "NES", "ESSW", ""};
		d1.rolls(cmd2[index]);
		cout << d1.d[2] << endl;
	}
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define endl '\n'

#define pb push_back
#define mp make_pair

#define fi first
#define se second

#define r(a) cin>>a
#define r2(a,b) cin>>a>>b
#define r3(a,b,c) cin>>a>>b>>c
#define r4(a,b,c,d) cin>>a>>b>>c>>d

#define p(a) cout<<a<<' '
#define pn(a) cout<<a<<endl
#define p2n(a,b) cout<<a<<' '<<b<<endl
#define p3n(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl
#define p4n(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl
#define psn cout<<endl

#define repeat(i,n) for(int i=0;i<n;++i)
#define repeat2(i,a,b) for(int i=a;i<b;++i)
#define rfor(i,n) for(int i=n-1;i>=0;--i)
#define range(i,a) for(auto &i:a)

#define readall(t) range(i,t)r(i)
#define printall(t) range(i,t)p(i);psn

#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(),a.end()

const int MAXN = 3000;

double dp[MAXN][MAXN];
double pr[MAXN];

int32_t main()
{
    ios::sync_with_stdio(false);
    int n ;
    r(n);
    repeat(i, n)
        r(pr[i]);
    
    dp[0][0] = 1 - pr[0];
    dp[0][1] = pr[0];

    repeat2(i, 1, n)
    {
        repeat(j, n + 1)
        {
            dp[i][j] = dp[i - 1][j] * (1 - pr[i]);
            if (j > 0)
                dp[i][j] += dp[i - 1][j - 1] * pr[i];
        }
    }

    double ans = 0;

    repeat2(i, n / 2 + 1, n + 1)
        ans += dp[n - 1][i];

    cout << setprecision(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 70528
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define v vector
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define endl '\n'
#define DEBUG

template<typename T> void DBG(const char* name, T&& H) {
	cerr << name << " = " << H << ')' << endl;
}

template<typename T, typename... Args> void DBG(const char* names, T&& H, Args&&... args) {
	const char* NEXT = strchr(names+1, ',');
	cerr.write(names, NEXT-names) << " = " << H << " |";
	DBG(NEXT+1, args...);
}

#ifdef DEBUG
	#define dbg(...) cerr << __FUNCTION__ << ' ' <<__LINE__ << " : (", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
#endif

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int INF = 1e8;
const int maxN = 2001;

ll n;
vector<pair<ll, ll>> a;
vector<vector<ll>> dp(maxN, vector<ll>(maxN, -1));

ll rec(ll idx, ll L, ll R) {
	if(dp[L][R] != -1) return dp[L][R];
	if(L == R) return a[idx].first * abs(L-a[idx].second); 
	ll ans = max((a[idx].first * abs(L-a[idx].second)) + rec(idx+1, L+1, R), (a[idx].first * abs(R-a[idx].second)) + rec(idx+1, L, R-1));
	dp[L][R] = ans;
	return ans;
}

void Solve() {
	cin >> n;
	for(ll i = 0; i < n; i ++) {
		pair<ll, ll> t;
		cin >> t.first;
		t.second = i;
		a.push_back(t);
	}
	sort(rALL(a));
	cout << rec(0, 0, n-1) << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int tt = 1;
	while(tt --) {
		Solve();
	}
	
	return 0;
}

Measured memory_bytes: 35136
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	string s;
	cin>>s;
	bool ok=true;
	if(s[0]!='A' || s[1]=='C' || s.back()=='C')ok=false;
	rep(i,0,s.size())while(islower(s[i]))s.erase(s.begin()+i);
	if(s!="AC")ok=false;
	puts(ok?"AC":"WA");
	return 0;
}



Measured memory_bytes: 256
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
public static void main(String[] args) throws Exception{

    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	int n = Integer.parseInt(br.readLine());
      	long sum = (((long)(n+1)) * n)/(long)2;
      	long sum_3 = 0;
      	if(n % 3 == 0)
      	{
      		sum_3 = ((long)(n/3) * ((long)3 + (long)n))/(long)2;
      	}
      	else
      	{
      		int count_3 = n;
      		int r = count_3 % 3;
      		count_3 = count_3 - r;
      		sum_3 = ((long)(count_3/3) * ((long)3 + (long)count_3))/(long)2;
      	}
      	long sum_5 = 0;
      	if(n % 5 == 0)
      	{
      		sum_5 = ((long)(n/5) * ((long)5 + (long)n))/(long)2;
      	}
      	else
      	{
      		int count_5 = n;
      		int r = count_5 % 5;
      		count_5 = count_5 - r;
      		sum_5 = ((long)(count_5/5) * ((long)5 + (long)count_5))/(long)2;
      	}
      	long sum_15 = 0;
      	if(n % 15 == 0)
      	{
      		sum_15 = ((long)(n/15) * ((long)15 + (long)n))/(long)2;
      	}
      	else
      	{
      		int count_15 = n;
      		int r = count_15 % 15;
      		count_15 = count_15 - r;
      		sum_15 = ((long)(count_15/15) * ((long)15 + (long)count_15))/(long)2;
      	}
      	System.out.println(sum -sum_5 - sum_3 + sum_15);
    }

}




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

// Range, 0 <= a, b, c <= 100, if a < b < c then output "Yes" otherwise "No"
int main(){
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;

	if(a < b && b < c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	lint x; cin>>x;
	
	cout<<(x/500)*1000 + ((x%500)/5)*5<<"\n";

	return 0;	
}


Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
    int n;
    cin>>n;
    int64_t a[n];
    int64_t cnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i!=0){
            if(a[i-1]>a[i]){
                cnt+=(a[i-1]-a[i]);
                a[i]=a[i-1];
            }
        }
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 5176
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String x=gs();
	    String y=gs();

        //System.out.println(2*b-a);
        if (x.equals(y)) {
        	System.out.print("=");
        }else if(x.compareTo(y) >0){
        	System.out.print(">");
        }else {
        	System.out.print("<");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35688
#include <stdio.h>

#define MAX_H 100
#define MAX_W 100

int H, W, res;
char field[MAX_H][MAX_W];

void dfs(int x, int y, char tree)
{
	field[x][y] = '.';
	
	int dx, dy;
	for (dx=-1;dx<=1;dx++) {
		for (dy=-1;dy<=1;dy++) {
			if (dx==dy || dx==-dy)	
				continue;
			
			int nx = x+dx, ny = y+dy;
			if (0 <= nx && nx< H && 0<= ny && ny < W && field[nx][ny]==tree) {
				dfs(nx, ny, tree);	
			}
		}
	}
}

int main(void)
{
	while (scanf("%d %d", &H, &W)&&H!=0&&W!=0)
	{	
		int i, j;
		char tree;
		res = 0; 
				
		for (i=0;i<H;i++) {
			for (j=0;j<W;j++) {
				scanf("\n%c", &field[i][j]);
			}
		}
		
		for (i=0;i<H;i++) {
			for (j=0;j<W;j++) {
				if (field[i][j]=='*' || field[i][j]=='@' || field[i][j]=='#') {
					tree = field[i][j];
					dfs (i, j, tree);
					res++;
				} 	
			}
		}
			
		printf("%d\n", res);
		
		for (i=0;i<H;i++) {
			for (j=0;j<W;j++) {
				field[i][j] = '\0';
			}
		}
	}
	
	return 0;
} 

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

#define MOD_1_000_000_007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, as[200020];
  map<ll, ll> mp;

  void init() {
    scanf("%lld", &N);
    ll a;
    rep(i, N) {
      scanf("%lld", &as[i]);
      mp[as[i]]++;
    }
  }

  void solve() {
    ll total = 0;
    for(const auto& m : mp) {
      total += m.second*(m.second-1)/2;
    }
    rep(i, N) {
      ll a = as[i];
      ll count = mp[a];
      if(count <= 1) printf("%lld\n", total);
      else printf("%lld\n", total-count*(count-1)/2+(count-1)*(count-2)/2);
    }
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

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

        /*
         * 標準Int入力 int y = scan.nextInt();
         */
        int n = scan.nextInt();
        System.out.println(xx(n));
    }

    public static int xx(final int n) {
        int count = 0;

        for (int i = 1; i <= n; i++) {
            count = count + i;
        }

        return count;
    }

    public static void test() {
        System.out.println("テストだよ~");
    }

    public static int max(final int x, final int y) {
        if (x > y){
            return x;
        }else{
            return y;
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    int cnt = 0;
    int t = n;
    while(t){
        cnt++;
        t >>= 1;
    }

    int e[60][3] = {};
    int ans = 0;
    int cost = 1;
    for(int i = cnt-2; i >= 0; i--){
        e[ans][0] = i;
        e[ans][1] = i+1;
        e[ans][2] = cost;
        cost *= 2;
        ans++;
        e[ans][0] = i;
        e[ans][1] = i+1;
        e[ans][2] = 0;
        ans++;
    }
    cost = n;
    rep(i,cnt-1)if(n & (1LL << i)){
        e[ans][0] = 0;
        e[ans][1] = cnt - i - 1;
        cost -= 1LL << i;
        e[ans][2] = cost;
        ans++;
    }
    cout << cnt << " " << ans << endl;
    rep(i,ans)cout << e[i][0]+1 << " " << e[i][1]+1 << " " << e[i][2] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    vector<int> in(3);
    io.read(in[0], in[1], in[2]);
    sort(in.begin(), in.end());
    if(in[0] == 5 && in[1] == 5 && in[2] == 7){
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001&lang=jp
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>

using namespace std;


int main(){
	int n = 10;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	printf("%d\n", a[9]);
	printf("%d\n", a[8]);
	printf("%d\n", a[7]);


	return 0;

}

Measured memory_bytes: 1160
#include <stdio.h>

int main(int argc, const char * argv[])
{

    char str[20];
    int i, j;
    
    for (i = 0; i < 20; i++) {
        str[i] = getchar();
        if (str[i] == '\n') {
            break;
        }
    }
    for (j = i - 1; 0 <= j; j--) {
        printf("%c",str[j]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; ++i) cin >> x[i];

	int min_res = 2e9;
	for (int i = 1; i <= 100; ++i) {
		int res = 0;
		for (int j = 0; j < n; ++j) {
			res += (x[j] - i) * (x[j] - i);
		}
		min_res = min(min_res, res);
	}
	cout << min_res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> ball(N, 0);
  vector<int> b;

  rep(i, N){
    cin >> a[i];
  }

  for(int i = N-1; i >= 0; i--){// 上から順に入れるかみていく
    int sum = 0;
    for(int j = i; j < N; j = j + i+1){ // トータルの個数をみていく
      sum += ball[j];
    }
    // print(sum);
    if(sum%2!=a[i]){
      ball[i] = 1;
      b.push_back(i+1);
    }
  }

  sort(b.begin(), b.end());
  print(b.size());
  if(b.size() > 0){
    for(int n: b){
      cout << n << " ";
    }
  cout  << endl;
  }

}


Measured memory_bytes: 3064
import java.util.Scanner;

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

        int n = input.nextInt();
        int m = input.nextInt();
        double[] votes = new double[n];
        double total=0;
        for (int i = 0; i < n; i++) {
            double vote = input.nextDouble();
            total+=vote;
            votes[i] =vote;
        }
        int counter =0;
        for (int i = 0; i < n; i++) {
                double ratio = total/(4*m);

            if( votes[i] >=ratio ){
                counter++;
            }
        }
        if(counter >=m){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

int MAXX(vector<int> v,int k){
int max=0;
REP(i,k){if(v[i]>=max){max=v[i];}}
return max;
}

int MINN(vector<int> v,int k){
int min=1e9;
  REP(i,k){if(v[i]<=min)min=v[i];}
return min;
}

int main(){
  string s,a;
  int n,min=754;
  cin>>s;
  REP(i,s.size()-2){
  a=s.substr(i,3);
  n=stoi(a);
    if(abs(n-753)<min){
    min=abs(n-753);
    }
  }
  cout<<min<<endl;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2000005,M=2e6;
const long long mod=1e9+7;
long long fac[N],inv[N],xx[10],yy[10],ans;
long long qpow(long long x,long long k)
{
	if(k==1) return x;
	long long tmp=qpow(x,k/2);
	return k%2?tmp*tmp%mod*x%mod:tmp*tmp%mod;
}
void Prework()
{
	register int i; fac[0]=inv[0]=1;
	for(i=1;i<=M;i++) fac[i]=fac[i-1]*i%mod;
	inv[M]=qpow(fac[M],mod-2);
	for(i=M-1;i;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(i=1;i<=6;i++) scanf("%lld",&xx[i]);
	for(i=1;i<=6;i++) scanf("%lld",&yy[i]);
}
long long C(int a,int b)
{
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
long long Ca(int x1,int y1,int x2,int y2,int x3,int y3)
{  
	long long ret=0,lx1=x3-x2-1,lx2=x2-x1,ly1=y3-y2-1,ly2=y2-y1;
	for(int i=x1;i<=x2;i++) ret+=C(ly1+x3-i,ly1)*C(ly2-x1+i,ly2)%mod*(ly2-x1+i+1)%mod,ret%=mod;
	for(int i=y1;i<=y2;i++) ret+=C(lx1+y3-i,lx1)*C(lx2-y1+i,lx2)%mod*(lx2-y1+i+1)%mod,ret%=mod;
	return ret;
}
long long Cal(int x1,int y1,int x2,int y2)
{
	long long ret=0;
	ret+=Ca(x1,y1,xx[4],yy[4],x2,y2);
	ret-=Ca(x1,y1,xx[3]-1,yy[4],x2,y2);
	ret-=Ca(x1,y1,xx[4],yy[3]-1,x2,y2);
	ret+=Ca(x1,y1,xx[3]-1,yy[3]-1,x2,y2);
	return (ret%mod+mod)%mod;
}
long long Calc(int x,int y)
{
	long long ret=0;
	ret+=Cal(x,y,xx[6]+1,yy[6]+1);
	ret-=Cal(x,y,xx[5],yy[6]+1); 
	ret-=Cal(x,y,xx[6]+1,yy[5]);
	ret+=Cal(x,y,xx[5],yy[5]);
	return (ret%mod+mod)%mod;
}
int main()
{
	Prework();
	ans+=Calc(xx[2],yy[2]);
	ans-=Calc(xx[1]-1,yy[2]);
	ans-=Calc(xx[2],yy[1]-1);
	ans+=Calc(xx[1]-1,yy[1]-1);
	printf("%lld",(ans%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 31360
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    int i,n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;

    scanf("%d",&n);
    
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(i=0;i<n;i++)
        scanf("%d",&y[i]);
    
    for(i=0;i<n;i++){
        
    //p=1
        p_1 += abs(x[i]-y[i]);
    
    //p=2
        p_2 += pow(fabs((double)x[i]-y[i]),2.0);
    
    //p=3
        p_3 += pow(fabs((double)x[i]-y[i]),3.0);
    
    //p=endless
        if(p_0 < abs(x[i]-y[i])) p_0 = abs(x[i]-y[i]);
        
    }
    
    printf("%lf\n%lf\n%lf\n%lf\n", p_1, pow(p_2,1.0/2), pow(p_3,1.0/3), p_0);
    
    
    return 0;
}

Measured memory_bytes: 696
import java.util.Scanner;

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

		String n = sc.next();

		char[] str = new char[n.length()];

		int count = 0;
		for (int i = 0; i < n.length(); i++) {
			String tmp = String.valueOf(n.charAt(i));

			if (tmp.equals("1")) {
				count++;
			}
		}

		// 出力
		System.out.println(count);
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<queue>
#include<string>
using namespace std;
int main(void){
string s;
cin>>s;
int a,b;
bool f=true;
for(int i=0;i<s.size();i++){
	if(s[i]=='A'&&f){
		a=i;
		f=false;
	}
	if(s[i]=='Z'){
		b=i;
	}
}
cout<<b-a+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#!python3

import itertools

import numpy as np


# input
a = input()
b = input()
c = input()


def judge_array(x, y):
    l = [None] * 2001
    for i in range(2001):
        s = x[i:]
        t = y[:2001 - i]
        l[i] = np.all(np.where((s == t) | (s == 0) | (t == 0), True, False))
    return l


def main():
    n = [len(a), len(b), len(c)]
    d = {chr(ord('a') + i - 1): i for i in range(1, 27)}
    d['?'] = 0
    abc = np.full((3, 2001), np.zeros(2001))
    for i in range(2000):
        if i < n[0]:
            abc[0][i] = d[a[i]]
        if i < n[1]:
            abc[1][i] = d[b[i]]
        if i < n[2]:
            abc[2][i] = d[c[i]]

    w = [[None] * 3, [None] * 3, [None] * 3]
    for i in range(3):
        for j in range(3):
            if i == j:
                continue
            w[i][j] = judge_array(abc[i], abc[j])
    
    l = itertools.permutations([0, 1, 2])
    ans = 6000
    for x, y, z in l:
        xy = w[x][y]
        xz = w[x][z]
        yz = w[y][z]
        for i in range(2001):
            for j in range(2001):
                if xy[i] and yz[j] and xz[min(2000, i + j)]:
                    v = max(n[x], i + n[y], i + j + n[z])
                    ans = min(ans, v)
                    break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14644
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int max_dp[2001];
int min_dp[2001];
int a[2001];
int main() {
	int N, Z, W;
	cin >> N >> Z >> W;
	for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = N - 1; i >= 0; i--) {
		max_dp[i] = 0;
		min_dp[i] = 1 << 30;
		for (int j = i + 1; j < N; j++) {
			max_dp[i] = max(max_dp[i], min_dp[j]);
			min_dp[i] = min(min_dp[i], max_dp[j]);
		}
		if (i > 0) {
			max_dp[i] = max(max_dp[i], abs(a[N] - a[i]));
			min_dp[i] = min(min_dp[i], abs(a[N] - a[i]));
		}
		else {
			max_dp[i] = max(max_dp[i], abs(a[N] - W));
			min_dp[i] = min(min_dp[i], abs(a[N] - Z));
		}
	}
	cout << max_dp[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main () {
  int N;
  cin >> N;

  int sum = 0;
  int sa = 0;
 
  
 
   for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sa = r - l + 1;
    sum += sa;
   
  }
  
  cout << sum << endl;
}

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

int main(void){

    int N, K;

    scanf("%d%d", &N, &K);

    int ans = K;

    for(int i = 1; i < N; i++){
        ans *= (K-1);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1720
#include<stdio.h>
int main(){
  int n,d[n-1],count = 0;
  scanf("%d",&n);
  for(int i = 0;i<n;i++){
    scanf("%d",&d[i]);
  }
  for(int i = 0;i<n;i++){
    for(int j = 0;j<n;j++){
      if(d[i] == d[j] && i != j){
        d[i] = 0;
      }
    }
  }
  for(int i = 0;i<n;i++){
    if(d[i] != 0){
      count++;
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
a = list(map(int, input().split()))

A = a[0] + a[1]
if(A==10 or A==12):
  if (a[0] == 7):
    if(a[2] == 5 and a[1] == 5):
      print('YES')
    else:
      print('NO')
  elif (a[1] == 7):
    if(a[2] == 5 and a[0] == 5):
      print('YES')
    else:
      print('NO')
  elif (a[2] == 7):
    if(a[0] == 5 and a[1] == 5):
      print('YES')
    else:
      print('NO')
  else:
    print('NO')
else:
  print('NO')

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

using namespace std;

const int N_MAX = 100;
int N, W;
int w[N_MAX+10], v[N_MAX+10];
int dp[N_MAX+10][10200] = {};

int main() {
  int i, j;
  scanf("%d %d", &N, &W);
  for (i = 0; i < N; i++) {
    scanf("%d %d", &v[i], &w[i]);
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < W; j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  for (i = 0; i < N; i++) {
    for (j = 0; j < W+1; j++) {
      if (dp[i][j] != -1) {
	dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
	if (j + w[i] <= W) {
	  dp[i+1][j+w[i]] = max(dp[i][j] + v[i], dp[i+1][j+w[i]]);
	}
      }
    }
  }
  int ans = 0;
  for (j = 0; j <= W; j++) {
    if (ans <= dp[N][j]) {
      ans = dp[N][j];
    }
  }
  //for (i = 0; i < N+1; i++) {
  //  for (j = 0; j < W+1; j++) {
  //    printf("%d ", dp[i][j]);
  // }
  //  printf("\n");
  // }
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 6764
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

int main(void) {

  int isright[26] = {
    0, 0, 0, 0, 0, 0, 0,       // A ~ G
    1, 1, 1, 1, 1, 1, 1, 1, 1, // H ~ P
    0, 0, 0, 0,                // Q ~ T
    1,                         // U
    0, 0, 0,                   // V ~ X
    1,                         // Y
    0                          // Z
  };

  for(;;) {
    std::string str;
    std::cin >> str;
    if( str == "#" ) break;
    
    int n = str.size();

    std::vector<int> v;
    for(int i = 0; i < n; ++i) {
      v.push_back( isright[ str[i] - 'a' ] );
    }

    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::cout << (int)v.size() - 1 << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll rcmax = 1000000;
    vector<mint> kai(rcmax*3,1);
    for(ll i=1;i<=rcmax*3;++i){
        kai[i] = kai[i-1]*mint(i);
    }
    mint ans(0);
    for(ll i=r1;i<=r2;++i){
        mint t1 = kai[i+c2+1]/(kai[i+1]*kai[c2]);
        mint t2 = kai[i+c1]/(kai[i+1]*kai[c1-1]);
        ans += t1 - t2;
    }
    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n , a[200007]={0} , i , m[200007]={0};
    stack < pair < int , int >  > st;
    long long int dp[200007]={0};
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    st.push({a[1] , 1});
    for(i=2;i<=n;i++)
    {
        int ne = a[i];
        if(st.empty())
        {
            st.push({a[i],i});
            continue;
        }
        int to = st.top().first;
        int mi = st.top().second;
        st.pop();
        while(to >= ne)
        {
            m[mi] = i;
            if(st.empty()) break;
            to = st.top().first;
            mi = st.top().second;
            st.pop();
        }
        if(to < ne)
        {
            st.push({to,mi});
        }
        st.push({a[i],i});
    }
    while(!st.empty())
    {
        m[st.top().second] = n + 1;
        st.pop();
    }
    long long int ans = 0;
    for(i=n;i>=1;i--)
    {
        dp[i] = (long long int)(m[i] - i)*(a[i]) + dp[m[i]];
        ans = ans + dp[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4992
N, M = map(int, input().split())
K = {}
like = [0] * M
for i in range(1, N + 1):
    inp = list(map(int, input().split()))
    for j in inp[1:]:
        like[j - 1] += 1
ans = 0
for i in like:
    if i == N:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n;
    cin >> n;
    pri(n*n*n);





}











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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion



int main(void)
{
	double    a, b, n, i,p;
	ull       y, x, t1, t2, tmp = 0;


	lf_cin(a);	lf_cin(b); lf_cin(n);


	/*for (i = n; i >= 1; i--) {
		t1 = (ull)(i / b) * (ull)a;
		t2 = (ull)((a * i) / b);
		y = t2 - t1;
		if (y > tmp) tmp = y;
		printf("i:%llf %lld \n", i, y);
	}*/

	if (n >= b) n = b - 1;
	t1 = (ull)(n / b) * (ull)a;
	t2 = (ull)((a * n) / b);
	y = t2 - t1;

	ull_cout(y);
	return 0;
}

//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 1732
s = input()

dp = [[[0, ''], [0, '']], [[1, s[0]], [-10**6, '']]]
for i in range(1, len(s)):
    if s[i-1:i+1] == dp[-2][1][1]:
        ndp1 = [dp[-2][0][0]+1, s[i-1:i+1]]
    else:
        ndp1 = [max(dp[-2][0][0], dp[-2][1][0])+1, s[i-1:i+1]]
    if s[i] == dp[-1][0][1]:
        ndp0 = [dp[-1][1][0]+1, s[i]]
    else:
        ndp0 = [max(dp[-1][0][0], dp[-1][1][0])+1, s[i]]
    dp.append([ndp0, ndp1])

print(max(dp[len(s)][0][0], dp[len(s)][1][0]))

Measured memory_bytes: 85416
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    cin >> N;

    if(N % 111 == 0){
        p(N);
    }else{
        int answer = (N / 111 + 1) * 111;
        p(answer);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    char op;
    
    while(1){
    scanf("%d %c %d",&a, &op, &b);
    
    if ( op == '+' )printf("%d\n",a + b );
    else if ( op == '-' )printf("%d\n",a - b );
    else if ( op == '*' )printf("%d\n",a * b );
    else if ( op == '/' )printf("%d\n",a / b ); 
    
    else if ( op == '?') break;
    
    }
    return 0;
    
     
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=998244353;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
ll f[10010],fi[10010];
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
void fact(ll n){
    f[0]=1;
    for(ll i=1;i<=n;i++){
        f[i]=f[i-1]*i%MOD;
    }
    fi[n]=mod_pow(f[n],MOD-2,MOD);
    for(ll i=n-1;i>=0;i--){
        fi[i]=fi[i+1]*(i+1)%MOD;
    }
}
ll ncr(ll n,ll r){
    if(r==0)return 1;
    if(n<0||r<0||n<r)return 0;
    return ((f[n]*fi[r])%MOD*fi[n-r])%MOD;
}
ll nhr(ll n,ll r){
    if(n==0&&r==0)return 1;
    return ncr(n+r-1,r);
}
int main(){
    ll n,k;cin>>k>>n;
    fact(10000);
    for(ll i=2;i<=2*k;i++){
        ll p=0;
        ll ans=0;
        for(int j=1;j<=k;j++){
            if(j<i-j&&i-j<=k)p++;
        }
        for(ll q=0;q<=min(n,p);q++){
            if(i%2){
                ans+=mod_pow(2,q,MOD)*ncr(p,q)%MOD*nhr(k-2*p+q,n-q)%MOD;
                ans%=MOD;
            }else{
                ans+=mod_pow(2,q,MOD)*ncr(p,q)%MOD*(nhr(k-2*p+q-1,n-q)+nhr(k-2*p+q-1,n-q-1))%MOD;
                ans%=MOD;
            }
        }
        cout<<ans%MOD<<endl;
    }
}


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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 1e6+5;
vector<int> p;
bool np[N];

void init(){
    for(int i = 2; i <= sqrt(N); ++i){
        if(!np[i]){
            p.push_back(i);
            for(int j = 2*i; j < N; j+=i)
                np[j] = 1;
        }
    }
}

LL gg(int x){
    LL res = 1;
    for(int &prime: p){
        if(prime > x) break;
        LL c = 0;
        while(x%prime == 0){
            x /= prime;
            c++;
        }
        res *= (c+1);
    }
    if(x != 1) res *= 2;
    return res;
}

void solve(){
    init();
    int n;
    cin >> n;
    LL res = 0;
    for(int c = 1; c < n; ++c){
        int ab = n-c;
        res += gg(ab);
    }
    cout << res << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 4632
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


class Coordinate:
    def __init__(self, x, y):
        self.x = x
        self.y = y


def kock(n, p1, p2):
    if n == 0:
        return

    s = Coordinate((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3)
    t = Coordinate((p1.x + 2 * p2.x) / 3, (p1.y + 2 * p2.y) / 3)
    u = Coordinate(
        (t.x - s.x) * math.cos(math.pi / 3) -
        (t.y - s.y) * math.sin(math.pi / 3) + s.x,
        (t.x - s.x) * math.sin(math.pi / 3) +
        (t.y - s.y) * math.cos(math.pi / 3) + s.y
    )

    kock(n - 1, p1, s)
    print(s.x, s.y)
    kock(n - 1, s, u)
    print(u.x, u.y)
    kock(n - 1, u, t)
    print(t.x, t.y)
    kock(n - 1, t, p2)


def main():
    n = int(input())

    p1 = Coordinate(0, 0)
    p2 = Coordinate(100, 0)

    print(p1.x, p1.y)
    kock(n, p1, p2)
    print(p2.x, p2.y)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9132
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val p = List.fill(n)(sc.nextInt)
  val q = List.fill(n)(sc.nextInt)

  val permutation = (1 to n).permutations.toVector

  val res = Math.abs(permutation.indexOf(p) - permutation.indexOf(q))

  println(res)


}


Measured memory_bytes: 49660
n=int(input())
b=input()
a={i:b.count(i) for i in b}
for i in range(n-1):
    b=input()
    a={i:min(a[i],b.count(i)) for i in b if i in a}
ans=""
for i in a.keys():
    ans+=i*a[i]
print(*sorted(ans),sep="")

Measured memory_bytes: 3188
#include <iostream>

int main(void)
{
    int iInput[5];
    int iK;
    int iIndex;
    for( iIndex = 0; iIndex < 5; iIndex++)
    {
        std::cin>>iInput[iIndex];
    }
    std::cin>>iK;
    if((iInput[4] - iInput[0]) > iK)
    {
        std::cout<<":("<<std::endl;
    }
    else
    {
        std::cout<<"Yay!"<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<numeric>
#include<sstream>
#include<cmath>
using namespace std;
long long int mod = 1e9;

int func(vector<int> a, int p) {
  int n = a.size();
  int x = a[0];
  if(p == 0) x = a[1];
  for(int i=0; i<n; i++) {
    if(i == p) continue;
    x = __gcd(x, a[i]);
  }
  return x;
}

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

  vector<int> l(n+1, 0);
  vector<int> r(n+1, 0);
  int x = a[0];
  for(int i=0; i<n; i++) {
    x = __gcd(x, a[i]);
    l[i] = x;
  }
  int y = a[n-1];
  for(int i=n-1; i>=0; i--) {
    y = __gcd(y, a[i]);
    r[i] = y;
  }

  int ans = 1;
  for(int i=1; i<n-1; i++) {
    ans = max(ans, __gcd(l[i-1], r[i+1]));
  }
  ans = max({ans, l[n-2], r[1]});
  cout << ans << endl;

  return 0;
}




// EOF


Measured memory_bytes: 1408