akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.{readLine,readInt}

object Main extends App {


  def exec(w:String):Unit =  {
    val len = w.length

    if(w=="-") return else {
      val n = readInt
      var cnt = 0

      for(i <- 1 to n) cnt += readInt
      println((w drop (cnt%len)) + (w take (cnt%len)))
      exec(readLine)
    }
  }

  exec(readLine)
}

Measured memory_bytes: 43860
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF (1 << 21)
typedef long long ll;

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

  vector<int> V[n];
  // int E[n][n];
  map<pair<int, int>, int> E;
  int d[n];
  int visited[n];

  priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > Q;

  REP(i, n) {
    d[i] = INF;
    visited[i] = 0;
  }

  REP(_, n) {
    int u, k;
    cin >> u >> k;
    REP(__, k) {
      int v, c;
      cin >> v >> c;
      V[u].push_back(v);
      E[make_pair(u, v)] = c;
    }
  }

  d[0] = 0;
  Q.push(make_pair(d[0], 0));
  while (!Q.empty()) {
    int mincost = Q.top().first;
    int minv = Q.top().second;
    Q.pop();

    visited[minv] = 1;
    for (vector<int>::iterator it = V[minv].begin(); it != V[minv].end(); it++) {
      if (E[make_pair(minv, *it)] < INF && d[minv] + E[make_pair(minv, *it)] < d[*it]) {
        d[*it] = d[minv] + E[make_pair(minv, *it)];
        Q.push(make_pair(d[*it], *it));
      }
    }
  }

  REP(i, n) {
    cout << i << " " << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 36880
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

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

    if (s[0] == s[1]&&s[0] == s[2]&&s[2] == s[1])
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,x;
    scanf("%d %d",&n,&x);
    int i;
    int l[100];
    for(i=0;i<n;i++){
        scanf("%d",&l[i]);
    }
    int gokei=0;
    i=0;
    for(;;){
        gokei+=l[i];
        i++;
        if(gokei>x) break;
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


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

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((A + B) >= C)cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> v(100001, 0);
    int m = 0;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a == 0) {
            m++;
            v[a]++;
            v[a + 1]++;
        } else {
            v[a]++;
            v[a + 1]++;
            v[a - 1]++;
        }
    }
    int mx = -1;
    for (int i = 0; i <= 100000; i++) {
        if (mx < v[i]) {
            mx = v[i];
        }
    }
    cout << max(mx, m) << endl;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 2; i < s.size() - 1; i += 2)
	{
		int length = i / 2;
		if (s.substr(0, length) == s.substr(length, length))
			ans = i;
	}
	cout << ans << endl;

	return 0;
}


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

int main(void){
  int n, x, t;
  cin >> n >> x >> t;
  int cnt = n / x;
  if(n % x != 0) cnt++;
  int ans = cnt * t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#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 T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline int add(int x,int y,int mod){
    x+=y;
    if (x>=mod) return x-mod;
    return x;
}
inline int sub(int x,int y,int mod){
    x-=y;
    if (x<0) return x+mod;
    return x;
}
inline int mul(int x,int y,int mod){
    return (x*1ll*y)%mod;
}
inline int power(int x,int y,int mod){
    int ans=1;
    while(y){
        if (y&1) ans=mul(ans,x,mod);
        x=mul(x,x,mod);
        y>>=1;
    }
    return ans;
}
inline int inv(int x,int mod){
    return power(x,mod-2,mod);
}
/*-----------------------------Code begins----------------------------------*/



