akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  int N, n[200], d[200], x[200], y[200], mx, my, Mx, My;
  while (1) {
    scanf("%d", &N);
    if (N == 0) break;
    x[0] = y[0] = 0;
    mx = my = Mx = My = 0;
    for (int i = 1; i < N; i++) {
      scanf("%d%d", &n[i], &d[i]);
      x[i] = x[n[i]] + dx[d[i]];
      y[i] = y[n[i]] + dy[d[i]];
      mx = min(mx, x[i]);
      Mx = max(Mx, x[i]);
      my = min(my, y[i]);
      My = max(My, y[i]);
    }
    printf("%d %d\n", Mx - mx + 1, My - my + 1);
  }
}


Measured memory_bytes: 2728
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int P, Q, R;
  std::cin >> P >> Q >> R;
  std::cout << min({P+Q, P+R, Q+R}) << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int dp[k+1]={0};
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>=a[j] && dp[i-a[j]]==0)
            dp[i]=1;
        }
    }
    if(dp[k]==1)
    cout<<"First";
    else 
    cout<<"Second";
    return 0;
}


Measured memory_bytes: 640
A,B,C,K = map(int,input().split())


# a = [1]*A
# b = [0]*B
# c = [-1]*C
# u = a + b + c
# u.sort(reverse=True)
ans = 0
if K <= A:
    ans = K
if K > A and K <= A + B:
    ans = A
if K > A + B:
    ans = A - (K-A - B)


# ans = 0
# for i in range(K):
#     ans += u[i]

print(ans)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=1e5+51;
unordered_map<ll,ll>mp;
ll cnt,x;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	cnt=read();
	for(register int i=0;i<cnt;i++)
	{
		x=read();
		if(mp.find(x)!=mp.end())
		{
			return puts("NO"),0;
		}
		mp[x]=1;
	}
	puts("YES");
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t N, K;
  cin >> N >> K;
  int64_t result;
  if (K >= N) {
    result = min(K - N, N);
  }
  else {
    result = min(K - N % K, N % K);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
alphabet_small = {chr(i):i-97 for i in range(97, 97+26)}
s = input()
k = int(input())
ans =""
for character in s:
    i = alphabet_small[character]
    #print(i,character)
    if i != 0 and k >= 26 - i:
        k -= 26 - i
        ans += "a"
    else:
        ans += character


if k > 0:
    k %= 26
    ans = ans[:-1] + chr((alphabet_small[ans[-1]]+k)%26+97)

print(ans)

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

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=a;i<=min(a+k-1,b);i++)
    cout<<i<<endl;
  for(int i=max(a+k,b-k+1);i<=b;i++)
    cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[220];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i=1;i<=n;i+=2)
	{
		a[i]=0;
		for (int j=1;j<=i;j++)
		{
			if (i%j==0) a[i]++;
		}
	}
	int jsq=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]==8) jsq++;
	}
	cout<<jsq;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int K = 102;
const long long M = 1000000007;

int n, k;

long long dp[N][K];
long long p[N][K];

int main()
{
    cin >> n >> k;
    vector<int> v;
    for (int x = 1; x * x <= n; ++x)
    {
        v.push_back(x);
        if (n / x != x)
            v.push_back(n / x);
    }
    sort(v.begin(), v.end());
    dp[0][0] = 1;
    for (int j = 0; j < v.size(); ++j)
        p[0][j] = 1;
    for (int i = 1; i <= k; ++i)
    {
        int j0 = v.size() - 1;
        for (int j = 0; j < v.size(); ++j)
        {
            while (v[j] * 1LL * v[j0] > n)
                --j0;
            if (j == 0)
                dp[i][j] = p[i - 1][j0];
            else
                dp[i][j] = (p[i - 1][j0] * (v[j] - v[j - 1])) % M;
        }
        p[i][0] = dp[i][0];
        for (int j = 1; j < v.size(); ++j)
            p[i][j] = (p[i][j - 1] + dp[i][j]) % M;
    }
    cout << p[k][v.size() - 1] << endl;
    return 0;
}


