akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
  #include <string>
  using namespace std;

  typedef struct{
    char mark;
    int  number;
  }card;

  void BubbleSort(card*,int);
  void SelectionSort(card*,int);
  void output(card*,int,int);
  void cardcopy(card*,card*,int);

  int main(void){

    int datanum;
    card* databuff;
    card* bubblebuff;
    card* selectionbuff;
    string input;

    cin >> datanum;

    databuff = new card[datanum];
    bubblebuff = new card[datanum];
    selectionbuff = new card[datanum];

    for ( int i = 0 ; i < datanum ; i++){
      cin >> input;
      databuff[i].mark = input[0];
      databuff[i].number = (int)(input[1] - '0');
    }

    cardcopy(databuff,bubblebuff,datanum);
    BubbleSort(bubblebuff,datanum);
    cardcopy(databuff,selectionbuff,datanum);
    SelectionSort(selectionbuff,datanum);

  }

  void BubbleSort(card* databuff,int datanum){
    card temp;

    for ( int i = 0 ; i < datanum ; i++){
      for ( int j = datanum - 1 ; j > i ; j--){
        if ( databuff[j].number < databuff[j-1].number){
          temp = databuff[j-1];
          databuff[j-1] = databuff[j];
          databuff[j] = temp;
        }
      }
    }

    output(databuff,datanum,1);
  }

  void SelectionSort(card* databuff,int datanum){
    int min;
    int stableflag;
    card temp;

    stableflag = 1;

    for ( int i = 0 ; i < datanum ; i++){
      min = i;

      for ( int j = i ; j < datanum ; j++){
        if ( databuff[j].number < databuff[min].number){
          min = j;
        }
      }

      if( i != min){
        int check;
        check = i + 1;
        while(check < min){
          if (databuff[check].number == databuff[i].number){stableflag = 0;}
          check++;
        }

        temp = databuff[min];
        databuff[min] = databuff[i];
        databuff[i] = temp;
      }
    }

    output(databuff,datanum,stableflag);
  }

  void output(card *databuff,int datanum,int stableflag){

    string output;
    for ( int i = 0 ; i < datanum ; i++){
      //output[0] = databuff[i].mark;
      //output[1] = databuff[i].number;
      cout << databuff[i].mark << databuff[i].number;

      if ( i < datanum - 1){
        cout << " ";
      }else{
        cout << endl;
      }
    }
    if(stableflag == 1){
      cout << "Stable" << endl;
    }else{
      cout << "Not stable" << endl;
    }

  }

  void cardcopy(card* base,card* next,int datanum){

    for ( int i = 0 ; i < datanum ; i++){
      next[i].mark = base[i].mark;
      next[i].number = base[i].number;
    }
  }

Measured memory_bytes: 3144
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long lli;
 
void solve(lli a, lli b, lli c) {
  vector<lli> fa, fc;
  for(lli i = 1; i <= a; ++i) {
    if(a % i == 0) fa.push_back(i);
  }
  for(lli i = 1; i <= labs(c); ++i) {
    if(c % i == 0) {
      fc.push_back(i);
      fc.push_back(-i);
    }
  }
 
  if(c == 0) {
 
    for(lli i = 0; i < fa.size(); ++i) {
      for(lli k = 0; k < 2; ++k) {
    lli p = fa[i];
    lli r = a / fa[i];
    lli q, s;
    if(k == 0) {
      if(b % p != 0) continue;
      q = 0;
      s = b / p;
    } else {
      if(b % r != 0) continue;
      s = 0;
      q = b / r;
    }
    if((p > r || (p == r && q >= s)) && p*s + q*r == b) {
      cout << p << " " << q << " " << r << " " << s << endl;
      return;
    }
      }
    }
 
  } else {
 
    for(lli i = 0; i < fa.size(); ++i) {
      for(lli j = 0; j < fc.size(); ++j) {
    lli p = fa[i];
    lli r = a / fa[i];
    lli q = fc[j];
    lli s = c / fc[j];
    if((p > r || (p == r && q >= s)) && p*s + q*r == b) {
      cout << p << " " << q << " " << r << " " << s << endl;
      return;
    }
      }
    }
 
  }
  cout << "Impossible" << endl;
}
 
