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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  string s;
  cin >> s;
  int N = s.size();
  for (int i = 0; i < N - 1; i++) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return;
    }
  }
  for (int i = 0; i < N - 2; i++) {
    if (s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return;
    }
  }
  cout << -1 << " " << -1 << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 512
N,M = map(int, input().split())
likeNum = []

inp = input().split(" ")
inp.remove(inp[0])
for i in inp:
  likeNum.append(i)

for n in range(0,N-1):
  inp = input().split(" ")
  inp.remove(inp[0])
  nextInp = []
  for i in inp:
    if i in likeNum:
      nextInp.append(i)
  likeNum = nextInp

print(len(likeNum))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  cout<<(n*(n+1))/2;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
	double x1,x2,xp,y1,y2,yp1,yp,naiseki,norm1,norm2,gaiseki;
	int q;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	scanf("%d",&q);

	for(int i=0; i < q; i++){
		scanf("%lf %lf",&xp,&yp);
		norm1 = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
		norm2 = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
		naiseki = (xp-x1)*(x2-x1)+(yp-y1)*(y2-y1);
		gaiseki = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
		if(fabs(naiseki/(norm1*norm2)+1) < 0.00000001){
			printf("ONLINE_BACK\n");
		}else if(fabs(naiseki-norm1*norm2)< 0.00000001){
			if(norm1 >= norm2){
				printf("ON_SEGMENT\n");
			}else{
				printf("ONLINE_FRONT\n");
			}
		}else if(gaiseki > 0){
			printf("COUNTER_CLOCKWISE\n");
		}else{
			printf("CLOCKWISE\n");
		}
	}

    return 0;
}

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main() {
    int N, K, S; cin >> N >> K >> S;
    REP(i,K) {
        if(i) cout << ' ';
        cout << S;
    }
    REP(i,N-K) {
        if(i || K) cout << ' ';
        cout << (S+1)%1000000000;
    }
    cout << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b) * h / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=14;
int n,m,x,ans;
int c[N],a[N][N],f[N];

int main(){
	scanf("%d%d%d",&n,&m,&x);
	ans=1e8;
	for (register int i=1; i<=n; ++i)
	{
		scanf("%d",&c[i]);
		for (register int j=1; j<=m; ++j) scanf("%d",&a[i][j]);
	}
	for (register int p=1; p<=(1<<n)-1; ++p)
	{
		memset(f,0,sizeof(f));
		int now=0;
		for (register int i=1; i<=n; ++i) 
		if ((1<<(i-1))&p)
		{
			now+=c[i];
			for (register int j=1; j<=m; ++j) f[j]+=a[i][j];
		}
		bool jay=true;
		for (register int i=1; i<=m; ++i) if (f[i]<x) {jay=false; break;}
		if (jay) ans=min(ans,now);
	}
	if (ans==1e8) ans=-1;
	printf("%d\n",ans);
return 0;
}

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

/*
2 8
5 2
8 3
*/

int N, W;
vector<pair<int, int>> goods(101);
vector<vector<int>> memo(101, vector<int>(10001, -1));

int rec(int i, int j){//i番目以降でj以下の重さで最大値
  if(i == N + 1){
    return 0;
  }
  if(memo.at(i).at(j) > 0){
    return memo.at(i).at(j);
  }
  int a = 0;
  int b = 0;
  int c = 0;
  /*if(i < N){
    if(j - goods.at(i + 1).second > 0){
      a = rec(i + 1, j - goods.at(i + 1).second) + goods.at(i + 1).first;
    }
  }*/
  if(j - goods.at(i).second >= 0){
    b = rec(i, j - goods.at(i).second) + goods.at(i).first;
  }
  c = rec(i + 1, j);

  return memo.at(i).at(j) = max(b, c);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  
  cin >> N >> W;
  for(int i = 1; i < N + 1; i++){
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(a, b);
    goods.at(i) = p;
  }

  cout << rec(1, W) <<endl;
}


Measured memory_bytes: 7708
from bisect import bisect_right

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

