akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict


def prime_factorize(n):
    i = 2
    res = defaultdict(lambda: 0)
    while i * i <= n:
        while n % i == 0:
            res[i] += 1
            n = n // i
        i += 1
    if n != 1:
        res[n] = 1
    res = dict(res)
    return res


def divisor(n):
    i = 1
    res = set()
    while i * i <= n:
        if n % i == 0:
            res.add(i)
            res.add(n // i)
        i += 1
    return res


def solve(n):
    pf1 = prime_factorize(n - 1)
    ans = 1
    for v in pf1.values():
        ans *= v + 1
    ans -= 1
    # print(ans)

    pf2 = divisor(n)
    pf2.remove(1)
    for y in pf2:
        m = n
        while m % y == 0:
            m //= y
        m %= y
        if m == 1:
            ans += 1
    return ans


n = int(input())
print(solve(n))


Measured memory_bytes: 39920
#include <iostream>
#include <string>
#include <cctype>

bool checkString(std::string s) {
  if (s[0] != 'A') {
    return false;
  }
  if (isupper(s[1])) {
    return false;
  }
  int ccount = 0;
  for (int i = 2; i < s.size() - 1; ++i) {
    if (s[i] == 'C') {
      ++ccount;
    } else if (isupper(s[i])) {
      return false;
    }
  }
  if (ccount != 1) {
    return false;
  }
  return islower(s[(s.size() - 1)]);
}

int main() {
  std::string s;
  std::cin >> s;
  if (checkString(s)) {
    std::cout << "AC";
  } else {
    std::cout << "WA";
  }
  std::cout << std::endl;
}



Measured memory_bytes: 256
import math

def GCD(a, b):
    if a > b: 
        return GCD(b, a)
    if a == 0:
        return b
    return GCD(b%a, a)

def LCM(a, b):
    return a * b / GCD(a, b)

def GetSmallest(a, b, c, d):
    # Get smallest multiple 
    tgt = max([a * d, b * c])
    lcm = LCM(c, d)
    if tgt % lcm == 0:
        factor = tgt / lcm
    else:
        factor = tgt / lcm + 1

    cm = factor * lcm
    newA = cm / d
    newB = cm / c

    return newA, newB

N = int(raw_input())
qn = []
for n in xrange(N):
    qn.append(map(int, raw_input().split()))

cur = (qn[0][0], qn[0][1])
for n in xrange(1, N):
    cur = GetSmallest(cur[0], cur[1], qn[n][0], qn[n][1])

print cur[0] + cur[1]

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

int N;
int M;
int K;

int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (int a=0; a<=M; a++) {
    for (int b=0; b<=N; b++) {
      if (a*N+b*M-2*a*b == K) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

void dfs(map<pair<int, int>, int> &e, map<int, vector<int>> &g, vector<int> &edgeid, int cur, int ngnum)
{
    int t = 1;
    if (t == ngnum)
        t++;

    for (auto x : g[cur])
    {
        if (edgeid[e[{cur, x}]] != -1)
            continue;
        edgeid[e[{cur, x}]] = t;
        dfs(e, g, edgeid, x, t);
        t++;
        if (t == ngnum)
            t++;
    }
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    map<pair<int, int>, int> e;
    map<int, vector<int>> g;
    int ans = -1;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        ans = max(ans, (int)g[a].size());
        g[b].push_back(a);
        ans = max(ans, (int)g[b].size());
        e[{a, b}] = i;
        e[{b, a}] = i;
    }
    vector<int> curnum(n, 1);
    vector<int> edgeid(n - 1, -1);
    dfs(e, g, edgeid, 0, -1);
    cout << ans << endl;
    rep(i, n - 1)
    {
        cout << edgeid[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 24832
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main(void)
{
	int iA, iB,iC;
	cin >> iA >> iB>>iC;
	if (iA>iB)
	swap(iA, iB);
	if (iB > iC)
		swap(iB, iC);
	if (iA > iB)
		swap(iA, iB);

	cout << iA << " " << iB << " " << iC << endl;
	return 0;
}


Measured memory_bytes: 3104
from heapq import heappop,heappush
Q=int(input())
M=[input() for i in range(Q)]
A=[]
#heappush(A,-10**10)
B=[]
#heappush(B,10**10)
a=0
b=0
sumb=0
n=0
for q in M:
    if q[0]=='1':
        num,x,y=map(int,q.split())
        sumb+=y
        n+=1
        m=(n+1)//2
        if n==1:
            heappush(A,-x)
            a+=x
            #print(a, b, sumb, n, m, A, B)
            continue
        if -A[0]>=x:
            heappush(A,-x)
            a+=x
            if len(A)>m:
                z=heappop(A)
                a+=z
                heappush(B,-z)
                b+=-z
        else:
            heappush(B,x)
            b+=x
            if len(B)>n-m:
                z=heappop(B)
                b-=z
                heappush(A,-z)
                a+=z
        #print(a,b,sumb,n,m,A,B)
    else:
        if n%2==0:
            print(-A[0],sumb+b-a)
        else:
            print(-A[0],sumb+b-a-A[0])




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

int main(){
  string s; cin>>s;
  if(s[0]=='S')cout<<"Cloudy"<<endl;
  else if(s[0]=='C')cout<<"Rainy"<<endl;
  else if(s[0]=='R')cout<<"Sunny"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	ll n;
	cin >> n;
	vector<ll> d(n + 1, 0);
	rep2(i,1,n+1){
		for (int j = i; j < n + 1;j += i)
			d[j] += 1;
	}
	ll ans = 0;
	rep2(i,1,n+1){
		ans += i * d[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 81340
X = int(input())
list = []

if X == 1:
  list.append(1)

#2^2からスタートするため、X=3も例外として加えなければならない
elif X == 2 or X == 3:
  list.append(2)
  
else:
  for b in range(2, X):
    p = 2
    #X自身になったときに処理できないので
    #<=が必要
    while b ** p <= X:
      list.append(b ** p)
      p += 1
      
print(max(list))
  

Measured memory_bytes: 3060
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0
last = nil
N.times do |i|
  ans += B[A[i]-1]
  ans += C[last] if last == A[i]-2
  last = A[i]-1
end
puts ans


Measured memory_bytes: 1788
import re
input_string = input()
keyence = "keyence"
patterns = ['^.*(keyence)$', '^k.*eyence$', '^ke.*yence$', '^key.*ence$', '^keye.*nce$', '^keyen.*ce$', '^keyenc.*e$', '^keyence.*$']
flag = False
for i in range(len(patterns)):
    result = re.match(patterns[i], input_string)
    if result:
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

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

int main(){
  int n;
  cin >> n;
  n = n % 10;
  if(n == 2 || n == 4 || 5 == n || n == 7 || n == 9){
    cout << "hon\n";
  }else if( n == 0 || n == 1 || 6 == n || n == 8){
    cout <<"pon\n";
  }else {
    cout <<"bon\n";
  }
  return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 1001001001;
    for (int i = 0; i < s.size() - 2; ++i) ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    cout << ans << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
line = [list(map(int, input().split())) for _ in range(m)]
line.sort(key=lambda x: x[1])

ans = 1
now = line[0][1]
for s, g in line[1:]:
    if s >= now:
        ans += 1
        now = g
print(ans)


Measured memory_bytes: 29084
A=[]
for _ in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
for _ in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if b==A[i][j]:
                A[i][j]=0
for k in range(3):
    ans=A[0][k]+A[1][k]+A[2][k]
    if ans==0:
        print("Yes");exit()
for k in range(3):
    ans=A[k][0]+A[k][1]+A[k][2]
    if ans==0:
        print("Yes");exit()
if A[0][0]+A[1][1]+A[2][2]==0:
    print("Yes")
elif A[0][2]+A[1][1]+A[2][0]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N,A,B=map(int,input().split())

if N==1 and A!=B:
  print(0)
elif A>B:
  print(0)
elif N==2 or A==B:
  print(1)
else:
  mi=A*(N-1)+B
  ma=B*(N-1)+A
  print(ma-mi+1)

Measured memory_bytes: 3060
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

void  fun(char c,string s,int l,int n) { 
	if (l==n) { 
		cout << s << endl; 
		return; 
	} 
	for (char i='a';i<=c;i++){ 
		fun(max(c,(char)(i+1)),s+i,l+1,n); 
	} 
} 
 
inline void solve(){ 
    int n; cin>>n; 
    fun('a',"",0,n); 
    return; 
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3568
#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;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int max_num = a[0], min_num = a[0];
    ll sum = 0;
    rep(i, n)
    {
        max_num = max(a[i], max_num);
        min_num = min(a[i], min_num);
        sum += a[i];
    }
    cout << min_num << " " << max_num << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   int ans = 0;
   std::vector<int> s(N);
   for(int i=0; i<N; ++i) {
      std::cin >> s[i];
      ans += s[i];
   }
   std::sort(s.begin(),s.end());

   if(ans%10!=0) {
      std::cout << ans << std::endl;
   }else {
      for(int i=0; i<N; ++i){
	 if((ans-s[i])%10!=0) {
	    std::cout << ans-s[i] << std::endl;
	    return 0;
	 }
      }
      std::cout << 0 << std::endl;
   }
   

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll solve(string s, ll n, char c) {
	bool finish = true;
	for (ll i = 0; i < n; i++) {
		if (s[i] != c) finish = false;
	}
	if (finish) return s.size();
	string t;
	for (ll i = 0; i < n - 1; i++) {
		if (s[i] == c || s[i + 1] == c) t.push_back(c);
		else t.push_back(s[i]);
	}
	return solve(t, n - 1, c);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	string s;
	cin >> s;
	ll n = s.size();

	vector<bool> chk(26, false);
	for (ll i = 0; i < n; i++) chk[s[i] - 'a'] = true;

	ll ans = inf;
	for (ll i = 0; i < 26; i++) {
		if (!chk[i]) continue;
		ans = min(ans, n - solve(s, n, (char)('a' + i)));
	}
	cout << ans << endl;
}


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

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        long k = Long.parseLong(stdIn.next());
        long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            h[i] = Long.parseLong(stdIn.next());
        }

        Arrays.sort(h);

        long ans = 0;
        for (int i = 0; i <= n - k - 1; i++) {
            ans += h[i];
        }
        System.out.println(ans);
    }
}

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

int main () {

  std::vector<int> v[16384];
  int num;
  int depth;
  int N;
  std::string str;

  std::cin >> N;
  for(int i = 0; i < N; ++i) {

    for(int j = 0; j < 16384; ++j) {
      v[j].clear();
    }
    
    std::cin >> str;
    depth = 0;
    for(int j = 0; j < str.size(); ++j) {
      if( str[j] == '[' ) {
	depth += 1;
	num = 0;
      }
      else if( '0' <= str[j] and str[j] <= '9' ) {
	num *= 10;
	num += str[j] - '0';
      }
      else {
	depth -= 1;
	if( num != -1 ) {
	  v[depth].push_back((num+1)/2);
	}
	else {
	  std::sort(v[depth+1].begin(), v[depth+1].end());
	  int sum = 0;
	  for(int k = 0; k < (v[depth+1].size()+1)/2; ++k) {
	    sum += v[depth+1][k];
	  }
	  v[depth].push_back(sum);
	  v[depth+1].clear();
	}
	num = -1;
      }
    }
    std::cout << v[0][0] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1660
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < r.length; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        int[] a = new int[n];
        for (int i = 0; i < a.length - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                a[i]++;
            }
        }
        int[] sum = new int[n + 1];
        for (int i = 0; i < a.length; i++) {
            sum[i + 1] = sum[i] + a[i]; 
        }
        for (int i = 0; i < r.length; i++) {
           System.out.println(sum[r[i]] - sum[l[i]]);
        }
        sc.close();
    }
}

Measured memory_bytes: 82236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,st,e;
    string y;
    cin>>y;
    int l=y.length();
    for(int i=0;i<l;i++)
    {
        if(y[i]=='A')
        {
            st=i+1;
            break;
        }
    }
    for(int i=0;i<l;i++)
    {
        if(y[i]=='Z')
        {
            e=i+1;
        }
    }
    x=e-st+1;
    cout<<x<<endl;
    return 0;
}

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

int main(){
    ll h,w;
    cin>>h>>w;
    vector<vector<ll>> s(h,vector<ll>(w));
    rep(i,h){
        string str;
        cin>>str;
        rep(j,w){
            if(str[j]=='.'){
                s[i][j]=0;
            }else {
                s[i][j]=1;
            }
        }
    }
    ll ans=-1;
    rep(i,h){
        rep(j,w){
            if(s[i][j]==0){
                vector<vector<bool>> used(h,vector<bool>(w,false));
                used[i][j]=true;
                queue<tuple<ll,ll,ll>> que;
                que.push(make_tuple(i,j,0));
                ll mdist=0;
                ll mx=i,my=j;
                while(que.size()){
                    auto now=que.front();
                    que.pop();
                    ll x=get<0>(now);
                    ll y=get<1>(now);
                    ll dist=get<2>(now);
                    if(dist>mdist){
                        mdist=dist;
                        mx=x;
                        my=y;
                    }
                    if(x-1>=0&&s[x-1][y]==0&&!used[x-1][y]){
                        used[x-1][y]=true;
                        que.push(make_tuple(x-1,y,dist+1));
                    }
                    if(x+1<=h-1&&s[x+1][y]==0&&!used[x+1][y]){
                        used[x+1][y]=true;
                        que.push(make_tuple(x+1,y,dist+1));
                    }
                    if(y-1>=0&&s[x][y-1]==0&&!used[x][y-1]){
                        used[x][y-1]=true;
                        que.push(make_tuple(x,y-1,dist+1));
                    }
                    if(y+1<=w-1&&s[x][y+1]==0&&!used[x][y+1]){
                        used[x][y+1]=true;
                        que.push(make_tuple(x,y+1,dist+1));
                    }
                }
                ans=max(ans,mdist);
            }
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

vector< vector<int> > M;

struct Move
{
	int y1;
	int x1;
	int y2;
	int x2;
};

vector<Move> ans;
int H, W;
void move(int h, int w)
{
	if (M[h][w] % 2 == 0)return;
	Move m;
	if (w + 1 < W&&M[h][w + 1] % 2 == 1)
	{
		m.y1 = h + 1; m.x1 = w + 1;
		m.y2 = h + 1; m.x2 = w + 2;
		M[h][w + 1]++;
		ans.push_back(m);
	}
	else if (h + 1 < H&&M[h + 1][w] % 2 == 1)
	{
		m.y1 = h + 1; m.x1 = w + 1;
		m.y2 = h + 2; m.x2 = w + 1;
		M[h + 1][w]++;
		ans.push_back(m);
	}
	else if (w + 1 < W)
	{
		m.y1 = h + 1; m.x1 = w + 1;
		m.y2 = h + 1; m.x2 = w + 2;
		M[h][w + 1]++;
		ans.push_back(m);
	}
	else if (h + 1 < H)
	{
		m.y1 = h + 1; m.x1 = w + 1;
		m.y2 = h + 2; m.x2 = w + 1;
		M[h + 1][w]++;
		ans.push_back(m);
	}
	return;
}

int main()
{
	cin >> H >> W;
	REP(i, H)
	{
		vector<int> w(W);
		REP(j, W)
		{
			cin >> w[j];
		}
		M.push_back(w);
	}

	REP(h, H)
	{
		REP(w, W)
		{
			move(h, w);
		}
	}

	cout << ans.size() << endl;
	REP(i, ans.size())
	{
		cout << ans[i].y1 << " " << ans[i].x1 << " " << ans[i].y2 << " " << ans[i].x2 << endl;
	}
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

class UnionFind
{   
public:
    static const int N_MAX = 1000000;
    int par[N_MAX];
    int n;
    
    UnionFind(int n)
        : n{n}
    {
        for (int i = 0; i < n; ++i) {
            par[i] = i;
        }
    }
    
    int root(int x)
    {
        if (par[x] == x) {
            return x;
        }
        return par[x] = root(par[x]);
    }
    
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) {
            return;
        }
        par[ry] = root(x);
        return;
    }
    
    int groups()
    {
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (root(i) == i)
            ++cnt;
        }
        return cnt;
    }
};


class Edge
{
public:
    ll from;
    ll to;
    ll cost;
    Edge() : to{0}, cost{0} {}
    Edge(ll to, ll cost) : to{to}, cost{cost} {}
    Edge(ll from, ll to, ll cost) : from{from}, to{to}, cost{cost} {}
    bool operator<(const Edge& rhs) const {
        return cost < rhs.cost;
    }
};

long long kruskal(vector<Edge>& edges, long long n)
{
    sort(edges.begin(), edges.end());
    UnionFind uf(n);
    long long min_cost = 0;

    for (Edge e : edges) {
        if (! uf.same(e.from, e.to)) {
            uf.unite(e.from, e.to);
            min_cost += e.cost;
        }
    }
    return min_cost;
}

int main()
{
    ll V, E;
    cin >> V >> E;
    vector<Edge> edges(E);
    ll s, t, w;
    rep(i, 0, E) {
        cin >> s >> t >> w;
        edges[i].from = s;
        edges[i].to = t;
        edges[i].cost = w;
    }
    ll ans;
    ans = kruskal(edges, V);
    cout << ans << endl;
}


Measured memory_bytes: 5192
#include <stdio.h>

int main() {

char ch[2000] = {0};
char W[15] = {0};
int i,j,k,l,m,n,o,p; 

m=0; /* ??????W?????\??? */
while(1) {

scanf("%c" , &W[m]);
/* printf("W[%d]???%c ",m,W[m]); /*W[m]????¢????*/
if(W[m] == '\n') {
break;
}
m = m+1;
}

n=0; /* ?????????T?????\??? */
while(1) {

scanf("%c",&ch[n]);

 /*printf("ch[%d]???%c ",n ,ch[n]); /*  ch[n]????¢???? */
 

if(ch[n] =='T' && ch[n-1] == 'X' && ch[n-2] == 'E' && ch[n-3] == 'T' && ch[n-4] == '_' && ch [n-5] == 'F' && ch[n-6] == 'O' && ch[n-7] == '_' && ch[n-8] == 'D' && ch[n-9] == 'N' && ch[n-10] == 'E') {
/* printf("break??????\n"); */
break;
}
n +=1;
} /*while??\????????????*/


/*??????????????¨?????????????¢????*/
p=0;
for(i=0; i<n; i++){
if(W[0] == ch[i] || W[0] == ch[i]+32 || W[0] == ch[i]-32) {
/* printf("????????????????¢????ch[%d]\n",i); /**/
if(ch[i+m] == ' ' || ch[i+m] == '\n' || W[0] == ch[0]  ) { 
if(ch[i-1] == ' ' || ch[i-1] == '\n' ||  W[0] == ch[0]+32 || W[0] == ch[0]-32){
o=o+1;
/*printf("ch[%d]???%c?????????\n",i,ch[i]); /*??????????¢????*/

for(j=0;j<m; j++) {
if(W[j] == ch[i+j] || W[j] == ch[i+j]+32 || W[j] == ch[i+j]-32){
/*printf("W[%d]???%c ch[%d]???%c\n",j,W[j],i+j,ch[i+j]); /*???= ????¢???????*/
o=o+1;
}
}
}
}

if(o==m+1){
p=p+1;
}
o=0;
}
}

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

return 0;

}



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

int main()
{
	string s;
	cin>>s;
	if((s[0]=='A'&&s[1]=='A'&&s[2]=='A')||(s[0]=='B'&&s[1]=='B'&&s[2]=='B'))
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0; //今までみつかった数
    for(int i = min(A,B); i >= 1; i--)
    {
        if(A % i == 0 && B % i == 0) {
            cnt++;
            if(cnt == K) {
                cout << i << endl;
                return 0;
            }
        }
 
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
int main()
{
    std::istream &istr = std::cin;
    //std::istringstream istr("8 8\n0 0");
    while (true)
    {
        int64_t a, b;
        istr >> a >> b;
        if (a * a + b * b == 0)
        {
            return 0;
        }
        for (int64_t i = 1; i <= a; i++)
        {
            char t[2] = {'#', '.'};

            for (int64_t j = 1; j <= b; j++)
            {
                std::cout << t[(i + j)%2];
            }
            std::cout << "\n";
        }
        std::cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    int K,S,count=0;
    int X,Y,Z;
    cin >> K >> S;

    for(X=0;X<=K;X++){
        for(Y=0;Y<=K;Y++){
            Z = S - X - Y;
            if(Z<=K && Z>=0) count++;
            //cout << X << Y << Z <<endl;
        }
    }
    cout << count << endl;
}

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

int main(){
	/*input*/
	long int a, b;	cin >> a >> b;
	int k;	cin >> k;
	/*calculation*/
	/*output*/
	if((b - a + 1) <= 2*k){
		for(long int i = a; i <= b; i++)cout << i << endl;
	}else{
		for(long int i = 0; i < k; i++)cout << a + i << endl;
		for(long int i = b - k + 1; i <= b; i++)cout << i << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    string S;
    cin >>S;
    map<char,ll> ma;
    ma[S[0]]++;ma[S[1]]++;ma[S[2]]++;ma[S[3]]++;
    bool ans = true;
    for(auto x : ma)if(x.second !=2)ans = false;
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

int n, x;
vector<int> xs;

int gcd(int a, int b) {
    return !b ? a : gcd(b, a%b);
}

int main() {
    scanf("%d%d", &n, &x);
    rep(i, n) {
        int xx; scanf("%d", &xx);
        xs.emplace_back(xx);
    }

    xs.emplace_back(x);
    sort(xs.begin(), xs.end());
    vector<int> difs;
    rep(i, n)
        difs.emplace_back(xs[i + 1] - xs[i]);

    //sort(difs.begin(), difs.end());
    int ans = difs[0];
    if (n > 1) {
        FOR(i, 1, difs.size()) {
            ans = gcd(ans, difs[i]);
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define pno return 0&puts("No")

long long int N, C[555], S[555], F[555], t[555];

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N - 1; ++i)scanf("%lld%lld%lld", C + i, S + i, F + i);
    for(int i = 0; i < N; ++i){
        for(int j = i; j < N - 1; ++j){
            t[i] = ((max(t[i], S[j]) + F[j] - 1) / F[j]) * F[j] + C[j];
        }
    }
    for(int i = 0; i < N; ++i)cout << t[i] << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

using namespace std;

int mx, n, m, x, y;
vector<int> v[100100];
int dp[100100];
int viz[100100];

void dfs(int x) {
    viz[x] = 1;
    int cur = -1;
    for (auto y : v[x]) {
        if (!viz[y])
            dfs(y);
        cur = max(cur, dp[y]);
    }

    mx = max(mx, cur + 1);
    dp[x] = cur + 1;
}

int main() {    
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        v[x].push_back(y);
    }

    for (int i = 1; i <= n; i++)
        if (!viz[i])
            dfs(i);

    cout << mx;

    return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int n,m,c;
vector<P>v[101];
int dp[101][101];
int main(){
    while(cin>>n>>m>>c,n){
        r(i,101)v[i].clear();
        r(i,101)r(j,101)dp[i][j]=1e9;
        r(i,m){
            int a,b,c;
            cin>>a>>b>>c;
            a--;b--;
            v[a].push_back(P(b,c));
        }
        dp[0][0]=0;
        priority_queue<P,vector<P>,greater<P> >q;
        q.push(P(0,0));
        while(!q.empty()){
            int cost=q.top().first;
            int now=q.top().second/10000;
            int num=q.top().second%10000;q.pop();
            r(i,v[now].size()){
                int next=v[now][i].first;
                int cost2=v[now][i].second;
                if(dp[next][num]>dp[now][num]+cost2){
                    dp[next][num]=dp[now][num]+cost2;
                    q.push(P(dp[now][num]+cost2,next*10000+num));
                }
                if(num<n&&dp[next][num+1]>dp[now][num]){
                    dp[next][num+1]=dp[now][num];
                    q.push(P(dp[now][num],next*10000+num+1));
                }
            }
        }
        int ans=1e9;
        r(i,n)if(dp[n-1][i]<c){
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3252
def solve(lscm,m)
    # least semi common multiple
    return ( m / lscm + 1 ) / 2 

end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

b = a.map do |k|
    
    res = 0
    while k.even?
        k /= 2
        res += 1
    end
    res
end
# p a
# p b
ans = 0
if b.uniq.size == 1
    lscm = a.map{|k| k/2}.inject(:lcm)
    # p lscm
    # p a
    # p b
    ans = solve(lscm, m)
end

puts ans



# a/2 * (2p+1)


Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        s = s.substr(0, k) + "...";
    }
    cout << s << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N];
            A[0] = 1;
            for (int i = 1; i < N; i++) {
                A[i] = sc.nextInt() - 1;
            }

            int[] counts = new int[N];
            for (int i = 1; i < N; i++) {
                counts[A[i]]++;
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < N; i++) {
                sb.append(counts[i]).append("\n");
            }
            System.out.println(sb.toString());

        }
    }
}


Measured memory_bytes: 50324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a,b,yp=0,bp=0;
  string s;
  cin >> n >> a >> b >> s;
  for(long i=0;i<n;i++) {
    if(yp<a+b) {
      if(s[i]=='a') {
        cout << "Yes" << endl;
        yp++;
      } else if(s[i]=='b'&&bp<b) {
        cout << "Yes" << endl;
        yp++,bp++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N; cin>>N;
  vi A(2);
  rep(i,0,N){
    int X; cin>>X;
    A[X%2]++;
  }
  string ans="YES";
  if(A[1]%2==1)
    ans="NO";
  cout<<ans<<endl;
  }


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
const int maxn = 100050;

int n, k, a[maxn], cnt, mx, g;

int gcd(int a,int b){return !b?a:gcd(b,a%b);}

int main()
{
	scanf("%d%d",&n,&k);
	fo(i,1,n) {scanf("%d",&a[i]); if(i==1)g=a[i];else g=gcd(a[i],g); if(a[i]==k) return 0*printf("POSSIBLE\n"); mx=max(mx,a[i]);}
	if(mx < k) return 0*printf("IMPOSSIBLE\n");
	if(k%g==0)return 0*printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 640
i = STDIN.gets.to_i

def factorial(n)
  arr = [*1..n]
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end

puts factorial(i) % (10 ** 9 + 7)

Measured memory_bytes: 9692
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    int n;
    cin >> n;
    if(n==1) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a[10000],b[10000],c[10000]={0},d[10000]={0},t;
int main(){
    int i=0;
    while(1){
        cin>>t;
        if(t==0)break;
        for(int z=0;z<t;z++){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                c[i]+=a[i]+b[i];
            }else if(b[i]>a[i]){
                d[i]+=a[i]+b[i];
            }else{
                c[i]+=a[i];
                d[i]+=b[i];
            }
        }
        cout<<c[i]<<" "<<d[i]<<endl;
        i++;
    }
    return 0;
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//セグメント木
//全て添字で扱うこと
template<typename T>
struct segment_tree {
  ll n; //vのサイズ
  ll m = 1; //葉の数
  vector<T> v;
  T id_e; //単位元

  //二項演算
  T seg_func(T a, T b) {
    return (a || b);
  }

  //初期化関数
  void init(vector<T> a, T b) {
    id_e = b;
    while (m < a.size()) m *= 2;
    n = 2 * m - 1;
    vector<T> w(n);
    v = w;
    for (ll i = 0; i < a.size(); i++) v[m - 1 + i] = a[i];
    for (ll i = a.size(); i < m; i++) v[m - 1 + i] = id_e;
    for (ll i = m - 2; i >= 0; i--) {
      v[i] = seg_func(v[2 * i + 1], v[2 * i + 2]);
    }
  }

  //値の更新
  void change(ll a, T b) {
    a += m - 1;
    v[a] = b;
    while ((a - 1) / 2 != a) {
      a = (a - 1) / 2;
      v[a] = seg_func(v[2 * a + 1], v[2 * a + 2]);
    }
  }

  //区間和用の補助関数
  T subsub(ll a, ll b, ll cur, ll l, ll r) {
    if (v[cur] == id_e) return v[cur];
    if (a <= l && r <= b) return v[cur];
    if (r < a || b < l) return id_e;
    if (l < r) {
      return seg_func(
        subsub(a, b, 2 * cur + 1, l, (l + r) / 2),
        subsub(a, b, 2 * cur + 2, (l + r) / 2 + 1, r)
      );
    }
  }

  //区間[a, b]の和
  T subsum(ll a, ll b) {
    if (a == b) return v[m - 1 + a];
    T ans = 0;
    ll cur = 0, l = 0, r = m - 1;
    ans = seg_func(ans, subsub(a, b, cur, l, r));
    return ans;
  }
};

int main() {
  ll n, q;
  string s;
  cin >> n >> s >> q;

  map<char, vector<bool>> m;
  for (char c = 'a'; c <= 'z'; c++) {
    vector<bool> v(n, false);
    for (ll i = 0; i < n; i++) {
      if (s[i] == c) v[i] = true;
    }
    m[c] = v;
  }

  map<char, segment_tree<bool>> mm;
  for (char c = 'a'; c <= 'z'; c++) {
    segment_tree<bool> seg;
    seg.init(m[c], false);
    mm[c] = seg;
  }

  for (ll i = 0; i < q; i++) {
    ll x;
    cin >> x;

    if (x == 1) {
      ll y;
      char c;
      cin >> y >> c;

      if (s[y - 1] == c) continue;

      mm[s[y - 1]].change(y - 1, false);
      mm[c].change(y - 1, true);
      s[y - 1] = c;
    }
    else {
      ll l, r;
      cin >> l >> r;

      ll cnt = 0;
      for (char c = 'a'; c <= 'z'; c++) {
        if (mm[c].subsum(l - 1, r - 1)) cnt++;
      }
      cout << cnt << endl;
    }
  }
}

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

int main() {
    int X, H = 0;
    cin >> X;
    int tmp = X;
    string res = "No";

    while (X /= 10 != 0)
    {
        H += X % 10;
        X /= 10;
    }
    
    if (tmp % H == 0) res = "Yes";

    cout << res << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;
    cin >> n;
    map<ll,ll> mp;
    ll sum=0;
    for(int i=0;i<n;i++){
        int A;
        cin >> A;
        mp[A]++;
        sum+=A;
    }
    int q;
    cin >> q;
    vector<int> B(q);
    vector<int> C(q);
    for(int i=0;i<q;i++){
        cin >> B[i] >> C[i];
    }
    for(int i=0;i<q;i++){
        int b,c;
        b=B[i];
        c=C[i];
        if(mp[b]==0){
            cout << sum << endl;
        }else{
            ll minus=mp[b]*b;
            ll plus=mp[b]*c;
            sum-=minus;
            sum+=plus;
            mp[c]+=mp[b];
            mp[b]=0;
            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 9704
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)

//const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    int res = 0, curr = 0;
    forab(i, 1,n-1) {
       if(a[i] <= a[i-1]){
         ++curr;
       }
       else {
         res = max(res, curr);
         curr = 0;
       }
    }
    res = max(res, curr);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000;
int A[maxn],B[maxn];
typedef long long LL;
void solve()
{
    for(int i = 0;i<=1250;++i)
    {
        A[i] = i*0.08;
        B[i] = i*0.1;
    }
    int a,b;
    cin >> a >> b;
    for(int i = 0;i<=1250;++i)
    {
        if(A[i]==a&&B[i]==b)
        {
            printf("%d\n",i);
            return ;
        }
    }
    printf("-1\n");
    return ;
}
int main()
{
   solve();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int count = 0;
  
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (i * 4 + j * 7 == N) {
        count++;
      }
    }
  }
  if (count > 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define DEBUG(x) cerr << #x << " = " << x << endl

struct SegTree {
    int N;
    vector<int> data;
    SegTree(int size) {
        N = 1;
        while(N < size) N *= 2;
        data.assign(2*N - 1, 0);
    }
    void add(int k, int a) {
        k += N - 1; // leaf
        data[k] += a;
        while(k > 0) {
            k = (k - 1) / 2; // up
            data[k] = max(data[2*k + 1], data[2*k + 2]); // left, right
        }
    }
    int search() {
        return sub(0) - (N - 1);
    }
    int sub(int k) {
        if(k >= N - 1) { // leaf
            return k;
        }
        if(data[2*k + 1] == data[k]) return sub(2*k + 1);
        else return sub(2*k + 2);
    }
};

int main() {
    int N, R, L; cin >> N >> R >> L;
    vector<int> score(N, 0);
    SegTree segt(N);
    int curteam = 0;
    int curtime = 0;
    for(int i = 0; i < R; i++) {
        int k, t, p; cin >> k >> t >> p;
        k--;

        score[curteam] += (t - curtime);
        segt.add(k, p);
        curteam = segt.search();
        curtime = t;
    }
    score[curteam] += (L - curtime);
    cout << distance(score.begin(), max_element(score.begin(), score.end())) + 1 << endl;
}

Measured memory_bytes: 2588
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll dp[100005][2] = {};

int main(){
    string s;
    cin >> s;
    int n = s.length();
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        if(s[i] == '1'){
            dp[i+1][0] += dp[i][0]*2;   dp[i+1][0] %= mod;
            dp[i+1][1] += dp[i][0];     dp[i+1][1] %= mod;
        }else{
            dp[i+1][0] += dp[i][0];     dp[i+1][0] %= mod;
        }

        // 1 - less ならやりたい放題
        dp[i+1][1] += dp[i][1]*3; dp[i+1][1] %= mod;
    }

    cout << (dp[n][0]+dp[n][1])%mod << endl;
    return 0;
}

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

using namespace std;

int main(){
	int x, y, s;
	while(cin>>x>>y>>s, x|y|s){
		int ans = 0;
		for(int i=1; i<s; i++){
			int p, q;
			for( p = (i * 100) / (100+x); p*(100+x)<(i+1)*100; p++);
			p--;
			for( q = ((s-i) * 100) / (100+x); q*(100+x)<(s-i+1)*100; q++);
			q--;
			if( p*(100+x)/100 + q*(100+x)/100 != s ) continue;
			int _p = p * (100+y) / 100;
			int _q = q * (100+y) / 100;
			ans = max(ans, _p+_q);
//			cout << p << " " << q << " " << _p+_q <<  endl;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
	int ikidomari[10];
	int sharyou,daisuu=0;
	
	while(scanf(" %d",&sharyou) != EOF){
		if(sharyou != 0){
			ikidomari[daisuu]=sharyou;
			daisuu++;
		}else{
			daisuu--;
			printf("%d\n",ikidomari[daisuu]);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  long long int a;
  long long int c[200000];
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    c[i] = a - i - 1;
  }
  sort(c, c + n);
  long long int count = 0;
  for(int i = 0;i < (n / 2);i++){
    count += (c[n - i - 1] - c[i]);
  }
  cout << count << endl;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){cin>>arr[i];}
	int i=0,j=k;
	while(j<n){
	    if(arr[i]<arr[j]){cout<<"Yes"<<"\n";}
	    else{cout<<"No"<<"\n";}
	    i++;j++;
	}
	return 0;
}


Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int q; cin >> q;
    rep(i,q) {
        string s,t;
        cin >> s >> t;
        int dp[1010][1010];
        int n = s.size();
        int m = t.size();
        rep(i,m+1) dp[0][m] = 0;
        for(int i = 0;i<n;i++) {
            for(int j = 0;j<m;j++) {
                if(s[i] == t[j]) {
                    dp[i+1][j+1] = max({dp[i][j] + 1,dp[i+1][j],dp[i][j+1]});
                } else {
                    dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
                }
            }
        }
        cout << dp[n][m] << endl;
    }
}


Measured memory_bytes: 7176
#include<iostream>
#include<string>
#include<algorithm>
typedef long long ll;
using namespace std;
const int N=2e5+5;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string str;
	cin>>str;
	int f=0;
	for(int i=0;i<str.length();i++){
		if(str[i]=='7')f=1;
	}
	if(f)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3640