akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

/*
ダブリングは、全体の要素数がN個あって1回移動した時に
どの要素に到達するのか定まっているとき、
「K個先の要素を求めるのに 𝑂(𝐾) かかる」ような状況において

- 前処理：𝑂(𝑁log𝐾) 時間, 𝑂(𝑁log𝐾) 空間
- クエリ：𝑂(log𝐾)

で行うことができるようにするアルゴリズムです

前処理：「doubling[k][i] : 𝑖 番目の要素から 2𝑘 先の要素は何か」を以下の式を利用して計算
doubling[k+1][i] = doubling[k][doubling[k][i]]

クエリ：前処理した結果を利用して K 個先の要素を求める
現在地を now として、𝐾 を2進数として見た時の全ての桁について以下を行う
𝐾 の 𝑘 桁目 が 1 ならば now = doubling[k][now] とする
*/

int main() {
    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        A.at(i)--;  // 0-indexed に変更
    }

    int d = 1;
    // Kより大きいbit列を作る(2^d > Kとなるようなdを見つけている)
    while ((1LL << d) < K) d++;

    // doubling[k][i] : i番目から 2^k 進んだ町
    vector<vector<int> > doubling(d, vector<int>(N));

    // i番目から1進んだ町
    for (int i = 0; i < N; i++) {
        doubling.at(0).at(i) = A.at(i);
    }

    // 前処理 doubling の計算
    // doubling[d][0〜n-1]を求める
    // 町iから2^k個先の町がどこかという情報をもつdpテーブルを作成
    for (int k = 0; k < d - 1; k++) {
        for (int i = 0; i < N; i++) {
            doubling.at(k + 1).at(i) = doubling.at(k).at(doubling.at(k).at(i));
        }
    }

    // 現在の町
    int now = 0;
    // Kの桁を1桁目を見ていく
    for (int k = 0; K > 0; k++) {
        // Kのk桁目に1が立っているならば、now = doubling[k][now]と更新する
        if (K & 1) now = doubling.at(k).at(now);
        // Kの1桁目を消去
        K = K >> 1;
    }
    cout << now + 1 << endl;
}


Measured memory_bytes: 51708
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int asn = 0;
    REP(i,16){
        if(s[i]!=t[i])asn++;
    }
    cout << asn << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

