akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
string k;
const ll L = 1e4 + 5;
ll dp[L][3][105], d;
ll rec(ll n, ll f, ll m)
{
	ll i;
	if(n == sz(k))
	{
		if(m == 0)
			return 1;
		return 0;
	}
	if(dp[n][f][m] != -1)
		return dp[n][f][m];
	ll l = 9;
	if(f)
		l = k[n] - '0';
	ll ans = 0;
	for(i=0;i<=l;i++)
	{
		ll nf;
		if(i < k[n] - '0')
			nf = 0;
		else
			nf = f;
		ans += rec(n+1,nf,(m+i)%d) % mod;
	}
	return dp[n][f][m] = ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	cin >> k >> d;
	ll i,j,p;
	for(i=0;i<=sz(k);i++)
		for(j=0;j<2;j++)
			for(p=0;p<d;p++)
				dp[i][j][p] = -1;
	cout << (mod + rec(0,1,0) - 1) % mod << endl;
	return 0;
}

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

typedef long long int ll;

ll solve(ll n)
{
	if(n == 1)
		return 1;
	else
		return  1LL + 2LL * solve(n/2);
}

int main()
{

	long long int n; cin >> n;
	cout << solve(n);

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n;
  string s1, s2;
  //char s1[101], s2[101];
  int r1 = 0, r2 = 0;
  
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    //scanf("%s %s", s1, s2);
    cin >> s1 >> s2;
    if(strcmp(s1.c_str(), s2.c_str()) == 1) r1 += 3;
    else if(strcmp(s1.c_str(), s2.c_str()) == 0) r1++, r2++;
    else r2 += 3;
  }
  
  cout << r1 << ' ' << r2 << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

template <class C> struct SegmentTreeBottomUp {
  using Data = typename C::Data; using Lazy = typename C::Lazy;
  int N; vector<Data> TR;
  template <class F> SegmentTreeBottomUp(int N, F f)
      : N(N), TR(N * 2, C::qdef()) {
    generate(TR.begin() + N, TR.end(), f);
    for (int i = N - 1; i > 0; i--) TR[i] = C::merge(TR[i * 2], TR[i * 2 + 1]);
  }
  template <class It> SegmentTreeBottomUp(It st, It en)
      : SegmentTreeBottomUp(en - st, [&] { return *st++; }) {}
  SegmentTreeBottomUp(int N, const Data &vdef)
      : SegmentTreeBottomUp(N, [&] { return vdef; }) {}
  void update(int i, const Lazy &v) {
    for (i += N, TR[i] = C::applyLazy(TR[i], v); i /= 2;)
      TR[i] = C::merge(TR[i * 2], TR[i * 2 + 1]);
  }
  Data query(int l, int r) {
    Data ql = C::qdef(), qr = C::qdef();
    for (l += N, r += N; l <= r; l /= 2, r /= 2) {
      if (l % 2) ql = C::merge(ql, TR[l++]);
      if (!(r % 2)) qr = C::merge(TR[r--], qr);
    }
    return C::merge(ql, qr);
  }
};

struct C {
  using Data = int;
  using Lazy = int;
  static Data qdef() { return numeric_limits<int>::min(); }
  static Data merge(const Data &l, const Data &r) {
    return max(l, r);
  }
  static Data applyLazy(const Data &l, const Lazy &r) {
    return l + r;
  }
};

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int H, W, M;
  cin >> H >> W >> M;
  vector<vector<int>> ws(H);
  vector<int> wCnt(W, 0);
  for (int i = 0; i < M; i++) {
    int h, w;
    cin >> h >> w;
    ws[--h].push_back(--w);
    wCnt[w]++;
  }
  SegmentTreeBottomUp<C> ST(wCnt.begin(), wCnt.end());
  int ans = 0;
  for (int h = 0; h < H; h++) {
    for (int w : ws[h]) ST.update(w, -1);
    ans = max(ans, sz(ws[h]) + ST.query(0, W - 1));
    for (int w : ws[h]) ST.update(w, 1);
  }
  cout << ans << nl;
  return 0;
}


Measured memory_bytes: 23248
package main

import(
    "fmt"
    "strconv"
)



