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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a, b, c;
    cin >> a >> b >> c;

    bool flag = false;
    repd(i, 1, b + 1) {
        int temp = a * i;
        if (temp % b == c) {
            flag = true;
        }
    }

    if (flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

using namespace std;

int main(void) {
    vector< vector<int> > c(3, vector<int>(3));
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            cin >> c[i][j];
        }
    }

    if(c[2][1]-c[2][0] != c[0][1]-c[0][0] || c[1][1]-c[1][0] != c[0][1]-c[0][0] || c[2][2]-c[2][1] != c[0][2]-c[0][1] || c[1][2]-c[1][1] != c[0][2]-c[0][1] || c[1][2]-c[0][2] != c[1][0]-c[0][0] || c[1][1]-c[0][1] != c[1][0]-c[0][0] || c[2][2]-c[1][2] != c[2][0]-c[1][0] || c[2][1]-c[1][1] != c[2][0]-c[1][0]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    l=[int(input()) for i in range(5)]
    l2=list(map(lambda x: -(-N//x)-1, l))
    print(5+sorted(l2)[4])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i <= (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int h,n; cin >> h >> n;
	vint a(n);
	int ans=0;
	rep(i,n) {
		cin >> a[i];
		ans+=a[i];
	}
	if(ans>=h) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3792
import sys
input = sys.stdin.readline
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]   
cnt = 0
for i in range(N-1,-1,-1):
    if (AB[i][0]+cnt)%AB[i][1] == 0:
        continue
    else:
        cnt += AB[i][1] - (AB[i][0]+cnt)%AB[i][1]
print(cnt)


Measured memory_bytes: 27368
def ismm(mm):
    mm = int(mm)
    if 0 < mm <= 12:
        return True
    else:
        return False


if __name__ == '__main__':
    S = input()
    s01 = S[0:2]
    s23 = S[2:4]

    yymm = ismm(s23)
    mmyy = ismm(s01)

    if yymm and mmyy:
        print('AMBIGUOUS')
    elif yymm:
        print('YYMM')
    elif mmyy:
        print('MMYY')
    else:
        print('NA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> A(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> A[i][j];
  int n; cin >> n;
  rep(i, n) {
    int b; cin >> b;
    rep(j, 3) rep(k, 3) if(A[j][k] == b) A[j][k] = 0;
  }
  rep(i, 3) {
    bool ok = true;
    rep(j, 3) if(A[i][j] != 0) ok = false;
    if(ok) {
      cout << "Yes" << endk;
      return 0;
    }
  }
  rep(j, 3) {
    bool ok = true;
    rep(i, 3) if(A[i][j] != 0) ok = false;
    if(ok) {
      cout << "Yes" << endk;
      return 0;
    }
  }
  {
    ll sum = A[0][0] + A[1][1] + A[2][2];
    if(sum == 0) {
      cout << "Yes" << endk;
      return 0;
    }
  }
  {
    ll sum = A[0][2] + A[1][1] + A[2][0];
    if(sum == 0) {
      cout << "Yes" << endk;
      return 0;
    }
  }
  cout << "No" << endk;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

vector<int> par;
vector<int> rak; // number of edges
vector<ll> sum; // sum of the weight of vertices
vector<int> ans; // number of edges satisfied

void init(int n) {
  par.resize(n+1);
  rak.resize(n+1);
  sum.resize(n+1);
  ans.resize(n+1);
  for(int i=1; i<=n; i++) {
    par.at(i) = i;
    rak.at(i) = 0;
    cin >> sum[i];
  }
}

int find(int x) {
  if (par.at(x) == x) {
    return x;
  } else {
    return par.at(x) = find(par.at(x));
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x==y) return;
  if (rak.at(x) < rak.at(y)) {
    rak[y] += rak[x];
    sum[y] += sum[x];
    ans[y] += ans[x];
    par.at(x) = y;
  } else {
    rak[x] += rak[y];
    sum[x] += sum[y];
    ans[x] += ans[y];
    par.at(y) = x;
  }
}

void calc(int x, ll len) {
  x = find(x);
  rak[x]++;
  if (len <= sum[x]) {
    ans[x] = rak[x];
  }
}

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

  int n, m; cin >> n >> m;
  init(n);
  vector<pair<int, P>> vec(m);
  rep(i, m) {
    int a, b, y; cin >> a >> b >> y;
    vec[i] = make_pair(y, P(a,b));
  }

  sort(vec.begin(), vec.end());

  for(auto e: vec) {
    auto a = e.second.first;
    auto b = e.second.second;
    auto len = e.first;
    unite(a,b);
    a = find(a);
    calc(a,len);
    //debug(x); debug(rak[x]); debugln(ans[x]);
  }
  cout << m - ans[find(1)] << endl;
}

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

int main()
{
	long long int a, b, c, ans;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0;
	else
	{
		if (a >= b && a >= c)
				ans = b * c;
		else if (b >= a && b >= c)
				ans = a * c;
		else if (c >= a && c >= b)
				ans = a * b;
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXL 3000
#define INF 1000000

string s, t;
int dp[MAXL + 3][MAXL + 3], sol[MAXL + 3][MAXL + 3];

string getSolution(int i, int j) {
    if (i == -1 || j == -1)
        return "";

    if (sol[i][j] == 2)
        return getSolution(i - 1, j - 1) + s[i];
    
    if (sol[i][j] == 0)
        return getSolution(i - 1, j);
    
    if (sol[i][j] == 1)
        return getSolution(i, j - 1);
}

int solve(int i, int j) {
    if (i == -1 || j == -1)
        return 0;

    if (dp[i][j] != -1)
        return dp[i][j];

    if (s[i] == t[j]) {
        sol[i][j] = 2;
        return dp[i][j] = 1 + solve(i - 1, j - 1);
    } else {
        int a = solve(i - 1, j);
        int b = solve(i, j - 1);
        
        sol[i][j] = (a > b ? 0 : 1);
        return dp[i][j] = max(a, b);
    }
}

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

    memset(dp, -1, sizeof(dp));

    solve(s.length() - 1, t.length() - 1);
    cout << getSolution(s.length() - 1, t.length() - 1) << endl;
}


Measured memory_bytes: 71040
#include<stdio.h>

int main(void){
  int i,j,s,n,m;
  static int a[100][100],b[100],c[100];

  scanf("%d%d",&n,&m);

  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

  for(i=0;i<m;i++)
    scanf("%d",&c[i]);

  for(i=0;i<n;i++){
    s = 0;
    for(j=0;j<m;j++)
      s += a[i][j] * c[j];
    printf("%d\n",s);
  }
  
  return 0;
}



Measured memory_bytes: 2112
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <functional>
#include <stdio.h>
using namespace std;

int main()
{
	int N;
	scanf("%d", &N);
	int amari = 0;
	int buf;
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &buf);
		if (amari == 1) {
			if (buf > 0) {
				sum += 1;
				buf--;
			}
		}
		sum += buf / 2;
		amari = buf % 2;
	}

	printf("%lld\n", sum);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

ll modpower(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll n, ll mod)
{
    return modpower(n, mod - 2, mod);
}

ll comb(ll n, ll m, ll mod)
{
    ll deno = 1;
    repi(i, m, 0)
    {
        deno = deno * (n - i) % mod;
    }
    ll frac = 1;
    repi(i, m + 1, 1)
    {
        frac = frac * modinv(i, mod) % MOD;
    }
    return deno * frac % mod;
}
int main()
{
    ll X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0)
    {
        cout << 0 << endl;
    }
    else
    {
        ll n = (2 * Y - X) / 3,
           m = (2 * X - Y) / 3;
        ll ans;
        if (n >= 0 && m >= 0)
        {
            ans = comb(n + m, n, MOD);
        }
        else
        {
            ans = 0;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
    long long t,i,k,n,x,y=1,z=1,s=1;
    cin>>n;
   for(i=0;i<n;i++)
   {
       s=(s*10)%1000000007;
   }
    for(i=0;i<n;i++)
   {
       y=(y*9)%1000000007;
   }
    for(i=0;i<n;i++)
   {
       z=(z*8)%1000000007;
   }
   cout<<(((s-(2*y)+z)%1000000007)+1000000007)%1000000007;

    return 0;
}


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

main(){
    int count;
    set<string> s;
    string n;
    cin>>count;
    for(int i=0;i<count;i++){
        cin>>n;
        s.insert(n);
    }
    cout<<s.size()<<endl;
    return 0; 
}

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

const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; ++i) cin >> h[i];

    int dp[n];
    for (int i = 0; i < n; ++i) dp[i] = INF;
    dp[0] = 0;

    for (int i = 1; i < n; ++i) {
        for (int m = 1; m <= min(k, i); ++m) {
            dp[i] = min(dp[i], dp[i - m] + abs(h[i] - h[i - m]));
        }
    }

    cout << dp[n - 1] << endl;
}


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

int main(){
    int n;
    cin>>n;
    int ans=0;
    if(n>=100 && n<=599) ans=8;
    else if(n>=600 && n<=799) ans=7;
    else if(n>=800 && n<=999) ans=6;
    else if(n>=1000 && n<=1199) ans=5;
    else if(n>=1200 && n<=1399) ans=4;
    else if(n>=1400 && n<=1599) ans=3;
    else if(n>=1600 && n<=1799) ans=2;
    else if(n>=1800 && n<=1999) ans=1;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.*;

class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<String> words = new ArrayList<String>();
		int size = 0;
		ArrayList<String> ans = new ArrayList<String>();
		int[] cnt = new int[1000];
		
		int maxLen = Integer.MIN_VALUE;
		String maxWord = "";
		
		StringTokenizer st = new StringTokenizer(br.readLine()," ");
		
		while (st.hasMoreTokens()) {
			
			String tmp = st.nextToken();
			if (tmp.length() > maxLen) {
				maxLen = tmp.length();
				maxWord = tmp;
			}
			if (!words.contains(tmp)) {
				words.add(tmp);
			}
			cnt[words.indexOf(tmp)]++;
			size++;
			
		}
		
		int max = 0;
		for (int c : cnt)
			max = Math.max(c, max);
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == max) {
				System.out.println(words.get(i) + " " + maxWord);
				break;
			}
		}
		
//		for (String a : ans)
//			System.out.println(a);
	}
	
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int a,b,c; cin>>a>>b>>c;
   cout<< (a==b?c:a==c?b:a) <<endl;
}


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

