akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  map<int, int> cnt;
  rep(i, n) cnt[a[i]]++;
  if (n % 2 == 0) {
    for (int i = 1; i < n; i += 2) {
      if (cnt[i] != 2) {
        cout << 0 << endl;
        return;
      }
    }
  } else {
    if (cnt[0] != 1) {
      cout << 0 << endl;
      return;
    }
    for (int i = 2; i < n; i += 2) {
      if (cnt[i] != 2) {
        cout << 0 << endl;
        return;
      }
    }
  }
  cout << exp((mint) 2, n / 2) << endl;
}

Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
"""
Bitset II - Enumeration of Combinations
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_11_D&lang=jp

"""
from itertools import combinations

n, k = map(int, input().split())
for n, combi in sorted([(sum([1<<b for b in c]), ' '.join(map(str, c)))  for c in combinations(range(n), k)]):
    print(f'{n}: {combi}')



Measured memory_bytes: 14704
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i,N):
        if A[i] == A[j]:
            continue
        for k in range(j,N):
            if A[i] == A[k] or A[j] == A[k]:
                continue
            l = [A[i],A[j],A[k]]
            n = sum(l) - 2*max(l)
            if n > 0:
                ans += 1

print(ans)


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, k;
	cin >> n >> k;
	co(n-k+1);

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		//500円玉
		int A = scanner.nextInt();
		//100円玉
		int B = scanner.nextInt();
		//50円玉
		int C = scanner.nextInt();
		//ちょうどX円にする
		int X = scanner.nextInt();

		int count = 0;
		for (int a = 0; a <= A; a++) {
			for (int b = 0; b <= B; b++) {
				for (int c = 0; c <= C; c++) {
					if (X == 500*a + 100*b + 50*c) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 22996
N = input()
L = [int(i) for i in input().split()]
L.sort()
max_L = L[-1]
# print(max_L)
other_L = sum(L[:-1])
# print(other_L, max_L)
# print(other_L > max_L)
if other_L > max_L:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
sum = 0
for x in A:
  sum += x
  sum %= (10**9+7)

sum2 = 0
for x in A:
  sum2 += x*x
  sum2 %= (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))


Measured memory_bytes: 49960
#include <stdio.h> 
 
  int main(){ 
 int a, b, c; 
     int tmp; 
     scanf("%d %d %d", &a, &b, &c); 
     if(a>b){ 
         tmp=a; 
         a=b; 
         b=tmp; 
     } 
     if(b>c){ 
         tmp=b; 
         b=c; 
         c=tmp; 
     } 
     if(a>b){ 
         tmp=a; 
         a=b; 
         b=tmp; 
     } 
     printf("%d %d %d\n", a, b, c); 
     return 0; 
 } 



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

int main(){

    int a,b; cin >> a >> b;
    cout << a*b << endl;

    return 0;

}

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

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

int main() {
	int N;
	string S;
	cin >> N >> S;
	RH rh(S);
	int ans = 0;
	for (int i=0;i<N;i++) {
		int ok = 0;
		int ng = N+1;
		while (ng - ok > 1) {
			int mid = (ok+ng)/2;
			if (i+mid > N) {
				ng = mid;
			} else {
				bool flag = false;
				for (int j=i+mid;j<N;j++) {
					if (j+mid > N) break;
					if (rh.get(i, i+mid)==rh.get(j, j+mid)) {
						flag = true;
						break;
					}
				}

				if (flag) {
					ok = mid;
				} else {
					ng = mid;
				}
			}
		}
		// cout << "i, ok: " << i << " " << ok << endl;
		ans = max(ans, ok);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

static ll int inf = 1e9;
const int cont = 10e5+10;
using namespace std;

void solve(){
    ll n;
    string s;
    cin>>s;
    int cnt = 0;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'R'){
            cnt++;
            ans = max(ans, cnt);
        }else {
            cnt = 0;
        }
    }
    cout<<ans<<endl;

}

int main(){
    Fast;

    solve();

	return Okay;
}



Measured memory_bytes: 3580
#include <numeric>
#include <cmath>
#include <iostream>
using namespace std;
constexpr int M = 1000000007;

int main() {
    int N, K; cin >> N >> K;
    if (N == 1) { cout << 1 << endl; return 0; }
    const int b = int(sqrt(N)) + 2;
    long long dps[2][b], dpl[2][b];
    int cur = 0, prev = 1;
    dps[0][0] = dps[1][0] = dpl[0][0] = dpl[1][0] = 0;
    for (int i = 1; i < b; i++) {
        dps[prev][i] = i;
        dpl[prev][i] = N/i;
    }
    while (--K) {
        for (int i = 1; i < b; i++) {
            dps[cur][i] = (dps[cur][i-1] + (N/i < b ? dps[prev][N/i] : dpl[prev][i])) % M;
        }
        for (int i = b-1; i > 0; i--) {
            dpl[cur][i] = ((i == b-1 ? dps[cur][N/b] : dpl[cur][i+1]) +
                           (N/(N/i) < b ? dps[prev][N/(N/i)] : dpl[prev][N/i])
                           * (N/i - N/(i+1))) % M;
        }
        swap(prev, cur);
    }
    cout << dpl[prev][1] << endl;
}


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

int main(){
	int n,a;
	cin >> n;
	set<int> s;
	while(n--){
		cin >> a;
		if (s.count(a)) s.erase(a);
		else s.insert(a);
	}
	cout << s.size();
	
}


Measured memory_bytes: 4864
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rept(i,s,n) for (int i = (s); i < (n); ++i)


#include <iostream>
#include <cmath>
using namespace std;

int main() {
  int x;
  int y;
  int z;

  int k;
  int s;

  int result = 0;

  cin >> k >> s;

 rep(x, k+1){
   rep(y,k+1){
     z = s - x - y;
     if(0<=z && z<=k)
        result++;
   }
 }

 cout << result<< endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main()
{
  int N;
  cin >> N;
  long ans = 1;
  for (int i = 1; i <= N; i++)
  {
    ans *= i;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n,m,a[10000],sum=0;
    scanf("%d %d\n",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(sum>n)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d", n-sum);
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
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;
//const ll INF = (ll)1e18 + 1;

int N, K, digit;
vector<int> que;
int ans;

int calc_digit(int x){
  int res = 0;
  while (x > 0){
    res++;
    x /= 10;
  }
  return res;
}

void dfs(int sum, int cnt = 1){
  if (sum >= N){
    ans = min(ans, sum);
    return;
  }
  if (cnt >= 7) return;

  for (int u: que){
    sum = sum * 10 + u;
    dfs(sum, cnt + 1);
    sum /= 10;
  }
}

int main(){
  cin >> N >> K;
  digit = calc_digit(N);
  vector<int> d(K); rep(i, K) cin >> d[i];

  rep(i, 10){
    if (count(d.begin(), d.end(), i) == 0) que.push_back(i);
  }

  ans = INF;
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
 /* Coding Space*/
int n;
string str;
 
void dfs(string s){
while(1){
  int ss = s.size();
  char c = s[ss-1];
  char cb = s[ss-2];
  if(ss == n){
    if((s[ss-1] == s[1] && ((s[0] == 'S' && str[0] == 'o')||(s[0]=='W' && str[0] == 'x'))) ||
       (s[ss-1] != s[1] && ((s[0] == 'W' && str[0] == 'o')||(s[0]=='S' && str[0] == 'x')))){ 
    if(cb!= s[0]){
      if((str[ss-1] == 'o' && c == 'W') || (str[ss-1] == 'x' && c == 'S')){
        cout << s << endl;
        
        exit(0);
        //return;
      }else
        return;
    }else{
      if((str[ss-1] == 'o' && c == 'S') || (str[ss-1] == 'x' && c == 'W')){
        cout << s << endl;
        exit(0);
       // return;
      }else
        return;
    }
    }else
      return;
  }
  if(c == 'S' && cb == 'W')
    s += ((str[ss-1] == 'o')?"W":"S");
  if(c == 'S' && cb == 'S')
    s += ((str[ss-1] == 'o')?"S":"W");
  if(c=='W' && cb == 'S')
    s += ((str[ss-1] == 'o')?"W":"S");
  if(c == 'W' && cb == 'W')
    s += ((str[ss-1] == 'o')?"S":"W");
 
}
  return;
}
 
int main(){
  cin >> n >> str;
  dfs("SS");
  dfs("SW");
  dfs("WS");
  dfs("WW");
  cout << -1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define LL long long

int cmp(const void *a, const void *b) {
    LL x = *(LL*)a, y = *(LL*)b;
    return (x > y) ? -1 : ((x == y) ? 0 : 1) ;
}

LL max_list(int x, int y, int z, int k) {
    LL l, m, n, cnt = 0;
    for(l = 1; l <= x; ++l) {
        for(m = 1; m <= y; ++m) {
            for(n = 1; n <= z; ++n) {
                if(l * m * n <= k) { ++cnt; }
            }
        }
    }
    return cnt;
}

void solve(LL *a, LL *b, LL *c, int x, int y, int z, int k) {
    qsort(a, x, sizeof(LL), cmp);
    qsort(b, y, sizeof(LL), cmp);
    qsort(c, z, sizeof(LL), cmp);
    //printf("max_list = %lld\n", max_list(1000, 1000, 1000, 3000));
    LL *list = (LL*)malloc((106309)*sizeof(LL));
    int l, m, n, p = 0;
    for(l = 0; l < x; ++l) {
        for(m = 0; m < y; ++m) {
            for(n = 0; n < z; ++n) {
                if((l+1)*(m+1)*(n+1) <= k) {
                    list[p++] = a[l] + b[m] + c[n];
                }
            }
        }
    }
    qsort(list, p, sizeof(LL), cmp);
    for(l = 0; l < k; ++l) { printf("%lld\n", list[l]); }

}

int main(void)
{
    int x, y, z, k, i;
    scanf("%d %d %d %d", &x, &y, &z, &k);
    LL *a = (LL*)malloc((x+2)*sizeof(LL));
    LL *b = (LL*)malloc((y+2)*sizeof(LL));
    LL *c = (LL*)malloc((z+2)*sizeof(LL));
    for(i = 0; i < x; ++i) { scanf("%lld", &a[i]); }
    for(i = 0; i < y; ++i) { scanf("%lld", &b[i]); }
    for(i = 0; i < z; ++i) { scanf("%lld", &c[i]); }
    solve(a, b, c, x, y, z, k);
    free(a); free(b); free(c);
    return 0;
}

Measured memory_bytes: 1916
#include <stdio.h>

int main(void) {
	
	int a,b,c,i,j=0,x;
	
	scanf("%d%d%d",&a,&b,&c);
	
	for(x=a;x<=b;x++)
	{
		if(c%x==0)
		{
			j++;
		}
		
		
	}
	printf("%d\n",j);
	
	
	
	
	// your code goes here
	return 0;
}



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

int main()
{
	int a, b, c, d;
	int train, bus;
	cin >> a >> b >> c >> d;
	if (a > b) train = b;
	else train = a;
	if (c > d) bus = d;
	else bus = c;
	cout << train + bus << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int find(int a, int b, int c) {
    int l=a;
    int r=b;
    while(l <= (l+r)) {
        if(l%c == 0)
            return l;
        l++;
    }
}
void solve() {
    int x, a;
    cin >> x >> a;
    if(x < a)
        cout << '0' << endl;
    else
        cout << "10" << endl;   
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans = [1]*n
for  _ in range(m):
    a,b=map(int,input().split())
    if h[a-1] < h[b-1]:
        ans[a-1] = 0
    elif h[a-1] > h[b-1]:
        ans[b-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0
print(sum(ans))

Measured memory_bytes: 84704
import math

a, b, h, m = map(int, input().split())
P = math.pi

#Hour hand
xh = a * math.sin(h*P/6 + m*P/360)
yh = -a * math.cos(h*P/6 + m*P/360)

#Minute hand
xm = b * math.sin(m*P/30)
ym = -b * math.cos(m*P/30)

print(((xh-xm)**2+(yh-ym)**2)**0.5)

Measured memory_bytes: 9536
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int a[3];
int ans;

int main() {
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if ((a[1] - a[0]) % 2 == 0) {
    ans += (a[1] - a[0]) / 2;
  } else {
    ans += (a[1] - a[0]) / 2 + 2;
  }

  ans += a[2] - a[1];
  cout << ans << endl;
  return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

string S;

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


Measured memory_bytes: 256
n,K = map(int, input().split())
mod = 10**9 + 7

def modcomb(n,a,mod):
    cnt = 1
    for i in range(a):
        cnt *= (n-i)
        cnt *= pow(i+1,mod-2,mod)
        cnt %= mod
    # print(cnt)
    return cnt

def modconb(n,mod):
    # テーブルを作る
    fac = [0]*(n+1)
    finv = [0]*(n+1)
    inv = [0]*(n+1)  

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] %mod
    return fac,finv
    # return(fac[n]*(finv[k]*finv[n-k]%mod)%mod)


cnt = 0
if n-1 >= K:
    fac1,finv1 = modconb(n,mod)
    for k in range(K+1):
        c1 = fac1[n]*(finv1[k]*finv1[n-k]%mod)%mod
        c2 = fac1[n-1]*(finv1[k]*finv1[n-1-k]%mod)%mod
        cnt += c1*c2
        cnt %= mod
    print(cnt%mod)
else:
    cnt1 = modcomb(2*(n-1),n-1,mod)
    cnt2 = modcomb(2*(n-1),n,mod)
    ans = (cnt1+cnt2)%mod
    print(ans)

Measured memory_bytes: 43760
k,q=map(int,input().split())
d=list(map(int,input().split()))

def solve(n,x,m):
    S=[0]*(k+1)
    cnt_z=[0]*(k+1)
    for i in range(k):
        a=d[i]%m
        S[i+1]=S[i]+a
        cnt_z[i+1]=cnt_z[i]
        if a==0:
            cnt_z[i+1]+=1
    pp=(n-1)//k#商
    r=(n-1)%k#余り
    
    s=x+S[-1]*pp+S[r]
    
    ans=(n-1)-s//m-cnt_z[-1]*pp-cnt_z[r]
    print(ans)
    
    


for i in range(q):
    n,x,m=map(int,input().split())
    x%=m
    solve(n,x,m)

Measured memory_bytes: 51924
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll u[2002][2002] = {}, d[2002][2002] = {};
ll r[2002][2002] = {}, l[2002][2002] = {};

int main() {
	IOS();
	ll h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (s[i - 1][j - 1] != '#')
				l[i][j] = l[i][j - 1] + 1;
			else
				l[i][j] = 0;
		}
		for (int j = w; j >= 1; j--) {
			if (s[i - 1][j - 1] != '#')
				r[i][j] = r[i][j + 1] + 1;
			else
				r[i][j] = 0;
		}
	}

	for (int j = 1; j <= w; j++) {
		for (int i = 1; i <= h; i++) {
			if (s[i - 1][j - 1] != '#')
				d[i][j] = d[i - 1][j] + 1;
			else
				d[i][j] = 0;
		}
		for (int i = h; i >= 1; i--) {
			if (s[i - 1][j - 1] != '#')
				u[i][j] = u[i + 1][j] + 1;
			else
				u[i][j] = 0;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			ll tmp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
			ans	= max(ans, tmp);
		}
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 129792
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() { 
    string o,e;
    cin >> o >> e;
    if(o.size()-e.size()==0){
        rep(i,o.size()){
            cout << o.at(i) << e.at(i);
        }
        cout << endl;
    }
    else{
        rep(i,e.size()){
            cout << o.at(i) << e.at(i);
        }
        cout << o.at(e.size()) << endl;
    }
}


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

int main(){
	int n, m, t, b;
	long long g;
	t = 1000000;
	b = -1000000;
	g = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> m ;
		if(m < t){
			t = m;
		}
		
		if(m > b){
			b = m;
		}
		g += m;
		
	}
	cout << t << " " << b << " " << g << endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=3e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//file input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;

int32_t main()
{
  IOS
  string a,b;
  cin>>a>>b;
  ll count=0;
  forn(a.length())
  if(a[i]!=b[i])
    count++;
  cout<<count<<"\n";
}





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

void Main()
{
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int cnt = 0;
  rep(i,n) {
  	if (i+1 == p[i]) {
      if (i+1 < n) swap(p[i], p[i+1]);
      else swap(p[i], p[i-1]);
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		
		int[] a = new int[n];
		
		for(int i=0; i<n; i++) {
			a[i] = in.nextInt();
		}
		
		int ans = 0;
		for(int i=0; i<n; i++) {
			int b = in.nextInt();
			if(b < a[i]) {
				ans += a[i] - b;
			}
		}
		
		System.out.println(ans);
		
		in.close();

	}

}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string s;
    cin>>s;
    for (int i=0; i<s.size(); i++) {
        for(int j=0;j<i;j++){
            if (s.at(j)=='C' && s.at(i)=='F') {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int dis(pair<int, int> x, pair<int, int> y){
	int a, b, c, d;
	tie(a,b) = x;
	tie(c,d) = y;
	return abs(a - c) + abs(b - d);
}

int main(){
	int h, w, d;
	cin >> h >> w >> d;

	vector<pair<int, int>> p(h * w);
	rep(i,h){
		rep(j,w){
			int a;
			cin >> a;
			p[a - 1] = make_pair(i,j);
		}
	}

	vector<vector<int>> a(h * w);
	rep(i,d){
		a[i].emplace_back(0);
		for (int j = i; j < h * w - d; j+=d) {
			a[i].emplace_back(dis(p[j], p[j + d]));
		}
	}

	rep(i,d){
		rep(j,a[i].size() - 1){
			a[i][j + 1] += a[i][j];
		}
	}

	int q;
	cin >> q;
	rep(i,q){
		int l, r;
		cin >> l >> r;
		l--; r--;
		//show(a[l % d][r / d]);
		cout << a[l % d][r / d] - a[l % d][l / d] << endl;
	}
}


Measured memory_bytes: 6016
line = input()
while line != '0 0':
    line_split = line.split(' ')
    no_candidate = int(line_split[0])
    no_stone_begin = int(line_split[1])
    no_stone = no_stone_begin
    candidate_list = [0]*no_candidate
    i = 0
    position = 0
    while True:
        if no_stone > 0:
            candidate_list[position] += 1
            no_stone -= 1
        else:
            if candidate_list[position] != no_stone_begin:
                no_stone = candidate_list[position]
                candidate_list[position] = 0
            else:
                print(str(position))
                break
        i += 1
        position = i % no_candidate
    line = input()


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

typedef long long ll;
typedef  unsigned long long ull;
const ll mod = 1e9 + 7;
const int N=1000000000;
const int M=2000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main()
{
    Run();
    int cnt=0;
    string s,c;
    cin>>s>>c;
    for(int i=0;i<s.size();i++)
    {
        if(c[i]!=s[i])
            cnt++;
    }
    cout<<cnt;
}


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

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

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
}


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

int main() {
    ll N,X,M; cin>>N>>X>>M;
    set<ll> appear;
    vl seq;
    ll before_loop=0;
    ll loop_len=0;
    appear.insert(X);
    seq.push_back(X);
    ll next=X*X%M;
    while(!appear.count(next)){
        appear.insert(next);
        seq.push_back(next);
        next=next*next%M;
    }
    ll ans=0;
    for (int i = 0; i < seq.size(); i++){
        if(seq[i]==next)break;
        else {
            ans+=seq[i];
            before_loop++;
        }
    }
    loop_len=seq.size()-before_loop;
    vl sum(loop_len);
    sum[0]=seq[before_loop];
    for (int i =1; i < loop_len; i++){
        sum[i]=sum[i-1]+seq[before_loop+i];
    }
    N-=before_loop;
    if(loop_len!=0){
        ans+=N/loop_len*sum[loop_len-1];
        if(N%loop_len!=0)ans+=sum[N%loop_len-1];
    }
    cout<<ans<<endl;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll a, b; cin >> a >> b;
    cout << a * b << "\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>

using namespace std;

int main(){
   int n;
   cin>>n;
   int a[110];
   for(int i=0;i<n;i++)cin>>a[i];
   int ans=0;
   sort(a,a+n,greater<int>());
   for(int i=0;i<n;i++){
      if(i%2==0){
         ans+=a[i];
      }
      else ans-=a[i];
   }
   cout<<ans<<endl;

   
   
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq
sys.setrecursionlimit(10**8)
INF = float("inf")


class MaxHeap(object):
    def __init__(self, x, default=-INF):
        self.heap = [-e for e in x]
        self.default = default
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, -value)

    def pop(self):
        if len(self.heap) == 0:
            return self.default
        else:
            return -heapq.heappop(self.heap)


def solve(X: int, Y: int, A: int, B: int, C: int, p: "List[int]", q: "List[int]", r: "List[int]"):
    p.sort()
    p = p[-X:]
    q.sort()
    q = q[-Y:]

    h = sorted(p+q+r)
    print(sum(h[-X-Y:]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    q = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    r = [int(next(tokens)) for _ in range(C)]  # type: "List[int]"
    solve(X, Y, A, B, C, p, q, r)


if __name__ == '__main__':
    main()


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

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

  int p=(s[0]-'0')*10+s[1]-'0';
  int b=(s[2]-'0')*10+s[3]-'0';

  string ans;
  if((p==0 && b==0)) ans="NA";
  else if((p==0 && b>12)) ans="NA";
  else if((p>12 && b==0)) ans="NA";
  else if((p>12 && b>12)) ans="NA";
  else if((p==0 && b<=12)) ans="YYMM";
  else if((p<=12 && b==0)) ans="MMYY";
  else if(p<=12&&b<=12) ans="AMBIGUOUS";
  else if(p>12) ans="YYMM";
  else ans="MMYY";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> count;
    count.resize(26,100);
    while(n--)
    {
        string s;
        cin>>s;
        int m=s.length();
        for(int i=0;i<26;i++){
            int c=0;
            for(int j=0;j<m;j++)
                if(s[j]==97+i)
                    c++;
            count[i]=min(c,count[i]);
        }
    }
    for(int i=0;i<26;i++)
        for(int j=0;j<count[i];j++)
        {
            char c=i+97;
            cout<<c;
        }
    cout<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
     int n;
     while(cin >> n) {
        int t = n, ans = 0;
        while(t) {
            ans += t % 10;
            t /= 10;
        }
        if(n % ans) cout << "No" << endl;
        else cout << "Yes" << endl;
     }
}


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

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

    int c = 0, tmp;
    for (int i = a; i <= b; i++) {
        tmp = i % 100;
        tmp = 10 * (tmp % 10) + tmp / 10;
        if (i / 1000 == tmp) c++;
    }

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
pair<int,int>p[200010];
int a;
signed main(){
	int n,k,ans=0;
	cin>>n>>k;
	rep(i,n){
		cin>>a;
		p[a].first++;
		p[a].second=a;
	}
	sort(p,p+n);
	reverse(p,p+n);
	for(int i=0;i<k;i++){
		ans+=p[i].first;
	}
	cout<<n-ans<<endl;
}

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

using namespace std;

int main()
{
	long long n;
	cin >> n;
	vector<int> ans;
	while (n != 0) {
		if (n % 26 == 0) {
			ans.emplace_back(26);
			n -= 26;
			n /= 26;
		} else {
			ans.emplace_back(n % 26);
			n /= 26;
		}
	}
	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << (char)(ans[i] + 'a' - 1);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(){
	int n, n1, n2, n3;
	scanf("%d", &n);
	n1=n%10;
	n2=(n/10)%10;
	n3=n/100;
		if(n1==7){
		puts("Yes");
}
		else if(n2==7){
		puts("Yes");			
}
		else if(n3==7){
		puts("Yes");
}
		else{
		puts("No");
}
	return 0;
}

Measured memory_bytes: 1648
a = [list(map(int, input().split())) for i in range(2)]
s = int(input())
if (a[0][1] <= a[1][1]):
    print("NO")
    exit()
if abs(a[1][0] - a[0][0]) /abs(a[0][1] - a[1][1]) <= s:
    print("YES")
else:
    print("NO")

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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vector<int> ans(n);
    rep(sv, n){
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d){
            if (dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while (!q.empty()){
            int v = q.front(); q.pop();
            int d = dist[v];
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < n) push(v+1, d+1);
            if (v == x) push(y, d+1);
            if (v == y) push(x, d+1);
        }
        rep(i,n) ans[dist[i]]++;
    }
    rep(i,n) ans[i] /= 2;
    for (int i=1; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();

		String S = scan.next();
		char[] list = new char[N] ;

		for (int i = 0; i < N; i++) {
			list[i] = S.charAt(i) ;

			if (i == K - 1) {
				if (list[i] == 'A') {
					list[i] = 'a' ;
				}
				else if (list[i] == 'B') {
					list[i] = 'b' ;
				}
				else if (list[i] == 'C') {
					list[i] = 'c' ;
				}
			}
		}

		for (int i = 0; i < N; i++) {
			System.out.print(list[i]);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3828
N = int(input())
M = 0
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    M += u * (N - v + 1)
V = 0
for r in range(1, N + 1):
    V += r * (N - r + 1)
print(V - M)


Measured memory_bytes: 9068
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    char s[n];
    cin>>s;
    if(s[k-1]=='A'){
        s[k-1]='a';
    }else if(s[k-1]=='B'){
        s[k-1]='b';
    }else{
        s[k-1]='c';
    }
    for(int i=0;i<n;++i){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
      return y
    else:
      while x % y != 0:
        z = x % y
        x = y
        y = z
      return y


N = int(input())
A = list(int(m) for m in input().split())
ans = A[0]
for i in range(N):
  ans = gcd(A[i], ans)
print(ans)



Measured memory_bytes: 14252
import sys
from collections import deque

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

######################################################

H, W = [int(_) for _ in input().split()]

G = [list(input()) for _ in range(H)]
INF = 1e10
G2 = [[INF] * W for _ in range(H)]

lst = deque()
lst.append((0, 0, 0))
while lst:
    y, x, v = lst.popleft()
    if G2[y][x] < INF: continue
    G2[y][x] = v
    if y == H - 1 and x == W - 1:
        break

    for a, b in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
        ny = y + a
        nx = x + b
        if 0 <= ny < H and 0 <= nx < W:
            if G[ny][nx] == '.':
                lst.append((ny, nx, v + 1))
if G2[H - 1][W - 1] == INF:
    print(-1)
    exit()

route_cnt = 0
x, y = W - 1, H - 1
while 1:
    route_cnt += 1
    if x == 0 and y == 0:
        break
    for a, b in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
        ny = y + a
        nx = x + b
        if 0 <= ny < H and 0 <= nx < W:
            if G2[ny][nx] == G2[y][x] - 1:
                x, y = nx, ny
                break

white_cnt = 0
for i in range(H):
    for j in range(W):
        white_cnt += G[i][j] == '.'
print(white_cnt - route_cnt)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#include <string>
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ll n, W;
	cin>>n>>W;
	ll a[n+1][W+1];
	for (ll i=0; i <=n; ++i)
	{
		for (ll j=0; j<=W; ++j)
		{
			a[i][j]=0;
		}
	}
	for (ll i=1; i<=n; ++i)
	{
		ll w, v;
		cin>>w>>v;
		for (ll j = 1; j<=W; ++j)
		{
			a[i][j]=a[i-1][j];
			if(j-w>=0){
				a[i][j] = max(a[i][j],a[i-1][j-w]+v);
			}
		}
	}
    ll an=0;
    for(ll i=0;i<=W;++i){
        an=max(a[n][i],an);
    }
    cout<<an;

    return 0;
} 

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
#define inf 1e18

int main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
         ll a,b;cin>>a>>b;
         if(a>b)cout<<"safe";
         else cout<<"unsafe";
    }
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
int i,j,a;
for(i=1;i<=9;i++){
	for(j=1;j<=9;j++){
		a=i*j;
		printf("%d",i);
		printf("x");
		printf("%d",j);
		printf("=");
		printf("%d\n",a);
			;}}
}


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

typedef long long ll;

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

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

int main() {
    int N,K;
    cin >> N >> K;
    
    ll ans = 0;
    for ( int b = K + 1; b <= N; ++b){
        int x = N / b;
        int y = N % b;
        ll num = 0;
        if ( K == 0 ){
            num = N;
        } else {
            num = x * ( b - K ) + max(0,y-K+1);
        }
        ans += num;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int main(){
	string s; cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void)
{
	int input[3];
	int dammy;
	int i,j;
	
	scanf("%d %d %d",&input[0],&input[1],&input[2]);
	for(i = 0 ; i < 3 ; i++)
	{
		for( j = i + 1 ; j < 3 ; j++ )
		{
			if(input[i] > input[j])
			{
				dammy = input[i];
				input[i] = input[j];
				input[j] = dammy;
			}
		}
	}
	printf("%d %d %d\n",input[0],input[1],input[2]);
	return 0;
}


Measured memory_bytes: 2052
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



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


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


int main(){
  string s;
  cin >> s;
  
  int n= s.size(),a=0,b=0,c=0;
  
  rep(i,n){
    if(s.at(i)=='a')
      a++;
    if(s.at(i)=='b')
      b++;
    if(s.at(i)=='c')
      c++;
  }
  
  if(a-b>=-1 && a-b<=1 && c-b>=-1 && c-b<=1 && a-c>=-1 && a-c<=1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int INF=0x3f3f3f3f;
#define N 200005

int p[N],m[N];

int find(int x){
	if(m[x]!=0)return x;
	else return p[x]=find(p[x]);
}

int main(){
	ios::sync_with_stdio(false);
	int n,q;
	while(cin>>n>>q){
		if(n==0&&q==0)break;
		memset(p,0,sizeof(p));
		memset(m,0,sizeof(m));
		p[1]=1;
		m[1]=-1;
		for (int i = 0; i < n-1; i++){
			cin>>p[i+2];
		}
		vector<pair<char,int>> st;
		while(q--){
			char t;
			int x;
			cin>>t>>x;
			st.push_back({t,x});
			if(t=='M'&&m[x]==0){
				m[x]=st.size();
			}
		}
		ll sum=0;
		for(int i=st.size()-1;i>=0;i--){
			if(st[i].fi=='M'){
				if(m[st[i].se]==i+1)m[st[i].se]=0;
			}
			else{
				sum+=find(st[i].se);
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 6264