sum_a = [0]
for v in a:
    sum_a.append(sum_a[-1] + v)

sum_b = [0]
for v in b:
    sum_b.append(sum_b[-1] + v)

x = bisect_right(sum_a, k)

res = 0
for i in range(x):
    res = max(res, bisect_right(sum_b, k - sum_a[i]) + i - 1)
print(res)

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

int main(){
    int n;
    cin >> n;
    bool f = true;
    while(1){
        f = true;
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0){
                f = false;
                break;
            }
        }
        if(f) break;
        n++;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        String x = scanner.next();

        String moji = new String();
        for(int i = 0; i < x.length(); i++)  {
            moji += "x";
        }



        System.out.println(moji);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());

llong LCM(llong A[],int n){
    llong lcm=A[0],tmp,gcd;
    int i=1;
    llong a,b,c;
    while(1){
        tmp=A[i];
        if(tmp > lcm){
            a=tmp;
            b=lcm;
        }
        else{
            a=lcm;
            b=tmp;
        }
        while(1){
            if(a%b==0) break;
            c=b;
            b=a%b;
            a=c;
        }
        tmp/=b;
        lcm=lcm*tmp;
        i+=1;
        if(i==n) break;
    }
    return lcm;

}


int main(){
    llong n,m;
    cin >> n >> m;
    llong A[2];
    A[0] = llong(n);
    A[1] = llong(m);
    llong lcm = LCM(A,2);
    A[0] = lcm /n;
    A[1] = lcm /m;
    llong llcm=LCM(A,2);
    llong ds= llcm /(lcm / n),dt= llcm /(lcm /m);

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

    int i=0;
    while(1){
        if(s[i*ds] != t[i*dt]){
            cout << -1 << endl;
            return 0;
        }
        i+=1;
        if(i*ds >= n) break;
    }
    cout << lcm << endl;

}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


ll H, W;
vector<string> vs;
vector<vector<string>> dp;
string dfs(ll h, ll w) {
	if (dp[h][w] != "") return dp[h][w];
	string tmp;
	if (h + 1 < H && vs[h+1][w] >= '0' && vs[h+1][w] <= '9') {
		string a = dfs(h + 1, w);
		if (tmp.size() < a.size()) {
			tmp = a;
		}else if(tmp.size() == a.size() && tmp < a){
			tmp = a;
		}
	}
	if (w + 1 < W && vs[h][w + 1] >= '0' && vs[h][w + 1] <= '9') {
		string a = dfs(h, w + 1);
		if (tmp.size() < a.size()) {
			tmp = a;
		}
		else if (tmp.size() == a.size() && tmp < a) {
			tmp = a;
		}
	}
	string res;
	res += vs[h][w];
	res += tmp;
	return dp[h][w] = res;
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		cin >> W >> H; if (H == 0) break;
		vs.resize(H); for (int i = 0; i < H; i++) cin >> vs[i];
		dp = vector<vector<string>>(H, vector<string>(W));
		string res;
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
			if (vs[i][j] >= '1' && vs[i][j] <= '9') {
				string tmp = dfs(i, j);
				if (res.size() < tmp.size()) res = tmp;
				else if (res.size() == tmp.size() && res < tmp) res = tmp;
			}
		}
		cout << res << "\n";
	}
	return 0;

}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll= long long;
int main(){
    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        mp[a]++;
    }
    for(int i=1;i<n;i++){
        cout << mp[i]<<endl;
    }
  cout << "0" ;
}

Measured memory_bytes: 13016
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>
#include <cmath>
#include <iomanip>
#include <iterator>

using namespace std;

clock_t timeStart, timeFinish;

void timeBegin() {
    timeStart = clock();
}

void timeEnd() {
    timeFinish = clock();
}

void timeDuration() {
    double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC);
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " sec " << endl;
}

