akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int A,B;

vector<string>vec;
string S;
void dfs(int a,int b){
    if(A==a&&B==b){
        vec.pb(S);
        return;
    }
    if(A<a||B<b)return;

    if(a==5&&b<=3)return;
    if(b==5&&a<=3)return;
    if(a==4&&b==6)return;
    if(b==4&&a==6)return;
    if(a==5&&b==5)return;
    S[a+b]='A';dfs(a+1,b);
    S[a+b]='B';dfs(a,b+1);
}
signed main(){
    cin>>A>>B;
    S=string(A+B,'?');
    dfs(0,0);
    sort(all(vec));
    rep(i,vec.size())cout<<vec[i]<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    map<string, int> list;
    queue<int> que;
    vector<string> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        if(!list.count(A.at(i))) {
            list[A.at(i)] = 0;
        }
        list.at(A.at(i))++;
    }
    int M = 0;
    cin >> M;
    vector<string> B(M);
    for(int i = 0; i < M; i++) {
        cin >> B.at(i);
        if(!list.count(B.at(i))) {
            list[B.at(i)] = 0;
        }
        list.at(B.at(i))--;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans,list.at(A.at(i)));
    }
    for(int i = 0; i < M; i++) {
        ans = max(ans,list.at(B.at(i)));
    }

    cout << ans << endl;

    return 0;
}

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

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    
    string word = A + B + C;

    if (word == "575") {
        cout << "YES" << endl;
    } else if (word == "557") {
        cout << "YES" << endl;
    } else if (word == "755") {
        cout << "YES" << endl;
    } else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d)cout << a*b;
	else cout << c*d;
	cout << endl;

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    for(int i=0; i<s.size(); i++) {
        if (i % 2 != 0) {
            if (s[i] != '0') a++;
            else b++;
        } else {
            if (s[i] != '1') a++;
            else b++;
        }
    }
    cout << min(a, b) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;
    static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        int N = nint();
        int W = nint();
        int[] ws = new int[N+1];
        int[] vs = new int[N+1];
        for (int i = 1; i <= N; i++) {
            ws[i] = nint();
            vs[i] = nint();
        }
        long[][] sum = new long[N+1][W+1];
        for (int n = 1; n <= N; n++) {
            for (int w = 1; w <= W; w++) {
                long a = sum[n-1][w];
                long b = (w-ws[n] >= 0) ? sum[n-1][w-ws[n]] + vs[n] : -1;
                sum[n][w] = max(a, b);
            }
        }
        System.out.println(sum[N][W]);
    }
    static long max(long... longs) {
        long max = -INF;
        for (long i: longs) {
            max = Math.max(i, max);
        }
        return max;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 221776
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	
	while (n > 0)
	{
		n /= 10;
		
		count++;
	}
	return count;
}
int digit(int n)
{
	
	int ans=0;
	while (n > 0)
	{
		ans+=n%10;
		n /= 10;
		
		
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin>>n;
	vector<pair<int,int>>ab(n);
	rep(i,n){
		scanf("%d%d",&ab[i].F,&ab[i].S);
	}
	sort(all(ab),ps2);
	cout<<ab[0].F+ab[0].S<<endl;
	

}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

string check(string s, char c){
    int cnt = 0;
    char tmp = c == '(' ? '(' : ')';
    string ret = "";
    rep(i, s.size()){
        if(s[i] == c){
            cnt++;
            ret += s[i];
        }else{
            if(cnt == 0){
                ret = c + ret;
                cnt++;
            }
            ret += s[i];
            cnt--;
        }
    }
    return ret;
}

int main(){
    int n;
    string s, ans = "";
    cin >> n >> s;
    ans = check(s, '(');
    reverse(all(ans));
    ans = check(ans, ')');
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, m, a[1000], b[1000], sport[1000] = {0};
	int i,j;
	scanf("%d %d",&n,&m);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i<m; i++)scanf("%d",&b[i]);
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			if (b[i] >= a[j]) {
				sport[j]++;
				break;
			}
		}
	}
	int max = sport[0];
	int max_index = 0;
	for (i = 1; i < n; i++) {
		if (max < sport[i]) {
			max = sport[i];
			max_index = i;
		}
	}
	printf("%d\n",max_index+1);

	return 0;
}

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