void solve(){
    ll n,w;cin>>n>>w;
    ll a[n][2];
    for(ll i=0;i<n;i++) cin>>a[i][0]>>a[i][1];

    vll dp(w+1,0);
    for(ll i=0;i<n;i++){
        for(ll j=w;j>=a[i][0];j--) dp[j]=max(dp[j], dp[j-a[i][0]]+a[i][1]);
    }
    cout<<*max_element(all(dp))<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

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

const int mul[3][3] = {{0, 0, 0}, {0, 1, 1}, {0, 1, 2}};
const int add[3][3] = {{0, 1, 2}, {1, 1, 2}, {2, 2, 2}};
const int neg[3] = {2, 1, 0};

int eval(string::iterator& c) {
	if(*c == '-') {
		return neg[eval(++c)];
	}
	if(*c == '(') {
		int left = eval(++c);
		c++;
		if(*c == '*') {
			int right = eval(++c);
			c++;
			return mul[left][right];
		}
		if(*c == '+') {
			int right = eval(++c);
			c++;
			return add[left][right];
		}
	}
	return *c-'0';
}

int main() {
	string S;
	while(cin >> S && S != ".") {
		int res = 0;
		rep(P,3) rep(Q,3) rep(R,3) {
			string s = S;
			int pos;
			pos = s.find("P");
			while(pos != string::npos) {
				s.replace(pos, 1, to_string(P));
				pos = s.find("P");
			}
			pos = s.find("Q");
			while(pos != string::npos) {
				s.replace(pos, 1, to_string(Q));
				pos = s.find("Q");
			}
			pos = s.find("R");
			while(pos != string::npos) {
				s.replace(pos, 1, to_string(R));
				pos = s.find("R");
			}
			string::iterator c = s.begin();
			if(eval(c) == 2) {
				res++;
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int cnt[1001]={0};
   int n;
   cin>>n;
   long long ans=1;
   for(int i=2;i<=n;i++){
    int k=i;
     for(int j=2;j<=sqrt(i);j++){
      while(k%j==0){
        cnt[j]++;
        k=k/j;
      }
     }
     if(k>1){
      cnt[k]++;
     }
   }
   //cout<<ans<<"\n";
   for(int i=2;i<=1000;i++){
       ll d=cnt[i]+1;
      ans*=d;
      ans%=mod;
   }
   cout<<ans<<"\n";




}

Measured memory_bytes: 3576
/*
 * B.cpp
 *
 *  Created on: 2020/08/02
 *      Author: 17k1028
 */



#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define REPD(i,n) for(ll i=n-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=a; i<=ll(b); i++)
#define FORD(i,a,b) for(ll i=a; i>=ll(b); i--)

int main(){
	ll N, D;
	cin >> N >> D;
	ll X[N],Y[N];
	REP(i,N){
		cin >> X[i] >> Y[i];
	}
	ll counter=0;
	REP(i,N){
		if((X[i]*X[i]+Y[i]*Y[i])<=D*D){
			counter++;
		}
	}
	cout << counter << endl;
}





Measured memory_bytes: 6752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	ll n,m;
	cin>>n>>m;
	ll r=-1,l=1e18+10;
	while(l-r>1){
		ll h=(l+r)/2;
		ll t=h;
		bool H=false;
		rep(i,n-1){
			if(t<t/m+1)H=true;
			t-=t/m+1;
		}
		if(!H)l=h;
		else r=h;
	}
	cout<<l<<endl;
}

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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int x = 0, y = 0, z = 0;
    rep(i, n)
    {
        if (p[i] <= a)
            x++;
        else if (a < p[i] && p[i] <= b)
            y++;
        else
            z++;
    }
    cout << min(x, min(y, z)) << endl;
}

int main(void)
{
    solve();
}

Measured memory_bytes: 3612
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
# a.sort()
check = [True for _ in range(10**6 + 5)]
dic = {}
if len(a) == 1:
    print(1)
    exit()

for i in a:
    if i in dic:
        dic[i] += 1
        continue
    dic[i] = 0
    now = 2 * i
    while (10**6 + 3 > now):
        check[now] = False
        now += i

ans = 0
for i in a:
    if check[i] and dic[i] == 0:
        ans += 1
print(ans)


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            var imp = Console.ReadLine().Split(' ');
            int[] data = new int[3];

            for(int i =0;i<3;++i)
            {
                data[i] = int.Parse(imp[i]);
            }

            Array.Sort(data);

            Console.Write(((data[1]) - (data[0])) + ((data[2]) - (data[1])));


            //System.Threading.Thread.Sleep(1000);
        }
    }
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int ans = (N-1) / (K-1);
    if((N-1)%(K-1) != 0) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
nums = [a, b, c, d, e]
ans = 'Yay!'
for i in range(0, 5):
    for j in range(0, 5):
        src = abs(nums[i] - nums[j])
        if src > k:
            ans = ':('
print(ans)

Measured memory_bytes: 3064
#include <numeric>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; for (auto& e : a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; for (auto& e : a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; for (auto& r : a) { for (auto& e : r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; for (auto& e : a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

#define forn(a, e) for (int a = 0; a < (int)e; a++)
#define forr(a, s, e) for (int a = s; a < (int)e; a++)

using i64 = long long;