Measured memory_bytes: 5244
#include<stdio.h>
int main()
{
  char s[4];
  scanf("%s", s);
  if(s[1]==s[2]){
    if(s[0]==s[1] || s[3]==s[2]) printf("Yes\n");
    else printf("No\n");
  }else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
//codeforces
//
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define inf 1e9+7
#define int64 long long
#define VI vector < int >
#define all(v) v.begin(),v.end()
#define inpv(v) for(auto &x:v) cin>>x
#define pii pair < int , int >
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
const int64 inf = 1e9+7;
const char nwl = '\n';

int main()
{
	//ur code
  	int64 n;
  	cin>>n;
  	int64 s=100;
  	int t=0;
  	while(s<n){
      s = s + s/100;
      t++;
    }
  	cout<<t;
	
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	cout << min(A, B) + min(C, D) << endl;
}

Measured memory_bytes: 3648
s=list(input())
n=len(s)
s.reverse()
mod=10**9+7
dp=[[0]*13 for i in range(n+1)]
dp[0][0]=1
x=1
for i in range(n):
  for j in range(13):
    if s[i]=='?':
      for k in range(10):
        dp[i+1][j]+=dp[i][(j-k*x)%13]
    else:
      dp[i+1][j]+=dp[i][(j-int(s[i])*x)%13]
    dp[i+1][j]%=mod
  x*=10
  x%=13
print(dp[n][5])

Measured memory_bytes: 67348
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	int	n ; cin >> n ;
	vll a(n) ;
	ll sum = 0 ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) ;
		sum ^= a.at(i) ;
	}
	for(int i=0;i<n;i++){
		cout << (a.at(i)^sum) ;
		if(i==n-1) cout << endl ;
		else cout << " " ;
	}
}




Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(ll i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
typedef long long ll;

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        int x;
        cin>>x;
        if(x == 0)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

int StrToInt(string s){stringstream ss;ss << s;int val;ss >> val;return val;}
string IntToStr(int i){stringstream ss;ss << i;return ss.str();}

int f(string str){
	int sum = 0;

	for(int i = 0; i < str.length(); i++){
		sum += str[i] - '0';
	}

	return sum;
}

int main(){

	string in;
	cin >> in;

	if(StrToInt(in)%f(in) == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

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

namespace _0076
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                double x = 1D;
                double y = 0D;

                int n = RInt();
                if (n == -1) break;

                for (int i = 1 ; i < n ; i++)
                {
                    double length = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
                    double dx = -y / length;
                    double dy = x / length;
                    x += dx;
                    y += dy;
                }
                Console.WriteLine(x);
                Console.WriteLine(y);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 13920
inf = 1000000000
H,W = map(int,input().split())
C = [[int(j) for j in input().split()] for i in range(10)]
#C[i][j]はiをjにするコスト
#各ノードから１への最短距離
for m in range(10):
    for s in range(10):
        for g in range(10):
                C[s][g] = min(C[s][g],C[s][m] + C[m][g])

def maryoku(x):
    if x == -1:return(0)
    else:return(C[x][1])

A = [list(map(int,input().split())) for i in range(H)]

print(sum([sum([maryoku(aa) for aa in a]) for a in A]))


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
int main() {
    i64 n;
    cin >> n;
    vector<i64> c(n);
    for (int i = 0; i < n; ++i) cin >> c[i];
    sort(begin(c), end(c));

    i64 ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        ans += ((mod + 1) / 2 + (mod + 1) / 4 * (n - i - 1) % mod) % mod * c[i] % mod;
        ans %= mod;
    }
    cout << ans * ipow(2, n) % mod * (ipow(2, n)) % mod << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <string>

using namespace std;

int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= s*t) cout << "Yes" << endl;
    else{
        cout << "No" << endl; 
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 200005;
ll x[MAX_N],y[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> x[i] >> y[i];
	}
	ll ans = 0;
	ll M = -1e10,m = 1e10;
	rep(i,N)
	{
		M = max(M,x[i]+y[i]);
		m = min(m,x[i]+y[i]);
	}
	ans = max(ans,M-m);
	M = -1e10,m = 1e10;
	rep(i,N)
	{
		M = max(M,-1*x[i]+y[i]);
		m = min(m,-1*x[i]+y[i]);
	}
	ans = max(ans,M-m);
	M = -1e10,m = 1e10;
	rep(i,N)
	{
		M = max(M,x[i]-y[i]);
		m = min(m,x[i]-y[i]);
	}
	ans = max(ans,M-m);
	M = -1e10,m = 1e10;
	rep(i,N)
	{
		M = max(M,-1*x[i]-y[i]);
		m = min(m,-1*x[i]-y[i]);
	}
	ans = max(ans,M-m);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  if (S=="abc" || S=="acb" || S=="bca" || S=="bac" || S=="cab" || S=="cba" )
    cout<<"Yes"<<endl;
  else
    
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
s=input()
ans="Yes"
for i in range(len(s)):
    if i%2==0 :
        if s[i]=="h":
            ans="Yes"
        else:
            ans="No"
            break
    if i%2==1 :
        if s[i]=="i":
            ans="Yes"
        else:
            ans="No"
            break
if len(s)%2==0:
    print(ans)
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double theta0 = 2.0*M_PI*(60*H+M)/(60*12);
    double theta1 = 2.0*M_PI*M/60;
    double a = A*A+B*B-2*A*B*cos(theta0-theta1);
    cout << fixed << setprecision(32) << sqrt(a) << endl;
    return 0;
}

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

double dfs(vector< vector< vector<double> > > &dp, vector< vector< vector<int> > > &visited, int i, int j, int k, int N){
  if(visited[i][j][k] > 0) return dp[i][j][k];
  visited[i][j][k] = 1;
  double ret = 0;
  int s = i+j+k;
  if(i > 0){
    //ret += dfs(dp,visited,i-1,j,k,N)*i/N;
    double d = dfs(dp,visited,i-1,j,k,N);
    if(s < N) ret += (double)i*N/s/s + d*i/s;
    else ret += (double)i/N*(1+d);
  }
  if(j > 0 and i < N){
    //ret += dfs(dp,visited,i+1,j-1,k,N)*j/N;
    double d = dfs(dp,visited,i+1,j-1,k,N);
    if(s < N) ret += (double)j*N/s/s + d*j/s;
    else ret += (double)j/N*(1+d);
  }
  if(k > 0 and j < N){
    //ret += dfs(dp,visited,i,j+1,k-1,N)*k/N;
    double d = dfs(dp,visited,i,j+1,k-1,N);
    if(s < N) ret += (double)k*N/s/s + d*k/s;
    else ret += (double)k/N*(1+d);
  }
  dp[i][j][k] = ret;
  //cerr << i << " " << j << " " << k << " " << ret << endl;
  return ret;
}

int main(){
  int N;
  cin >> N;
  int A[] = {0,0,0};
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    ++A[a-1];
  }
  vector< vector< vector<double> > > dp(N+1,vector< vector<double> >(N+1,vector<double>(N+1,0)));
  vector< vector< vector<int> > > visited(N+1,vector< vector<int> >(N+1,vector<int>(N+1,0)));
  printf("%.12f\n",dfs(dp,visited,A[0],A[1],A[2],N));
}


Measured memory_bytes: 326400
#include <stdio.h>

int main() {
	int l, r, d, i = 0;
	
	scanf("%d %d %d", &l, &r, &d);
	while (l<=r){
		if(l%d == 0) {
			i++;
		}
		l++;
	}
	printf ("%d", i);
	return 0;
}

Measured memory_bytes: 1696
n = int(input())
ok = False
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(1, n - 1):
    if a[i] == b[i] and a[i - 1] == b[i - 1] and a[i + 1] == b[i + 1]:
        ok = True
print('Yes' if ok else 'No')


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = INF;
    for (int i = 0; i <= S.length() - T.length(); i++) {
        int cnt = 0;
        for (int j = 0; j < T.length(); j++) if (S[i + j] != T[j]) cnt++;
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

struct score {
    llong unit;
    llong complete;
    llong number;
    llong total;
};

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

    llong D, G;
    cin >> D >> G;

    vector<score> points;
    FORS(i, 1, D + 1) {
        llong number, comp;
        cin >> number >> comp;
        points.push_back({i * 100, comp, number, (i * 100 * number + comp)});
    }

    llong mask = (1 << D) - 1;
    llong ans = INF;
    while (mask >= 0) {
        llong total = 0;
        llong count = 0;
        FOR(i, D) {
            if((mask >> i) & 1 == 1) {
                total += points[i].total;
                count += points[i].number;
            }
        }
        if(total < G) {
            for(llong i = D - 1; i >= 0; i--) {
                if(!((mask >> i) & 1 == 1)) {
                    llong ness = (G - total + points[i].unit - 1) / points[i].unit;
                    if(ness > points[i].number) {
                        continue;
                    }
                    count += ness;
                    total += ness * points[i].unit;
                    break;
                }
            }
        }

        if(total >= G) {
            ans = min(ans, count);
        }

        mask--;
    }

    cout << ans << endl;

    return 0;
}

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

template<long long mod>
struct modint{
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x;is >> x;
    a = modint<mod>(x);
    return is;
  }
};