bool div2(int n){
    dump(n);
    if(n%2==0 && n/2==1) return true;
    else if(n%2) return false;
    else return div2(n/2);
}

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

    ll res = s;
    ll cnt = 1;

    if(s==1){
        cout << 4 << endl;
        return 0;
    }

    while(1){
        if(div2(res)){
            break;
        }
        else if(res%2==0){
            cnt++;
            res = res/2;
        }
        else if(res%2!=0){
            cnt++;
            res = res * 3 + 1;
        }
    }

    if(res>=4){
        while(res!=4){
            cnt++;
            res/=2;
        }

        cout << cnt + 3 << endl;
        return 0; 
    }
    else if(res==2){
        cout << cnt + 3 << endl;
        return 0;
    }
    else if(res==1){
        cout << cnt + 3 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int zs,x,y;
string st;
int main()
{
	cin>>st;
	for (int i=0;i<=st.size()-1;i++)
	  if (x==y) {x++;if (st[i]=='p') zs--;} 
	    else {y++;if (st[i]=='g') zs++;}
	cout<<zs<<endl; 
	return 0;
}

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

int main() {
  int a;
  cin >> a;
  if (a%2 == 0) {
    cout << (a/2)*(a/2) << endl;
  }
  else {
    cout << (a/2)*(a/2+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=pow(10,9)+7;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
int main()
{
 ll j,i,n;
 cin>>n;
 long double cost[n],dp[n][n+1];
 for(i=0;i<n;i++)
    cin>>cost[i];
 for(i=0;i<n;i++)
     for(j=0;j<=n;j++) 
          dp[i][j]=0;
 dp[0][0]=1-cost[0];
 dp[0][1]=cost[0];
 for(i=0;i<n-1;i++)
 {
     for(j=0;j<=i+1;j++) 
     {
          dp[i+1][j]+=dp[i][j]*(1-cost[i+1]);
          dp[i+1][j+1]+=dp[i][j]*(cost[i+1]);
     } 
 }
 long double ans=0;
 for(i=n;i>=(n+1)/2;i--)
   ans+=dp[n-1][i];
 printf("%.15Lf",ans); 
 return 0;
}

Measured memory_bytes: 140928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		String str = sc.next();

		if (num < 3200) {
			str = "red";
		}
		System.out.println(str);
		sc.close();
	}
}


Measured memory_bytes: 22992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

ll nCrNaive(const long long n, long long k) {
    if (n < 0) return 0;
    if (k < 0) return 0;
    ll ret = 1;
    k = min(k,n-k);
    for (int i = 0; i < k; i++) {
        ret *= (ll)n - (ll)i;
        ret /= ll(i+1);
    }
    return ret;
}

void solve(long long N, std::vector<long long> A){
    unordered_map<ll,ll> m;
    for (long long i = 0; i < N; i++) {
        m[A[i]]++;
    }
    unordered_map<ll,ll> mcmb;
    ll sum=0;
    for (auto& e: m) {
        if(e.second>=2){
            mcmb[e.first]=nCrNaive(e.second, 2);
        }
        sum+=mcmb[e.first];
    }
    for (long long i = 0; i < N; i++) {
        cout << sum-(m[A[i]]-1) << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 16072
from collections import deque
def main():
    # 最短距離に使うマス以外を黒に塗る
    # そもそも右下のゴールに辿り着けないなら-1
    # ans = 元の白個数-最短距離 if ゴール到達可能 else -1
    H,W = map(int, input().split())
    sx,sy = 0,0
    road = [[False]*W for _ in range(H)]
    origWhite = 0
    for i in range(H):
        c = input()
        for j in range(W):
            if c[j]=='.':
                road[i][j] = True
                origWhite += 1

    # H*Wのマスをs->gへ移動
    # ゴールできるか + ゴールまでの"最短距離"を知る
    gx,gy = (H-1),(W-1)
    directions = [(1,0),(0,1),(-1,0),(0,-1)] # 東西南北に移動可能
    depth = [[0]*W for _ in range(H)]
    arrived = [[False]*W for _ in range(H)]
    arrived[sx][sy] = True
    que = deque([(sx,sy)]) # BFS:appendleftとpopでキュー
    while que:
        x1,y1 = que.pop()
        for dx,dy in directions:
            x2,y2 = x1+dx,y1+dy
            # 枠外
            if x2<0 or H<=x2 or y2<0 or W<=y2:
                continue
            # 壁
            if not road[x2][y2]:
                continue
            # 探索済み
            if arrived[x2][y2]:
                continue
            que.appendleft((x2,y2))
            arrived[x2][y2] = True
            depth[x2][y2] = depth[x1][y1]+1
            if (x2,y2)==(gx,gy):
                print(origWhite-(depth[x2][y2]+1))
                return
    print(-1)


main()


Measured memory_bytes: 40432
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto rgb = readints;
    int x = 100 * rgb[0] + 10 * rgb[1] + rgb[2];
    writeln(x % 4 == 0 ? "YES" : "NO");
}


Measured memory_bytes: 256
# ABC 054 D
N, Ma, Mb = map(int, input().split())
P = [list(map(int, input().split())) for k in range(N)]
INF = 10000
dp = [[[INF for m in range(401)] for k in range(401)] for l in range(N+1)]
dp[0][0][0] = 0

for k in range(N):
    a = P[k][0]
    b = P[k][1]
    c = P[k][2]
    for l in range(401):
        for m in range(401):
            if dp[k][l][m] != INF:
                dp[k+1][l][m] = min(dp[k+1][l][m],dp[k][l][m])
                dp[k+1][l+a][m+b] = min(dp[k+1][l+a][m+b], dp[k][l][m]+c) 

ans = INF
for l in range(1,401):
    for m in range(1,401):
        if Ma*m == Mb*l:
            ans = min(ans,dp[N][l][m])

print(ans if ans != INF else -1)

Measured memory_bytes: 59988
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion


signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> u(M), v(M);

  vector<vector<int>> g(N);
  rep(i, M) {
    cin >> u[i] >> v[i];
    u[i]--, v[i]--;
    g[u[i]].pb(v[i]);
    g[v[i]].pb(u[i]);
  }

  int single = 0, bipart = 0, not_bipart = 0;

  vector<int> color(N, -1);
  rep(i, N) {
    if (len(g[i]) == 0) {
      single++;
      continue;
    }

    if (color[i] != -1)
      continue;

    bool is_bipart = true;
    queue<int> q;
    q.push(i);
    color[i] = 0;
    while (!q.empty()) {
      int i = q.front();
      q.pop();
      int c = color[i];

      int nc = 1 - c;
      for (int ni : g[i]) {
        if (color[ni] == -1) {
          color[ni] = nc;
          q.push(ni);
        } else if (color[ni] != nc) {
          is_bipart = false;
        }
      }
    }

    (is_bipart ? bipart : not_bipart)++;
  }

  int not_single = N - single;

  int ans = 0;
  ans += single * not_single * 2 + single * single;
  ans += bipart * bipart * 2;
  ans += bipart * not_bipart * 2;
  ans += not_bipart * not_bipart;

  cout << ans << endl;
}

Measured memory_bytes: 13056
# abc177_b
s, t, match = input(), input(), 0
for i in range(len(s) - len(t) + 1):
	temp = 0
	for j in range(len(t)):
		if s[i + j] == t[j]:
			temp += 1
	if match < temp:
		match = temp
print(len(t) - match)

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  scanf("%d", &n);

  vector<int> v(n);
  REP(i, n) {
    scanf("%d", &v[i]);
  }

  double an = 0;
  REP (i, n) an += v[i];

  double ave = an / n;

  int ans = 0;
  double now = 1000000;
  REP (i, n) {
    if (now > abs(ave - v[i])) {
      ans = i;
      now = abs(ave - v[i]);
    }
  }

  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;







int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    ll n,m;
    ll k;
    cin>>n>>m>>k;
    string s[n+10];
    for(ll i=0; i<n; i++)
        cin>>s[i];
    ll ans=0;
    for(ll i=0; i<(1<<n); i++)
    {
        for(ll j=0; j<(1<<m); j++)
        {
            ll cnt=0;
            for(ll x=0; x<n; x++)
            {
                if((i&(1<<x)))
                    continue;
                for(ll y=0; y<m; y++)
                {
                    if((j&(1<<y)))
                        continue;

                    if(s[x][y]=='#')
                        cnt++;
                }
            }
            if(cnt==k)
                ans++;
        }
    }
    cout<<ans<<nn;






}


/* Final check before submit :

1. array size or integer overflow.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/



Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int m=n;
    int count = 0;
    for(int i=0;i<=11;i++){
        if(m<pow(10,i)) break;
        count += n%10;
        n/=10;
    }
    if(m%count!=0){
        cout << "No" << endl;
    }else if(m%count == 0){
        cout << "Yes" << endl;
    }
}

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

void Main() {
  int N;
  cin >> N;
  if (N % 1000 == 0) cout << 0 << endl;
  else cout << 1000 - (N % 1000) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3580
X,K,D = map(int,input().split())

Xmin = X - D*K
Xmax = X + D*K

if Xmin * Xmax <= 0:
    ans = min(Xmax%(2*D), 2*D - (Xmax%(2*D)))
elif Xmin > 0:
    ans = Xmin
else:
    ans = -Xmax

print(ans)


Measured memory_bytes: 61792
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;

int pre1[N], pre2[N];
int sa[N], sb[N];

int main ()
{
	string s1, s2;
	cin >> s1 >> s2;
	int n = s1.size(), m = s2.size();
	
	for (int i = 0; i < n; i++) {
		sa[i+1] = s1[i];
	}
	for (int i = 0; i < m; i++) {
		sb[i+1] = s2[i];
	}
	
	for (int i = 1; i <= n; i++) 
	{
		if (sa[i] == 'A') {
			pre1[i] = pre1[i-1] + 1;
		} else {
			pre1[i] = pre1[i-1] + 2;
		}
	}
	for (int i = 1; i<= m; i++) 
	{
		if (sb[i] == 'A') {
			pre2[i] = pre2[i-1] + 1;
		} else {
			pre2[i] = pre2[i-1] + 2;
		}
	}
	
	int q;
	cin >> q;
	while (q--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum1 = pre1[b]-pre1[a-1], sum2 = pre2[d]-pre2[c-1];
		cout << (sum1%3 == sum2%3 ? "YES\n" : "NO\n");
			continue;
	}
	return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<cctype>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    int a=0;
    int b=0;
    int c=0;
    string s,t,ss;
    int ap;
    cin>>s>>t;
    ss=s+s;
    ap=ss.find(t);
    if(ap!=-1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 3216
A, B, C, X, Y = map(int, input().split())
sum_1 = A * X + B * Y
sum_2 = C * min(X, Y) * 2 + A * (X - min(X, Y)) + B * (Y - min(X, Y))
sum_3 = C * max(X, Y) * 2
print(min(sum_1, sum_2, sum_3))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

template<typename T>
struct Point {
	T x, y;
	Point(T x=0, T y=0):x(x), y(y) {}
	Point(pair<T, T> p): x(p.first), y(p.second) {}
	Point operator + (const Point &o){ return Point(x+o.x, y+o.y); }
	Point& operator += (const Point &o){ x += o.x; y += o.y; return *this; }
	Point operator - (const Point &o){ return Point(x-o.x, y+o.y); }
	Point& operator -= (const Point &o){ x -= o.x; y -= o.y; return *this; }
	T dot(const Point &o){ return x*o.x + y*o.y; }
	T det(const Point &o){ return x*o.y-y*o.x; }
};


int main(){
	int N;
	cin >> N;
	vector<ll> X(N), Y(N);
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i];
	vector<Point<ll>> Ps(N);
	for(int i=0; i<N; i++) Ps[i] = Point<ll>(X[i], Y[i]);

	vector<pair<double, int>> rads;
	for(int i=0; i<N; i++){
		double rad;
		if(X[i]>0) rad=atan((double)Y[i]/X[i]);
		else if(X[i]<0) rad=atan((double)Y[i]/X[i])+M_PI;
		else if(X[i]==0 && Y[i]>0) rad=M_PI/2;
		else rad=-M_PI/2;
		rads.push_back({rad, i});
	}

	sort(rads.begin(), rads.end());
	ll ans = 0;
	for(int i=0; i<N; i++){
		Point<ll> sum;
		for(int j=0; j<N; j++){
			sum += Ps[rads[(i+j)%N].second];
			debug(any{i, j, sum.x, sum.y});
			ans = max(ans, sum.dot(sum));
		}
	}

	cout << setprecision(20) << sqrt(ans) << endl;

	return 0;
}


Measured memory_bytes: 384
import sys
import heapq
import math


def main():
    n, m = [int(s) for s in sys.stdin.readline().strip().split()]
    a = [int(s) for s in sys.stdin.readline().strip().split()]

    q = []
    for ai in a:
        heapq.heappush(q, - ai)

    for i in range(m):
        value = heapq.heappop(q)
        discounted = math.ceil(value / 2)
        heapq.heappush(q, discounted)

    print(- sum(q))


main()


Measured memory_bytes: 89856
x = input()
y = x.split(" ")
cookie = [int(i) for i in y]
if(cookie[0] >= cookie[2] or cookie[1] >= cookie[2] or cookie[0]+cookie[1] >= cookie[2]):
    print(cookie[2] + cookie[1])
else:
    print(2*cookie[1] + cookie[0] + 1)

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

int main() {
  long N;
  cin >> N;
  for(int i = (int)sqrt(N); i>0; i--) {
    if(N%i==0){
      long a=1;
      int b=0;
      while(a<=N/i){
        a*=10;
        b++;
      }
      cout<<b<<endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

const static int MAX=1000005;
const static int INF=(1<<28);
int T[MAX];
int res(int n){
	vector<int> C;
	for(int i=1;i*(i+1)*(i+2)/6<=n;i++){
		C.push_back(i*(i+1)*(i+2)/6);
	}
	
	
	for(int i=0;i<=n;i++){
		T[i]=INF;
	}
	
	T[0]=0;
	
	int k=C.size();
	
	for(int i=0;i<k;i++){
		for(int j=0;j+C[i]<=n;j++){
			T[j+C[i]]=min(T[j+C[i]],T[j]+1);
		}
	}
	return T[n];
}

int odd(int n){
	vector<int> C;
	for(int i=1;i*(i+1)*(i+2)/6<=n;i++){
		int t=i*(i+1)*(i+2)/6;
		if(t%2==1){
			C.push_back(t);
		}
	}	
	for(int i=0;i<=n;i++){
		T[i]=INF;
	}
	
	T[0]=0;
	
	int k=C.size();
	
	for(int i=0;i<k;i++){
		for(int j=0;j+C[i]<=n;j++){
			T[j+C[i]]=min(T[j+C[i]],T[j]+1);
		}
	}
	return T[n];	
}

int main()
{
	int n;
	while(true){
		cin>>n;
		if(n==0)break;
		int a=res(n);
		int b=odd(n);
		cout<<a<<" "<<b<<endl;
	}	
}


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    string S;
    cin>>N>>S;
    int x=0;
    int answer=0;
    rep(i,N) {
        if(S[i]=='I') x++;
        else x--;
        answer=max(answer,x);
    }
    cout<<answer<<endl;
}

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

int main(){
    int r, d, x;
    cin >> r >> d >> x;

    for(int i = 0; i < 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

vector<pii> g[100005];
int z[100005];

void dfs(int x, int p) {
    for (pii i : g[x]) if (i.first != p) {
        if (i.second) z[i.first] = !z[x];
        else z[i.first] = z[x];
        dfs(i.first, x);
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, u, v, w;
    cin >> n;
    for (int i = 1; i < n; i++) cin >> u >> v >> w, w %= 2, g[u].push_back({v, w}), g[v].push_back({u, w});
    dfs(1, 1);
    for (int i = 1; i <= n; i++) cout << z[i] << '\n';
}


Measured memory_bytes: 8448
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll X, Y;
  cin >> X >> Y;
  rep(i, X + 1)
  {
    rep(j, X + 1)
    {
      if (2 * i + 4 * j == Y && i + j == X)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3724
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int gcd(int a, int b){
   int tmp;
   while(a%b!=0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   if(n==0||n==1) return false;
   vector<bool> a(n+1);
   fill(ALL(a),true);
   FOR(i,2,n/2+1){
      if(!a[i]) continue;
      for(int j=2;i*j<=n;j++){
         a[i*j]=false;
      }
   }
   return a[n];
}

int main(){
   int n,ans;
   string s,min;
   cin >> n;
   REP(i,n){
      cin >> s;
      sort(ALL(s));
      min=s;
      reverse(ALL(s));
      ans=toInt(s)-toInt(min);
      cout << ans << endl;
   }
}

Measured memory_bytes: 1236
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int n;
    long long unsigned int power = 1;
    cin >> n;
    for(int i = 1; i < n + 1; i++){
        if(pow(10,9) + 7 > power){
            power = power * i;
        }else{
            power = (power % ( (int)pow(10,9) + 7) ) * i;
        }
    }
    cout << power % ((int)pow(10,9) + 7) << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let c = read::<i64>();
    let d = read::<i64>();

    let x = c*d;
    let y = x / gcd(max(c, d), min(c, d));

    let bet = b-a+1;

    let dc = b / c;
    let dd = b / d;
    let dcd = b / y;

    let sdc = (a-1) / c;
    let sdd = (a-1) / d;
    let sdcd = (a-1) / y;

    println!("{}", bet - ((dc+dd-dcd) - (sdc+sdd-sdcd)));
}

fn gcd(a :i64, b :i64) -> i64 {
    if b == 0 {
        return a;
    }

    return gcd(b, a%b);
}

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

using namespace std;

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

    cin >> d >> t >> s;

    if(d/s<=t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y123123
#define int ll

using namespace std;

const int N = 3e5 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;

int n, q, timer;
int tin[N], tout[N], ps[N];
vector<int> a[N];
int d[N], ans[N];

void dfs(int v, int pr = 0){
    tin[v] = ++timer;
    ps[timer] = v;
    for(int i = 0; i < a[v].size(); ++i){
        int to = a[v][i];
        if(to == pr)continue;
        dfs(to, v);
    }
    tout[v] = timer;
}

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

    cin >> n >> q;
    for(int i = 1; i < n; ++i){
        int x, y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    dfs(1);
    for(int i = 1; i <= q; ++i){
        int x, y;
        cin >> x >> y;
        d[tin[x]] += y;
        d[tout[x] + 1] -= y;
    }
    for(int i = 1; i <= n; ++i)d[i] += d[i - 1];
    for(int i = 1; i <= n; ++i)ans[ps[i]] = d[i];
    for(int i = 1; i <= n; ++i){
        cout << ans[i] << " ";
    }
}


Measured memory_bytes: 35968
import scala.io.StdIn.readInt

object Main {
  def pow(x:Long, y:Long):Long = {
    def pow2(m:Long, n:Long, odd:Long, b:Long):Long = {
      n match {
        case 0 => 1
        case 1 => m*odd
        case _ =>
          pow2(m*m, n/2, (if(n%2==1) odd*b else odd), b*b)
      }
    }
    pow2(x, y, 1, x)
  }

  def getZeros(n:Long,ct:Long,i:Long):Long = {
    val d = n/pow(5,i)
    if(d>0) getZeros(n,d+ct,i+1) else ct
  }

  def main(args:Array[String]) = {
    var n = 0;
    while( {n=readInt;n}!= 0 )
      println(getZeros(n,0,1))
  }
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int N, A, B, C, X, Y[105];
  while(1){
    cin>>N>>A>>B>>C>>X;
    if(N==0) break;
    REP(i,0,N) cin>>Y[i];

    int cnt = 0, i = 0;
    for(i=0;i<10001;i++){
      if(Y[cnt] == X) cnt++;
      if(cnt == N) break;
      X = (A*X + B)%C;
    }

    if(cnt == N) cout<<i<<endl;
    else cout<<-1<<endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

  string X; cin >> X;

  ll s = 0;

  ll ans = 0;
  rep(i,X.size()){
    if(X[i] == 'T'){
      if(s == 0 )ans ++;
      else s--;
    }
    if(X[i] == 'S') s++;
  }

  cout << ans * 2 << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>
using namespace std;

int bit[100001];
int n,q;

void add(int i,int v){
	while(i<=n){
		bit[i] += v;
		i += i & -i;
	}
}

int sum(int i){
	int res = 0;
	while(i>0){
		res += bit[i];
		i -= i & -i;
	}
	return res;
}


int main(){
	scanf("%d %d",&n,&q);
	fill(bit,bit+n+1,0);
	for(int i=0;i<q;i++){
		int cmd,x,y;
		scanf("%d %d %d",&cmd,&x,&y);
		if(cmd==0){
			add(x,y);
		}else{
			printf("%d\n",sum(y)-sum(x-1));
		}
	}
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int like[40] = {};
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      like[A - 1]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (like[i] == N) ans++;
  }

  cout << ans << endl;
}

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

int main(void){
    
    int Num;
    int Input[1001];
    int i;
    float average,Mix;
    float answer;
    
    while(1){
        scanf("%d",&Num);
        if(Num==0) break;
        
        Mix=0;
        answer=0;
        
        for(i=0;i<Num;i++){
            scanf("%d",&Input[i]);
            Mix+=Input[i];
        }
        average = Mix/Num;
        
        for(i=0;i<Num;i++){
            answer += (Input[i]-average)*(Input[i]-average);
        }
        printf("%f\n",sqrt(answer/Num));
    }
}


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

using namespace std;

int solve(vector<long long int> &pos, const int posCnt, long long int neg, const int negCnt)
{
    if (neg >= 0)
        return 0;
    sort(pos.begin(), pos.end(), greater<long long int>());
    for (int i = 0; i < posCnt; i++)
    {
        neg += pos[i];
        if (neg >= 0)
            return i + 1 + negCnt;
    }
    return -1;
}

int main()
{
    int n;
    scanf("%d", &n);
    vector<long long int> dif(n), pos(n);
    long long int neg = 0;
    int posCnt = 0, negCnt = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &dif[i]);
    }
    for (int i = 0; i < n; i++)
    {
        long long int buf;
        scanf("%lld", &buf);
        buf = dif[i] - buf;
        if (buf > 0)
            pos[posCnt++] = buf;
        else
        {
            neg += buf;
            negCnt++;
        }
        dif[i] = buf;
    }

    pos.resize(posCnt);
    printf("%d\n", solve(pos, posCnt, neg, negCnt));

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{
	int n;
	vector<ll> a;
	int ans = 0;
	int temp;
	bool flag = true;
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> temp;
		a.push_back(temp);
	}
	sort(a.begin(), a.end());

	if (n != 1) {
		temp = a[0];
		for (i = 1; i < n; i++) {
			if (temp == a[i]) {
				if (flag == true) {
					flag = false;
				}
				else {
					flag = true;
				}
			}
			else {
				temp = a[i];
				if (flag == true) {
					ans++;
				}
				flag = true;
			}
		}

		if (flag == true) {
			ans++;;
		}
	}
	else {
		cout << 1 << endl;
		return (0);
	}

	cout << ans << endl;

	return (0);
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = Integer.parseInt(scan.next());
		int w = Integer.parseInt(scan.next());		
		int i=0;
		int j=0;
		while(h!=0 && w!=0){
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					if(j%2==0 && i%2==0)
						System.out.print("#");
					else if(j%2!=0 && i%2==0)
						System.out.print(".");
					else if(j%2==0 && i%2!=0)
						System.out.print(".");
					else
						System.out.print("#");
				}
				System.out.println("");
			}	
			h = Integer.parseInt(scan.next());
			w = Integer.parseInt(scan.next());
                        System.out.println("");	
		}
	}
}

Measured memory_bytes: 25784
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="MON")cout<<6;
    else if(s=="TUE")cout<<5;
    else if(s=="WED")cout<<4;
    else if(s=="THU")cout<<3;
    else if(s=="FRI")cout<<2;
    else if(s=="SAT")cout<<1;
    else if(s=="SUN")cout<<7;
    return 0;
}
    

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

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

        int H = sc.nextInt();
        int N = sc.nextInt();

        int sumA = 0;

        for (int i = 0; i < N; i++) {
            sumA += sc.nextInt();
        }

        System.out.println(H <= sumA ? "Yes" : "No");
    }
}


Measured memory_bytes: 47936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout << a << " " << b << endl;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

vector<int>E[200000];

int dfs(int v,int p){
	int cnt=0;
	for(int u:E[v]){
		if(u==p)continue;
		cnt+=dfs(u,v);
	}
	if(cnt>1){
		puts("First");exit(0);
	}
	return !cnt;
}

int main(){
	int n;cin>>n;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	if(dfs(0,-1)){
		puts("First");
	}
	else puts("Second");
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  string ans="";
  for(int i=0;i<s.size();i++){
    if (s.at(i) == '0') ans += '0';
    if (s.at(i) == '1') ans += '1';
    if(s.at(i) == 'B' && ans != "") ans.pop_back();
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int N, K;
string S;

int main() {
	cin >> N >> K >> S;
	S[K - 1] += 32;
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 3612
package main

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

var sc = NewScanner()

const (
	None = iota
	Black
	White
)

var (
	visited []int
	m       [][]Edge
)

type Edge struct {
	from int
	to   int
	dist int
}

type Stack struct {
	slice []Edge
}

func (s *Stack) Push(e Edge) {
	s.slice = append(s.slice, e)
}

func (s *Stack) Pop(e Edge) Edge {
	top := s.slice[len(s.slice)-1]
	s.slice = s.slice[:len(s.slice)-1]
	return top
}

func (s *Stack) Len() int {
	return len(s.slice)
}

func main() {
	n := sc.NextInt()
	m = make([][]Edge, n+1)
	var u, v, w int
	for i := 0; i < n-1; i++ {
		u = sc.NextInt()
		v = sc.NextInt()
		w = sc.NextInt()
		m[u] = append(m[u], Edge{from: u, to: v, dist: w % 2})
		m[v] = append(m[v], Edge{from: v, to: u, dist: w % 2})
	}

	visited = make([]int, n+1)
	DFS(1, 0)
	for i := 1; i < n+1; i++ {
		fmt.Println(visited[i] % 2)
	}
}

func DFS(v int, depth int) {
	if depth%2 == 0 {
		visited[v] = White
	} else {
		visited[v] = Black
	}
	for _, edge := range m[v] {
		if visited[edge.to] == None {
			DFS(edge.to, depth+edge.dist)
		}
	}
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc}
}

func (sc *Scanner) NextInt() int {
	sc.sc.Scan()
	i, err := strconv.Atoi(sc.sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

Measured memory_bytes: 27392
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch, ch2;
    int i, j, n, m;

    str = sc.nextLine(); m = str.length();
    ch = new char[m]; ch2 = new char[m];
    for(i = 0;i < m;i++){
      ch[i] = str.charAt(i); ch2[i] = ch[i];
    }

    n = 0; i = 23;
    for(j = 0;j < m;j++){
      if(ch[j] >= 'A' && ch[j] <= 'Z'){
        ch2[j] = (char)((ch[j] + i) % ('Z' + 1));
        if(ch2[j] < 'A')ch2[j] += 'A';
      }
    }
    for(j = 0;j < m;j++)out.print(ch2[j]);
    out.println();

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int ans[365],c[26],s[365][26],last[26],csum,nowscore,newscore;
const int INF=1e9,d=365;

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

void FIN(bool a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]+1<<"\n";
    fout.close();
    return;
  }
  REP(i,d)cout<<ans[i]+1<<"\n";
  return;
}
/*
int score(){
  int res=0;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    last[ans[day]]=day;
    REP(i,26)res-=c[i]*(day-last[i]);
  }
  return res;
}
*/
int score(){//上のがO(26*365)、こっちがO(365)のスコア計算
  int res=0,minus=csum;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    minus-=c[ans[day]]*(day-last[ans[day]]);
    last[ans[day]]=day;
    res-=minus;
    minus+=csum;
  }
  return res;
}
void swap(){
  int day=rand()%(d-8),diff=(rand()&7)+1;
  swap(ans[day],ans[day+diff]);
  newscore=score();
  if(newscore<nowscore)swap(ans[day],ans[day+diff]);
  else nowscore=newscore;
}
void onechange(){
  int day=rand()%365;
  REP(i,26){
    int tmp=ans[day];
    ans[day]=i;
    newscore=score();
    if(newscore<nowscore)ans[day]=tmp;
    else nowscore=newscore;
  }
}

