akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	
//	入力されるデータセット
	public static Scanner inputData = null; 
//	 入力された生徒数:n
	public static int iStudentNum = 0;
//	 入力された生徒の点数の配列を格納したList(n<1000のため1000)
	public static int[] iScoreList = new int[1000];
//	点数の平均値
	public static double dScoreMean = 0;
//	標準偏差
	public static double dSD = 0;
	
	public static void main(String[] args) {
//		TODO データセットを取得する処理
		getData();
		while( true) {
//			TODO 生徒数nを取得する処理
			getStudentNum();
//			TODO n=0の時、処理を終了する
			if( iStudentNum == 0) {
				inputData.close();
				break;
			}
//			TODO 生徒の点数の配列 LScoreList を取得する処理
			getScore();
//			TODO LScoreList から、平均値を出す処理
			getMeanScore();
//			TODO 標準偏差を割り出す処理
			getSD();
//			TODO 標準偏差を出力する処理
			outputResult();
		}
	}

	private static void outputResult() {
		// TODO 値を出力する処理
		System.out.println(dSD);
		}

	private static void getSD() {
		// TODO 平均値から標準偏差を割り出す処理
		double sumSigmaResult = 0;
		for(int count=0; count<iStudentNum; count++ ) {
			sumSigmaResult += Math.pow( iScoreList[count] - dScoreMean, 2);
		}
		dSD = Math.sqrt( sumSigmaResult / ( double)iStudentNum);
	}

	private static void getMeanScore() {
		// TODO Listのデータから平均値を出す処理
		int sumScore = 0;
		for(int count=0; count<iStudentNum; count++ ) {
			sumScore += iScoreList[count];
		}
		dScoreMean = sumScore / ( double)iStudentNum;
	}

	private static void getScore() {
//		TODO 生徒の点数の配列 LScoreList を取得する処理
//		初期化
		for( int count=0; count<iScoreList.length; count++) {
			iScoreList[count] = 0;
		}
		for( int count=0; count<iStudentNum; count++) {
			iScoreList[count] = inputData.nextInt();
		}
	}

	private static void getStudentNum() {
		// TODO 生徒数nを取得する処理
		if( inputData.hasNext() ) {
			iStudentNum = inputData.nextInt();
		}
	}
	
	private static void getData() {
		// TODO データセットを取得する処理
		inputData = new Scanner(System.in);
	}
}


Measured memory_bytes: 31536
#include <iostream>
#include <cmath>

bool is_triangle(int a, int b, int c) {
  return (std::pow(a, 2) == (std::pow(b, 2) + std::pow(c, 2)));
}

int main(void) {
  int n = 0;
  
  int a = 0;
  int b = 0;
  int c = 0;

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;

    bool triangle = is_triangle(a, b, c) || is_triangle(b, c, a) || is_triangle(c, a, b);

    if (triangle) {
      std::cout << "YES" << std::endl;
    } else {
      std::cout << "NO" << std::endl;
    }
  }
   
  return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

ll gcd(ll a, ll b) {
	if (b == 0) return abs(a);
	else return gcd(b, a % b);
}

int main() {
	int T; cin >> T;
	while (T--) {
		ll h, w; cin >> h >> w;
		for (; h % 2 == 0 && w % 2 == 0; h /= 2, w /= 2);
		if (h % 2 == 0 || w % 2 == 0) {
			cout << 1 << ' ' << 1 << endl;
			continue;
		}
		ll d = gcd(h, w);
		h /= d; w /= d;
		if (h < w) swap(h, w);
		ll r = ((h - w) / 2 + 1) * w + (w / 2) * (w / 2) * 2;
		ll b = ((h - w) / 2) * w + (w / 2) * (w / 2 + 1) * 2;
		d = gcd(r, b);
		cout << r / d << ' ' << b / d << endl;
	}
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
	
	string s[3];
	cin>>s[0]>>s[1]>>s[2];
	int i[3]={0};
	int l=0,m=0;
	char ans;
	bool flag=true;
	while(flag){
		if(s[l][m]=='a'){
			i[l]++;
			l='a'-'a';
			m=i[l];
			if(m==s[l].size()){
				flag=false;
				cout<<'A'<<endl;
			}
			//cout<<'a';
		}
		else if(s[l][m]=='b'){
			i[l]++;
			l='b'-'a';
			m=i[l];
			if(m==s[l].size()){
				flag=false;
				cout<<'B'<<endl;
			}
			//cout<<'b';
		}
		else if(s[l][m]=='c'){
			i[l]++;
			l='c'-'a';
			m=i[l];
			if(m==s[l].size()){
				flag=false;
				cout<<'C'<<endl;
			}
			//cout<<'c';
		}
	}
	
}

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