func main() {
    var s string
    fmt.Scan(&s)
    a := s[:2]
    b := s[2:]
    c, _ := strconv.Atoi(a)
    d, _ := strconv.Atoi(b)
    ans := "NA"
    switch{
        case c>=1 && c<=12 && d>=1 && d<=12:
            ans = "AMBIGUOUS"
        case (c==0 && d>12) || (c>12 && d==0) || (c==0 && d==0):
            ans = "NA"
        case c>=1 && c<=12:
            ans = "MMYY"
        case d>=1 && d<=12:
            ans = "YYMM"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	long long x,id;
}s[7000004];
int cmp(node a,node b)
{
	if(a.x==b.x)return a.id<b.id;
	return a.x<b.x;
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>s[i].x,s[i].x-=1,s[i].id=i;
	for(int i=1;i<=n;i++)s[i].x=s[i-1].x+s[i].x,s[i].x%=m;
//	for(int i=0;i<=n;i++)cout<<s[i].x<<" ";cout<<endl;
	sort(s+1,s+1+n,cmp);//for(int i=0;i<=n;i++)cout<<s[i].x<<" ";cout<<endl;
	long long last=0,ans=0,cnt=0;
//	for(int i=1;i<=n;i++)if(s[i].x==1)ans++;
	int l=0,r=1;
	while(r<=n)
	{
	//	cout<<l<<" "<<r<<" ";
	//	cout<<s[l].id<<" "<<s[r].id<<" ";
		if(s[l].x!=s[r].x)
		{
			l=r;
			r++;
		}
		else 
		{
			while(s[r].id-s[l].id>=m&&l<r)
			{
				l++;
			}
			if(s[r].id-s[l].id<m)ans+=r-l,r++;
			else
			{
				l=r;r++;	
			}
		}
	//	cout<<ans<<endl;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
const int ININF = 1000000;

int main() {
    string hw[22];
    int H, W;
    cin >> H >> W;
    rep(i, 0, H) { cin >> hw[i]; }
    int res = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            if(hw[i][j] == '#') {
                continue;
            }
            int d[22][22];
            rep(t, 0, H) {
                rep(s, 0, W) { d[t][s] = ININF; }
            }
            d[i][j] = 0;
            queue<pair<int, int>> que;

            que.push(make_pair(i, j));
            // BFS 開始 (キューが空になるまで探索を行う)
            while(!que.empty()) {
                pair<int, int> tmp = que.front();
                que.pop();
                int a = tmp.first;
                int b = tmp.second;
                int count = d[a][b];
                if(a != 0 && hw[a - 1][b] == '.' && d[a - 1][b] > count + 1) {
                    d[a - 1][b] = count + 1;
                    que.push(make_pair(a - 1, b));
                }
                if(b != 0 && hw[a][b - 1] == '.' && d[a][b - 1] > count + 1) {
                    d[a][b - 1] = count + 1;
                    que.push(make_pair(a, b - 1));
                }
                if(a != H - 1 && hw[a + 1][b] == '.' &&
                   d[a + 1][b] > count + 1) {
                    d[a + 1][b] = count + 1;
                    que.push(make_pair(a + 1, b));
                }
                if(b != W - 1 && hw[a][b + 1] == '.' &&
                   d[a][b + 1] > count + 1) {
                    d[a][b + 1] = count + 1;
                    que.push(make_pair(a, b + 1));
                }
            }
            int max = 0;
            rep(t, 0, H) {
                rep(s, 0, W) {
                    if(d[t][s] != ININF && d[t][s] > max) {
                        max = d[t][s];
                    }
                    // cout << d[t][s] << " ";
                }
                // cout << endl;
            }
            if(res < max) {
                res = max;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s;
    int K;
    cin>>s>>K;
    int n=s.size();
    int N=min(n,K);
    map<string,int> m;
    rep(i,n){
        rep(j,N){
            m[s.substr(i,j+1)]++;
        }
    }
    int c=0;
    string ans;
    for(auto p:m){
        c++;
        if(c==K){
            ans=p.first;
            break;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 4800
#include <stdio.h>
int main(void)
{
	int i, n;
	char t[4];
	int c[4];
	for (i=0; i<4; ++i) c[i]=0;
	while (scanf("%d,%s", &n, t) != EOF) {
		switch (t[0]) {
			case 'A': if (t[1]=='B') c[2]++; else c[0]++; break;
			case 'B': c[1]++; break;
			case 'O': c[3]++; break;
		}
	}
	if (c[2] < 10) return 1;
	for (i=0; i<4; ++i) printf("%d\n", c[i]);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
 
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
 
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
 

int main(){
	int a ,b;
	cin>>a>>b;
	if((a*b)%2==1){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MN 201000

int a[MN];
long long f[MN][3];
long long s[MN];

int main()
{
	int n; scanf("%d", &n);
	long long ans = 1e18;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]), s[i] = s[i - 1] + a[i];
	for(int i = 1; i <= n; i++)
	{
		f[i][0] = std::min(f[i - 1][0], s[i - 1]) + (a[i] == 0 ? 2 : ((a[i] & 1) ? 1 : 0));
		f[i][1] = std::min(f[i - 1][0], std::min(f[i - 1][1], s[i - 1])) + (a[i] == 0 ? 1 : ((a[i] & 1) ? 0 : 1));
		f[i][2] = std::min(f[i - 1][1], f[i - 1][2]) + (a[i] == 0 ? 2 : ((a[i] & 1) ? 1 : 0));		
		ans = std::min(ans, std::min(std::min(f[i][0], f[i][1]), std::min(f[i][2], s[i])) + s[n] - s[i]);
	}
	printf("%lld\n", ans);
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main() {
    ll n, m, k;
    ll i, j, h;
    cin >> n >> m;
    if((n + m) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (n + m) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N;
    cin >> N;
    map<int,int> factor;
    int M = N;
    for(int i = 2; i*i <= M; i++){
        while(N % i == 0) {
            factor[i]++;
            N /= i;
        }
    }
    if(N != 1) factor[N]++;

    cout << M << ":";
    for(const pair<int,int>& p : factor){
        for(int i = 0; i < p.second; i++){
            cout << " " << p.first;
        }
    }
    cout << endl;


}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<double> x(n);
    rep(i,n)
    {
        x[i]=r[i];
        rep(j,i)
        {
            double t = x[j]+2*sqrt(r[i]*r[j]);
            x[i] = max(x[i],t);
        }
    }

    double ans = 0;
    rep(i,n) ans = max(ans,x[i]+r[i]);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
//D - equeue
int main(void){
    int n,k;
    std::cin >> n >>k;
    int i,j,p;
    int ans=0;
    int a[101],b[101];
    for (i = 1; i <= n; i++) {
        std::cin >> a[i];
    }
    for (i = 0; i <= k && i<=n; i++) {
        for (j = 0; j<=i; j++) {
            int l=j,cnt=0,res=0;
            //追加処理
            for(p=1;p<=l;p++)b[++cnt]=a[p];
            for(p=n;p>n-i+j;p--)b[++cnt]=a[p];
            sort(b+1,b+cnt+1);
            //取り除く処理
            for(p=1;p<=k-i && p<=cnt;p++)if(b[p]>=0)break;else b[p]=0;
            for(p=1;p<=cnt;p++)res+=b[p];
            ans=max(ans,res);
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k;
        return 0;
    }
    if(k>a&&k<=a+b){
        cout<<a;
        return 0;
    }
    int x=k-a-b;
    cout<<a-x;
    return 0;
}



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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    ll x;
    cin >> x;
    ll ans;
    if (x <= 6){
        ans = 1;
    } else if (x <= 11){
        ans = 2;
    } else {
        ans = x / 11 * 2;
        int mod = x % 11;
        if (mod > 0 && mod <= 6){
            ans++;
        } else if (mod > 6) {
            ans += 2;
        }
    } 
    cout <<  ans << endl;



    return 0;
}


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

n, k = map(int, input().split())
h = list(map(int, input().split()))

# K は必殺技
# 最小の攻撃数は？ 1減らし

h.sort(reverse=True)
r = h[k:]
rh = sum(r)

print(rh)

Measured memory_bytes: 26764
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in range(n):
  if a[i] in d.keys():
    d[a[i]] += 1
  else:
    d[a[i]] = 1
s = 0
for x in d.values():
  s += x*(x-1)//2
for i in range(n):
  print(s - d[a[i]] + 1)
  

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n;
int dp[301][301];
bool take[301][301];
int w[301];

int main() {
    while (cin >> n, n) {
        fill(dp[0], dp[n], 0);
        fill(take[0], take[n], false);
        rep(i, n) cin >> w[i];

        for (int len=0; len<n; ++len) {
            rep(i, n-len) {
                int l = i, r = i+len;

                // [l, k] + [k+1, r] -> [l, r]
                for (int k=l; k<r; ++k) {
                    if (take[l][k] and take[k+1][r]) take[l][r] = true;
                }

                if (len+1 == 2) {
                    if (abs(w[r]-w[l]) <= 1) take[l][r] = true;
                }
                if (take[l][r]) {
                    int ll = l-1, rr = r+1;
                    while (true) {
                        if (ll < 0 or ll >= n or rr < 0 or rr >= n) break;
                        if (abs(w[rr]-w[ll]) >= 2) break;
                        take[ll][rr] = true;
                        ll--; rr++;
                    }
                }
            }
        }

        rep(i, n) for (int j=i+1; j<n; ++j) {
            if (take[i][j]) dp[i][j] = j-i+1;
        }

        rep(i, n) for (int j=i; j<n; ++j) for (int k=i; k<j; ++k) {
            dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
        }

        cout << dp[0][n-1] << endl;
    }
}



Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> pi;
int k, x, y, t;
pi a[200020];
pi cal(int x, int y) {
    if (x > y) {
        pi t = cal(y, x);
        return {t.y, t.x};
    }
    if (x < 0) {
        pi t = cal(-x, y);
        return { -t.x, t.y};
    }
    if (x + y >= 2 * k) return {x, y - k};

    if (x + y == k) return {0, 0};
    return  { -k + (x + y) / 2, x + y - (x + y) / 2};
    int t = k - (x + y) / 2;
    return { -t, y - k + x + t};
}
int main() {
    scanf("%d%d%d", &k, &x, &y);
    if (!(k & 1) && (x + y) & 1) return puts("-1"), 0;
    a[0] = {x, y};
    for (; a[t].x || a[t].y; t++) a[t + 1] = cal(a[t].x, a[t].y);
    printf("%d\n", t);
    for (; t--;) printf("%d %d\n", a[t].x, a[t].y);
}

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

int main() {
  string s;

  int a[26] = {};

  while(getline(cin,s)){
    for(int i = 0; i < s.size(); i++){
      if(s[i] >= 'a' && s[i] <= 'z'){
        a[s[i] - 'a']++;
      }else if(s[i] >= 'A' && s[i] <= 'Z'){
        a[s[i] - 'A']++;
      }
    }
  }

  for (int i = 0; i < 26; i++) {
    cout  << (char)('a'+i) << " " <<  ":" << " " << a[i] << endl;
  }
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>

using namespace std;

int n,m;

int main() {

	cin >> n >> m;
	cout << n + m/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int cards[4][14] = {{0}};
        char suit;
        int rank;
        rep(i,n){
            cin >> suit >> rank;
            if(suit == 'S') cards[0][rank]++;
            else if(suit == 'H') cards[1][rank]++;
            else if(suit == 'C') cards[2][rank]++;
            else cards[3][rank]++;
        }
        rep(i,4){
            range(j,1,13+1){
                if(!cards[i][j]){
                    if(i == 0) cout << "S " << j << endl;
                    else if(i == 1) cout << "H " << j << endl;
                    else if(i == 2) cout << "C " << j << endl;
                    else cout << "D " << j << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 1164
N = int(input())
C = [int(input()) for _ in range(N)]
before = [-1] * (2 * 10**5 + 1)
count = [0] * (N + 1)
count[-1] = 1
mod = 10**9 + 7
for i in range(N):
    count[i] = count[i - 1]
    if 0 <= before[C[i]] < i - 1:
        count[i] += count[before[C[i]]]
        count[i] %= mod
    before[C[i]] = i
print(count[N - 1])


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

void solve(std::string b)
{
    if (b == "A")
    {
        cout << "T" << endl;
    }
    else if (b == "T")
    {
        cout << "A" << endl;
    }
    else if (b == "G")
    {
        cout << "C" << endl;
    }
    else if (b == "C")
    {
        cout << "G" << 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()
{
    std::string b;
    std::cin >> b;
    solve(b);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B));

        sc.close();
    }

    static int solve(int A, int B) {
        return A * B;
    }
}

Measured memory_bytes: 35652
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n, m;
  cin >> n >> m;

  vector<vector<int>> Graph(n, vector<int>(0));
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  int res = 0;
  vector<int> per(0);
  rep(i,n) per.push_back(i);
  do {
    if(per[0] != 0) continue;
    bool flag = true;
    rep(i,n-1) {
      int cnt = count(Graph[per[i]].begin(), Graph[per[i]].end(), per[i+1]);
      if(cnt == 0) flag = false;
    }
    if(flag) res++;
  } while(next_permutation(per.begin(), per.end()));

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

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int main(){
	int n;
	scanf("%d",&n);
	ll ans=1,y=1e18;
	double tmp=1;
	for(int i=1;i<=n;i++){
		ll x;
		scanf("%lld",&x);
		ans=ans*x;
		tmp=tmp*x;
	}
	if(ans>y||tmp>y) puts("-1");
	else printf("%lld\n",ans);
	return 0;
}

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

bool check(int a, int b, int c, int i){
  if(b>a && c>b){
    return true;
  }
  if(i<=0){
    return false;
  }
  if(check(2*a, b, c, i-1)){
    return true;
  }
    if(check(a, 2*b, c, i-1)){
    return true;
  } 
   if(check(a, b, 2*c, i-1)){
    return true;
  }
  return false;
}

int main(){
  int a,b,c, k;
  cin >> a >> b >> c >> k;
  
  if (check(a, b, c, k)){
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> dp(n, INT32_MAX), h(n);
    for (int i = 0; i < n; i++) { cin >> h[i]; }
    dp[0] = 0;
    for (int i = 1; i < k && i < n; i++) {
        for (int j = 0; j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    for (int i = k; i < n; i++) {
        for (int j = 0; j < k; j++) {
            dp[i] = min(dp[i], dp[i - k + j] + abs(h[i] - h[i - k + j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define N 200
//#define INFTY 1000000000

using namespace std;
static const long long INFTY = (1LL << 32);

long long A[N][N]; //隣接行列
//int c[N][N]; //最短距離の箱
int v;

void warshallFloyd() {
	for (int k = 0; k < v; k++) {
		for (int i = 0; i < v; i++) {
			if (A[i][k] == INFTY) {
				continue;
			}
			for (int j = 0; j < v; j++) {
				if (A[k][j] == INFTY) {
					continue;
				}
				A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
			}
		}
	}
}


int main() {
	int e;
	int s, t, d;


	cin >> v >> e;

	for (int i = 0; i < v; i++) {
		for (int j = 0; j < v; j++) {
			A[i][j] = INFTY;
			//cout << A[i][j] << " ";
		}
		//cout << endl;
	}
	   
	for (int i = 0; i < v; i++) {
		A[i][i] = 0;
	}


	for (int i = 0; i < e; i++) {
		cin >> s >> t >> d;
		A[s][t] = d;
	}


	warshallFloyd();

	bool negative = false;
	for (int i = 0; i < v; i++) {
		if (A[i][i] < 0) negative = true;
	}
	

	if (negative) cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < v; i++) {
			for (int j = 0; j < v; j++) {
				if (j != v - 1) {
					if (A[i][j] != INFTY) cout << A[i][j] << " ";
					else cout << "INF" << " ";
				}
				else {
					if (A[i][j] != INFTY) cout << A[i][j] << endl;
					else cout << "INF" << endl;
				}
			}
		}
	}

	return 0;
}
/*
4 6
0 1 1
0 2 5
1 2 2
1 3 4
2 3 1
3 2 7
*/




Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(string, s);
  int left = stoi(s.substr(0, 2));
  int right = stoi(s.substr(2));

  if (1 <= right && right <= 12) {
    if (1 <= left && left <= 12) {
      puts("AMBIGUOUS");
      return;
    } else {
      puts("YYMM");
      return;
    }
  } else {
    if (1 <= left && left <= 12) {
      puts("MMYY");
      return;
    } else {
      puts("NA");
      return;
    }
  }
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
dists = $<.map{|s|s.split.map &:to_i}

ans = 0
N.times{|i|
  (i+1...N).map{|j|
    a = dists[i][j]
    N.times.any?{|k|
      b = dists[i][k] + dists[k][j]
      if a > b
        p~0
        exit
      else
        a == b && i != k && j != k
      end
    } || ans += a
  }
}
p ans

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    VL d1(n), d2(n);
    rep(i, 0, n) cin >> d1[i] >> d2[i];
    ll mx = 0;
    ll cnt = 0;
    rep(j, 0, n) {
        if(d1[j] == d2[j]) cnt++;
        else cnt = 0;
        mx = max(mx, cnt);
    }
    if(mx >= 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define len(x)           x.length()
#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

//coded by Avijit Mandal 
ll n,m;
void dfs(vector<ll>adj[],ll v[],ll dp[],ll u){
   v[u]=1;
   for(int i=0;i<adj[u].size();i++){
      if(!v[adj[u][i]]){
         dfs(adj,v,dp,adj[u][i]);      
      }
      dp[u]=max(dp[u],1+dp[adj[u][i]]);
   }
}
void fun(vector<ll>adj[],ll v[],ll dp[]){
   for(int i=1;i<=n;i++){
      if(v[i]==0)
         dfs(adj,v,dp,i);
   }
}
int main(){
   IOS;
   ll i,j,k,t1,t2;
   cin>>n>>m;
   vector<ll> adj[n+1];
   ll dp[n+1];
   mem0(dp);
   for(i=0;i<m;i++){
      cin>>t1>>t2;
      adj[t1].push_back(t2);
   }
   ll v[n+1];
   mem0(v);
   fun(adj,v,dp);ll mx=0;
   for(i=0;i<=n;i++)mx=max(mx,dp[i]);
   cout<<mx<<"\n";
}


Measured memory_bytes: 10752
from heapq import heappush,heappop
n,m=map(int,input().split())
d=[]
for i in range(n):
  a,b=map(int,input().split())
  heappush(d,(a,b))
ans=0
while d:
  a,b=heappop(d)
  if m>b:
    ans+=a*b
    m-=b
  else:
    ans+=a*m
    break
print(ans)

Measured memory_bytes: 83960
from scipy import misc

N = int(input())
K = int(input())
d = len(str(N))
first = int(str(N)[0])
if K == 1:
    print(9*(d-1)+first)
elif K == 2:
    if d == 1:
        print('0')
    else:
        for i in range(1,d):
            if str(N)[i] != '0':
                second_dig = i+1
                second_num = int(str(N)[i])
                break
        else:
            second_dig = d
            second_num = 0
        print(((d-1)*(d-2)//2*81)+(first-1)*(d-1)*9+(d-second_dig)*9+second_num)
else:
    if K < 3:
        print('0')
    else:
        found_second = False
        found_third = False
        for i in range(1,d):
            if str(N)[i] != '0':
                if found_second == False:
                    second_dig = i+1
                    second_num = int(str(N)[i])
                    found_second = True
                else:
                    third_dig = i+1
                    third_num = int(str(N)[i])
                    found_third = True
                    break
        if found_second == False:
            print((d-1)*(d-2)*(d-3)//6*729+(first-1)*((d-1)*(d-2)//2*81))
        elif found_third == False:
            print((d-1)*(d-2)*(d-3)//6*729+(first-1)*((d-1)*(d-2)//2*81)+(second_num-1)*(d-second_dig)*9+(d-second_dig)*(d-second_dig-1)//2*81)
        else:
            print((d-1)*(d-2)*(d-3)//6*729+(first-1)*((d-1)*(d-2)//2*81)+(second_num-1)*(d-second_dig)*9+(d-second_dig)*(d-second_dig-1)//2*81+(d-third_dig)*9+third_num)

Measured memory_bytes: 14664
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int count(LL x) {
  int cnt = 0;
  while (x > 0 && x % 2 == 0) {
    x /= 2LL;
    ++cnt;
  }
  return cnt;
}

int main() {
  LL N, M; cin >> N >> M;
  vector<LL> a(N); cin >> a;
  int cnt0 = count(a[0]);
  if (cnt0 == 0) {
    cout << 0 << endl;
    return 0;
  }

  LL v = a[0]/2;
  for (int i = 1; i < N; ++i) {
    int cnt = count(a[i]);
    if (cnt0 != cnt) {
      cout << 0 << endl;
      return 0;
    }
    v = lcm(v, a[i]/2LL);
  }

  cout << M / v - M / (2LL * v) << endl;
}


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

e_all = S.count('E')

w_cnt = 0
e_cnt = 0
ans = float('inf')
for i in range(N):
    if S[i] == 'W':
        w_cnt += 1
        ans = min(ans, w_cnt - 1 + e_all - e_cnt)
    else:
        e_cnt += 1
        ans = min(ans, w_cnt + e_all - e_cnt)

print(ans)


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

int main()
{
    int n,m;
    while(cin >> n >> m)
    {
        for(int i = m / n;i > 0;i --)
        if(m % i == 0)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    vector<int> v;
    int num = 0;
    char prev = s[0];
    for(auto& c : s){
        if(c == prev){
            num++;
        }else{
            v.push_back(num);
            num = 1;
        }
        prev = c;
    }
    v.push_back(num);
    prints(v);
    int ans = *max_element(v.begin(), v.end());
    ans = max(ans, (n + 1)/ 2);
    for(size_t i = 1; i < v.size() - 1; i++){
        // ans = max(ans, min(v[i - 1], v[i]));
        ans = max(ans, min(v[i - 1], v[i + 1]) + v[i]);
    }
    int l = ans, r = n;
    printd(ans);
    while(l < r){
        int piv = (l + r + 1) / 2;
        int rem = n - piv;
        int maxi = 0;
        int idx = rem;
        while(idx < n && s[idx] == s[rem]){ idx++; }
        maxi = max(maxi, idx - rem);
        idx = n - 1 - rem;
        while(idx >= 0 && s[idx] == s[n - 1 - rem]){ idx--; }
        maxi = max(maxi, n - 1 - rem - idx);
        // maxi = max(maxi, n - idx - 1);
        int total = rem + maxi;
        if(total >= piv){
            l = piv;
        }else{
            r = piv - 1;
        }
    }
    // cout << ans << '\n';
    printd(l);
    cout << l << '\n';
}


Measured memory_bytes: 704
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, int>;
const int MAXN = 100005;

int n, x;
int b[MAXN], s[MAXN], e[MAXN];

bool trial(lint T){
	lint k = T / x, m = T % x;
	if(k == n) return 1;
	lint taken = 0ll;
	vector<pi> v;
	for(int i=0; i<n; i++){
		lint upCost = 1ll * (x - b[i]) * e[i] + 1ll * b[i] * s[i];
		taken -= 1ll * b[i] * s[i];
		v.emplace_back(upCost, i);
	}
	sort(v.rbegin(), v.rend());
	lint ksum = 0;
	lint kp1sum = 0;
	for(int i=0; i<n; i++){
		if(i < k) ksum += v[i].first;
		if(i <= k) kp1sum += v[i].first;
	}
	for(int i=0; i<n; i++){
		int j = v[i].second;
		if(i <= k){
			lint upV = kp1sum - v[i].first;
			upV += max((m - b[j]) * e[j], (m - b[j]) * s[j]) + 1ll * b[j] * s[j];
			if(upV + taken >= 0ll) return 1;
		}
		else{
			lint upV = ksum;
			upV += max((m - b[j]) * e[j], (m - b[j]) * s[j]);
			upV += 1ll * b[j] * s[j];
			if(upV + taken >= 0ll) return 1;
		}
	}
	return 0;
}

int main(){
	scanf("%d %d",&n,&x);
	for(int i=0; i<n; i++){
		scanf("%d %d %d",&b[i],&s[i],&e[i]);
	}
	lint s = 0, e = 1ll * n * x;
	while(s != e){
		lint m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m+1;
	}
	cout << s << endl;
}


Measured memory_bytes: 5652
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    int x = -1;
    int y = -1;
    int z = -1;
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N - i; j++) {
        int sum = i * 10000 + j * 5000 + (N - i - j) * 1000;
        if (sum == Y) {
          x = i;
          y = j;
          z = N - i - j;
          break;
        }
      }
    }
    System.out.println(x + " " + y + " " + z);
  }
}

Measured memory_bytes: 38956
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(void){
    int n, d;
    cin>>n>>d;
    vector<vector<double>> hoge(n, vector<double> (d));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin>>hoge.at(i).at(j);
        }
    }
    
    int ans=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            double distance=0;
            for(int l=0; l<d; l++){
                distance+=pow(hoge.at(i).at(l)-hoge.at(j).at(l),2);
            }
            distance=sqrt(distance);
            if(distance==floor(distance)) ans++;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int l[5],k,f=0;;
   cin>>l[0];cin>>l[1];cin>>l[2];cin>>l[3];cin>>l[4];cin>>k;
   for(int i=0;i<5;i++){
       for(int j=0;j<5;j++){
           if((l[i]-l[j])*(l[i]-l[j])>k*k)f=1;
       }
   }
   cout<<(f?":(":"Yay!");
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
typedef long long ll;
using namespace std;
const int N = 1 + 10;
int main() {
	int n, m, k;
	cin >> n >> m >> k;

	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= m; ++j) {
			if (i*m + j*n - 2 * i*j == k) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i + 1, f + s[i + 1]) + \
        dfs(i+1, f+"+"+s[i+1])


s = input()
n = len(s)

print(dfs(0, s[0]))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using ll=long long;
using namespace std;

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

    vector<char> c(N);
    int cnt=0;
    for(int i=0;i<N;i++){
        cin>>c[i];
        if(c[i]=='R'){
            cnt++;
        }
    }

    int ans=0;
    for(int i=0;i<cnt;i++){
        if(c[i]=='W'){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//int n,k;
//ll p[10000],c[10000];
//ll ans=-1000000000000000000LL;
//int main()
//{
//	cin>>n>>k;
//	for(int i=1;i<=n;i++)cin>>p[i];
//	for(int i=1;i<=n;i++)cin>>c[i];
//	for(int i=1;i<=n;i++)
//	{
//		int next=p[i];
//	    int l=1;
//	    ll s=c[next];
//		ans=max(ans,s);
//	    while(l<k&&next!=i)
//		{
//	    	next=p[next];
//	    	s+=c[next];
//	    	ans=max(ans,s);
//	    	l++;
//	    }
//	    if(s>=0LL&&l<k)
//		{
//	    	s*=(ll)((k-l)/l);
//	    	int t=k%l+l;
//	    	while(t>0)
//			{
//		        next=p[next];
//		        s+=c[next];
//		        if(s>ans) ans=s;        
//		        t--;
//			}
//		}
//	}
//	cout<<ans;
//	return 0;
//}
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
ll n,k,a[100005],b[100005],ans=-1000000000000000000;
bool vis[100005];
vector<ll>vec;
void dfs(ll i,ll cnt)
{
	if(vis[i])return;
	vis[i]=1;
	cnt+=b[i];
	vec.pb(cnt);
	dfs(a[i],cnt);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	forn(i,n)
	{
		cin>>a[i];
		a[i]--;
	}
	forn(i,n)cin>>b[i];
	forn(j,n)
	{
		memset(vis,0,sizeof(vis));
		vec.clear();
		dfs(j,0);
		if(vec.back()>0&&k>=vec.size())
		{
			ll q=k/vec.size();
			if(q>=1)
			{
				ll mx=-1000000000000000000;
				if(q-1>0)mx=0;
				forn(i,vec.size())mx=max(mx,vec[i]);
				ans=max(ans,(q-1)*vec.back()+mx);
			}
			int r=k%vec.size();
			ll mx=0;
			forn(i,r)mx=max(mx,vec[i]);
			ans=max(ans,mx+q*vec.back());
		}
		else
		{
			for(int i=1;i<=k;i++)
			{
				if(i-1<vec.size())ans=max(ans,vec[i-1]);
				else break;
			}
		}
	}
	cout<<ans;
	return 0;
}


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

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

template <class T>
struct Kruskal {
  struct UnionFind {
    int N;
    vector<int> sz_tree, parent;
    UnionFind() {}
    UnionFind(int N) : N(N), sz_tree(N, 1), parent(N) {
      iota(parent.begin(), parent.end(), 0);
    }
    int root(int x) {
      return parent[x] == x ? x : parent[x] = root(parent[x]);
    }
    void merge(int x, int y) {
      if ((x = root(x)) == (y = root(y))) return;
      if (sz_tree[x] < sz_tree[y]) swap(x, y);
      sz_tree[x] += sz_tree[y];
      parent[y] = x;
    }
    bool same(int x, int y) {
      return root(x) == root(y);
    }
    int size(int x) {
      return sz_tree[root(x)];
    }
  };
  struct edge {
    int from, to; T cost;
    edge() {}
    edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  };
 
  int N;
  vector<edge> es;
  Kruskal() {}
  Kruskal(int N) : N(N) {}
 
  void add_edge(int from, int to, T cost) {
    es.emplace_back(from, to, cost);
  }
  T mst() {
    T res = 0;
    UnionFind uf(N);
    sort(es.begin(), es.end(), [&](edge a, edge b) {
      return a.cost < b.cost;
    });
    for (auto &e : es) {
      if (uf.same(e.from, e.to)) continue;
      uf.merge(e.from, e.to);
      res += e.cost;
    }
    return res;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n, m;
  while (cin >> n, n) {
    cin >> m;
    Kruskal<int> K(n);
    for (int i = 0; i < m; i++) {
      int a, b, d;
      char c;
      cin >> a >> c >> b >> c >> d;
      K.add_edge(a, b, d / 100);
      K.add_edge(b, a, d / 100);
    }
    cout << K.mst() - (n - 1) << endl;
  }  

  return 0;
}


Measured memory_bytes: 3252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


string s;

int main() {

	cin >> s;

	rep(i, s.size()) {
		s[i] = 'x';
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> T(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }
  ll M;
  cin >> M;
  vector<ll> P(M), X(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
    P[i]--;
    cout << sum + X[i] - T[P[i]] << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int N;
   int count=1;
   //int map[20+2][20+2];
   while(cin>>N&&N)
   {
     int map[20+2][20+2]={{0}};
     bool flag=false;
     int step=1;
     cout<<"Case "<<(count++)<<":"<<endl;
     for(int i=0;i<2*N;i++)
     {
       if(i==0)  map[0][0]=(step++);
       else
       {
         if(flag==false)
         {
           for(int j=0;j<=i;j++)
           {
             if(j>=0&&j<N&&(i-j)>=0&&(i-j)<N)
             {
               map[j][i-j]=(step++);                 
             }          
           }    
           flag=true;
         }
         else
         {
           for(int j=0;j<=i;j++)
           {
             if(j>=0&&j<N&&(i-j)>=0&&(i-j)<N)
             {
               map[i-j][j]=(step++);                 
             }          
           }    
           flag=false;   
         }
       }       
     }
     for(int i=0;i<N;i++)
     {
       for(int j=0;j<N;j++)
       {
         if(map[i][j]<10) cout<<"  "<<map[i][j];
         else cout<<" "<<map[i][j];         
       }        
       cout<<endl;
     }                  
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3080
#include<stdio.h>
#include<cstdio>
#include<string>
#include<math.h>
using namespace std;

int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  printf("%d\n", (1900*M + 100*(N-M)) * (int)pow(2, M));
}

Measured memory_bytes: 128
from string import ascii_lowercase, ascii_uppercase
import sys
readline = sys.stdin.readline
write = sys.stdout.write

from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**100

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]
        self.D = {}

    def add_edge(self, fr, to, cap, cost):
        G = self.G
        G[fr].append([to, cap, cost, len(G[to])])
        G[to].append([fr, 0, -cost, len(G[fr])-1])
        self.D[fr, to] = G[fr][-1]
        self.D[to, fr] = G[to][-1]

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [0]*N

        while f:
            dist = [INF]*N
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                for i, (w, cap, cost, _) in enumerate(G[v]):
                    if cap > 0 and dist[w] > dist[v] + cost + H[v] - H[w]:
                        dist[w] = r = dist[v] + cost + H[v] - H[w]
                        prv_v[w] = v; prv_e[w] = i
                        heappush(que, (r, w))
            if dist[t] == INF:
                return -1

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, G[prv_v[v]][prv_e[v]][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = G[prv_v[v]][prv_e[v]]
                e[1] -= d
                G[v][e[3]][1] += d
                v = prv_v[v]
        return res

cs = ascii_uppercase + ascii_lowercase
L = len(cs)
def solve():
    N = int(readline())

    g = N*2
    mcf = MinCostFlow(N*2+2)
    for i in range(N):
        mcf.add_edge(g, i, 1, 0)
        mcf.add_edge(N+i, g+1, 1, 0)

    S = []
    for i in range(N):
        *Si, = map(cs.index, readline().strip())
        for j in range(N):
            mcf.add_edge(i, j+N, 1, -L**(L-Si[j]))
        S.append(Si)

    mcf.flow(g, g+1, N)
    ans = []
    for i in range(N):
        Si = S[i]
        for j in range(N):
            if mcf.D[i, j+N][1] == 0:
                ans.append(Si[j])
    ans.sort()

    write("".join(map(cs.__getitem__, ans)))
    write("\n")
solve()


Measured memory_bytes: 8060
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	
	// 確率
	double answer = 0.0;
	
	// N個のサイコロ
	for (int i = 1; i <= N; i++)
	{
		// サイコロの最初の確率
		double probability = 1.0 / N;
		// サイコロの得点
		int point = i;
		// 得点が1以上 K - 1以下の場合
		while(point < K)
		{
			point *= 2;
			// 確率 *= 0.5 (コインが表になる確率)
			probability *= 0.5;
		}
		answer += probability;
	}
	
	// 出力結果を出力例と同様にする対応
	cout << fixed << setprecision(12) << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256