int main() {
  lli a, b, c;
  while(cin >> a >> b >> c && (a|b|c)) {
    solve(a,b,c);
  }
  return 0;
}

Measured memory_bytes: 1216
from random import randint
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(k):
    cur = 0
    new_a = [-1]*n
    end = [0]*n
    for j in range(n):
        cur += 1
        new_a[j] += cur
        end[min(j+a[j],n-1)] += 1
        cur -= end[j]
    end = [0]*n
    for j in range(n)[::-1]:
        cur += 1
        new_a[j] += cur
        end[max(j-a[j],0)] += 1
        cur -= end[j]
    a = new_a
    if a[0] == n:
        print(*[n]*n)
        exit()
print(*a)

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

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

  if (N / 10 == 9 || N % 10 == 9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e5+4;
ll a[M],dp[M];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    vector<ll> a(n), b(n), c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> b_upper(n, 0);
    rep(i,n){
        auto Iter=upper_bound(c.begin(),c.end(),b[i]);
        b_upper[i]=c.end()-Iter;
    }
    rep(i,n-1){
        b_upper[n-2-i]+=b_upper[n-1-i];
    }
    ll res=0;
    rep(i,n){
        auto Iter=upper_bound(b.begin(), b.end(), a[i]);
        ll index=Iter-b.begin();
        res+=b_upper[index];
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3328
H, W = map(int, input().split())
m = 10**9+7
index_lst = []
grid_0 = [0] * (W+1)
grid_0[1] = 1
for _ in range(1, H+1):
  grid_1 = [0] * (W+1)
  for i, j in enumerate(input(), 1):
    if j == '.':
      grid_1[i] = (grid_0[i] + grid_1[i-1]) % m
  grid_0 = grid_1
    
print(grid_0[-1])


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
const int M = 1e6 + 7;
int a[N], b[M];
int main(void){    
    IOS;
    int n; cin >> n;
    int mx = 0;
    for (int i = 1; i <= n; ++i){
    	cin >> a[i];
    	mx = max(mx, a[i]);
    }
    sort(a+1, a+n+1);
    for (int i = 1; i <= n; ++i){
    	if (a[i] == a[i-1]){
    		b[a[i]] = 1;
    	}
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i){
    	if (!b[a[i]]) ans++;
    	for (int j = a[i]+a[i]; j <= mx; j += a[i]){
    		b[j] = 1;
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8300
gets
table = readlines.map(&:chomp).each_with_object(Hash.new(0)) { |s, h|
  h[s[0]] += 1
}

puts %w[M A R C H].combination(3).map { |a, b, c|
  table[a] * table[b] * table[c]
}.inject(&:+)


Measured memory_bytes: 16636
import math
import itertools
k = int(input())
t = list(map(lambda x:list(x),itertools.product([i+1 for i in range(k)],repeat=2)))
ans = 0
for i in range(len(t)):
    cu = math.gcd(t[i][0],t[i][1])
    for j in range(1,k+1):
        ans += math.gcd(j,cu)
print(ans)

Measured memory_bytes: 12316
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            temp = __gcd(i,j);
            for(k=1;k<=n;k++)
            {
                ans+=(__gcd(temp,k));
            }
        }
    }
    
    cout<<ans<<endl;
    
    
    
    
        
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    if((r * 100 + g * 10 + b) % 4 != 0){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, h = map(int, input().split())
alst = []
blst = []
for _ in range(n):
    a, b = map(int, input().split())
    alst.append(a)
    blst.append(b)
blst.sort(reverse = True)
a = max(alst)
ans = 0
for num in blst:
    if num < a:
        ans += (h - 1) // a + 1
        break
    else:
        ans += 1
        h -= num
        if h <= 0:
            break

else:
    ans += (h - 1) // a + 1
print(ans)

Measured memory_bytes: 17124
import sys
next(sys.stdin)
m = [[[0]*10 for _ in range(3)] for _ in range(4)]
for l in sys.stdin:
    b,f,r,v = map(int, l.split())
    m[b-1][f-1][r-1] += v
for i,b in enumerate(m):
    if i: print('#'*20)
    for f in b: print('',*f)


Measured memory_bytes: 5620
#include <iostream>
using namespace std;
int a[500][500];
int ans[250000][4];
int main(void){
    int H,W;
    cin >> H >> W;
    for (int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    int M=0;
    for (int i=0;i<H-1;i++){
        for(int j=0;j<W;j++){
            if (a[i][j]%2==1){
                ans[M][0]=i;
                ans[M][1]=j;
                ans[M][2]=i+1;
                ans[M][3]=j;
                M++;
                a[i][j]--;
                a[i+1][j]++;
            }
        }
    }
    for(int j=0;j<W-1;j++){
        if (a[H-1][j]%2==1){
            ans[M][0]=H-1;
            ans[M][1]=j;
            ans[M][2]=H-1;
            ans[M][3]=j+1;
            M++;
            a[H-1][j]--;
            a[H-1][j+1]++;
        }
    }
    cout << M << endl;
    for (int i=0;i<M;i++){
        cout << ans[i][0]+1 << " " << ans[i][1]+1 << " " << ans[i][2]+1 << " " << ans[i][3]+1 << endl;
    }
    return 0;
}


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

int A[56];
int n, k;

bool cmp(int a, int b) {
    return a > b;
}

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

    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A, A + n, cmp);
    int res = 0;
    for(int i = 0; i < k; i++) {
        res += A[i];
    }
    cout << res;
    
    return 0;
}

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

int main(void){
	int N;
	cin >> N;
	int H[N+1];
	for(int i=1;i<=N;i++) cin >> H[i];
	
	int ans=1;
	for(int i=2;i<=N;i++){
		int count=0;
		for(int j=1;j<=i-1;j++){
			if(H[j]<=H[i]) count++;
		}
		if(count==i-1) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    long long w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(12);
    if(2*x==w && 2*y==h){
        cout<<(double)w*h/2.0<<" "<<1<<endl;
    }
    else{
        cout<<(double)w*h/2.0<<" "<<0<<endl;
    }
    
  
    
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long x; cin >> x;
    long long ans = 0;
    long long d = x / 500;
    ans += d * 1000;
    x -= d * 500;
    ans += (x / 5) * 5;
    cout << ans << "\n";
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;



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

	int ans = 0;

	if (a >= k) {
		ans += k;
		a -= k;
		k = 0;
	}
	else {
		ans += a;
		k -= a;
		a = 0;
	}


	k -= b;
	b = 0;
	if (k <= 0) {
		cout << ans << endl;
	}
	else {
		cout << ans - k << endl;
	}

}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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;}
const ll INF = 1LL<<60;
const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve(){
    ll h, w; cin >> h >> w;
    vector<string> vs;
    REP(i, h){
        string s; cin >> s;
        vs.pb(s);
    }
    ll res = 0;
    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){
            if(vs[i][j] == '.'){
                vector<vector<ll>> seen(h, vector<ll>(w, -1));
                pair<ll, ll> st = {i, j};
                queue<pair<ll, ll>> que;
                seen[st.fi][st.se] = 0;
                que.push(st);
                while(!que.empty()){
                    ll y = que.front().fi, x = que.front().se;
                    que.pop();
                    ll ncnt = seen[y][x];
                    for(int i=0; i<4; i++){
                        ll ny = y + dy[i], nx = x + dx[i];
                        if(0 <= ny && ny < h && 0 <= nx && nx < w){
                            if(vs[ny][nx] == '.' && seen[ny][nx] == -1){
                                seen[ny][nx] = ncnt + 1;
                                que.push({ny, nx});
                            }
                        }
                    } 
                }
                REP(k, h){
                    REP(l, w){
                        res = max(res, seen[k][l]);
                    }
                }
            }
        }
    }
    cout << res << endl;
}

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

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

typedef complex<double> P;

// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)

// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 2直線の平行判定 : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

int main(){
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		P a(x1,y1), b(x2,y2), c(x3,y3), d(x4,y4);
		if( is_parallel(a,b,c,d) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}



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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
int n,m,q,T,k;



int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c;

    cin >> n;
    vector<ll> A;
    rep(c1,0,3*n){
        cin >> a;
        A.push_back(a);
    }
    sort(all(A));
    ll ans = 0;
    b = 0;
    for(ll c1 = 3*n-2; b < n; c1-=2){
        ans += A[c1];
        b++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6000
import java.util.*;
import java.math.*;

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

    int ans = 0;
    int n = N;
    while (n != 0) {
      n /= K;
      ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21712
#include<stdio.h>

#define N 101
int x;
int P[N];
int M[N][N];
void Matrix_Chain_Order(){
  int n,i,j,l,k,q;
  n=x;

  for(i=1;i<=n;i++){
    M[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j]=100000;
      for(k=i;k<=j-1;k++){
	q=M[i][k]+M[k+1][j]+P[i]*P[k+1]*P[j+1];
	if(q<M[i][j]){
	  M[i][j]=q;
	}
      }
    }
  }
  printf("%d\n", M[1][x]);
}

main(){
  
  int n,i,a,count;
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%d %d",&P[i+1],&a);
    
  }
  P[i+1]=a;
  
  Matrix_Chain_Order();
  
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-b-a<=0||4*a*b>=(c-a-b)*(c-a-b)) cout<<"No";
    else cout<<"Yes";
}


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

using namespace std;


int main() {
	int n, l;
	cin >> n >> l;
	auto v = vector<string>(n);
	generate(v.begin(), v.end(), []() {
		string x;
		cin >> x;
		return x;
	});
	sort(v.begin(), v.end());
	cout<<accumulate(v.begin(), v.end(),string(""), [](auto acc,auto x) {
		return acc + x;
	})<< endl;
}

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

typedef long long ll;
const ll MOD = 1000000007;
const int MAXN = 300010;

int len, a[MAXN]; char s[MAXN];
ll ans, dp[MAXN][3][2][2][2];

int main()
{
	scanf("%s", s);
	len = strlen(s);
	s[len] = '1';
	dp[0][0][0][0][0] = 1;
	for(int i = 0; i <= len; ++i)
		for(int j = 0; j < 3; ++j)
			for(int las = 0; las < 2; ++las)
				for(int pos = 0; pos < 2; ++pos)
					for(int sz = 0; sz < 2; ++sz)
						for(int tag = 0; tag < 2; ++tag)
						{
							if(s[i] == '0' && tag == 1) continue;
							if(s[i] == '1' && tag == 0) continue;
							if(tag == 1)
							{
								if((las == 1 || i == 0) && pos == 0)
									(dp[i + 1][max(1, j)][tag][pos ^ 1][0] += dp[i][j][las][pos][sz]) %= MOD;
								if((las == 1 || i == 0) && pos == 1)
									(dp[i + 1][2 * (j >= 1)][tag][pos ^ 1][0] += dp[i][j][las][pos][sz]) %= MOD;
								if(las == 0 && i > 0 && sz == 1)
									(dp[i + 1][j][tag][pos][0] += dp[i][j][las][pos][sz]) %= MOD;
								if(las == 0 && i > 0 && sz == 0)
									(dp[i + 1][j][tag][pos ^ 1][0] += dp[i][j][las][pos][sz]) %= MOD;
							}
							if(tag == 0) (dp[i + 1][j][tag][pos][sz ^ 1] += dp[i][j][las][pos][sz]) %= MOD;
						}
	for(int i = 0; i < 2; ++i)
		for(int j = 0; j < 2; ++j)
			for(int k = 0; k < 2; ++k)
				(ans += dp[len + 1][2][i][j][k]) %= MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 57600
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

void no() {
  cout << "Impossible" << endl;
  exit(0);
}

int N;
int cnt[110];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  int maxa = -1;
  REP(i,N) {
    int a;
    cin >> a;
    cnt[a]++;
    CHMAX(maxa,a);
  }
  int b = (maxa+1)/2;
  if (maxa%2 == 1) {
    if (cnt[b] != 2) no();
  } else {
    if (cnt[b] != 1) no();
  }
  REP(i,maxa+1) {
    if (i < b) {
      if (cnt[i] > 0) no();
    } else if (i > b) {
      if (cnt[i] < 2) no();
    }
  }
  cout << "Possible" << endl;

  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l;
    string s;
    cin >> n >> l;
    string a_1[100];
    string ans;
    for (int i=0;i<n;i++){
        cin >> s;
        a_1[i] = s;
    }
    sort(a_1,a_1+n);
    for(int i=0;i<n;i++){
        ans+=a_1[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
	cin>>n;
	int p = 0, q, ans = 0;
	for(int i=0;i<n;i++){
		cin>>q;
		if(q > p) ans += q - p;
		p = q;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,a;

int main(){
	scanf("%d",&n);
	while(n!=0){
		a=0;n=1000-n;
		a+=n/500;
		n=n%500;
		a+=n/100;
		n=n%100;
		a+=n/50;
		n=n%50;
		a+=n/10;
		n=n%10;
		a+=n/5;
		n=n%5;
		a+=n/1;
		printf("%d\n",a);
		scanf("%d",&n);
	}
	return 0;
}

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

using namespace std;

long long int cnt[200001];

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

	int n,t;
	vector <int> v;

	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
		cnt[t]++;
	}

	long long int res = 0;
	for(int i=1;i<=n;i++)
	{
		res += (cnt[i]*(cnt[i]-1))/2;
	}
	for(int i=0;i<n;i++)
	{
		cout << res - (cnt[v[i]]*(cnt[v[i]]-1)/2) + ((cnt[v[i]]-1)*(cnt[v[i]]-2)/2) << '\n';
	}

    return 0;
}

Measured memory_bytes: 4084
# -*- coding: utf-8 -*-

S = input().strip()
#-----
num = 0
cnt_mod = {0:1}  # type {int: int} , contents {remainder : count}
mod = 2019
base_pow = 1

for i in range(len(S)):
    digit = int( S[len(S)-1-i] )
    
    num += (digit * base_pow) % mod
    num %= mod
    
    base_pow = (base_pow * 10) % mod
    
    cnt_mod.setdefault(num, 0)
    cnt_mod[num] += 1


ans = 0

for r,c in cnt_mod.items():
    # r: remainder
    # c: count
    if c >= 2:
        ans += c*(c-1)//2

print(ans)


Measured memory_bytes: 9368
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);

	if(abs(x-a)<abs(x-b)){
		printf("A\n");
	}else{
		printf("B\n");		
	}


	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int a,b,x,y,temp,maxa,mina;

	while(scanf("%d %d",&a,&b)!=EOF){
		x=a;
		y=b;
		while(x!=0){
			if(x<y){
				temp=y;
				y=x;
				x=temp;
			}


			x=x%y;
		}
		maxa=y;

		mina=(a/maxa)*b;

		printf("%d %d\n",maxa,mina);

	}

	return 0;
}

Measured memory_bytes: 596
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        int d = inp.nextInt();
        boolean if1 = Math.abs(a - c) <= d;
        boolean if2 = Math.abs(a - b) <= d;
        boolean if3 = Math.abs(b - c) <= d;
        if (if1 || if2 && if3) System.out.println("Yes");
        else System.out.println("No");
        inp.close();
    }
}


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

