akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int a,b;
	int f;
	int t=0;

	cin>>a>>b;

	if(b<10){
		a=a*10;
	}else if(b/10<10){
		a=a*100;
	}else if(b/10==10){
		a=a*1000;
	}

	f=a+b;

	for(int i=1; i<f+1; ++i){
		if(i*i==f){
			t=1;

		}
	}
	if(t==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}



	return 0;



}


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



struct modCalc{
	int mod;
	int n;
	vector<int> fact,invfact;
	modCalc(){};

	modCalc(int _mod,int _n){
		mod=_mod,n=_n;
		fact.resize(n+1,1);
		invfact.resize(n+1,1);

		for(int i=0;i<n;i++)fact[i+1]=fact[i]*(i+1)%mod;
		invfact[n]=modinv(fact[n]);
		for(int i=n;i>1;i--)invfact[i-1]=invfact[i]*i%mod;
	};

	int modpow(int x,int n){
		int ret=1;
		while(n>0){
			if(n&1)(ret*=x)%=mod;
			(x*=x)%=mod;
			n>>=1;
		}
		return ret;
	}
	int modinv(int x){
		return modpow(x,mod-2);
	}
	int nCm(int x,int y){
		if(y==0)return 1;
		else return fact[x]*invfact[y]%mod*invfact[x-y]%mod;
	}
	int nPm(int x,int y=-1){
		if(y==-1)y=x;
		return fact[x]*invfact[x-y]%mod;
	}
};


signed main() {
	int q;cin>>q;
	vector<int>x(q),d(q),n(q);
	rep(i,q)cin>>x[i]>>d[i]>>n[i];
	int mod=1e6+3;
	modCalc mc(mod,mod-1);
	
	rep(i,q){
	int x0=x[i],d0=d[i],n0=n[i];
	if(x0==0){cout<<0<<endl;continue;}
	if(d0==0){cout<<mc.modpow(x0,n0)<<endl;continue;}
//	if(n0==1){cout<<x0<<endl;continue;}

	int dn=mc.modpow(d0,n0);
	int xd=mc.modinv(d0)*x0%mod;
	if(xd+n0-1>=mod){cout<<0<<endl;continue;}
	int ret=mc.nPm(xd+n0-1,n0)*dn%mod;	
	cout<<ret<<endl;
	}
	

}


