akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b-a-b+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)

int main()
{
    int N;
    cin >> N;
    long long ret = 0;
    FOR(i, 1, N + 1) ret += 1LL * i * (N / i) * (N / i + 1) / 2;
    cout << ret << '\n';
}


Measured memory_bytes: 3196
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  var A = input[0];
  var B = input[1];
  if(A % B != 0){
     console.log(A);
  }else{
   	console.log(-1); 
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);

        int min = Integer.MAX_VALUE;
        for (int i = 0; i <= n - k; i++) {
            int tmin = arr[i];
            int tmax = arr[i+k-1];
            min = Math.min(min, tmax-tmin);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 52120
def main():
	n = int(input())

	dp=[0 for i in range(n+1)]
	dp[0]=2
	dp[1]=1
	for i in range(2,n+1):
		dp[i] = dp[i-1]+dp[i-2]
	print(dp[n])
	
if __name__ == "__main__": main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll ch[100010];
int main() {
	ll n,k,R,S,P;
	cin>>n>>k>>R>>S>>P;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++){
		char now;
		cin>>now;
		if(i>=k){
			if(s[i]==s[i-k]&&ch[i-k]!=0){
				continue;
			}
		}
		if(s[i]=='s'){
			ch[i]=R;
		}
		else if(s[i]=='p'){
			ch[i]=S;
		}
		else{
			ch[i]=P;
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		cnt+=ch[i];
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4500
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    val N = reader.nextInt()
    val numList = mutableListOf<Int>()
    repeat(N){
        numList.add(reader.nextInt())
    }
    val stateList = mutableListOf<MutableList<Int>>()
    var count = 0
    repeat(N){
        val size = stateList.size
        val currentNum = numList[it]
        
        stateList.add(mutableListOf(currentNum))
        for (i in 0 until size) {
            val oldItems = stateList[i]
            val newItems = mutableListOf<Int>()
            newItems.addAll(oldItems)
            
            var findFlg = false
            for(j in 0 until newItems.size){
                findFlg =  currentNum == newItems[j]
                if(findFlg){
                    break
                }
            }
            if (!findFlg) {
                newItems.add(currentNum)
                if (newItems.size < 3) {
                    stateList.add(newItems)
                } else {
                    if (newItems[0] + newItems[1] > newItems[2] &&
                        newItems[0] + newItems[2] > newItems[1] &&
                        newItems[1] + newItems[2] > newItems[0]
                    ) {
                        count++
                    }

                }
            }
        }
    }
    println(count)
}

Measured memory_bytes: 58284
#include <stdio.h>

#define MOD 1000000007

typedef long long ll;

ll fct[500005] = { 1, 1 }, inv[500005] = { 1, 1 }, fiv[500005] = { 1, 1 };

ll combination(ll n, ll r)
{
	return fct[n] * fiv[r] % MOD * fiv[n - r] % MOD;
}

ll permutation(ll n, ll r)
{
	return fct[n] * fiv[n - r] % MOD;
}

int main(void)
{
	ll n, m, i, ans = 0;
	
	scanf("%lld %lld", &n, &m);

	for (i = 2; i <= m; i++)
	{
		fct[i] = fct[i - 1] * i % MOD;
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fiv[i] = fiv[i - 1] * inv[i] % MOD;
	}

	for (i = 0; i <= n; i++)
	{
		ll p = combination(n, i) * permutation(m, i) % MOD * permutation(m - i, n - i) % MOD * permutation(m - i, n - i) % MOD;
		
		if (i % 2)
			ans = (ans - p + MOD * (ll)1e8) % MOD;
		else
			ans = (ans + p) % MOD;
	}

	printf("%lld", ans);
	return 0;
}

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

int main()
{
  int a,b;
  char c;
  while(1){
    cin>>a>>c>>b;
    if(c=='?')break;
    switch(c){
    case '+':
      cout<<a+b<<endl;
      break;
    case '-':
      cout<<a-b<<endl;
      break;
    case '*':
      cout<<a*b<<endl;
      break;
    default:
      cout<<a/b<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll q[N],st[N],cnt[N],a[N],s[N],x;int top,n,m;
void ins(R ll x,R ll p,R int pos){
	R int k;
	while(x>=st[1]){
		k=lower_bound(st+1,st+1+pos,x+1)-st-1;
		s[k]+=x/st[k]*p,x%=st[k],pos=k-1;
	}
	a[x]+=p;
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m),top=0;
	st[++top]=n;
	fp(i,1,m){
		scanf("%lld",&x);
		while(top&&x<=st[top])--top;
		st[++top]=x;
	}
	fp(i,1,top-1)cnt[i]=st[i+1]/st[i];
	cnt[top]=cnt[top+1]=1;
	fd(i,top,2)cnt[i]=cnt[i]*cnt[i+1]+s[i],ins(st[i]%st[i-1],cnt[i],i-1);
	cnt[1]=cnt[1]*cnt[2]+s[1];
	fd(i,n,1)a[i]+=a[i+1];
	fp(i,1,n)printf("%lld\n",(i<=st[1]?cnt[1]+a[i]:0));
	return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct node{
  int key;
  struct node *next,*prev;
}Node;

typedef Node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil=(NodePointer)malloc(sizeof(struct node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  NodePointer cur=nil->next;
  int inf=0;
  while(1){
    if(cur==nil)break;
    if(inf==1)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
    inf=1;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;

  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s",com);

    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F')deleteFirst();
	else if(com[6]=='L')deleteLast();
      }
      else{
	scanf("%d",&key);
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}



Measured memory_bytes: 32956
from collections import deque
H,W = map(int,input().split())
A = [list(input()) for i in range(H)]

q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            q.append((i, j))
ans = -1

while len(q) != 0:
    ans += 1
    qq = []
    while len(q) != 0:
        t = q.popleft()
        i,j = t[0],t[1]
        if i > 0 and A[i-1][j] == '.':
            qq.append((i-1,j))
            A[i-1][j] = '#'
        if j > 0 and A[i][j-1] == '.':
            qq.append((i,j-1))
            A[i][j-1] = '#'
        if i < H-1 and A[i+1][j] == '.':
            qq.append((i+1,j))
            A[i+1][j] = '#'
        if j < W-1 and A[i][j+1] == '.':
            qq.append((i,j+1))
            A[i][j+1] = '#'
    q = deque(qq)

print(ans)


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

long long int n;

int main(){
  cin >> n;
  long long int num = sqrt(n);
  long long int i = 0, j = 0;
  for(long long int k = 2; k <= num; k++){
    if(n % k != 0){
      continue;
    }
    i = k;
    j = n / i;
  }
  if(i == 0){
    cout << n - 1 << endl;
  }else{
    cout << i + j - 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 15000
using namespace std;

template <typename T>
void print(T x){cout<<x<<"\n";}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<"\n";}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<"\n";}

int mincost(int n)
{
    int dp[n][3],a[n],b[n],c[n];
    for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];

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

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

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

int main()
{
    io;
    ll test_case;
    //cin>>test_case;
    test_case=1;
    while(test_case--)
    {
        ll n,k;
        cin>>n;
        cout<<mincost(n)<<"\n";
    }   
}

Measured memory_bytes: 5936
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int n;
	cin>>n;
	int dp[n+1];
	int h[n+1];
	for(int i=1;i<=n;i++)
	cin>>h[i];
	dp[0]=0;
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
	cout<<dp[n];
}


Measured memory_bytes: 1024
//#define _USE_MATH_DEFINES

#include <iostream>
//#include <vector>
#include <algorithm>
//#include <numeric>
//#include <string>
//#include <array>
//#include <set>
//#include <sstream>
//#include <cstdio>
//#include <cmath>

using namespace std;

int main() {
	int K, S, cnt = 0, z_init = 0;
	scanf("%d %d", &K, &S);

	if (S > 2 * K) z_init = S - 2 * K;

	for (int z = z_init; z <= K; ++z) {
		if (S - z < 0) break;

		if (S - z > K) cnt += (2 * K - S + z + 1);
		else cnt += (S - z + 1);
	}
	printf("%d\n", cnt);

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){	
	int n;
	ll numbers[100001];

	cin>>n;
	REP(i,n) cin>>numbers[i];
	SORT(numbers,n);

	ll number=0,counter=0,result=0;
	REP(i,n){
		if(numbers[i]!=number){
			if(counter%2==1) result++;
			number=numbers[i];
			counter=1;
		}else{
			counter++;
		}
	}
	if(counter%2==1) result++;
	cout<<result<<endl;

	return 0;
}



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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]\n";}

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

	ll n; cin >> n;
	ll sum = 0;
	vector<ll> a(n+1); FOR (i, 1, n) cin >> a[i], sum += a[i];
	
	if (sum % (n*(n+1)/2)) {
		cout << "NO\n";
		return 0;
	}

	ll no = sum / (n*(n+1)/2);

	if (n == 1) {
		cout << "YES\n";
		return 0;
	}
	vector<ll> st(n + 1);

	FOR (i, 1, n) {
		int nxt = i == n ? 1 : i + 1;
		ll times = a[i] - a[nxt] + no;
		if (times < 0 or times % n) {
			cout << "NO\n";
			return 0;
		}
		st[nxt]+= times / n;
	}
	
	cout << "YES\n";
	return 0;
}


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


int main() {
    int m,f,r;
    vector<char> grade;
    while(1){
        cin >> m >> f >> r;
        if(m+f+r == -3)break;
        if(m == -1 or f == -1)grade.push_back('F');
        else if (m+f >= 80)
        {
            grade.push_back('A');
        }else if (m+f >= 65)
        {
            grade.push_back('B');
        }else if (m+f >= 50 || (m+f>=30 && r >= 50))
        {
            grade.push_back('C');
        }else if (m+f>=30)
        {
            grade.push_back('D');
        }else{
            grade.push_back('F');
        }
    }
    rep(i,grade.size())cout << grade.at(i) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3168
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int ans=1;
		for(int i=0;i<n;i++){
			int buf=ans*2;
			int buf2=ans+k;
			ans=(buf<buf2)?buf:buf2;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
#define ll long long

void solve(){
    string s;
    cin>>s;
    string a=s;
    int len=s.length();
    reverse(a.begin(),a.end());
    string x(s.begin(),s.begin()+(len-1)/2);
    string y(s.begin()+(len+3)/2-1,s.end());
    string b=x,c=y;
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    if(s==a&&b==x&&y==c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main(){
    solve();
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		boolean[] prime = new boolean[300001];
		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;
		for (int i = 2; i < prime.length; ++i) {
			if (prime[i]) {
				for (long j = (long) i * i; j < prime.length; j += i) {
					prime[(int) j] = false;
				}
			}
		}
		int[] count = new int[prime.length];
		for (int i = 1; i < count.length; ++i) {
			count[i] = count[i - 1] + (prime[i] ? 1 : 0);
		}
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			System.out.println(count[2 * N] - count[N]);
		}
	}

}

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

int main() {
  
  string s;
  cin >> s;
  
  int n = s.size() - 2;
  int m = 999;
  REP(i,n) {
    int x = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
    m = min(m,abs(753-x));
  }

  cout << m << endl;

}

Measured memory_bytes: 3636
n,m = map(int,input().split())
a = list(map(int,input().split()))

boad = sum(a) * 1/(4*m)
a.sort(reverse=True)
count = 0
for i,a_ in enumerate(a):
    if a_ >= boad:
        count += 1
    if count == m:
        break

if count == m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int a, b, c;
  int x;
  scanf("%d\n%d\n%d\n%d", &a, &b, &c, &x);
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
	if(500 * i + 100 * j + 50 * k == x) ans++;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
c = []
for i in range(3):
    t = list(map(int, input().split()))
    c.append(t)
for i in range(1,3):
    if not (c[i][0] - c[0][0] == c[i][1] - c[0][1] == c[i][2] - c[0][2]):
        print('No')
        exit()
print('Yes')


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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int mincst = c * max(x, y) * 2;
    for (int i=0; i<=100000; i++) {
        int cst = i * c * 2 + max(0, x-i) * a + max(0, y-i) * b;
        mincst = min(cst, mincst);
    }

    cout << mincst << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long dp[102][11][1002];
int main(){
  int N,S;
  while(cin>>N>>S&&(N!=0)){
    for(int i=101;i>=0;i--){
      for(int j=0;j<=N;j++){
        for(int k=0;k<=S;k++){
          long long res=0;
          if(i==101)res=(j==0&&k==0);
          else{
            res+=dp[i+1][j][k];
            if(j-1>=0&&k-i>=0)res+=dp[i+1][j-1][k-i];
          }
          dp[i][j][k]=res;
        }
      }
    }
    cout<<dp[0][N][S]<<endl;
  }
  return 0;
}

Measured memory_bytes: 9796
#include<stdio.h>
int d[11];
int N=0;
void f(int B,int C,int n,int j){
	if(n>9)return ;
	if(j){if(B>d[n])return;B=d[n];}
	else {if(C>d[n])return;C=d[n];}
	if(n>N)N=n;
	f(B,C,++n,0);
	n--;
	f(B,C,++n,1);
}
int main(){
	int n,i,j;
	scanf("%d",&n);
	for(j=0;j<n;j++){
		N=0;
		for(i=0;i<10;i++)scanf("%d",&d[i]);
		f(0,0,0,0);
		if(N!=9){N=0;f(0,0,0,1);}
		if(N==9)printf("YES\n");
		else printf("NO\n");
	}exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
const int N = 105;
int x[N];
int main()
{
	int n;
	scanf("%d", &n);

	int c1 = 0;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &x[i]);
		c1 += x[i];
	}

	int c2 = c1;
	c2 /= n;
	c1 = ceil(c1 * 1.0 / n);

	int res = 0, res1 = 0;

	for (int i = 1; i <= n; ++i)
	{
		res += (x[i] - c1) * (x[i] - c1);
		res1 += (x[i] - c2) * (x[i] - c2);
	}

	printf("%d\n", min(res, res1));


	return 0;
}

Measured memory_bytes: 256
N= int(input())
 
N1=N%10
 
if N1==2:
	print("hon")
elif N1==4:
	print("hon")
elif N1==5:
	print("hon")
elif N1==7:
	print("hon")
elif N1==9:
	print("hon")
elif N1==0:
	print("pon")
elif N1==1:
	print("pon")
elif N1==6:
	print("pon")
elif N1==8:
	print("pon")
else:
  	print("bon")


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int const inf = numeric_limits<int>::max();

template<class T>
struct SegmentTree {
    int n;
    vector<T> dat;
    SegmentTree(int n_ = 0) : n(n_){
        n = 1;
        while(n < n_) n <<= 1;
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(r <= l || w == 0) return inf;
        if(l + w == r) return dat[v];
        return min(query(v*2, w/2, l, min(r, w/2)),
                   query(v*2+1, w/2, max(0, l-w/2), r-w/2));
    }
    void update(int i, T x){
        i += n;
        dat[i] = x;
        for(; i!=1; i/=2) dat[i/2] = min(dat[i], dat[i^1]);
    }
    T query(int l, int r){
        return query(1,n,l,r);
    }
    size_t size() const {
        return n;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    while(cin >> n >> q){
        SegmentTree<int> st(n);
        while(q--){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                st.update(x,y);
            } else {
                cout << st.query(x,y+1) << '\n';
            }
        }
    }
}

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

ans = 0
for i in range(1, N+1):
    J = i
    t = 0
    while K > J:
        J = J * 2
        t += 1
        
    ans += (1 / N) * 0.5**t 
    
print(ans)    
    

Measured memory_bytes: 2940
import java.util.*;
import java.util.Scanner;
import java.lang.*;

public class Main
{
  public static void main(String args[])
  {
    try
    {
    int n,rem=0,res=0,a=0,r=0,w=0,t=0;
    Scanner s=new Scanner(System.in);
    n=s.nextInt();
    String str;  
    for(int i=0;i<n;i++)  
    {
      str=s.next();
      if(str.charAt(0)=='A') 
      {
        a++;
      }
      else if(str.charAt(0)=='W') 
      {
        w++;
      }
      else if(str.charAt(0)=='T') 
      {
        t++;
      }
      else if(str.charAt(0)=='R') 
      {
        r++;
      }
      else
      {
        continue;
      }
    }
      
      System.out.println("AC x "+a);
      System.out.println("WA x "+w);
	 System.out.println("TLE x "+t);
	 System.out.println("RE x "+r);


      
      
      
      
      
   
  //    System.out.println(res);
    }
    catch(Exception e)
    {
      return ;
    }
  }
}
      
   
    

Measured memory_bytes: 58640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
  
int num,stack[200];
 
 
int pop(){
  num--;
  return stack[num+1];
}
 
 
void push(int n){
  stack[++num] = n;
}
 
 
int main(void){
  int a,b;
  num = 0;
  char c[100];
  while(scanf("%s",c)!=EOF){
    if( c[0] == '+' ){
      a = pop();
      b = pop();
      push( a + b );
    }
    else if( c[0] == '-' ){
      b = pop();
      a = pop();
      push( a - b);
    }
    else if( c[0] == '*' ){
      a = pop();
      b = pop();
      push( a * b );
    }
    else{
      push(atoi(c));  //文字列の数値をint型の数値に変換する
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y){ if (x > y){ return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y){ return (x / gcd(x, y) * y); }

using pll = pair<long, long>;
using W_graph = vector<vector<pll>>; // (next , cost)

void Dijkstra(W_graph &g, long s, vector<long> &res){
	vector<long> dist(g.size(), INT_MAX);
	priority_queue<pll, vector<pll>, greater<pll>> que;
	long V = g.size() + 1;
	dist[s] = 0;
	que.push(make_pair(dist[s], s));

	while (!que.empty()){
		long cost, now;
		tie(cost, now) = que.top(); que.pop();

		if (dist[now] < cost) continue;
		dist[now] = cost; V--;
		if (V == 0) break;

		for (auto e : g[now]){
			long path, next;
			tie(next, path) = e;
			que.push(make_pair(cost + path, next));
		}
	}

	res = dist;
	return;
}

void Bellman_Ford(W_graph &g, long s, vector<long> &res, bool &b){
	vector<long> dist(g.size(), INT_MAX);
	dist[s] = 0;
	long V = g.size();

	for (int i = 0; i < V; i++){
		bool change = false;
		for (int j = 0; j < V; j++){
			for (auto e : g[j]){
				long path, next;
				tie(next, path) = e;
				if (dist[next] > dist[j] + path){
					dist[next] = dist[j] + path;
					change = true;
				}
			}
		}

		if (i == V - 1) b = change;
	}

	res = dist;
	return;
}

void Warshall_Froyd(W_graph &g, vector<vector<long>> &res){
	long V = g.size();
	vector<vector<long>> dist(V, vector<long>(V , INT_MAX));

	for (int i = 0; i < V; i++) dist[i][i] = 0;
	for (int i = 0; i < V; i++) for (auto e : g[i]) dist[i][e.first] = e.second;

	for (int i = 0; i < V; i++){
		for (int j = 0; j < V; j++){
			for (int k = 0; k < V; k++){
				dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
			}
		}
	}

	res = dist;
	return;
}

int main(){
	long N, M, L; cin >> N >> M >> L;

	W_graph G(N) , G2(N);

	for (int i = 0; i < M; i++){
		long a, b, c; cin >> a >> b >> c; a--; b--;
		G[a].push_back(make_pair(b, c));
		G[b].push_back(make_pair(a, c));
	}

	vector<vector<long>> path, path2;

	Warshall_Froyd(G, path);

	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++){
		if (path[i][j] <= L) G2[i].push_back(make_pair(j, 1));
	}

	Warshall_Froyd(G2, path2);

	long Q; cin >> Q;

	for (int i = 0; i < Q; i++){
		long s, t; cin >> s >> t; s--; t--;
        if (path2[s][t] == INT_MAX) cout << -1 << endl;
		else cout << path2[s][t] - 1 << endl;
	}
}

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

int main() {
  string n;cin>>n;
  for(int i=0;i < 3;i++){
    if(n[i]=='1') cout << 9;
    else if(n[i]=='9') cout << 1;
    else cout << n[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  int n;
  cin >> n;
  int ans = (n - 2) * 180;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
//using vi = vector<int>;
//using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
//using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin  >> n;
	
	vector<int> data(n);

	rep(i,0,n){
		
		cin >> data[i];

	}

	int MAX = data[0];
	int MIN = data[0];

	rep(i,0,n){
		MAX = max(MAX,data[i]);
		MIN = min(MIN,data[i]);
	}
	
	cout << MAX - MIN << endl;
	
	//system("pause");



	


}
	


Measured memory_bytes: 256
import itertools

L, R= map(int, input().rstrip().split())

min_modulo = 2019
if R - L >= 2019:
    min_modulo = 0
else:
    num_list =\
        list(itertools.combinations(list(range(L, R + 1)), 2))
    for x, y in num_list:
        modulo = (x * y) % 2019
        if modulo == 0:
            min_modulo = 0
            break
        else:
            if modulo < min_modulo:
                min_modulo = modulo

print(min_modulo)


Measured memory_bytes: 148280
#include<iostream>
using namespace std ;
int main()
{
    int n,s,sum=0,f=1,co=0,sum1=0;
    cin >> n ;
    s=n;
    while(s>9)
    {
        s/=10;
        f++;
    }
    //cout << f << endl;
    for(int i=1;i<=f;i++)
    {
        sum=9+10*sum;
        if(i==f && i%2==1)
        {
           co+=(n-sum1);
        }
        else if (i%2==1)
        {
            co+=(sum-sum1);
        }
        sum1=sum;
    }
    cout << co << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=3e5+7,inf=0x3f3f3f3f;
char ib[N*50],*ip=ib;
int _(){
	int x=0;
	while(*ip<48)++ip;
	while(*ip>47)x=x*10+*ip++-48;
	return x;
}
void maxs(int&a,int b){if(a<b)a=b;}
struct pos{
	int x,y;
	bool operator<(const pos&w)const{return x<w.x;}
}ps[N];
int ss1[N],ss2[N],sp1=0,sp2=0;
int xm,ym,m,n,ans=0,b1[N],b2[N],t1[1<<20|111],t2[1<<20|111],mx;
void ins(int*f,int x,int y){
	for(++x;x<N;x+=x&-x)maxs(f[x],y);
}
int gmx(int*f,int x){
	int v=-inf;
	for(++x;x;x-=x&-x)maxs(v,f[x]);
	return v;
}
void insx(int*f,int x,int y){
	for(x+=mx+1;x;x>>=1)maxs(f[x],y);
}
int gmx(int*f,int l,int r){
	int v=-inf;
	for(l+=mx,r+=mx+2;r-l>1;l>>=1,r>>=1){
		if(~l&1)maxs(v,f[l+1]);
		if(r&1)maxs(v,f[r-1]);
	}
	return v;
}
struct itv{
	int l,r,v;
	bool operator<(const itv&w)const{return r>w.r;}
	void cal(){
		int L=ps[l].x,R=ps[r].x;
		if(v<=m){
			maxs(ans,gmx(b1,l)-v+R-L);
			maxs(ans,gmx(t1,l,r)-v+R);
			ins(b2,l,-v);
			insx(t2,l,-v-L);
		}else{
			maxs(ans,gmx(b2,l)+v+R-L);
			maxs(ans,gmx(t2,l,r)+v+R);
			ins(b1,l,v);
			insx(t1,l,v-L);
		}
	}
}is[N];
#define clr(a) memset(a,-0x3f,sizeof(a))
#define push(ss,sp,op,y,lr,i) do{for(;sp&&ps[ss[sp]].y op y;is[ss[sp--]].lr=i);ss[++sp]=i;}while(0)
void cal2(){
	for(int i=1;i<=n;++i){
		int y=is[i].v=ps[i].y;
		push(ss1,sp1,>,y,r,i);
	}
	for(;sp1;is[ss1[sp1--]].r=n+1);
	for(int i=n;i>=1;--i){
		int y=ps[i].y;
		push(ss1,sp1,>=,y,l,i);
	}
	for(;sp1;is[ss1[sp1--]].l=0);
	for(int i=1;i<=n;++i)maxs(ans,ps[is[i].r].x-ps[is[i].l].x+is[i].v);
}
void cal(){
	m=ym/2;
	std::sort(ps+1,ps+n+1);
	ps[0].x=0,ps[n+1].x=xm;
	for(int i=0;i<=n;++i)maxs(ans,ps[i+1].x-ps[i].x+ym);
	for(int i=1;i<=n;++i){
		int y=is[i].v=ps[i].y;
		if(y<=m)push(ss1,sp1,<,y,r,i);
		else push(ss2,sp2,>,y,r,i);
	}
	for(;sp1;is[ss1[sp1--]].r=n+1);
	for(;sp2;is[ss2[sp2--]].r=n+1);
	for(int i=n;i>=1;--i){
		int y=ps[i].y;
		if(y<=m)push(ss1,sp1,<=,y,l,i);
		else push(ss2,sp2,>=,y,l,i);
	}
	for(;sp1;is[ss1[sp1--]].l=0);
	for(;sp2;is[ss2[sp2--]].l=0);
	std::sort(is+1,is+n+1);
	clr(b1),clr(b2),clr(t1),clr(t2);
	for(int i=1;i<=n;++i)is[i].cal();
	cal2();
	for(int i=1;i<=n;++i)ps[i].y=ym-ps[i].y;
	cal2();
}
int main(){
	fread(ib,1,sizeof(ib),stdin);
	xm=_(),ym=_(),n=_();
	for(mx=2;mx<n+5;mx<<=1);
	maxs(ans,xm+1);
	maxs(ans,ym+1);
	for(int i=1;i<=n;++i){
		ps[i].x=_();
		ps[i].y=_();
	}
	cal();
	std::swap(xm,ym);
	for(int i=1;i<=n;++i)std::swap(ps[i].x,ps[i].y);
	cal();
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 24832
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

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

	for i := 0; i < n; i++ {
		a[i] = nextInt() - 1
	}

	res := 0
	for i := 0; i < n; i++ {
		if i == a[a[i]] {
			res++
		}
	}

	fmt.Println(res / 2)
}


Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main () {
    input! {
        s: chars,
    }
    let mut cnt = 0;
    for c in s {
        if c == '1' {
            cnt+=1;
        }
    }
    println!("{}", cnt);
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
 ll n,sum=0,cp;
 cin>>n;
 ll arr[n];
 for(ll i=0;i<n;i++)
    cin>>arr[i];
for(ll i=1;i<n;i++){
    if(arr[i]<arr[i-1]){
        cp=arr[i-1]-arr[i];sum+=cp;arr[i]+=cp;
    }
}cout<<sum;
return 0;
}

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

const int MAX_N = 2000005;
const long long MOD = 1000000007;

int n;

long long ans;

int arr[MAX_N];

std::unordered_map <int, int> mp;

void update(int val) {
  int d, exp;
  d = 2;
  while (d * d <= val) {
    exp = 0;
    while (val % d == 0) {
      ++exp;
      val /= d;
    }
    if (exp > 0) {
      mp[d] = std::max(mp[d], exp);
    }
    d += 2 - (d == 2);
  }
  if (val > 1) {
    mp[val] = std::max(mp[val], 1);
  }
}

int get_times(int n, int d) {
  int cnt;
  cnt = 0;
  while (n % d == 0) {
    ++cnt;
    n /= d;
  }
  return cnt;
}

long long lgpow(long long base, long long exp) {
  long long ret;
  ret = 1;
  while (exp > 0) {
    if ((exp & 1) > 0) {
      ret = (ret * base) % MOD;
    }
    base = (base * base) % MOD;
    exp >>= 1;
  }
  return ret;
}

void query(int val) {
  long long sum, pow;
  int e;
  sum = pow = 1;
  for (auto div : mp) {
    e = get_times(val, div.first);
    if (e < div.second) {
      pow = lgpow(div.first, div.second - e);
      sum = (sum * pow) % MOD;
    }
  }
  ans = (ans + sum) % MOD;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  std::cin >> n;
  for (int i = 1; i <= n; ++i) {
    std::cin >> arr[i];
    update(arr[i]);
  }
  for (int i = 1; i <= n; ++i) {
    query(arr[i]);
  }
  std::cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
#define ll long long
using namespace std;

bool binary_searcha(ll key, ll n, ll box[]) {
	ll right, left, mid;
	right = 0;
	left = n;
	while (right < left) {
		mid = (right + left) / 2;
		if (box[mid] == key) {
			return true;
		}
		else if (box[mid] > key) {
			left = mid;
		}
		else {
			right = mid + 1;
		}
	}
	return false;
}

int main() {
	ll n, s[200000], q, t[100000], c = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> s[i];
	cin >> q;
	for (int i = 0; i < q; i++)cin >> t[i];
	
	for (int i = 0; i < q; i++) {
		if (binary_searcha(t[i], n, s) == true)c++;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
static const int INFTY = (1 << 21);
int main(){
    ll N, M, X;
    cin >> N >> M >> X;
    vl C(N), T(M);
    vector<vector<ll>> A(N, vector<ll>(M));
    for(int i = 0; i < N; i++){
        cin >> C.at(i);
        for(int j = 0; j < M; j++){
            cin >> A.at(i).at(j);
        }
    }
    ll fans = INFTY;
    for(int tmp = 0; tmp < (1 << 12); tmp++){
        bool a = 1;
        ll ans = 0;
        bitset<12> s(tmp);
        for(int i = 0; i < M; i++){
            T.at(i) = 0;
        }
        for(int i = 0; i < N; i++){
            if(s.test(i)){
                ans += C.at(i);
                for(int j = 0; j < M; j++){
                    T.at(j) += A.at(i).at(j);
                }
            }
        }     
        for(int i = 0; i < M; i++){
            if(T.at(i) < X){
                a = 0;
            }
        }
        if(a){
            fans  = min(ans, fans);
        }
    }
    if(fans == INFTY){
        cout << -1 << endl;
    }
    else{
        cout << fans << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int D = I.nextInt();
		int T = I.nextInt();
		int S = I.nextInt();
		long t = ceil(D,S);
		O.pln(t<=T?"Yes":"No");
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25612
#include "bits/stdc++.h"
#define BUGAVOID(x) x
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end());
#define mp make_pair
#define write(x) cout<<(x)<<endl
#ifdef LOCAL
#define debug(...) debug_vars(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
const int INF = 1 << 28;
const double EPS = 1e-8;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M;
set<int> parents[MAX];
vector<int> children[MAX];
int ans[MAX];

int main()
{
    cin >> N >> M;
    rep(i, N - 1 + M) {
        int a, b;
        cin >> a >> b;
        parents[b].insert(a);
        children[a].push_back(b);
    }

    rep(i, 1, N + 1) {
        // 根
        if (parents[i].size() == 0) {
            queue<int> next;
            next.push(i);
            while (!next.empty()) {
                int cur = next.front();
                next.pop();
                // ノードの子
                rep(j, children[cur].size()) {
                    int curc = children[cur][j];
                    if (parents[curc].size() != 1) {
                        parents[curc].erase(cur);
                    }
                    else {
                        next.push(curc);
                        ans[curc] = cur;
                    }
                }
            }
            ans[i] = 0;
            break;
        }
    }

    rep(i, 1, N + 1) {
        write(ans[i]);
    }
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll c[3][3];
  REP(i, 3) {
    REP(j, 3) { cin >> c[i][j]; }
  }
  ll a[3];
  bool f[3];

  REP(a1, 101) {
    REP(a2, 101) {
      REP(a3, 101) {
        REP(i, 3) { f[i] = false; }
        a[0] = a1;
        a[1] = a2;
        a[2] = a3;
        REP(j, 3) {
          ll tmp[3];
          REP(i, 3) { tmp[i] = c[i][j] - a[i]; }
          if (tmp[0] >= 0 && tmp[0] == tmp[1] && tmp[1] == tmp[2]) f[j] = true;
        }
        if (f[0] && f[1] && f[2]) {
          cout << "Yes";
          return 0;
        }
      }
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
a = list(map(int, input().split()))

ans = 0
now = -1
for e in a:
    if e == now:
        ans += 1
        now = -1
    else:
        now = e
print(ans)


Measured memory_bytes: 38384
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>
#include <stdlib.h>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  ll a;
  string b;
  cin >> a >> b;
  int temp = b[0] - '0';
  int temp2 = stoi(b.substr(2, 2));
  cout << a * temp + (a * temp2) / 100 << endl;
}


Measured memory_bytes: 3608
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b =	sc.nextInt();
        if(a==b) System.out.println("Draw");
	else if(a==1) System.out.println("Alice");
	else if(b==1) System.out.println("Bob");
        else if(a<b) System.out.println("Bob");
	else System.out.println("Alice");
    }
}

Measured memory_bytes: 23764
import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
 int x,i,tmp;
 StringBuilder sb = new StringBuilder();
 
 x = Integer.parseInt(br.readLine());
  for(i=1;i<=x;i++){
   if(i%3==0){
    sb.append(" "+i);
   }else{
   tmp=i;
    while(tmp!=0){
      if(tmp%10==3){    
       sb.append(" "+i);  
       break;    
      }
     tmp =tmp/10; 
    }
   }
  }
  System.out.println(sb); 
  
 }
}

Measured memory_bytes: 26152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class PriorityQueue<TKey>
{
    SortedDictionary<TKey, int> dict = new SortedDictionary<TKey, int>();
    int count = 0;

    public int Count
    {
        get
        {
            return count;
        }
    }

    public void Enqueue(TKey key)
    {
        if (!dict.ContainsKey(key))
        {
            dict[key] = 0;
        }
        dict[key]++;
        count++;
    }

    public TKey Dequeue()
    {
        var queue = dict.First();
        if (queue.Value <= 1)
        {
            dict.Remove(queue.Key);
        }
        else
        {
            dict[queue.Key]--;
        }
        count--;
        return queue.Key;
    }
}

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var queue = new PriorityQueue<long>();
        foreach (var a in A)
        {
            queue.Enqueue(-a);
        }

        for (int i = 0; i < M; i++)
        {
            var a = queue.Dequeue();
            queue.Enqueue(a / 2);
        }

        long sum = 0;
        while (queue.Count > 0)
        {
            sum -= queue.Dequeue();
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 35160
string = input()
l = 0
string1 = []
 
for i in string:
    if(i == '1'):
        string1.append('1')
        l += 1
    elif(i == '0'):
        string1.append('0')
        l += 1
    elif(i == 'B'):
        if(l > 0):
            string1.pop()
            l = l - 1
 
for i in string1:
    print(i, end = '')

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

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

  int n;
  vector<int> s;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    s.push_back(p);
  }

  int q;
  vector<int> t;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int p;
    cin >> p;
    t.push_back(p);
  }

  int c = 0;
  for (int i = 0; i < q; ++i) {
    int p = t[i];
    for (int j = 0; j < n; ++j) {
      if (p == s[j]) {
        ++c;
        break;
      }
    }
  }
  cout << c << endl;

  return 0;
}



Measured memory_bytes: 3248
import java.util.Scanner;
            import java.util.List;
            import java.util.ArrayList;
            import java.util.Collections;
             
            class Main {
              	public static void main(String args[]) {
                  
                  Scanner std = new Scanner(System.in);
                  List<Integer> list = new ArrayList<>();
                  
                  int N = std.nextInt();
                  for(int i = 0; i < N; i++) {
                  	int a = std.nextInt();
                    list.add(a);
                  }
                  
                  Integer x = Collections.max(list);
                  Integer y = Collections.min(list);
                    
                 System.out.println(x-y);
                }
            }

Measured memory_bytes: 21844