int int_sort( const void *a , const void *b ) {
  if( *(int*)a < *(int*)b ) {
    return -1;
  }
  else
  if( *(int*)a == *(int*)b ) {
    return 0;
  }
  return 1;
}

int main(){
  int n,i,j,tmp,flag=0;
  int *a;
  
  scanf("%d",&n);
  a=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  qsort((void*)a ,(size_t)n, sizeof(a[0]),int_sort);
  
  for(i=0;i<n;i++){
    if(i==0){
      tmp=a[0];
    }
    
    if(i!=0){
      if(tmp!=a[i]){
        tmp=a[i];
      } else {
        flag=1;
        break;
      }
    }
  }
  
  if(flag==0){
    printf("YES");
  } else {
    printf("NO");
  }
  free(a);
}
  

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

int main(){
  long long n,k;
  cin >> n >> k;
  double res = 0.0;
  for (long long i = 1; i <= n; ++i){
    double prob = 1.0;
    long long point = i;
    while (point < k){
      prob /= 2.0;
      point *= 2;
    }
    res += prob;
  }
  res /= n;
  cout << fixed << setprecision(10) << res << endl;
  return 0;
}

Measured memory_bytes: 256
def hantei(dominoes)
  return "Yes" if dominoes.size == 1

  parity = []
  domino_exists = []
  same_domino_exists = []
  7.times do
    parity << 0
    domino_exists << false
    same_domino_exists << false
  end

  dominoes.each do |domino|
    if domino[0] == domino[1]
      same_domino_exists[domino[0].to_i] = true
      next
    end

    domino.each_char do |num|
      parity[num.to_i] ^= 1
      domino_exists[num.to_i] = true
    end
  end

  7.times do |i|
    if same_domino_exists[i] && !domino_exists[i]
      return "No"
    end
  end

  odd_numbers = parity.select { |p| p == 1 }.size
  if [0, 2].include? odd_numbers
    return "Yes"
  else
    return "No"
  end
