akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int a[LIMIT2]={0};
ll k;
int find(ll price){
  ll i,j;
  j=price%10;
  if(price<=0) return 1;
  rep(i,k) if(a[i]==j) return 0;
  return find(price/10);
}
int main(void){
  initialize();
  ll n,m,i,j,result=0;
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&k);
  rep(i,k) scanf("%d",&a[i]);
  i=n;
  while(1){
    if(find(i)==1){
      result = i;
      break;
    }
    i++;
  }
  printf("%lld\n",result);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<1001;i++){
		if(n*i%m==k){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#list(map(int, input().split()))
h, w = map(int, input().split())
s = [list(input().split()) for _ in range(h)]
alph='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(h):
    for j in range(w):
        if s[i][j] == 'snuke':
            print(alph[j]+str(i+1))
            break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 500100
using namespace std;
typedef pair<int,int> pii;
const int inf = 1e18;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
	fastio;
	int n,k;
	cin>>n>>k;
	int d=0;
	while(n>0){
		d++;
		n/=k;
	}
	cout<<d<<endl;
}

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

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		TreeSet<String> sub = new TreeSet<String>();
		
		for(int i = 1; i <= 5; i++) {
			for(int n = 0; n < s.length(); n++) {
				if((n + i) >= s.length()) {
					sub.add(s.substring(n, s.length()));
				}else {
					sub.add(s.substring(n, (n + i)));
				}
			}
		}
		
		int k = sc.nextInt();
		int count = 0;
		for(String st: sub) {
			count++;
			if(count == k) {
				System.out.println(st);
				break;
			}
		}
		
	}
}

Measured memory_bytes: 23764
import sys
N = int(input())
H = [int(i) for i in input().split()]
"""H.append(H[-1])
tmp = H[0]
for i in range(1,N):
    if H[i]-tmp ==1:
        H[i]-=1
    if (H[i]-tmp != 0) and (not tmp<=H[i]<=H[i+1]):
        print('No')
        sys.exit()
    tmp = H[i]
print('Yes')"""
Max = H[0]
for i in range(1,N):
    Max = max(Max,H[i-1])
    if not  H[i]>=Max-1:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 14396
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl h(n);
        rep(i, n) cin >> h[i];
        vl d(n + 1);
        d[0] = 0;
        rep(i, n) {
            d[i + 1] = max(d[i], h[i]);
        }
        ll ans = 0;
        rep(i, n) {
            if (d[i + 1] == h[i]) ans++;
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long n,c,d[31][31],cc[500][500],i,j,p[31][3]={},k,min;
  scanf("%ld %ld",&n,&c);
  for(i=0;i<c;i++)
    for(j=0;j<c;j++)
      scanf("%ld",&d[i+1][j+1]);
  
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      scanf("%ld",&cc[i][j]);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      for(k=1;k<=c;k++)
        p[k][(i+j)%3]+=d[cc[i][j]][k];
  min=500*500*1000+1;
  for(i=1;i<=c;i++){
    for(j=1;j<=c;j++){
      if(i!=j){
        for(k=1;k<=c;k++){
          if(i!=k&&j!=k&&min>p[i][0]+p[j][1]+p[k][2]){
            min=p[i][0]+p[j][1]+p[k][2];
          }
        }
      }
    }
  }
  printf("%ld\n",min);
}

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

int main(){
  int N,L;cin>>N>>L;
  int sum=0,m,mm=300;
  for(int i=1;i<=N;i++){
    sum+=L+i-1;
    if(abs(L+i-1)<abs(mm)){m=i;mm=L+i-1;}
  }
  cout<<sum-(L+m-1)<<endl;
  return 0;
}

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

using namespace std;

int main() {

	int n;
	double g,nn;
	cin >> n;
	if (n % 2 == 0) {
		g = n / 2;
		nn = n;
		printf("%f\n", g / nn);
	}
	else {
		g = n / 2 + 1;
		nn = n;
		printf("%f\n", g / nn);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1))%md;
    else {
        ll k=po(x,n/2);
        return (k*k)%md;
    }
}

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return po(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }


 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 ll a[200005];
