akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 

struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }

}comp_functor;
 
int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int p=0,d,i,j,ans=0,n,a[300005],c=0,b[300005],h[3000005]={0},temp,x,y;
    
    string s;
    
    cin>>n;
    
   
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        //h[x]++;
    }
    
    cin>>d;
    
    for(i=0;i<d;i++)
    {
        cin>>b[i];
    }
    
    sort(a,a+n);
    sort(b,b+d);
    
    if(d>n)
    {
        cout<<"NO";
        return 0;
    }
    else 
    {
        p=0;
        for(i=0;i<n;i++)
        {
            if(a[i]==b[p])
            {
                p++;
            }
        }
    }
    
    //cout<<p;
    if(p!=d)
    {
        cout<<"NO";
    }
    else
    {
        cout<<"YES";
    }
    return 0;
}
 

Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll count = 0;
	if (a == k) {
		cout << a << endl;
		return 0;
	}
	rep(i, k) {
		if (a > 0) {
			count++;
			a--;
			continue;
		}
		else if (b > 0) {
			b--;
			continue;
		}
		else {
			count--;
		}
	}
	cout << count << endl;
	return 0;
}

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

using namespace std;

#define LL long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)

inline int Read() {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a,T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a,T const&b) {
	return a<b?a=b,1:0;
}

const int N=15;

char S[5];

int A[N][N];

int main() {
	int n=Read(),m=Read(),t=0;
	rep(i,1,n)rep(j,1,m)A[i][j]=Read();
	rep(i,1,n-1)rep(j,i+1,n){
		int Ans=0;
		rep(k,1,m)Ans=Ans+(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
		int p=sqrt(Ans);
		if(p*p==Ans)t++;
	}
	cout<<t;
//	if(f)puts("Yes");
//	else puts("No");
	return 0;
}

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

ll N, X;
vector<ll> x;
vector<ll> table;
vector<ll> diff;

ll makegcd(ll a, ll b) {
    ll large = (a > b) ? a : b;
    ll small = (a > b) ? b : a;
    if (!(large % small)) return small;
    else {
        int nextsmall = large % small;
        return makegcd(small, nextsmall); 
    }
}

int main() {
    scanf("%Ld %Ld", &N, &X);
    for (int i = 0; i < N; i++) {
        ll temp; scanf("%Ld", & temp);
        x.push_back(temp);
    }
    sort(x.begin(), x.end());
    int flag = 1;
    for (int i = 0; i < N; i++) {
        if (flag && x[i] > X) {
            table.push_back(X);
            flag = 0;
        }
        table.push_back(x[i]);
    }
    if(flag) table.push_back(X);

    for (int i = 0; i < N; i++) diff.push_back(table[i+1] - table[i]);

    ll tempgcd = diff[0];
    for (int i = 1; i < N; i++) tempgcd = makegcd(tempgcd, diff[i]);

    cout << tempgcd << endl;
    return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define loop(n)  for(int i=0;i<n;i++)
#define loop1(i,a,n)  for(int i=a;i<n;i++)
using namespace std;
int main()
{
  fastio;
  int n,m;
  cin>>n>>m;
  int a[m+1];
  memset(a,0,sizeof(a));
  loop(n)
  {
    int k;
    cin>>k;
    loop1(j,0,k)
    {
      int x;
      cin>>x;
      a[x]++;
    }
  }
  int out=0;
  loop(m+1)
  {
    if(a[i]==n)
    {
      out++;
    }
  }
  cout<<out;
  return 0;
}

Measured memory_bytes: 256
// Problem : C - Snuke Festival
// Contest : AtCoder Regular Contest 084
// URL : https://atcoder.jp/contests/arc084/tasks/arc084_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 1e5 + 1, mod = 1e9 + 7, inf = 2e9;

map<int, int> m;
vector<pair<int, ll>> b;
int n, a[N], c[N];
ll ans = 0;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		int l = m[x];
		if (l) {
			b[l].second += lower_bound(a + 1, a + n + 1, x) - a - 1;
		} else {
			m[x] = size(b);
			b.push_back({x, lower_bound(a + 1, a + n + 1, x) - a - 1});
		}
	}
	sort(b.begin(), b.end());
	for (int i = 0; i < size(b); i++) {
		if (i) {
			b[i].second += b[i - 1].second;
		}
	}
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		auto l = lower_bound(b.begin(), b.end(), pair<int, ll>{x, 0});
		if (l != b.begin()) {
			l--;
			ans += l->second;
		}
	}
	cout << ans;
}