end

loop do
  STDIN.readline rescue break

  dominoes = STDIN.readline.chomp.split(" ")
  puts hantei(dominoes)
end

Measured memory_bytes: 6108
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        if (A[N-1] < K) {
            System.out.println("IMPOSSIBLE");
            return;
        }
        int gcd = gcd(A);
        if (K % gcd == 0) {
            System.out.println("POSSIBLE");
            return;
        }
        System.out.println("IMPOSSIBLE");
    }
    private int gcd(int[] x) {
        int ans = 0;
        for (int i = 0; i < x.length; i++) {
            ans = gcd(x[i], ans);
        }
        return ans;
    }
    private int gcd(int x, int y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }
}


Measured memory_bytes: 49864
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,k,a;
  cin>>n>>k;
  a = k - 1;
  n = n - 1;
  for(int i=0;i<n;i++){
    k = k * a;
  }
  if(n<1){
    k*(a+1);
  }
  cout<<k<<"\n";
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s1,s2,s3,s4,s5;
int ti,dist,n,m,st,go,mi,p1,p2;
int d[502][502];
map<string,int>M;
int main(){
  while(cin>>n>>m,n){
    M.clear();
    r(i,502)r(j,502)d[i][j]=1e8;
    int c=0;
    cin>>s1>>s2>>s3;
    r(i,m){
      cin>>s4>>s5>>dist>>ti;
      if(M[s4])p1=M[s4];
      else M[s4]=++c,p1=M[s4];
      if(M[s5])p2=M[s5];
      else M[s5]=++c,p2=M[s5];
      if(s1==s5)st=M[s5];
      if(s1==s4)st=M[s4];
      if(s2==s5)mi=M[s5];
      if(s2==s4)mi=M[s4];
      if(s3==s5)go=M[s5];
      if(s3==s4)go=M[s4];
      d[p1][p2]=d[p2][p1]=dist/40+ti;
    }
    r(o,n+1)r(i,n+1)r(j,n+1)d[i][j]=min(d[i][j],d[i][o]+d[o][j]);
    cout<<d[st][mi]+d[mi][go]<<endl;
  }
}

