akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  if(s < t) print("Yes");
  else print("No");

}


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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {

        public void Calc()
        {
            //var n = int.Parse(Console.ReadLine());
            //var votes = new Dictionary<string, int>();
            //for (int i = 0; i < n; i++)
            //{
            //    var s = Console.ReadLine();

            //    if (votes.ContainsKey(s))
            //    {
            //        votes[s] += 1;
            //    }
            //    else
            //    {
            //        votes.Add(s, 1);
            //    }
            //}

            //var max = votes.Max(p => p.Value);
            //var elected = votes.Where(p => p.Value == max).Select(p => p.Key).ToArray();
            //Array.Sort(elected, StringComparer.Ordinal);
            //foreach (var a in elected)
            //{
            //    Console.WriteLine(a);
            //}

            var N = int.Parse(Console.ReadLine());
            var Ss = new Dictionary<String, int>();
            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                if (Ss.ContainsKey(s))
                {
                    Ss[s]++;
                }
                else
                {
                    Ss.Add(s, 1);
                }
            }

            var max = Ss.Max(x => x.Value);

            var ans = Ss.Where(x => x.Value == max).Select(x => x.Key).ToArray();

            Array.Sort(ans, StringComparer.Ordinal);

            foreach (var a in ans)
            {
                Console.WriteLine(a);
            }
        }
    }
}