int main() {
  int a,b,c; cin >> a >> b >>c;
  int k; cin >> k;
  int cnt = 0;
  while(1){
    if(a >= b){
      b *=2;
      cnt++;
      //cout << cnt << endl;
    }
    else
      break;
  }
  while(1){
    if(b >= c){
      c *=2;
      cnt++;
      //cout << cnt << endl;
    }
    else
      break;
  }
  
  if(cnt <= k)
    cout << "Yes";
  else
    cout << "No";
    
}



Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 310

//head

int n, k;
int h[N];
ll dp[N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  rep(i, n) cin >> h[i+1];
  fill(dp[0]+1, dp[n+1], LINF);
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= i; j++) {
      for(int k = j-1; k < i; k++) {
        chmin(dp[i][j], dp[k][j-1] + max(0, h[i]-h[k]));
      }
      //cout << dp[i][j] << (j == i?'\n':' ');
    }
  }
  ll ans = LINF;
  rep(i, n+1) chmin(ans, dp[i][n-k]);
  cout << ans << endl;
}

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

const int maxn = 200 + 10, inf = 1e9 + 1;
int w[maxn][maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, r; cin >> n >> m >> r;
    for (int i = 0; i < maxn; ++i) for (int j = 0; j < maxn; ++j) w[i][j] = inf;
    for (int i = 0; i < maxn; ++i) w[i][i] = 0;
    vector<int> ord(r);
    for (int i = 0; i < r; ++i) cin >> ord[i];
    for (int i = 0; i < m; ++i) {
        int a, b, c; cin >> a >> b >> c;
        w[a][b] = min(w[a][b], c);
        w[b][a] = min(w[b][a], c);
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
            }
        }
    }
    if (r == 2) return cout << w[ord[0]][ord[1]] << endl, 0;
    sort(ord.begin(), ord.end());
    int ans = inf;
    do {
        int cur = 0;
        for (int i = 0; i < r - 1; ++i) cur += w[ord[i]][ord[i + 1]];
        ans = min(ans, cur);
    } while (next_permutation(ord.begin(), ord.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    n, m = map(int, input().split())
    a = set([int(input()) for _ in range(m)])

    ansls = [0]*(n+1)
    big = 10**9 + 7

    if 0 not in a:
        ansls[0] = 1
    if 1 not in a:
        ansls[1] = 1

    for i in range(2, n+1):
        if i not in a:
            ansls[i] = (ansls[i-2] + ansls[i-1])%big
    
    print(ansls[-1])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 13216
#include <atcoder/fenwicktree>
#include <cstdio>

int main() {
  int n, q;
  scanf("%d %d", &n, &q);

  atcoder::fenwick_tree<long long> tree(n);
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    tree.add(i, a);
  }

  while (q--) {
    int t, l, r;
    scanf("%d %d %d", &t, &l, &r);

    if (t == 0) {
      tree.add(l, r);
    } else if (t == 1) {
      printf("%lld\n", tree.sum(l, r));
    }
  }
  return 0;
}


Measured memory_bytes: 8216
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int n;
  cin >> n;
  VI a(n);
  rep(i,n){
	cin >> a.at(i);
  }
  ll m;
  m=pow(3,a.size());
  int odd=1;
  rep(i,n){
    if(a.at(i)%2==0){
      odd*=2;
    }
  }
  cout << m-odd << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    rep(i,h){
        rep(j,w){
            int flag = 0;
            if(i<b)flag++;
            if(j<a)flag++;
            if(flag%2==0){
                cout << '0';
            }else{
                cout << '1';
            }
        }
        cout << endl;
    }

    return 0;
}
 
 


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

#define INF 100100100
#define MOD 1000000007

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

using namespace std;
using ll = long long;
using ull = unsigned long long ;

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n;
   cin >> n;
   vector<int>a(n);
   FOR(i,n)cin>>a[i];

   map<int,int>mp[2];
   FOR(i,n){
      mp[i&1][a[i]]++;
   }

   vector<pair<int,int> > v[2];
   for(int i=0;i<2;i++){
      for(auto &j:mp[i]){
         v[i].emplace_back(j.second,j.first);
      }
      sort(v[i].rbegin(),v[i].rend());
      if(v[i].size() == 1){
         v[i].emplace_back(0,-1);
      }
   }

   int ans = 0;
   FOR(i,2){
      FOR(j,2){
         if(v[0][i].second != v[1][j].second){
            ans = max(ans,v[0][i].first+v[1][j].first);
         }
      }
   }
   cout << n-ans << endl;

   return 0;
}


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

int main(){

  int a,b;
  cin >> a >> b;
  if(a==1){
    a=10000;
  }
  if(b==1){
    b =	10000;
  }

  if(a>b){
    cout << "Alice" << endl;
  }else	if(a==b){
    cout << "Draw" << endl;
  }else{
    cout << "Bob" << endl;
  }

}




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