class InputReader {
public:
    InputReader() {
        input_file = stdin;
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    InputReader(const char *file_name) {
        input_file = fopen(file_name, "r");
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    inline InputReader &operator >>(int &n) {
        while((buffer[cursor] < '0' || buffer[cursor] > '9') && buffer[cursor] != '-') {
            advance();
        }
        int sign = 1;
        if (buffer[cursor] == '-') {
            sign = -1;
            advance();
        }
        n = 0;
        while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
            n = n * 10 + buffer[cursor] - '0';
            advance();
        }
        n *= sign;
        return *this;
    }
private:
    FILE *input_file;
    static const int SIZE = 1 << 17;
    int cursor;
    char buffer[SIZE];
    inline void advance() {
        ++ cursor;
        if(cursor == SIZE) {
            cursor = 0;
            fread(buffer, SIZE, 1, input_file);
        }
    }
};

const int MAXN = 500;

int best[1 + MAXN][1 + MAXN];
int cost[1 + MAXN][1 + MAXN];
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};

int main() {
    timeBegin();
    //ifstream cin("input.in");
    //ofstream cout("ultrapoligon.out");
    int n;
    cin >> n;
    long long answer = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) {
            best[i][j] = min(min(i - 1, n - i), min(j - 1, n - j));
            cost[i][j] = 1;
        }
    for (int i = 1; i <= n * n; i++) {
        int x;
        cin >> x;
        int r = (x - 1) / n + 1, c = (x - 1) % n + 1;
        answer += best[r][c];
        queue<pair<int, int> > q;
        q.push(make_pair(r, c));
        cost[r][c] = 0;
        while (!q.empty()) {
            r = q.front().first, c = q.front().second;
            q.pop();
            for (int j = 0; j < 4; j++) {
                int r0 = r + dx[j], c0 = c + dy[j];
                if (r0 >= 1 && r0 <= n && c0 >= 1 && c0 <= n && best[r0][c0] > best[r][c] + cost[r][c]) {
                    best[r0][c0] = best[r][c] + cost[r][c];
                    q.push(make_pair(r0, c0));
                }
            }
        }
    }
    cout << answer << "\n";
    timeEnd();
    //timeDuration();
    return 0;
}





Measured memory_bytes: 5428
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    bool ok=false;
    int n; cin >> n;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j==n) ok=true;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    prev = -1
    ans = 0
    for i in range(N):
        ans += B[i]
        if prev == A[i]-1:
            ans += C[prev-1]
        prev = A[i]
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define LLINF 100000000000000000
#define INF 1000000000
#define MOD 1000000007

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

ll d1[111111];
ll d2[111111];

int main(){
	
	REP(i,111111)d1[i] = d2[i] = LLINF;
	int n,m,s,g;cin >> n >> m >> s >> g;
	s--;g--;
	
	vector<vector<pair<ll,pair<ll,ll>>>> v(n);
	
	REP(i,m){
		ll a,b,c,d;cin >> a >> b >> c >> d;
		a--;b--;
		v[a].PB(MP(b,MP(c,d)));
		v[b].PB(MP(a,MP(c,d)));
	}
	
	d1[s] = 0;
	d2[g] = 0;
		
	priority_queue<P,vector<P>,greater<P>> pq;
	pq.push(MP(0,s));
	
	while(!pq.empty()){
		
		auto now = pq.top();pq.pop();
		ll node = now.SE;
		if(d1[node] < now.FI)continue;
		
		REP(i,v[node].size()){
			ll dist = v[node][i].SE.FI;
			ll aite = v[node][i].FI;
			
			if(d1[aite] > d1[node] + dist){
				d1[aite] = d1[node] + dist;
				pq.push(MP(d1[aite],aite));
			}
		}
	}

	pq.push(MP(0,g));
	while(!pq.empty()){
		
		auto now = pq.top();pq.pop();
		ll node = now.SE;
		if(d2[node] < now.FI)continue;
		
		REP(i,v[node].size()){
			ll dist = v[node][i].SE.SE;
			ll aite = v[node][i].FI;
			
			if(d2[aite] > d2[node] + dist){
				d2[aite] = d2[node] + dist;
				pq.push(MP(d2[aite],aite));
			}
		}
	}	

	REP(i,n){
		pq.push(MP(d1[i] + d2[i],i));
	}
	
	auto seica = pq.top();pq.pop();
	REP(i,n){
		while(seica.SE < i){
			seica = pq.top();pq.pop();
		}
		cout << 1000000000000000 - seica.FI << endl;
	}
		
	
	
	return 0;
}


