akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
int main(){
	scanf("%lld",&n);
	ll ans=0;
	ll M=0;
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		if(M<=t)ans++;
		M=max(M,t);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

// xのn乗のmodでのmodを返す

long long int modpow(long long int x,long long int n,long long int mod){
    long long int res = 1;
    while(n>0){
        if(n&1){
            res = (res*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return res;
}

long long int COM(long long int N, long long int R, long long int MOD){
    long long int ans = 1,div=1;
    for(long long int i=0;i<R;i++){
        ans *= N-i;
        div *= i+1;
        ans %= MOD;
        div %= MOD;
    }

    ans *= modpow(div,MOD-2,MOD);
    ans %= MOD;

    return ans;
}

long long int MOD = 1000000007;

int main(){
    long long int N,K;
    cin >> N >> K;
    for(long long int i=1;i<=K;i++){
        cout << COM(N-K+1,i,MOD)*COM(K-1,i-1,MOD)%MOD << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int H,W,K;
  cin >> H >> W >> K;
  char S[H][W];
  int ans[H][W]={};
  rep(i,H) cin >> S[i];
  int Kcount=1;
  rep(i,H) rep(j,W) if(S[i][j]=='#') ans[i][j]=Kcount++;
  rep(i,H) rep(j,W){
    if(S[i][j]=='#'){
      int number=ans[i][j];
      int up=j-1,dp=j+1;
      while(up>=0 && ans[i][up]==0) ans[i][up]=number,up--;
      while(dp<W && ans[i][dp]==0) ans[i][dp]=number,dp++;
    }
  }
  rep(k,300) rep(i,H) rep(j,W){
    if(ans[i][j]==0){
      if(i!=H-1) ans[i][j]=ans[i+1][j];
      else ans[i][j]=ans[i-1][j];
    }
  }
  rep(k,300) rep(i,H) rep(j,W){
    if(ans[i][j]==0){
      if(i!=0) ans[i][j]=ans[i-1][j];
      else ans[i][j]=ans[i+1][j];
    }
  }
  rep(i,H){
    rep(j,W) cout << ans[i][j] << " ";
    cout << endl;
  }
}

Measured memory_bytes: 1280
sub f{$M[$_]=1;$M[$_]||&f for@$_;unshift@s,$_;}$%=<>;/ /,push@{$`},$'+0for<>;$M[$_]||f for 1..$%;map{$\+=$-=($p=$p[$_])-$\;$p[$_]+=$-=$p+1-$p[$_]for@$_}@s;print

Measured memory_bytes: 111232
#include <bits/stdc++.h>
using namespace std; 
int main() {
  int n;
  cin >> n;
  int i,sum=0,maxi=0;
  vector<int> vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);
    maxi=max(maxi,vec.at(i));
    sum+=vec.at(i);
  }
  if(sum-maxi>maxi){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}
  

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){
  int N,K;
  cin >>N>>K;
  double ans = 0;
  for(double i = 1;i<=N;i++){
    if(i >= K){
      ans += (double)1/N;
      continue;
    }
    ans += (double)pow((double)1/2,ceil(log2(K/i))) / (double)N;

  }

  printf("%.16f\n",ans);
  return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll a,b;
	cin>>a>>b;
	if(a<10&&b<10)
	cout<<a*b;
	else
	cout<<-1;	
}

Measured memory_bytes: 256
using System;

namespace AtC156
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Xstr = Console.ReadLine().Split(' ');
            int[] X = new int[N];
            for (int i = 0; i < N; i++) X[i] = int.Parse(Xstr[i]);
            int[] Pow = new int[101];
            for (int i = 0; i < 101; i++) Pow[i] = i * i;
            long ans = 10000000;
            for(int i = 0; i < 101; i++)
            {
                long tmp = 0;
                for (int j = 0; j < N; j++) tmp += Pow[Math.Abs(i - X[j])];
                ans = Math.Min(ans, tmp);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += a//2
        a //= 2
    else:
        if b%2 == 1:
            b -= 1
        a += b//2
        b //= 2
print(a, b)


Measured memory_bytes: 38256
import io
import sys

def main():
    s = int(input())
    li = list(input())

    if s % 2 != 0:
    	print ("No")
    	sys.exit(0)

    front = []
    back = []

    for i in range(int(s/2)):
    	front.append(str(li[int(i)]))

    for j in range(int(s/2), s):
    	back.append(str(li[int(j)]))


    if (front == back):
    	print ('Yes')
    else:
    	print ('No')


if __name__ == '__main__':
	main()

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

using namespace std;
using ll = long long;

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

ll go(int choice, multiset<pair<int, int>> l, multiset<pair<int, int>> r) {
	int pos = 0;
	ll ans = 0;
	// cout << "choice = " << choice << endl;
	while (l.size()) {
		int a, b;
		if (choice) { // ->
			a = -l.begin()->first;
			b = l.begin()->second;
			l.erase(l.begin());
			r.erase(r.find({b, a}));
		}
		else {
			b = r.begin()->first;
			a = r.begin()->second;
			r.erase(r.begin());
			l.erase(l.find({-a, b}));
		}
		if (pos >= a && pos <= b) {
			//do nothing
		}
		else if (abs(a - pos) < abs(b - pos)) {
			ans += abs(a - pos);
			pos = a;
		}
		else {
			ans += abs(b - pos);
			pos = b;
		}
		// cout << "goto " << a << " " << b << ", pos = " << pos << endl;
		choice = !choice;
	}
	ans += abs(pos);
	// cout << "ANS = " << ans << endl;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	multiset<pair<int, int>> l, r;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		l.insert({-a, b});
		r.insert({b, a});
	}
	cout << max(go(0, l, r), go(1, l, r)) << endl;
}


Measured memory_bytes: 19072
import java.util.Scanner;

public class Main {
	static int[] ary;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ary = new int[n];
		for(int i = 0; i < n; i++){
			ary[i] = sc.nextInt();
		}
		int count = 0;
		for(int i = 0; i < n-2; i++){
			if(check(ary[i], ary[i + 1], ary[i + 2])){
				count++;
			}
		}
		System.out.println(count);
	}
	static boolean check(int a, int b, int c){
		return (Math.max(a, Math.max(b, c)) != b)
				&& (Math.min(a, Math.min(b, c)) != b);
	}
}


Measured memory_bytes: 21844
from bisect import bisect_left, bisect_right
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A.sort()
C.sort()
ans = 0
for b in B:
    ltB = bisect_left(A, b)
    gtB = N - bisect_right(C, b)
    ans += ltB*gtB
print(ans)

Measured memory_bytes: 23232
package main

import (
	"fmt"
)

// 2018-08-02T12:25:38+0800
// 2018-08-02T12:28:40+0800
// 2018-08-02T12:32:30+0800
func main() {
	var N int
	fmt.Scanf("%d", &N)
	a := make([]int, N)
	m := make(map[int]int)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a[i])
		m[a[i]] ++
	}
	out := 0
	for key, value := range m {
		if value > key {
			out += value - key
		} else if value < key {
			out += value
		}
	}
	fmt.Println(out)
}

Measured memory_bytes: 10908
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N, M = map(int, input().split())
    PY = []
    for i in range(M):
        P, Y = map(int, input().split())
        PY.append([Y, P, i + 1])
    PY.sort()

    # cnt: key=県, value=すでに幾つの市がその県に属しているか
    # res: [市の番号, 県の番号, 順番]
    cnt = {}
    res = []
    for y, p, i in PY:
        if p not in cnt:
            cnt[p] = 1
        else:
            cnt[p] += 1
        res.append([i, p, cnt[p]])

    res.sort()
    for i, p, x in res:
        print('{:06}{:06}'.format(p, x))


Measured memory_bytes: 42172
import java.util.Scanner;

public 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("a > b");
		else if (a == b)
			System.out.println("a == b");
		else
			System.out.println("a < b");

	}

}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	while (1) {
		bool flag = false;
		int n, p;
		int now;
		int pos = 0;
		int a[51] = {};

		cin >> n >> p;
		if (n == 0 && p == 0) {
			break;
		}
		now = p;
		while (1) {
			if (now > 0) {
				now--;
				a[pos]++;
				
			}
			else {
				FOR(i, 0, n - 1) {
					if (a[i] == p) {
						cout << i << endl;
						flag = true;
						break;
					}
				}
				now += a[pos];
				a[pos] = 0;
			}
			pos++;
			if (pos == n) {
				pos = 0;
			}
			if (flag == true) {
				break;
			}
		}
	}

}


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

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

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   string s; cin >> s;
   int n = s.size();

   vector<int> cost(2);
   for (int k = 0; k < 2; ++k) {
      for (int i = 0; i < n; ++i) {
         if (((i+k) % 2) ^ (s[i] == '0')) {
            ++cost[k];
         }
      }
   }
   cout << *min_element(cost.begin(), cost.end()) << endl;

   return 0;
}


Measured memory_bytes: 512
n,q = map(int, input().split( ))
tag = [i for i in range(n)]
for _ in range(q):
    cmmd,x,y =map(int, input().split( ))
    if cmmd == 0:
        chng1 = []
        chng2 = []
        chng1.append(x)
        x = tag[x]
        chng2.append(y)
        y = tag[y]
        while x != tag[x]:
            chng1.append(x)
            x = tag[x]
        chng1.append(x)
        while y != tag[y]:
            chng2.append(y)
            y = tag[y]
        chng2.append(y)
        if x != y:
            if len(chng1) < len(chng2):
                for x_ in chng1:
                    tag[x_] = y
            else:
                for y_ in chng2:
                    tag[y_] = x
 
    else:
        while x != tag[x]:
            x = tag[x]
        while y != tag[y]:
            y = tag[y]
        if x != y:
            print(0)
        else:
            print(1)


Measured memory_bytes: 6000
// inputに入力データ全体が入る
function Main(input) {
  switch(input.split('\n')[0]){
    case 'Sunny':
      process.stdout.write("Cloudy");
      break;
    case 'Cloudy':
      process.stdout.write("Rainy");
      break;
    case 'Rainy':
      process.stdout.write("Sunny");
      break;
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7244
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  const fields = lines[0];

  const fieldStack = [];
  const pondStack = [];
  const len = fields.length;
  for (let i = 0; i < len; i++) {
    const c = fields[i];
    if (c === "\\") {
      fieldStack.push(i);
    } else if (c === "/") {
      let j = fieldStack.pop();
      if (j != null) {
        let a = i - j;
        let pond = pondStack.pop();
        while (pond) {
          if (pond.first > j) {
            a += pond.area;
            pond = pondStack.pop();
          } else {
            pondStack.push(pond);
            break;
          }
        }
        pondStack.push({ area: a, first: j });
      }
    }
  }
  console.log(pondStack.reduce((prev, e) => prev + e.area, 0));
  let msg = "" + pondStack.length;
  if (pondStack.length > 0) {
    msg += " " + pondStack.map((e) => e.area).join(" ");
  }
  console.log(msg);
});



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

// input
int N, M;
vector<int> A, B;

const int INF = 1e9;
int w[50][50];


void input() {
    cin >> N >> M;
    A = B = vector<int>(M);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
}


bool judge() {
    int v[50][50];
    rep(i, 50) rep(j, 50) v[i][j] = w[i][j];
    rep(k, N) rep(i, N) rep(j, N) {
        v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
    }
    rep(i, N) rep(j, N) if (v[i][j] == INF) return true;
    return false;
}


int main() {
    input();
    rep(i, N) rep(j, N) {
        if (i == j) w[i][j] = 0;
        else w[i][j] = INF;
    }
    rep(i, M) w[A[i]][B[i]] = w[B[i]][A[i]] = 1;
    
    int ans = 0;
    rep(i, M) {
        w[A[i]][B[i]] = w[B[i]][A[i]] = INF;
        if (judge()) ans++;
        w[A[i]][B[i]] = w[B[i]][A[i]] = 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
const int maxn=200010;

int main()
{
	char x[maxn];	
	cin>>x;
	int n=strlen(x);
//	cout<<n<<endl;
	int sumt=0,sums=0;
	for(int i=0;i<n;i++)
	{
		if(x[i]=='S')
			sums++;
		else
		{
			if(sums>0)
				sums--;
			else
				sumt++;
		}
	}
	cout<<sums+sumt<<endl;
	return 0; 
 } 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    map<char, int> counts;
    for (char c : s)
    {
        counts[c]++;
    }

    int ans = INT32_MAX;
    for (auto i : counts)
    {
        char c = i.first;
        int now = 0;
        string s2;
        s2.assign(s.data());

        while (s2 != string(s2.size(), c))
        {
            now++;
            rep(i, s2.size() - 1)
            {
                if (s2.at(i) != c && s2.at(i + 1) == c)
                {
                    s2[i] = c;
                }
            }
            s2.pop_back();
        }
        ans = min(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(raw_input())
for i in range(N):
    a=raw_input()
    b=raw_input()
    if len(a)<len(b):
        (a,b)=(b,a)
    b=''.join(['0' for x in range(len(a)-len(b))])+b
    c=[]
    o=0
    for p in range(len(a)):
        d=(int(a[-p-1])+int(b[-p-1])+o)%10
        o=(int(a[-p-1])+int(b[-p-1])+o)/10
        c.append(d)
    if o:
        c.append(o)
    c.reverse()
    if len(c)<81:
        print ''.join([str(x) for x in c])
    else:
        print 'overflow'

Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n, m;
  cin >> n >> m;
  vector<int> to[100005];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vi dist(n, INF);
  vi pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()){
    int v = q.front(); q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes\n";
  rep(i, n) {
    if (i == 0) continue;
    cout << pre[i] + 1 << endl;
  }
}

Measured memory_bytes: 10544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        String st = s.nextLine();
        String tt = s.nextLine();
        
        // if(st.equals(tt)){
        //     System.out.println(0);
        //     return;
        // }

        int max = 0;
        for(int i=0; i<=st.length()-tt.length(); i++){
            int count = 0;
            for(int j=0; j<tt.length(); j++){
                if(st.charAt(i+j)==tt.charAt(j)) count++;
            }
            max = Math.max(max, count);
        }

        System.out.println(tt.length()-max);
        
    }
}

Measured memory_bytes: 32648
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    if s=="AAA" or s=="BBB":print("No")
    else:print("Yes")

main()

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    const int arr[] = {1, 2, 4, 8, 16, 32, 64};
    int n; cin >> n;

    int ans = 1;
    rep(i, 7) {
        if (arr[i] <= n) ans = arr[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	double N;
	ll ANS=1;
	cin >> N;
	for(ll i=1;i<=sqrt(N);i++){
		ANS=i*i;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#pragma 03
using namespace std;
ll mod = 1e9+7;
ll factorial[1000005];
ll binpow(ll c, ll d){
	ll a = c % mod, b = d % (mod-1); 
	if (b == 0) return 1;
	ll x = binpow(a, b/2);
	(x *= x) %= mod;
	if (b % 2 == 0) return x;
	else return (x * a) % mod;
}
ll bindiv(ll a, ll b){
	a %= mod; b %= mod;
	ll x = binpow(b, mod - 2);
	return (x * a) % mod;
}
ll com(ll a, ll b){
	ll x = factorial[a] * factorial[b-a];
	ll y = factorial[b];
	return bindiv(y, x);
}
int main(){ 
	ll x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0){
		cout << 0;
		return 0;
	}
	factorial[0] = 1LL;
	for (ll i = 1; i<1000005; i++) factorial[i] = (factorial[i-1] * i) % mod;
	if (2 * x < y || 2 * y < x) cout << 0;
	else cout << com((2*x-y)/3, (x+y)/3);
    return 0; 
} 

Measured memory_bytes: 8064
n, k, *A = map(int, open(0).read().split())
B = set()
C = []
p = 0
while True:
    p = A[p]-1
    if p in B:
        C.append(p)
        break
    B.add(p)
    C.append(p)

x = C.index(p)
if k-1 < x:
     print(C[k-1]+1)
else:
    D = C[x:len(C)-1]
    print(D[(k-1-x) % len(D)]+1)

Measured memory_bytes: 35900
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readString()

	m := []byte(n)[1:]
	l := []byte(n)[:len(n)-1]

	if (m[0] == m[1] && m[1] == m[2]) || (l[0] == l[1] && l[1] == l[2]) {
		println("Yes")
	} else {
		println("No")
	}

}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	int K, N;
	cin >> N >> K;
	vector<int>vec(N);
	for (int ia = 0; ia < N; ia++) {
		cin >> vec.at(ia);
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	int sum = 0;
	for (int ib = 0; ib < K; ib++) {
		sum += vec.at(ib);
	}
	cout << sum << endl;
}



	


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

int main(){
    double a,b,c,d=0,e=0,z=0,x=0;
    cin>>a>>b;
    c=a+b;
    d=max(a,b);
    d=(d*2)-1;
    cout<<max(c,d);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> order(n);
    for(int i = 0; i < n; i++){
        order[i] = i+1;
    }
    
    vector<int> p(n);
    vector<int> q(n);

    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 0; i < n; i++){
        cin >> q[i];
    }

    int a, b;
    int cnt = 1;
    do{
        for(int i = 0; i < n; i++){
            if(order[i] != p[i]){
                break;
            }
            if(i == n-1){
                a = cnt;
            }
        }
        for(int i = 0; i < n; i++){
            if(order[i] != q[i]){
                break;
            }
            if(i == n-1){
                b = cnt;
            }
        }
        cnt++;
    } while(next_permutation(order.begin(), order.end()));
    int ans = abs(a-b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char a[105];
int f,l;
int main()
{
	scanf("%s",a);
	for(int i=0;i<105;i++)
	{
		if(a[i]=='C'&&!f)f=i+1;
		if(a[i]=='F')l=i+1;
	}
	if(f<l&&f)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
import itertools
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    n %= 10
    if n == 3:
        txt = 'bon'
    elif n in (0, 1, 6, 8):
        txt = 'pon'
    else:
        txt = 'hon'

    print(txt)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
NK = list(map(int, input().split()))
ans = [0]*NK[0]

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(1,NK[0]+1):
    if table.count(j) != 0:
      ans[j-1] = 1
print(NK[0]-sum(ans))

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

int main()
{
    string S;
    cin >> S;
    string S1 = S;

    int count  = 0;

    reverse(S1.begin(),S1.end());

    for (int i = 0; i < (S.size() / 2); i++) {
        if (S1[i] != S[i])
            count++; 

    }

    cout << count << '\n';
    
    return 0;

}

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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> c.at(i).at(j);
    vector<int> a(3), b(3);
    rep(i, 3) b.at(i) = c.at(i).at(0);
    rep(i, 3) a.at(i) = c.at(0).at(i) - b.at(0);
    bool flag = true;
    rep(i, 3) rep(j, 3) if(a.at(j) + b.at(i) != c.at(i).at(j)) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[200];
ll t[200];
ll n;
char s[200];
int main(){
	rep(i,'a','z'+1)a[i]=INF;
	scanf("%lld\n",&n);
	rep(i,0,n){
		scanf("%s",s);
		ll k=strlen(s);
		rep(i,'a','z'+1)t[i]=0;
		rep(i,0,k)t[s[i]]++;
		rep(i,'a','z'+1)a[i]=min(a[i],t[i]);
	}
	rep(i,'a','z'+1)rep(j,0,a[i])putchar(i);
	puts("");
}

Measured memory_bytes: 128
from copy import deepcopy
H, W = map(int, input().split())
spots = []
dirs = [[0, 1], [1, 0], [0, -1], [-1, 0]]
maze = []
for h in range(H):
  line = list(input())
  maze.append(line)
res = 0
for h in range(H):
  for w in range(W):
    if maze[h][w] == '.':
      newMaze = deepcopy(maze)
      newMaze[h][w] = '#'
      # print(j, i)
      # for line in newMaze:
      #   print(line)
      # print()
      newSpots = [[h, w]]
      count = 0
      while True:
        spots = newSpots
        newSpots = []
        # print(count)
        # for line in newMaze:
        #   print(line)
        # print()
        if 0 < len(spots):
          count += 1
        else:
          break
        for pos in spots:
          # if j == 5 and i == 4:
          #   for line in newMaze:
          #     print(line)
          #   print()
          for d in dirs:
            x = d[1] + pos[1]
            y = d[0] + pos[0]
            if 0 <= x < W and 0 <= y < H and newMaze[y][x] == '.':
              newMaze[y][x] = '#'
              newSpots.append([y, x])
      if res < count:
        res = count
print(res-1)

Measured memory_bytes: 51164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll money = 1000;
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll k = 0;
    for (int i = 1; i < N; i++) {
        if (A[i-1] < A[i]) {
            k += money/A[i-1];
            money %= A[i-1];
        }
        else {
            money += k*A[i-1];
            k = 0;
        }
    }
    money += k*A[N-1];
    cout << money << endl;
}


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

using namespace std;

#define int long long
#define f(i, n) for(ll i=0;i<n;i++)
#define fr(i, n) for(ll i=n-1;i>=0;i--)
#define fa(i, a, n) for(ll i=a;i<n;i++)
#define fra(i, a, n) for(ll i=a-1;i>=n;i--)
#define MOD 998244353
#define pb push_back
#define lb lower_bound
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<long long> vi;
typedef pair<ll, ll> pii;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<int, vi> miv;

class Solution {
public:
    void pre() {}

    int power(int x, unsigned int y, unsigned int m) {
        if (y == 0)
            return 1;
        int p = power(x, y / 2, m) % m;
        p = (p * p) % m;
        return (y % 2 == 0) ? p : (x * p) % m;
    }

    void modInverse(int a, int m) {
        power(a, m - 2, m);
    }

    void solve() {
        int n, m;
        cin >> n >> m;
        cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    }
};

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    Solution solver;
    //solver.pre();
    for (int i = 0; i < t; i++) {
        //cout << "Case #" << i + 1 << ": ";
        solver.solve();
    }
    return 0;
}


Measured memory_bytes: 256
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int N = ni();
    	int M = ni();
    	Set<Integer> set = new HashSet<>();
    	int[] sv = new int[N+1];
    	int ac = 0, wa = 0;
    	int p;
    	String s;
    	for (int i = 0; i < M; i++) {
    		p = ni();
    		s = ns();
			if(!set.contains(p)) {
				if(s.equals("AC")) {
    				ac++;
    				set.add(p);
    				wa += sv[p];
    				sv[p] = 0;
    			} else {
    				sv[p]++;
    			}
    		}
		}
    	out.println(ac + " " + wa);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 68860
#include <iostream>
using namespace std;
int main(){
  int a,b,ans=0;cin>>a>>b;
  if(4*a>=b){
    if((4*a-b)%2==0){
      if((4*a-b)/2<=a){ans=1;}
    }
  }
  if(ans==0){
    cout << "No"<<endl;
  }else{
    cout << "Yes"<<endl;
  }
}

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

#define PB push_back
#define SZ(c) int((c).size())
#define ALL(c) (c).begin(), (c).end()
#define CONTAINS(c, x) ((c).find(x) != (c).end())
#define REP(i, n) for(int i=0; i<n; i++)
#define PER(i, n) for(int i=n-1; i>=0; i--)
#define WAIT cout<<flush, system("PAUSE");
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 1100100;

ll N, A[MAX], s, sol;

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

	cin >> N;
	REP(I, N) cin >> A[I], s+=A[I];
	sort(A, A+N);
	
	sol = 1;
	s -= A[N-1];
	PER(I, N-1){
		if (s * 2 < A[I+1]) break;
		s -= A[I];
		sol++;
	}
	cout << sol << endl;
}


















Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int r;
    cin >> r;
    
    cout << r*r << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Abc156b
{
    static int n, k;

    static void Solve()
    {
        // var t = Math.Ceiling(Math.Log(n) / Math.Log(k));
        // System.Console.WriteLine(t);
        var i = 2;
        var t = k;
        while(true){
            if(n >= t){
                ++i;
                t*=k;
            }
            else
                break;
        }

        System.Console.WriteLine(i-1);
    }

    static void Scan()
    {
        var buf = Console.ReadLine().Split();
        n = int.Parse(buf[0]);
        k = int.Parse(buf[1]);
    }

    static void Main()
    {
        Scan();
        Solve();
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var dp = new int[N + 1, 4, 4, 4];
        dp[0, 3, 3, 3] = 1;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    for (int l = 0; l < 4; l++)
                    {
                        for (int f = 0; f < 4; f++)
                        {

                            if (k == 0 && l == 2 && f == 1
                                || k == 0 && l == 1 && f == 2
                                || k == 2 && l == 0 && f == 1
                                || j == 0 && l == 2 && f == 1
                                || j == 0 && k == 2 && f == 1)
                            {
                                continue;
                            }
                            dp[i + 1, k, l, f] = (dp[i + 1, k, l, f] + dp[i, j, k, l]) % 1000000007;
                        }
                    }
                }
            }

        }
        var ans = 0L;
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    ans = (ans + dp[N, i, j, k]) % 1000000007;
                }
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 11184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (10010)
string s;

int main(){
	cin>>s;
	if (s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]) printf("Yes");
	else if (s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]) printf("Yes");
	else if (s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]) printf("Yes");
	else printf("No");
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算(nCkをO(1)で)
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    COMinit();
    int S;cin >> S;
    if(S < 3){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    long long loop = 0;
    while(true){
        long long remain = S-3*(loop+1);
        if(remain < 0) break;
        ans += COM(remain+loop,remain);
        ans %= MOD;
        loop++;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15604
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      Map<Integer, Long> freqMap = new HashMap<>();
      int[] balls = new int[n];
      for(int i = 0; i < n; i++) {
        balls[i] = sc.nextInt();
        freqMap.put(balls[i], freqMap.getOrDefault(balls[i], 0L) + 1);
      }

      long cnt = 0;
      for(Map.Entry<Integer, Long> entry : freqMap.entrySet()) {
        if(entry.getValue() < 2) continue;
        cnt += comb(entry.getValue());
      }

      for(int k = 0; k < n; k++) {
        int num = balls[k];
        long freq = freqMap.get(num);
        if(freq < 2) System.out.println(cnt);
        else {
          long removeCnt = comb(freq);
          long newCnt = comb(freq-1);
          System.out.println(cnt - removeCnt + newCnt);
        }
      }
  }

  private static long comb(long a) {
    if(a < 2) return 0;
    return a * (a - 1) / 2;
  }
}

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

const int MAXN = 100010;
int N, M;
vector<int> adj[MAXN];
bool vis[MAXN];

void dfs(int cur) {
	if (vis[cur]) return;
	vis[cur] = true;
	for (int nxt : adj[cur]) {
		dfs(nxt);
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b, dummy; cin >> a >> b >> dummy;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int nComps = 0;
	for (int i = 1; i <= N; i++) {
		if (vis[i]) continue;
		nComps++;
		dfs(i);
	}
	cout << nComps << endl;

	return 0;
}


Measured memory_bytes: 8960
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
if __name__ == '__main__':
    while True:
        try:
            a, b = map(int, input().split())
            print('{0} {1}'.format(math.gcd(a, b), lcm(a, b)))
        except EOFError:
            break


Measured memory_bytes: 5668
#include<iostream>
#include<cstdio>
using namespace std;
long long t,l,r,mid;
char c;
void doit1(long long n)
{
	long long ts=n;
	while(ts)
	{
		ts=(ts-9)/10;
		if (ts==0) break;
		cout<<"? "<<ts<<endl;
		cin>>c;
		if (c=='N')
		{
			cout<<"! "<<ts+1<<endl;
			exit(0);
		}
	}
	ts=n+1;
	while(1)
	{
		if (ts>=1e12)
		{
			cout<<"! "<<1<<endl;
			exit(0);
		}
		cout<<"? "<<ts<<endl;
		cin>>c;
		if (c=='N') 
		{
			l=ts/10*9;
			r=ts-1;
			return;
		}
		ts*=10;
	}
}
int main()
{
	fflush(stdout);
	t=10;
	while(1)
	{
		cout<<"? "<<t<<endl;
		cin>>c;
		if (c=='N')
		{
			l=t/10+1;
			r=t-1;
			break;
		}
		else
		{
			cout<<"? "<<t-1<<endl;
			cin>>c;
			if (c=='Y') 
			{
				doit1(t-1);
				break;
			}
			else t*=10;
		}
	}
	while(l<=r)
	{
		mid=(l+r)/2;
		cout<<"? "<<mid*10<<endl;
		cin>>c;
		if (c=='Y') r=mid-1;
		else l=mid+1;
	}
	cout<<"! "<<l<<endl;
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner scanner = new Scanner(System.in);
      	int n = scanner.nextInt();
      	double m = scanner.nextFloat();
      	int total = 0;
      	int[] a = new int[n];
      	for(int i =0; i<n; i++){
        	a[i] = scanner.nextInt();
          	total += a[i];
        }
      	int num = 0;
      	for(int i =0; i<n; i++){
        	if(a[i] >= total/(4*m)){num += 1;}
        }
      if(num >= m){
      	System.out.println("Yes");
      }else{
      	System.out.println("No");
      }
          
    }
}


Measured memory_bytes: 23124
#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 n,m;
  cin >> n >> m;
  int ans;
  ans = n*(n-1)/2 + m*(m-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nums = br.readLine().split(" ");
        int a = Integer.parseInt(nums[0]);
        int b = Integer.parseInt(nums[1]);
        int c = Integer.parseInt(nums[2]);
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24364