Measured memory_bytes: 7024
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if((a*b)%2==1)cout<<"Odd"<<endl;
  else cout<<"Even"<<endl;



  return 0;
}

Measured memory_bytes: 256
a,b=list(map(int,input().split()))
if(a>=0 and b>=0):
  if(a==0 or b==0):
    print("Zero")
  else:
    print("Positive")
elif(a<0 and b<0):
  if(abs(a-b)%2 == 0):
    print("Negative")
  else:
    print("Positive")
else:
  print("Zero")
  
  

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int H, A; cin >> H >> A;

  if (H % A == 0) cout << H / A << endl;
  else cout << H / A + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    int pp=0;
    while(a)
    {
        int x=a%10;
        if(x==9)
        pp=1;
        a/=10;
    }
    if(pp)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

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

	bool b = true;
	for (int i = S.size() - 1; i >= 0; ) {
		char ch = S.at(i);
		//cout << "ch:" << ch << endl;

		if (ch == 'm') {
			if (i<4) {
				b = false;
				break;
			}
			else {
				string s = S.substr(i - 4, 5);
				//cout << "m-s:" << s << endl;

				if (s != "dream") {
					b = false;
					break;
				}
			}
			i -= 5;
		}
		else if (ch == 'e') {
			if (i < 4) {
				b = false;
				break;
			}
			else {
				string s = S.substr(i - 4, 5);
				//cout << "e-s:" << s << endl;

				if (s != "erase") {
					b = false;
					break;
				}
			}
			i -= 5;
		}
		else if (ch == 'r') {
			if (i < 5) {
				b = false;
				break;
			}
			else {
				string s = S.substr(i - 2, 3);
				if (s != "mer" && s!="ser") {
					b = false;
					break;
				}
				else {
					if (s == "mer") {
						s = S.substr(i - 6, 7);
						//cout << "mer-s:" << s << endl;

						if (s != "dreamer") {
							b = false;
							break;
						}
						else {
							i -= 7;
						}
					}
					else if (s == "ser") {
						s = S.substr(i - 5, 6);
						//cout << "ser-s:" << s << endl;

						if (s != "eraser") {
							b = false;
							break;
						}
						else {
							i -= 6;
						}
					}
				}
			}
		}
		else {
			b = false;
			break;
		}
	}

	if (b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 512
PROGRAM piyo
      IMPLICIT NONE
      integer :: a,b,i
      logical :: flaga(1:1000)=.false.,flagb(1:1000)=.false.
      
      read*,a,b
      
      a = a
      b = b
      
      do i = 1,1000
        if( (i*108)/100 - i == a )then
          flaga(i) =.true.
        end if
        
        if( (i*110)/100 - i ==b )then
          flagb(i) = .true.
        end if
      end do
      
      do i= 1,1000
        if( flaga(i).and.flagb(i) )then
          print*,i
          stop
        end if
      end do
      
      print*,'-1'
      
      
      
      
      
      
      
      END PROGRAM

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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

int cnts[100005];

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

const int MAX_V = 100005;

mint fac[MAX_V];
mint inv[MAX_V]; 

void initFact() {
  fac[0] = 1;
  inv[0] = 1;
  for (int i = 1; i <= MAX_V; i++) {
    fac[i] = (fac[i - 1] * i);
    inv[i] = fac[i].inv();
  }
}

mint combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * inv[k] * inv[n - k];
}

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

  long n;
  cin >> n;

  string s;
  cin >> s;
  
  int q;
  cin >> q;

  vector<long> C;
  rep(i, n) {
    if (s[i] == 'C') {
      C.push_back(i);
    }
  }

  vector<long> D(n+1);
  vector<long> M(n+1);
  rep(i, n) {
    D[i+1] = D[i];
    M[i+1] = M[i];
    if(s[i] == 'D') {
      D[i+1]++;
    }
    if(s[i] == 'M') {
      M[i+1]++;
    }
  }

  rep(i, q) {
    long k;
    cin >> k;
    vector<long> DM(n+1);
    rep(i, n) {
      DM[i+1] = DM[i];
      if (s[i] == 'M') {
        DM[i+1]+=(D[i]-D[max(0L, i-k+1)]);
      }
      if (i-k+1 >= 0 && s[i-k+1] == 'D') {
        DM[i+1]-=(M[i+1]-M[max(0L, i-k+2)]);
      }
    }
    long res = 0;
    for(auto c: C) {
      res += DM[c];
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 35088
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    ll int n;
    cin>>n;
    ll int arr[n];
    ll int ans[n];
    ll int c=0;
    ll int k=0;
    ll int anss=0;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]>arr[i+1])
        {
            ans[k]=arr[i]-arr[i+1];
            arr[i+1]=arr[i];
            c++;
            k++;
        }
    }
    for(int j=0;j<c;j++)
    {
       anss=anss+ans[j];
    }
    cout<<anss<<endl;
    return 0;
}