Measured memory_bytes: 4216
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

ans = 0
s = sr()
for i,c in enumerate(s):
    if i%2 == 0:
        if c == 'p':
            ans-=1
    else:
        if c == 'g':
            ans+=1
print(ans)

Measured memory_bytes: 78720
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);

        string ret = "";

        if (a < b && b < c)
            ret = "Yes";
        else
            ret = "No";

        Console.WriteLine(ret);
    }
}


Measured memory_bytes: 9008
#include <iostream>
#include <string>

using namespace std;

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

  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 592
from collections import defaultdict as ddict
def cal_interval(Num):
	interval = ddict(int)
	dp = [0 for i in range(Num)]
	for i in range(Num):
		tmp = int(raw_input())
		for j in range(i+1):
			dp[j] += tmp
			interval[dp[j]] += 1
	return interval
while 1:
	N, M = map(int,raw_input().split(" "))
	if (N, M) == (0,0):
		break
	Lon = cal_interval(N)
	Lat = cal_interval(M)
	print sum(v * Lat[k] for k,v in Lon.iteritems())

Measured memory_bytes: 81860
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;

int main(){  
    ll n;cin>>n;
    vector<ll>a(n);
    vector<ll> cnt(100002,0);
    ll sum = 0;
    rep(i,n){
        cin>>a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    ll q;cin>>q;
    vector<ll> b(q),c(q);
    rep(i,q)cin>>b[i]>>c[i];
    rep(i,q){
        sum = sum + (c[i]-b[i])*cnt[b[i]];
        cnt[c[i]] = cnt[c[i]]+cnt[b[i]];
        cnt[b[i]] = 0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define maxn 500006
using namespace std;

int tree[26][maxn];

int query(int idx, int flag){
    int sum = 0;
    while(idx > 0){
        sum += tree[flag][idx];
        idx -= idx & (-idx);
    }
    return sum;
}


void update(int idx, int x, int n, int flag){
    while(idx <= n){
        tree[flag][idx] += x;
        idx += idx & (-idx);
    }
}

int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=1;i<=n;i++){
        int x = s[i-1] - 'a';
        update(i, 1, n, x);
    }
    int q;
    cin >> q;
    while(q--){
        int f;
        cin >> f;
        if(f == 1){
            int pos, x, y;
            string t;
            cin >> pos >> t;
            x = t[0] - 'a';
            y = s[pos-1] - 'a';
            s[pos-1] = t[0];
            update(pos, -1, n, y);
            update(pos, 1, n, x);
        }
        else{
            int l, r, res = 0;
            cin >> l >> r;
            for(int i=0;i<26;i++){
                int qr = query(r, i) - query(l-1, i);
                if(qr) res++;
            }
            cout << res << endl;

        }
    }



    return 0;
}



Measured memory_bytes: 51716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define mod 1000000007
using namespace std;
string a[200009];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(n%2==0){
		for(int i=n;i>=2;i-=2){
			cout<<a[i]<<" ";
		}
		for(int i=1;i<n;i=i+2){
			cout<<a[i]<<" ";
		}
		cout<<endl;
	}
	if(n%2==1){
		for(int i=n;i>=1;i-=2){
			cout<<a[i]<<" ";
		}
		for(int i=2;i<n;i=i+2){
			cout<<a[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 15872
using System;
using System.Linq;
using System.Collections.Generic;
 
class P{
    static void Main(){
       List<long>Sosu=new List<long>();
       var s=Console.ReadLine().Split().Select(long.Parse).ToArray();
        if(s[0]==1){
           Console.WriteLine(s[1]);
           return;
       }
       long lim=1+(long)Math.Pow((double)s[1],1.0/s[0]);
       int l=0;
       List<long>cd=new List<long>();
       for(long i=2;i<=lim;i++){
           if(Sosu.All(x=>i%x!=0)){
                Sosu.Add(i);
                cd.Add(0L);
                while(s[1]%i==0){
                    s[1]/=i;
                    cd[l]++;
                }
                l++;
                if(s[1]==1)break;
            }
       }
       int Lsosu=Sosu.Count();
       long ans=1;
       for(int i=0;i<Lsosu;i++){
           ans*=(long)Math.Pow((double)Sosu[i],(double)(cd[i]/s[0]));
       }
       Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15452
#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 a, b;
  cin >> a >> b;
  int amin = (a*200) / 8;
  amin = (amin+1) / 2;
  int amax = (a+1)*200 / 8;
  amax = (amax-1) / 2;
  int bmax = (b+1)*200 / 10;
  bmax = (bmax-1) / 2;
  int bmin = b*200 / 10;
  bmin = (bmin+1) / 2;
  if ((amin <= bmax) && (bmin <= amax)) {cout << max(amin, bmin);}
  else cout << -1;
}


Measured memory_bytes: 256
//RohitKaushal
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define print(x) cerr << (#x) << "is "<< x << "\n"
typedef long long ll;
const int MOD = 1e9+7;


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

   string str;
   cin>>str;
   int f=1;

   int n= str.size();

   for (int i = 0; i < n; i+=2)
   {
		if(str[i]!='R' && str[i]!='U' && str[i]!='D'){
			f=0;
			break;
		}
   }

   for (int i = 1; i < n; i+=2)
   {
		if(str[i]!='L' && str[i]!='U' && str[i]!='D'){
			f=0;
			break;
		}
   }

   if(f) cout<<"Yes";
   else cout<<"No";

   return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {
//
//    }
    ll m,n;cin>>m>>n;
    if(m==n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k,c;
    cin >> n >> k;
    priority_queue<ll> h;

    rep(i,n){
        cin >> c;
        h.push(c);
    }
    rep(i,k){
        h.pop();
        if(h.empty()){
            cout << 0 << endl;
            return 0;
        }
    }
    ll cnt=0;
    while(!h.empty()){
        cnt += h.top();
        h.pop();
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int a[100005];
int main()
{
    int n, ans, tem, left;
    while(~scanf("%d",&n))
    {
        left = ans = 0;
        memset(a, 0, sizeof(a));
        while(n--)
        {
            scanf("%d",&tem);
            if(a[tem]) left++;
            else
            {
                a[tem]++;
                ans++;
            }
        }
        if(left%2) ans--;
        cout << ans << endl;
    }
}


Measured memory_bytes: 768
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [a,b,c,k] = nexts(4);
  var ans = k;
  k -= a;
  if(k > 0)ans -= k, k -= b;
  if(k > 0)ans -= k;
  return ans;
}

Measured memory_bytes: 29892
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(100000+1)]
for i in range(n):
    b[a[i]] += 1
eat = 0
for i in range(100000+1):
    eat += max(0, b[i]-1)
print(n-(eat+1)//2*2)


Measured memory_bytes: 14388
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func mpow(a, b int) int {
	if b == 0 {
		return 1
	} else if b%2 == 0 {
		tmp := mpow(a, b/2)
		return tmp * tmp % mod
	}
	return mpow(a, b-1) * a % mod
}

var fracMemo = []int{1, 1}

func mfrac(n int) int {
	if len(fracMemo) > n {
		return fracMemo[n]
	}
	if len(fracMemo) == 0 {
		fracMemo = append(fracMemo, 1)
	}
	for len(fracMemo) <= n {
		size := len(fracMemo)
		fracMemo = append(fracMemo, fracMemo[size-1]*size%mod)
	}
	return fracMemo[n]
}

var ifracMemo = []int{1, 1}

func mifrac(n int) int {
	if len(ifracMemo) > n {
		return ifracMemo[n]
	}
	if len(ifracMemo) == 0 {
		fracMemo = append(ifracMemo, 1)
	}
	for len(ifracMemo) <= n {
		size := len(ifracMemo)
		ifracMemo = append(ifracMemo, ifracMemo[size-1]*mpow(size, mod-2)%mod)
	}
	return ifracMemo[n]
}

func nCr(n, r int) int {
	if n == r {
		return 1
	}
	if n < r || r < 0 {
		return 0
	}
	ret := 1
	ret *= mfrac(n)
	ret %= mod
	ret *= mifrac(r)
	ret %= mod
	ret *= mifrac(n - r)
	ret %= mod
	out(mfrac(n), mifrac(r), mifrac(n-r))
	return (ret)
}

func frac(n, m int) int {
	ret := 1
	for n > 0 {
		ret *= n
		ret %= mod
		n--
	}
	return ret
}

// 逆元を使った割り算（MOD）
// mod. m での a の逆元 a^{-1} を計算する
func modinv(a, m int) int {
	b := m
	u := 1
	v := 0
	for b != 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}

func main() {
	sc.Split(bufio.ScanWords)
	X, Y := getInt(), getInt()

	a := 2*X - Y
	b := 2*Y - X
	if a%3 != 0 || b%3 != 0 {
		out(0)
		return
	}
	if a < 0 || b < 0 {
		out(0)
		return
	}
	a /= 3
	b /= 3
	// out(a, b)
	// out(nCr(a+b, a))
	// return
	ans := frac(a+b, mod)
	as := frac(a, mod)
	bs := frac(b, mod)
	// out(ans, as, bs)
	ans *= modinv(as, mod)
	ans %= mod
	ans *= modinv(bs, mod)
	ans %= mod
	out(ans)
}


Measured memory_bytes: 640
s = input()
# if(len(s) < 15):
# 	rem = 15 - len(s)
# 	s = s + s[:rem]
# print(len(s))
rem = 15 - len(s)
p = s.count('o') + rem
# print(p)
if p >= 8:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include<string>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
const LL maxn=4e5+10;
const double eps=1e-9;
LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int read1()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main()
{
    set<char> se;
    se.clear();
    string s;
    cin>>s;
    se.insert(s[0]);se.insert(s[1]);se.insert(s[2]);
    if(se.size()==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
int main(void)
{
	int second;
	int time;
	int minute;
	scanf( "%d", &second );

	time = second / 3600;
	minute = (second - time * 3600) / 60;
	second = second % 60;

	printf( "%d:%d:%d\n", time, minute, second );

	return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n){
        if(i==n-1 || s[i]!=s[i+1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function unionFind(n){this.a=Array(n+1).fill(-1);}
unionFind.prototype={
  root:function(i){return this.a[i]<0?i:this.a[i]=this.root(this.a[i]);},
  same:function(x,y){return this.root(x)===this.root(y);},
  unite:function(x,y){x=this.root(x);y=this.root(y);if(x===y)return 1;if(this.a[y]<=this.a[x])this.a[y]+=this.a[x],this.a[x]=y;else this.a[x]+=this.a[y],this.a[y]=x;},
  size:function(i){return -this.a[this.root(i)];},
}

function main(){
  var n = o.a();
  var u = o.a();
  var v = o.a();
  var a = o.m(n-1);
  var g = xArray("[]",n+1);
  for(var i = 0; i < n-1; i++){
    var w=a[i][0], x=a[i][1];
    g[w].push(x);
    g[x].push(w);
  }
  var line = [];
  dfs(u,-1);
  var dx = line.length-2>>1;
  var z = line[dx+1];
  var uf = new unionFind(n);
  for(var i = 0; i < n-1; i++){
    var w=a[i][0], x=a[i][1];
    if(w === z || x === z)continue;
    uf.unite(w,x);
  }
  var g2 = xArray("[]",n+1);
  for(var i = 0; i < n-1; i++){
    var w=a[i][0], x=a[i][1];
    if(!uf.same(w,u)||!uf.same(x,u))continue;
    g2[w].push(x);
    g2[x].push(w);
  }
  var mx = 0;
  dfs2(line[dx],-1,0);
  if(line.length%2===1)dx++;
  return mx+dx;

  function dfs(s,p){
    line.push(s);
    if(s === v)return true;
    for(var i of g[s]){
      if(i === p)continue;
      if(dfs(i,s))return true;
    }
    line.pop();
  }
  function dfs2(s,p,d){
    if(d > mx)mx = d;
    for(var i of g2[s]){
      if(i === p)continue;
      dfs2(i,s,d+1);
    }
  }
}
if (process.argv.length <= 2) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=240000"] });
else {
  console.log(main());
}

Measured memory_bytes: 132468
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
	public int x { get; set; }
	public int y { get; set; }
	public int t { get; set; }
	public int d { get; set; }
	public int visited { get; set; }
}

public class hello
{
	public static int h, w;
	public static void Main()
	{
		while (true)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			w = int.Parse(line[0]);
			h = int.Parse(line[1]);
			if (w == 0 && h == 0) break;
			var map = new int[h, w];
			var sx = 0; var sy = 0;
			for (int i = 0; i < h; i++)
			{
				line = Console.ReadLine().Trim().Split(' ');
				for (int j = 0; j < w; j++)
				{
					if (line[j] == "P") { map[i, j] = -1; sx = i; sy = j; }
					else if (line[j] == ".") map[i, j] = -1;
					else map[i, j] = int.Parse(line[j]);
				}
			}
			var n = int.Parse(Console.ReadLine().Trim());
			var data = new int[10, 3];
			var tmax = 0;
			for (int i = 0; i < n; i++)
			{
				line = Console.ReadLine().Trim().Split(' ');
				var id = int.Parse(line[0]);
				for (int j = 0; j < 3; j++)
				{
					data[id, j] = int.Parse(line[j + 1]);
					if (j == 2) tmax = Max(tmax, data[id, j]);
				}
			}
			var ans = getAns(map, data, n, sx, sy, tmax);
			Console.WriteLine(ans);
		}
	}
	static int getAns(int[,] map, int[,] data, int n, int sx, int sy, int tmax)
	{
		var ans = 0;
		var dx = new int[] { 0, 1, 0, -1 };
		var dy = new int[] { 1, 0, -1, 0 };
		var used = new bool[h, w, 1 << 10,tmax+2];
		used[sx, sy, 0,0] = true;
		var q = new Queue<P>();
		q.Enqueue(new P { x = sx, y = sy , t = 0 });
		while (q.Count() > 0)
		{
			var a = q.Dequeue();
			var www = Convert.ToString(a.visited, 2);
			if (a.t > tmax) { ans = Max(ans, a.d); continue; }
			var nvisited = a.visited;
			var nd = a.d;
			var nt = a.t + 1;
			for (int i = 0; i < 4; i++)
			{
				var nx = a.x + dx[i];
				var ny = a.y + dy[i];
				if (nx >= 0 && nx < h && ny >= 0 && ny < w)
				{
					var mp = map[nx, ny];
					if (mp != -1 && canGet(nvisited, mp, a.t, data))
					{
						nvisited |= 1 << mp;
						nd += data[mp, 0];
					}
				}
			}
			for (int i = 0; i < 4; i++)
			{
				var nx = a.x + dx[i];
				var ny = a.y + dy[i];
				if (nx >= 0 && nx < h && ny >= 0 && ny < w)
				{
					var mp = map[nx, ny];
					if (mp == -1 && !used[nx, ny, nvisited,nt])
					{
						q.Enqueue(new P { x = nx, y = ny, d = nd, t = nt, visited = nvisited });
						used[nx, ny, nvisited,nt] = true;
					}
				}
			}
		}
		return ans;
	}
	static bool canGet(int a, int mp, int t, int[,] data)
		=> (t >= data[mp, 1] && t < data[mp, 2]) && (((a >> mp) & 1) == 0);
}



Measured memory_bytes: 116948
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
 
public class Main {
	
	
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        
        boolean[] colored = new boolean[N];
        
        for(int i = 0; i < M; i++){
        	final int a = sc.nextInt();
        	final int L = sc.nextInt();
        	
        	for(int j = 0; j < L; j++){
        		final int index = (a + j) % N;
        		
        		colored[index] = true;
        	}
        }
        
        int false_pos = -1;
        for(int i = 0; i < N; i++){
        	if(!colored[i]){
        		false_pos = i;
        		break;
        	}
        }
        
        if(false_pos == -1){
        	System.out.println(N + " " + 1);
        	return;
        }
        
        int[] counts = new int[N];
        int count = 0;
        boolean prev = false;
        for(int i = 0; i < N; i++){
        	final int index = (i + false_pos) % N;
        	
        	if(colored[index]){
        		if(!prev){
        			prev = true;
        		}
        		count++;
        	}else{
        		if(prev){
        			prev = false;
        			counts[count]++;
        			count = 0;
        		}
        	}
        }
        
        if(count != 0){
        	counts[count]++;
        	count = 0;
        }
        //System.out.println(Arrays.toString(colored));
        
        for(int i = N - 1; i >= 0; i--){
        	if(counts[i] > 0){
        		System.out.println(i + " " + counts[i]);
        	}
        }
        
    }
     
} 


Measured memory_bytes: 18192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++)
  {
    int tmp;
    cin >> tmp;
    b.at(i) = tmp;
  }
  int ac = 0;
  for (int i = 0; i < n; i++)
  {
    int s = c;
    for (int j = 0; j < m; j++)
    {
      int v;
      cin >> v;
      s += v*b.at(j);
    }
    if (s > 0)
    {
      ac += 1;
    }
  }
  cout << ac << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;

namespace ConsoleApp15
{
    class Class220
    {
        static void Main()
        {
            var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = NK[0], K = NK[1];
            N %= K;
            Console.WriteLine(Min(N,Abs(N-K)));
        }
    }
}


Measured memory_bytes: 13396
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
	    Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	String ss=s.next();
	String t=s.next();
	
	String s1="";
	
	for(int i=0;i<n;i++)
	s1+=ss.charAt(i)+""+t.charAt(i);
	
	System.out.println(s1);
		}
}

Measured memory_bytes: 21844
using System;

public class A{
    public static void Main(){
        int x,a;
        string[] input = Console.ReadLine().Split();
        x = int.Parse(input[0]);
        a = int.Parse(input[1]);
        if (x<a){
            Console.WriteLine(0);
        }
        else{
            Console.WriteLine(10);
        }
        
    }
}


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

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, v = 1, mv = 0, tmp, x;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> tmp;
		if (abs(tmp)>mv) mv = abs(tmp), v = i, x = (tmp<0) ? 1 : 0;
	}
	cout << 2 * n - 2 << "\n";
	for (int i = 1; i <= n; i++)
		if (i != v) cout << v << " " << i << "\n";
	if (x)
		for (int i = n; i>1; i--)
			cout << i << " " << i - 1 << "\n";
	else
		for (int i = 2; i <= n; i++)
			cout << i - 1 << " " << i << "\n";
}

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

int N, a, ans = 0, t = 1;
int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a;
        if(a == t) {
            ans++;
            t++;
        }
    }
    if(!ans) cout << -1;
    else cout << N - ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        int hagi = 0;
        for(int i=0;i<n;i++){
            
            
            if(s.charAt(i) == 'I'){
                hagi++;
            } else {
                hagi--;
            }
            
            ans =  Math.max(ans,hagi);
        }
        System.out.println(ans);
    }        
}    

Measured memory_bytes: 35336
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int x = 0, y = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')x++;
		if (s[i] == 'D')x--;
		y = max(x, y);
	}
	cout << y << endl;

	return 0;
}

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