int main(){
  memset(last,-1,sizeof(last));
  cin>>c[0];
  REP(i,26){cin>>c[i];csum+=c[i];}
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(day,d){
    int idx,mx=-INF;
    REP(i,26){
      int A=c[i]*(day-last[i])+s[day][i];
      if(mx<A)mx=A,idx=i;
    }
    ans[day]=idx,last[idx]=day;
  }
  nowscore=score();
  REP(_,1500){
    REP(__,100)swap();
    REP(__,100)onechange();
  }
  FIN(0);
}


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

int main(){
    int f[601];
    for(int i=0; i<600; i++){
        f[i] = i*i;
    }
    int d;
    while(cin >> d){
        int S=0;
        for(int i=1; i<600/d; i++){
            S+=d*f[i*d];
        }
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= x; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
//#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

void print(vi &v)
{
    f(v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

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

    int n;
    cin>>n;
    vi v;

        for(int j=1;j*j<=n;j++)
        {
            if(n%j)
            {
                v.pb(n/j);
            }
            else{
                v.pb((n/j)-1);
            }

        }
        fo(i,1,v.size())
        {
            v[i]-=i;
        }
        //print(v);
        int s=accumulate(all(v),0);
        double x=sqrt(n);
        int y;
        if(x==(int)x)
        {
            y=x-1;
        }
        else
        {
            y=x;
        }
        //cout<<x<<endl;
        cout<<s*2-y<<endl;



    cerr<< "Time Killed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3812
S = int(input())

x = [0] * 3
y = [0] * 3
bound = 10**9
import math

start = math.floor(math.sqrt(S))-1
x[1] = start
y[2] = start
tmp = x[1]*y[2]
while tmp < S:
    if x[1] < bound:
        x[1] += 1
    if y[2] < bound:
        y[2] += 1
    tmp = x[1]*y[2]

    
if tmp == S:
    x[2] = 0
    y[1] = 0
else:
    x[2] = 1
    y[1] = tmp-S

    
menseki = x[1]*y[2] - y[1]*x[2]

ans = []
for i in range(3):
    for j in range(2):
        if j == 0:
            ans.append(x[i])    
        else:
            ans.append(y[i])
            
print(' '.join(map(str,ans)))

Measured memory_bytes: 3064
S = list(input())
T = list(input())
A = list(set(S))
B = list(set(T))
X = []
Y = []
flag = 0
for i in range(len(A)) :
    x = S.count(A[i])
    X.append(x)
for j in range(len(B)) :
    y = T.count(B[j])
    Y.append(y)
X.sort()
Y.sort()
if len(X) == len(Y) :
    for k in range(len(X)) :
        if X[k] != Y[k] :
            flag += 1
            break
else :
    flag += 1
if flag == 0 :
    print("Yes")
else :
    print("No")
    

Measured memory_bytes: 7216
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

k = int(input())

list = [a, b, c, d, e]

Flag = "Yay!"
for i in range(5):
    for j in range(5):
        if abs(list[i] - list[j]) > k:
            Flag = ":("
            break
print(Flag)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
string S;

//解法
void solve() {

	int hoge[3] = { 0,0,0 };

	rep(i, 3) {
		if (S[i] == 'a') hoge[0]++;
		if (S[i] == 'b') hoge[1]++;
		if (S[i] == 'c') hoge[2]++;
	}

	if (hoge[0] == 1 && hoge[1] == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return;
}

int main() {
	//入力
	cin >> S;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

	int n, i, s, sum, min, max;

	scanf("%d", &n);
	while(n != 0){
		sum = 0;
		min = 1000;
		max = 0;
		for(i = 0; i < n; i++){
			scanf("%d", &s);
			sum += s;
			if(s < min)
				min = s;
			if(s > max)
				max = s;
		}
		printf("%d\n", (sum - min - max) / (n - 2));
		scanf("%d", &n);
	}

	return 0;
}



Measured memory_bytes: 2032