Measured memory_bytes: 6268
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
typedef pair<string,pll> P;
bool comp(P p1,P p2){
  return p1.first<p2.first || (p1.first==p2.first && p1.second>p2.second);
}
int main(){
  int n,a,i;
  string s;
  vector<P> x;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s >> a;
    x.push_back(make_pair(s,pll(a,i)));
  }
  sort(x.begin(),x.end(),comp);
  for(i=0;i<n;i++){
    cout << x[i].second.second+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()

def yn(a):
    print('Yes' if a else 'No')

if C < D:
    # `##` is NG btw A and D
    yn('##' not in S[A:C] and '##' not in S[B:D])
else:
    # `#` is NG prev D except oikoseru
    yn('##' not in S[A:C] and '...' in S[B-2:D+1])


Measured memory_bytes: 3572
def main():
    N, M, Q = map(int, input().split())
    memo = [[0] * N for _ in range(N+1)]
    for _ in range(M):
        l, r = map(int, input().split())
        memo[l][r-l] += 1
    cumsum = [[0] * N for _ in range(N+1)]
    for i in range(1, N+1):
        cumsum[i][0] = memo[i][0]
        for j in range(1, N):
            cumsum[i][j] = memo[i][j] + cumsum[i][j-1]
    for _ in range(Q):
        p, q = map(int, input().split())
        ans = 0
        for i in range(q-p+1):
            ans += cumsum[p+i][q-p-i]
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 59640
from math import gcd
k=int(input())
L=[[0]*200 for i in range(200)]

for i in range(1,k+1):
    for j in range(1,k+1):
        L[i-1][j-1]=gcd(i,j)
        
r=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            r+=L[L[i-1][j-1]-1][l-1]
print(r)

Measured memory_bytes: 9396
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    string S;
    input(S);
    rep(i, 0, S.size())
    {
        cout << "x";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, open(0).read().split())

X = str(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(len(X) + 1)]
dp[0][0][0] = 1

for i in range(len(X)):
    D = int(X[i])
    for j in range(2):
        for k in range(K + 1):
            for d in range((9 if j == 1 else D) + 1):
                if k + int(d != 0) <= K:
                    dp[i + 1][j | (d < D)][k + int(d != 0)] += dp[i][j][k]

print(dp[-1][-1][-1] + int(X.count("0") == len(X) - K))


Measured memory_bytes: 41072
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  int c=0;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == '9'){
      c++;
      break;
    }
  }
  if(c==0)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main (void)
{
    long long N,cul,bef;
    char c;
    int i;
    long long count=0;
    long long max=0;

    scanf("%lld",&N);
    scanf("%c",&c);

    scanf("%lld ",&bef);
    //printf("first :%d\n",bef);

    for(i=1;i<N;i++){
        scanf("%lld",&cul);
        scanf("%c",&c);

        //printf("cul %lld\n",cul);

        if(bef<cul){

            bef=cul;
            count=0;
            continue;
        }else{
            count++;
            bef=cul;
            //printf("cont %d\n",count);
            if(max<count){
                max=count;
                //printf("max:%lld\n",max);
            }
        }

    }

    printf("%lld",max);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int n = Integer.parseInt(scanner.next());
    int[] t = new int[100];
    for(int i=0; i<n; i++){
      t[i] = Integer.parseInt(scanner.next());
    }
    int m = Integer.parseInt(scanner.next());
    int[] p = new int[100];
    int[] x = new int[100];
    for(int i=0; i<m; i++){
      p[i] = Integer.parseInt(scanner.next());
      x[i] = Integer.parseInt(scanner.next());
    }
    scanner.close();

    int sum = 0;
    for(int i=0; i<n; i++){
      sum += t[i];
    }

    for(int i=0; i<m; i++){
      System.out.println(sum-t[p[i]-1]+x[i]);
    }
  }
}