int32_t main(){
    IOS;
    ll sum=0,n,k,sum2=0;
    cin >> n;
    fori(n){
        cin >> a[i];
        sum += a[i];
        sum %= md;
        sum2 += (a[i]*a[i])%md;
    }
    ll ans =0 ;
    ans = (((sum*sum)%md - sum2)%md + md)%md;
    ans  = (ans * modInv(2ll))%md;
    // fori(n){
    //     ans = ( ans + (a[i]*(sum-a[i]))%md)%md;
    //     ans %= md;
    // }
    // ans = ans*modInv(2ll) ;
    cout << (ans+md) % md <<"\n";
    // cout << modInv(2ll)<<"\n";
    // cout <<((ll)1e18%md)<<"\n";
} 

Measured memory_bytes: 5208
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2* 100 * 1000 + 47;



struct RMQ
{
    int T[MAX << 4];
    
    void push(int v, int tl, int tr)
    {
        if (!T[v] || tl == tr)return;
        T[v+v] = T[v+v+1] = T[v];
        T[v] = 0;
    }
    
    void set(int v, int tl, int tr, int l, int r, int x)
    {
        if (r < l)return ;
        push(v, tl, tr);
        if (l == tl && r == tr)
        {
            T[v] = x;
            return ;
        }
        int tm = (tl + tr) / 2;
        set(v + v, tl, tm, l, min(r, tm), x);
        set(v + v + 1, tm+1, tr, max(tm+1, l), r, x);
    }
    
    int get(int v, int tl, int tr, int pos)
    {
        if (tl == tr)return T[v];
        push(v, tl, tr);
        int tm = (tl + tr) / 2;
        if (pos <= tm)return get(v + v, tl, tm, pos);
        else return get(v+v+1, tm+1, tr, pos);
    }
};

RMQ T;
int L[MAX], R[MAX];
int A[MAX];
int n, k, sz;
LL D[MAX];



LL F(int x)
{
    int f = T.get(1, 1, sz, x);
    if (!f)return 0;
    int a = A[L[f]] - A[x];
    if (a < 0)a += k;
    return D[f] + a;
}


int main()
{
    // freopen("in.txt", "r", stdin);
    scanf("%d%d", &n, &k);
    LL s = 0;
    int prev = 0;
    FOR(i, 1, n+1)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a *= 2;
        s += a;
        if (b == 1 && a > k)
        {
            printf("-1\n");
            return 0;
        }
        a = (prev - a % k + k) % k;
        if (b == 1)L[i] = prev, R[i] = a;
        else L[i] = 0, R[i] = k-1;
        prev = a;
    }
    FOR(i, 1, n+1)
        A[i + i - 1] = L[i],
        A[i + i] = R[i];
    sort(A + 1, A + n + n + 1);
    sz = unique(A + 1, A + n + n + 1) - A - 1;
    
    FOR(i, 1, n+1)
    {
        L[i] = lower_bound(A + 1, A + sz + 1, L[i]) - A;
        R[i] = lower_bound(A + 1, A + sz + 1, R[i]) - A;
    }
    
    RFOR(i, n+1, 1)
    {
        D[i] = F(L[i]);
        if (L[i] > R[i])
        {
            T.set(1, 1, sz, R[i] + 1, L[i] - 1, i);
        }
        else
        {
            T.set(1, 1, sz, 1, L[i]-1, i);
            T.set(1, 1, sz, R[i]+1, sz, i);
        }
    }

    
    
    LL ans = D[1];
    FOR(i, 1, sz+1)
    {
     //   cout << F(i) << endl;
        ans = min(ans, F(i));
    }
    ans += s;
    printf("%lld\n", ans);
    
    
    
    return 0;
}





Measured memory_bytes: 5632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    if(N % 2 == 0) {
      if(S.substring(0,N/2).equals(S.substring(N/2,N))) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } else {
      System.out.println("No");
    }
  }
}

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