Measured memory_bytes: 40156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n = s.size();
    for (int i = 0; i < n; i++) {
        s[i] -= '0';
    }

    int r = 1 << 30;
    for (int i = 0; i < n - 2; i++) {
        r = min(r, abs(753 - (s[i] * 100 + s[i + 1] * 10 + s[i + 2])));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<set>
#include<algorithm>
#include <queue>

using ll =  long long;
#define rep(i,n) for(int i= 0; i< (n); i++)
using namespace std;
using Graph = vector<vector<int>>;

int main(){

    int n, m;cin >> n >> m;
    int cnt=0;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
   return 0;  
}

Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
int tax(int per,int yen) {return cast(int)(yen * (100 +per) / 100);}
void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		foreach(i;1..s){
			foreach(j;i..s){
				if (tax(x,i) + tax(x,j) == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}

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

bool check(int n,int s[],int t){
  int left=0,right=n;
  while(right-left>=1){
    int mid=(left+right)/2;
    if(s[mid]==t)return true;
    if(s[mid]<t)left=mid+1;
    else right=mid;
  }
  return false;
}

int main(){
  int ans=0;
  int n,s[100005],q,t;
  
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>t;
    if(check(n,s,t))ans++;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3476
// AOJ 2549 7 Age
// 2018.2.5 bal4u

#include <stdio.h>

#define QMAX 250000
typedef struct { int s, t; } Q;
Q que[QMAX+2]; int top, end;

int lo[501], up[501];
int w[501][501];
int p[501];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define MAX(a,b)	((a)>=(b)?(a):(b))

int main()
{
	int n, s, i, j, k, t, dt, ans;

	n = in(), s = in()-1;
	for (i = 0; i < n; i++) lo[i] = in(), up[i] = in();
	for (i = 0; i < n; i++) for (j = 0; j < n; j++) w[i][j] = in();

	for (k = 0; k < n; k++) for (i = 0; i < n; i++) for (j = 0; j < n; j++)
		if ((t = w[i][k] + w[k][j]) < w[i][j]) w[i][j] = t;

	top = end = 0;
	for (i = 0; i < n; i++) if (up[i] > w[s][i]) {
		p[i] = up[i]-MAX(w[s][i], lo[i]);
		que[end].s = i, que[end++].t = up[i];
	}

	while (top != end) {
		k = que[top].s, t = que[top++].t;
		for (i = 0; i < n; i++) if (up[i] > t+w[k][i]) {
			dt = up[i] - MAX(t+w[k][i], lo[i]);
			if (p[i] < p[k] + dt) {
				p[i] = p[k] + dt;
				que[end].s = i, que[end++].t = up[i];
			}
		}
	}
	ans = 0;
	for (i = 0; i < n; i++) if (p[i] > ans) ans = p[i];
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,m;
  int sum=0;
  cin>>n>>m;
  vector<int>a(m);
  rep(i,m) {
    cin>>a[i];
    sum+=a[i];
  }
  if(n>=sum)
    cout<<n-sum<<endl;
  else
    cout<<-1<<endl;
  
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CWhenIHitMyPocket solver = new CWhenIHitMyPocket();
        solver.solve(1, in, out);
        out.close();
    }

    static class CWhenIHitMyPocket {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long k = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            long res = 0;
            long count = a - 1;
            while (count + 1 < k) {
                res += b - a;
                count += 2;
            }
            res += a;
            out.println(Math.max(k + 1, res + k - count));

        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

ll gcd(int a,int b){
  ll r = a%b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main(){
  ll a,b; cin >> a >> b;
  if(a<b){
    swap(a,b);
  }

  ll GCD = gcd(a,b);

  cout << a*b/GCD << endl;

}


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

typedef long long ll;
typedef long double ld;

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

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

int main(){

    string A, B, C;

    cin >> A >> B >> C;

    cout << (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0] ? "YES" : "NO") << endl;

    return 0;
}

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

int main() {
  string S; 
  cin>>S;
  int h=S.size()/2;
  string S1 = S.substr(0,h);
  string S2 = S.substr(h+1,h);
  string Sr = S, S1r = S1, S2r = S2; 

  bool yn = 1;
  reverse(Sr.begin(),Sr.end());
  if(S != Sr){
    yn = 0;
  }
  reverse(S1r.begin(),S1r.end());
  if(S1r != S1){
    yn = 0;
  }
  reverse(S2r.begin(),S2r.end());
  if(S2r != S2){
    yn = 0;
  }
  if(yn){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a+b>=c)
cout<<"Yes";
else
cout<<"No";
system("pause");
return 0;}

Measured memory_bytes: 504
<?php
    fscanf(STDIN, "%d %d", $a, $b);
    $count = array_fill(0,$a,0);
    for ($i=0; $i < $b; $i++) { 
        fscanf(STDIN, "%d %d", $start_road[$i], $end_road[$i]);
        $count[$start_road[$i]-1]++;
        $count[$end_road[$i]-1]++;
    }
    for ($i=0; $i < $a; $i++) { 
        echo ($count[$i]);
        echo ("\n");
    }
?>

Measured memory_bytes: 4604
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
}P;
P Q[LEN];
int head, tail, n;
void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
 }
P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}
int min(int a, int b) {
	return a < b ? a : b;
}
int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	for (i = 1; i <= n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1;
	tail = n + 1;
	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0) enqueue(u);
		else {
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}


Measured memory_bytes: 12724
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<pair<int, int>> XY(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> XY[i].first >> XY[i].second;
    for(int i=0; i<M; i++) XY[i].first--;
    vector<int> cnt(N+1, 0);
    for(int i=0; i<N; i++)
        cnt[A[i]]++;

    vector<int> d(N+2, 0);
    vector<int> v(N+2, 0);
    for(int i=1; i<=N; i++){
        d[max(1, i-cnt[i]+1)]++;
        d[i+1]--;
    }

    for(int i=1; i<=N; i++)
        v[i] = v[i-1] + d[i];

    int ans = 0;
    for(int i=1; i<=N; i++)
        if(v[i] == 0) ans++;

    for(int i=0; i<M; i++){
        int x = A[XY[i].first];
        int y = XY[i].second;

        if(x-cnt[x]+1 >=1){
            if(v[x-cnt[x]+1] == 1) ans++;
            v[x-cnt[x]+1]--;
        }
        cnt[x]--;

        if(y-cnt[y] >= 1){
            if(v[y-cnt[y]] == 0) ans--;
            v[y-cnt[y]]++;
        }
        cnt[y]++;

        A[XY[i].first] = y;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7808
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long N = in.nextLong();
    long[] A = new long[5];
    long min = Long.MAX_VALUE;
    for (int i = 0; i < 5; i++) {
      A[i] = in.nextLong();
      min = Math.min(min, A[i]);
    }
    if (N <= min) {
      System.out.println(5);
    } else {
      int pos = -1;
      while (A[++pos] != min)
        ;
      System.out.println(N / min + (N % min == 0 ? 0 : 1) + 4);
    }
  }
}

Measured memory_bytes: 23892
order = list(map(len, input().split("T")))
x, y = map(int, input().split())
ans = "No"
lon = [order[i] for i in range(len(order)) if i % 2 == 0]
lat = [order[i] for i in range(len(order)) if i % 2 == 1]
x -= lon[0]
lon = lon[1:]
def f(x, A):
  A.append(abs(x))
  A.sort(reverse=True)
  k = A[0]
  for p in A[1:]:
      if k > 0:
        k -= p
      else:
        k += p
  if k == 0:
    return True
  else:
    return False
  
#print(lon, lat)
if f(x, lon) == f(y, lat) == True:
  ans = "Yes"
  
print(ans)

Measured memory_bytes: 3188
from sys import stdin
from collections import deque
input = stdin.readline

s = input().rstrip()
d = deque([])

for i in s:
    if i != "B":
        d.append(i)
    else:
        if d:
            d.pop()
        else:
            pass

while d:
    print(d.popleft(), end="")

print()


Measured memory_bytes: 3316
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  n,k = map(int,input().split())
  l = list(map(int,input().split()))
  
  l = sorted(l,reverse=True)
  
  print(sum(l[:k]))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int H = vs[0];
			int W = vs[1];
			vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int h = vs[0];
			int w = vs[1];
			Console.WriteLine((H - h) * (W - w));
		}
	}
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main{
	static char get(char c) {
		if ((c - '0') == 0)
			return '-';
		return '+';
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char m[] = sc.next().toCharArray();
		int n1 = m[0] - '0';
		int n2 = m[1] - '0';
		int n3 = m[2] - '0';
		int n4 = m[3] - '0';
		for (int i = 0; i < (1 << 3); i++) {
			char[] k = Integer.toBinaryString(8 + i).toCharArray();
			//System.out.println(k);
			int ans = 0;
			ans = (k[1] - '0' == 1) ? n1 + n2 : n1 - n2;

			ans = (k[2] - '0' == 1) ? ans + n3 : ans - n3;

			ans = (k[3] - '0' == 1) ? ans + n4 : ans - n4;
			if (ans == 7) {
				System.out.println(n1 + "" + get(k[1]) + n2 + get(k[2]) + n3 + get(k[3]) + n4 + "=7");
				return;
			}

		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200000+9,mod=1e9+7;
int arr[10000+9];
int main(){
    GO();
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                ll res= i*i+i*j+i*k+j*j+j*k+k*k;
                if(res>10000) continue;
                arr[res]++;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cout<<arr[i]<<" ";
    cout<<"\n";

}




















































































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

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, q, x;
    cin>>n>>k>>q;
    int a[n+1], f[n+1], qq=q;
    for(int i=1; i<=n; i++){a[i]=k;f[i]=0;}
    while(q--)
    {
        cin>>x;
        f[x]++;
    }
    for(int i=1; i<=n; i++)
    {
        if(a[i]-(qq-f[i])<=0)cout<<"No\n";
        else cout<<"Yes\n";
    }
	
	return 0;
}

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

main()
{
    long long n; cin>>n;
    int ans=0;
    for(long long d=2; d*d<=n; ++d)
    {
        int cnt=0;
        while(n%d==0)
        {
            cnt++;
            n/=d;
        }
        for(int i=1; cnt>=i; ++i)
        {
            ++ans;
            cnt-=i;
        }
    }
    if(n>1)
    {
        ++ans;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
} fastio;


/* <Dijkstra> */

template <typename T>
std::vector<T> dijkstra(std::vector<std::vector<std::pair<int,T> > > & G, int s) {
	const T INF = std::numeric_limits<T>::max();
	int n = G.size();
	using n_node = std::pair<T,int>;
	std::vector<T> dist(n,INF);
	std::priority_queue<n_node,std::vector<n_node>,std::greater<n_node> > next;
	next.emplace(0,s);
	while(!next.empty()) {
		n_node t = next.top(); next.pop();
		int i = t.second; T cost = t.first;
		if(dist[i]!=INF) continue;
		dist[i] = cost;
		for(auto e:G[i]) {
			next.emplace(cost+e.second,e.first);
		}
	}
	return dist;
}

/* <Dijkstra> */

signed main() {
	int n,m,s,t;
	std::cin >> n >> m >> s >> t;
	s--;t--;
	using Graph = std::vector<std::vector<std::pair<int, int> > >;
	Graph ga(n);
	Graph gb(n);
	rep(i,m) {
		int u,v,a,b;
		std::cin >> u >> v >> a >> b;
		u--;v--;
		ga[u].emplace_back(v,a); ga[v].emplace_back(u,a);
		gb[u].emplace_back(v,b); gb[v].emplace_back(u,b);
	}
	std::vector<int> adist = dijkstra(ga,s);
	std::vector<int> bdist = dijkstra(gb,t);

	std::vector<int> min_reduce(n);
	int min = adist[n-1]+bdist[n-1];
	min_reduce[n-1] = min;
	for(int i=n-2;i>=0;i--) {
		min = std::min(min,adist[i]+bdist[i]);
		min_reduce[i] = min;
	}

	const int start = 1e15;

	rep(i,n) print(start-min_reduce[i]);

	return 0;
}


Measured memory_bytes: 18976
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;
class mint{
    public:
        ll x;
        static unsigned long long mod;
        static unsigned long long mod_plus;
        mint(){x = 0;}
        mint(ll _x) : x((_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod){}
        /*mint& operator=(const ll &a){
            x = a;
            return *this;
        }*/

        mint operator-(){
            return x == 0 ? 0 : mod - x;
        }
        mint& operator+=(const mint& a){
            if((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint operator+(const mint& a) const{
            mint res(*this);
            return res += a;
        }
        mint& operator-=(const mint& a){
            if((x -= a.x) < 0) x += mod;
            return *this;
        }
        mint operator-(const mint& a) const{
            mint res(*this);
            return res -= a;
        }
        mint& operator*=(const mint& a){
            (x *= a.x)%=mod;
            return *this;
        }
        /*mint& operator*=(const ll& a){
            mint temp(a);
            return *this *= temp;
        }*/
        mint operator*(const mint& a) const{
            mint res(*this);
            return res *= a;
        }
        /*mint operator*(const ll& a) const{
            mint res(*this);
            return res *= a;
        }*/
        mint pow(unsigned long long pw) const{
            mint res(1), comp(*this);
            while(pw){
                if(pw&1) res *= comp;
                comp *= comp;
                pw >>= 1;
            }
            return res;
        }
        //以下、modが素数のときのみ
        mint inv() const{
            mint res(*this);
            return res.pow(mod - 2);
        }
        mint& operator/=(const mint &a){
            (x *= a.inv().x)%=mod;
            return *this;
        }
        mint operator/(const mint &a) const{
            mint res(*this);
            return res /= a;
        }
};
ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
unsigned long long mint::mod = int(1e+9) + 7;
unsigned long long mint::mod_plus = (LLONG_MAX / mint::mod) * mint::mod;
typedef vector<mint> vm;

int main() {
    cin>>N>>K;
    mint ans(0);
    reps(k,K,N + 2){
        ans += (N * 2 - k + 1) * k / 2;
        ans -= ll(k - 1) * k / 2;
        ans += 1;
        //cout<<k<<' '<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
  	int n = sc.nextInt();
  	int[] a = new int[n];
  	for(int i = 0; i < n; ++i){
  		a[i] = sc.nextInt();
  	}
  	
  	int num = 0;
  	for(int i = 0; i < n; ++i){
  		int minj = i;
  		for(int j = i; j < n; ++j){
  			if(a[minj] > a[j]){
  				minj = j;
  			}
  		}
		if(minj != i){
	  		int tmp = a[minj];
  			a[minj] = a[i];
  			a[i] = tmp;
  			num = num + 1;
  		}	
  	}
  	for(int i = 0; i < n; ++i){
  		System.out.print(i == 0 ? a[i] : " " + a[i]);
  	}
  	System.out.println();
  	System.out.println(num);
  }
}

Measured memory_bytes: 26360
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

vector<ll> makeDivisors(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n%i == 0) {
            ret.push_back(i);
            if(i*i != n) ret.push_back(n/i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    /*
    k * (k+1) が 2 * N で割り切れるか
    CRT (Chinese Remainder Theorem)
    */ 
    ll N;
    cin >> N;
    vector<ll> cand = makeDivisors(2 * N);
    vector<ll> ans;
    ans.push_back(2 * N);
    for (ll x : cand) {
        // x と N/x で割った余りが0, -1
        pair<ll, ll> temp = crt({0, -1}, {x, 2 * N / x});
        if (temp.first != 0) {
            ans.push_back(temp.first);
        }
        temp = crt({-1, 0}, {x, 2 * N / x});
        if (temp.first != 0) {
            ans.push_back(temp.first);
        }
    }
    sort(ans.begin(), ans.end());
    for (ll a : ans) {
        if (a == 0) continue;
        cout << a << '\n';
        return 0;
    }
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 3792
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (a, b): (i32, i32) = read();
    println!("{}", (a+b+1)/2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}



signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n;
 cin>>n;
 int ans=1000*((n+999)/1000)-n;
 cout<<ans;

}


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

int main()
{
	ll A, B, C, res = 0;
	cin >> A >> B >> C;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		if (A == B && B == C) {
			cout << -1 << endl;
			return 0;
		}
		ll a = A, b = B, c = C;
		A = (b + c) / 2;
		B = (c + a) / 2;
		C = (a + b) / 2;
		res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
N = len(s)

ans = 0

goal1 = [0]*N
goal2 = [0]*N

for i in range(N):
    if i%2==0:
        goal1[i] = '0'
        goal2[i] = '1'
    else:
        goal1[i] = '1'
        goal2[i] = '0'

ans1 = 0
ans2 = 0

for i in range(N):
    if s[i] != goal1[i]:
        ans1 += 1
    if s[i] != goal2[i]:
        ans2 += 1
ans = min(ans1, ans2)

print(ans)


Measured memory_bytes: 46368
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool four = false;
  rep(i, N) {
    string S;
    cin >> S;
    if (S == "Y") four = true;
  }
  if (four)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n, y, i, j, b, r, t, num;
  double ans, max;

  while(1){

    max = 0.0;
    
    scanf("%d", &n);
    if(n == 0) break;

    scanf("%d", &y);

    
    for(i=0; i<n; i++){
      scanf("%d%d%d", &b, &r, &t);

      if(t == 1){
	ans = (1 + y * (double)r / 100);
    
      }
  
      else{
	ans = 1.0;
	for(j=0; j<y; j++){
	ans *= (1 + (double)r / 100);
	}
	
      }

      if(max < ans){
      num = b;
      max = ans;
      }

    }
    
    printf("%d\n",num);

  }

  return 0;

}

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

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 long long INF = 1LL << 60;

long long h[100010];

long long dp[100010];

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

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

    dp[0] = 0;

    for(int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

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

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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int x,y,z;
        cin>>x>>y>>z;
        swap(x,y);
        swap(x,z);
        cout<<x<<" "<<y<<" "<<z;
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#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 pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N;
  cin >> N;
  string tmp = s;
  sort(all(tmp));
  if(N==1){
    cout << tmp[0] << endl;
    return 0;
  }
  set<string> st;
  for(int i=0;i<(int)s.size();i++){
    for(int j=i;j<(int)s.size() && j-i<5;j++){
      //cout << j-i+1 << endl;
      tmp = s.substr(i,j-i+1);
      st.insert(tmp);
    }
  }
  for(auto x:st){
    //cout << x << endl;
  }
  auto itr = st.begin();
  rep(i,N-1)itr++;
  cout << *itr << endl;

  return 0;
}


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

int main()
{
    string s,c;
    cin >> s;
    c=s;
    reverse(c.begin(),c.end());
    if(s==c){
        cout << "Yes" << endl;
    }else{
        cout  << "No" << endl;
    }
    return 0;
}

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


public class C
{
	public static void Main()	
	{
		long N = GetLong();
		long min = long.MaxValue;
		for(long i = 1; i * i <= N; i++)
		{
			if(N % i > 0)
				continue;
			min = Math.Min(min, F(i, N/i));
		}
		Console.WriteLine(min);
	}

	private static long F(long A, long B)
	{
		return (long)Math.Max(getNumDigits(A), getNumDigits(B));
	}

	private static long getNumDigits(long x)
	{
		long tmp = x;
		long ans = 0;
		while(tmp > 0)
		{
			tmp /= 10;
			ans++;
		}
		return ans;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int n;
	cin >> n;
	int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
	string s;
	rep(i, 0, n)
	{
		cin >> s;
		if (s == "AC")
			c1++;
		else if (s == "WA")
			c2++;
		else if (s == "TLE")
			c3++;
		else
			c4++;
	}
	cout << "AC x " << c1 << endl;
	cout << "WA x " << c2 << endl;
	cout << "TLE x " << c3 << endl;
	cout << "RE x " << c4 << endl;
	return 0;
}

Measured memory_bytes: 3616
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	string s;
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy" << endl;
	if(s == "Cloudy")
		cout << "Rainy" << endl;
	if(s == "Rainy")
		cout << "Sunny" << endl;
	return 0;
}


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

int main(){
    int64_t N;
    int64_t AC = 0;
    int64_t WA = 0;
    int64_t TLE = 0;
    int64_t RE = 0;
    cin >> N;
    vector<string> res(N);
    for(int64_t i = 0; i < N; i++){
        cin >> res.at(i);
        if(res.at(i) == "AC"){
            AC++;
        }else if(res.at(i) == "WA"){
            WA++;
        }else if(res.at(i) == "TLE"){
            TLE++;
        }else{
            RE++;
        }
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

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

int main(){
	int a,b;
	int c;
	cin>>a>>b;
	for(int c=1;c<=1001;c++){
		if(floor(c*0.08)==a&&floor(c*0.1)==b){
			cout<<c<<endl;
			return 0;
		}
	}
	cout<<"-1"<<endl;
	
	
	
}


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

int main() {
  int A, B;
  cin >> A >> B;

  if (A <= 8 && B <= 8)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  return 0;
}

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

using std::max;

const int N=2010;

int n,m,up[N][N];
bool map[N][N],mp[N][N];

void Init() {
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;++i)
		for (int j=0;j<m;++j) {
			char ch=getchar();
			while (ch!='#' && ch!='.') ch=getchar();
			if (ch=='#') map[i][j]=0;
			else map[i][j]=1;
		}
}

int que[N],ans;
void Work(int *up) {
	int top=0; up[m]=-1;
	for (int i=1;i<=m;++i) {
		while (top && up[que[top]]>up[i]) {
			ans=max(ans,(up[que[top]]+1)*(i-que[top-1]));
			top--;
		}
		que[++top]=i;
	}
}

void Solve() {
	for (int i=1;i<n;++i) 
		for (int j=1;j<m;++j) 
			mp[i][j]=map[i][j]^map[i-1][j]^map[i][j-1]^map[i-1][j-1]^1;
	for (int i=1;i<n;++i)
		for (int j=1;j<m;++j) {
			if (mp[i][j]) up[i][j]=up[i-1][j]+1;
			else up[i][j]=0;
		}
	ans=max(n,m);
	for (int i=1;i<n;++i) Work(up[i]);
	printf("%d\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <deque>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    deque<int> A;
    int n, op, d, num;
    cin >> n;
    repi(i, n, 0)
    {
        cin >> op;
        if (op == 0)
        {
            cin >> d >> num;
            d % 2 == 0 ? A.push_front(num) : A.push_back(num);
        }
        else if (op == 1)
        {
            cin >> num;
            cout << A[num] << endl;
        }
        else if (op == 2)
        {
            cin >> d;
            d % 2 == 0 ? A.pop_front() : A.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 4564
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <algorithm>
#define brijesh ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define popb pop_back
#define l1 long long
#define vi vector<int>
#define vl vector<l1>
#define vs vector<string>
using namespace std;
int main() {
    brijesh;
    l1 a,b=0;
    cin>>a;
    char s[a];
    cin>>s;
    for(int i=0;i<a-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            b++;
            i+=2;
        }
    }
    cout<<b<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

class tree{
public:
  int node;
  int parent = -1;
  int sibling = -1;
  int deg = 0;
  int depth = 0;
  int h = 0;
  vector<int> child;
  string type = "";
  void output(){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", node, parent, sibling, deg, depth, h);
    cout << type << endl;
  }
};

vector<tree> bt;
void input(int id, int l, int r){
  bt[id].node = id;
  bt[l].sibling = r;
  bt[r].sibling = l;
  bt[l].parent = id;
  bt[r].parent = id;
  bt[id].deg = 2;
  if( l == -1 ){
    bt[id].deg--;
  }else{
    bt[id].child.push_back(l);
  }
  if( r == -1 ){
    bt[id].deg--;
  }else{
    bt[id].child.push_back(r);
  }
}

void getdepth(int pos, int depth){
  bt[pos].depth = depth;
  for(int i=0; i<bt[pos].child.size(); i++) getdepth(bt[pos].child[i], depth+1);
}

int getheight(int pos, int height){
  if( bt[pos].child.size() == 0 ) return height;
  else{
    int tmp = height;
    for(int i=0; i<bt[pos].child.size(); i++){
      tmp = max(tmp, getheight(bt[pos].child[i], height+1));
    }
    return tmp;
  }
}

int main(void) {

  int n;
  cin >> n;
  bt.resize(n);
  int id, l, r;
  for(int i=0; i<n; i++){
    cin >> id >> l >> r;
    input(id, l, r);
  }
  int root = -1;
  for(int i=0; i<n; i++){
    if( bt[i].parent == -1 ) root = bt[i].node;
  }

  getdepth(root, 0);
  for(int i=0; i<n; i++){
    bt[bt[i].node].h = getheight(bt[i].node, 0);
    if( bt[bt[i].node].parent == -1 ) bt[bt[i].node].type = "root";
    else if( bt[bt[i].node].child.size() == 0 ) bt[bt[i].node].type = "leaf";
    else bt[bt[i].node].type = "internal node";
  }
  for(int i=0; i<n; i++){
    bt[i].output();
  }

  return 0;
}

// EOF

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;

inline int add(int x, int y, int m = mod)
{
	if (x + y < m)
		return x + y;
	return x + y - m;
}

inline int sub(int x, int y, int m = mod)
{
	if (x >= y)
		return x - y;
	return x - y + m;
}

inline int mult(int x, int y, int m = mod)
{
	return x * (LL) y % m;
}

inline int power(int x, LL y, int m  = mod)
{
	int r = 1;
	while(y)
	{
		if (y & 1)
			r = mult(r, x, m);
		x = mult(x, x, m);
		y >>= 1;
	}
	
	return r;
}

const int N = 1 << 18;
int f[N];
int inv[N];

inline int C(int n, int k)
{
	return mult(f[n], mult(inv[k], inv[n - k]));
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	f[0] = 1;
	FOR(i, 1, N)
		f[i] = mult(i, f[i - 1]);
	FOR(i, 0, N)
		inv[i] = power(f[i], mod - 2);
	
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	a = mult(a, power(100, mod - 2));
	b = mult(b, power(100, mod - 2));
	c = add(a, b);
	a = mult(a, power(c, mod - 2));
	b = mult(b, power(c, mod - 2));
	
	int ans = 0;
	
	FOR(i, 0, n)
	{			
		int tut = mult(n + i, power(c, mod - 2));		
		//debug(tut);
		int dod = add(mult(power(a, n), power(b, i)), 
					  mult(power(b, n), power(a, i)));
		
					  
		dod = mult(dod, C(n + i - (i > 0), i));
		ans = add(ans, mult(tut, dod));		
	}	
		
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 2304
import java.io.*;
 
class Main{
    public static void main(String[] args)throws IOException{
		long sum;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
    }
}

Measured memory_bytes: 24352
import Data.Bits
import Data.Array
main = do
  n <- read  <$> getLine
  x' <- getLine
  let x = listArray (0,n) x'
      p = length $ filter (=='1') x'
      pow2_0 = listArray (0,n) (take n (iterate (\t -> (2*t)  `mod` (p+1)) 1))
      pow2_1 = listArray (0,n) (take n (iterate (\t -> (2*t)  `mod` (p-1)) 1))
      r0 = sum [if x ! i == '1' then pow2_0 ! (n-1-i) else 0| i <- [0..n-1]]
      r1 = if p /= 1 
        then sum [if x ! i == '1' then pow2_1 ! (n-1-i) else 0| i <- [0..n-1]]
        else undefined 
      xs = [if x ! i == '1' && p /= 1 then 
        (r1 - pow2_1 ! (n-1-i)) `mod` (p-1) 
        else if x ! i == '1' && p == 1 then -1
        else (r0 + pow2_0 ! (n-1-i)) `mod` (p+1) | i <- [0..(n-1)]]
      ans = fmap (print . f) xs
  sequence ans

f :: Int -> Int
f n
  | n == -1 = 0
  | n == 0 = 1
  | otherwise = 1 + f n'
  where n' = n `mod` popCount n




Measured memory_bytes: 39756
function Main(s) {
  var s = s.split("\n")[0].split(" ").map(e => Number(e));
  var x = s[3], y = s[4];
  var c = s[3] < s[4] ? s[4] * 2:s[3] * 2;
  var sum;
  var min = 10000000001;
  for (var i = 0; i <= c; i += 2) {
    sum = s[0] * x + s[1] * y + s[2] * i;
    min = sum < min ? sum:min;
    if (x > 0) x--;
    if (y > 0) y--;
  }
  console.log(min);
}

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

Measured memory_bytes: 7372
#include<stdio.h>

int main(){
	int i,n,a,b,c,d,e,f,g,h;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);
			printf("%d " ,a*e-b*f-c*g-d*h);
			printf("%d " ,b*e+a*f-d*g+c*h);
			printf("%d " ,c*e+d*f+a*g-b*h);
			printf("%d\n",d*e-c*f+b*g+a*h);
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
  long N,setN,i=0;
  scanf("%ld",&N);
  setN = N;
  
  while(N>=1){
    i=i+N%10;
    N=N/10;
   // printf("%ld %ld\n",N,i);
  }
 // printf("%d %d\n",setN,i)  ;
  if(setN%i==0)printf("Yes");
  else printf("No");
  
  return 0;
}
  

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

int32_t main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int d,t,s;cin>>d>>t>>s;
    if(s*t>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
/*


*/



Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1)break;
        else if (m == -1 || f ==-1){
            printf("F\n");}
        else if ((m + f)>= 80){
            printf("A\n");}
        else if ((m + f)>= 65){
            printf("B\n");}
        else if ((m + f)>= 50){
            printf("C\n");}
        else if ((m + f)>= 30){
            if(r >= 50){printf("C\n");}
            else printf("D\n");}
        else if ((m + f)< 30){
            printf("F\n");}
        }
        return 0;
    }



Measured memory_bytes: 2068
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main(){
    int k,s;
    cin >> k >> s;
    int sum=0;
    int z=0;
    int count=0;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            z=s-i-j;
            if(0<=z && z<=k) count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int n;
    ll a, b;
    cin >> n >> a >> b;
    ll x[n];
    REP(i, n) {
        cin >> x[i];
    }
    ll ans = 0;
    REP(i, n - 1) {
        if ((x[i + 1] - x[i]) * a < b) {
            ans += (x[i + 1] - x[i]) * a;
        } else {
            ans += b;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;
import java.util.regex.Pattern;

public class Main {
    public static void main(final String[] args) {
        final InputStream inputStream = System.in;
        final OutputStream outputStream = System.out;
        final InputReader in = new InputReader(inputStream);
        final PrintWriter out = new PrintWriter(outputStream);
        final Solution solver = new Solution();
        solver.solve(in, out);
        out.close();
    }

    static class Solution {
        void solve(final InputReader in, final PrintWriter out) {
            final String text = in.next().replaceAll(Pattern.quote("?"), ".");
            final String pattern = in.next();
            String minimumText = "~";
            for (int i = 0; i + pattern.length() <= text.length(); i++) {
                if (pattern.matches(text.substring(i, i + pattern.length()))) {
                    final String replacedText = text.subSequence(0, i) + pattern + text.substring(i + pattern.length());
                    if (replacedText.compareTo(minimumText) < 0) {
                        minimumText = replacedText.replaceAll(Pattern.quote("."), "a");
                    }
                }
            }
            if (minimumText.equals("~")) {
                out.println("UNRESTORABLE");
            } else {
                out.println(minimumText);
            }
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(final InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 23508
#include <stdio.h>

int main(){
   int i,a,n,h,m,ma;
 
   scanf("%d",&n);
   ma=a=0;
   scanf("%d",&m);
   for (i=1;i<n;i++) {
      scanf("%d",&h);
      if (h<=m) 
         a++;
      else  {
         if (ma<a) ma=a;
         a=0;
      }
      m=h;
   }
   if (ma<a) ma=a;
   printf("%d\n",ma);
   return 0;
}


Measured memory_bytes: 128