akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 using namespace std;
 int main() {
     int a;
     int b;
     int c;
     cin >> a >> b >> c;
     if( c >= a ){if(c <= b){
         cout << "Yes" << endl;
     }else{
         cout << "No" << endl;
     } }else{
         cout << "No" << endl;
     }   return 0;
 }

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;

    ll x = a+b;
    ll r;
    ll ans;
    r = floor(n/(double)x);
    ans = a*r;
    if (n%x < a)
    {
        ans += n%x;
    }
    else
    {
        ans += a;
    }
        
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    string s1(1e5, ' ');
    int    n = 0;
    for (int i = 0, e = s.size(); i < e; i += 2) {
        s1[n] = s[i];
        ++n;
    }
    cout << s1.substr(0, n) << endl;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;
const long double PI = acos(-1) ;
int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	long double r ;
	cin>>r ;
	long double ans = 2.00 * PI * r ;
	return cout<<fixed<<setprecision(10)<<ans<<"\n" , 0 ;
}		


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n,x; cin>>n>>x;

    int cnt=1,a=0;
    int l[n];
    rep(i,n)cin>>l[i];
    rep(i,n)
    {
        a+=l[i];
        if(a>x)break;
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math.BigInt
object Main extends App {
  val Array(n, a, b) = readLine.split(" ") map {_.toInt}
  val vs = (readLine.split(" ") map {_.toLong}).sorted.reverse
  println("%.6f".format(vs.take(a).sum.toDouble / a))
  val borderValue = vs.take(a).last
  val borders = vs.count(_ == borderValue)
  val overBorders = vs.count(_ > borderValue)
  println(overBorders match {
    case 0 => ((a to (b min borders)) map {i => countCombinations(borders, i)}).sum
    case _ => countCombinations(borders, a - overBorders)
  })

  def countCombinations(n: Long, r: Long): Long = (f(n) / f(r) / f(n - r)).toLong
  @scala.annotation.tailrec
  def f(n: BigInt, base: BigInt = 1): BigInt = {if (n == 0 || n == 1) base else f(n - 1, base * n)}
}

Measured memory_bytes: 30000
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
#resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)

Measured memory_bytes: 371216
import java.util.*;

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

        for (int i=0; i<n; i++) {
            l[sc.nextInt()]++;
        }

        int ans = 0;
        int remaining = k;
        for (int i=50; i>0; i--) {
            if (l[i] >= remaining) {
                ans += i*remaining;
                remaining = 0;
            } else {
                ans += i*l[i];
                remaining -= l[i];
            }
            if (remaining == 0) {break;} 
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

int main(){
    int N, M;
    cin >> N >> M;
    
    // 段
    vector<int> oks(N+1, true);
    for(int i = 0; i < M; i++){
        int a; cin >> a;
        // 壊れている段
        oks[a] = false;
    }

    // 計算
    vector<long long int> dp(N+1, 0);
    dp[0] = 1;
    for(int now = 0; now <= N; now++){
        for(int next = now + 1; next <= min(N, now + 2); next++){
            if(oks[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
 
namespace relay_c
{
  class Program
  {
    static void Main(string[] args)
    {
      int n = int.Parse(Console.ReadLine());
      long x = (long)Math.Pow(2,n);
      LinkedList<int> a = new LinkedList<int>();
      for (long i = 0; i < x; i++) a.AddLast(int.Parse(Console.ReadLine()));
      while (a.Count > 1)
      {
        int l = a.First.Value;
        a.RemoveFirst();
        int r = a.First.Value;
        a.RemoveFirst();
        a.AddLast(l == r ? l : Math.Abs(l - r));
      }
      Console.WriteLine(a.First.Value);
    }
  }
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    int s;
    for(int i=0;i<N;++i){
        cin >> s;
        A[s-1]=i+1;
    }
    for(int i=0;i<N;i++){
        cout << A[i];
        cout << ' ';
    }
    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

vector<int> divisor(int n){
    vector<int> res;

    for (int i = 1; i*i <= n; ++i) {
        if(n % i == 0){
            res.push_back(i);
            if(i * i != n){
                res.push_back(n / i);
            }
        }
    }

    return res;
}


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

    int n;
    cin >> n;

    vector<int> a(n), l(n), r(n);
    rep(i, n){
        cin >> a[i];
    }

    for (int i = 0; i < n-1; ++i) {
        l[i+1] = __gcd(a[i], l[i]);        
    }
    for(int i = n-1; i >= 1; --i){
        r[i-1] = __gcd(a[i], r[i]);
    }

    int ans = 1;
    rep(i, n){
        ans = max(ans, __gcd(l[i], r[i]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
def main():
    max_lim = 10 ** 18
    _ = int(input())
    A = [int(x) for x in input().split()]
    now = A[0]
    for a in A[1:]:
        if now != -1:
            now *= a
        if a == 0:
            print(0)
            return
        if now > max_lim:
            now = -1
    print(now)

if __name__ == "__main__":
    main()


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

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}

//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}



int main(){
  ll n;
  cin >> n;
  ll p[200005];
  rep(i, n){
    cin >> p[i];
  }
  
  ll ans = n;
  ll max = 1e18;
  
  for(int i = 0; i < n; i++){
    if(p[i] > max) ans--;
    else max = p[i];
  }
  cout << ans << endl;
}

 

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll N, L;
    cin >> N >> L;
    VS s(N);
    rep(i,0,N) cin >> s[i];
    sort(ALL(s));
    rep(i,0,N){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  long long N,D;
  cin>>N>>D;
  
  vector<vector<long long>> vec(N,vector<long long>(2));
  for(int i=0;i<N;i++){
    cin>>vec[i][0]>>vec[i][1];
  }
  
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    if(vec[i][0]*vec[i][0]+vec[i][1]*vec[i][1]<=D*D){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}

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

const int MOD = 1000000007;

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

ll mod_inv(ll x, ll mod) { return mod_pow(x, mod - 2, mod); }

ll mod_comb(int n, int r, ll mod) {
    if (n < r) return 0;
    if (n - r < r) r = n - r;
    ll x = 1, y = 1;
    for (int i = 0; i < r; i++) x = x * (n - i) % mod;
    for (int i = r; i > 0; i--) y = y * i % mod;
    return x * mod_inv(y, mod) % mod;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll a = 0, b = 0;
    for (ll i = 0; i <= x; i++) {
        ll ta = x - i;
        ll tb = y - i * 2;
        if (ta < 0 || tb < 0) continue;
        if (tb * 2 == ta) {
            a = i, b = tb;
            break;
        }
    }
    ll ans = mod_comb(a + b, b, MOD);
    if (a == 0 && b == 0) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n,i,j,visr[10000]={},visc[10000]={},ans=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)
                continue;
            ans+=a[i]*a[j];
            visr[i]=i;
            visc[j]=j;
        }
    }
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); //個数
		int total=in.nextInt(); //許容量
		int[] v = new int[n];//価値
		int[] w = new int[n];//重さ
		for (int i = 0; i < n; i++) {
			v[i] = in.nextInt();
			w[i] = in.nextInt();
		}

		int[] t = new int[total + 1];

		for (int i = 0; i < n ; i++) {

			for (int j = w[i]; j <= total; j++) {

				t[j] = Math.max(t[j], t[j - w[i]] + v[i]);
				//System.out.printf("t[%d]=%d\n",j,t[j]);
			}
		}

		System.out.println(t[total]);
		in.close();
	}
}





Measured memory_bytes: 27108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	if (s[0] == s.back()) {
		if ((s.size() - 3) % 2 == 0) {
			cout << "Second" << endl;
		}
		else {
			cout << "First" << endl;
		}
	}
	else {
		if ((s.size() - 2) % 2 == 0) {
			cout << "Second" << endl;
		}
		else {
			cout << "First" << endl;
		}
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int getgcd(int a , int b)
{
    int c =  a % b;
    while (c){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main()
{
    int a , b , ans;
    while (scanf("%d %d" , &a ,&b)!= EOF){
        if (a > b)
            ans = getgcd(a , b);
        else
            ans = getgcd(b , a);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
struct No{
    int x;
    int id;
};
No a[maxn];

bool cmp(No a,No b)
{
    return a.x<b.x;
}

int main()
{
    int N;
    int x;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>a[i].x;
        a[i].id=i;
    }
    sort(a+1,a+1+N,cmp);
    int pos=N/2;

    int ans[maxn];
    for(int i=1;i<=N;i++){
        int id=a[i].id;
        if(i<=pos) ans[id]=a[pos+1].x;
        else ans[id]=a[pos].x;
    }
    for(int i=1;i<=N;i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int va[n+1];
  for(int i=0;i<n;i++){
    cin>>va[i];
  }
  sort(va,va +n);
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum+=va[i];
  }
  cout<<sum+va[n-1]/2<<'\n';
  return 0;
}


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

const int N = 1e6;
char str[N];


string solve( char one, char two, char three ) {
        string ret = "";
        ret.push_back(one);
        ret.push_back(two);
        ret.push_back(three);
        return ret;
}

set< int > g[500];

int main() {

        int n; scanf("%d", &n);
        scanf("%s", str);

        string s = string(str);

        for(int i = 0; i < n; i++) {
                g[ s[i] ].insert(i);
        }

        set< string > save;

        for(auto x : s) {
                g[x].erase( g[x].begin() );

                for(char L = '0'; L <= '9'; L++) {
                        for( char R = '0'; R <= '9'; R++ ) {
                                if( L == R ) {
                                        if( g[L].size() > 1 ) {
                                                save.insert( solve(x, L, L) );
                                        }
                                } else {
                                        if( g[L].empty() || g[R].empty() ) continue;

                                        auto it = g[L].begin();
                                        auto iit = g[R].end(); iit--;
                                        if( *it < *iit ) {
                                                save.insert( solve(x, L, R) );
                                        }
                                }
                        }
                }

        }

        printf("%d\n", (int)save.size() );





        return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;


int main(){
	int R;
	scanf("%d",&R);

	if(R<1200){
		printf("ABC\n");
	}else if(R<2800){
		printf("ARC\n");
	}else{
		printf("AGC\n");
	}

	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

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

    string ans = s;
    bool rev = false;
    string f = "";
    string b = "";
    rep(i, q){
        int n;
        cin >> n;
        if (n == 1){
            if (rev){
                rev = false;
            }else{
                rev = true;
            }
        }else{
            int F;
            cin >> F;
            char c;
            cin >> c;
            if (rev){
                if (F == 1){
                    b += c;
                }else{
                    f += c;
                }
            }else{
                if (F == 1){
                    f += c;
                }else{
                    b += c;
                }
            }
        }
    }
    if(rev){
        rep(i, s.size()+b.size()+f.size()){
            if (i < b.size()){
                cout << b[b.size()-1-i];
            }else if (i >= b.size() && i < b.size() + s.size()){
                int idx = b.size() + s.size() - 1 - i;
                cout << s[idx];
            }else{
                int idx = i - b.size() - s.size();
                cout << f[idx];
            }
        }
    }else{
        rep(i, s.size()+b.size()+f.size()){
            if (i < f.size()){
                int idx = f.size()-1-i;
                cout << f[idx];
            }else if (i >= f.size() && i < f.size() + s.size()){
                int idx = i - f.size();
                cout << s[idx];
            }else{
                int idx = i - f.size() - s.size();
                cout << b[idx];
            }
        }  
    }
    cout << endl;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  int c = 0;
  for (int i = 0; i < N; i++)
    if (a[i] == c + 1) c++;
  int ans = c ? N - c : -1;
  cout << ans << '\n';
  return 0;
}


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

void func145b() {
  int n;
  string s;
  cin >> n >> s;
  if (n%2 == 1) {
    cout << "No\n";
    return;
  }
  //substr(x, y)
  //x番目からy要素分取得
  //y省略でそれ以降全部
  if (s.substr(0, n/2) == s.substr(n/2)) {
    cout << "Yes\n"; 
  } else {
    cout << "No\n";
  }
}

int main() {
  func145b();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define PI 3.141592653589793
using namespace std;
int main(void){
    double r;
    cin >> r;
    double L = 2*PI*r;
    double A = PI*r*r;
    cout << fixed << setprecision(5) << A << " " << L << endl;
    return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(n);
	READ(k);
	int ncr[2001][2001] = {};
	
	ncr[0][0] = 1;
	FOR (i, 1, 2000)
	{
		ncr[i][0] = 1;
		FOR (j, 1, i)
			ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % mod; 
	}
		
	FOR (j, 1, k)
		if (n + 1 >= k + j) cout << ncr[n - k + 1][j] * ncr[k - 1][j - 1] % mod << endl;
		else cout << 0 << endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],a;
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>pp[i].first;
        pp[i].first--;
    }
    rep(i,n){
        cin>>pp[i].second;
    }
    rep(i,n){
        ans=-INF;
        int a=0,b=i,d=0,cnt=0,e=-INF,f;
        while(1){
            cnt++;
            b=pp[b].first;
            if(b==i){
                f=cnt;
                break;
            }
        }
        b=i;
        cnt=0;
        while(1){
            cnt++;
            a+=pp[b].second;
            if(a>ans){
                ans=a;
                d=cnt;
            }
            b=pp[b].first;
            if(b==i){
                aa[i]=max((m-d)/cnt*max(a,0LL)+ans,m/cnt*max(a,0LL)+e);
                break;
            }
            if(cnt==m){
                aa[i]=ans;
                break;
            }
            if((m-cnt)%f==0){
                e=ans;
            }
        }
    }
    ans=-INF;
    rep(i,n){
        ans=max(ans,aa[i]);
    }
    cout<<ans<<endl;
}

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

int main(){
    
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> count(100003, 0);

    for(int i = 0; i < n; i++){

        if(a[i] == 0){
            count[0]++;
            count[1]++;
        }else{
            count[a[i] - 1]++;
            count[a[i]]++;
            count[a[i] + 1]++;            
        }
    }

    int ans = 0;
    for(int i = 0; i < 100003; i++) ans = max(ans, count[i]);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

ll gcd(ll a, ll b) {
	ll m = a, n = b;
	if (m < n) {
		swap(m, n);
	}
	while (m % n != 0) {
		m = m % n;
		swap(m, n);
	}
	return n;
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = 0;
	ans += b / c - (a - 1) / c;
	ans += b / d - (a - 1) / d;
	ll hoge = c * d / gcd(c, d);
	ans -= b / hoge - (a - 1) / hoge;
	ans = b - a - ans + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	double t, x;
	cin >> t >> x;
	cout << (t / x) << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  reverse(all(h));
  int count=0;
  rep(i,n-1){
    rep2(j,i+1,n){
  if(h[i]<h[j]){
    count++;
    break;
  }
    }
  }
    cout<<n-count<<endl;
  return 0;
    }

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    k = int(input())
    d = deque()

    for i in range(1, 10):
        d.append(str(i))

    n = 0
    ans = [str(i) for i in range(1, 10)]

    while n < k:
        di = d.popleft()
        end_digit = di[-1]

        for i in range(10):
            if abs(int(end_digit) - i) <= 1:
                new_di = di + str(i)
                ans.append(new_di)
                d.append(new_di)

                n += 1

    print(ans[k - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

#define INF 1e+9




int main(){

ios::sync_with_stdio(false);
cin.tie(0);

long long int n;
cin>>n;

long long int a[n+1];
long long int b[n+1]={};
a[1]=1;
for(long long int i=2;i<=n;i++){
cin>>a[i];
b[a[i]]++;
}

for(int i=1;i<=n;i++){
cout<<b[i]<<endl;
}

}


Measured memory_bytes: 6736
#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() {
    string N;
    cin >> N;
    string ans = "No";
    rep(i,N.size()) if (N.at(i) == '7') ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(100000)

vx = [1, -1, 0, 0, 1, 1, -1, -1]
vy = [0, 0, 1, -1, 1, -1, 1, -1]


def dfs(x, y):
    c[y][x] = 0
    for dx, dy in zip(vx, vy):
        nx = x + dx
        ny = y + dy
        if nx < 0 or ny < 0 or nx >= w or ny >= h:
            continue
        if c[ny][nx] == 0:
            continue
        dfs(nx, ny)

while True:
    w, h = map(int, raw_input().split())
    if w == 0:
        break

    c = []
    for _ in range(h):
        c.append(map(int, raw_input().split()))

    cnt = 0

    for y in range(h):
        for x in range(w):
            if c[y][x] == 1:
                cnt += 1
                dfs(x, y)
    print cnt

# def dfs(x, y):
#     C[y][x] = 0
#     for dx,dy in zip([1,1,0,-1,-1,-1,0,1],[0,1,1,1,0,-1,-1,-1]):
#         if 0 <= x+dx < w and 0 <= y+dy < h and C[y+dy][x+dx] == 1:
#             dfs(x+dx, y+dy)
 
# while 1:
#     w,h = map(int,raw_input().split())
#     if w == h == 0: break
#     C = [map(int,raw_input().split()) for _ in xrange(h)]
 
#     ans = 0
#     for y in range(h):
#         for x in range(w):
#             if C[y][x] == 1:
#                 dfs(x, y)
#                 ans += 1
#     print ans    

Measured memory_bytes: 9920
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007

int main()
{
	
	/*ll n,i,w=0,r=0,ans=0;
	bool f=0;
	char c;
	cin>>n;
	cin>>c;
	if(c=='W')
	{
		f=0;
		w++;
	}
	else
	{
		f=1;
		r++;
	}
	FOR(i,n-1)
	{
		cin>>c;
		if(f==0)
		{
			if(c=='W')
				++w;
			else
			{
				f=1;
				r=1;;
			}
		}
		else
		{
			if(c=='R')
			{
				++r;
			}
			else
			{
				ans+=min(w,r);
				w=1;
				f=0;
				r=0;
			}
		}
	}

	if(f==1)
		ans+=min(w,r);

	cout<<ans;*/
	string s;
	int n,i;
	cin>>n;
	cin>>s;
	set<ll> w,r;
	ll ans=0;
	FOR(i,n){
		if(s[i]=='W'){
			w.insert(i);
		}else{
			r.insert(i);
		}
	}
	while(w.size()&&r.size()){
		if(*w.begin()<*r.rbegin()){
			ans++;
			w.erase(w.begin());
			r.erase(*r.rbegin());
		}else{
			break;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 12916
import collections
from collections import deque

n,m = list(map(int,input().split()))
li = [[] for i in range(n)]

for i in range(m):
  a,b = list(map(int,input().split()))
  li[a-1].append(b-1)
  li[b-1].append(a-1)

michi = [None for i in range(n)]
q = deque([0])
while q:
    pop = q.popleft()
    for i in li[pop]:
        if michi[i] is None:
            michi[i] = pop
            q.append(i)
print("Yes")
for i in range(1,len(michi)):
    print(michi[i]+1)

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

int main() {
  int x, y;
  cin >> x >> y ;
  int a,b;
  a=2*x-y/2;
  b=y/2-x;
  if (y%2 != 0)  {
    cout << "No" << endl;
  }
  else if ((a>=0)&&(b>=0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
fun main() {
    val builder = StringBuilder()

    val (n, m, k) = readInputLine().split(" ").map { it.toLong() }

    val aArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()
    val bArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    var accumTime = 0L
    var a = 0
    var b = 0

    // ひとまずAをできるだけ読む
    for (i in 0 until n.toInt()) {
        if (accumTime + aArr[i] <= k) {
            a++
            accumTime += aArr[i]
        } else {
            break
        }
    }

    // 残った時間でBをできるだけ読む
    for (i in 0 until m.toInt()) {
        if (accumTime + bArr[i] <= k) {
            b++
            accumTime += bArr[i]
        } else {
            break
        }
    }

    // Aを読む量を減らしてBを読む量をそれ以上にできるならば入れ替え
    var downAccumTime = 0L
    var upAccumTime = 0L

    var aTmp = a
    var bTmp = b

    while (aTmp > 0 && bTmp != m.toInt()) {
        downAccumTime += aArr[aTmp - 1]
        aTmp--
        while (bTmp != m.toInt()) {
            if (upAccumTime + bArr[bTmp] - downAccumTime + accumTime > k) {
                break
            }
            upAccumTime += bArr[bTmp]
            bTmp++
        }
        if ((a - aTmp < bTmp - b) || ((a - aTmp == bTmp - b) && downAccumTime >= upAccumTime)) {
            accumTime -= downAccumTime - upAccumTime
            a = aTmp
            b = bTmp
            downAccumTime = 0L
            upAccumTime = 0L
        }
    }

    builder.appendln(a + b)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 79016
#include "bits/stdc++.h"
using namespace std;
struct Point {
  int x, y;
  Point(int x, int y) : x(x), y(y) {}
};
int main() {
  int W, H, N; cin >> W >> H >> N;
  Point sta{0, 0};
  Point end{W, H};
  for (int i{0}; i < N; ++i) {
    int x, y, a; cin >> x >> y >> a;
    switch (a) {
      case 1:
        sta.x = max(x, sta.x);
        break;
      case 2:
        end.x = min(x, end.x);
        break;
      case 3:
        sta.y = max(y, sta.y);
        break;
      case 4:
        end.y = min(y, end.y);
        break;
    }
  }
  cout << max(end.x - sta.x, 0) * max(end.y - sta.y, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i;
  int rank1 = 0;
  int rank2 = 0;
  int rank3 = 0;
  int x;
  for (i = 0; i < 10; i++) {
    scanf("%d", &x);
    if (x > rank1) {
      rank3 = rank2;
      rank2 = rank1;
      rank1 = x;
    } else if (x > rank2) {
      rank3 = rank2;
      rank2 = x;
    } else if (x > rank3) {
      rank3 = x;
    }
  }
  printf("%d\n%d\n%d\n", rank1, rank2, rank3);
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>

int main(void)
{
	char road[150];
	int str;
	int i;
	char aka;
	
	while (scanf("%s", road)){
		if (road[0] == '#'){
			break;
		}
		str = strlen(road);
		
		aka = 'A';
		for (i = 0; i < str; i++){
			switch (aka){
			  case 'A':
			  	if (road[i] == '0'){
					aka = 'X';
			  	}
				else {
					aka = 'Y';
				}
				break;
				
			  case 'X':
			  	if (road[i] == '0'){
					aka = 0;
			  	}
				else {
					aka = 'Z';
				}
				break;
				
			  case 'Y':
			  	if (road[i] == '0'){
					aka = 'X';
			  	}
				else {
					aka = 0;
				}
				break;
				
			  case 'Z':
			  	if (road[i] == '0'){
					aka = 'W';
			  	}
				else {
					aka = 'B';
				}
				break;
				
			  case 'W':
			  	if (road[i] == '0'){
					aka = 'B';
			  	}
				else {
					aka = 'Y';
				}
				break;
				
			  case 'B':
			  	if (road[i] == '0'){
					aka = 'Y';
			  	}
				else {
					aka = 'X';
				}
				break;
				
			  default:
			  	i = str;
				break;
			}
		}
		
		if (aka == 'B'){
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    cout<<v[n-1] - v[0] <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();
		int[] dist = new int[n - k + 1];

		for (int i = 0; i < n - k + 1; i++) {
			dist[i] = Math.abs(x[i + k - 1] - x[i]);
			dist[i] += Math.min(Math.abs(x[i + k - 1]), Math.abs(x[i]));

		}

		System.out.println(haimin(dist));

	}

	public static int haimin(int a[]) {
		int d;
		d = a[0];
		for (int i = 0; i <= a.length - 1; i++) {
			if (d >= a[i]) {
				d = a[i];
			}

		}
		return d;
	}

}


Measured memory_bytes: 50752
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        s[0] = s[0].ToUpper();
        s[1] = s[1].ToUpper();
        s[2] = s[2].ToUpper();
        Console.WriteLine("{0}{1}{2}", s[0][0].ToString(), s[1][0].ToString(), s[2][0].ToString());
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    vector<P> p(N);
    rep(i,N) {
        p[i].first = A[i];
        p[i].second = i + 1;
    }

    sort(p.begin(), p.end(), greater<P>());

    set<int> S;
    S.insert(-1);
    S.insert(0);
    S.insert(N + 1);
    S.insert(N + 2);

    ll ans = 0;

    rep(i,N) {
        P q = p[i];
        S.insert(q.second);
        int w, x, y, z;
        decltype(S)::iterator it = S.lower_bound(q.second);
        y = *(++it);
        z = *(++it);
        decltype(S)::iterator it_low = S.lower_bound(q.second);
        x = *(--it_low);
        w = *(--it_low);
        if (w <= 0) w = 0;
        if (x <= 0) x = 0;
        if (y >= N + 1) y = N + 1;
        if (z >= N + 1) z = N + 1;
        ll count = 0;
        count += (x - w) * (y - q.second);
        count += (q.second - x) * (z - y);
        count *= q.first;
        ans += count;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 8980
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
v1=v[0::2]
v2=v[1::2]

v1c=Counter(v1).most_common()
v2c=Counter(v2).most_common()
v1c.append((0,0))
v2c.append((0,0))
#print(v1c[0])
if v1c[0][0]==v2c[0][0]:
    print(min(n-v1c[0][1]-v2c[1][1],n-v1c[1][1]-v2c[0][1]))
else:
    print(n-v1c[0][1]-v2c[0][1])


Measured memory_bytes: 65388
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pl;


int main(){
  int n;
  cin>>n;

  double bun=n;
  if(n%2!=0)
  bun+=1;

  // cout<<setprecision(10)<<bun<<endl;

  // cout<<fixed<<setprecision(10)<<bun/2<<" "<<(double)n<<endl;
  double ans=(bun/2)/(double)n;
  cout<<fixed<<setprecision(10)<<ans<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int A;
    int B;
    int C;
    int D;
    int E;
    int ans = 0;
    
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> E;
    
    if (A < 0) {
        int min_val = min(0, B);
        ans += abs((A - min_val) * C);
        A = min_val;
    }
    if (A == 0 && A < B) {
        ans += D;
    }
    if (A < B) {
        ans += (B - A) * E;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> list = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
			//int a = Integer.parseInt(aa);
			//int b = Integer.parseInt(bb);
			int cal =0;
			
			if(op.charAt(0) == '?'){
				break;
			}
			else{
				if(op.charAt(0) == '+'){
					cal = a + b;
				}
				if(op.charAt(0) == '-'){
					cal = a - b;
				}
				if(op.charAt(0) == '*'){
					cal = a * b;
				}
				if(op.charAt(0) == '/'){
					cal = a / b;
				}
				list.add(cal);			
			}
		}
		for(int i=0;i<list.size();i++){
			System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 26176
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

VV<V<ll>> dp;
string S;

ll calc(ll l, ll r, ll rest) {
    if(r < l) return 0;
    if(l == r) {
        if(rest) return 1;
        else return S[l] == S[r];
    }
    
    auto &d = dp[l][r][rest];
    if(d != -1) return d;

    if(S[l] == S[r]) chmax(d, calc(l + 1, r - 1, rest) + 2);
    else if(rest) chmax(d, calc(l + 1, r - 1, rest - 1) + 2);
    chmax(d, calc(l + 1, r, rest));
    chmax(d, calc(l, r - 1, rest));

    return d;
}

int main() {
    dp = make_v<ll>(-1, 302, 302, 302);
    ll K;
    cin >> S >> K;
    cout << calc(0, S.size() - 1, K) << endl;
    return 0;
}


Measured memory_bytes: 219776
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,j,a[100001],cnt;
	long long sum,x,b[100001],y;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	b[0]=0;
	for(i=1;i<=n;i++)	b[i]=(b[i-1]+a[i])%m;
	sort(b,b+n+1);
//	for(i=0;i<=n;i++)	printf("%lld ",b[i]);	printf("\n");
	x=b[0];	cnt=1;
	sum=0;
	for(i=1;i<=n;i++)	{
		if(x==b[i])	cnt++;
		else {
			y=(long long)cnt*(cnt-1)/2;
			sum+=y;
			x=b[i];
			cnt=1;
		}
	}	
	y=(long long)cnt*(cnt-1)/2;
	sum+=y;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1280
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let k: usize = util::get();

    let mut deq = VecDeque::new();
    deq.push_front((1, 1));
    let mut visited = vec![false; k];

    loop {
        let (n, c) = deq.pop_front().unwrap();
        if n == 0 {
            println!("{}", c);
            break;
        }

        if visited[n] {
            continue;
        }

        visited[n] = true;

        deq.push_front((10 * n % k, c));
        deq.push_back(((n + 1) % k, c + 1));
    }
}


Measured memory_bytes: 6396
#include <stdio.h>

int main(){
    char S[20]={0};
    char T[20]={0};
    scanf("%s", S);
    scanf("%s", T);

    int flag = 1;
    int i = 0;
    while(S[i]){
        if(S[i]!=T[i]){
            flag = 0;
        }
        i++;
    }
    if(T[i]==0){
        flag = 0;
    }
    if(T[i+1]!=0 && i!=9){
        flag = 0;
    }
    if(flag==0){
        puts("No");
    }else{
        puts("Yes");
    }
    return 0;
}

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

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string a;
    string b;
    cin>>a>>b;
    if(a.size()+1 != b.size())
        cout<<"No"<<endl;
    else{
        for(int i=0; i<a.size(); i++){
            if(a[i]!=b[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int N;
  cin>>N;
  vector<string> vec(N);
  cinv(vec,0,N);
  int flag=0;
  int res=0;
  FOR(i,0,N){
    FOR(j,0,N){
      FOR(k,0,N){
        if(vec[(j+i)%N][k]!=vec[(k+i)%N][j]) flag=1;
      }
    }
    if(flag==0)res++;
    flag=0;
  }
  cout<<res*N<<endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}



Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String[] sl;

    s = r.readLine();
    sl = s.split(" ");
    long n = Integer.parseInt(sl[0]);
    long m = Integer.parseInt(sl[1]);

    s = r.readLine();
    String t = r.readLine();

    long v = gcd(n, m);
    long z = n * m / v;
    for(long i = 0; i < n * m; i += z)
    {
      if(s.charAt((int)(i / m)) != t.charAt((int)(i / n)))
      {
        //System.out.println(i);
        System.out.println("-1");
        System.exit(0);
      }
    }

    System.out.println(z);

  }


  public static long gcd(long n, long m)
  {
    long t;
    if(n < m)
    {
      t = n;
      n = m;
      m = t;
    }

    while(m != 0)
    {
      n %= m;
      t = n;
      n = m;
      m = t;
    }

    return n;
  }

}

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

ll n;
vector<pair<long long,long long> >prime_factorize(long long N){
    vector<pair<long long, long long>> res;
    for(long long a=2;a*a<=N;a++){
        if(N%a!=0) continue;
        long long ex=0;
        while(N%a==0){
            ex++;
            N /= a;
        }
        res.push_back({a,ex});
    }
    if(N!=1) res.push_back({N,1});
    return res;
}

int main(){
    cin >> n;
    vector<ll> ex(n+1,0);
   for(long long i=2;i<=n;i++){
       const auto &res = prime_factorize(i);
       for(auto p:res) ex[p.first] +=p.second;
   }
   ll count75=0;
   ll count25=0;
   ll count15=0;
   ll count5=0;
   ll count3=0;
   for(ll i=0;i<=n;i++){
       if(ex[i]>=74) count75++;
       if(ex[i]>=24) count25++;
       if(ex[i]>=14) count15++;
       if(ex[i]>=4) count5++;
       if(ex[i]>=2) count3++;
   }
   ll res=count75+count25*(count3-1)+count15*(count5-1)+count5*(count3-2)*(count5-1)/2;
   cout << res << endl;
   return 0;
}  


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

int n;
vector <pair <int, int> > a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int g, s, b;
    cin >> g >> s >> b;
    n = g + s + b;
    a.resize(n);
    ll ans = 0;
    for(auto &i : a){
        int c;
        cin >> i.first >> i.second >> c;
        ans += c;
        i.first -= c;
        i.second -= c;
    }
    sort(a.begin(), a.end(), [&](pair <int, int> l, pair <int, int> r){
        return l.first + r.second > r.first + l.second;
    });
    vector <ll> suff(n, -1);
    multiset <int> t;
    ll sum = 0;
    for(int i = n - 1 ; i >= 0 ; i--){
        sum += a[i].second;
        t.insert(a[i].second);
        if((int)t.size() > s){
            sum -= *t.begin();
            t.erase(t.begin());
        }
        if((int)t.size() == s){
            suff[i] = sum;
        }
    }
    t.clear();
    sum = 0;
    ll mx = -1e18;
    for(int i = 0 ; i + 1 < n ; i++){
        if(suff[i + 1] == -1) break;
        sum += a[i].first;
        t.insert(a[i].first);
        if((int)t.size() > g){
            sum -= *t.begin();
            t.erase(t.begin());
        }
        if((int)t.size() == g){
            mx = max(mx, sum + suff[i + 1]);
        }
    }
    cout << ans + mx << endl;
}


Measured memory_bytes: 6272