struct UnionFind {

	vector<long long> data;

	UnionFind(long long size): data(size, -1) {}
	
	void unite(long long x, long long y){
		x = root(x);
		y = root(y);
		if( x != y ){
			if( data[y] < data[x] ) swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
	}

	bool same(long long x, long long y){
		return root(x) == root(y);
	}

	long long root(long long x){
		return (data[x] < 0) ? x : data[x] = root(data[x]);
	}

	long long size(long long x){
		return -data[ root(x) ];
	}
};


int main() {
    long long n, q;
    cin >> n >> q;
    UnionFind tree(n);

    for (long long i = 0; i < q; i++) {
        long long com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            tree.unite(x, y);
        } else {
            if (tree.same(x , y)) cout << 1 <<endl;
            else cout << 0 << endl;
        }
    }
}




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

int main()
{
	int a, b, c;

	while (cin >> a >> b)
	{
		int count = 1;
		c = a + b;
		while (c >= 10)
		{
			c = c / 10;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
  
using namespace std;

int n, m;
string b = "";
int p[15];

int solve(int  sn)
{
    string nowp = "";
    int ans = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < p[i]; j++){
            if(i % 2 == 0) nowp += sn + '0';
            else nowp += (sn + 1) % 2 + '0';
        }
    }
    // cout << nowp << endl;
    for(int i = 0; i < nowp.length() - 1; i++){
        if(nowp[i] != b[i]){
            int cnt = 1;
            while(nowp[i + cnt] != b[i] && i + cnt < nowp.length()) cnt++;
            // cout << cnt << endl;
            for(int j = i + cnt; j > i; j--){
                swap(nowp[j], nowp[j - 1]);
                ans++;
            }
        }
    }
    // cout << ans << endl;
    return ans;
}


int main()
{
    cin >> n >> m;
    int bzeronum = 0,pevennum = 0;
    char c;
    for(int i = 0; i < n; i++){
        cin >> c;
        if(c == '0') bzeronum++;
        b += c;
    }
    for(int i = 0; i < m; i++){
        cin >> p[i];
        if(i % 2 == 0) pevennum += p[i];
    }
    int ans = 1000;
    if(bzeronum == pevennum) ans = min(ans, solve(0));
    if(n - bzeronum == pevennum) ans = min(ans, solve(1));
    cout << ans << endl;
}

Measured memory_bytes: 1216
a,b,k=map(int,input().split())

loop=0
if a<b:
    loop=a
else:
    loop=b
ans=0

for i in range(loop,0,-1):
    if a%i==0 and b%i==0:
        k-=1
        if k==0:
            ans=i
            break

print(ans)       

Measured memory_bytes: 3064
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int input;
	int sum = 0;
	for(int i = 0;i < 4;i++){
		cin >> input;
		sum += input;
	}
	cout << sum / 60 << endl << sum % 60 << endl;
	return 0;
}

Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ShiftOnly solver = new ShiftOnly();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class ShiftOnly {

		private int n;
		private ArrayList<Integer> aInput;

		private Scanner scanner;

		private String answer;

		public ShiftOnly() {
			this.scanner = new Scanner(System.in);
		}

		public void readInput() {
			aInput = new ArrayList<Integer>();
			n = scanner.nextInt();
			for(int i=0; i<n; i++) {
				Integer b =scanner.nextInt();
				aInput.add(b);
			}
		}

		public void solve() {
			int o = 0;
			while(true) {
				for(Integer a :aInput) {
					aInput.set(aInput.indexOf(a), a>>1);
					if(Integer.lowestOneBit(a) == 1) {
						answer = String.valueOf(o);
						return;
					}
				}
				o++;
			}
		}

		public void writeOutput() {
			System.out.println(answer);
		}

	}


}