int count(int n, int x){
   int cnt = 0;
    for ( int i = 1; i <= n-2; i++ ){
        for ( int j = i+1; j <= n-1; j++ ){
            for ( int k = j+1; k <= n; k++ ){
              if ( i + j + k == x ) cnt++;
            }
        }
    }
    return cnt;
}

int main(){
  int n, x;
    
    while(1){
      cin >> n >> x;
      if ( n == 0 && x == 0 ) break;
      cout << count(n, x) << endl;
    }   
    
    return 0;
}    

Measured memory_bytes: 1160
#!/usr/bin/env python3
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

rank_P = rank_Q = 0

for i, t in enumerate(permutations(range(1, N + 1)), start=1):
    if t == P:
        rank_P = i
        if rank_Q:
            break

    if t == Q:
        rank_Q = i
        if rank_P:
            break

print(abs(rank_P - rank_Q))


Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int n,m,x[maxn][maxn];
inline bool checkh(int h){
    for(register int j=1;j<=m;j++) if(x[h][j]) return false;
    return true;
}
inline bool checkl(int l){
    for(register int i=1;i<=n;i++) if(x[i][l]) return false;
    return true;
}
int main(){
    scanf("%d%d",&n,&m);char ch;
    for(register int i=1;i<=n;i++){
        getchar();
        for(register int j=1;j<=m;j++){
            ch=getchar();
            if(ch=='#') x[i][j]=1;
        }
    }
    for(register int i=1;i<=n;i++) if(checkh(i)){
        for(register int p=i;p<n;p++){
            for(register int q=1;q<=m;q++) x[p][q]=x[p+1][q];
        }
        n--;i--;
    }
    for(register int j=1;j<=m;j++) if(checkl(j)){
        for(register int q=j;q<m;q++){
            for(register int p=1;p<=n;p++) x[p][q]=x[p][q+1];
        }
        m--;j--;
    }
    for(register int i=1;i<=n;i++){
        for(register int j=1;j<=m;j++) putchar(x[i][j]?'#':'.');
        putchar('\n');
    }
    return 0;
}

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

int main() {


  string cat;
  string ans;
  cin >> cat;

  int sta = 0;
  for(int i=0;i<cat.size();i++) {
    if(sta == 0 && cat[i] == 'A') ans += 'A',sta = 1;
    if(sta == 1 && cat[i] == 'Z') ans += 'Z' ,sta = 0;

  }

  int b = ans.size();
  if(ans[ans.size()-1] == 'A') b--;
  if(b == 0) cout << -1 << endl;
  else {
  for(int i=0;i<b;i++) cout << ans[i];
  cout << endl;
  }

  return 0;

}

Measured memory_bytes: 1184
#include<stdio.h>

int main(void){
    register int i;
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int lc[n],rc[n],crl = 0,crr =0 ;
    for(i = 0;i < n;i++){lc[i] = 0; rc[i] = 0;}
    for(i = 0;i < n;i++){
        lc[i] = crl;
        if(s[i] == 'W')crl++;
        rc[n-i-1] = crr;
        if(s[n-i-1] == 'E')crr++;
    }
    int min = 1001001;
    for(i = 0;i < n;i++)if(min > rc[i]+lc[i])min = rc[i] + lc[i];
    printf("%d",min);
}

Measured memory_bytes: 2944
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