const long long mod = 1000000007;

int main(){
  modint<mod> N; cin >> N;
  vector<modint<mod>> mm(26,1);

  for(int i = 0; i < N.num; ++i){
    char c; cin >> c;
    mm[int(c-'a')] = mm[int(c - 'a')] + 1;    
  }
  modint<mod> res(1);
  for(int i = 0; i < 26; ++i)
    res = res * mm[i];

  cout << res - 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll k;
int main(){
	cin>>k;
	cout<<50<<endl;
	if(k%50==0){
		for(int i=0;i<50;i++){
			cout<<49+(k/50)<<" ";
		}
	}else{
		ll a=49+(k/50);
		ll b=k%50;
		for(int i=0;i<b;i++){
			cout<<(a+50)-b+1<<" ";
		}
		for(int i=0;i<50-b;i++){
			cout<<a-b<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  LL N;
  cin >> N;
  vector<LL> A(N);
  REP(i,N){
    cin >> A[i];
    A[i] -= i;
  }
  SORT(A);
  LL hoge = A[N / 2];
  LL sum = 0;
  REP(i,N){
    sum += abs(A[i] - hoge);
  }
  cout << sum << endl;
}


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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  
  int ans = 0;
  for (int i=1; i<n; i++){
    int cnt = 0;
    for (char target = 'a'; target <= 'z'; target++){
      bool left = false, right = false;
      for (int j=0; j<i; j++) if (s.at(j) == target) left = true;
      for (int j=i; j<n; j++) if (s.at(j) == target) right = true;
      
      if (left&&right) cnt++;
    }
    ans = max(ans, cnt);
  }
  
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
     long long  a,b,c,k,x,p=0,sum=0;
   cin>>a>>b>>c>>k;
       if(k>=a)
       sum=a;
       else
        sum=k;
       x=(k-a)-b;
       if(x>0)
        p=x*-1;
       sum+=p;
       cout<<sum<<endl;

return 0;
}


Measured memory_bytes: 3596
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long[] paty;
long[][] bager;

void main()
{
    long n, k;
    scan(n, k);
    paty ~= 1, bager ~= [1];
    foreach (i; iota(1, n + 1))
    {
        paty ~= 2 * paty[i - 1] + 1;
        bager ~= [1, bager[i - 1].sum(), 1, bager[i - 1].sum(), 1];
    }
    // paty.writeln();
    // bager.writeln();
    long ans;
    solve(ans, n, k);
    ans.writeln();
}

void solve(ref long ans, long depth, long res)
{
    if (res == 0)
    {
        return;
    }
    else if (depth == 0)
    {
        ans += 1;
        return;
    }

    foreach (i, e; bager[depth])
    {
        if (res >= e)
        {
            if(i != 0 && i != bager[depth].length - 1)
                ans += min(e, paty[depth - 1]);
            res -= e;
        }
        else
        {
            solve(ans, depth - 1, res);
            return;
        }
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
n, m = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i)
a.sort!

bcs = []
m.times do 
  bcs << gets.chomp.split(' ').map(&:to_i)
end


bcs.sort!{|x, y| y[1] <=> x[1]}

i = 0

catch :loop do

bcs.each do |bc|
  bc[0].times do
    if i < n
      if bc[1] > a[i]
        a[i] = bc[1]
        i += 1
      else
        throw :loop
      end
    else
      throw :loop
    end
  end
end

end

puts a.inject(:+)



Measured memory_bytes: 18808
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int now=1;
  int ans=a[0]-1;
  repi(i,1,n){
    if(a[i]==now+1) now++;
    else{
      ans+=(a[i]-1)/(now+1);
    }
    
  }
  cout<<ans<<endl;
  

  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> vec = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

  string ans;
  if (a == b) {
    ans = "Draw";
  } else if (vec.at(a) > vec.at(b)) {
    ans = "Alice";
  } else {
    ans = "Bob";
  }

  cout << ans << endl;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    ll n;
    cin >> n;
    vector<vector<int>> edges(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        if (u > v) swap(u,v);
        edges[u].push_back(v);
    }
    ll ans = (n+2)*n*(n+1)/6;
    for (int i = 0;i < n;++i) for (int j : edges[i]) {
        ans -= (i+1)*(n-j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 14396
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	if (n % 10 == 3)
		printf("bon");
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
		printf("pon");
	else if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
		printf("hon");
	return 0;
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
  cin>>A>>B>>C>>D;
  int x=max(A,C);
  int y=min(B,D);
  if(x<=y)
    cout<<y-x<<endl;
  else
    cout<<0<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


pii rotate (pii vec) {
    int x = -vec.second;
    int y = vec.first;
    return {x,y};
}

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

pii p1,p2,p3,p4;
cin >> p1.first >> p1.second;
cin >> p2.first >> p2.second;

pii vec = { p2.first - p1.first , p2.second - p1.second };
vec = rotate(vec);

p3.first = p2.first + vec.first;
p3.second = p2.second + vec.second;

p4.first = p1.first + vec.first;
p4.second = p1.second + vec.second;

cout << p3.first << ' ' << p3.second << ' ' << p4.first << ' ' << p4.second << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,n;
    cin>>a>>b>>n;
    ll i;
    if(n<=b-1)
    {
    	cout<<floor((a*n)/b)<<endl;
	}
	else
	{
		cout<<floor((a*(b-1))/b)<<endl;
	}
	//cout<<max1<<endl;
	return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    ll A,B,C; std::cin>>A>>B>>C;
    //aA=bB+Cとなるa,bが存在するか
    for(int a=1; a<B+1; ++a){
        if(a*A%B==C){
            std::cout << "YES";
            return 0;
        }
    }
    std::cout << "NO";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = tuple(map(int, input().split()))
x = a[0]
y = sum(a[1:])
mn = abs(x-y)
for i in range(1, N-1):
  x += a[i]
  y -= a[i]
  mn = ab if (ab := abs(x-y)) < mn else mn
print(mn)

Measured memory_bytes: 31756
#include <vector>
#include <algorithm>
#include <cstdio>
int main(){
	int n;
	for(;scanf("%d",&n),n;){
		std::vector<int>v(n);
		for(int i=0;i<n;i++)scanf("%d",&v[i]);
		std::sort(v.begin(),v.end());
		int r=v[1]-v[0];
		for(int i=2;i<n;i++)r=std::min(r,v[i]-v[i-1]);
		printf("%d\n",r);
	}
}

Measured memory_bytes: 2784
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    string S;
    cin >> S;
    bool ok = true;
    rep(i,a){
        if (!(('0'<=S[i]) && (S[i]<='9'))) {
            ok = false;
        }
    }
    if (!(S[a]=='-')) {
        ok = false;
    }
    for(int i=a+1;i<=a+b;i++){
        if (!(('0'<=S[i]) && (S[i]<='9'))){ 
            ok = false;
        }
    }
    if (ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	vector<int> V;
	int tmp;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	int num_query;
	scanf("%d",&num_query);

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&tmp);

		printf("%lld\n",lower_bound(V.begin(),V.end(),tmp)-V.begin());
	}

	return 0;
}



Measured memory_bytes: 3504
#include<iostream>
#include<algorithm>
using namespace std;
int d[100000+1];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1]; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

ll X, Y;

int main(void){
    cin >> X >> Y;

    int res = 1;
    while(X * 2 <= Y){
        X *= 2;
        res++;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()

alp = [chr(i) for i in range(ord('A'), ord('Z')+1)]
alp_num = 0

def moji(c):
    m = ''
    for num,alphabet in enumerate(alp):
        if c == alphabet:
            m = alp[(num+N)%26]
    return m
S2 = '' 
s = ''   
for i in S:
    s = moji(i) 
    S2 = S2 + s

print(S2)


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

int main(){
    int N;
    cin>>N;
    int A[20] = {0}, B[20] = {0}, C[20] = {0};
    for(int i=1;i<=N;i++)
        cin>>A[i];
    for(int i=1;i<=N;i++)
        cin>>B[i];
    for(int i=1;i<N;i++)
        cin>>C[i];
    
    int point = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++)
            if(A[i] == j)
                point += B[j];
        if(A[i]+1 == A[i+1])
            point += C[A[i]];
    }

    cout<<point<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long x = in.nextLong();
        long m = in.nextLong();
        List<Long> foundList = new ArrayList<>();
        Set<Long> foundSet = new HashSet<>();
        
        long a = x;
        long ans = a;
        foundList.add(Long.MIN_VALUE); // 0番目はダミーの値。便宜上。
        foundList.add(a);
        foundSet.add(a);
        for(long i=2; i<=n; i++) {
            long next = (a*a)%m;
            foundList.add(next);
            if(foundSet.contains(next)) {
                // ループ検出
                // 何番目からi番目までがループであるのかを知る
                int loopStart = foundList.indexOf(next); // これがintに収まるということは未証明
                int loopEnd = (int)i-1;
                long loopCycle = loopEnd - loopStart + 1;
                long loopLength = n - loopStart + 1;
                long loopMod = loopLength % loopCycle;
                long loopCount = (loopLength - loopMod) / loopCycle;
                loopCount--; // ループ1回分は既にansに足されているので
                
                long loopSum = 0;
                for(int j=loopStart; j<=loopEnd; j++) {
                    loopSum += foundList.get(j);
                }
                if(loopCount>0) {
                    ans += loopCount*loopSum;
                }
                for(int j=loopStart; j<loopStart+loopMod; j++) {
                    ans += foundList.get(j);
                }
                break;
            }
            else {
                foundSet.add(next);
            }
            ans += next;
            a = next;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 44524
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly string OK = "Possible", NG = "Impossible";

    public void Solve()
    {
        int N = Reader.Int();
        var Len = Reader.IntArray(N);
        Array.Sort(Len);
        Console.WriteLine(SolveIt(N, Len));
    }

    string SolveIt(int N, int[] Len)
    {
        int max = Len[N - 1];
        int min = Len[0];
        if (Len[N - 2] != max) return NG;
        if (min != (max + 1) / 2) return NG;

        int[] count = new int[N];
        foreach (int x in Len) count[x]++;
        if (max % 2 == 0 && count[min] != 1) return NG;
        if (max % 2 == 1 && count[min] != 2) return NG;
        for (int len = min + 1; len < max; len++)
            if (count[len] < 2) return NG;

        return OK;
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 2776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String str = sc.next();
		int len = str.length();
		if(len<=k) System.out.println(str);
		else{
			char[] ch = new char[len+3];
			char[] temp = str.toCharArray();
			for(int i=0;i<k;i++) ch[i]=temp[i];
			ch[k]='.';
			ch[k+1]='.';
			ch[k+2]='.';
			for(int i=0;i<k+3;i++) System.out.print(ch[i]);
			System.out.println();
		}
	}
}


Measured memory_bytes: 35712
#include <iostream>
#include <climits>
#include <map>

using namespace std;

int main()
{
    int q, mass;
    cin >> q >> mass;

    int ans = 0;
    int sml = INT_MAX;

    while(q--)
    {
        int n;
        cin >> n;

        mass -= n;
        sml = min(sml, n);
        ans++;
    }

    ans += (mass / sml);

    cout << ans << endl;

    return 0;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {

    int n, m;
    cin >> n >> m;
    vector<ll> cards(n);
    rep(i, n)cin >> cards[i];
    sort(cards.begin(), cards.end());

    vector<P> changes(m);
    rep(i, m) cin >> changes[i].second >> changes[i].first;
    sort(changes.rbegin(), changes.rend());

    int s = 0;
    for (P p : changes) {
        for (int i = 0; i < p.second; i++) {
            if (s == n) break;
            cmax(cards[s], p.first);
            s++;
        }
    }

    cout << accumulate(cards.begin(), cards.end(), 0ll) << endl;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int given_number = 100*r + 10*g + b;
  int result = (given_number / 4) * 4;
  if (given_number == result) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
s = input()
l = ['A', 'T', 'G', 'C']
tmp = 0
answer = 0
for i in range(0, len(s)):
  if (s[i] in l) == True:
    tmp += 1
  else:
    tmp = 0
  if tmp > answer:
    answer = tmp
print(answer)

Measured memory_bytes: 3060
N, M = map(int, input().split())
E = [[] for i in range(N)]
RE = [[] for i in range(N)]
for i in range(M):
  u, v = map(int, input().split())
  E[u - 1].append(v - 1)
  RE[v - 1].append(u - 1)
S, T = map(int, input().split())
RD = [-1] * N
RD[T - 1] = 0
Q = [T - 1]
while Q:
  q = Q.pop(0)
  for adj in RE[q]:
    if RD[adj] == -1:
      RD[adj] = RD[q] + 1
      Q.append(adj)
D = [[-1, -1, -1] for i in range(N)]
Q = [[-1, -1, -1] for i in range(M)]
if M:
  Q[0] = [S - 1, 0, RD[S - 1] % 3]
o = 0
i = 1
while Q:
  q, d, m = Q[o]
  Q[o] = [-1, -1, -1]
  o = (o + 1) % M
  if q == -1:
    break
  if RD[q] == -1:
    continue
  D[q][m] = d + RD[q]
  if m != 0:
    for adj in E[q]:
      _m = (d + 1 + RD[adj]) % 3
      if D[adj][_m] == -1:
        Q[i] = [adj, d + 1, _m]
        i = (i + 1) % M
P = [d[0] for d in D if d[0] != -1]
if P:
  print(min(P) // 3)
else:
  print(-1)

Measured memory_bytes: 63820
def answer(a: int, b: int, c: int) -> str:
    for i in range(1, b + 1):
        if a * i % b == c:
            return 'YES'
    return 'NO'


def main():
    a, b, c = map(int, input().split())
    print(answer(a, b, c))


if __name__ == '__main__':
    main()

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    ll a,b,c;
    cin>>a>>b>>c;
    ll t = min(a,c);
    a -= t;
    c -= t;
    b -= min(b,c);
    cout << a << " " << b <<  endl;

}

Measured memory_bytes: 256
S = input() 
T = input() 

if __name__ == "__main__":
    n = len(S)
    ans = 0
    pre = -1 
    for c in T: 
        pos = S.find(c, pre + 1, n)
        if pos != -1:
            ans += (pos - pre)
            pre = pos 
        else:
            pos = S.find(c, 0, pre + 1)
            if pos != -1:
                ans += n + pos - pre
                pre = pos  
            else:
                ans = -1
                break
    
    print(ans)


Measured memory_bytes: 3316
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	LL N, M;
	cin >> N >> M;
	LL ans;
	if (N == 1 && M == 1) {
		ans = 1;
	}
	else if (N == 1) {
		ans = M - 2;
	}
	else if (M == 1) {
		ans = N - 2;
	}
	else {
		ans = (N - 2) * (M - 2);
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main()
{
  int a,b;
  cin>>a>>b;
  if((a+b)%2==1)
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
  else
  {
    cout<<(a+b)/2<<endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;
typedef long long ll;

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main() {
    scanf("%d %d ", &N, &M);
    for (int i = 0; i < M; i++) {
        scanf("%d %d ", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++) sort(yd[i + 1].begin(), yd[i + 1].end());

    for (int i = 0; i < M; i++) {
        auto lb  = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]);
        int rank = lb - yd[P[i]].begin() + 1;
        printf("%06d%06d\n", P[i], rank);
    }
}


Measured memory_bytes: 7808
#include<stdio.h>
#define DATA 200

int main(){
	int a, b, c, d;
	int n[DATA];
	int i=0, j, com = 0;

	while (scanf("%d", &n[i]) != EOF)
		i++;

	for (j = 0; j < i; j++){
		for (a = 0; a <= 9; a++){
			for (b = 0; b <= 9; b++){
				for (c = 0; c <= 9; c++){
					for (d = 0; d <= 9; d++){
						if (a + b + c + d == n[j])
							com++;
					}
				}
			}
		}
		printf("%d\n", com);
		com = 0;
	}
	return 0;
}

Measured memory_bytes: 592
N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
S = sum(A)
for i in range(P-1):
    x = A.pop()
    S -= x
total_score = M*(V-P+1)
kazu = N - P + 1
for i in range(N-P+1):
    a = A.pop(0)
    total_score -= M
    S -= a
    kazu -= 1
    T = (M+a)*kazu - S
    if i == N - P:
        ans = P
    else:
        if (a+M) >= A[-1]:
            if T >= total_score:
                ans = kazu + P
                break
print(ans)


Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1e9+7;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

int main(){
    int N;
    cin>>N;
    cout<<N/2+N%2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int W,H,x,y,r;
    scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
    if(x-r<0||x+r>W||y-r<0||y+r>H){
        printf("No\n");
    }
    else if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
        printf("Yes\n");
    }
    return 0;
}



Measured memory_bytes: 2104