akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<String> 
	// { 
	//     public int compare(String a, String b) 
	//     { 
	//     	return (a+b).compareTo(b+a);
	//     } 
	// }
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList<Integer> a[];
	// TreeMap<Integer, Long> map;
	// int vis[];
	// long d[];
	// void dfs(int ver, int m)
	// {
	// 	map.put(ver, d[m % 3]);
	// 	for(int v : a[ver])
	// 	{
	// 		if(vis[v] == 0){
	// 			vis[v] = vis[ver] + 1;
	// 			dfs(v, m + 1);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		int n = nextInt();
		if(n >= 30)
			out.println("Yes");
		else
			out.println("No");
	}
	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}
}



Measured memory_bytes: 32916
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int num;
    vector<int> a;
    int i, j;
    int ans = 11451419;
    int sum = 0;
    
    for(i = 0; i < n; i++){
        cin >> num;
        a.push_back(num);
    }
    
    for(i = -100; i <= 100; i++){
        sum = 0;
        for(j = 0; j < n; j++){
            sum += (a[j] - i) * (a[j] - i);
        }
        if(ans > sum){
            ans = sum;
        }
    }
    
    cout << ans << endl;
}


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

struct Edge
{
    int to;
    int cost;
    Edge(int t, int c) : to(t), cost(c) {}
};

bool bellmanford(int s, vector<vector<Edge>>& g, vector<int>& d, 
                vector<int>& prev, const int INF=1e9+1)
{
    int n = g.size();
    d.assign(n, INF);
    prev.assign(n, -1);
    d[s] = 0;
    
    rep(i,n) {
        rep(j,n) {
            for(auto& e:g[j]) {
                if(d[e.to] > d[j] + e.cost) {
                    d[e.to] = d[j] + e.cost;
                    prev[e.to] = j;
                    if(i == n-1) 
                        return false; // negative loop
                }
            }
        }
    }

    return true;
}