Measured memory_bytes: 14192
import java.util.*;

public class Main {

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(N*A > B){
            System.out.println(B);
        } else {
            System.out.println(N*A);
        }

    }



}


Measured memory_bytes: 21972
import java.util.Scanner;
import java.util.InputMismatchException;
class Main{
public static void main(String args[]){

    Scanner scan = new Scanner(System.in);
    try{
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int temp;

int i=0;
for(i=0;i<3;i++){
if(a>b){

    temp=a;
    a=b;
    b=temp;
    
}

if(b>c){

    temp=b;
    b=c;
    c=temp;
    
}



if(a>c){

    temp=a;
    a=c;
    c=temp;
    
}

}



System.out.println(a+ " " +b+ " " +c);



}catch (InputMismatchException e) {
        	System.out.println("try again!!");
        }





}
}



Measured memory_bytes: 26212
#include <stdio.h>

int main()
{
    int n;
    int x[4][3][10] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        x[b - 1][f - 1][r - 1] += v;
    }
    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                printf(" %d", x[b][f][r]);
            }
printf("\n");
        }
        if (b != 3)
        {
            printf("####################\n");
        }
    }

return 0;
}



Measured memory_bytes: 2048
using System;
using System.Linq;

namespace Contest
{
    

    class Program
    {

        static void Main(string[] args)
        {
            try
            {
                checked
                {
                    var n = int.Parse(Console.ReadLine());
                    var a = Console.ReadLine().Split(" ").Select(x => ulong.Parse(x)).ToArray();

                    if (a.Contains((ulong)0))
                    {
                        Console.WriteLine("0");
                    } else
                    {
                        var ans = a.Aggregate((ulong)1, (x, y) => x * y);
                        
                        if(ans > 1000000000000000000)
                        {
                            Console.WriteLine("-1");

                        } else
                        {
                            Console.WriteLine(ans);
                        }
                    }
                }
            } catch
            {
                Console.WriteLine("-1");
            }
            
        }
    }
}