template<typename T>
using Pair = array<T, 2>;

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

    int n;
    while (cin >> n) {
        int q;
        cin >> q;
        vector<vector<int>> g(n);
        forn(i, n - 1) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            g[a].push_back(b);
            g[b].push_back(a);
        }

        vector<int> inc(n);
        forn(i, q) {
            int x, p;
            cin >> p >> x;
            p--;
            inc[p] += x;
        }

        vector<int> used(n);
        vector<int> counter(n);
        function<void(int, int)> dfs = [&](int v, int cinc) {
            if (used[v]) {
                return;
            }
            used[v] = true;
            counter[v] = cinc + inc[v];
            for (auto u : g[v]) {
                dfs(u, cinc + inc[v]);
            }
        };
        dfs(0, 0);
        forn(i, n) {
            cout << counter[i] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 28160
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int nAns = 0;
    for(int i = 1; i < n; i++){
        nAns += (n-1) / i;
    }
    printf("%d", nAns);
        
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){

    int X,Y,Z;
    cin>>X>>Y>>Z;

    swap(X,Y); swap(X,Z);

    cout<<X<<" "<<Y<<" "<<Z<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct BinaryIndexedTree {
    vector<ll> data;
    BinaryIndexedTree(int size): data(size+1,0) {
        
    }
    int n=sz(data);
    void add(int a,ll w) {
        for(int i=a; i<=n; i+=(i&-i)) data[i] += w;
    }
    ll sum(int a) {
        int ret=0;
        for(int i=a; i>0; i-=(i&-i)) ret+=data[i];
        return ret;
    }
};


int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> vec(n+1,0);
    rep(i,n) {
        ll a;
        cin>>a;
        a-=k;
        vec[i+1]=vec[i]+a;
    }
    
    vector<ll> vals;
    rep(i,n+1) vals.push_back(vec[i]);
    sort(all(vals));
    vals.erase(unique(all(vals)),vals.end());
    
    rep(i,n+1) {
        int x=lower_bound(all(vals),vec[i])-vals.begin()+1;
        vec[i]=x;
    }
    
    BinaryIndexedTree BIT(300000);
    ll ans=0;
    rrep(i,n+1) {
        if(i!=n) ans+=(ll)((n-i)-BIT.sum(vec[i]-1));
        BIT.add(vec[i],1);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);


  int a,b;
  cin>>a>>b;
  int c=b-a;
  int w=0;
  for(int i=0;i<c;i++){
    w+=i;
  }
  
  cout<<w-a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100000 ;
///Power
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
   ll n,a,b ;
   cin>>n>>a>>b ;
   ll x=n/(a+b);
   ll ans=x*a ;
   ll y=n-x*(a+b) ;
   ans+=min(y,a) ;

   cout<<ans ;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <iomanip>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    int L;
    double a;
    cin >> L;
    a = L/3.0;
    // cout << a << endl;
    cout << setprecision(10) << a*a*a << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int fa[maxn];
struct Node{
  ll x, y, id;
}st[maxn];
 
struct Edge{
  ll cost, p1, p2;
}edge[maxn*2];

int cmp1(Node a,Node b){ 
	return a.x<b.x; 
}
int cmp2(Node a,Node b){ 
	return a.y<b.y; 
}
int cmp3(Edge a,Edge b){ 
	return a.cost<b.cost; 
}
 
int find(int u){
  	if(fa[u]==u) 
  		return fa[u];
  	return fa[u]=find(fa[u]);
}
 
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
		scanf("%lld%lld", &st[i].x, &st[i].y); 
		st[i].id=i; 
		fa[i]=i;
	}
    sort(st+1,st+1+n,cmp1);
    int cnt=0;
    for(int i=2;i<=n;i++){
        edge[++cnt].p1=st[i-1].id;
        edge[cnt].p2=st[i].id;
        edge[cnt].cost=st[i].x-st[i-1].x;
    }
    sort(st+1,st+1+n,cmp2);
    for(int i=2;i<=n;i++){
        edge[++cnt].p1=st[i-1].id;
        edge[cnt].p2=st[i].id;
        edge[cnt].cost=st[i].y-st[i-1].y;
    }
    sort(edge+1,edge+1+cnt,cmp3);
    ll ans=0;int num=0;
    for(int i=1;i<=cnt;i++){
        int fa_p1=find(edge[i].p1);
        int fa_p2=find(edge[i].p2);
        if(fa_p1==fa_p2) 
			continue;
        else{
            fa[fa_p1]=fa_p2;
            num++;
            ans+=(edge[i].cost);
        }
        if(num==n-1) break;
    }
    printf("%lld\n",ans);

    return 0;

}