int main()
{
    int n,m,p;
    cin >> n >> m >> p;
    vector<vector<Edge>> g(n);
    vector<vector<Edge>> rg(n);
    rep(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        g[a-1].push_back({b-1, -(c-p)});
        rg[b-1].push_back({a-1, 0});
    }

    vector<int> d(n,-1), rd(n,-1);
    queue<pair<int,int>> que;
    que.push({0,0});
    d[0] = 0;
    while(!que.empty()) {
        int cv = que.front().first;
        int cd = que.front().second;
        que.pop();

        for(auto& e:g[cv]) {
            if(d[e.to] >= 0) continue;
            que.push({e.to, cd+1});
            d[e.to] = cd+1;
        }
    }
    if(d[n-1] < 0) {
        cout << -1 << endl;
        return 0;
    }

    que.push({n-1,0});
    rd[n-1] = 0;
    while(!que.empty()) {
        int cv = que.front().first;
        int cd = que.front().second;
        que.pop();

        for(auto& e:rg[cv]) {
            if(rd[e.to] >= 0) continue;
            que.push({e.to, cd+1});
            rd[e.to] = cd+1;
        }
    }

    rep(i,n)
        if(d[i] < 0 || rd[i] < 0) g[i].clear();

    vector<int> bd, prev;
    bool has_max = bellmanford(0, g, bd, prev);

    cout << (has_max ? max(0, -bd[n-1]) : -1) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int main(void){
  int n;

  while(cin >> n){
	if(n == 0) break;
	int field[n][n];
	int x= n/2 + 1;
	int y= n/2;
	int i=2;

	memset(field, -1, sizeof(field));
	field[x][y] = 1;
	x++; y++;
	while(i <= n*n){
	  if(x == n) x = 0;
	  if(y == n) y = 0;
	  if(x == -1) x = n-1;
	  if(y == -1) y = n-1;

	  if(field[x][y] == -1){
		field[x][y] = i++;
		x++; y++;
	  }else{
		x++; y--;
	  }
	}

	for(int i=0;i<n;i++){
	  for(int j=0;j<n;j++){
		printf("%4d", field[i][j]);
	  }
	  cout << endl;
	}
  }
  return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
num = {i%K:N//K for i in range(1, K+1)}
mod = N % K
for i in range(1, mod+1):
    num[i] += 1

ans = 0
for i in range(K):
    if (2*i) % K == 0:
        cnt = num[i]
        cnt *= num[(K-i)%K] * num[(K-i)%K]
        ans += cnt
print(ans) 

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    string s;
    cin >> s;
    REP(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 256
class UnionFind:
	def __init__(self,n):
		self.par=[i for i in range(n)]
		self.rank=[0]*n
	def find(self,x):
		if self.par[x]==x:
			return x
		else:
			self.par[x]=self.find(self.par[x])
			return self.par[x]
	def union(self,x,y):
		x=self.find(x)
		y=self.find(y)
		if self.rank[x]<self.rank[y]:
			self.par[x]=y
		else:
			self.par[y]=x
			if self.rank[x]==self.rank[y]:
				self.rank[x]+=1
	def same_check(self,x,y):
		return self.find(x)==self.find(y)

n,m=map(int,input().split())
uf=UnionFind(n)
p=[int(i)-1 for i in input().split()]
for _ in range(m):
	x,y=map(int,input().split())
	uf.union(x-1,y-1)
print([uf.same_check(i,p[i]) for i in range(n)].count(True))



Measured memory_bytes: 18608
from operator import mul
from functools import reduce


def cmb(n_cmb, r_cmb):
    r_cmb = min(n_cmb - r_cmb, r_cmb)
    if r_cmb == 0: return 1
    over = reduce(mul, range(n_cmb, n_cmb - r_cmb, -1))
    under = reduce(mul, range(1, r_cmb + 1))
    return over // under


n, m = map(int, input().split())

if n <= 1:
    ansn = 0
else:
    ansn = cmb(n, 2)

if m <= 1:
    ansm = 0
else:
    ansm = cmb(m, 2)
print(ansn + ansm)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000;     //10^9

int main () {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X.at(i);

    int ans = inf;
    for (int i = 0; i <= 100; i++) {
        int cost = 0;
        rep(j, N) cost += (X.at(j) - i) * (X.at(j) - i);
        ans = min(ans, cost);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
// abc161_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vector<int> dp(N);
    vector<int> dp_rev(N);

    C++;

    int tmp_max_cnt = 0;
    int max_cnt = 0;
    REP(i, N){
        if (i - C >= 0){
            max_cnt = max(max_cnt, dp[i-C]);
        }

        if (S[i] == 'o'){
            dp[i] = max_cnt + 1;
        } else {
            dp[i] = tmp_max_cnt;
        }
        tmp_max_cnt = max(tmp_max_cnt, dp[i]);
    }

    max_cnt = 0;
    tmp_max_cnt = 0;
    REP_REV(i, N){
        if (i + C < N){
            max_cnt = max(max_cnt, dp_rev[i+C]);
        }

        if (S[i] == 'o'){
            dp_rev[i] = max_cnt + 1;
        } else {
            dp_rev[i] = tmp_max_cnt;
        }
        tmp_max_cnt = max(tmp_max_cnt, dp_rev[i]);
    }

//    print(dp);
//    print(dp_rev);

    REP(i, N) {
        if (S[i] == 'o') {
            if (i == 0){
                if (dp_rev[1] < K) print(i+1);
            } else if ( i == N-1){
                if (dp[N-2] < K) print(i+1);
            } else {
                if (dp[i - 1] + dp_rev[i + 1] < K) print(i+1);
            }
        }

    }
    return 0;



    // 以下WA


//    vector<bool> need(N, true);
//    need[0] = dp_rev[1] < K;
//    need[N-1] = dp[N-2] < K;
    vector<int> need_imos(N, 0);

    if (C == 1) C = 2; //特殊処理
    REP(i, N-C){
        if (dp[i] + dp_rev[i + C] >= K){
//            REPN(j, 1, C){
//                need[i+j] = false;
//            }
            need_imos[i+1] ++;
            need_imos[i+C] --;
        }
    }

    vector<bool> need(N, true);
    int cumsum = 0;
    REP(i, N){
        cumsum += need_imos[i];
        if (cumsum > 0){
            need[i] = false;
        }
    }
    need[0] = dp_rev[1] < K;
    need[N-1] = dp[N-2] < K;

//    print(need);

    REP(i, N){
        if (need[i] && S[i] == 'o'){
            print(i+1);
        }
    }

    return 0;
}


Measured memory_bytes: 3348
// abc053_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  int ans=0,i,j;
  cin >> s;
  for (i=0; i<s.size(); ++i) {
    if(s[i]=='A') break;
  }
  for(j=i+1; j<s.size(); ++j)  {
    if (s[j]=='Z') {
      ans = max(ans,j-i+1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

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

   vector<int> b(n+1);
   b[0]=100000000;
   b[n]=100000000;
   for(int i=1;i<n;i++){
      cin>>b[i];
   }
   ll ans=0;
   for(int i=1;i<=n;i++){
      int a=min(b[i-1],b[i]);
      ans+=a;
   }

   cout<<ans;
   return 0;
}


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

int main(){
    int N;
    int input;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> input;
        if(input % 2 == 1) continue;
        if(input % 3 != 0 && input % 5 != 0){
            cout << "DENIED" << "\n";
            return 0;
        }
    }
    cout << "APPROVED" << "\n";
}

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

int main(){
	int n;
	cin >> n;
	int ans=0;
	for (int i=1;i<=n;i++){
		if (std::to_string(i).size()%2==1){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  import MapHelper._

  val n = in.readInt
  val pb = Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray
  
  val map = mu.HashMap.empty[(Int,Int),Int]

  for {
    a <- pb
    b <- pb
    if a != b
  } {
    val x = a(0) - b(0)
    val y = a(1) - b(1)
    map.addOrUpdate((x, y), 1)
  }


  val t = if(map.nonEmpty) map.maxBy(_._2)._2 else 0

  val ans = n - t
  println(ans)

  object MapHelper {
    implicit class AddOrUpdate[A](map:mu.HashMap[(Int,Int),Int]) {
      def addOrUpdate(key:(Int,Int), value:Int):mu.HashMap[(Int,Int),Int] =
      {
        if(map.contains(key)) map(key) += value
        else map += (key -> value)
        map
      }
    }
  }
}

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

int main(){

	int n;
	cin >> n;

	int card[4][13] = {};
	int i = 0;
	char mark;
	int num;
	while(i < n){
		cin >> mark >> num;
		if(mark == 'S'){
			card[0][num-1] = 1;
		}else if(mark == 'H'){
			card[1][num-1] = 1;
		}else if(mark == 'C'){
			card[2][num-1] = 1;
		}else if(mark == 'D'){
			card[3][num-1] = 1;
		}
		i++;
	}

	for(int j = 0; j < 4; j++){
		for(int k = 0; k < 13; k++){
			if(card[j][k] == 0){
				if(j == 0){
					cout << "S " << k + 1 << endl;
				}else if(j == 1){
					cout << "H " << k + 1 << endl;
				}else if(j == 2){
					cout << "C " << k + 1 << endl;
				}else if(j == 3){
					cout << "D " << k + 1 << endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int a, b;
	int i, j;
    int goukei1, goukei2, goukei3;
    goukei1 = 0;
    goukei2 = 0;
    goukei3 = 0;
    int hyou[100][100];

	scanf("%d %d", &a, &b);


	for (i = 0; i < a; i++)
	{

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


    for (i = 0; i < a; i++) 
    {

        for (j = 0; j < b; j++) 
        {

            printf("%d ", hyou[i][j]);

            goukei1 = goukei1 + hyou[i][j];

        }

        printf("%d\n", goukei1);

        goukei1 = 0;

    }


    for (j = 0; j < b; j++)
    {

        for (i = 0; i < a; i++)
        {

            goukei2 = goukei2 + hyou[i][j];

        }

        printf("%d ", goukei2);

        goukei3 = goukei3 + goukei2;
        goukei2 = 0;

    }


    printf("%d\n", goukei3);

    return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int Q;cin >> Q;
  vector<ll> v;
  ll minval = 0;
  priority_queue<int> left;
  priority_queue<int,vector<int>,greater<int> > right;
  ll C;
  while(Q--){
    int q;cin >> q;
    if(q==1){
      ll a,b;
      cin >> a >> b;
      minval+=b;
      if(left.size() == 0){
        left.push(a);
      }else if(left.size()==right.size()){
        int vrt = right.top();
        if(a>vrt){
          minval += abs(a-vrt);
          left.push(vrt);
          right.pop();
          right.push(a);
        }else{
          int vlt = left.top();
          minval += max(0LL,vlt - a);
          left.push(a);
        }
      }else{
        int vlt = left.top();
        minval+=abs(a-vlt);
        if(vlt <= a){
          right.push(a);
        }else{
          right.push(vlt);
          left.pop();
          left.push(a);
        }
      }
    }else{
      int vlt = left.top();
      cout << vlt << " " << minval << endl;
    }
  }
  return 0;
}


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

#define State string::const_iterator
class ParseError {};

int expression(State &begin);
int term(State &begin);
int number(State &begin);
int factor(State &begin);

// 四則演算の式をパースして、その評価結果を返す。
int expression(State &begin) {
    int ret = term(begin);

    while(true){
        if(*begin == '+'){
            begin++;
            ret += term(begin);
        }
        else if(*begin == '-'){
            begin++;
            ret -= term(begin);
        }
        else{
            break;
        }
    }

    return ret;

}

// 乗算除算の式をパースして、その評価結果を返す。
int term(State &begin) {
    int ret = factor(begin);

    while(true){
        if(*begin == '*'){
            begin++;
            ret *= factor(begin);
        }
        else if(*begin == '/'){
            begin++;
            ret /= factor(begin);
        }
        else{
            break;
        }
    }

    return ret;
}

// 数字の列をパースして、その数を返す。
int number(State &begin) {
    int ret = 0;

    while(isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

// 括弧か数をパースして、その評価結果を返す。
int factor(State &begin) {
    if (*begin == '(') {
        begin++; // '('を飛ばす。
        int ret = expression(begin);
        begin++; // ')'を飛ばす。
        return ret;
    } else {
        return number(begin);
    }
}

int main() {

    int n;

    cin >> n;

    while(n--){

        string input;

        cin >> input;

        State s = input.begin();

        cout << expression(s) << endl;

    }

    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    string A,B;
    int ans = 0,cnt = 0;
    for(int i=1;i<N;i++){
        A = S.substr(0,i);
        B = S.substr(i,N-i);
        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
       A.erase(unique(A.begin(),A.end()),A.end());
       B.erase(unique(B.begin(),B.end()),B.end());
        
        for(int j=0;j<A.length();j++){
            for(int k=0;k<B.length();k++){
                if(A[j]==B[k]){
                    cnt++;
                }
                ans = max(ans,cnt);
            }
        }
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    while (H != 0)
    {
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i%2 == 0 && j%2 == 0) || (i%2 == 1 && j%2 == 1)){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;

        cin >> H >> W;
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v < w) cout << "NO\n";
	else {
		ll dis = abs(a - b);
		if (dis <= t * (v - w)) cout << "YES\n";
		else cout << "NO\n";
	}
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

vector<vector<int>> g;
vector<int> r;

vector<int> grn;

int rec(int cur)
{
    if (grn[cur] >= 0)
        return grn[cur];

    vector<int> v;
    for (auto& next : g[cur]) {
        v.push_back(rec(next));
    }

    sort(v.begin(), v.end());

    // cerr << "#";
    // for (auto& t : v) {
    //     cerr << " " << t;
    // }

    int ret = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] < ret)
            continue;
        if (ret == v[i]) {
            ret++;
            continue;
        }
        break;
    }

    // cerr << ": " << ret << endl;

    return grn[cur] = ret;
}

bool check(int i)
{
    int c = grn[i];
    set<int> ss;
    for (auto& next : g[i]) {
        int t = grn[next];
        if (t < c)
            ss.insert(t);
        if (t == c)
            return false;
    }
    return ss.size() == c;
}

int main()
{
    cin.tie(0);
    int64_t n;
    cin >> n;

    g.resize(n);
    r.resize(n);

    for (int i = 0; i < n; i++) {
        int f;
        cin >> f;
        f--;
        g[f].push_back(i);
        r[i] = f;
    }

    vector<int> used(n, -1);
    vector<int> loop;
    int loop_start = 0;
    {
        int cur = 0;
        while (used[cur] < 0) {
            used[cur] = loop.size();
            loop.push_back(cur);
            cur = r[cur];
        }
        loop_start = used[cur];
    }

    int min_deg = n + 1;
    int min_vert = 0;

    // cerr << "* ";
    // for (int i = loop_start; i < loop.size(); i++) {
    //     cerr << loop[i] << " ";
    // }
    // cerr << endl;

    for (int i = loop_start; i < loop.size(); i++) {
        int v = loop[i];
        int deg = g[v].size();
        if (deg < min_deg) {
            min_deg = deg;
            min_vert = v;
        }
    }

    // cerr << "* mv: " << min_vert << ", " << min_deg << endl;

    grn.resize(n);
    for (int cand = 0; cand <= min_deg; cand++) {
        for (int i = 0; i < n; i++) {
            grn[i] = (i == min_vert ? cand : -1);
        }

        // cerr << "* ";
        // for (int i = 0; i < n; i++) {
        //     cerr << grn[i] << " ";
        // }
        // cerr << endl;

        for (int i = 0; i < n; i++) {
            if (i == min_vert)
                continue;
            rec(i);
        }

        // cerr << "* ";
        // for (int i = 0; i < n; i++) {
        //     cerr << grn[i] << " ";
        // }
        // cerr << endl;

        if (check(min_vert)) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 20596
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int N, M, R;

struct Edge
{
    int dst;
    int weight;
    Edge(int dst, int weight) : dst(dst), weight(weight) {}
};

vector<Edge> Edges[200];
int d[200];

void dijkstra(int s)
{
    priority_queue<pint, vector<pint>, greater<pint>> q;
    fill(d, d + 200, INF);
    d[s] = 0;
    q.push(pint(0, s));
    while (q.size())
    {
        pint p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
        {
            continue;
        }
        for (int i = 0; i < Edges[v].size(); i++)
        {
            Edge e = Edges[v][i];
            if (d[e.dst] > d[v] + e.weight)
            {
                d[e.dst] = d[v] + e.weight;
                q.push(pint(d[e.dst], e.dst));
            }
        }
    }
}

int d_goal[8][8];
int solve(int n_visited, int now_pos)
{
    if ((1 << R) - 1 == n_visited)
    {
        return 0;
    }

    int res = INF;
    rep(i, R)
    {
        if (!(n_visited & (1 << i)))
        {
            res = min(res, solve(n_visited | (1 << i), i) + d_goal[i][now_pos]);
        }
    }
    return res;
}

int main()
{
    cin >> N >> M >> R;
    int goal[R];
    rep(i, R)
    {
        cin >> goal[i];
        goal[i]--;
    }
    rep(i, M)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        Edges[a].push_back(Edge(b, c));
        Edges[b].push_back(Edge(a, c));
    }

    rep(i, R)
    {
        dijkstra(goal[i]);
        rep(j, R)
        {
            d_goal[i][j] = d[goal[j]];
        }
    }

    int ans = INF;
    rep(i, R)
    {
        ans = min(ans, solve(0 | (1 << i), i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
   vector<vector<int>> v(3, vector<int> (3));
   vector<vector<bool>> ch(3, vector<bool> (3));
   for (int i = 0; i < 3; ++i) {
	   for (int j = 0; j < 3; ++j) {
		   cin >> v[i][j];
	   }
   }
   int n;
   cin >> n;
   vector<int> val(n);
   for(int i = 0; i < n; ++i) {
	   cin >> val[i];
   }
   for(int i = 0; i < n; ++i) {
	   for (int j = 0; j < 3; ++j) {
		   for (int k = 0; k < 3; ++k) {
			   if (v[j][k] == val[i]) {
				   ch[j][k] = 1;
			   }
		   }
	   }
   }
   bool d = 0;
   for (int i = 0; i < 3; ++i) {
	   bool a = 1;
	   bool b = 1;
	   for (int j = 0; j < 3; ++j) {
		   if (ch[i][j] != 1) {
			   a = 0;
		   }
		   if (ch[j][i] != 1) {
			   b = 0;
		   }
	   }
	   if (a || b) {
			   d = 1;
		}
   }
   if (ch[0][0] == 1 && ch[1][1] == 1 && ch[2][2] == 1) {
	   d = 1;
   }
   if (ch[2][0] == 1 && ch[1][1] == 1 && ch[0][2] == 1) {
	   d = 1;
   }
   if (d) {
	   cout << "Yes";
   }else {
	   cout << "No";
   }
}



















Measured memory_bytes: 3620
#n,m = map(int,input().split())
#s,t = map(str,input().split())
#a = list(map(int,input().split()))
#m = list(map(str,input().split()))
#n = int(input())
#s = list(str(input()))
#s = str(input())
#t = str(input())

s_dash = list(str(input()))
t = list(str(input()))

lt = len(t)
ls = len(s_dash)
msg = "UNRESTORABLE"

#Tの方が長ければ不可能
if ls < lt:
    print(msg)
    exit()

#Sの候補を探す
candidate = []
for i in range(ls-lt+1):
    is_matched = True#TとS'の部分文字列が一致する可能性があるか
    tmp = s_dash.copy()

    for j in range(lt):
        if t[j] == s_dash[i+j] or s_dash[i+j] == '?':
            tmp[i+j] = t[j]
        else:
            is_matched = False
            break

    if is_matched == True:#一致する可能性があれば
        for j in range(ls):#残った'?'は'a'に置換
            if tmp[j] == '?':
                tmp[j] = 'a'
        
        cand = str("")
        for c in tmp:
            cand += c
        candidate.append(cand)

if len(candidate) == 0:
    print(msg)
else:
    candidate.sort()
    print(candidate[0])

Measured memory_bytes: 9008
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,k;
    cin >> n >> k;
    cout << k * (int64)pow(k-1,n-1) << endl;
}

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

int main(){
	#ifndef ONLINE_JUDGE 

	// For getting input from input.txt file 
	freopen("/home/devanshi/AtCoderDPproblems/vacationinput.txt", "r", stdin); 

	// Printing the Output to output.txt file 
	freopen("/home/devanshi/AtCoderDPproblems/vacationoutput.txt", "w", stdout); 

	#endif 

	int n;
	cin>>n;

	int*a=new int[n];
	int*b=new int[n];
	int*c=new int[n];

	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}

	int dp[100001][3];

	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];

	for(int i=1;i<n;i++){
		dp[i][0]=max(a[i]+dp[i-1][1],a[i]+dp[i-1][2]);
		dp[i][1]=max(b[i]+dp[i-1][0],b[i]+dp[i-1][2]);
		dp[i][2]=max(c[i]+dp[i-1][1],c[i]+dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

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

using namespace std;

vector<int> count(int first, int last, int distance) {
  vector<int> v;
  if (first >= last) {
    v.push_back(0);
    v.push_back(0);
    return v;
  };

  int d1 = distance - 1;
  int d2 = last - first;
  int cnt = d2 / d1;
  int rem = d2 % d1;

  v.push_back(rem == 0 ? cnt : cnt + 1);
  v.push_back(rem);
  return v;
}

int main()
{
  int N, K;
  vector<int> A;
  cin >> N;
  cin >> K;
  for (int i = 0; i < N; i++) {
    int buf;
    cin >> buf;
    A.push_back(buf);
  }
  int min_i = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 1) {
      min_i = i;
      break;
    }
  }
  vector<int> prev = count(0,     min_i, K);
  vector<int> next = count(min_i, N - 1, K);
  int cnt = prev[0] + next[0];
  if (prev[1] + next[1] <= K - 1 && prev[1] > 0 && next[1] > 0) cnt--;

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int flag1=0;
    int flag2=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
        {
            flag1=1;
            break;
        }
    }

    if(s[(n-1)/2 -1]!=s[0] || s[(n+3)/2 -1]!=s[n-1])
        flag2=1;

    // cout<< flag1||flag2 ;
    if((flag1 || flag2 )==1)
        cout<<"No";
    else
    {
        cout<<"Yes";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<int> v(1<<N,MAX_I);
  v[0] = 0;
  rep(i,M){
    int cost,n;cin >> cost >> n;
    int S = 0;
    while(n--){
      int x;cin >> x;
      --x;
      S|=1<<x;
    }
    rep(s, 1<<N){
      if((s&S) == S) continue;
      if(v[s] == MAX_I) continue;
      v[s|S] = min(v[s]+cost, v[s|S]);
    }
  }
  if(v[(1<<N)-1] == MAX_I) cout << -1 << endl;
  else cout << v[(1<<N)-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

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

const int N = 2e4 + 10;
const long long INF = (ll)1e18;

int main ()
{
	int a, b, c, d, n;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &n);
	c = min(c, 4 * a); c = min(c, 2 * b);
	ll ans = 0;
	if(n & 1){
		if(d < 2 * c) ans = (ll) n / 2 * d + c;
		else ans = (ll) n * c;
	}else{
		d = min(d, c * 2);
		ans = (ll)n / 2 * d;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
const ld pi=3.14159265358979323846;
 
int main() {
    ll n,l;
    cin>>n>>l;
    vector<string> v;
    rep(i,n){
        string s;
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    string ans="";
    rep(i,n){
        ans+=v.at(i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
unordered_map<ll,vector<ll>>seen;
ll dp[100001];
bool visited[100001];
double a[3001];
double memo[3001][3001];
ll taken[3001][3001];
double findans(ll i,ll n,ll h)
{
    if(i==n)
    {
        ll t=n-h;
        if(t<h)
        {
            return 1.0;
        }
        else
        {
            return 0.0;
        }
    }
    if(memo[i][h]!=-1)
    {
        return memo[i][h];
    }
    double p1=0.0,p2=0.0;
    p1=a[i]*findans(i+1,n,h+1);
    p2=(1-a[i])*findans(i+1,n,h);
    //taken[i][h]=1;
    return memo[i][h]=p1+p2;
}

int main(){
    // Your code here!
    
    cin>>n;
    
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<=3000;i++)
    {
        for(ll j=0;j<=3000;j++)
        {
            memo[i][j]=-1.0;
            //memo[i][j]=0;
        }
    }
    cout<<fixed<<setprecision(10)<<findans(0,n,0);
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int h, w, m;
  cin >> h >> w >> m;
  int mx = 0, my = 0;
  vector<int> x(300010), y(300010);
  set<P> se;
  rep(i, 0, m) {
    int nx, ny;
    cin >> nx >> ny;
    --nx, --ny;
    ++x[nx];
    ++y[ny];
    chmax(mx, x[nx]);
    chmax(my, y[ny]);
    se.insert({nx, ny});
  }
  vector<int> sx, sy;
  rep(i, 0, h) if (mx == x[i]) sx.emplace_back(i);
  rep(i, 0, w) if (my == y[i]) sy.emplace_back(i);
  bool jud = false;
  int ans = mx + my;
  arep(i, sx) arep(j, sy) if (se.find({i, j}) == se.end()) {
    jud = true;
    goto out;
  }
out:
  cout << (jud ? ans : ans - 1) << '\n';
  return 0;
}

Measured memory_bytes: 35048
#include "bits/stdc++.h"
using namespace std;

vector<int> G[52];
vector<int> used(52,0);
int x,y;
int c=0;

int dfs(int p){
	if(p==y){
		c=1;
	}
	for(int i=0;i<G[p].size();i++){
		if((p==x&&G[p][i]==y)){
		}else if(used[G[p][i]]==0){
			used[G[p][i]]=1;
			dfs(G[p][i]);
			used[G[p][i]]=0;
		}
	}
	return 0;
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> a(52);
	vector<int> b(52);
	
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	
	int ans=0;
	
	for(int i=0;i<m;i++){
		x=a[i];
		y=b[i];
		c=0;
		dfs(a[i]);
		ans+=1-c;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<
      max(a,max(b,c))*10+(a+b+c)-max(a,max(b,c))
      <<endl;
}

Measured memory_bytes: 256
N, M, C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
x = C


for i in range(N):
    A = list(map(int,input().split()))
    for k in range(M):
        x += A[k] * B[k]
    if x > 0:
        ans += 1
    x = C 

print(ans)

Measured memory_bytes: 9120
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

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


Measured memory_bytes: 764
//050A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b =0;
    char op = ' ';
    cin >> a >> op >> b;
    if (op=='+'){
        cout << a+b;
    }else if (op=='-'){
        cout << a-b;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0)
    {
        c-=b;
        if(c<=0)
            break;
        a-=d;
        if(a<=0)
            break;
    }
    if(a<=0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iterator>
#include <map>
#include <string>

using Key = std::string;

int main(void) {
    int q;
    std::cin >> q;

    std::map<Key, int> my_map{};
    for (int i = 0; i < q; ++i) {
        int kind;
        std::cin >> kind;

        Key key;
        switch (kind) {
            case 0:
                /**
                 * insert
                 * add key-x to my_map
                 * if exist, update it
                 */
                int x;
                std::cin >> key >> x;
                if (my_map.find(key) == my_map.end()) {
                    my_map.insert(std::make_pair(key, x));
                } else {
                    my_map[key] = x;
                }
                break;
            case 1:
                /**
                 * get
                 * output value whose key is it
                 * but no-exist case, output 0
                 */
                std::cin >> key;
                if (my_map.find(key) != my_map.end()) {
                    std::cout << my_map[key] << std::endl;
                } else {
                    std::cout << 0 << std::endl;
                }
                break;
            case 2:
                /**
                 * delete
                 * delete member whose key is it
                 */
                std::cin >> key;
                my_map.erase(key);
                break;
        }
    }
}


Measured memory_bytes: 27776
(* O(|s|) *)
let string_count s sub =
  let n = String.length s in
  let sub_len = String.length sub in
  let reg = Str.regexp sub in
  let rec loop acc i =
    try
      if i >= n then
        acc
      else
        let j = Str.search_forward reg s i + sub_len in
        loop (acc + 1) j
    with
    | _ -> acc
  in
    loop 0 0

(* O(n^2) *)
let solve n ss =
  let b_start, a_end, both, ab = List.fold_left
    (fun (b_start, a_end, both, ab) s ->
      let count = string_count s "AB" in
      let new_ab = ab + count in
      let starts_b = s.[0] = 'B' and ends_a = s.[String.length s - 1] = 'A' in
      let new_b_start = if starts_b then b_start + 1 else b_start in
      let new_a_end = if ends_a then a_end + 1 else a_end in
      if starts_b && ends_a then
        new_b_start - 1, new_a_end - 1, both + 1, new_ab
      else
      new_b_start, new_a_end, both, new_ab)
    (0, 0, 0, 0)
    ss
  in
    let pair = min b_start a_end in
    let need = max b_start a_end - pair in
    let addition = if pair > 0 || need > 0 then
        pair + both
      else
        max (both - 1) 0
    in
      addition + ab

(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

let _ =
  let n = read_int () in
  fold_int
    (fun acc _ -> read_line () :: acc)
    []
    n |> solve n |> string_of_int |> print_endline

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

using namespace std;

#define int long long 
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, x, a[2001];
int tmp[2001];

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

    cin >> N >> x;
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
        tmp[i] = a[i];
    }
    int res = LINF;
    for(int i = 0; i < N; ++i) {
        int ret = i * x;
        for(int j = 0; j < N; ++j) chmin(tmp[j], a[(j - i + N) % N]);
        for(int j = 0; j < N; ++j) ret += tmp[j];
        chmin(res, ret);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int H1, M1, H2, M2, K;

	cin >> H1 >> M1 >> H2 >> M2 >> K;

	cout << H2 * 60 + M2 - (H1 * 60 + M1) - K << endl;


	

	






	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

ll mpow(ll a, ll b, ll m = mod) {
	ll ans = 1;
	while (b) {
		if (b & 1ll) {
			ans *= a;
			ans %= m;
		}
		a *= a;
		a %= m;
		b = b >> 1;
	}
	return ans;
}

void solve() {

	ll n;
	cin >> n;
	ll ans = mpow(10,n);
	ans = (((ans - mpow(9,n))%mod)+mod)%mod;
	ans = (((ans - mpow(9,n))%mod)+mod)%mod;
	ans = (((ans + mpow(8,n))%mod)+mod)%mod;
	cout << ans << endl;

}

int32_t main()
{
	IOS
	// int T; cin >> T; while (T--)
	solve();
	return 0;
}


Measured memory_bytes: 3644