typedef long long       ll;

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

    vector<ll> l(90);
    l[0]=2;
    l[1]=1;
    for (int i=2; i<=86; ++i) {
        l[i]=l[i-1]+l[i-2];
    }

    int n;
    cin >> n;
    cout << l[n];

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,K,i,ans=1000000000;cin>>N>>K;ll x[N];
  REP(i,N)cin>>x[i];
  REP(i,N-K+1){
    ans=min(ans,min(abs(x[i]),abs(x[i+K-1]))+abs(x[i]-x[i+K-1]));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
//  C - Replacing Integer
// https://atcoder.jp/contests/abc161/tasks/abc161_c
#include <iostream>
#include <bits/stdc++.h>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x));

const ll mxsize = 5e6 + 5;
const ll linf = 1e9;
const long double inf = 10000000000.0;

#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

const ll mod = 998244353;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 
vector < ll > arr;
void compute()
{
    queue < ll > q;
    for(ll i = 0 ; i <= 9 ; i++)
    {
        q.push(i);
    }
    while(!q.empty())
    {
        auto x = q.front();
        q.pop();
        arr.pb(x);
        if(x == 0) 
        {
            continue;
        }
        if(arr.size() >= mxsize)
        {
            break;
        }
        ll lastdig = x % 10;
        ll a = 10 * x + (lastdig);
        ll b = 10 * x + (lastdig - 1);
        ll c = 10 * x + (lastdig + 1);
        if(lastdig == 0)
        {
            q.push(a);
            q.push(c);
        }
        else if(lastdig == 9)
        {
            q.push(a);
            q.push(b);
        }
        else
        {
            q.push(a);
            q.push(b);
            q.push(c);
        }
    }
}
int main()
{
    fastIO;
    compute();
    sort(arr.begin() , arr.end());
    ll k;
    cin >> k;
    cout << arr[k] << endl;
}

Measured memory_bytes: 134240
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef vector<int> vi;
#define pb push_back
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,a[N],b[N],fa[N],id[N];
ll s[N],f[N],g[N];
vi E[N];
bool vis[N];

int getf(int x) {
	return x==fa[x]?x:fa[x]=getf(fa[x]);
}

bool cmp(int x,int y) {
	return a[x]<a[y];
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		a[i]=gi(),b[i]=gi();
		a[i]=max(a[i]-b[i],0);
		id[i]=fa[i]=i;s[i]=b[i];f[i]=g[i]=a[i]+b[i];
	}
	for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++) {
		int u=id[i];vis[u]=1;
		for(auto v:E[u])
			if(vis[v]) {
				int x=u,y=getf(v);
				if(x!=y) {
					fa[y]=x;
					ll new_f=min(max(g[x],s[x]+f[y]),max(g[y],s[y]+f[x])),new_g=s[x]+s[y]+a[x];
					f[x]=new_f;g[x]=new_g;s[x]+=s[y];
				}
			}
	}
	cout<<f[getf(1)];
	return 0;
}