Measured memory_bytes: 42148
import java.util.*;
public class Main{
  static long[] d;
  static long[] cnt;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    d = new long[n+1];
    cnt = new long[n+1];
    d[0]=1;
    cnt[0]=1;
    for(int i=1;i<=n;i++){
      d[i]=2*d[i-1]+3;
      cnt[i]=2*cnt[i-1]+1;
    }
    long x = sc.nextLong();
    long p = find(n,x);
    System.out.println(p);
  }
  static long find(int n,long x){
    if(n==0&&x>0)return 1;
    else if(n==0)return 0;
    else if(x<=d[n-1]+1)return find(n-1,x-1);
    else return cnt[n-1]+1+find(n-1,x-2-d[n-1]);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
const int MAXN=3010;
string s,dp[2][MAXN];
char x;
int sl,tl;

int main(){
	cin>>s,sl=s.size(),s=" "+s; cin.get();
	while(x=getchar()){
		if(x=='\n') break;
		++tl;
		for(register int j=1;j<=sl;++j){
			if(s[j]==x) dp[tl&1][j]=dp[(tl-1)&1][j-1]+x;
			else dp[tl&1][j]=(dp[(tl-1)&1][j].size()>dp[tl&1][j-1].size()?dp[(tl-1)&1][j]:dp[tl&1][j-1]);
		}
	}
	cout<<dp[tl&1][sl]<<endl;
//bhsdjvbidnvnidf
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

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

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

ans = 0

for i in range(len(L)):
    for k in range(i + 1, len(L), 1):
        for l in range(k + 1, len(L), 1):
            A = [L[i], L[k], L[l]]
            if (2 * max(A) < sum(A)) & (len(A) == len(set(A))):
                ans = ans + 1
print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
const int nmax=200005;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}

ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

// 繰り返し二乗法 n*nが64bitにおさまる必要
ll pow_mod(ll n,ll k,ll m){
  ll res=1;
  for(;k>0;k>>=1){
    if(k&1){
      res=(res*n)%m;
    }
    n=(n*n)%m;  
  }
  return res;
}

// 逆元
ll mod_inv(ll a, ll m)
{
	return pow_mod(a,m-2,m);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int b,w;cin >> b >> w;
    COMinit();
    vector<ll> p(b+w+1),q(b+w+1);
    FOR(i,1,b+w+1){
        p[i]=(p[i-1]+com(i-1,b-1)*mod_inv(pow_mod(2,i,mod),mod))%mod;
        q[i]=(q[i-1]+com(i-1,w-1)*mod_inv(pow_mod(2,i,mod),mod))%mod;
    }
    FOR(i,1,b+w+1){
        cout << (1-p[i-1]+mod+q[i-1])%mod*inv[2]%mod << endl;
    }
}

Measured memory_bytes: 11112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    vector<ll> y(m);
    rep(i,m) cin >> y[i];
    vector<ll> dx(n - 1);
    rep(i,n - 1) dx[i] = x[i + 1] - x[i];
    vector<ll> dy(m - 1);
    rep(i,m - 1) dy[i] = y[i + 1] - y[i];
    ll x_all = 0;
    rep(i,n - 1){
        x_all = (x_all + (((dx[i] * (i + 1)) % 1000000007) * (n - 1 - i)) % 1000000007) % 1000000007;
    }
    ll y_all = 0;
    rep(i,m - 1){
        y_all = (y_all + (((dy[i] * (i + 1)) % 1000000007) * (m - 1 - i)) % 1000000007) % 1000000007;
    }
    cout << (x_all * y_all) % 1000000007 << endl;
}

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

int N;
int ans = 10000000;

int unit(int n)
{
    int res = 0;
    while(n)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}