lli Euclid(lli a,lli b)
{
 
  lli r;
 
  if(a<b){
    swap(a,b);
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  return b;
}

int main(){
  lli A,B;
  cin >> A >> B;
  cout << (A*B)/Euclid(A,B) << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
fil=int((N-1)*(N-2)/2)
if K>fil:
  print(-1)
else:
  M=N-1+fil-K
  print(M)
  for i in range(N-1):
    print(1,i+2)
    count=0
  list=[]

  for j in range(2,N):
    for k in range(j+1,N+1):
      list.append((j,k))
  for i in range(fil-K):
    print(list[i][0],list[i][1])

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

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);

  ll r;
  if (k <= x / d) {
    r = x - k * d;
  } else if ((k - x / d) % 2 == 0) {
    r = x % d;
  } else {
    r = d - x % d;
  }
  cout << r << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    priority_queue<pair<ll,pair<ll,ll>>> q;
    vector<vector<ll>> z(n,vector<ll>(n));
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> z[i][j];
            if (i < j) {
                q.push(make_pair(z[i][j], make_pair(i, j)));
                ans += z[i][j];
            }
        }
    }
    
    while (!(q.empty())) {
        ll a = q.top().first;
        ll b = q.top().second.first;
        ll c = q.top().second.second;
        ll flag = 0;
        ll out = 0;
        for (int i = 0; i < n; i++) {
            if (i == b || i == c)continue;
            if (a > z[b][i] + z[c][i])out = 1;
            if (a == z[b][i] + z[c][i])flag = 1;
        }
        if (out == 1) {
            ans = -1;
            break;
        }
        if (flag == 1)ans -= a;
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5696
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int Max = 10000;
static const int Infty = (1<<20);
static const int W = 0;
static const int G = 1;
static const int B = 2;

int n;
vector<pair<int, int> > adj[Max];

void dijkstra(){
  priority_queue<pair<int, int> > PQ;
  int i, j, u, v, color[Max], d[Max];

  for(i = 0 ; i < n ; i++){
    d[i] = Infty;
    color[i] = W;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = G;

  while(!PQ.empty()){
    pair<int, int> f = PQ.top();
    PQ.pop();
    u = f.second;
    color[u] = B;

    if(d[u] < f.first * (-1)) continue;

    for(j = 0 ; j < adj[u].size() ; j++){
      v = adj[u][j].first;
      if(color[v] == B) continue;
      if(d[v] > d[u] + adj[u][j].second){
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = G;
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    cout << i << " " << (d[i] == Infty ? -1 : d[i]) << endl;
  }
}



int main(){
  int i, j, k, u, v, c;

  cin >> n;
  for(i = 0 ; i < n ; i++){
    cin >> u >> k;
    for(j = 0 ; j < k ; j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}


Measured memory_bytes: 8004
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  x=abs(x);
    ll amari=x%d;
    ll amarim=amari-d;
    ll waru=x/d;
    if(k<=waru){
      cout << abs(x-k*d) << endl;
      return 0;
    }
    else if((k-waru)%2==0){
      cout << abs(amari) << endl;
    }
    else
    cout << abs(amarim) << endl;
}



Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

ll dp[100100][2],a[100100];

int main(void){
	int n,i;
	fill(dp[0],dp[100100],-INFLL);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	dp[0][0] = a[0];
	for(i=1; i<n; ++i){
		dp[i][0] = max(dp[i][0],dp[i-1][0]+a[i]);
		dp[i][0] = max(dp[i][0],dp[i-1][1]+a[i]);
		dp[i][1] = max(dp[i][1],dp[i-1][0]-a[i-1]*2-a[i]);
		dp[i][1] = max(dp[i][1],dp[i-1][1]+a[i-1]*2-a[i]);
	}
	cout << max(dp[n-1][0],dp[n-1][1]) << endl;
	return 0;
}


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

char itoc(int i)
{
    return static_cast<char>('0' + i);
}

void solve(long long N, string S)
{
    int cnt = 0;
    for (size_t i = 0; i <= 999; i++)
    {
        string T = "000";
        T[2] = itoc(i % 10);
        T[1] = itoc((i / 10) % 10);
        T[0] = itoc((i / 100) % 10);

        // cout << T << endl;
        for (size_t i = 0; i < S.length(); i++)
        {
            if (S[i] == T[0])
            {
                for (size_t j = i + 1; j < S.length(); j++)
                {
                    if (S[j] == T[1])
                    {
                        for (size_t k = j + 1; k < S.length(); k++)
                        {
                            if (S[k] == T[2])
                            {
                                cnt++;
                                break;
                            }
                        }
                        break;
                    }
                }
                break;
            }
        }
    }
    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    cin >> N;
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 384
S = input()


def solve(n,S,idx):
    ans = 0
    if idx >= len(S):
        return eval(n)

    ans += solve(n+"+"+S[idx], S, idx+1)
    ans += solve(n+S[idx], S, idx+1)
    return ans

if len(S) == 1:
    print(S)
else:
    ans = solve(S[0], S, 1)
    print(ans)

Measured memory_bytes: 3060
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
    string s;
    cin>>s;
    string t;
    cin>>t;
    ll n = s.size();
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += (s[i] != t[i]);
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

deque<char> qq;

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

  string s; cin>>s;
  int rev = 0;
  for (char c: s) {
    qq.push_back(c);
  }
  int q; cin>>q;

  while (q--) {
    int typ; cin>>typ;
    if (typ == 1) {
      rev++;
    } else {
      int f; char c; cin>>f>>c;
      if (f == 1) {
	if (rev%2==0) {
	  qq.push_front(c);
	} else {
	  qq.push_back(c);
	}
      } else {
	if (rev%2==0) {
	  qq.push_back(c);
	} else {
	  qq.push_front(c);
	}
      }
    }
  }

  string res;
  for (char c: qq) res += c;
  if (rev%2) reverse(res.begin(), res.end());
  out(res);
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 1624
/// @author MuSTAFA MOGHAZY
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int arr [5][5];
int main()
{
  string a, b;
  cin>>a>>b;
  string s = a+b;
  int n = stoi(s);
  if( sqrt(n) - int(sqrt(n)) == 0 )
    cout<<"Yes";
  else
    cout<<"No";
}




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

int main()
{
	string A, B, C;
	string ans = "000";

	cin >> A >> B >> C;
	ans.at(0) = A.at(0);
	ans.at(1) = B.at(0);
	ans.at(2) = C.at(0);
	cout << ans << endl;
	return 0;
}

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

const int mxN=100;
int h, w, ei, ej, a1[mxN][mxN+1], a2[mxN+1][mxN];
short dp[mxN][mxN][mxN][mxN];
string s[mxN];

void ud(short &x, short y) {
	x=max(x, y);
}

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

	cin >> h >> w;
	for(int i=0; i<h; ++i) {
		cin >> s[i];
		for(int j=0; j<w; ++j) {
			if(s[i][j]=='E')
				ei=i, ej=j;
			a1[i][j+1]=a1[i][j]+(s[i][j]=='o');
			a2[i+1][j]=a2[i][j]+(s[i][j]=='o');
		}
	}
	memset(dp, 0xc0, sizeof(dp));
	dp[ei][ei][ej][ej]=0;
	for(int i1=ei; ~i1; --i1) {
		for(int i2=ei; i2<h; ++i2) {
			for(int j1=ej; ~j1; --j1) {
				for(int j2=ej; j2<w; ++j2) {
					int i3=max(i2-ei, i1), i4=min(h-1+i1-ei, i2)+1, j3=max(j2-ej, j1), j4=min(w-1+j1-ej, j2)+1;
					if(i1)
						ud(dp[i1-1][i2][j1][j2], dp[i1][i2][j1][j2]+(i1>i2-ei&&j3<j4?a1[i1-1][j4]-a1[i1-1][j3]:0));
					if(i2<h-1)
						ud(dp[i1][i2+1][j1][j2], dp[i1][i2][j1][j2]+(i2<h-1+i1-ei&&j3<j4?a1[i2+1][j4]-a1[i2+1][j3]:0));
					if(j1)
						ud(dp[i1][i2][j1-1][j2], dp[i1][i2][j1][j2]+(j1>j2-ej&&i3<i4?a2[i4][j1-1]-a2[i3][j1-1]:0));
					if(j2<w-1)
						ud(dp[i1][i2][j1][j2+1], dp[i1][i2][j1][j2]+(j2<w-1+j1-ej&&i3<i4?a2[i4][j2+1]-a2[i3][j2+1]:0));
				}
			}
		}
	}
	cout << dp[0][h-1][0][w-1];
}

Measured memory_bytes: 195712
#!/usr/bin/env python3

def is_palindrome(sn):
    return sn[0] == sn[4] and sn[1] == sn[3]

a, b = map(int, input().split())
res = 0
for n in range(a, b + 1):
    sn = "%5d" % n
    if is_palindrome(sn):
        res += 1

print(res)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
	return 0;
}


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

int main(){
	int n,m,c,ans=0;
	cin>>n>>m>>c;
	int a[m],b[m];
	for(int i=0;i<m;i++) cin>>b[i];
	for(int i=0;i<n;i++){
		int sum=c;
		for(int j=0;j<m;j++){
			cin>>a[j];
			sum+=a[j]*b[j];
		}
		if(sum>0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<vector<int>> edges(N + 1);
    for (int i = 0; i < M; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    int ans = 0;
    vector<bool> vis(N + 1, false);
    for (int i = 1; i <= N; ++i) {
        if (!vis[i]) {
            ++ans;
            vis[i] = true;
            queue<int> que;
            que.push(i);
            while (que.size()) {
                int cur = que.front();
                que.pop();
                for (int j = 0; j < (int)edges[cur].size(); ++j) {
                    int next = edges[cur][j];
                    if (vis[next]) {
                        continue;
                    }
                    vis[next] = true;
                    que.push(next);
                }
            }            
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6520
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	int h,w,n;cin>>h>>w>>n;
	cout<<ceil(1.0*n/max(h,w))<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 3005;

int n, l, t[N];
double ax, ay;

#define db double

const db pi = acos(-1);

int main() {
	scanf("%d %d", &n, &l);
	fo(i, 1, n) scanf("%d", &t[i]);
	fo(i, 1, n) fo(j, i + 1, n) {
		int v = t[i] + t[j] - l;
		ax += cos(pi * v / l) * (j - i - 1);
		ay += sin(pi * v / l) * (j - i - 1);
		v += l;
		ax += cos(pi * v / l) * (n - (j - i + 1));
		ay += sin(pi * v / l) * (n - (j - i + 1));
	}
	ax /= (double) n * (n - 1) * (n - 2) / 6;
	ay /= (double) n * (n - 1) * (n - 2) / 6;
	pp("%.9lf %.9lf\n", ax, ay);
}


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


Measured memory_bytes: 2044
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
string S,T;
const int S_MAX_LEN=1e5,T_MAX_LEN=1e5;
int psms[S_MAX_LEN+1][2],psmt[T_MAX_LEN+1][2];
int main(){
	cin>>S>>T;
	REP(i,(int)S.size()){
		REP(j,2){
			psms[i+1][j]=psms[i][j];
		}
		if (S[i]=='A'){
			psms[i+1][0]++;
		}else{
			psms[i+1][1]++;
		}
	}
	REP(i,(int)T.size()){
		REP(j,2){
			psmt[i+1][j]=psmt[i][j];
		}
		if (T[i]=='A'){
			psmt[i+1][0]++;
		}else{
			psmt[i+1][1]++;
		}
	}
	int q;
	cin>>q;
	REP(i,q){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<((((psmt[d][0]-psmt[c-1][0])-(psms[b][0]-psms[a-1][0]))-((psmt[d][1]-psmt[c-1][1])-(psms[b][1]-psms[a-1][1])))%3==0 ?  "YES" : "NO")<<endl;
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;


int main(){
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll t,i,q,j,x,y,k,temp,temp2,z,l,tt,n,m,sum=0;
    cin >> n;
    string a;
    cin >> a;
    ll w=0;
    for(i=0;i<n;i++){
        if(a[i]=='W') w++;
    }
    ll ans=0;
    for(i=n-1;i>=0;i--){
        if(w==0) break;
        else if(a[i]=='R') ans++;
        w--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
	int L;
	cin >> L;
	int A[L];
	for (int i=0;i<L;i++){
		cin >> A[i];
	}
	long int V[L][5];
	for(int i = 0;i<L;i++){
		for(int j=0;j<5;j++){
			V[i][j] = 0;
		}
	}
	V[0][0] = A[0];
	for (int i = 1;i<L;i++){
		V[i][0] = V[i-1][0] + A[i];
	}
	V[0][1] = A[0]%2;
	for (int i=1;i<L;i++){
		long int cost = 0;
		if(A[i] == 0){
			cost = 2;
		}
		else{
			cost = A[i] % 2;
		}
		V[i][1] = min(V[i-1][0],V[i-1][1]) + cost;
	}
	V[0][2] = (A[0] + 1) % 2;
	for (int i=1;i<L;i++){
		long int cost = 0;
		if(A[i] == 0){
			cost = 1;
		}
		else{
			cost = (A[i]+1) % 2;
		}
		V[i][2] = min({V[i-1][0],V[i-1][1],V[i-1][2]}) + cost;
	}
	V[0][3] = A[0]%2;
	for (int i=1;i<L;i++){
		long int cost = 0;
		if(A[i] == 0){
			cost = 2;
		}
		else{
			cost = A[i] % 2;
		}
		V[i][3] = min({V[i-1][0],V[i-1][1],V[i-1][2],V[i-1][3]}) + cost;
	}
	V[0][4] = A[0];
	for (int i=1;i<L;i++){
		V[i][4] = min({V[i-1][0],V[i-1][1],V[i-1][2],V[i-1][3],V[i-1][4]}) + A[i];
	}
	long int m = V[L-1][0];
	for(int i = 0;i<5;i++){
		m = min(m,V[L-1][i]);
	}
	cout << m << endl;
}


Measured memory_bytes: 8832
abcd = input()

n = ["+","-"]
for i1 in n:
  for i2 in n:
    for i3 in n:
      if eval(abcd[0]+i1+abcd[1]+i2+abcd[2]+i3+abcd[3]) == 7:
        print(abcd[0]+i1+abcd[1]+i2+abcd[2]+i3+abcd[3]+"=7")
        exit()

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4)
    {
        if (s[i] == '+')
            ans++;
        else
            ans--;
    }

    OP(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;

void add_self(int &a , int b){
    a += b;
    if(a >= Mod)
        a -= Mod;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n; cin >> n;
    string s; cin >> s;

    int dp[2][n+1];
    memset(dp , 0 , sizeof(dp));
    dp[0][1] = 1;
    
    for(int ln = 2 ;ln <= n; ++ln){

        for(int i = 1 ; i <= ln-1 ; i++)
            add_self(dp[0][i] , dp[0][i-1]);

        for(int curr = 1 ; curr <= ln ; curr++){
            int L , R;
            if(s[ln-2] == '<')
                L = 1 , R = curr-1;
            else    
                L = curr , R = ln-1;
            
            add_self(dp[1][curr] , (dp[0][R] - dp[0][L-1] + Mod)%Mod);
            
        }
        for(int i = 0 ;i <= n ; i++){
            dp[0][i] = dp[1][i];
            dp[1][i] = 0;
        }
    }

    int ans = 0;
    for(int i = 1;i <= n; i++)
        add_self(ans , dp[0][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 1e9+7, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;

/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */

bool solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll curr = a;
	fori(i, 1, 40) {
		// cout << curr << ' ';
		curr -= b;
		// cout << curr << ' ';
		if(curr <= c) curr += d;
	}
	// cout << endl;
	if(a < b) return false;
	if(b > d) return false;
	if(b == d) {
		if(a <= c) return true;
		return a - ((a-c)/b)*b >= b;
	}
	if(a <= c) return true;
	ll nxt = a - ((a-c)/__gcd(b, d)) * __gcd(b, d);
	// cout << nxt << endl;
	if(nxt == c) nxt += __gcd(b, d);
	// cout << nxt << endl;
	return nxt >= b;
}

int main() {
	iostream_optimize();
	int t;
	cin >> t;
	while(t--) cout << (solve() ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

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

int main()
{
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 30009
bool prime[N];
vector<ll> prm;
void seive ()
{

	memset(prime, true, sizeof(prime));

	for( ll i=2; i*i<=N; i++)
	{
		if (prime[i] == true)
		{
		    prm.pb(i);
			for (ll j=i*i; j<=N; j += i)
				prime[j] = false;
		}
	}
}
bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int , int >mp;
set<int  > st;
multiset<string> :: iterator it;
queue < int > q1,q2;
int vis [1000000];
//pair<int,int> a[2020];
int main()
{
    fast;
    string s;
    cin >> s;
    cout << s[0]<<s[1]<<s[2]<<endl;;

}







Measured memory_bytes: 3624
#include<stdio.h>

int main(){
    
    int x,h,m,s;
    
    scanf("%d",&x);
    
    if(x<0||x>86400) return 0;
    
    else{
        
        s=x%60;
        m=x/60;
        h=m/60;
        m=m%60;
        
        printf("%d:%d:%d\n",h,m,s);
        
        return 0;
        
        }
}


Measured memory_bytes: 2112
#include <stdio.h>

int cmp_max(int a, int b){
  if(a < b){
    return (b);
  }else{
    return (a);
  }
}

int cmp_min(int a, int b){
  if(a < b){
    return (a);
  }else{
    return (b);
  }
}
int main(){
  long long int a, b,t;
  long long int result1, result2;
  long long int min, max;
  while(scanf("%lld %lld", &a, &b) != EOF){
    result1 = result2 = 0;
    min = cmp_min(a, b);
    max = cmp_max(a, b);
    while((max % min) != 0){
      t = min;
      min = max % min;
      max = t;
    }
    result1 = min;
    result2 = a*b/result1;
    printf("%lld %lld\n", result1, result2);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000003
typedef long long ll;
using namespace std;

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

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

int main(){
  int Q;
  cin>>Q;
  
  setComb();
  for(int i=0;i<Q;i++){
    ll x,d,n;
    cin>>x>>d>>n;

    if(d==0){
      cout<<mod_pow(x,n)<<endl;
      continue;
    }

    x=x*inv[d]%MOD;
    x=(x+MOD)%MOD;

    if((x+n-1)>=MOD) cout<<0<<endl;
    else{
      ll ans=fac[(x+n-1)]%MOD;
      if(x==0){
        cout<<0<<endl;
        continue;
      }

      ans=ans*ifac[(x-1)]%MOD;
      ans=ans*mod_pow(d,n)%MOD;
      cout<<(ans+MOD)%MOD<<endl;
    }
    
  }

  return 0;
}


Measured memory_bytes: 24320
n = int(input())

if n<=9:
    print(n)
elif n<=99:
    print(9)
elif n<=999:
    s=9+n%100+1
    print(9+n-100+1)
elif n<=9999:
    print(909)
elif n<=99999:
    print(909+n-10000+1)
else:
    print(90909)

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

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
     
using namespace std;

main {
  int n;
  for(;;) {
    cin>>n;
    if(n==0)break;
    int a=0,b=0;
    rep(i,n) {
      int c,d;
      cin>>c>>d;
      if (c>d) a+=c+d; else if (c<d) b+=c+d; else {a+=c; b+=d;}
     }
    cout<<a<<' '<<b<<endl;
  }
  bye;
}

Measured memory_bytes: 2972
import numpy as np

N = int(input())
C = []
for _ in range(N):
    a, b = map(int, input().split())
    C.append([a+b, a, b])

D = sorted(C, reverse=True)

ans = 0

for i in range(N):
    if i % 2 == 0:
        ans += D[i][1]
    elif i % 2 == 1:
        ans -= D[i][2]

print(ans)


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

const int MOD = 1e9 + 7;

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	int pos;
	cin >> pos;
	
	int sum = 0;
	
	for(int i = 1 ; ; i ++){
		sum += i;
		if(sum >= pos){
			cout << i << "\n";
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#include <vector>
using namespace std;
 
 
int main(){
    int64_t n,ans=1;
    cin>>n;
    char key;
    
    vector<char> s(n);
    for(int i=0;i<n;i++)cin>>s.at(i);
    
   key=s.at(0);
   
    for(int i=1;i<n;i++){
        if(key!=s.at(i)){
            ans++;
            key=s.at(i);
        }
    }
    
    cout<<ans<<endl;
    
   
    
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc077.contest.atcoder.jp/tasks/arc077_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll n,m; cin >> n >> m;
    vector<ll> a(n); for(auto &in:a){ cin >> in; in--;}
    vector<ll> imos1(2*m,0);
    vector<ll> imos2(2*m,0);
    ll sum = 0;
    for(int i = 0; i < n-1;i++){
        ll l = a[i], r = a[i+1];
        if(r < l) r += m;
        sum += r - l;
        if(r - l <= 1) continue;
        imos1[l+2] += 1;
        imos1[r+1] -= 1;
        imos2[r+1] -= (r+1) - (l+2);
    }
    
    imos2[0] += imos1[0];
    for(int i = 0; i < 2*m-1;i++){
        imos1[i+1] += imos1[i];
        imos2[i+1] += imos2[i] + imos1[i+1];
    }
    
    vector<ll> dec(m);
    for(int i = 0; i < m;i++) dec[i] = imos2[i] + imos2[i+m];
    res = sum - *max_element(dec.begin(),dec.end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 4992
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vi arr(21,-1);
    int ans=0;
    int x,tmp=-1;
    for(int i=0;i<n;++i)
    {
        cin>>x;

        for(int j=0;j<21;++j)
        {
            if(x&(1<<j))
            {
                tmp=max(tmp,arr[j]);
                arr[j]=i;
            }
        }

        ans+=(i-tmp);
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define N 100002

int main(void){
  long long int x,a,b;
  int i,j,m;
  long long int t;
  
  m=200;
  
  scanf("%lld", &x);
  
  for(a=-m;a<m;a++){for(b=-m;b<m;b++){
    t=a*a*a*a*a - b*b*b*b*b;
    if(t==x) goto flag;    
  }}
  
  flag:
  printf("%lld %lld", a, b);
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int b[10],k[10],i,v1,v2;
  double h;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5],&b[6],&b[7],&b[8],&b[9],&v1,&v2)!=EOF) {
    k[0]=b[0];
	for (i=1;i<10;i++) k[i]=k[i-1]+b[i];
	h=(double)k[9]*v1/(v1+v2);
	for (i=0;i<10;i++) if (h>=k[i]-b[i] && h<=k[i]) break;
	cout << i+1 << endl;
  }
  return 0;
  }

Measured memory_bytes: 1208
//ABC084B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s == "Sunny"){
		cout << "Cloudy" << endl;
	}else if(s == "Cloudy"){
		cout << "Rainy" << endl;
	}else{
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256