#define SIZE 200000

using namespace std;

int main() {
    long long int A,B,i,j,k,N,M,K,Q,D,D2;
    long long int X,Y,Y2;
  //  long long int A[100][100];
    long long int r;

    r = 0;

cin >> N >> D;
D2 = D*D;
for (i=0;i<N;i++) {
  cin >> X >> Y;
  A = X*X;
  B = Y*Y;
  if ((A+B) <= D2)
    r++;
}
  cout << r << endl;

  return 0;

}


Measured memory_bytes: 3620
# ABC051B - Sum of Three Integers
def main():
    K, S = tuple(map(int, input().split()))
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if z < 0:
                break
            if z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll cnt = 1;
    ll ans = n;
    rep(i, n-1) {
        if ( a[i+1] <= a[i] * 2 ) ++cnt;
        else {
            ans -= cnt;
            cnt = 1;
        }
        a[i+1] += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

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

	cin >> a >> b >> c >> d;

	if ((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# ABC084D - 2017-like Number
import sys
input = sys.stdin.readline

from bisect import bisect_left, bisect_right


def get_primes(n):
    # return a list of primes <= n
    n += 1  # include n itself
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def main():
    Q = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(Q))
    _, R = zip(*A)
    lim = max(R)
    P = get_primes(lim)
    S = set(P)
    selected_P = [p for p in P if (p + 1) // 2 in S]
    ans = []
    for l, r in A:
        x = bisect_right(selected_P, r) - bisect_left(selected_P, l)
        ans += [x]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 25140
import itertools
n, k = map(int, input().split())
l = [0] * 100010
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
d = 0
for i in range(1, 100001):
    d += l[i]
    if d >= k:
        print(i)
        break


Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int h, w, n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> n;
    cout << min((n + h - 1) / h, (n + w - 1) / w) << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d, e int
	fmt.Scan(&a, &b, &c, &d, &e)

	res := 300 * 5
	ar := []int{a, b, c, d, e}
	for i, v := range ar {
		tmp := v
		for j := range ar {
			if i == j {
				continue
			}
			tmp += (ar[j] + 9) / 10 * 10
		}

		if tmp < res {
			res = tmp
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int s=0;
	if(a>b)
	s+=b;
	else
	s+=a;
	if(c>d)
	s+=d;
	else
	s+=c;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256