Measured memory_bytes: 7680
#include<stdio.h>
#include<string.h>
int main(){
  int h=0,i;
  int b=0,e,p,q,r;
  char s[1026];
  fgets(s,1026,stdin);
  s[strlen(s)-1]='\0';
  for(;;){
    p=(int)strchr(s+b,' ');
    q=(int)strchr(s+b,',');
    r=(int)strchr(s+b,'.');
    if(p==0&&q==0&&r==0)
      e=strlen(s);
    else if(p<q&&p<r)
      e=(char*)p-s;
    else if(q<p&&q<r)
      e=(char*)q-s;
    else if(r<p&&r<q)
      e=(char*)r-s;
    if(3<=e-b&&e-b<=6){
      if(h)
	printf(" ");
      h=1;
      for(i=0;i<e-b;i++)
	printf("%c",s[b+i]);
    }
    if(e==strlen(s))
      break;
    b=e+1;
  }
  puts("");
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main
{
	private static int mesh[][];
	private static int dx[] = {0, 0,1,-1};
	private static int dy[] = {1,-1,0, 0};
	private static int w, h;
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			w = 12;
			h = 12;
			if (w == 0 && h == 0) break;
			mesh = new int [h][w];
			for (int i = 0; i < h; i++)
			{
				String str = sc.next();
				for (int j = 0; j < w; j++)
				{
					mesh[i][j] = str.charAt(j) - '0';
				}
			}
			System.out.println(countIlands(0));
		}
	}
	private static int countIlands(int n)
	{
		int x = -1;
		int y = -1;
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if (mesh[i][j] == 1)
				{
						x = i;
						y = j;
				}
			}
		}
		if (x == -1) return n;
		check(x, y);
		return countIlands(++n);
	}
	private static void check(int x, int y)
	{
		try
		{
			if (mesh[x][y] == 1)
			{
				mesh[x][y] = 0;
				for(int i = 0; i < 4; i++){
					check(x+dx[i], y+dy[i]);
				}
			}
		}
		catch (ArrayIndexOutOfBoundsException e)
		{
			return;
		}
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            b[i] = Integer.parseInt(sc.next());
        }
        int[] a = new int[n];
        a[0] = b[0];
        for (int i = 1; i < n - 1; i++) {
            a[i] = Math.min(b[i - 1], b[i]);
        }
        a[n-1] = b[n-2];

        System.out.println(IntStream.of(a).sum());
    }
}


Measured memory_bytes: 28884
S = list(input())

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
            continue
        else:
            print("No")
            exit()
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
            continue
        else:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 3060
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.contentEquals("ABC")) {
			System.out.println("ARC");
		}
		if(S.equals("ARC")) {
			System.out.println("ABC");
		}
	}
}