int main() {
    int D, G, p[11], c[11];
    cin >> D >> G;
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    int ans = 999999999;
    for (int mask = 0; mask < (1 << D); ++mask) {
        int s = 0, num = 0, rest_max = -1;
        for (int i = 0; i < D; ++i) {
            if (mask >> i & 1) {
                s += 100 * (i + 1) * p[i] + c[i];
                num += p[i];
            } else {
                rest_max = i;
            }
        }
        if (s < G) {
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if (need >= p[rest_max]) {
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(100), b(100), c(100), d(100);
  for(int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  queue<ll> que;
  for(int i = 0; i < m; i++) {
    que.push(i);
  }
  ll limit = 0;
  for(int i = 0; i < n; i++) {
    limit += (m - 1)* pow(10, i);
  }
  //cout << limit << endl;
  for(int i = 0; i <= 99999; i++) {
    bool ok = false;
    ll tmp = que.front();
    ll in = tmp;
    for(int j = in % 10; j < m; j++) {
      que.push(in * 10 + j);
      if(in * 10 + j >= limit){
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
    que.pop();
  }
  //cout << que.front() << endl;

  ll ans = 0;
  while(!que.empty()) {
    ll sum = 0;
    ll tmp = que.front();
    //cout << tmp << endl;
    que.pop();
    vector<ll> e(100, 0);
    bool ok = true;
    for(int i = n - 1; i >= 0; i--) {
      if(tmp % 10 > m) {
        ok = false;
        break;
      }
      e[i] = tmp % 10;
      tmp /= 10;
      //cout << e[i] << " ";
    }
    //cout << endl;
    if(ok == false) {
      continue;
    }
    for(int i = 0; i < q; i++) {
      if(e[b[i]] - e[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main()
{
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < k + x; i++)
    {
        cout << i;
        if (i != k + x - 1)
            cout << " ";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long x,y,n,d,ans;
 cin >> n >> d;
 ans =0;
 for(int i=0;i<n;i++){
  cin >> x >> y;
  if(d*d>=x*x+y*y){ans++;}
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 3556
n=int(input())
a=1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
print(a[n-1])

Measured memory_bytes: 9144
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
MOD = 10**9 + 7

def main():
    count1 = [0 for _ in range(N)]
    count2 = [0 for _ in range(N)]
    
    # 同じ整数列内での転倒数を数える
    for i, a in enumerate(A[:-1]):
        c = 0
        for b in A[i+1:]:
            if a > b:
                c += 1
        count1[i] = c

    # 異なる整数列に対する転倒数を数える
    for i, a in enumerate(A):
        c = 0
        for b in A[:i]:
            if a > b:
                c += 1
        count2[i] = c + count1[i]

    s = (sum(count1) * K) % MOD
    s += (sum(count2) * (K-1) * K // 2) % MOD
    print(s%MOD)
                
if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(){
	int n, m, l;
	vector< vector<long> > matlix1, matlix2, ans;
	cin >> n >> m >> l;
	for(int y = 0; y < n; y++){
		vector<long> tmp;
		for(int x = 0; x < m; x++){
			long num;
			cin >> num;
			tmp.push_back(num);
		}
		matlix1.push_back(tmp);
	}
	for(int y = 0; y < m; y++){
		vector<long> tmp;
		for(int x = 0; x < l; x++){
			long num;
			cin >> num;
			tmp.push_back(num);
		}
		matlix2.push_back(tmp);
	}
	for(int i = 0; i < n; i++){
		vector<long> tmp;
		for(int j = 0; j < l; j++){
			long mul = 0;
			for(int k = 0; k < m; k++){
				mul += matlix1[i][k] * matlix2[k][j];
			}
			tmp.push_back(mul);
		}
		ans.push_back(tmp);
	}
	for(int y = 0; y < n; y++){
		for(int x = 0; x < l; x++){
			cout << ans[y][x];
			if(x < l - 1) cout << ' ';
		}
		if(y < n) cout << '\n';
	}
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
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++)
typedef long long ll;

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


Measured memory_bytes: 256
//What is love?

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>

using namespace std;

#define FOR(i,n,m) for(int i=n;i<m;++i)
#define ROF(i,n,m) for(int i=n;i>m;--i)
#define pb push_back
#define ll long long
#define ri(a) scanf("%d",&a)
#define rii(a,b) scanf("%d %d",&a,&b)

const int INF = 0x3f3f3f3f;

//Baby don't hurt me

int n,ans,acum;
string s;

//Don't hurt me

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

    cin>>s;
    n=s.size();
    FOR(i,0,n){
        if(s[i]!='0'){
            ans=max(acum + int(s[i]-'1') + (n-1-i)*9,ans);
            acum+=int(s[i]-'0');
        }
    }
    ans=max(acum,ans);
    cout<<ans<<endl;
 
    return 0;
}

//No more

Measured memory_bytes: 256
l=[[0]*1001 for i in range(10)]
l[0][0]=1
for i in range(101):
    for j in range(9,0,-1):
        for k in range(i,1000):
            l[j][k]+=l[j-1][k-i]
while 1:
    n,k=map(int,raw_input().split())
    if n==k==0:
        break
    print l[n][k]

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  int sum = 0;
  vector<int> a(n);  
  rep(i, 0, n) {
    cin >> a[i];
    sum += a[i];
  }
  sum = (sum +4*m -1)/(4*m);
  
  int ans = n;
  rep(i, 0, n) {
    if(a[i] < sum)
      ans--;
  }
  
  cout << ( ans >= m ?"Yes" :"No") << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
int a[N];
map<int,int> mp1, mp2;
int main(void){
    IOS;
    int n; cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        ans += mp1[i-a[i]];
        ans += mp2[i+a[i]];
        mp1[i+a[i]]++;
        mp2[i-a[i]]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int h,w;
  cin >> h >> w;
  
  for(int i=0;i<w+2;i++){
    cout << '#' ;  
  }
  cout << endl;
  
  for(int i=0;i<h;i++){
    string s;
    cin >>s;
    cout << '#'+ s +'#' << endl;
  }
  
  for(int i=0;i<w+2;i++){
    cout <<'#';
  }
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int n = stdin.nextInt();
    int[][] card = { new int[13], new int[13], new int[13], new int[13] };
    char[] suit = { 'S', 'H', 'C', 'D' };

    for (int i = 0; i < n; i++) {
      String s = stdin.next();
      int j = stdin.nextInt() - 1;
      if (s.equals("S")) {
        card[0][j] = 1;
      } else if (s.equals("H")) {
        card[1][j] = 1;
      } else if (s.equals("C")) {
        card[2][j] = 1;
      } else {
        card[3][j] = 1;
      }
    }

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 13; j++) {
        if (card[i][j] == 0) {
          System.out.printf("%s %d%n", suit[i], j + 1);
        }
      }
    }
  }

}

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

int main() {
    int a, b, c, surplus;
    cin >> a >> b >> c;
    bool can = false;
    /* iを増やしていくとiがbになった時点で余りは0となり、
    そこから余りの遷移はループする。
    よって、１ループ内で調べれば全てを調べたことになる。*/
    for (int i=1; i<=b; i++) {
        surplus = (a * i) % b;
        if (surplus == c) can = true;
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

AC=0
WA=0
TLE=0
RE=0

for i in range(N):
    a=input()
    if a=='AC':
        AC+=1
    if a=='WA':
        WA+=1
    if a=='TLE':
        TLE+=1
    if a=='RE':
        RE+=1
print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')

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

using namespace std;

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

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

const ll mod = 1e9+7;
const int INF = 1e9+10;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i],a[i];
	reverse(all(a));

	vector<int> dp(n,INF);
	rep(i,n){
		*upper_bound(all(dp),a[i])=a[i];
	}
	// rep(i,n)cout<<dp[i]<<" ";
	// cout<<endl;
	cout<<lower_bound(all(dp),INF)-dp.begin()<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);

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

    for(int i = n-1; i >= 0; i--){
        a[i] += add;
        long long mod = a[i] % b[i];
        if(mod != 0){
            add += b[i] - mod;
        }
    }

    cout << add << endl;


}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var hw = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var gre = new string[hw[0]];
        for (var i = 0; i < hw[0]; i++)
            gre[i] = ReadLine();
        for (var i = 0; i < hw[0]; i++)
        {
            var isClear = true;
            for (var j = 0; j < hw[1]; j++)
            {
                if (gre[i][j] != '#') continue;
                if (i != 0 && gre[i - 1][j] == '#') continue;
                if (i != hw[0] - 1 && gre[i + 1][j] == '#') continue;
                if (j != 0 && gre[i][j - 1] == '#') continue;
                if (j != hw[1] - 1 && gre[i][j + 1] == '#') continue;
                isClear = false;
                break;
            }
            if (!isClear) { WriteLine("No"); return; }
        }
        WriteLine("Yes");
    }
}


Measured memory_bytes: 13140
fun main(args: Array<String>) {
    dwacon6thPrelimsB()
}

fun dwacon6thPrelimsB() {
    val n = readLine()!!.toInt()
    val xList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    val diffs = LongArray(n - 1)
    for (i in 0 until n - 1) diffs[i] = xList[i + 1] - xList[i]

    var answer = Mint(0)
    var c = Mint(0)

    nCkInit()

    for (i in diffs.indices) {
        c += inv[i + 1]
        answer += c * diffs[i]
    }

    answer *= fac[n - 1]

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private const val MAX = 1000000
private val fac = LongArray(MAX)
private val fInv = LongArray(MAX)
private val inv = LongArray(MAX)

private fun nCkInit() {
    fac[0] = 1
    fac[1] = 1
    fInv[0] = 1
    fInv[1] = 1
    inv[1] = 1
    for (i in 2 until MAX) {
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
        fInv[i] = fInv[i - 1] * inv[i] % MOD
    }
}

private class Mint(value: Long) {
    private val value = if (value < 0) (value % MOD) + MOD else value % MOD
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * other)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = Mint(modPow(other, MOD - 2, MOD))
    operator fun div(other: Mint) = this.div(other.value)
    override fun toString(): String {
        return this.value.toString()
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as Mint

        if (value != other.value) return false

        return true
    }

    override fun hashCode(): Int {
        return value.hashCode()
    }

    @Suppress("SameParameterValue")
    companion object Mod {
        private fun modPow(n: Long, p: Long, m: Long): Long {
            var x = n
            var y = p
            var result = 1L
            x %= m
            while (y > 0) {
                if (y % 2 == 1L)
                    result = (result * x) % m
                y = y shr 1
                x = (x * x) % m
            }
            return result
        }
    }
}


Measured memory_bytes: 97112
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

template<class T> struct Counting {
    Counting(int64_t n) {
        _fact.assign(n+1, 1);
        for(int64_t i = 1; i <= n; i++)  _fact[i] = T(i) * _fact[i-1];
    }

    T fact(int64_t n) {
        assert(0 <= n && n < (int)_fact.size());
        return _fact[n];
    }

    T perm(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / fact(n-k);
    }

    T comb(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / (fact(k) * fact(n-k));
    }

    private:
        vector<T> _fact;
};

int main() {
    Counting<mint> cnt(1e6);

    lint n, a, b;
    cin >> n >> a >> b;

    mint ans = mint::pow(2, n) - 1;

    mint nca = 1;
    for(lint i=1; i<=a; i++) {
        nca *= n-i+1;
        nca /= i;
    }

    mint ncb = 1;
    for(lint i=1; i<=b; i++) {
        ncb *= n-i+1;
        ncb /= i;
    }
    cout << ans - nca - ncb << endl;
}

Measured memory_bytes: 8192
def _input():
    string = input()
    return list(string)

def is_easy_dance(movings):
    index = 0
    for i in movings:
        if index % 2 == 0:
            if i == 'R' or i == 'U' or i == 'D':
                pass
            else:
                return 'No'
        else:
            if i == 'L' or i == 'U' or i == 'D':
                pass
            else:
                return 'No'
        index += 1
        if index == len(movings):
            return 'Yes'

if __name__ == "__main__":
    movings = _input()
    print(is_easy_dance(movings))


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

using namespace std;


int main() {
    vector<int> r;
    int n;
    cin>>n;
    int t;
    for (int i = 0; i <n ; ++i) {
        cin>>t;
        r.push_back(t);
    }
    int minv=r[0];
    int maxv=-2000000000;
    for(int i=1;i<r.size();i++){
        maxv=max(maxv,r[i]-minv);
        minv=min(minv,r[i]);
    }
    cout<<maxv<<endl;
    return 0;

}



Measured memory_bytes: 3928
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    int ans = 0;
    rep(i,30) {
        if (pow(k,i)<=n && n<pow(k,i+1)) {
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



























Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			String input = in.nextLine();
			String result = "";
			for(int i=0;i<input.length();i++){
				String test = "";
				if(input.length()>i+4)test=input.substring(i,i+5);
				if(test.equals("apple")){
					i+=4;
					result+="peach";
				}else if(test.equals("peach")){
					i+=4;
					result+="apple";
				}else result+=input.charAt(i);
			}
			System.out.println(result);
		}
	}
}

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

int main(){
  string s1;
  string s2;
  cin >> s1;
  if (s1[s1.size()-1] == 's') s2 = s1 + "es";
  else s2 = s1 + "s";
  cout << s2 << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<long> A(N);
	long miNum=0;
	long minNum = LONG_MAX;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] < 0)	miNum++;
		if(minNum > abs(A[i]))
			minNum = abs(A[i]);
	}

	long sum = 0;
	for(int i = 0; i < N; i++){
		sum += abs(A[i]);
	}

	if(miNum%2)
		sum = sum - 2*minNum;

	cout << sum << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
    int min = 1000000;
    int N, A, B;

    cin >> N >> A >> B;

    if(A*N <= B){
        min = A*N;
    } else {
        min = B;
    }
    cout << min << endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int result = 0;

  int q = x / 100;
  int r = x % 100;

  if (r <= q * 5) {
    result = 1;
  }

  cout << result << endl;

  return 0;
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var p = int.Parse(list[0]);
        var q = int.Parse(list[1]);
        var r = int.Parse(list[2]);

        if (p < q)
        {
            if (q < r)
            {}
            else
                q = r;
        }
        else
        {
            if (p < r)
            {}
            else
                p = r;
        }

        Console.WriteLine(p + q);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13140
H,W = map(int,input().split())
graph = [[i for i in input()] for j in range(H)]

def bfs(sx,sy):
  queue = [[sx,sy,0]]
  visited = [[False for i in range(W)] for j in range(H)]
  while queue:
    now = queue.pop(0)
    visited[now[0]][now[1]] = True
    for next in [[1,0],[-1,0],[0,1],[0,-1]]:
      if now[0]+next[0] < 0 or now[1]+next[1] < 0: continue
      if now[0]+next[0] > H-1 or now[1]+next[1] > W-1: continue
      if visited[now[0]+next[0]][now[1]+next[1]]: continue
      if graph[now[0]+next[0]][now[1]+next[1]]=='#': continue
      queue.append([now[0]+next[0],now[1]+next[1],now[2]+1])
      visited[now[0]+next[0]][now[1]+next[1]] = True
  return now[2]

ans = -1
for i in range(H):
  for j in range(W):
    if graph[i][j]=='#': continue
    ans = max(ans,bfs(i,j))
    
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 2000000009
#define init(x) memset(x,0,sizeof(x))
int a,b,c,d;
int main()
{
	ios::sync_with_stdio(false);
	scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
	if (a==b&&b==c) cout<<"Yes";
	else if (b==c&&c==d) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,d=0,x=0;
  scanf("%d %d %d",&a,&b,&c);
  for ( x = a; x <= b; x++){
    if(c%x==0) d++;
  }
  printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  rep(i, N-M+1) rep(j, N-M+1) {
    bool ret = true;
    rep(k, M)
      rep(l, M)
      if(A[i+k][j+l] != B[k][l]) ret = false;
    if(ret) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
while(1):
    n,x=map(int,input().split())
    cnt=0
    if n==0&x==0:
        break
    else:
        for i in range(1,n-1):
            for j in range(i+1,n):
                #print(i,j)
                if x-(i+j)<=n and x-(i+j)>j:
                    cnt=cnt+1
    print(cnt)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
#define int long long

void solve() {
	int w, h; cin >> w >> h;
    vector<ll> x(w), y(h);
    ll ans = 0;
    rep(i, w) {
        cin >> x[i];
        ans += x[i] * (h + 1);
    }
    rep(i, h) {
        cin >> y[i];
        ans += y[i] * (w + 1);
    } 
    sort(all(x)); sort(all(y));
    rep(i, w) {
        ans -= x[i] * (lower_bound(all(y), x[i]) - y.begin());
    }
    rep(i, h) {
        ans -= y[i] * (upper_bound(all(x), y[i]) - x.begin());
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
	int i;
	int n,a,b,asum,bsum;
	while(scanf("%d",&n)){
		if(n==0) break;
		asum=bsum=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a<b) bsum+=a+b;
			else if(b<a) asum+=a+b;
			else{
				asum+=a;
				bsum+=b;
			}
		}
		printf("%d %d\n",asum,bsum);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, m;
    cin >> n >> m;

    vl v(n+10);
    rep(i, m) {
        ll a;
        cin >> a;
        v[a] = 1;
    }

    vl dp(n+10);  // dp[i] : i段目に上る場合の数
    dp[0] = 1;
    if(v[1] == 0) {
        dp[1] = 1;
    }
    rep(i, n) {
        if(v[i+2] == 0) {
            dp[i+2] = dp[i+1] + dp[i];
            dp[i+2] %= mod;   
        }
    }
    
    out(dp[n]);
    re0;
}

Measured memory_bytes: 4844
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 10100
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

struct E
{
    int u,v,c,w;
    E(){}
    E(int u,int v,int c,int w):u(u),v(v),c(c),w(w){}
};
vector<E> e;
vi to[maxn+5];

int src,sink,FLOW,dis[maxn+5],pre[maxn+5];
bool mark[maxn+5];

void add(int u,int v,int c,int w)
{
    to[u].pb(e.size()); e.pb(E(u,v,c,w));
    to[v].pb(e.size()); e.pb(E(v,u,0,-w));
}
int spfa(int n)
{
    rep(i,1,n) dis[i]=inf;
    rep(i,1,n) pre[i]=-1;
    deque<int> q; q.pb(src);
    dis[src]=0; mark[src]=1;
    while(q.size())
    {
        int now=q.front(); q.pop_front(); mark[now]=0;
        for(auto i: to[now])
        {
            int v=e[i].v;
            if(dis[v]>dis[now]+e[i].w && e[i].c>0)
            {
                dis[v]=dis[now]+e[i].w;
                pre[v]=i;
                if(!mark[v])
                {
                    if(!q.empty() && dis[v]>=dis[q.front()]) q.pb(v);
                    else q.push_front(v);
                    mark[v]=1;
                }
            }
        }
    }
    return dis[sink]!=inf;
}
int costflow(int n)
{
    FLOW=0;
    int ans=0;
    while(spfa(n))
    {
        int mf=inf;
        for(int i=pre[sink];~i;i=pre[e[i].u]) mf=min(mf,e[i].c);
        for(int i=pre[sink];~i;i=pre[e[i].u]) e[i].c-=mf,e[i^1].c+=mf;
        ans+=dis[sink]*mf;
        FLOW+=mf;
    }
    return ans;
}

char g[55][55];
int DIS[55][55];
vector<pair<int, pii>> res;

const int mov[2][2]={{0,1},{1,0}};

void bfs(int sx,int sy)
{
    memset(DIS,63,sizeof DIS);
    res.clear();
    queue<pii> q;
    q.push(mp(sx,sy));
    DIS[sx][sy]=0;
    while(q.size())
    {
        int x=q.front().FI;
        int y=q.front().SE;
        res.pb(mp(-DIS[x][y],mp(x,y)));
        q.pop();
        rep(d,0,1)
        {
            int nx=x+mov[d][0];
            int ny=y+mov[d][1];
            if(DIS[nx][ny]==inf && (g[nx][ny]=='.' || g[nx][ny]=='o')) 
            {
                DIS[nx][ny]=DIS[x][y]+1;
                q.push(mp(nx,ny));
            }
        }
    }
    reverse(res.begin(),res.end());
}

int main()
{
    int n,m; scanf("%d%d",&n,&m);
    rep(i,1,n) scanf("%s",g[i]+1);
    int cnt=0;
    rep(i,1,n) rep(j,1,m) if(g[i][j]=='o') cnt++;
    int N=cnt,id=0;
    map<pii,int> ID;
    rep(i,1,n) rep(j,1,m) if(g[i][j]=='o')
    {
        bfs(i,j);
        id++;
        int l=res.size();
        rep(k,0,min(cnt-1,l-1))
        {
            int x=res[k].SE.FI;
            int y=res[k].SE.SE;
            if(ID[mp(x,y)]==0) ID[mp(x,y)]=++N;
            add(id,ID[mp(x,y)],1,res[k].FI);
        }
    }
    src=++N; sink=++N;
    rep(i,1,cnt) add(src,i,1,0); 
    rep(i,cnt+1,N-2) add(i,sink,1,0);
    printf("%d\n",-costflow(N)); 
    return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, m, i;
	cin >> n >> m;
	int ans = (n * (n - 1) / 2) + (m * (m - 1)) / 2;
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %.5lf",d,r,f);
return 0;}

Measured memory_bytes: 2708
import sys
input = sys.stdin.readline

n = int(input())
s = input()
s = list(s)

k = int(input())

temp = s[k-1]

# print(temp)

for i in range(n):
    if s[i] != temp:
        s[i] = '*'

# print(s)
s = ''.join(s)
print(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  int cnt = a;
  int ans = 1;
  while (cnt < b) {
    cnt += a-1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    bool res = false;
    for (int i = a; i <= b; i++) {
        res = res || i % k == 0;
    }

    cout << (res ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3636