Measured memory_bytes: 18816
#include<stdio.h>
int main(void)
{
	int a[3],max=0,t,i;
	for(i=0; i<3; i++)
	{
		scanf("%d", &a[i]);
		if(a[i]>max)
		{
			max=a[i];
			t=i;
		}
	}
	printf("%d\n", a[0]+a[1]+a[2]-a[t]);
	
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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

  if(13 <= a){
    cout << b << endl;
    return 0;
  }
  if(6 <= a){
    cout << b/2 << endl;
    return 0;
  }
  
  cout << 0 << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------
int main(void)
{

	ll n, k;

	cin >> n >> k;

	ll keta = 0;
	while (1)
	{
		if(n<pow(k,keta) )break;


		keta++;

	}

	cout << keta << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, x[1000], i, ans=1000000000, tai=0, j;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i];
    }
    for(i=1;i<=100;i++){
        tai=0;
        for(j=0;j<n;j++){
            tai+=(x[j]-i)*(x[j]-i);
        }
        ans=min(ans, tai);
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;



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

    int n;
    cin >> n;

    if (~n & 1) {
        cout << n << " " << n << " " << n / 2;
    }
    else {
        for (int h = 1; h <= 3500; ++h) {
            for (int w = 1; w <= 3500; ++w) {
                long long prod = n * 1LL * h * w;
                long long sum = 4LL * h * w - n * 1LL * w - n * 1LL * h;
                if (sum <= 0) continue;
                if (prod % sum == 0) {
                    int k = prod / sum;
                    cout << h << " " << w << " " << k;
                    return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
h, w = list(map(int, input().split()))
a = [0]*26
for i in range(h):
    s = input()
    for j in range(w):
        a[ord(s[j]) - ord("a")] += 1

soto = 0
for i in range(26):
    soto += int(4*(a[i] // 4))
    a[i] -= int(4*(a[i] // 4))

amari = 0

if (h + w) % 2 == 1:
    if h % 2 == 0:
        b = h
    else:
        b = w
    if soto < h * w - b:
        print("No")
    else:
        for i in range(len(a)):
            if a[i] % 2 == 1:
                print("No")
                break
            if i == 25:
                print("Yes")

elif h % 2 == 0 and w % 2 == 0:
    if soto == h * w:
        print("Yes")
    else:
        print("No")

else:
    if soto < h * w  - h - w  + 1:
        print("No")
    else:
        flag = 0
        for i in range(26):
            if a[i] % 2 == 1 and flag == 0:
                flag = 1
            elif a[i] % 2 == 1 and flag == 1:
                print("No")
                break
            if i == 25:
                print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;

const int MAXN = 1000*1000 + 7;
const int SS = 1<<20;
const int INF = 1000*1000*1000 + 7;

long long t[MAXN];
int n, m, q;

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

	int T;
	//cin >> T;
	T = 1;
	while(T--)
	{
		string s;
		cin >> s;
		if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
		{
			cout << 3 << '\n';
			continue;
		}
		if(s[0] == 'R' && s[1] == 'R' && s[2] == 'S')
		{
			cout << 2 << '\n';
			continue;
		}
		if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R')
		{
			cout << 2 << '\n';
			continue;
		}
		if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
		{
			cout << 1 << '\n';
			continue;
		}
		cout << 0 << '\n';
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  long long sum = 0;

  for (int i = 1; i <= n; i++)
  {
    if(i%3!=0 && i%5!=0) sum+=i;
  }
  cout << sum << endl;  
}

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



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

  int x[10];
  int y[10];
  vector<int> p(N);

  rep(i,N){
    p[i] = i;
  }

  auto dist = [&](int i,int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return sqrt(dx*dx+dy*dy);
  };


  rep(i,N){
    cin >> x[i] >> y[i];
  }

  int count = 0;

  double sum = 0;

  do{
    rep(i,N-1){
      sum += dist(p[i], p[i+1]);
    }
    count++;
  }while(next_permutation(p.begin(),p.end()));

  printf("%.10f\n", sum / count);

}


Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

ll x;
cin >> x;
cout << (x^1);
  
 eNd();
  return 0;
 
}

Measured memory_bytes: 3636
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#include <map>

using namespace std;

typedef long long LL;

const int inf = 1e9;
LL a,b,c,d;
map<LL,LL>dp;
LL f(LL n){
//	cout << x << endl;
	if(n == 1)return d;
	if(dp.count(n) != 0)return dp[n];
	LL ans=1e18;
	if(n >= 2){
		ans = min(ans, f(n/2)+a+d*(n-n/2*2));
		if(n%2 != 0)ans = min(ans, f((n+1)/2)+a+d*(n%2==0?0:1));
	}
	if(n >= 3){
		ans = min(ans, f(n/3)+b+d*(n-n/3*3));
		if(n%3 != 0)ans = min(ans, f((n+2)/3)+b+d*(n%3==0?0:3-n%3));
	}
	if(n >= 5){
		ans = min(ans, f(n/5)+c+d*(n-n/5*5));
		if(n%5 != 0)ans = min(ans, f((n+4)/5)+c+d*(n%5==0?0:5-n%5));
	}
	if(n*d > 0 && ans > n*d)ans = n*d;
	return dp[n] = ans;
}
signed main(){
	int te;scanf("%d",&te);while(te--){
		dp.clear();
		LL n;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		printf("%lld\n",f(n));
	}

	return 0;
}



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

int main()
{
    int N ,M;
    cin >> N >> M;

    vector<vector<string>> vec(M, vector<string>(2));
    rep(i,M)rep(j,2) cin >> vec[i][j];

    map<string, int> map;
    int ac = 0;
    int wa = 0;
    string tmpNum = "";
    int s = 0;    
    rep(i,M){
        string tmp = vec[i][0] + vec[i][1];
        if(vec[i][1] == "AC" && map[tmp] == 0){
            ac++;
            tmpNum = vec[i][0] + "WA";
            wa += map[tmpNum];
        }
        map[tmp] += 1;
    }
    
    cout << ac << " " << wa << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

using namespace std;

typedef long long ll;

int main() {
    ll N, W;

    scanf("%lld %lld", &N, &W);
    vector<ll> ws(N + 1), cs(N + 1);
    vector<vector<ll>> dp(W + 1, vector<ll>(N + 1));

    for (ll i = 1; i <= N; i++)
        scanf("%lld %lld", &ws[i], &cs[i]);

    for (ll w = 1; w <= W; w++)
        for (ll j = 1; j <= N; j++) {
            dp[w][j] = dp[w][j - 1];
            if (ws[j] <= w)
                dp[w][j] = max(dp[w][j], cs[j] + dp[w - ws[j]][j - 1]);
        }

    printf("%lld\n", dp[W][N]);

    return 0;
}

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

int main() {
    int N, M; cin >> N >> M;

    priority_queue<long long> que;
    for (int i = 0; i < N; ++i) {
        long long A; cin >> A; que.push(A);
    }
    for (int i = 0; i < M; ++i) {
        long long t = que.top(); que.pop();
        que.push(t/2);
    }
    long long res = 0;
    while (!que.empty()) res += que.top(), que.pop();
    cout << res << endl;
}











Measured memory_bytes: 1400
from collections import*
q = deque([])
a,b=map(int,input().split())
for i in range(a):
    c,d=input().split()
    q.append([c,int(d)])
t=0
while len(q)>0:
    tmp=q.popleft()
    if tmp[1]>b:
        tmp[1]-=b
        q.append(tmp)
        t+=b
    else:
        print(tmp[0],tmp[1]+t)
        t+=tmp[1]


Measured memory_bytes: 13272
#!/bin/bash

read h1 m1 h2 m2 k

h=`expr $h2 - $h1`
if [ $m2 -ge $m1 ]; then
        m=`expr $m2 - $m1`
else
        h=`expr $h - 1`
        m=`expr $m2 - $m1 + 60`
fi

ANS=`expr $h \* 60 + $m - $k`
echo "$ANS"

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n,a,ans,user;
  int u[10000],ut[10000];
  string day,time,on;
  string nowd,nowt;
  while(1){
    cin>>n;
    ans=0;
    if(n==0) break;
    for(int i=0;i<1000;i++){
      u[i]=ut[i]=0;
    }
    for(int i=0;i<n;i++){
      cin>>day>>time>>on>>user;
      if(i==0){
	nowd=day;
	nowt=time;
      }
      if(nowd!=day){
	nowd=day;
	nowt=time;
      }
      if(nowt!=time){
	a=(((time[0]-'0')-(nowt[0]-'0'))*10+((time[1]-'0')-(nowt[1]-'0')))*60+(((time[3]-'0')-(nowt[3]-'0'))*10+((time[4]-'0')-(nowt[4]-'0')));
	//	cout<<a<<endl;
	nowt=time;
	if(u[0]==1){
	  for(int j=1;j<1000;j++){
	    if(u[j]==1){
	      ut[j]+=a;
	      ans=max(ans,ut[j]);
	    }
	  }
	}
      }
      if(on=="O") u[user]=0;
      if(on=="I") u[user]=1;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var temp = Console.ReadLine().Split(' ');
			int[] a = new int[3];
			a[0] = int.Parse(temp[0]);
			a[1] = int.Parse(temp[1]);
			a[2] = int.Parse(temp[2]);
			Array.Sort(a);
			Console.WriteLine(a[0]+a[1]);
		}
	}
}

Measured memory_bytes: 13140
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	sc = bufio.NewScanner(os.Stdin)
	mod = 1000000007
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

//ソートする
//sは最初のインデックス fは最後のインデックス
func Sort(ls []float64,l int,r int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if ls[j] < ls[r]{
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort(ls,l,i-1)
	Sort(ls,i+1,r)
}

//配列の大小を指定した要素で比較
//a < bならtrue
func sizeCheck(a []int,b []int,ls []int) bool {
	for _,i:= range ls{
		if a[i] < b[i]{
			return true
		} else if a[i] > b[i] {
			return false
		}
	}
	return false
}

//二次元配列のソート
func Sort2D(ls [][]int,l int,r int,index ...int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if sizeCheck(ls[j],ls[r],index){
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort2D(ls,l,i-1,index ...)
	Sort2D(ls,i+1,r,index ...)
}

func main() {
	s := nextLine()
	dp := make([]int,13)
	dp[0] = 1
	length := len(s)
	n := 1
	for i:=length-1;i>=0;i--{
		nextDp := make([]int,13)
		if string(s[i]) == "?"{
			for j:=0;j<10;j++{
				for k:=0;k<13;k++{
					nextDp[(n*j+k) % 13] += dp[k]
					nextDp[(n*j+k)%13] %= mod
				}
			}
		} else {
			j,_ := strconv.Atoi(string(s[i]))
			for k:=0;k<13;k++{
				nextDp[(n*j+k) % 13] += dp[k]
				nextDp[(n*j+k)%13] %= mod
			}
		}
		n *= 10
		n %= 13
		dp = nextDp
	}
	fmt.Println(dp[5])
}


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

typedef std::vector<int> vi;

struct union_find {
  vi p; union_find(int n) : p(n, -1) { }
  int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
  bool unite(int x, int y) {
    int xp = find(x), yp = find(y);
    if (xp == yp)       return false;
    if (p[xp] > p[yp])  std::swap(xp,yp);
    p[xp] += p[yp], p[yp] = xp;
    return true;
  }
  int size(int x) { return -p[find(x)]; }
};

int N, M;

int main() {
  std::cin >> N >> M;
  union_find uf(N);
  for (int i = 0; i < M; ++i) {
    int u, v;   std::cin >> u >> v;
    uf.unite(u-1, v-1);
  }

  int ans = 0;
  for (int i = 0; i < N; ++i)
    ans = std::max(ans, uf.size(i));
  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 4052
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#define h 1000010
#define ll long long
#define pb push_back
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll int n, m, k, l;
  cin>>n>>m>>k;
  l=((n+(k-1))/k)*k;
  if(l>m) cout<<0<<endl;
  else cout<<((m-l)/k)+1<<endl; 
  return 0;
} 


Measured memory_bytes: 3600
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib> 
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
	char x[104], y[104]; int n, i;
	cin >> n >> x >> y;
	for (i = 0; i < n; i++) cout << x[i] << y[i];
	cout << endl;
}

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

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

  map<int, int> mp;
  for(int i = 0; i < n; i++){
    int t;
    cin >> t;
    mp[t]++;
  }
  int ans = 0;
  for(auto p: mp){
    if(p.first < p.second){
      ans += p.second - p.first;
    }
    if(p.first > p.second){
      ans += p.second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4736
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
'''

def MAIN():
  # T_IN()
  A()


def A():
  num = IN_I()
  lists = IN_L_I()
  lists.sort()

  print(lists[num // 2] - lists[num // 2 - 1])
  return None


def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 14396
#include<iostream>
using namespace std;
int main()
{
    int ans=0;
    string s;
    cin>>s;
    if(s[0]!='C')ans++;
    if(s[1]!='O')ans++;
    if(s[2]!='D')ans++;
    if(s[3]!='E')ans++;
    if(s[4]!='F')ans++;
    if(s[5]!='E')ans++;
    if(s[6]!='S')ans++;
    if(s[7]!='T')ans++;
    if(s[8]!='I')ans++;
    if(s[9]!='V')ans++;
    if(s[10]!='A')ans++;
    if(s[11]!='L')ans++;
    if(s[12]!='2')ans++;
    if(s[13]!='0')ans++;
    if(s[14]!='1')ans++;
    if(s[15]!='6')ans++;
    cout<<ans;
    return 0;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

/**
 *  約数を列挙する
 */
template<typename T>
std::vector<T> divisor(T n, bool sort = true) {
    std::vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    if(sort) std::sort(ret.begin(), ret.end());
    return ret;
}

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

    ll N;
    std::cin >> N;

    auto d = divisor(N);
    ll ans = 0;
    for(const auto& v : d) {
        if(v == 1) continue;
        if(N / (v - 1) == N % (v - 1)) ans += v - 1;
    }
    std::cout << ans << std::endl;

    return 0;
}


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

namespace _20200802ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            if(X>= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static int[] arrayGen()
        {
            string[] input = Console.ReadLine().Split(" ");
            int[] output = new int[input.Length];
            for(var i = 0; i< input.Length; i++)
            {
                output[i] = int.Parse(input[i]);
            }
            return output;
        }
    }
}


Measured memory_bytes: 27528
import java.util.*;

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

        boolean snk[] = new boolean[n+1];

        for(int i = 1; i < n + 1; i++){
            snk[i] = false;
        }

        for(int i = 0;i < k;i++){
            int treat = scan.nextInt();
            for(int j = 0; j < treat; j++){
                int g = scan.nextInt();
                if(!snk[g]) snk[g] = true;
            }
        }

        scan.close();
        for(int i = 1; i < n + 1; i++){
            if(!snk[i]) count++;
        }

        System.out.println(count);

        
    }
}

Measured memory_bytes: 46384
import java.util.Scanner;

public class Main {
    private int n;
    private int[] num;

    public Main(int n, int[] num) {
        this.n = n;
        this.num = num;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
        }

        Main main = new Main(n, num);
        main.insertSort();
    }

    private void insertSort() {
        this.print();
        for (int i = 1; i < n; i++) {
            int key = num[i];
            int j = i - 1;
            while (j >= 0 && num[j] > key) {
                num[j + 1] = num[j];
                j--;
            }
            num[j + 1] = key;
            this.print();
        }
    }

    private void print() {
        for (int k = 0; k < n; k++) {
            System.out.print(num[k]);
            if (k < n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 31988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rRep(i,a,b) for (int i=(a);i>=b;i--)
const int Maxn=100005;
int n,m;
vector <pair <int,int> > v[Maxn];
bool used[Maxn];
int a[Maxn];
bool dfs(int cur,int col)
{
	if (used[cur])
	{
		return a[cur]==col;
	}
	used[cur]=true;
	a[cur]=col;
	for (auto &u:v[cur])
	{
		if (!dfs(u.first,a[cur]+u.second))
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin>>n>>m;
	for (int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,-c));
	}
	for (int i=1;i<=n;i++)
	{
		if (!used[i])
		{
			if (!dfs(i,0))
			{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return false;
}

Measured memory_bytes: 11136
import sys
readline = sys.stdin.readline

# 操作でLとなるべき石と、Rとなるべき石は確定できる
# 左端は必ずLかつB、右端は必ずRかつBである
# 隣り合う石が同じであれば、L->R,R->Lとなる
# 隣り合う石が異なれば、L->L,R->Rとなる

N = int(readline())
S = readline().rstrip()
DIV = 10 ** 9 + 7

if S[0] == "W" or S[-1] == "W":
  print(0)
  exit(0)

D = [None] * (2 * N)

D[0] = "L"
for i in range(1,len(S)):
  if S[i] != S[i - 1]:
    D[i] = D[i - 1]
  else:
    if D[i - 1] == "R":
      D[i] = "L"
    else:
      D[i] = "R"

if D.count("L") != N:
  print(0)
  exit(0)

# 先頭から順にLの数をカウントする
# Rに遭遇したら、そこまでに遭遇したLの数を掛け合わせる
# ただし一回計算したら、選べるLの候補は1減る。
# 選べるLの候補が0になっていたらその時点で0である(掛け算で0になるので実質考慮不要)

L = 0
R = 0
ans = 1
for d in D:
  if d == "L":
    L += 1
    continue
  ans *= L
  ans %= DIV
  L -= 1

# 組み合わせに対して、操作の順番がN!通りある
for i in range(1, N + 1):
  ans *= i
  ans %= DIV
  
print(ans)

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

const int MOD = 1e9 + 7;

class BinomialCoefficients{
  int max;
  int mod;
  long long *fac;
  long long *finv;
  long long *inv;
public:
  long long C(int, int);
  BinomialCoefficients(int, int);
  ~BinomialCoefficients();
};

long long BinomialCoefficients::C(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

BinomialCoefficients::BinomialCoefficients(int mx = 1e6, int md = MOD){
  max = mx;
  mod = md;
  fac = new long long[max];
  finv = new long long[max];
  inv = new long long[max];
  
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < max; ++i){
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

BinomialCoefficients::~BinomialCoefficients(){
  delete [] fac;
  delete [] finv;
  delete [] inv;
}

std::vector<int> factorize(int m){
  std::vector<int> index;
  
  for(int p = 2; p * p <= m; ++p){
    int i = 0;
    while(m % p == 0){
      ++i;
      m /= p;
    }
    
    if(i != 0) index.emplace_back(i);
  }
  
  if(m != 1) index.emplace_back(1);
  
  return index;
}

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int N, M;
  std::cin >> N >> M;
  
  BinomialCoefficients c;
  
  std::vector<int> index = factorize(M);
  
  long long count = 1;
  for(int i : index){
    count *= c.C(N + i - 1, N - 1);
    count %= MOD;
  }
  
  std::cout << count << std::endl;
  
  return 0;
}


Measured memory_bytes: 23680
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s;
int p,len;
vector<char> t;

P add(P a,P b){
  ll x=a.first*b.second+a.second*b.first;
  ll y=a.second*b.second;
  ll z=__gcd(x,y);
  return P(x/z,y/z);
}

int main(){
  while(1){
    cin>>s;
    if(s=="#")break;
    p=0;
    t.clear();
    len=s.size();
    while(p<len){
      t.push_back(s[p]);
      if(s[p]=='n')p+=5;
      else p+=4;
    }
    reverse(t.begin(),t.end());
    P ans;
    if(t[0]=='n')ans=P(0,1);
    else ans=P(90,1);
    ll a=2;
    for(int i=1;i<(int)t.size();i++){
      if(t[i]=='n'){
	ans=add(ans,P(-90,a));
      }else{
	ans=add(ans,P(90,a));
      }
      a*=2LL;
    }

    if(ans.second==1)cout<<ans.first<<endl;
    else cout<<ans.first<<'/'<<ans.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main() {
    int a,b,c,k;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);
    while (k>0) {
        if (c<=b) {
            c*=2;
            k--;
        } else if (b<=a) {
            b*=2;
            k--;
        } else {
            break;
        }
    }
    if (a<b&&b<c) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1644
#include <stdio.h>

int main(void){
    int a[5];
    int k,i,m,n,maxl,length;
    maxl = 0;
    for (i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    for(n=0;n<4;n++){
        for(m=1;m<5;m++){
            length = a[m]-a[n];
            if(maxl<length){
                maxl = length;
            }
        }
    }
        if(maxl>k){
            printf(":(");
        }else{
            printf("Yay!");
        }
    return 0;
    
}

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

int main(void) {
    int a,b; cin >> a >> b;
    string ans; 
    if(a <= b) {
        for(int i=0; i<b; i++) ans+=to_string(a);
    }
    else {
     for(int i=0; i<a; i++) ans+=to_string(b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


n = readint()
ab = [readints() for i in range(n)]


if n%2==1:
    l = -1
    r = 10**9+1
    while l+1 != r:
        m = (l+r)//2
        x = 0
        for i in range(n):
            a,b = ab[i]
            if a<=m:
                x+=1
        if x>=n//2+1:
            r = m
        else:
            l = m
    left = r
    l = -1
    r = 10**9+1
    while l+1 != r:
        m = (l+r)//2
        x = 0
        for i in range(n):
            a,b = ab[i]
            if m<=b:
                x+=1
        if x>=n//2+1:
            l = m
        else:
            r = m
    right = l
    print(right-left+1)
else:
    l = -1
    r = 10**9+1
    while l+1 != r:
        m = (l+r)//2
        x = 0
        for i in range(n):
            a,b = ab[i]
            if a<=m:
                x+=1
        if x>=n//2:
            r = m
        else:
            l = m
    left1 = r

    l = -1
    r = 10**9+1
    while l+1 != r:
        m = (l+r)//2
        x = 0
        for i in range(n):
            a,b = ab[i]
            if a<=m:
                x+=1
        if x>=n//2+1:
            r = m
        else:
            l = m
    left2 = r

    l = -1
    r = 10**9+1
    while l+1 != r:
        m = (l+r)//2
        x = 0
        for i in range(n):
            a,b = ab[i]
            if m<=b:
                x+=1
        if x>=n//2:
            l = m
        else:
            r = m
    right1 = l

    l = -1
    r = 10**9+1
    while l+1 != r:
        m = (l+r)//2
        x = 0
        for i in range(n):
            a,b = ab[i]
            if m<=b:
                x+=1
        if x>=n//2+1:
            l = m
        else:
            r = m
    right2 = l
    ans = 0
    ans += right2+right1 - left2-left1 + 1
    print(ans)







Measured memory_bytes: 99404
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    long long a, b, x;
    cin >> a >> b >> x;

    long long ans;
    if(a != 0) ans = b / x - (a - 1) / x;
    else ans = b / x + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import fractions
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

if n == 1:
    if k == ai[0]:
        print('POSSIBLE')
        exit()
    else:
        print('IMPOSSIBLE')
        exit()

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 88172
import statistics
import math
import datetime
from collections import Counter
import itertools

a, b, c, d, e = map(int, input().split())

if a == 0:
    print(1)
elif b == 0:
    print(2)
elif c == 0:
    print(3)
elif d == 0:
    print(4)
else:
    print(5)


Measured memory_bytes: 11112
x = int(input())
ans = 1
b,p = 2,2
while 1:
    while 1:
        if b ** p <= x:
            if b ** p > ans:    
                ans = b ** p
            p += 1
        else:
            p = 2
            break
    b += 1
    if b ** 2 > x:
        break
print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	void run(){
		int[] a=new int[10000];
		int[] b=new int[10000];
		for(;;){
			int n=sc.nextInt();
			int k=sc.nextInt();
			int m=sc.nextInt()-1;
			if(n==0){
				break;
			}
			Arrays.fill(a, -1);
			for(int i=0; i<n; i++){
				a[i]=i+1;
			}
			int p=m;
			for(int j=n-1; j>0; j--){
				//println("a:"+Arrays.toString(a));
				System.arraycopy(a, 0, b, 0, a.length);
				//println("b:"+Arrays.toString(b));
				System.arraycopy(b, p+1, a, p, n-(p+1));
				//println("a2:"+Arrays.toString(a));
				p=(p+k-1)%j;
			}
			println(""+a[0]);
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.ArrayList;
import java.util.List;
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 s = sc.nextInt();
		sc.close();

		List<String> list = new ArrayList<>();
		String just = String.valueOf(s);
		for (int i = 0; i < k; i++) {
			list.add(just);
		}
		String string = String.valueOf(s - 1);
		if (s == 1 || s == 2) {
			string = "10";
		}
		for (int i = 0; i < n - k; i++) {
			list.add(string);
		}
		System.out.println(String.join(" ", list));
	}
}

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

int main(){
	
	int n; cin>>n;
	int sum{};
	vector<int> b(n-1);
	for(int i=0; i<n-1; i++){
		cin >>b.at(i);
	}
	for(int i=n-1; i>=0; i--){
		if(i==n-1){
			sum += b.at(n-2);
		}
		else if(i==0){
			sum += b.at(0);
		}
		else{
			sum += min(b.at(i),b.at(i-1));
		}
	}
	cout << sum << endl;
	
}

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

int main() {
	int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int min = 1 << 30;
    
    for (int i = 0; i <= (x > y ? x : y); i++){
        int Apizza, Bpizza, ABPizza;
        Apizza = i;
        ABPizza = (((x > y ? x : y) - i) * 2 > 0 ? ((x > y ? x : y) - i) * 2 : 0);
        Bpizza = ((x > y ? y : x) - ((x > y ? x : y) - i) > 0 ? (x > y ? y : x) - ((x > y ? x : y) - i) : 0);

        int64_t cost = (x > y ? a : b) * Apizza + (x > y ? b : a) * Bpizza + c * ABPizza;
        if (min > cost){
            min = cost;
        }
    }

    cout << min << endl;
}

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

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

    for (int i = 0; i < s.size(); i++){
        if (i % 2 == 0){
            zero += "0";
            one  += "1";
        } else {
            zero += "1";
            one  += "0";
        }
    }

    int zero_diff = 0;
    int one_diff  = 0;
    for (int i = 0; i < s.size(); i++){
        if (zero.at(i) != s.at(i)){
            zero_diff++;
        }
        if (one.at(i) != s.at(i)){
            one_diff++;
        }
    } 
    if (zero_diff < one_diff){
        cout << zero_diff << endl;
    }else{
        cout << one_diff << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<ll> a(n);
    for(auto &x:a){
        cin >> x;
    }

    ll count=0;
    for(int i=0;i<n;i++){
        while(a[i]%2==0){
            a[i]/=2;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3696
Imports System

Class A
	Shared Sub Main
		Dim a,b,c As Integer
		Dim inputs() As String
		inputs = Console.ReadLine().Split()
		a = Int32.Parse(inputs(0))
		b = Int32.Parse(inputs(1))
		c = Int32.Parse(inputs(2))
		
		Dim ans As String
		If 	(a = b AndAlso b <> c ) OrElse _
			(b = c AndAlso c <> a ) OrElse _
			(c = a AndAlso a <> b )
			ans = "Yes"
		Else
			ans = "No"
		End If
		Console.WriteLine(ans)
	End Sub
End Class


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll sol = n;
	string S = to_string(n);
	int res = 0;
	rep(i, S.size()) {
		int a = n % 10;
		n = n / 10;
		res += a;
	}
	if (sol % res == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

void printRes( string s )
{
    for( int i = 0; i < s.size() - 1; i++ )
        cout << s[i] << " ";
    cout << s[s.size()-1] << endl;
}

int main()
{
    int n, a[24], x, y;
    string s, t;

    for( int i = 0; i < 10; i++ )
        a[i] = i;
    for( int i = 10; i < 16; i++ )
        a[i] = 15 - i;
    for( int i = 16; i < 24; i++ )
        a[i] = i - 15;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        s = "";
        t = "";
        cin >> x >> y;

        if( 6 <= x && x <= 9 )
        {
            for( int j = x; j < 24; j++ )
            {
                s += a[j] + '0';
                if( a[j] == y )
                    break;
            }
            printRes( s );
        }
        else
        {
            bool judge1 = false, judge2 = false;
            for( int j = x; j >= 0; j-- )
            {
                s += a[j] + '0';
                if( a[j] == y )
                {
                    judge1 = true;
                    break;
                }
            }

            for( int j = x; j < 16; j++ )
            {
                t += a[j] + '0';
                if( a[j] == y )
                {
                    judge2 = true;
                    break;
                }
            }

            if( s.size() < t.size() )
            {
                if( judge1 == 1 )
                    printRes( s );
                else
                    printRes( t );
            }
            else
            {
                if( judge2 == 1 )
                    printRes( t );
                else
                    printRes( s );
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3172
S=input()
MojiNagasa=len(S)
flag=True
if S[0]!="A":
  flag=False
count=0
for i in range(1,MojiNagasa):
  if S[i].isupper():
    if i==1 or i==MojiNagasa-1 or S[i]!='C':
      flag=False
    count+=1
if (count!=1):
  flag=False
print("AC" if flag else "WA")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmp(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<lli, lli>> vec(n);
	rep0(i, n)cin >> vec[i].first >> vec[i].second;
	
	sort(all(vec), cmp);
	lli ans = 0;
	rep0(i, n) {
		//cout << ans << ' ' << vec[i].first << ' ' << vec[i].second << endl;
		ans += vec[i].first;
		if (ans > vec[i].second) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
	return 0;

}

Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>

using namespace std;

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

  int A;
  for (int i;i<N;i++){
    scanf("%d",&A);
    H -= A;
  }
  if(H > 0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 256
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp.gsub("AC", "aC")
aa = [0]
r = 0
s.each_char { |ch|
  if ch == "a"
    r = r + 1
  end
  aa << r
}

for x in 1..q
  a, b = gets.chomp.split.map(&:to_i)
  puts aa[b - 1] - aa[a - 1]
end


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    vector<int> b = a;
    sort(all(b));
    int cnt = 0;
    for(int i=0; i<n; i++) {
        a[i] = lower_bound(all(b), a[i]) - b.begin();
        cnt += abs(a[i] - i) % 2;
    }
    cout << cnt / 2 << endl;

    return 0;
}

// EOF



Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int n,B[100005],a[100005],len;
int main()
{
	  fast;
    cin>>n;
    for (int i=1;i<=n;i++)
       cin>>a[i];
    B[1]=-a[1],len=1;
    for (int i=2;i<=n;i++)
    {
        if (-a[i]>=B[len]) 
				   B[++len]=-a[i];
        else
        {
            int pos=upper_bound(B+1,B+len,-a[i])-B;
            B[pos]=-a[i];
        }
    }
    cout<<len<<endl;
}


Measured memory_bytes: 1024
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int m;
	cin >> m;
	cout << 24+24 - m << endl;

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    int h,a;
    cin>>h>>a;
    int cnt=0;
    while(h>0){
        cnt++;
        h-=a;
        //cout<<h<<endl;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
void add(int &a, int b) {
	a = (a + b);
	if (a >= MOD)a -= MOD;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	int D;
	cin >> D;
	vector<vector<vector<int> > > dp(N + 1, vector<vector<int> >(D, vector<int>(2, 0)));
	dp[0][0][1] = 1;
	for (int i = 0; i < N; i++) {
		for (int d = 0; d < D; d++) {
			for (int j = 0; j < S[i] - '0'; j++) {
				add(dp[i + 1][(d + j) % D][0], dp[i][d][1]);
			}
			{
				int j = S[i] - '0';
				add(dp[i + 1][(d + j) % D][1], dp[i][d][1]);
			}
			for (int j = 0; j < 10; j++) {
				add(dp[i + 1][(d + j) % D][0], dp[i][d][0]);
			}
		}


	}
	int res = (dp[N][0][0] + dp[N][0][1] - 1 + MOD) % MOD;
	cout << res << endl;
}

Measured memory_bytes: 55424
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] a = new int[n][m];
		int[][] b = new int[m][1];
		int[][] output = new int[n][1];

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

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

		for (int i = 0; i< n; i++) {
			for (int j = 0; j < m; j++) {
				output[i][0] += a[i][j] * b[j][0];
			}
		}

		for (int i = 0; i<n; i++) {
			System.out.println(output[i][0]);
		}
	}
}

Measured memory_bytes: 40284
#include <stdio.h>
#define H 5000000

int n;
int s[H];

void maxHeapify(int);
void buildMaxHeap();

int main()
{
  int i;

  scanf("%d", &n);

  for(i=1;i<=n;i++){
    scanf("%d", &s[i]);
  }

  buildMaxHeap();

  for(i=1;i<=n;i++)
    printf(" %d", s[i]);
  printf("\n");

  return 0;
}

void buildMaxHeap()
{
  int i;
 
  for(i=n/2;i>0;i--)
    maxHeapify(i);
}

void maxHeapify(int i)
{
  int l, r, max, tmp;
  
  l = i*2;
  r = i*2+1;
  if(l<=n && s[l]>s[i])
    max = l;
  else max = i;
  if(r<=n && s[r]>s[max])
    max = r;
  if(max!=i){
    tmp = s[i];
    s[i] = s[max];
    s[max] = tmp;
    maxHeapify(max);
  }
}

Measured memory_bytes: 2552
#author: raghav_0901
from math import *

mod = (10**9) + 7


def _in():
    return [int(x) for x in input().split(' ')]


if __name__ == "__main__":
    a, b, n = _in()
    x = b - 1
    if(n < b):
        x = n
    ans = ((a * x) // b) - (a * (x // b))
    print(ans)


Measured memory_bytes: 9108
import java.util.*;

public class Main{
	public static void main(String args[]){
	
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		int i = A;
                int j = B-K+1;
                if(j<i){
                	j=i;
                }
                while(i<A+K && i<j){
                	System.out.println(i);
                	i++;
                }
                while(j <= B){
                	System.out.println(j);
                	j++;
                }
	}	
}

Measured memory_bytes: 22868
A,B=map(int,input().split())
S=input()
num=[str(k) for k in range(10)]

for i in range(A):
  if S[i] not in num:
    print('No')
    exit()
    
if S[A]!='-':
  print('No')
  exit()
  
for j in range(A+1,A+B):
  if S[j] not in num:
    print('No')
    exit()
    
print('Yes')


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

using namespace std;

int main() {
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int value, source_value, count = 0;

		cin >> source_value;
		value = source_value;

		while (value >= 10) {
			count++;

			string str = to_string(value);
			int len = str.size(), max = 0;

			for (int j = 1; j < len; j++) {
				int temp1, temp2;

				temp1 = stoi(str.substr(0, j));
				temp2 = stoi(str.substr(j));

				if (max < temp1 * temp2) {
					max = temp1 * temp2;
				}
			}

			value = max;
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 3260