Measured memory_bytes: 9980
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0110
"""
# runtime error
import sys
import re

def solve(exp):
    p1 = re.compile('^0+')
    for i in range(10):
        modified_exp = exp.replace('X', str(i))
        left, right = modified_exp.split('=')
        left1, left2 = left.split('+')

        left1 = p1.sub('', left1)
        if left1 == '':
            left1 = '0'
        left2 = p1.sub('', left2)
        if left2 == '':
            left2 = '0'
        right = p1.sub('', right)
        if right == '':
            right = '0'

        # print('{} + {} <=> {}'.format(left1, left2, right))
        if int(left1) + int(left2) == int(right):
            return i
    return 'NA'



def solve2(exp):
    for i in range(10):
        left, right = exp.split('=')
        left1, left2 = left.split('+')

        left1 = left1.replace('X', str(i))
        left2 = left2.replace('X', str(i))
        right = right.replace('X', str(i))
        if len(left1) > 1 and left1[0] == '0':
            continue
        if len(left2) > 1 and left2[0] == '0':
            continue
        if len(right) > 1 and right[0] == '0':
            continue
        if int(left1, base=10) + int(left2, base=10) == int(right, base=10):
            return i
    return 'NA'




def main(args):
    for line in sys.stdin:
        #result = solve(line.strip())
        #print(result)
        result = solve2(line.strip())
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

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

int main() {

  int N;
  cin >> N;

  vector<vector<int>> g(N);
  map<P, ll> wm;
  rep(i, N - 1) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);

    ll w;
    cin >> w;
    w %= 2;
    wm.emplace(make_pair(u, v), w);
    wm.emplace(make_pair(v, u), w);
  }

  queue<int> que;
  vector<int> color(N, -1);
  que.push(0);
  color[0] = 0;
  while (!que.empty()) {
    int from = que.front();
    que.pop();
    ll nw = color[from];

    for (auto to : g[from]) {
      if (color[to] != -1) continue;
      ll w = wm.at(make_pair(from, to));
      color[to] = (nw + w) % 2;
      que.push(to);
    }
  }

  rep(i, N) { cout << color[i] << endl; }
}

Measured memory_bytes: 18816
#include<stdio.h>
int main(){
	int n;
	scanf("%d", &n);
		int diff = 1000 - (n%1000);
		if(n<1000 || n%1000!=0){
			printf("%d", diff);
		}
		if(n%1000==0){
			printf("%d", diff-1000);
		}

	return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= X; Y++) {
      for (int Z = 0; Z <= Y; Z++) {
        if (X + Y + Z == S) {
          if (X == Y && Y == Z) count++;
          else if (X != Y && Y != Z) count += 6;
          else count += 3;
        }
      }
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N,K;
	cin >> N >> K;

	ll ans = 0;
	rep(i, N) {
		ll h;
		cin >> h;
		if (h >= K) ans++;
	}

	cout << ans;


}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


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

int n,k,f[305][305][305],ans;
char s[305];

void work()
{
	scanf("%s\n%d",s+1,&k),n=strlen(s+1);
	for (int i=1; i<=n; i++)  f[i][i][0]=1;
	for (int len=2; len<=n; len++)
		for (int i=1,j=len; j<=n; i++,j++)
			for (int l=0; l<=k; l++)
				{
					f[i][j][l]=max(f[i+1][j][l],f[i][j-1][l]);
					if (l)  f[i][j][l]=max(f[i][j][l],f[i+1][j-1][l-1]+2);
					if (s[i]==s[j])  f[i][j][l]=max(f[i][j][l],f[i+1][j-1][l]+2);
				}
	for (int l=0; l<=k; l++)  ans=max(ans,f[1][n][l]);
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 110464
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int i,j;
    int ans = 0;
    i = 0;
    j = s.size() - 1;
    while(i <= j){
        if(s[i] != s[j]){
            ans++;
        }
        i++;
        j--;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

num = [-1 for _ in range(N)]

flag = False
for i in range(M):
    s,c = map(int,input().split())
    if num[s-1] == -1 or num[s-1] == c:
        num[s-1] = c
    else:
        break
else:
    flag = True

if flag==False or (num[0]==0 and N>1):
    print(-1)
else:
    ans = 0
    if num[0]==-1 and N>1:
        num[0] = 1
    for i in range(N):
        if num[i]!=-1:
            ans += num[i]*(10**(N-i-1))
    print(ans)
 

Measured memory_bytes: 3064
#include <stdio.h>

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

    int a[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        a[i]--;
    }

    int b[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }

    int c[n];
    for (int i = 0; i < n - 1; i++) {
        scanf("%d", &c[i]);
    }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
#define ull unsigned long long
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;
using namespace std;
vector<pair<int,ll> > g[MAXN];
ll dist[MAXN];
bool ok[MAXN];
int n,m;
bool cycle;
void bellman()
{
	for(int i = 1 ; i < MAXN ; i++)
		  dist[i] = 1e18;

   dist[1] = 0;
	for(int i = 1 ; i <= n - 1 ; i++)
		{
			for(int j = 1 ; j <= n ; j++)
				 {
				 	for(auto &k : g[j])
				 	{
				 		int v = k.first;
				 		ll w = k.second;
				 		if(dist[j] != 1e18) dist[v] = min(dist[v] , dist[j] + w);
				 	}
				 }
		}


	for(int j = 1 ; j <= n ; j++)
				 {
				 	for(auto &k : g[j])
				 	{
				 		int v = k.first;
				 		ll w = k.second;
				 		if(dist[j] == 1e18) continue;
				 		if(dist[v] > (dist[j] + w) )
				 			 {
				 			     dist[v] = dist[j] + w;
				 			    ok[v] = 1;
				 			 }
				 	}
				
				 }


}
int main() {

cin >> n >> m;

for(int i = 0 ; i < m ; i++)
{
	int u,v;
	ll w;
	cin >> u >> v >> w;
	g[u].emplace_back(v,-w);
}

bellman();
if(ok[n])
   cout << "inf";
 else 
   cout << -dist[n] ;



} 

Measured memory_bytes: 384
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

priority_queue<pair<ll,ll> > pq;
ll n,q;
ll st[100100],cnt;
ll ans[100100];
int main(){
#ifdef LZT
//	freopen("in","r",stdin);
#endif
	n=read(),q=read();
	st[++cnt]=n;
	for(int i=1;i<=q;i++){
		ll x=read();
		while(st[cnt]>=x) cnt--;
		st[++cnt]=x;
	}
	pq.push(mp(st[cnt],1));
	for(int i=cnt;i>=1;i--){
		ll sum=0,cur=st[i];
		while(!pq.empty() && pq.top().fi>cur){
			pair<ll,ll> nw=pq.top();pq.pop();
			sum+=nw.se*(nw.fi/cur);
			if(nw.fi%cur) pq.push(mp(nw.fi%cur,nw.se));
		}
		pq.push(mp(cur,sum));
	}
	while(!pq.empty()) ans[pq.top().fi]+=pq.top().se,pq.pop();
	rrep(i,n,1) ans[i]+=ans[i+1];
	rep(i,1,n) printf("%lld \n",ans[i]);
	return 0;
}


Measured memory_bytes: 5104
l = []
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    l.append((h, w))

for h, w in l:
    print('#' * w)
    for _ in range(h - 2):
        print('#' + '.'*(w -2) + '#')
    print('#' * w)
    print('')


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k; string s;
  IN(n, k, s);
  s[k-1] = tolower(s[k-1]);
  OUTL(s);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int maxn = 100000 + 5;

int H, W, h, w;

int main() {
    cin >> H >> W >> h >> w;
    H -= h; W -= w;
    cout << H * W << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>


using namespace std;

int main(){
    int len;
    char s[27];
    bool flag = true;
    cin >> s;
    len = strlen(s);


    for (int i = 0; i<len; i++){
        for (int j = i+1; j<len; j++){
            if (s[i] == s[j]) {
                flag = false;
                //break;
            }
        }
    }
    
    if (flag){
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
sum = 0
for k in A:
    sum += k
x = int(sum/N)

var1 = 0
for i in A:
    var1 += (i-x)*(i-x)

var2 =0
for j in A :
    var2 += (j-x-1)*(j-x-1)

print(min(var1,var2))

Measured memory_bytes: 3064
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

N = int(input())
XY = sorted([inpl() for _ in range(N)])
D = defaultdict(int)
for i in range(N):
    for j in range(i+1, N):
        D[(XY[j][0] - XY[i][0]), (XY[j][1] - XY[i][1])] += 1

print(N - max(D.values()) if N > 1 else 1)

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

int main()
{
    int n,sum=0;
    cin>>n;
    if(n%10==0)
    {
        cout<<10<<endl;
    }
    else
    {
        while(n)
        {
            sum+=n%10;
            n/=10;
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

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

int main(){
	ll k,n;
	cin>>k>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(),a.end());
	ll MAX=k-a[n-1]+a[0];
	for(int i=0;i<n-1;i++){
		MAX=max(MAX,a[i+1]-a[i]);
	}
	cout<<k-MAX<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int l,r,d;cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++) if(i%d==0) ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll n;
  cin >> n;
  vll a(n);

  ll length = 0;
  rep(i,n)
  {
    cin >> a[i];
    length += a[i];
  }

  ll l_leng = 0,r_leng = 0;
  ll pos = 0;

  rep(i,n)
  {
    r_leng += a[i];
    if(r_leng >= length / 2.0)
    {
      l_leng = r_leng - a[i];
      break;
    }
  }

  ll l_h_leng = length - l_leng;
  ll r_h_leng = length - r_leng;

  cout << min(abs(l_h_leng - l_leng),abs(r_leng - r_h_leng)) << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main() {

	string s; cin >> s;

	int f = stoi(s.substr(0, 2));
	int e = stoi(s.substr(2, 2));

	bool can_f = false;
	bool can_e = false;

	if (1 <= f && f <= 12) can_f = true;
	if (1 <= e && e <= 12) can_e = true;

	if (can_f && can_e) cout << "AMBIGUOUS" << endl;
	else if (can_f && !can_e) cout << "MMYY" << endl;
	else if (!can_f && can_e) cout << "YYMM" << endl;
	else  cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256