int main()
{
    cin >> N;
    for(int i = 1; i < N; i++)
    {
        ans = min(ans,unit(i) + unit(N - i));
    }

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


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
signed main() {
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

total = 0

if X == 1:
  total += 300000
elif X == 2:
  total += 200000
elif X == 3:
  total += 100000
  
if Y == 1:
  total += 300000
elif Y == 2:
  total += 200000
elif Y == 3:
  total += 100000

if X == 1 and Y == 1:
  total += 400000


print(total)

Measured memory_bytes: 3316
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let mut vec: Vec<usize> = vec![a, b];
    vec.sort();

    let mut val = 0;

    for i in 0..2 {
        let max = vec.pop().unwrap();
        val += max;
        vec.push(max - 1);
        vec.sort();
    }

    println!("{}", val);
}


Measured memory_bytes: 4352
require 'scanf'

while true
	a,op,b = gets.scanf("%d %s %d")

	case op
	when '+'
		result = a + b;
	when '-'
		result = a - b;
	when '*'
		result = a * b;
	when '/'
		result = a / b;
	else
		break
	end

	puts result

end

Measured memory_bytes: 6436
#include<stdio.h>

int main()
{
  long long int n;
  long long int i,k;
  scanf("%lld",&n);
  char s[n+1];

  long long int del = 0;

  scanf("%s",s);

  s[n]=0;

  for(i=0;i<n-del-1;i++)
  {
    while(s[i]==s[i+1])
    {
      for(k=i+1;k<n-del;k++)
      {
        s[k]=s[k+1];
      }
      del=del+1;
      if(del+1==n)
      {
        break;
      }
    }
  }


  printf("%lld",n-del);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(1e5+2, 0);  // -1 <= a <= 1e5
  rep(i,n) {
    int a; cin >> a;
    rep(j,3) ++arr[a+j];
  }

  int ans = 0;
  rep(i,1e5+2) ans = max(ans, arr[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    n = int(input())
    ps = list(map(int, input().split()))
    ans = 0
    for i in range(2,n):
        arr = ps[i-2:i+1]
        arr2 = sorted(arr)
        if arr[1] == arr2[1]: ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 13232
n, y = gets.split(" ").map(&:to_i)
l = 10000
m = 5000
s = 1000
result = nil

(0..n).each do |i|
  (0..(n - i)).each do |j|
    if s * (n - i - j) == y - (l * i + m * j)
      result = [i, j, n - i - j]
    end
  end
end

result = [-1, -1, -1] if !result

print result[0]
print " "
print result[1]
print " "
print result[2]

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct card {
	ll B, C;
	bool operator < (const card& b) const {
		return C > b.C;
	}
};

ll A[100010];
card num[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) cin >> num[i].B >> num[i].C;
	sort(num, num + M);
	sort(A, A + N);
	int j = 0;
	for (int i = 0; i < M; i++) {
		int cnt = 0;
		if (j == N) break;
		while (num[i].C > A[j] && cnt < num[i].B && j < N) {
			A[j] = num[i].C;
			j++;
			cnt++;
		}
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += A[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[200005];
int main() {
	int n;
	cin >> n;
	deque<ll>ans;
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			if (i % 2 == 0) {
				ans.push_back(a[i]);
			}
			else {
				ans.push_front(a[i]);
			}
		}
		for (int i = 0; i < n; i++) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			if (i % 2 == 1) {
				ans.push_back(a[i]);
			}
			else {
				ans.push_front(a[i]);
			}
		}
		for (int i = 0; i < n; i++) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long int allmask;
long long int n;
void print(vector<vector<long long int>> &dp)
{
    for(long long int i=0;i<dp.size();i++)
    {
        for(long long int j=0;j<dp[0].size();j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
}
long long int count_ways(long long int mask,long long int i,vector<vector<long long int>> &dp,vector<vector<long long int>> &A)
{
    if(mask==allmask)
    {
        return 1;
    }
    if(i>=n)
    {
        return 0;
    }
    if(dp[mask][i]!=-1)
    {
        return dp[mask][i];
    }
    long long int count=0;
    for(long long int j=0;j<n;j++)
    {
        if(A[i][j] && !(mask & (1<<j)))
        {
            count=(count%mod)+(count_ways(mask | (1<<j),i+1,dp,A)%mod)%mod;
        }
    }
    dp[mask][i]=count;
    return dp[mask][i];
}
int main() 
{
	cin>>n;
	vector<vector<long long int>> A(n,vector<long long int>(n));
	for(long long int i=0;i<n;i++)
	{
	    for(long long int j=0;j<n;j++)
	    {
	        cin>>A[i][j];
	    }      
	}
	vector<vector<long long int>> dp(pow(2,n),vector<long long int>(n,-1));
	allmask=(1<<n)-1;
	cout<<count_ways(0,0,dp,A)%mod;
	//print(dp);
}

Measured memory_bytes: 411904
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

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


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, T;
	cin >> N >> T;

	vector<vector<Int>> ab(N, vector<Int>(2));
	for (Int i = 0; i < N; i++) {
		cin >> ab[i][0] >> ab[i][1];
	}
	//sort(ab.begin(), ab.end());

	//vector<vector<Int>> dp(N + 1, vector<Int>(T));//dp[i+1][j]: i番目までの料理の中で時間j以内となる最大うまさ

	//Int ans = 0;
	//for (Int i = 0; i < N; i++) {
	//	for (Int j = 0; j < T; j++) {

	//		//i番目の料理を食べる場合
	//		if (j + ab[i][0] < T) {
	//			dp[i + 1][j + ab[i][0]] = max(dp[i][j] + ab[i][1], dp[i + 1][j + ab[i][0]]);
	//		}

	//		//i番目の料理を食べない場合
	//		dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
	//	}
	//}

	auto dp = make_vec(N + 1, T, 2,0LL);//dp[i+1][j][k]: i番目までの料理の中で時間j以内となる最大うまさ k=1の時、既にT-1分時点で注文する商品が決まっている
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < T; j++) {
			for (Int k = 0; k < 2; k++) {
				if (k==0) {
					//i番目を取らない場合
					chmax(dp[i + 1][j][k], dp[i][j][k]);

					//i番目をT-1分に取る場合
					chmax(dp[i + 1][j][1], dp[i][j][k] + ab[i][1]);

					//i番目を普通に取る場合
					if (j + ab[i][0] < T) {
						chmax(dp[i + 1][j + ab[i][0]][k], dp[i][j][k] + ab[i][1]);
					}
				}
				else {
					//i番目を取らない場合
					chmax(dp[i + 1][j][k], dp[i][j][k]);

					//i番目を普通に取る場合
					if (j + ab[i][0] < T) {
						chmax(dp[i + 1][j + ab[i][0]][k], dp[i][j][k] + ab[i][1]);
					}
				}
			}
		}
	}


	Int ans = 0;
	/*or (Int i = 0; i < N; i++) {
	\
	}*/

	for (Int k = 0; k < 2; k++) {
		chmax(ans, dp[N][T-1][k]);
	}

	cout << ans << "\n";
}


Measured memory_bytes: 493056
import sys
from itertools import product, combinations_with_replacement
import math
from collections import defaultdict
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
N = int(input())
d = defaultdict(int)

combs = list(combinations_with_replacement(range(1, int(math.sqrt(10001))), 3))
for c in combs:
    x, y, z = c
    calc = x**2 + y**2 + z**2 +x*y +z*y + x*z
    #print(calc, x, y, z)
    if  x == y and y == z:
        d[calc] += 1
    elif x== y or x == z or y == z:
        d[calc] += 3
    else:
        d[calc] += 6


for i in range(1, N+1):
    if i in d:
        print(d[i])
    else:
        print(0)


Measured memory_bytes: 91096
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  if(n==1)
    printf("1\n");
  if(2<=n&&n<4)
    printf("2\n"); 
  if(4<=n&&n<8)
    printf("4\n"); 
  if(8<=n&&n<16)
    printf("8\n"); 
  if(16<=n&&n<32)
    printf("16\n"); 
  if(32<=n&&n<64)
    printf("32\n"); 
  if(64<=n&&n<=100)
    printf("64\n"); 
  return 0;
}

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

vector<vector<int>> ha;
vector<vector<int>> dp;

int solve(int day, int pre, int n){
    if(day>=n){
        return 0;
    }
    
    if(pre==-1){
        return max(ha[day][0] + solve(day+1, 0, n), max(ha[day][1] + solve(day+1, 1, n), ha[day][2] + solve(day+1, 2, n)));
    }
    
    if(dp[day][pre]!=-1){
        return dp[day][pre];
    }
    
    int m = INT_MIN;
    for(int i=0; i<3; i++){
        if(i==pre){
            continue;
        }
        m = max(m, ha[day][i] + solve(day+1, i, n));
    }
    
    return dp[day][pre] = m;
    
    
}

int main(){
    int n;
    cin>>n;
    ha.resize(n, vector<int> (3));
    dp.resize(n, vector<int> (3, -1));
    
    for(int i=0; i<n; i++){
        cin>>ha[i][0]>>ha[i][1]>>ha[i][2];
    }
    int res = solve(0, -1, n);
    cout<<res;
}

Measured memory_bytes: 23504
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> K;
  cin >>S;
  S[K-1]+=32;
  

  cout << S << endl;

}


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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import defaultdict

def main():
	h,w=MI()
	d=defaultdict(int)

	for _ in range(h):
		s=RD()
		for i in s:
			d[i]+=1

	dd=defaultdict(int)

	for k,v in d.items():
		q,r=divmod(v,4)
		dd[4]+=q
		qq,rr=divmod(r,2)
		dd[2]+=qq
		dd[1]+=rr
	#print(dd)


	ans="Yes"

	if h%2==0 and w%2==0:
		if dd[2]!=0 or dd[1]!=0:
			ans="No"

	elif h%2==0:
		if dd[1]!=0 or dd[2]>h//2:
			ans="No"

	elif w%2==0:
		if dd[1]!=0 or dd[2]>w//2:
			ans="No"

	else:
		if dd[1]!=1:
			ans="No"
		else:
			if dd[2]>h//2+w//2:
				ans="No"

	print(ans)


















if __name__ == "__main__":
	main()


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

int main() {

  int A, B, a, d, f = 0, N;
  cin >> A >> B;
  N = A;

  for (int i = 0; i < B - A + 1; i++) {
    a = N / 10000, d = N % 10;
    if (a == d) if(N / 1000 - a * 10 == (N % 100 - d) / 10) f++;
    N++;
  }

  cout << f << endl;

}

Measured memory_bytes: 3632
import java.util.*;
 
public class Main{
 
    int[] v;
    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
 
    void solve(){
        Scanner sc = new Scanner(System.in);

        calc();
 
        while(sc.hasNext()){
            String pzl = "";
            for(int i=0; i<2; i++){
                for(int j=0; j<4; j++){
                    pzl += sc.next();
                }
            }

            int ans = v[Integer.parseInt(pzl.substring(0,7))];
 
            System.out.println(ans);
        }
    }
 
    class P{
        String pzz;
        int x,y,cnt;
        P(String pzz, int x, int y, int cnt){
            this.pzz = pzz;
            this.x = x;
            this.y = y;
            this.cnt = cnt;
        }
    }
 
    void calc(){
        Queue<P> q = new LinkedList<P>();
        q.add(new P("01234567",0,0,0));
        v = new int[7654322];
        Arrays.fill(v,-1);
 
        while(q.size()>0){
            P pp = q.poll();
            String pzz = pp.pzz;
            int x = pp.x, y = pp.y, cnt = pp.cnt;
  
            int num = Integer.parseInt(pzz.substring(0,7));
            if(v[num]!=-1) continue;
            v[num] = cnt;
 
            char[] c = pzz.toCharArray();
 
            for(int i=0; i<4; i++){
                int nx = x+dx[i], ny = y+dy[i];
                if(nx<0 || nx>=4 || ny<0 || ny>=2) continue;
                c[y*4+x] = c[ny*4+nx];
                c[ny*4+nx] = '0';
                String ns = String.valueOf(c);
                q.add(new P(ns,nx,ny,cnt+1));
                c[ny*4+nx] = c[y*4+x];
                c[y*4+x] ='0';
            }
        }
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 44000
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

s = input()
t = input()
for i in range(len(s)):
    s = s[1:]+s[0]
    # print(s)
    if s == t:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 38512
#include<stdio.h>

int main()
{
    int n=0 ,m=0 ;
    int A[101][101] = {0} ;
    int b[101] = {0} ;
    int c[101] = {0} ;
    int i=0 ,j=0 ;

    scanf("%d %d" ,&n ,&m) ;

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

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

    for (i=0 ;i < n ;i++)
    {
        for (j=0 ;j < m ;j++)
        {
            c[i] = c[i] + (A[i][j] * b[j]) ;
        }
        printf("%d\n" ,c[i]) ;
    }

    return 0;
}

Measured memory_bytes: 648
#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;

  set<string> st;

  string s;
  rep(i, N) {
    cin >> s;
    st.insert(s);
  }

  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19120
using System;
using System.Linq;

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];

		var uf = new UF(n);

		for (int i = 0; i < h[1]; i++)
		{
			var q = Read();
			if (q[0] == 0)
				uf.Unite(q[1], q[2]);
			else
				Console.WriteLine(uf.AreUnited(q[1], q[2]) ? 1 : 0);
		}
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
}


Measured memory_bytes: 23140
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define PP pair<P,int>
using namespace std;
int inf = 1ll << 30;

int main(){
    for(int i=1;i<6;i++){
        int x; cin >> x;
        if(x==i)continue;
        cout << i << endl;
    }
}


Measured memory_bytes: 3636