Measured memory_bytes: 35636
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	arr := strings.Split(sc.Text(), " ")
	nums := make([]int, 3)
	for i := range arr {
		nums[i], _ = strconv.Atoi(arr[i])
	}
	sort.Ints(nums)
	fmt.Println(nums[len(nums)-1] - nums[0])
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int a, b;
	char op;
	while(1){
		scanf("%d %s %d", &a, &op, &b);
		if(op == '?') break;
		switch (op){
			case '+':
				printf("%d\n", a + b);
				break;
			case '-':
				printf("%d\n", a - b);
				break;
			case '*':
				printf("%d\n", a * b);
				break;
			case '/':
				printf("%d\n", a / b);
				break;
			default:
				break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdio>
using namespace std;


string rev(int a, int b, string x){
    string res = "";
    for(int i = 0;i < x.size();i++){
	if(x[i] < 'a' || x[i] > 'z')res += x[i];
	else{
	    int p = x[i] - 'a';
	    p += b;
	    p *= a;	    
	    p %= 26;
	    res += 'a' + p;
	}
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    scanf("%*c");
    for(int i  = 0;i < n;i++){
	string input = "";
	char c;
	while(true){
	    c = getchar();
	    if(c == '\n' || c == EOF)break;
	    input += c;
	}
	string ans;
	for(int a = 1;a < 26;a++){
	    for(int b = 0;b < 26;b++){
		if(a % 2 == 0 || a % 13 == 0)continue;
		string o = rev(a, b, input);
		const char *orig = o.c_str();
		if(strstr(orig, "this") || strstr(orig, "that")){
		    ans = orig;
		}
	    }
	}
	cout << ans << endl;
    }
}

Measured memory_bytes: 1240
def solve():
    N = int(input())
    s = input()
    ans = 0
    for i in range(1000):
        t = str(i).zfill(3)
        t_index = 0 
        for s_index in range(N):
            if s[s_index] == t[t_index]:
                t_index += 1
                if t_index == 3:
                    break
        if t_index == 3:
            ans += 1
    print(ans)
solve()

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

class Program
{
    static void Main(string[] args)
    {

        var n = int.Parse(Console.ReadLine());
        var abcs = new int[n,3];
        for(int i= 0;i<n;i++)
        {
            var tmp = Console.ReadLine().Split(' ');
            abcs[i, 0] = int.Parse(tmp[0]);
            abcs[i, 1] = int.Parse(tmp[1]);
            abcs[i, 2] = int.Parse(tmp[2]);
        }
        List<int[]> dp = new List<int[]>();
        dp.Add(new[]{0,0,0});
        for(int i = 0; i < n; i++)
        {
            int[] tmp = new int[3];
            tmp[0] = abcs[i, 0] + Math.Max(dp[i][1], dp[i][2]);
            tmp[1] = abcs[i, 1] + Math.Max(dp[i][0], dp[i][2]);
            tmp[2] = abcs[i, 2] + Math.Max(dp[i][1], dp[i][0]);
            dp.Add(tmp);
        }

        Console.Write(dp.Last().Max());


    }
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int ans=0;
  if(K<=A){
    cout<<K<<endl;
    return 0;
  }
  ans+=A;
  K-=A;
  if(K<=B){
    cout<<ans<<endl;
    return 0;
  }
  K-=B;
  if(K<=C){
    cout<<ans-K<<endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int result = 0;
  for (int i = a; i <= b; ++i) {
    if (c % i == 0) ++result;
  }
  cout << result << endl;
  return 0;
} 



Measured memory_bytes: 3100
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph2 {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	private int[] discover; //discover time stamp, -1 for undiscovered
	private int[] finish; //finish time stamp
	public Graph2() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1; //-1, index
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1; //-1, index
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public int DFS(int v, int t0) {
		discover[v] = t0;
		LinkedList<Integer> nb = adjList.get(v);
		Iterator<Integer> it = nb.iterator();
		int t = t0;
		while(it.hasNext()) {
			int w = it.next();
			if(discover[w] == -1) {
				t ++; //one forward step
				t = DFS(w, t);
			}
		}
		finish[v] = t + 1; //+1 for backtrack step
		return t + 1;
	}
	
	public void timeStamp() {
		int v;
		discover = new int[totalVertex];
		finish = new int[totalVertex];
		for(v = 0; v < totalVertex; v ++) discover[v] = -1; //-1: not discovered
		int t = 0;
		for(v = 0; v < totalVertex; v ++) {
			if(discover[v] == -1) { //for disconnected graph, restart from an unvisited node
				t = DFS(v, t);
				t ++;
			}
		}
		//display the result
		for(v = 0; v < totalVertex; v ++) {
			System.out.println((v + 1) + " " + (discover[v] + 1) + " " + (finish[v] + 1));
			//+1, node 0 -> 1, 1 -> 2, etc
		}
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph2 g = new Graph2();
		g.loadAdjList();
		g.timeStamp();
	}
}


Measured memory_bytes: 28044
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define f(i,n) for(ll i=0;i<n;i++)
    #define fz for(ll j=i+1;j<n;j++)
    #define f2(i,n) for(ll i=1;i<=n;i++)
    #define endl "\n"
    #define vll vector <ll>
    #define sz(a) (ll)a.size()
    #define mod 1000000007
    #define pb push_back
    #define inf 1e13+5

    ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
    ll lcm(ll a, ll b){return a*b/gcd(a, b);}
    ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod; b/=2;a=a*a%mod;}return ans;}
    ll inverse(ll a, ll p){return fexp(a, p-2);} 

    ll dp[3003][3003];
    ll game(ll *arr,ll l,ll r){
        if(l>r)return 0;
        if(l==r)return arr[l];
        if(dp[l][r]!=-(ll)1e18)return dp[l][r];
        return ( dp[l][r]=max(arr[l]-game(arr,l+1,r), arr[r]-game(arr,l,r-1)) );
    }
    
    void solve(){
      ll n;cin>>n;
      ll a[n];f(i,n)cin>>a[i];
      f(i,n){
          f(j,n)dp[i][j]=-(ll)1e18;
      }
      ll ans=game(a,0,n-1);
      cout<<ans<<endl;
                                                                                    

    }


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

       
        ll t;
        t=1;
        // cin>>t;
        while(t--){
            solve();
        }

       
        
        return 0;
    }

Measured memory_bytes: 70912
n = gets.to_i
b = gets.split.map(&:to_i)

a = Array.new(n, 0)
b.each_with_index do |x, i|
  if i == 0
    a[i] = x
  else
    a[i] = [a[i], x].min   
  end
  a[i + 1] = x   
end

puts a.inject(:+)


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        for(int i=0;i<b;i++){
            cout<<a;
        }
    }else{
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
}