Measured memory_bytes: 21972
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int Maxn=200000+10;
int n,m,ans;
double a[Maxn],b[Maxn];
inline double dis(double x,double y)
{
	return sqrt((x*x)+(y*y));
}
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	n=read(),m=read();
	double tmp=1.0*m;
	for(int i=1;i<=n;++i)
	{
		a[i]=read(),b[i]=read();
		if(dis(a[i],b[i])<=tmp)++ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6828
#include<iostream>

using namespace std;

int main(){

  int n=0, i=0;
  long long int S1=0, S2=0;
  int* a = new int[n];

  cin >> n;
  while(i<n){
    cin >> a[i];
    S2+=a[i];
    i++;
  }

  int min = S2;
  for(i=0;i<n;i++){
    S1+=a[i];
    S2-=a[i];
    if(abs(S1-S2) <= min){
      min=abs(S1-S2);
    }
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right
N, K = map(int, input().split())
s = input()

arr = [0] * N
cnt = 0
Flag = False
for i, char in enumerate(s):
    if not Flag and char == '0':
        Flag = True
        cnt += 1
    if char == '1':
        Flag = False
    arr[i] = cnt
ans = 0
for i, val in enumerate(s):
    if val == '0':
        ans = max(ans, bisect_right(arr,arr[i]+K-1)-i)
    else:
        ans = max(ans, bisect_right(arr,arr[i]+K)-i)
print(ans)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	cout<<"square1001"<<endl;
	
	return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
using namespace std;
     
int main() {
  int sum = 0;
  string str;
  cin >> str;
  
  while (!(str == "0")) {
    sum = 0;
    for (int i = 0; i < str.size(); i++) {
      sum += (str[i] - '0');
    }
    cout << sum << endl;
  
    cin >> str;
  }
  return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N, M; cin >> N >> M;
    V<int> A(N);
    rep(i, N) cin >> A[i];
    priority_queue<int> que;
    rep(i, N) que.push(A[i]);
    rep(t, M) {
        int x = que.top(); que.pop();
        que.push(x / 2);
    }
    ll ans = 0;
    rep(i, N) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr =input.trim().split("\n");
var [a,b] = arr.shift().split(" ").map(Number);
var n = arr.shift() - 0;
var flag = 0;
while(n--){
   var [s,f] = arr.shift().split(" ").map(Number);
   if(f<=a || b<=s)continue;
   else flag = 1;
}
console.log(flag);


Measured memory_bytes: 17392
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,count,next,loopnum,startloop,p;
    long long int k;
    cin>>n>>k;
    int a[n],l[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        l[i]=0;
    }
    count=next=1;
    while(1){
        if(l[next-1]==0){
            l[next-1]=count;
            count++;
            next=a[next-1];
        }
        else{
            loopnum=count-l[next-1];
            startloop=l[next-1];
            break;
        }
    }
    if(k+1-startloop<0)p=k+1;
    else p=(k+1-startloop)%loopnum+startloop;
    for(int i=0;i<n;i++){
        if(l[i]==p){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 5204
a=[]
for n in range(5):
    b=int(input())
    a.append(b)

def mykey(x):
    x=x%10
    if x<0:
        x=-x
    if x==0:
        x=10
    return -int(x)

b=sorted(a,key=mykey)
    
for i in range(4):
    if (b[i]%10)>0:
        b[i]=int(b[i]/10)+1
        b[i]=b[i]*10
g=0    
for i in range(5):
    g+=b[i]
print(g)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  const int D = 60;
  vector<vector<int>> to(n, vector<int>(D + 1));
  REP(i, n) {
    cin >> a[i];
    a[i]--;
    to[i][0] = a[i];
  }

  REP(j, D) {
    REP(i, n) { to[i][j + 1] = to[to[i][j]][j]; }
  }

  int p = 0;

  REP(i, D + 1) {
    if (k & (1LL << i)) {
      p = to[p][i];
    }
  }
  cout << p + 1 << endl;
}


Measured memory_bytes: 58648
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"

int  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    data_type t,n,k,te=0;
    cin>>n;
    vector<data_type> vc(n);
    for(auto &i:vc)
        cin>>i;
    data_type avg=accumulate(vc.begin(),vc.end(),0LL);
    data_type x1=(avg+n-1)/n,x2=avg/n,ans1=0,ans2=0;
    for(auto i:vc)
        {
            ans1+=(i-x1)*(i-x1);
            ans2+=(i-x2)*(i-x2);
        }
    cout<<min(ans1,ans2)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SZ(x) x.size()
#define pii pair<int,int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int mod = 1e9 + 7;
ll qpow(ll a, ll b, ll mod) {
    ll ans = 1;
    while(b) {
        if(b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll inv(ll a, ll p) {
    return qpow(a, p - 2, p) ;
}
ll Inv[200005];
int main() {
    for(int i = 0; i < 200005; i++)
        Inv[i] = inv(i, mod);
    ll n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    ll t1 = 1;
    for(ll i = n - a + 1; i <= n; i++)
        t1 = t1 * i % mod;
    for(ll i = 1; i <= a; i++)
        t1 = t1 * Inv[i] % mod;
    ll t2 = 1;
    for(ll i = n - b + 1; i <= n; i++)
        t2 = t2 * i % mod;
    for(ll i = 1; i <= b; i++)
        t2 = t2 * Inv[i] % mod;
    ll ans = qpow(2, n, mod) - 1 - t1 - t2;
    ans = (ans % mod + mod) % mod;
    printf("%lld", ans);
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
   string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
   string b;
   cin>>b;
   for(int i=0; i<7; i++){
       if (a[i]==b){
           cout<<7-i;
       }
   }
   return 0;
}

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

typedef struct box{ int val; box* next; } box_t;

box_t* init()   // initialize.
{
    box_t* head = new box_t;
    head->val = -1;
    head->next = NULL;
    return head;
}

box_t* push(box_t* head, int data)
{
    box_t* box = new box_t;
    box->val = data;
    box->next = head->next;
    head->next = box;
    return box;
}

int pop(box_t* head)
{
    box_t* box = head->next;
    int val;
    if(box == NULL){
        return 0;
    }else{
        head->next = box->next;
        val = box->val;
        delete box;
    }
    return val;
}

bool isEmpty(box_t* head){ return (head->next == NULL ? true : false); }

int front(box_t* head)
{
    if(head->next == NULL) return -1;
    return head->next->val;
}

int volume(box_t* head)
{
    int v = 0;
    box_t*box = head->next;
    while(box){ box = box->next; v++; }
    return v;
}

void reduce(box_t* head)
{
    int val1, val2;
    val1 = pop(head);
    val2 = pop(head);
    push(head, val1 + val2);
    return;
}

void show_all(box_t* head)
{
    box_t* box = head->next;
    while(box){
        cout << box->val;
        box = box->next;
        if(box) cout << " ";
    }
    cout << endl;
}

int main()
{
    char data[20000], ch;
    box_t* b1 = init();
    box_t* ponds = init();
    box_t* b2 = init();
    int i = 0, left, Area = 0, end = 0;

    cin >> data;
    while(data[end]){ end++; };

    while(data[end - i - 1]){
        ch = data[end - i - 1];
        if(ch == '/'){
            push(b1, i); push(b2, i);
        }else if(ch == '\\'){
            if(isEmpty(b1)){ i++; continue; }
            left = pop(b1);
            Area = Area + i - left;
            push(ponds, i - left);
            while(front(b2) > left){
                pop(b2);
                reduce(ponds);
            };
        }else{}
        i++;
    };
    cout << Area << endl;
    cout << volume(ponds);
    if(!isEmpty(ponds)){
        cout << " "; show_all(ponds); 
    }else{
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2440
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")
#define y1 hoainambimaysolokill
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,pair<int,int> >
#define PII3 pair<pair<int,int>,int >
int n;
void solve()
{
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(int(log10(i))%2==0)ans++;
    }
    cout<<ans;
}
main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);

    //freopen("TBC.inp", "r", stdin);
    //freopen("FORMMAU.out", "w", stdout);

    //int t;cin>>t;while(t--)

    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n;
vector<vi> e;
int rec(int c, int p, int d){
	int res = 1;
	if(d == 0) return res;
	for(int i : e[c]) if(i != p){
		res += rec(i, c, d - 1);
	}
	return res;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int k; cin >> n >> k;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	int ans = 0;
	if(k % 2){
		rep(i, n) for(int j : e[i]) if(i < j){
			ans = max(ans, rec(i, j, k / 2) + rec(j, i, k / 2));
		}
	}
	else{
		rep(i, n) ans = max(ans, rec(i, i, k / 2));
	}
	cout << n - ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
from copy import deepcopy
# 多次元配列を作成する
def make_multi_list(initial, degree):
    ans = [initial for _ in range(degree[-1])]
    for d in reversed(degree[:-1]):
        ans = [deepcopy(ans) for _ in range(d)]
    return ans


H, W = map(int, input().split())
C = []
INF = float('inf')
dist = make_multi_list(INF, [10, 10])

for i in range(10):
    C.append(list(map(int, input().split())))

# ワーシャルフロイド
for i in range(10):
    for j in range(10):
        dist[i][j] = C[i][j]
for k in range(10):
    for i in range(10):
        for j in range(10):
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

ans = 0
for i in range(H):
    for n in map(int, input().split()):
        if n == -1:
            continue
        ans += dist[n][1]

print(ans)


Measured memory_bytes: 3436
#include<iostream>

#define A 1.1
#define B 0.6
#define C 0.2

using namespace std;

int main(){
	int rc[4]={0},lc[4]={0},count=0;
	double r,l;
	
	while(cin>>r>>l){
		if(r>=A){
			rc[0]++;
		}
		else if(r>=B && r<A){
			rc[1]++;
		}
		else if(r>=C && r<B){
			rc[2]++;
		}
		else if(r<C){
			rc[3]++;
		}
		
		if(l>=A){
			lc[0]++;
		}
		else if(l>=B && l<A){
			lc[1]++;
		}
		else if(l>=C && l<B){
			lc[2]++;
		}
		else if(l<C){
			lc[3]++;
		}
		
		count++;
	}
	for(int i=0;i<4;i++){
		cout<<rc[i]<<" "<<lc[i]<<endl;
	}
}

Measured memory_bytes: 1224
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
   input!{n:chars};
   println!("{}", if n[0]==n[2] {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<(A+B>=C?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int sum=0;
    string s;
    cin >> s;
    for (int i=0; i<s.length(); i++){
        sum += s[i]-'0';
    }
    if (sum%9 == 0)
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3708
import scala.io.StdIn._
object Main extends App {
  val x = readLine.trim.split(' ').map(_.toLong).apply(0)

  var deposit = 100L
  var year = 0
  while(deposit < x){
    deposit = (deposit * 1.01).toLong
    year = year + 1
  }

  println(year)
}


Measured memory_bytes: 54708
N, M = map(int, input().split())
order = [i for i in range(2, N+1)]
reverse = order[::-1]
d = 0
for i in range(M):
    if N%4 == 0 and reverse[i] - order[i] == N//2:
        d = 1
    if N%2 == 0 and i == (N//2-1) //2:
        d = 1
    print(order[i+d], reverse[i])

Measured memory_bytes: 80368
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7;
const long long OO = 1e18+25;

#define par pair<pair<int,int>, int>
#define f first
#define s second

int n,W,w[105], v[105], mx;
long long mem[105][N]; 

long long dp(int idx, int prof)
{
    if(prof == 0) return 0;
    if(idx == n) return oo;
    long long &ret = mem[idx][prof];
    if(~ret) return ret;
    return ret = min(dp(idx+1, prof), (prof>=v[idx]?dp(idx+1, prof-v[idx])+w[idx]:oo));
}

int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d%d",&n,&W);
    for(int i=0; i<n ;i++) scanf("%d%d",w+i,v+i);
    for(int i=N-1; i>0; i--) 
        if(dp(0, i)<=W)
        {
            mx = i;
            break;
        }

    printf("%d",mx);
    return 0;
}

Measured memory_bytes: 82432
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 5003
#define ll long long

using namespace std;

int n, m, a, b;
int pos[N];
ll f[N][N << 1];

int main(){
	cin >> n >> a >> b; m = n * 2 + 1;
	for(int i = 1; i <= n; ++i){
		int x; scanf("%d", &x);
		pos[x] = i * 2;
	}
	memset(f, 127, sizeof f);
	for(int j = 1; j <= m; ++j) f[0][j] = 0;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			ll tmp = (j != pos[i]) * (j < pos[i] ? b : a);
			if(j & 1) tmp += f[i - 1][j];
			else tmp += f[i - 1][j - 1];
			f[i][j] = tmp;
		}
		for(int j = 2; j <= m; ++j)
			f[i][j] = min(f[i][j], f[i][j - 1]);
	}
	cout << f[n][m] << endl;
	return 0;
}

Measured memory_bytes: 391424
#include <bits/stdc++.h>
using namespace std;
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> check(n, 0);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }

    vector<vector<int>> a(m, vector<int>(2));
    for(int i = 0; i < m; i++){
        cin >> a.at(i).at(0) >> a.at(i).at(1);
    }
    
    int count = 0;
    for(int i = 0; i < m; i++){
        if(h.at(a.at(i).at(0) - 1) == h.at(a.at(i).at(1) - 1) ){
            check.at(a.at(i).at(1) - 1) = 1;
            check.at(a.at(i).at(0) - 1) = 1;
        }else if(h.at(a.at(i).at(0) - 1) > h.at(a.at(i).at(1) - 1) ){
            check.at(a.at(i).at(1) - 1) = 1;
        }else{
            check.at(a.at(i).at(0) - 1) = 1;
        }
    }

    for(int i = 0; i < n; i++){
        //cout << check.at(i) << endl;
        if(check.at(i) == 0){
            count++;
        }
    }
    cout << count << endl;
    //vector<vector<int>> a(m, vector<int>(2));
}

Measured memory_bytes: 9596
N, K = map(int, input().split())

A = [0] * N

for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(len(a)):
        A[a[j]-1] += 1

ans = 0
for i in range(len(A)):
    if A[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int S=0;
  cin>>N;
  vector<int> V(N);
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
  cin>>V.at(i);}
  
  for (int i = 0; i < N; i++) {
  cin>>C.at(i);}
  
  for(int i=0; i<N; i++){
    if(V.at(i)>C.at(i)){
      S+=V.at(i)-C.at(i);
    }
  }
    cout<<S<<endl;
}


Measured memory_bytes: 256
A = int(input())+1
B = int(input())+1
C = int(input())+1
X = int(input())
Y = []
for i in range(A):
  for j in range(B):
    for k in range(C):
      Y.append(500 *i + 100 *j + 50 *k)
print(Y.count(X))

Measured memory_bytes: 8368
#include <bits/stdc++.h>
using namespace std;
long long n, x, k, c, m, mm, i, j, b[100005], f[100005], g[100005];
char s[100005];
int main(){
	scanf("%s", s);
	for(i=0; i<=2; i++){	
		printf("%c", s[i]);
	}
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
int Y[3][13]={{0, 1,1,1,2},{0,0,0,1,1,1,2,2,2},{0, 1,1,1, 2, 2,2,2,2, 3,3,3,4}};
int X[3][13]={{0,-1,0,1,0},{0,1,2,0,1,2,0,1,2},{0,-1,0,1,-2,-1,0,1,2,-1,0,1,0}};
int d[14][14]={0};
int s[]={5,9,13};
int x[12],y[12],p[12],r=0;
int f(int h,int n){
  int i,j,k,c;
  if(n==0){
    for(i=2;i<12;i++){
      for(j=2;j<12;j++){
	if(d[i][j])return 0;
      }
    }
    return 1;
  }
  for(i=h;i<12;i++){
    for(j=2;j<12;j++){
      if(d[i][j]==0)continue;
      for(k=2;k>-1;k--){
	for(c=0;c<s[k];c++){
	  if(d[i+Y[k][c]][j+X[k][c]]==0)break;
	}
	if(c==s[k]){
	  for(c=0;c<s[k];c++)d[i+Y[k][c]][j+X[k][c]]--;
	  y[r]=i+k/2-1;
	  x[r]=j+k%2-2;
	  p[r++]=k+1;
	  if(f(i,n-1))return 1;
	  for(c=0;c<s[k];c++)d[i+Y[k][c]][j+X[k][c]]++;
	  r--;
	}
      }
      return 0;
    }
  }
  return 0;
}    
int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=2;i<12;i++){
    for(j=2;j<12;j++)scanf("%d",&d[i][j]);
  }
  f(2,n);
  for(i=0;i<n;i++)printf("%d %d %d\n",x[i],y[i],p[i]);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int t,a;cin>>t>>a;
  vector<double>h(n);
  rep(i,n)cin>>h[i];
  int res=0;
  double min=1e9+7;
  rep(i,n)
  {
    if(chmin(min,abs(a-(t-h[i]*0.006))))res=i;
  }
  cout<<res+1<<endl;
  return 0;

}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 5*100*1000;

int tab[MAXN + 3];
int cnt[MAXN + 3];

int main(){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &tab[i]);
        cnt[tab[i]]++;
    }
    
    LL ans = 0;
    for(int i=1; i<=n; i++){
        ans += (LL)cnt[i]*(cnt[i]-1)/2; 
    }
    
    for(int i=0; i<n; i++){
        LL sub = (LL)cnt[tab[i]]*(cnt[tab[i]]-1)/2;
        LL add = (LL)max(0, cnt[tab[i]]-1)*max(0, cnt[tab[i]]-2)/2;
        printf("%lld\n", ans - sub + add);
    }
    
return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  bool ans=0;
  string s;
  cin >>s;

  rep(i,3){
    if(s[i]==s[i+1])  ans=1;
  }
  if(ans) cout << "Bad" << endl;
  else  cout << "Good" << endl; 
}


Measured memory_bytes: 256
/*
abc 158 c
*/
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N, A, B, ans = -1, a, b;
    cin >> A >> B;
    a = (int) A / 0.08;
    b = (int) B / 0.1;
    
    REP(i,1001){
        if( (int)( (i+1) * 0.08 ) == A && (int)( (i+1) * 0.1 ) == B){
            cout << i+1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

int main () {
  int A, B, C, D; cin >> A >> B >> C >> D;
  
  if (A+B > C+D) cout << "Left" << endl;
  else if (A+B == C+D) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}


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

int main () {
  int exam[3],midterm_exam=0,terminal_exam=0,reexam=0,score,i=0;
  while (i != 3) {
    score = 0;
	i = 0;
    cin >> midterm_exam >> terminal_exam >> reexam;
    if (midterm_exam != -1) {
      score = score + midterm_exam;
	} else ++i;


    if (terminal_exam != -1) {
      score = score + terminal_exam;
	} else {
	if (i == 1 && reexam == -1) break;
    ++i;
	}


    if (i == 0) {
	  if (score >= 80)
	    cout << "A" << endl;

	  if (score >= 65 && score < 80)
	    cout << "B" << endl;
	    if (score >= 50 && score < 65)
	      cout << "C" << endl;

        if (score >= 30 && score < 50 && reexam < 50) {
	        cout << "D" << endl;
		} else if (score >= 30 && score < 50 && reexam >= 50) {
	        cout << "C" << endl;
	    }
	}

    if (score < 30 || i > 0) {
	  cout << "F" << endl;
    }

  }
  return 0;
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec) {
        is >> x;
    }
    return is;
}

#define MOD 1000000007
ll dp[100010][13];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;

    // REP(i, 100010) REP(j, 13) {
    //     // if (i == 0)
    //     dp[i][j] = -1;
    // }

    if(s[s.size() - 1] == '?') {
        REP(i, 10) { dp[0][i] = 1; }
    } else {
        dp[0][s[s.size() - 1] - '0'] = 1;
        // cout << s[0] - '0' << endl;
    }

    ll digit = 1;
    FOR(i, 1, s.size()) {
        digit = digit * 10 % 13;
        if(s[s.size() - i - 1] == '?') {
            REP(j, 13) {
                REP(k, 10) {
                    ll p = (k * digit + j) % 13;
                    dp[i][p] += dp[i - 1][j];
                    dp[i][p] %= MOD;
                }
            }
        } else {
            REP(j, 13) {
                ll p = s[s.size() - i - 1] - '0';
                p = (p * digit + j) % 13;
                dp[i][p] += dp[i - 1][j];
                dp[i][p] %= MOD;
            }
        }
    }

    cout << dp[s.size() - 1][5] << endl;

    return 0;
}


Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

ll N;

vvl mul(vvl A, vvl B){
    vector<vector<ll>> rec(N, vector<ll>(N, 0));
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++){
            ll sum=0;
            for(ll k=0;k<N;k++){
                sum+=A[i][k]*B[k][j];
                sum%=MOD;
            }
            rec[i][j]=sum;
        }
    return rec;
}

vvl pow(vvl A, ll K){
    //単位行列を作成
    vector<vector<ll>> rec(N, vector<ll>(N, 0));
    for(ll i=0;i<N;i++)rec[i][i]=1;

    for(ll i=0;i<64;i++){
        if(K&(1LL<<i))rec=mul(rec,A);
        A=mul(A,A);
    }
    
    return rec;
}

int main(){
    cin >> N;
    ll K;
    cin >> K;
    vector<vector<ll>> A(N, vector<ll>(N, 0));
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)cin>>A[i][j];
    
    vvl ans=pow(A,K);
    ll Ans=0;
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++){
            Ans+=ans[i][j];
            Ans%=MOD;
        }

    print(Ans);
    
    


    return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int p[200010];

void swap(int *a, int i, int x) {
  int tmp1 = a[i], tmp2 = p[x];
  a[p[x]] = a[i];
  a[i] = x;
  p[x] = i;
  p[tmp1] = tmp2;
  return;
}
  


int
main(int argc, char *argv[])
{
  int n, x;
  scanf("%d %d", &n, &x);
  if (x == 1 || x == 2 * n - 1) printf("No\n");
  else if (n == 2) {
    printf("Yes\n");
    for (int i = 0; i < 2 * n - 1; i++) printf("%d\n", i + 1);
  } else {
    int a[200100];
    for (int i = 0; i < 2 * n - 1; i++) {
      a[i] = i + 1;
      p[i + 1] = i;
    }
    swap(a, n - 1, x);
    swap(a, n, x + 1);
    swap(a, n - 2, x - 1);
   
    if (x + 2 <= 2 * n - 1) {
      swap(a, n - 3, x + 2);
    } else {
      swap(a, n + 1, x - 2);
    }
    printf("Yes\n");
    rep(i, 2 * n - 1) printf("%d\n", a[i]);
  }

  return 0;
}
    
  


Measured memory_bytes: 2944
#include<iostream>
#include<cmath>
#include<cfenv>

using namespace std;
 
int main(){
    int d[5]; 
    for(int i = 0; i < 5; i++) cin >> d[i];

    int min = 10;
    int idx = 0;
    int f = 0;

    for(int i = 0; i < 5; i++){
        f = d[i] % 10;
        if( min > f && f != 0 ){
            min = f;
            idx = i;
        }
    }

    int sum = 0;
    for(int i = 0; i < 5; i++){
        if( i != idx ){
            if( (d[i] % 10) != 0){
                sum += ((d[i]/10) + 1) * 10;
            }else{
                sum += d[i];
            }
        }
    }
    sum += d[idx];

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
i = int(input())

data = []

def chg(x,y):
	print("hoge")
	if x[0] == y[0]:
		return x[1] > y[1]
	else:
		return x[0] > y[0]

for i in range(i):
	ip = input().split(' ')
	dt = [ip[0],int(ip[1])]
	data.append(dt)


ls = sorted(data,key=itemgetter(1),reverse=True)
ls = sorted(ls,key=itemgetter(0))

for i in ls:
	cnt = 0
	for j in data:
		if i == j:
			break
		cnt += 1
	
	print(cnt + 1)

Measured memory_bytes: 3064
n, c, k = map(int, input().split())
if n == 1:
    print(1)
else:
    t = []
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ini = t[0]
    count = 1
    ans = 1
    for i in t[1:]:
        if count < c and ini + k >= i:
            count += 1
        else:
            ans += 1
            ini = i
            count = 1
    print(ans)

Measured memory_bytes: 7888