Measured memory_bytes: 35768
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int s;
	double w, h, BMI;
	
	while (scanf("%d,%lf,%lf", &s, &w, &h) != EOF){
		BMI = w/(h*h);
		if (BMI >= 25){
			cout << s << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	string s;
	cin>>s;
	ll ans=15-s.size();
	for(ll i=0;i<s.size();i++){
		if(s[i]=='o'){
			ans++;
		}
	}
	cout << (ans>=8?"YES":"NO");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int f[110];
int main(){
  ll n,m,x,a;
  cin>>n>>m>>x;
  for(int i=0;i<m;i++){
    cin>>a;
    f[a]=1;
  }
  ll cnt1=0,cnt2=0,ans;
  for(int i=0;i<=x;i++)cnt1+=f[i];
  for(int i=x;i<=n;i++)cnt2+=f[i];
  ans=min(cnt1,cnt2);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int check=0;
		if(i%3==0){
			cout<<" "<<i;
			check=1;
		}
		int x=i;
		while(check==0){
			if(x%10==3){
			    cout<<" "<<i;
			    check=1;
			}
			x/=10;
			if(x==0)
				break;
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int a,b,c,d,i,j,k;
    char s[5],a1,a2,a3;
    scanf("%s",s);
    a = s[0] - 48;
    b = s[1] - 48;
    c = s[2] - 48;
    d = s[3] - 48;
    for (i = 1;i > -2;i -= 2) {
        if (i == 1) {
            a1 = '+';
        } else {
            a1 = '-';
        }
        for (j = 1;j > -2;j -= 2) {
            if (j == 1) {
                a2 = '+';
            } else {
                a2 = '-';
            }
            for (k = 1;k > -2;k -= 2) {
                if (k == 1) {
                    a3 = '+';
                } else {
                    a3 = '-';
                }
                if (a + b * i + c * j + d * k == 7) {
                    printf("%d%c%d%c%d%c%d=7\n",a,a1,b,a2,c,a3,d);
                    exit(0);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        long ans[]=new long[N+1];
        ans[0]=2;
        ans[1]=1;
        for(int i=2;N>=i;i++){
            ans[i]=ans[i-1]+ans[i-2];
        }
        System.out.println(ans[N]);
    }
}

Measured memory_bytes: 23764
fun main(args:Array<String>?): Unit {
    val (m, n) = readLine()!!.trim().split(' ').map(String::toInt)
    val range = Pair(0 until n, 0 until m)
    val state = Array(m){readLine()!!.trim()}
    println((1 until m).sumBy{line -> (state[line].indices).count{col -> state[line][col] == '-' && Position(col, line).neighbor8.filter { it in range }.all{ state[it] != 'x' } && Position(col, line).neighbor2.filter{it in range}.all{state[it] != 'o' }}})
}
operator fun Array<String>.get(position: Position): Char = this[position.y][position.x]
operator fun Pair<IntRange, IntRange>.contains(that: Position): Boolean {
    return that.x in first && that.y in second
}
data class Position(val x: Int, val y: Int) {
    operator fun plus(that: Position): Position = Position(this.x + that.x, this.y + that.y)
    val neighbor2: Iterable<Position>
        get() = listOf(Position(x + 1, y), Position(x - 1, y))
    val neighbor8: Iterable<Position>
        get() = listOf(Position(0, 1), Position(1, 0), Position(1, 1), Position(0, -1), Position(-1, 0), Position(-1, -1), Position(1, -1), Position(-1, 1)).map{it + this}
}


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

int main(){
	int n,c=0;
	cin >> n;
	int ar[n];
	for(int i=0; i<n; i++){
		cin >> ar[i];
	}
	for(int i=1; i<n;){
		if(ar[i]==ar[i-1])c++,i+=2;
		else i++;

	}
	cout << c <<endl;
	return 0;
}

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

const ll mod = 1e9 + 7;

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

int main(){
    int a=0,N,max_num=0;
    cin >> N;
    vector<string> S(N);
    vector<string> v;
    vector<string> v_emp;
    for (int i = 0; i < N; i++){
        cin >> S[i];
    }
    // cout << endl;
    sort(S.begin(),S.end());
    for (int i = 0; i < N; i++){
        if(i == N-1){
            if(a == max_num){
                v.push_back(S[i]);
            }else if(a > max_num){
                max_num = a;
                v = v_emp;
                v.push_back(S[i]);
                // cout << S[i] << endl;
            }
            a = 0;
        }else if(S[i] == S[i+1]){
                a++;
        }else{
            if(a == max_num){
                v.push_back(S[i]);
            }else if(a > max_num){
                max_num = a;
                v = v_emp;
                v.push_back(S[i]);
                // cout << S[i] << endl;
            }
            a = 0;
        }
    }
    // cout << endl;
    for (int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 15988
from itertools import permutations

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

for i, pat in enumerate(permutations(range(1, n + 1), n)):
    if pat == p:
        a = i + 1
    if pat == q:
        b = i + 1

print(abs(a - b))


Measured memory_bytes: 3060
#include<stdio.h>

main(){
  int a,b,c;
  int i,count;
  scanf("%d %d %d",&a,&b,&c);
  count=0;
  for(i=a;i<=b;i++){
    if(c%i==0){
      count++;
    }
  }
  printf("%d\n",count);
}



Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

char M[4] = { 'S','H','C','D' };
struct Card
{
	int N[4] = { 0,0,0,0 };
};
Card C[15];

int main()
{
	int N;
	cin >> N;
	REP(n, N)
	{
		int c;
		char m;
		cin >> m >> c;
		REP(i, 4)
		{
			if (M[i] == m)
			{
				C[c - 1].N[i]++;
				break;
			}
		}
	}

	REP(m, 4)
	{
		REP(c, 13)
		{
			if (C[c].N[m] == 0)
			{
				cout << M[m] << " " << c + 1 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3136
/* ITP1_8_B:Sum of Numbers */
/* 20181123 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int sum(char *x);

int main(void) {
	char x[1000];

	while(1) {
		scanf("%s", x);
		if(x[0] == '0') break;
		printf("%d\n", sum(x));
	}

	return 0;
}

int sum(char *x) {
	int s = 0;
	int i = 0;
	
	while(i < strlen(x)) {
		s += (x[i++] - '0');
	}
	
	return s;
}


Measured memory_bytes: 2112
using System;

namespace ABC119_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            decimal sum = 0;

            for (int i = 0; i < n; i++)
            {
                var xu = Console.ReadLine().Split();
                if (xu[1] == "BTC")
                {
                    sum += (decimal.Parse(xu[0]) * 380000);
                }
                else
                {
                    sum += int.Parse(xu[0]);
                }
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1000000000000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

#define MOD 1000000007
template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;

mint nCx(int n, int x) {
    mint res = 1;
    for (int i = n; i > n-x; --i)
        res *= i;
    for (int i = x; i > 0; --i)
        res /= i;
    return res;
}

map<int,int> prime_factors;

void prime_factorization(int n) {
	while (n%2 == 0) {
		n /= 2;
		prime_factors[2]++;
	}
	for (int i = 3; i * i <= n; i = i+2) {
		while (n%i == 0) {
			n /= i;
			prime_factors[i]++;
		}
	}
	if (n > 2) {
		prime_factors[n]++;
	}
}

int main () {
    int n, m;
    cin >> n >> m;
	prime_factorization(m);
	mint res = 1;
	for (auto const& p : prime_factors) {
		res *= nCx(p.second + n - 1, n-1);
	}
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int d1[n],d2[n],count=0;
    for(i=1;i<=n;i++)
    {
        cin>>d1[i]>>d2[i];
    }
    for(i=3;i<=n;i++)
    {
        if(d1[i-2]==d2[i-2]&&d1[i-1]==d2[i-1]&&d1[i]==d2[i])
        {
            count=1;
            break;
        }
    }
    if(count==1)
    {
        cout<<"Yes"<<"\n";
    }
    else
    {
        cout<<"No"<<"\n";
    }
    
}

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



int main() {
    int n;
    cin>>n;
    rep(i,100)rep(j,100){
        if(i*4+j*7==n){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0,dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int n,x,ans=100000,div=0;
	cin >> n;
	rep(i, n) {
		div = 0;
		cin >> x;
		while (x % 2 == 0) {
			div++;
			x /= 2;
		}
		if (div < ans)
			ans = div;
	}
	cout << ans;
}

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

int main(){
	int coin[12] = {1,6,36,216,1296, 7776,46656,9,81,729,6561,59049};
	int inf = 1e9;
	int n; cin>>n;
	vector<int> dp(n+1, inf);
	dp[0] = 0;
	for(int c:coin)
		for(int yen=c; yen<=n; ++yen)
			dp[yen] = min(dp[yen], dp[yen-c] + 1);
	cout<< dp[n] <<endl;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int x,k,d;

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>x>>k>>d;
	if (x<0) x=-x;
	int d1=x%d;
	int d2=(x/d+1)*d-x;
	int t1=x/d;
	int t2=x/d+1;
	if (k-t1<0 && k-t2<0){
		cout<<min(abs(x-k*d),abs(x+k*d))<<endl;
		return 0;
	}
	t1=k-t1;
	t2=k-t2;
	int ans1=2e18,ans2=2e18;
	if (t1>=0) ans1=(t1%2==0?d1:d2);
	if (t2>=0) ans2=(t2%2==0?d2:d1);
	cout<<min(abs(ans1),abs(ans2))<<endl;
	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        int[] candy = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int a,b,c;
        a = candy[0];
        b = candy[1];
        c = candy[2];
        
        if(a + b == c || b + c == a || c + a == b){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
vector<ll> v;
void divisors(ll x)
{
    for(ll i=1;i<=sqrt(x);i++)
    {
        if(x%i==0)
        {
            if(i==(x/i))
                v.pb(i);
            else
            {
                v.pb(i);
                v.pb(x/i);
            }
        }
    }
}
void solve()
{
    ll n,m,k,x,y,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1,cnt2=0;
   cin>>n>>m>>k;
   x=__gcd(n,m);
   divisors(x);
   sort(v.begin(),v.end(),greater<ll>());
   cout<<v[k-1];
}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N, n, m;
    cin >> N;
    int X[N];
    m = 0;
    for(int i = 0; i < N; i++){
        cin >> X[i];
        m = max(m, X[i]);
    }

    int ans = 999999;
    for(int i = 1; i < m + 1; i++){
        n = 0;
        for(int x = 0; x < N; x++){
            n += (i - X[x]) * (i - X[x]);
        }

        ans = min(ans, n);
    }

    cout << ans << endl;

    return 0;
            
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))

res = 0
used = [True]*n
for i in range(1,n):
    if a[i] == a[i-1] and used[i-1]:
        res += 1
        used[i] = False
print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
ll dp[100005];
int w[100005];ll v[100005];
int n,W;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>W;
    for (int i=1;i<=n;++i) cin>>w[i]>>v[i];
    for (int i=1;i<=n;++i){
    	for (int j=W;j>=w[i];--j) dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
	}
	cout<<dp[W];
    return 0; 
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

ll bit[500001], n;

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

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

int main() {
  int q;
  ll a, b, c;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a;
    add(i + 1, a);
  }
  while (q--) {
    cin >> a >> b >> c;
    if (a == 0) {
      add(b + 1, c);
    } else {
      cout << sum(c) - sum(b) << endl;
    }
  }
}

Measured memory_bytes: 8224
n = int(input())
a_list = list(map(int,input().split()))
ans = float('inf')

for i in [1,-1]:
    ans_i = 0
    sums  = 0
    for a in a_list:
        sums += a
        if sums*i <= 0:
            ans_i += abs(sums-i)
            sums = i
        i *= -1
    ans = min(ans,ans_i)

print(ans)

Measured memory_bytes: 14332
N = int(input())
ALis = list(map(int,input().split()))
Flag = True

for i in range(N):
    if ALis[i] % 2 == 0:
        if ALis[i] % 3 != 0 and ALis[i] % 5 != 0:
           Flag = False

if Flag:
    print("APPROVED") 
else:
    print("DENIED")
    

Measured memory_bytes: 2940
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef std::pair<int, int> par;
inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 100005;
std::vector<par> G[maxn];
bool a[maxn], vis[maxn];
par edge[maxn];
bool ans[maxn];

void dfs(int u) {
	vis[u] = true;
	for(par p : G[u])
		if(not vis[p.first]) {
			dfs(p.first);
			if(a[p.first]) {
				a[u] ^= 1;
				a[p.first] ^= 1;
				ans[p.second] ^= 1;
			}
		}
}

int main() {
	int n = input(), m = input();
	for(int i = 1; i <= m; i ++) {
		int u = input(), v = input();
		G[u].push_back(par(v, i));
		G[v].push_back(par(u, i));
		edge[i] = par(u, v);
		a[u] ^= 1;
	}
	dfs(1);
	if(a[1])
		puts("-1");
	else {
		for(int i = 1; i <= m; i ++) {
			if(ans[i]) std::swap(edge[i].first, edge[i].second);
			printf("%d %d\n", edge[i].first, edge[i].second);
		}
	}
}


Measured memory_bytes: 12672
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    l = t[:]
    num = int(px[i][0]-1)
    l[num] = px[i][1]
    print(sum(l))

Measured memory_bytes: 3060
// B.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, k, l[50], ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}
	sort(l, l + n);
	for (int i = n - k; i < n; ++i) {
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const a = BigInt(arg[0].split(" ")[0]);
    const b = BigInt(arg[0].split(" ")[1]);
    const c = BigInt(arg[0].split(" ")[2]);
    const d = BigInt(arg[0].split(" ")[3]);
    
    let answers = [];
    
    answers.push(a * c);
    answers.push(a * d);
    answers.push(b * c);
    answers.push(b * d);
  
    let answer = answers[0];
  
    for(let i in answers) {
      if(answers[i] > answer) {
        answer = answers[i];
      }
    }
    
    console.log(answer.toString());
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29712
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
 ll n,p;
  cin>>n>>p;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll ans=1;
  rep(i,n) ans*=2;
  rep(i,n){
    if(a[i]%2!=0){
    cout<<ans/2<<endl;
    return 0;
    }
  }
  if(p==0) cout<<ans<<endl;
  if(p==1) cout<<0<<endl;
 return 0; 
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int

ll POW(ll a, ll b){
	if(b == 0) return 1LL;
	if(b == 1) return a;
	if(b %2 == 1) return (a*POW(a, b-1))%INF;
	return POW(a*a%INF, b/2);
}

ll GCD(ll a, ll b){
	if(a<b) return GCD(b,a);
	if(b==0) return a;
	return GCD(b,a%b);
}

int main(){
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k-1] += 'a'-'A';
	cout << s << endl;
	return 0;
} 


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

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

using namespace std;
using lint=long long;

int main(){
	int n,m; cin>>n>>m;
	pair<int,int> a[100000];
	rep(i,n) cin>>a[i].first>>a[i].second;

	sort(a,a+n);

	lint ans=0;
	rep(i,n) while(a[i].second>0 && m>0) ans+=a[i].first, a[i].second--, m--;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int prime[] = new int[500000];
		prime[0]=2;
		int idx=0;
		int num =3;
		while(prime[idx]<x) {
			for(int i=0;i<=idx;i++) {
				if(num%prime[i]==0)break;
				if(i==idx) {
					idx++;
					prime[idx]=num;
				}
			}
			num+=2;
		}
		print(""+prime[idx]);
	}
	
	private static int min(int a, int b) {
		return a<b?a:b;
	}
	
	private static Long min(Long a, Long b) {
		return a<b?a:b;
	}
	
	private static int max(int a, int b) {
		return a>b?a:b;
	}
	
	private static Long max(Long a, Long b) {
		return a>b?a:b;
	}
	
	private static void print(String s) {
		System.out.println(s);
	}

}


Measured memory_bytes: 25300
import java.util.*;
import java.util.stream.Collectors;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] is = new int[m][2];
        for (int i = 0; i < m; i++) {
            is[i][0] = sc.nextInt() - 1;
            is[i][1] = sc.nextInt() - 1;
        }
        //        System.out.println(is.length);
 
        LinkedHashMap<Integer, Set<Integer>> map = new LinkedHashMap<>();
        for (int[] i : is) {
            int a = i[0];
            int b = i[1];
            if (!map.containsKey(a)) {
                map.put(a, new TreeSet<>());
            }
            if (!map.containsKey(b)) {
                map.put(b, new TreeSet<>());
            }
            map.get(a).add(b);
            map.get(b).add(a);
        }
        // System.out.println(map);
 
        int[][] xxx = new int[n + 1][0];
        for (Map.Entry<Integer, Set<Integer>> entry : map.entrySet()) {
            int key = entry.getKey();
            List<Integer> list = new ArrayList<>(entry.getValue());
            xxx[key] = new int[list.size()];
            for (int i = 0; i < list.size(); i++) {
                xxx[key][i] = list.get(i);
            }
        }
 
        // 一番端点が少ないものから始める
        List<Integer> list = new ArrayList<>(map.keySet());
        list.sort((a, b) -> map.get(a).size() - map.get(b).size());
 
 
        for (int start : list) {
            int[] must = xxx[start];
            // mustをすべて通る経路を探す
            LinkedList<Integer> result = new LinkedList<>();
            for (int second : must) {
                boolean[] passed = new boolean[n];
                passed[start] = true;
                boolean ok = go(second, xxx, must, passed, result);
                if (ok) {
                    result.addFirst(start);
                    System.out.println(result.size());
                    System.out.println(result.stream().map(i -> i + 1 + "").collect(Collectors.joining(" ")));
                    return;
                }
            }
        }
    }
 
    public static boolean go(int into, int[][] xxx, int[] must, boolean[] passed, LinkedList<Integer> result) {
        if (passed[into] == true) {
            return false;
        }
        passed[into] = true;
        if (isAllPassed(into, xxx, must, passed)) {
            result.addFirst(into);
            return true;
        }
        for (int next : xxx[into]) {
            boolean ok = go(next, xxx, must, passed, result);
            if (ok) {
                result.addFirst(into);
                return true;
            }
        }
        passed[into] = false;
        return false;
    }
 
    public static boolean isAllPassed(int end, int[][] xxx, int[] must, boolean[] passed) {
        for (int i : must) {
            if (passed[i] == false) {
                return false;
            }
        }
        for (int i : xxx[end]) {
            if (passed[i] == false) {
                return false;
            }
        }
        return true;
    }
}
 

Measured memory_bytes: 116700
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
  
// ここから
function main(){
  for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
    var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
    var longest = pow(inputArray[2]);
    var middle = pow(inputArray[1]);
    var shortest = pow(inputArray[0]);
    var isRightTriangle = middle + shortest - longest;
      console.log(isRightTriangle ? 'NO' : 'YES');
  }
}

function pow(a){
  return a*a;
}

Measured memory_bytes: 10380
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	long long N,X;
	cin >> N >> X;
	long long L =N, a =X, b =N-X;
	while(a != b) {
		if(a > b) swap(a,b);
		long long k =b/a;
		if(k*a == b) k--;
		b -=k*a;
		L +=2*k*a;}
	L +=b;
	cout << L << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {





public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
char a[][]=new char[n][n];
char b[][]=new char[m][m];
for(int i=0;i<n;i++) {
	char s[]=sc.next().toCharArray();
	for(int j=0;j<n;j++) {
		a[i][j]=s[j];
	}
}
for(int i=0;i<m;i++) {
	char s[]=sc.next().toCharArray();
	for(int j=0;j<m;j++) {
		b[i][j]=s[j];
	}
}
int count=0;
int f=1;
outer:for(int i=0;i<n;i++) {
	for(int j=0;j<n;j++) {
		for(int k=0;k<m;k++) {
			for(int l=0;l<m;l++) {
				if(i+j+k<n&&j+l<n&&a[i+j+k][j+l]==b[k][l]) {
					count++;
				}
			}
		}
		if(count==m*m) {
			f=0;
			System.out.println("Yes");
	break outer;
}
count=0;

		
	}
}
if(f!=0) {
	System.out.println("No");
}

	


	

}

}




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

int main() {
  vector<int> v(4);
  for (int i = 0; i < 4; i++) cin >> v[i];
  sort(v.begin(), v.end() - 1);
  v[2] *= pow(2, v[3]);
  cout << accumulate(v.begin(), v.end() - 1, 0) << endl;
}


Measured memory_bytes: 384