Measured memory_bytes: 256
// ABC154D3.cpp
//#include "pch.h"
#include <iostream>
#include<vector>
using namespace std;
int main()
{
    long long N,K;
    cin >> N >> K;
    vector<long long>p(N);
    long long ans2=0;
    for (int i = 0; i < N; i++)
    {
        cin >> p.at(i);
        ans2+=p.at(i);
    }
    long long max = 0;
    long long tmp = 0;
    for (long long i = 0; i < K; i++)
    {
        tmp += p.at(i);
    }
    long long left = 0;
    long long right = K;
    while (right < N) {
        tmp = tmp + p.at(right) - p.at(left);
        if (tmp > max) {
            max = tmp;
        }
        left++;
        right++;
    }
    if (K<N) {
            printf("%.10lf\n", (double)(max+K)/2.0);
    }else{
        printf("%.10lf\n", (double)(ans2+K)/2.0);
    }
}


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

int main(){
	int n;
	while(cin >> n){
		if(!n){
			break;
		}
		bool field[255][255];
		int  count = 0;
		for(int i=0;i<n;i++){
			string f;
			cin >> f;
			for(int j=0;j<n;j++){
				if(f[j] == '1')
					field[i][j] = 1;
				else
					field[i][j] = 0;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(field[i][j] == 1){
					int cnt=0;
					for(int k=0;k<n;k++){
						if((field[i+k][j] == 1) && (i+k < n)){
							cnt++;
						}
						else{		
							break;
						}
					}
					count = max(count,cnt);
					cnt = 0;
					for(int k=0;k<n;k++){
						if(field[i][j+k] == 1 && j+k < n){
							cnt++;
						}
						else
							break;
					}
					count = max(count,cnt);
					cnt = 0;
					for(int k=0;k<n;k++){
						if(field[i+k][j+k] == 1 && i+k < n && j+k < n)
							cnt++;
						else
							break;
					}
					count = max(count,cnt);
					cnt = 0;
					for(int k=0;k<n;k++){
						if(field[i+k][j-k] == 1 && i+k < n && j-k >= 0){
							cnt++;
						}
						else
							break;
					}
					count = max(count,cnt);
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e6 + 5, M = 1e5 + 5;

ll MOD(1e9 + 7);
long long pow(long long a, long long b)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}
inline long long InverseEuler(long long n)
{
    return pow(n,MOD-2);
}

ll f[N];

int main(){
    f[0] = 1;
    for(int i = 1 ; i < N ; ++i)
        f[i] = (f[i - 1] * 1LL * i) % MOD;
    int x, y;
    cin >> x >> y;
    if(x > y)swap(x, y);
    for(ll one = 1 ; one <= x ; ++one){
        ll two = (x - one) / 2;
        if((x - one) & 1)continue;
        if(one * 2LL + two == y){
            ll kolo = one + two;
            ll t7t = InverseEuler(f[one]);
            t7t *= InverseEuler(f[two]);
            t7t %= MOD;
            printf("%lld\n", (f[kolo] * t7t) % MOD);
            return 0;
        }
    }
    puts("0");
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define lint                     long long 
#define setbits(x)              __builtin_popcountll(x)
#define zrbits(x)               __builtin_ctzll(x)
#define zlbits(x)               __builtin_clzll(x)
#define parsbits(x)             __builtin_parityll(x)
#define mem(a, b)               memset(a, (b), sizeof(a))
#define MOD                     1000000007
#define inf                     1e17 
#define neginf                  -1e17 
#define sp(x,y)                 fixed<<setprecision(x)<<y
#define testcase(t)             lint t; cin>>t; while(t--)
#define power(a,b)              (double)pow((double)a,(double)b)
#define FOR(i,n)                for(lint i=0;i<n;i++)
#define gcd(a,b)                __gcd(a,b)
#define PI                      3.1415926535
#define pb                      push_back
#define ss                      second
#define ff                      first
#define umap                    unordered_map           
#define ummap                   unordered_multimap
#define uset                    unordered_set
#define umset                   unordered_multiset

             
typedef unsigned long long   ull;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
         
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    #ifndef ONLINE_JUDGE
  //  freopen("C:\\Users\\pranjal bhatt\\Desktop\\code contests\\input1.txt", "r", stdin);
    //freopen("C:\\Users\\pranjal bhatt\\Desktop\\code contests\\output1.txt", "w", stdout);
    //#endif
}

lint me(lint x, lint y, lint p)  
{  
    lint res = 1;     
     
    x = x % p; 
           
    if (x == 0) return 0; 
          
    while (y > 0)  
    {  
                
        if (y & 1)  
        res = (res*x) % p;  
          
                  
        y = y>>1;  
        x = (x*x) % p;  
    }  
    return res;  
}

    /*---------------------------SOLUTION---------------------------------*/

void solve()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    lint n;
    cin>>n;
    lint sum=0;
    lint arr[n];
    FOR(i,n){
    cin>>arr[i];
    sum=sum+arr[i];}
    lint avg=sum/n;
    lint avg1=avg+1;
    lint c=0;
    lint c1=0;
    for(lint i=0;i<n;i++)
    {
        c=c+((arr[i]-avg)*(arr[i]-avg));
        c1=c1+((arr[i]-avg1)*(arr[i]-avg1));
    }
    cout<<min(c,c1)<<endl;

}


int main()
{
    c_p_c();
    lint flg99=0;
    if(flg99==1)
    {
        testcase(t)
        {
             solve();
        }
    }
    else
    {
        solve();
    }
    return 0;
            
}
                
            
                

                

                



Measured memory_bytes: 3580
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
char str[maxn];
int main(){
	int n;
	scanf("%d",&n);
	getchar();
	scanf("%s",str);
	int sum=0;
	for(int cut=1;cut<n;cut++){
		int a[26]={0},ans=0;
		for(int i=0;i<cut;i++){
			if(a[str[i]-'a']==1)continue;
			for(int j=cut;j<n;j++){
				if(str[i]==str[j]&&a[str[i]-'a']==0){
					ans++;
					a[str[i]-'a']=1;
				}
			}
		}
		sum=max(sum,ans);
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll MAXQ = 64;
ll A[MAXQ];
ll B[MAXQ];
ll C[MAXQ];
ll D[MAXQ];

ll N, M, Q;

const ll MAXN = 12;
ll V[MAXN];

ll dfs(ll k)
{
    if (N <= k)
    {
        ll res = 0;

        rep (i, Q) if (V[B[i] - 1] - V[A[i] - 1] == C[i])
        {
            res += D[i];
        }

        return res;
    }

    ll ans = 0;

    for (ll v=(k==0?1:V[k-1]);v<=M;++v)
    {
        V[k] = v;

        const ll res = dfs(k + 1);
        ans = max(ans, res);
    }

    return ans;
}

int main()
{
    cin >> N >> M >> Q;
    rep (i, Q) { cin >> A[i] >> B[i] >> C[i] >> D[i]; }

    const ll res = dfs(0);
    cout << res << endl;

    return 0;
}


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

typedef long long ll;

int main() {
    string N;
    int K;
    cin >> N >> K;
    int l = N.size();
    vector<vector<vector<ll>>> dp(l + 1, vector<vector<ll>>(2, vector<ll>(K + 2, 0)));
    dp[0][0][0] = 1;
    rep(i, l) {
        int d = N[i] - '0';
        if (d == 0) {
            dp[i + 1][0][0] = dp[i][0][0];
            dp[i + 1][1][0] = dp[i][1][0];
        } else {
            dp[i + 1][0][0] = 0;
            dp[i + 1][1][0] = 1;
        }
        rep(k, K) {
            if (d == 0) {
                dp[i + 1][0][k + 1] = dp[i][0][k + 1];
                dp[i + 1][1][k + 1] = dp[i][1][k + 1] + dp[i][1][k] * 9; 
            } else {
                dp[i + 1][0][k + 1] = dp[i][0][k];
                dp[i + 1][1][k + 1] = dp[i][1][k] * 9 + dp[i][0][k] * (d - 1) + dp[i][1][k + 1] + dp[i][0][k + 1];
            }
        }
    }
    cout << dp[l][0][K] + dp[l][1][K] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t;cin >> n >> t;
    int ans=inf;
    REP(i,n){
        int a,b;cin >> a >> b;
        if(b<=t){
            chmin(ans,a);
        }
    }
    if(ans==inf){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3648
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) throws Exception{    
        Scanner sc = new Scanner(System.in);
        // code
       
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        String[] c = new String[h];
        
        for(int i=0; i<h; i++){
        	c[i] = sc.next();
        }
        
        for(int i=0; i<h; i++){
        	System.out.println(c[i]);
        	System.out.println(c[i]);
        }
        
        sc.close();
    }
    
    
    
    
 
}

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

int main ()
{
    int n,m,c=0;
    double s=0;
    cin>>n>>m;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        s+=x[i];
    }
    s=s/(4*m);
    sort(x,x+n);
    for(int i=n-1;i>=0;i--)
    {
        if(x[i]>=s)c++;
        else break;
    }

    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <sstream>
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const ll maxn = 1000005;
const double pi = acos(-1.0);

int n,k;
ll C[2005][2005];

int main()
{
    C[0][0] = 1;
    for(int i = 1; i < 2005; i ++)
    {   
        C[i][0] = 1;
        for(int j = 0; j < 2005; j ++)
        {
            C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            if(C[i][j] >= mod)
                C[i][j] -= mod;
        }
    }
    while(cin >> n >> k)
    {
        for(int i = 1; i <= k; i ++)
            cout << C[n - k + 1][i] * C[k - 1][i - 1] % mod << endl;

    }
    return 0;
}



Measured memory_bytes: 31616
$stdin = DATA if $stdin.eof?

appear_count = Hash.new(0)
ARGF.each_line do |line|
  line.downcase.each_char.group_by{|c| c}.map{|k, arr| appear_count[k] += arr.size}

end

('a'..'z').each do |c|
  puts "#{c} : #{appear_count[c]}"
end

__END__
This is a pen.
zzzz

Measured memory_bytes: 6104
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";
ll diff = 1e9;
string B = "753";

int main() {
	cin >> S;
	for(int i = 0; i < S.size() - 2; i++) {
		char A[15];
		A[0] = S[i];
		A[1] = S[i + 1];
		A[2] = S[i + 2];
		// A.clear();
		// A.push_back(S[i]);
		// A.push_back(S[i + 1]);
		// A.push_back(S[i + 2]);
		// cout << A << " ";
		 int val = atoi(A);
		if(diff >= abs(val - 753))
		{
			diff = abs((val - 753));
		}
	}
	printf("%lld\n", diff);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main(void) {
	int n, t, a, h, cout;
	double min = 99999;

	scanf("%d", &n);
	scanf("%d %d", &t, &a);

	for (int i = 0; i < n; ++i) {
		scanf("%d", &h);
		if (fabs(a - (t - h * 0.006)) < min) {
			cout = i+1;
			min = fmin(min, fabs(a - (t - h * 0.006)));
		}
	}

	printf("%d", cout);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
typedef int64_t ll;
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; }



int main() {
	int n;
	cin >> n;
	vector<int> H(n), P(n);
	for (int i = 0; i < n; i++)cin >> H[i];
	for (int i = 1; i < n; i++) if (H[i - 1] >= H[i])P[i] = 1;
	for (int i = 0; i < n; i++)if (P[i])P[i] += P[i - 1];
	cout << *max_element(P.begin(), P.end()) << endl;

}

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

int main()
{
    int a, b;
    vector<int>v;
    cin>>a>>b;
    int add = a + b;
    int sub = a - b;
    int mul = a * b;
    v.push_back(add);
    v.push_back(sub);
    v.push_back(mul);
    cout<<*max_element(v.begin(), v.end())<<endl;

}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int gcd(int a, int b){

	if(b < a) swap(a, b);

	if(a == 0) return b;
	else return gcd(a, b%a);


}

int main(void){

	int N; cin >> N;
	int ans; cin >> ans;
	REP(i,N-1){
		int A; cin >> A;
		ans = gcd(ans, A);
	}

	cout << ans << endl;
	return 0;

}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    int p[20];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int cnt = 0;
    
    for(int i=1;i<n-1;i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]){
            cnt++;
        }
        if(p[i-1] > p[i] && p[i] > p[i+1]){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    return 0;
}


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


using namespace std;

int Rank[10000], root[10000];

int findset(int s) {
	if (root[s] == s) {
		return s;
	}
	else {
		return root[s] = findset(root[s]);
	}
}

void unit(int x, int y) {
	x = findset(x);
	y = findset(y);

	if (x == y) {
		return;
	}

	if (Rank[x] < Rank[y]) {
		root[x] = y;
	}
	else if(Rank[x] == Rank[y]){
		root[y] = x;
		Rank[x]++;
	}
	else {
		root[y] = x;
	}
}

int main() {
	int n, q, com;
	scanf("%d %d", &n, &q);
	
	int x, y;
	for (int i = 0;i < n;i++) {
		Rank[i] = 0;
		root[i] = i;
	}
	for (int i = 0;i < q;i++) {
		scanf("%d %d %d",&com , &x, &y);
		if (com == 0) {
			unit(x, y);
		}
		else {
			if (findset(x) == findset(y)){
				printf("1\n");
			}
			else {
				printf("0\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3224