akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n,a,b;
	cin>>n>>a>>b;

	if((b-a)%2==0){
		cout<<(b-a)/2<<endl;
	}else{
		ll ans=INF;
		chmin(ans,b-1);
		chmin(ans,n-a);
		chmin(ans,(a+(b-a-1)/2));
		chmin(ans,(n-b+1 + (n-(a+n-b+1))/2));
		cout<<ans<<endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	int K; cin >> K;
	F0R(i, S.size()) {
		if ('z' - S[i] < K && S[i] != 'a') {
			K -= 'z' - S[i] + 1;
			S[i] = 'a';
		}
	}
	K %= 26;
	S[S.size()-1] = (S[S.size()-1] -'a' + K) % 26 + 'a';
	print(S);
}

Measured memory_bytes: 3744
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;


int main(){

  string s;cin>>s;
  bool e1=false,e2=false;

  rep(i,0,s.size()){

    if(e1){
      if(s[i]=='F'){
        e2=true;
        break;
      }
    }else{
      if(s[i]=='C'){
        e1=true;
      }
    }

  }
  if(e1&&e2)out("Yes")
  else out("No")

  return 0;
}


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

int main()
{
  int64_t n, k;
  cin >> k >> n;
  vector<int64_t> li(n * 2);
  for (int i = 0; i < n; ++i)
  {
    cin >> li[i];
    li[i + n] = li[i] - k;
  }
  sort(li.begin(), li.end());
  int64_t ans = 10e9;
  for (int i = 0; i < 2 * n - (n - 1); ++i)
    ans = min(ans, abs(li[i] - li[i + n - 1]));
  cout << ans << "\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct Sieve {
    int N;
    vector<int> min_factor;
    Sieve(int _N):N(_N) {
        min_factor.assign(N + 1,-1);
        int i = 2;
        for (; i*i <= N; ++i) {
            if (min_factor[i] < 0) {
                min_factor[i] = i;
                for (int p = i*i; p <= N; p += i) {
                    if (min_factor[p] < 0) min_factor[p] = i;
                }
            }
        }
        for (int j = i; j <= N; ++j) {
            if (min_factor[j] < 0) min_factor[j] = j;
        }
    }
    // M > 1 
    vector<pair<int,int>> factorization(int M) {
        vector<pair<int,int>> ret;
        while (M > 1) {
            int p = min_factor[M],e = 1;
            M /= p;
            while (p == min_factor[M]) {
                ++e;
                M /= p;
            }
            ret.emplace_back(p,e);
        }
        return ret;
    }
    int count_factor(int M) {
        int ans = 1;
        while (M > 1) {
            int p = min_factor[M],e = 1;
            M /= p;
            while (p == min_factor[M]) {
                ++e;
                M /= p;
            }
            ans *= (e + 1);
        }
        return ans;
    }
};

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

    int N; cin >> N;
    Sieve sieve(N);
    ll ans = 0;
    rep(i,N) {
        ans += (ll)(i + 1) * (ll)sieve.count_factor(i + 1);
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 100000000; i > 0; i /= 10) {
    int x = (n % (i * 10)) / i;
    sum += x;
  }
    
  if (n % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<cmath>
#include<cstdlib>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

int main(){
	string line;
	while(getline(cin,line)){
		string s;
		for(int x=0;x<line.size();++x){
			if(line[x]==' ' || line[x]=='.'){
				s += line[x];
			}else{
				s += line[x]-32;
			}
		}
		cout<<s<<endl;
	}
	return 0;	
}

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

int main() {
    int w, h, n, xLeft = 0, xRight, yDown = 0, yUp, x, y, a, ans;
    cin >> w >> h >> n;
    xRight = w;
    yUp = h;
    rep(i, n) {
        cin >> x >> y >> a;
        if(a == 1 && xLeft < x) xLeft = x;
        else if(a == 2 && xRight > x) xRight = x;
        else if(a == 3 && yDown < y) yDown = y;
        else if(a == 4 && yUp > y) yUp = y;
    }
    ans = max(0, xRight - xLeft) * max(0, yUp - yDown);
    cout << ans << endl;
}

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

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int t1 = c/b;
	if(c%b)t1++;
	int t2 = a/d;
	if(a%d)t2++;
	if(t1<=t2)cout<<"Yes\n";
	else cout<<"No\n";
	
	return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
int main(void){
  int data[10];
  int i,j,tmp;
  for(i=0;i<5;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<4;i++){
    for(j=4;j>i;j--){
      if(data[j]>data[j-1]){
	tmp=data[j];
	data[j]=data[j-1];
	data[j-1]=tmp;
      }
    }
  }
  printf("%d %d %d %d %d\n",data[0],data[1],data[2],data[3],data[4]);
  return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fastAF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mapll map<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define deb(x) cout<<x
using namespace std;
int main()
{
    fastAF
 string t,s;
 cin>>s>>t;
 int x=s.length(),y=t.length();
 int c=0,m=10000;
 ll int k=0;
 for(int i=0;i<=x-y;i++){
     k=i;c=0;
     for(int j=0;j<y;j++){
         if(s[k]!=t[j]){
             c++;
         }
         k++;
     }
     m=min(m,c);
 }
 cout<<m<<endl;
}
 
 
 

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

int main()
{
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;

}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n;
  cin >> n;
  int check = 0;

  if((n % 7) == 0) check++;
  
  while(n > 3){
    if((n % 4) == 0) check++;
    n -= 7;    
    }
    string ans;
    if(check != 0){
       ans = "Yes";
        }else{
          ans = "No";
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// AGC023
// B - Find Symmetries

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 300;

int N;
char s[MAX_N][MAX_N + 2];

bool check(int d) {
    for (int j = 0; j < N; j++) {
        for (int i = 0; i < N; i++) {
            if (s[i][(j + d) % N] != s[j][(i + d) % N]) {
                return false;
            }
        }
    }
    return true;
}

int solve() {
    int ans = 0;
    for (int d = 0; d < N; d++) {
        if (check(d)) {
            ans += N;
        }
    }
    return ans;
}

int main() {
    cin >> N;
    for (int j = 0; j < N; j++) {
        cin >> s[j];
        cerr << s[j] << endl;
    }

    cout << solve() << endl;

    return 0;
}


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

#define int long long 

const int N = 1005;
const int mod = 1000000007;
int dp[N][N];
char arr[N][N];
int32_t main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>arr[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i=2;i<=n;i++){
        if(arr[1][i] == '.'){
            dp[1][i] = dp[1][i-1];
        }
        else{
            dp[1][i] = 0;
        }
    }
    for(int i=2;i<=n;i++){
        if(arr[i][1] == '.'){
            dp[i][1] = dp[i-1][1];
        }
        else{
            dp[i][1] = 0;
        }
    }
    for(int i=2;i<=n;i++){
        for(int j=2;j<=m;j++){
            if(arr[i][j] == '#'){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=m;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 12432
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main()
{
    int n, reT=0, reH=0;
    std::string str, doubt;
    std::vector<std::string> v;
    cin >> n;

    std::getline(cin, doubt);
    for (int i = 0; i < n; ++i)
    {
        std::getline(cin, str);
        v = split(str, ' ');
        if (v[0] > v[1])
            reT += 3;
        else if(v[0] < v[1])
            reH += 3;
        else
        {
            reT++; reH++;
        }
    }

    cout << reT << " " << reH << endl;
    return 0;
}


Measured memory_bytes: 3172
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
r=[0]*n
l[0]=a[0]
r[n-1]=a[n-1]
for i in range(1,n):
  l[i]=gcd(l[i-1],a[i])
for i in range(n-2,-1,-1):
  r[i]=gcd(r[i+1],a[i])
g1=a[1]
for i in range(2,n):
  g1=gcd(g1,a[i])
g2=a[0]
for i in range(1,n-1):
  g2=gcd(g2,a[i])
ans=max(g1,g2)
for i in range(n-2):
  ans=max(ans,gcd(l[i],r[i+2]))
print(ans)

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	string s,t;cin>>s>>t;
	int ans=0;
	for(int i=0;i<sz(s);i++) {
		if(s[i]!=t[i]) ans++;
	}
	cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


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

int main() {
	int n;
	long long sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
vector<int>i;
int u[114514],y[114514];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c,d=0,e=0,f=-1,g=0;
  cin >>a>>u[0];
  for(int n=1;n<a;n++){
    cin >>u[n];
    if(u[n]<=u[n-1]) y[n]=y[n-1]+1;
  }
  for(int n=0;n<a;n++){
    if(y[n]>d) d=y[n];
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main()
{
ll ans,n,k;

cin >> n>>k;

int table[n]={};
rep(i,n) {
    cin >> table[i];
}
ans=(n-1)/(k-1)+1;
if((n-1)%(k-1)==0)ans--;

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





Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}


int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k, s;

signed main() {
	cin >> n >> k >> s;
	for (int i = 0; i < k; i++) {
		cout << s << " ";
	}
	for (int i = 0; i < n - k; i++) {
		if (s == 1000000000)cout << s - 1 << " ";
		else cout << s + 1 << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, P; cin >> N >> P;
    int A[55]; rep(i, N) cin >> A[i];
    bool flag = true;
    rep(i, N) {
        if(A[i] % 2 == 1) flag = false;
    }
    if(flag) {
        if(P == 1) {
            cout << 0 << endl;
        } else {
            ll ans = 1LL;
            rep(k, N) ans *= 2;
            cout << ans << endl;
        }
        return 0;
    } else {
        ll ans = 1LL;
        rep(k, N - 1) ans *= 2;
        cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [input() for _ in range(n)]
cd = [input() for _ in range(m)]
target = []
for x1y1 in ab:
    x1, y1 = map(int, x1y1.split())
    dist = float('inf')
    for i, x2y2 in enumerate(cd):
        x2, y2 = map(int, x2y2.split())
        temp_dist = abs(x1 - x2) + abs(y1 - y2)
        if temp_dist < dist:
            dist = temp_dist
            temp_target = i+1
    target.append(temp_target)
for i in target:
    print(i)

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  string s, t;
  cin >> s >> t;

  int res = 0;
  rep (i, 0, 3) {
    if (s[i] == t[i])
      res++;
  }
  cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

ans=1
n=int(input())
t=[0 for i in range(n)]
for i in range(n):
    t[i]=int(input())

for i in range(n):
    ans=lcm(ans,t[i])

#print(lcm(t[0],t[1]))
print(ans)


Measured memory_bytes: 3060
n, k, q = map(int, input().split())
anslist = [0] * n
ans = ["No"] * n
for i in range(q):
    a = int(input())
    anslist[a-1]+=1
for i in range(len(anslist)):
    if anslist[i] >= (q - k + 1):
        ans[i]="Yes"
[print(i) for i in ans]


Measured memory_bytes: 6448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)


//AtCoder Beginner Contest 126 - A
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
//#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    string a,b,c;
    cin>>a>>b>>c;
    char cur='a',ans;
    while(1){
        if(cur=='a'){
            if(a.size()==0){
                ans='A';
                break;
            }
            cur=a[0];
            a.erase(0,1);
        }
        if(cur=='b'){
            if(b.size()==0){
                ans='B';
                break;
            }
            cur=b[0];
            b.erase(0,1);
        }
        if(cur=='c'){
            if(c.size()==0){
                ans='C';
                break;
            }
            cur=c[0];
            c.erase(0,1);
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3636
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

nums = [A, B, C, D, E]
max_num = max(nums)

rest_time = [(10 - num % 10) % 10 for num in nums]

print(sum(nums) + sum(rest_time) - max(rest_time))


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define ls(x) (x << 1)
#define rs(x) (x<<1|1)
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;
typedef pair<bool, int> pbi;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2147483647;
const double INF_d = 1e64;

template<class T>
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }

// head

const int N = 2e5 + 7;
struct node{
    int l, r, tag, val;
};

int n, m, op, x, y, w;
node T[N << 2];

void build(int rt, int l, int r){
    T[rt].l = l, T[rt].r = r, T[rt].val = 0, T[rt].tag = 0;
    if (l == r) return;
    int mid = (l + r) >> 1;
    build(ls(rt), l, mid);
    build(rs(rt), mid + 1, r);
}

void push_down(int rt){
    if (T[rt].tag){
        T[ls(rt)].tag += T[rt].tag, T[rs(rt)].tag += T[rt].tag;
        T[ls(rt)].val += T[rt].tag; T[rs(rt)].val += T[rt].tag;
        T[rt].tag = 0;
    }
}

void push_up(int rt){
    T[rt].val = min(T[ls(rt)].val, T[rs(rt)].val);
}

void update(int rt, int l, int r, int val){
    if (l > T[rt].r || r < T[rt].l) return;
    if (l <= T[rt].l && T[rt].r <= r){
        T[rt].val += val;
        T[rt].tag += val; return;
    }
    push_down(rt);
    int mid = (T[rt].l + T[rt].r) >> 1;
    if (l <= mid) update(ls(rt), l, r, val);
    if (r > mid) update(rs(rt), l, r, val);
    push_up(rt);
}

int query(int rt, int l, int r){
    if (l > T[rt].r || T[rt].l > r) return INF;
    if (l <= T[rt].l && T[rt].r <= r) return T[rt].val;
    push_down(rt);
    int ret = INF;
    int mid = (T[rt].l + T[rt].r) >> 1;
    if (l <= mid) ret = min(ret, query(ls(rt), l, r));
    if (r > mid) ret = min(ret, query(rs(rt), l, r));
    return ret;
}

int main(){
    //freopen("1.in", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    build(1, 1, n);
    for (int i = 0; i < m; i++){
        scanf("%d", &op);
        if (!op){
            scanf("%d%d%d", &x, &y, &w); x++, y++;
            update(1, x, y, w);
        }
        else{
            scanf("%d%d", &x, &y); x++, y++;
            printf("%d\n", query(1, x, y));
        }
    }
    return 0;
}



Measured memory_bytes: 7320
package main

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

var sc = bufio.NewScanner(os.Stdin)

func receiveInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := receiveInt()

	a := make([]int, n*3)
	for i := 0; i < n*3; i++ {
		a[i] = receiveInt()
	}
	sort.Ints(a)

	var sum int
	for i := n; i < 3*n; i += 2 {
		sum += a[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	long long b=0;
	for(int i=0;i<a.size();i++)
	{
		b+=a[i]-'0';
	}
	if(b%9==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3720
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int D,N;
	cin>>D>>N;
	int C=0;
	int A=0;
	while(C<N){
		++A;
		int count = 0;
		int ter = A;
		while(ter%100 == 0){
			ter /= 100;
			++count;
		}
		if(count==D){
			++C;
		}
	}
	cout << A << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
//#define MOD 1000000007
using namespace std;
typedef long long ll;

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

const int MOD = 998244353;
const ll MAX_VAL = 1000000;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}


ll inv[1000010];//逆元
vector<ll>divisors[1000010];//約数の集合
ll sum1[1000010];//sum1[d]=dの倍数の和
ll sum2[1000010];//sum2[d]=dの倍数の2乗の和
ll A[200020];
ll f[1000010];
ll g[1000010];
//逆元の前計算
void inverse_init() {
	inv[1] = 1;
	for (int i = 2; i <= MAX_VAL; i++) {
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	}
}
//約数列挙
void divisors_init() {
	for (int d = 1; d <= MAX_VAL; d++) {
		for (int x = d; x <= MAX_VAL; x += d) {
			divisors[x].pb(d);
			//divs[x].insert(d);
		}
	}
}
//g(d)の計算
void calc_g() {
	for (int d = 1; d <= MAX_VAL; d++) {
		ll tmp = 0;
		tmp = add(tmp, mult(sum1[d], sum1[d]));
		tmp = sub(tmp, sum2[d]);
		tmp = mult(tmp, inv[2]);
		g[d] = tmp;
	}
}

void Main() {

	divisors_init();//約数列挙
	inverse_init();//逆元の前計算


	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
		for (auto x : divisors[A[i]]) {
			sum1[x] = add(sum1[x], A[i]);
			sum2[x] = add(sum2[x], mult(A[i], A[i]));
		}
	}
	calc_g();//g(d)の計算
	ll ans = 0;
	for (int d = MAX_VAL; d >= 1; d--) {
		ll tmp = g[d];
		for (int k = 2; k*d <= MAX_VAL; k++) {
			tmp = sub(tmp, f[k*d]);
		}
		f[d] = tmp;
		ans = add(ans, mult(f[d],inv[d]));
	}
	cout << ans << endl;


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


Measured memory_bytes: 221568
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    LLI N;
    cin >> N;
    // i  1 2 3 4 5  N
    // M  2 3 4 5 6  1
    cout << N * (N - 1) / 2;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C;
    cin >> A >> B >> C;
    if(A == B && B == C) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  rep(i,n-1){
    double a = v[0], b = v[1];
    v[1] = 10000;
    v[0] = (a+b)/2;
    sort(v.begin(),v.end());
  }
  cout << v[0] << endl;
}


Measured memory_bytes: 3780
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    char S[5];

    scanf("%s", S);

    char list[4];
    size_t size = 0;
    size_t count[4];

    for (size_t i = 0; i < 4; i++) {
        bool found = false;

        for (size_t pos = 0; pos < size; pos++) {
            if (list[pos] == S[i]) {
                count[pos]++;

                found = true;

                break;
            }
        }

        if (!found) {
            list[size] = S[i];
            count[size] = 1;

            size++;
        }
    }

    puts(size == 2 && count[0] == 2 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
#define mo 19930726
#define ll long long
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
int n,pre[MAXN],nxt[MAXN],a[MAXN],flag;
int main()
{
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2!=i%2) flag=1;
	}
	
	for(re int i=1;i<=n;i++) pre[i]=max(pre[i-1],a[i]);
	memset(nxt,100,sizeof(nxt));
	for(re int i=n;i>=1;i--) nxt[i]=min(nxt[i+1],a[i]);
	for(re int i=2;i<=n-1;i++)
		if(a[i]!=i&&nxt[i+1]<a[i]&&pre[i-1]>a[i])
			flag=1;
	for(re int i=1;i<=n-1;i++)
		if(((a[i]==i)==(a[i+1]==i+1))&&pre[i]!=i)
			flag=1;
	if(flag) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
vector<int> seq(10);

int main() {
  long long a, b, n;
  cin >> a >> b >> n;

  if (n >= b - 1)
    cout << (a * (b - 1)) / b << endl;
  else
    cout << (a * n) / b << endl;
}


Measured memory_bytes: 3636
n = int(input().strip())
a = list(map(int, input().strip().split()))
x, y = a[0], sum(a[1:])
minxy = abs(x-y)

for i in range(1,n-1):
  x += a[i]
  y -= a[i]
  minxy = min(minxy, abs(x-y))

print(minxy)

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

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

    auto adjacency_list = vector<set<int>>(N);
    auto queue = std::queue<pair<int, int>>();
    for (auto i = 0; i < 2*(N-1); i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;

        if (adjacency_list[a].count(b)) queue.push({a, b});
        else
        {
            adjacency_list[a].insert(b);
            adjacency_list[b].insert(a);
        }
    }

    auto representatives = vector<int>(N);
    iota(begin(representatives), end(representatives), 0);

    const function<int(int)> find = [&](const int i)
    {
        if (representatives[i] != i)
            representatives[i] = find(representatives[i]);
        return representatives[i];
    };

    auto size = N;
    while (!queue.empty())
    {
        int a, b; tie(a, b) = queue.front(); queue.pop();
        a = find(a); b = find(b);

        if (adjacency_list[a].size() > adjacency_list[b].size())
            swap(a, b);

        representatives[a] = b;

        adjacency_list[b].erase(a);

        for (const auto v : adjacency_list[a]) if (v != b)
        {
            if (adjacency_list[b].count(v)) queue.push({b, v});
            adjacency_list[v].erase(a);
            adjacency_list[v].insert(b);
            adjacency_list[b].insert(v);
        }

        size--;
    }

    cout << (size == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll x,n,a,b,c,d;
map<ll,ll> mp;
ll dist(ll n){

    if(n==1)return d;
    else if(n==0)return 0;
    if(mp.count(n))return mp[n];
    ll ret = 1e18;
    ret = min(
        {
            d * abs(n - n/5*5) + c + dist(n/5),
            d * abs(n - (n+4)/5*5) + c + dist((n+4)/5),
            d * abs(n - n/3*3) + b + dist(n/3),
            d * abs(n - (n+2)/3*3) + b + dist((n+2)/3),
            d * abs(n - n/2*2) + a + dist(n/2),
            d * abs(n - (n+1)/2*2) + a + dist((n+1)/2)
        }
    );
    if(n<9e9)chmin(ret,d*n);
    mp[n] = ret;
    return ret;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int t;
    cin >> t;
    while(t--){
        cin >> x >> a >> b >> c >> d;
        cout << dist(x) << endl;
        mp.clear();
    }
}

Measured memory_bytes: 4392
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    A, B = get_ln_int_inputs()
    C = A + B
    if A % 3 == 0 or B % 3 == 0 or C % 3 == 0:
        print("Possible")
    else:
        print("Impossible")


main()

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int intA = sc.nextInt();
		int intB = sc.nextInt();
		int intC = sc.nextInt();

		if(intA < intB){
			if(intB < intC){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26252
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int N, M, C;
    std::vector<int> B(100);
    std::vector<std::vector<int>> A(100, std::vector<int>(100 ,0));

    std::cin >> N >> M >> C;
    for(int i = 0; i < M; i++){
        std::cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            std::cin >> A[i][j];
        }
    }

    int cnt = 0;
    for(int i = 0; i < N; i++){
        int sum = C;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }

        if(sum > 0){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans=0;
    for(int i=1;i<s.size();i++){
        if(s[i-1] != s[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;



bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    int sqrtNum = 2;
    while(1){
	  if(sqrtNum*sqrtNum >= num){
	  break;
      }
      sqrtNum++;
    }

    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
  int n;
  cin >> n;
  
  while(1){
    if(IsPrime(n)){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

/////

int main(){
    bool fact[200000];
    fill(fact, fact+200000, true);
    fact[0] = fact[1] = false;
    for(int i=2;i<100000;i++){
        if(!fact[i])continue;
        for(int j=2;i*j<200000;j++){
            fact[i*j] = false;
        }
    }
    set<int> prime;
    for(int i=0;i<200000;i++){
        if(fact[i])prime.insert(i);   
    }
    int n;
    cin >> n;
    cout << n << ":";
    for(auto&& i:prime){
        if(n<=1)break;
        while( n % i == 0 ){
            cout << " " << i;
            n /= i;
        }
    }
    if(n>1) cout << " " << n ;
    cout << endl;
}


Measured memory_bytes: 4128
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue
import itertools

n,m = map(int, input().split())
if n == m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 13784
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<bool>> used;
vector<ll> d;

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    map<ll, ll> m;
    for (int i = 0; i < n; ++i)
    {
        ll tmp;
        cin >> tmp;
        m[tmp]++;
    }
    ll q;
    cin >> q;
    
    ll ret = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr)
    {
        ret += itr->first * itr->second;
    }
    
    while (q--)
    {
        ll b, c;
        cin >> b >> c;
        ret -= m[b] * b;
        ret += m[b] * c;
        m[c] += m[b];
        m[b] = 0;
        cout << ret << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1LL<<60)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
#define Int long long

int min(int a,int b){
  if(a<b) return a;
  return b;
}
int max(int a,int b){
  if(a>b) return a;
  return b;
}

int gcd(Int a, Int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
  return a / gcd(a, b)*b;
}
// a x + b y = gcd(a, b)
int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

vector<int> g[100010];
int done[100010];



signed main(){
  int n;
  cin>>n;
  vector<int> v;
  int sum=0;
  lp(i,n){
    int a;
    cin>>a;
    sum+=a;
    v.push_back(a);
  }
  int b=0;
  int ans=INF;
  lp(i,n-1){
    b+=v[i];
    sum-=v[i];
    //cout<<b<<" "<<sum<<endl;
    ans=min(abs(sum-b),ans);
    /*
      cout<<endl;
      cout<<sum<<" "<<b<<endl;
      cout<<abs(sum-b)<<endl;
      cout<<ans<<endl;*/
  }
  cout<<ans<<endl;
  
  return 0;
}
 


Measured memory_bytes: 4724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double  w, h, x, y,ans;
	cin >> w >> h >> x >> y;
	bool unko = 0;
	ans = w * h / 2;
	if (w == 2 * x&&h == 2 * y) unko = 1;
	cout << fixed << setprecision(10);
	cout << ans << " " << unko;
}



Measured memory_bytes: 256