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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int h,w,a,b;

signed main() {
    cin >> h >> w >> a >> b;
    rep(i,h) {
        rep(j,w) {
            if (i<b ^ j<a) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int arr[MAXN];
int mod(ll x){x%=INF;
	return x;	
}
int f(int x){
	return mod(x*1LL*(x+1)/2);	
}
int main(){
  //  freopen("file.in", "r", stdin);
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    	scanf("%d",arr+i);
    for(int i=1;i<=n;i++){
		int a=0,b=0;
		for(int j=i+1;j<=n;j++)
			b+=(arr[i]>arr[j]);
		for(int j=1;j<=n;j++)
			a+=(arr[i]>arr[j]);
		ans=mod(ans+mod(k*1LL*b));
		ans=mod(ans+mod(a*1LL*f(k-1)));		
	}
	printf("%d\n",ans);
	return 0;
}


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

ll a[MAX_N];
ll b[MAX_N];

ll lmax(ll x,ll y){return (x<y)?y:x;}

int main()
{
    ll N, d, e, f;
    e = 0;
    f = 0;
    cin >> N;
    for (int i = 0; i < N + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < N; i++)
    {
        d = lmax(0, b[i] - a[i]);
        a[i + 1] -= d;
        if (a[i + 1] < 0)
        {
            e += a[i + 1];
            a[i + 1] = 0;
        }
    }
    for (int i = 0; i < N; i++)
    {
        f += b[i];
    }
    cout << f+e;
    //printf("%lld\n", f + e);
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
  int k;
  cin >>k;
    
    vector<long long> h(100200);
    rep(i,n) {
     cin >> h[i];
    }
    
    
   const long long INF = 1LL << 60;
   long long dp[100200];
   
    
    for(int i = 0;i < 100200;i++) {
     dp[i] = INF;
    }
    dp[0] = 0;
    
    for(int i = 0;i<n;i++) {
        for(int j = 1;j<=k;j++)
     chmin(dp[i+j], dp[i]+abs(h[i] - h[i+j]));
     }
    
    cout << dp[n-1];
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    int H, W;
    cin >> H >> W;

    V<string> grid(H);
    rep(i, H) {
        string t;
        cin >> t;
        grid[i] = t;
    }

    lint ah = H, aw = W;
    VV<bool> flag(H, V<bool>(W, false));
    rep(y, H) {

        bool f = true;
        rep(x, W) {
            if(grid[y][x] == '#') {
                f = false;
            }
        }
        if(f) {
            ah--;
            rep(x, W) { flag[y][x] = true; }
        }
    }

    rep(x, W) {

        bool f = true;
        rep(y, H) {
            if(grid[y][x] == '#') {
                f = false;
            }
        }
        if(f) {
            aw--;
            rep(y, H) { flag[y][x] = true; }
        }
    }

    V<string> ans(ah);

    lint i = 0;
    rep(y, H) {
        string t = "";
        rep(x, W) {
            if(not flag[y][x]) {
                t += grid[y][x];
            }
        }
        if(t != "") {
            ans[i] = t;
            i++;
        }
    }

    rep(y, ah) { cout << ans[y] << endl; }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3628
/*
 * d.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int ids[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    nbrs[u].push_back(v);
    nbrs[v].push_back(u);
  }

  int gn = 0;

  for (int st = 0; st < n; st++)
    if (! ids[st]) {
      ids[st] = ++gn;
      qi q;
      q.push(st);

      while (! q.empty()) {
	int u = q.front(); q.pop();
	vi &nbru = nbrs[u];

	for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
	  int &v = *vit;
	  if (! ids[v]) {
	    ids[v] = gn;
	    q.push(v);
	  }
	}
      }
    }

  int qn;
  cin >> qn;
  while (qn--) {
    int s, t;
    cin >> s >> t;
    cout << (ids[s] == ids[t] ? "yes" : "no") << endl;
  }
  return 0;
}

Measured memory_bytes: 7064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	if s == "Sunny" {
		fmt.Println("Cloudy")
	} else if s == "Cloudy" {
		fmt.Println("Rainy")
	} else {
		fmt.Println("Sunny")
	}
}


Measured memory_bytes: 1772
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    edge=[[] for _ in range(N)]
    for _ in range(N-1):
        a,b,c=map(int1,input().split())
        c+=1
        edge[a].append((c,b))
        edge[b].append((c,a))
    
    Q,K=map(int,input().split())
    K-=1
    from heapq import heappop,heappush
    def dijkstra(start,n,edges):
        d=[INF]*n
        used=[False]*n
        d[start]=0
        used[start]=True
        edgelist=[]
        for edge in edges[start]:
            heappush(edgelist,edge)
        while edgelist:
            minedge=heappop(edgelist)
            if used[minedge[1]]:
                continue
            v=minedge[1]
            d[v]=minedge[0]
            used[v]=True
            for edge in edges[v]:
                if not used[edge[1]]:
                    heappush(edgelist,(edge[0]+d[v],edge[1]))
        return d
    
    d=dijkstra(K,N,edge)
    for _ in range(Q):
        x,y=map(int1,input().split())
        print(d[x]+d[y])

if __name__ == '__main__':
    main()


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

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

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

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt();
    if(a%3==0||b%3==0||(a+b)%3==0)
        cout<<"Possible\n";
    else
        cout<<"Impossible\n";
    
    
    return 0;   
}




 
 


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<vector<int>> G(3, vector<int>(N+1, 0));
  for (int i = 0; i < N; i++) {
    G.at(0).at(i+1) = G.at(0).at(i);
    if (S.at(i) == 'R') G.at(0).at(i+1)++;
  }
  for (int i = 0; i < N; i++) {
    G.at(1).at(i+1) = G.at(1).at(i);
    if (S.at(i) == 'G') G.at(1).at(i+1)++;
  }
  for (int i = 0; i < N; i++) {
    G.at(2).at(i+1) = G.at(2).at(i);
    if (S.at(i) == 'B') G.at(2).at(i+1)++;
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    for (int k = i+1; k < N; k++) {
      if ((S.at(i) == 'R' && S.at(k) == 'G') || (S.at(i) == 'G' && S.at(k) == 'R')) {
        ans += G.at(2).at(k) - G.at(2).at(i+1);
        if (((k - i) % 2 == 0) && S.at((k+i)/2) == 'B') ans--;
      }
      if ((S.at(i) == 'R' && S.at(k) == 'B') || (S.at(i) == 'B' && S.at(k) == 'R')) {
        ans += G.at(1).at(k) - G.at(1).at(i+1);
        if (((k - i) % 2 == 0) && S.at((k+i)/2) == 'G') ans--;
      }
      if ((S.at(i) == 'G' && S.at(k) == 'B') || (S.at(i) == 'B' && S.at(k) == 'G')) {
        ans += G.at(0).at(k) - G.at(0).at(i+1);
        if (((k - i) % 2 == 0) && S.at((k+i)/2) == 'R') ans--;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, bsum = 0;
    cin >> n;
    vector<int> a(n+1,0), b(n+1,0);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        if(n/2 < i){
            b[i] = a[i];
            bsum += b[i];
        }
    }
    for(int i = n/2; i >= 1; i--){
        for(int j = i*2; j <= n; j += i){
            b[i] += b[j];
        }
        b[i] = (b[i] % 2 != a[i] ? 1 : 0);
        bsum += b[i];
    }
    cout << bsum << endl;
    for(int i = 1; i <= n; i++){
        if(b[i]) printf("%d ", i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;


int main() {
    int i, j, num, start, end, c;
    double a, b, rad, s[1000], mean, dev;

    cin >> num;
    while(num!=0){

        mean=0.0;
        for(i=0;i<num;i++){
            cin >> s[i];
            mean = mean + s[i];
        }
        mean = mean / num;

        dev=0.0;
        for(i=0;i<num;i++){
            dev = dev + (s[i]-mean)*(s[i]-mean);
        }
        dev = sqrt(dev/num);

        cout << fixed <<setprecision(10) << dev << endl;

        cin >> num;
    }

    return 0;
}


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

int main(){
  int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  k=k-1;
  cout<<a[k];
}


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

int main() {
	int a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	string k = "win";
	if(a1 + a2 + a3	 >= 22)
	{
		k = "bust";
	}
    cout << k << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,x[210],y[210],p;
const int q=998244353;
inline int power(int a,int b)
{
	if(!b)
	  return 1;
	int c=power(a,b>>1);
	c=(L)c*c%q;
	if(b&1)
	  c=(L)c*a%q;
	return c;
}
inline bool chk(int i,int j,int k)
{
	return (x[i]-x[k])*(y[j]-y[k])-(x[j]-x[k])*(y[i]-y[k])==0;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l,u;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  scanf("%d%d",&x[i],&y[i]);
	p=power(2,n)-1-n;
	for(i=1;i<=n;i++)
	  for(j=i+1;j<=n;j++)
	    {
	     for(k=1,l=4,u=3;k<=n;k++)
	       if(k!=i && k!=j && chk(i,j,k))
	         if(k<j)
	           {
				l=u=0;
				break;
			   }
			 else
			   {
			    l=(l<<1)%q;
			    u++;
			   }
		 p=(p-l+u)%q;
		}
	p=(p+q)%q;
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.nextLine();
        String t = stdIn.nextLine();
        int c = 0;
        for(int i = 0; i < s.length() ; i++){
            if(s.charAt(i) != t.charAt(i)){
                c += 1;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 42520
k = int(input())
a, b = map(int, input().split())
if a > b:
    print("NG")
if a == b:
    if b % k == 0:
        print("OK")
        exit()
    else:
        print("NG")
        exit()
num_a = a // k
num_b = b // k
if num_b > num_a:
    print("OK")
else:
    if a % k == 0:
        print("OK")
    else:
        print("NG")

Measured memory_bytes: 61896
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl B(N - 1, 0);
  REP(i, N - 1) cin >> B[i];
  ll ans = 0;
  REP(i, N - 1) {
    if (i == 0)
      ans += B[0];
    else
      ans += min(B[i], B[i - 1]);
  }
  ans += B[N - 2];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<stdio.h>
#include<string.h>
#include<string>
#include<string>
#include<set>
#include<stdlib.h>
#include<bitset>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
int n,a,b;
vector<int>v;
bool check(long long x) {
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		if (b*x >= v[i])
			continue;
		// x == y + z
		// v[i] <= a*y + b*z
		// v[i] <= a*y +(b*(x-y))
		// v[i] <= a*y + b*x -b*y
		// v[i] -b*x <= y*(a-b)
		// y = (v[i] - b*x)/(a-b)
		sum += max((ll)0, (ll)ceil((double)(v[i] - b*x) / (a - b)));
	}
	return sum <= x;
}
int main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif // !ONLINE_JUDGE
	int x;
	scanf("%d%d%d", &n, &a, &b);
	long long d = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x);
		v.push_back(x);
		d += x / a + (x%a?1:0);
	}
	long long low = 0, high = d, mid, ans = d;
	while (low <= high) {
		mid = (low + high) / 2;
		if (check(mid)) {
			ans = mid;
			high = mid - 1;
		}
		else
			low = mid + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ret = 0
for a_i in range(a+1):
    for b_i in range(b+1):
        for c_i in range(c+1):
            if x == 500 * a_i + 100 * b_i + 50 * c_i:
                ret += 1

print(ret)

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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    rep(i, n) if (s[i] != s[k - 1]) s[i] = '*';
    cout << s << endl;
}

int main(void)
{
    solve();
}


Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long K = scn.nextLong();
		long A[] = new long[N];
		long F[] = new long[N];
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextLong();
		}
		for(int i = 0;i < N;i++) {
			F[i] = scn.nextLong();
		}
		Arrays.sort(A);
		Arrays.sort(F);
		System.out.println(searchAns(A,F,K));
	}

	public static boolean solve(long[] A,long[] F, long K, long ans) {//必要な引数を入れる
		long cnt = 0;
		long[] ideal = new long[A.length];
		for(int i = 0;i < A.length;i++) {
			ideal[i] = ans / F[i];
		}
		for(int i = 0;i < A.length;i++) {
			cnt += Math.max(A[A.length-i-1] - ideal[i], 0);
		}
		return K>=cnt;
	}
	public static long searchAns(long[] A, long[] F, long K) {//必要な引数を入れる
		long l = -1, r = 10000000000000L;
		while(r-l > 1) {
			long mid = (r+l)/2;
			if(solve(A,F,K,mid)) {//必要な引数を入れる
				r = mid;
			}else {
				l = mid;
			}
		}
		return r;
	}

}



Measured memory_bytes: 154620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
int n,L,a[10],b[10];
bool vis[10];
ll f[305][35],cnt,sum;
void dfs(int k){
	if(k==n){
		cnt++;
		memset(f,0,sizeof(f));
		f[n*a[n]][0]=1;
		for(int i=0;i<n*L;i++){
			for(int p=i;p<=n*L;p++){
				for(int j=0;j<1<<n-1;j++){
					if(i%n&&!(j>>(i%n-1)&1)){
						f[min(n*L,max(p,i+n*a[i%n]))][j|(1<<(i%n-1))]+=f[p][j];
					}
				}
			}
		}
		sum+=f[n*L][(1<<n-1)-1];
		return;
	}
	for(int i=1;i<n;i++) if(!vis[i]){
		vis[i]=1;
		a[k]=b[i];
		dfs(k+1);
		vis[i]=0;
	}
}
int main(){
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	sort(b+1,b+n+1);
	a[n]=b[n];
	dfs(1);
	for(int i=1;i<n;i++) cnt*=L;
	printf("%.13lf\n",double(sum)/cnt);
	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    for (int i = S.size() - 2; i; i -= 2)
    {
        if (S.compare(0, i / 2, S, i / 2, i / 2) == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long, long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(ll i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

void Main()
{
	ll N, K;
	cin >> N >> K;
	vecll p(N), S(N + 1, 0);
	rep(i, N) { cin >> p[i]; S[i + 1] = S[i] + p[i]; }

	//sort(all(p));
	//reverse(all(p));

	ll max;
	for (int i = 0; i < N - K + 1; i++)
	{
		debug_cout(i);
		debug_tabcout(1, i + K);
		debug_tabcout(1, S[i + K] - S[i]);
		chmax(max, S[i + K] - S[i] + K);
	}

	cout << ((ld)max / 2.0);
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    string N;
    cin >> N;
    string out = "No";
    if(N[0]=='7'||N[1]=='7'||N[2]=='7') out = "Yes";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
A = A[::-1]

if N % 2:
  a = sum(A[:(N - 1) // 2])
  b = sum(A[(N - 1) // 2:(N - 1) // 2 + 2])
  c = sum(A[(N - 1) // 2 + 2:])
  answer = a * 2 + b * (-1) + c * (-2)
  a = sum(A[:(N - 3) // 2])
  b = sum(A[(N - 3) // 2:(N - 3) // 2 + 2])
  c = sum(A[(N - 3) // 2 + 2:])
  answer = max(answer, a * 2 + b + c * (-2))
else:
  a = sum(A[:(N - 2) // 2])
  b = A[(N - 2) // 2:(N - 2) // 2 + 2]
  c = sum(A[(N - 2) // 2 + 2:])
  answer = a * 2 + b[0] - b[1] + c * (-2)
print(answer)  

Measured memory_bytes: 54104
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define lint long long int
#define N_MAX 100000



int main()
{
    lint x;
    cin >> x;
    
    for (lint a = 0; a < 200; a++) {
        for (lint b = 0; b <= a; b++) {
            lint a5 = a*a*a*a*a;
            lint b5 = b*b*b*b*b;
            
            if (a5-b5 == x) {
                cout << a << ' ' << b << endl;
                return 0;
            }
            if (b5+a5 == x) {
                cout << b << ' ' << -a << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	vint p(n),q(n);
	rep(i, n){
		cin>>p[i];
	}
	vint ar(n);
	rep(i, n){
		cin>>q[i];
		ar[i] = i+1;
	}
	int count = 0,aa,bb;
	do{	
		int flag = 1;
		rep(i, n){
			if(ar[i] != p[i])flag = 0;
		}
		if(flag)aa = count;
		flag = 1;
		rep(i, n){
			if(ar[i] != q[i])flag = 0;
		}
		if(flag)bb = count; 
		count++;
	}while(next_permutation(all(ar)));
	cout << (int)abs(bb-aa)<<endl;
	return 0;
}


Measured memory_bytes: 256
def num2alpha(num):
    if num <= 26:
        return chr(96+num)
    elif num % 26 == 0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num % 26)


def main():
    N = int(input())
    print(num2alpha(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include<stdio.h>
int main(){
  int i,a,b,d[4],p[]={0,6,4,3,2};
  for(i=0;i<4;i++){
    scanf("%d %d",&a,&b);
    printf("%d\n",p[a]*b*1000);
  }
  return 0;
}
    

Measured memory_bytes: 600
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define REP(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define rep(i,a,b) for (int i = a;i < b;i ++)

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


vector<int> g[100010];

int dis[100010];
int vis[100010] = {0};
int f[100010];
struct Node {
    int n,w,f;
    int operator<(const Node &o) const {
        return w > o.w;
    }
};

void dij(int s) {
    mem(dis,-1);
    mem(f,-1);
    
    priority_queue<Node> q;
    q.push({s,dis[s] = 0,-1});
    
    Node current;
    int k;
    while (!q.empty()) {
        current = q.top();
        q.pop();
        f[current.n] = current.f;
        if (vis[current.n]) continue;
        vis[current.n] = 1;
        
        for (auto to : g[current.n]) {
            k = dis[current.n] + 1;
            if (dis[to] == -1 || dis[to] > k) {
                q.push({to,dis[to] = k,current.n});
            }
        }
    }
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int u,v;
    rep(i,0,m) {
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        g[v].pb(u);
    }
    dij(1);
    int ok = 1;
    REP(i,1,n) {
        if (dis[i] == -1) {
            ok = 0;
            break;
        }
    }
    if (ok) {
        printf("Yes\n");
        REP(i,2,n) {
            printf("%d\n",f[i]);
        }
    } else printf("No\n");
    return 0;
}


Measured memory_bytes: 12172
n = int(input())
if n == 1:
    print(1)
elif n < 4:
    print(2)
elif n < 8:
    print(4)
elif n < 16:
    print(8)
elif n < 32:
    print(16)
elif n < 64:
    print(32)
else:
    print(64)

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

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

	int N,M;

	cin>>N>>M;

	if(N==M)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define mp make_pair
#define endl "\n"
using namespace std;
int vis[200007]={0};
vvi vec;
int c=0;
void dfs(int a);
void solve1();
void solve()
{
    int T;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n,m;cin>>n>>m;
    vec.resize(n+1);
    int a,b;int ans=0;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        vec[a].pb(b);vec[b].pb(a);
    }
    for(int i=1;i<=n;i++)
    {
        int d=c;
        if(vis[i]==0)
        {
            //cout<<i<<endl;
            dfs(i);

            ans=max(ans,c-d);
        }
    }
    cout<<ans<<endl;
}
void dfs(int a)
{
    if(vis[a]==1)return;
    c++;vis[a]=1;
    for(int i=0;i<vec[a].size();i++)
    {
        dfs(vec[a][i]);
    }
}




Measured memory_bytes: 21928
// https://atcoder.jp/contests/arc083/tasks/arc083_b

package main

import "fmt"
import "bufio"
import "os"
import "strconv"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	var A = make([][]int, N)

	sum := 0
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)

		for j := 0; j < N; j++ {
			a := nextInt()
			A[i][j] = a
			sum += a
		}
	}

	dupes := 0
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			if i == k || A[i][k] == 0 {
				continue
			}
			for j := i + 1; j < N; j++ {
				if k == j || A[k][j] == 0 {
					continue
				}
				if A[i][j] > A[i][k]+A[k][j] {
					fmt.Println(-1)
					return
				} else if A[i][j] == A[i][k]+A[k][j] {
					dupes += A[i][j]
					A[i][j] = 0
					A[j][i] = 0
				}
			}
		}
	}

	fmt.Println((sum/2 - dupes))
}

var _sw = bufio.NewScanner(os.Stdin)

func init() {
	_sw.Split(bufio.ScanWords)
}

func nextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 2816
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.endaa(),0),pop_back()
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    string s;
    cin>>s;
    if(s == "ARC")
        cout<<"ABC";
    else
        cout<<"ARC";

    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int n;
	cin>>n;
	int fac[n+1];
	fac[0]=fac[1]=1;
	for(int i=2;i<=n;i++){
		fac[i] = i*fac[i-1];
	}
	int a[n];
	int b[n];
	forr(i,n) cin>>a[i];
	forr(i,n) cin>>b[i]; 
	int aa = 0;
	int bb = 0;
	int c[n];
	for(int i=0;i<n;i++) c[i] = i+1;

		do{ aa++;
			bool ok = true;
			for(int i=0;i<n;i++){
				if(a[i]!=c[i]){
					ok=false;
				}
			}
			if(ok) break;
 
		}while(next_permutation(c,c+n));

		for(int i=0;i<n;i++) c[i] = i+1;

		do{
			bb++;
			bool ok = true;
			for(int i=0;i<n;i++){
				if(b[i]!=c[i]){
					ok=false;	
				}
			}
			if(ok) break;

		}while(next_permutation(c,c+n));
		cout<<abs(aa-bb);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
 
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

template<typename T>
vector<pair<T, int>> prime_factorization(T n) {
    vector<pair<T, int> > res;
    for (T i = 2; i*i <= n; i++) {
        int cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) res.push_back(make_pair(i,cnt));
    }
    if (n > 1) res.push_back(make_pair(n,1));
    return res;
}
 
int main(){
    ll a,b,x=0,y=0,d=0,n,h,w,k,max=-100,ans=0,ptr=0,sum=0;
    string s;
    cin >> a >> b;
    a = gcd(a,b);
    cout << prime_factorization(a).size()+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[105][100005];
signed main(){
    int N,K;
    cin >> N >> K;
    vector<int>a(N);
    dp[0][0] = 1;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        int res = 0;
        for(int j = 0; j <= K; j++) {
            res += dp[i][j];
            if(j > a[i]) {
                res -= dp[i][j-a[i]-1];
            }
            res += mod;
            res %= mod;
            dp[i+1][j] = res;
        }
    }
    cout << dp[N][K] << endl;
}


Measured memory_bytes: 81768
#include<bits/stdc++.h>
using namespace std;
int a[100000],n,m;
int main()
{
   
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=n;i>=n-m+1;i--)
    sum+=a[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,l,a[100001];
void out(int po)
{
cout<<"Possible\n";
for(int i=1;i<po;++i)cout<<i<<"\n";
for(int i=n-1;i>po;--i)cout<<i<<"\n";
cout<<po;
exit(0);
}
int main()
{
cin>>n>>l;
for(int i=1;i<=n;++i)
{
cin>>a[i];
if(i==1)continue;
if(a[i]+a[i-1]>=l)out(i-1);
}
cout<<"Impossible";
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<pii> P(N);
    cin >> P;
    sort(all(P));
    auto dist = [&](int i, int j) {
        return sqrt((P[i].first - P[j].first) * (P[i].first - P[j].first) + (P[i].second - P[j].second) * (P[i].second - P[j].second));
    };

    double ans = 0;
    int cnt = 0;
    do {
        rep(i, 0, N - 1) {
            ans += dist(i, i + 1);
        }
        cnt++;
    } while (next_permutation(all(P)));
    cout << ans / cnt << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
let n = read_int ()
let s = read_line ()
let ans = ref 0
let _ = for i = 0 to n - 1 do let c = ref 0 in
  for j = Char.code 'a' to Char.code 'z' do if String.(contains (sub s 0 i) @@ Char.chr j && contains (sub s i @@ n - i) @@ Char.chr j) then incr c done;
  ans := max !ans !c done; Printf.printf "%d\n" !ans

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

int main() {

    int n;

    cin >> n;

    char last_c;

    string input;

    set<string> s;

    cin >> input;

    s.insert(input);

    string ans = "Yes";

    last_c = *(input.end() - 1);

    for(int i=1; i<n; i++){
        cin >> input;
        if(last_c != *(input.begin())){
            ans = "No";
            break;
        }
        last_c = *(input.end() - 1);
        s.insert(input);
        if(s.size() != i+1){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int N,W;
  cin>>N>>W;
  vector<int> v(N),w(N);
  rep(i,N)cin>>v[i]>>w[i];

  vector<vector<int>> dp(N+10,vector<int>(10004,INF));

  dp[0][0]=0;

  rep(i,N+1){
    rep(j,10004){
      if(j-v[i]>=0)
        dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  int ans=-1;
  rep(j,10004){
    if(dp[N][j]<=W){
      ans=max(ans,j);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 11600
#include <iostream>
#include <string>

using namespace std;

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

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

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

int main()
{
    int N;
    cin >> N;
    vector<int> a;
    vector<vector<int>> x,y;
    x.resize(N);
    y.resize(N);
    a.resize(N);
    rep(i,N){
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        rep(j,a[i]){
            cin >> x[i][j] >> y[i][j];
        }
    }
    vector<int> bin;
    bin.resize(N);
    int k;

    
    int count=0;
    int max_count=0;
    bool flag=true;
    rep(i,pow(2,N)){
        k=0;
        rep(j,N)bin[j]=0;
        int i_val=i;
        while(i_val>=1){
            bin[k]=i_val%2;
            i_val/=2;++k;
        }
        rep(j,N){
            if(bin[j]==1){
                rep(l,a[j]){
                    if(bin[x[j][l]-1]!=y[j][l]){
                        flag=false;
                        break;
                    }
                }
                if(flag==true){
                    count++;
                }else{
                    break;
                }
            }
            
        }
        if(flag==true&&max_count<count){
            max_count=count;
        }
        flag=true;count=0;
    }
    cout << max_count << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

from collections import Counter

odd = Counter(A[::2])
even = Counter(A[1::2])

odd = sorted(((c,v) for v,c in odd.items()), reverse=True)
even = sorted(((c,v) for v,c in even.items()), reverse=True)

odd.append((0,None))
even.append((0,None))

if odd[0][1] == even[0][1]:
  if odd[0][0] - odd[1][0] < even[0][0] - even[1][0]:
    print(n - odd[1][0] - even[0][0])
  else:
    print(n - even[1][0] - odd[0][0])
else:
  print(n - odd[0][0] - even[0][0])

Measured memory_bytes: 18528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    vector<int> a(n),c(n-1);
    For(i,n) {
        cin>>a.at(i);
        a.at(i)--;
    }
    For(i,n){
        int k;cin>>k;
        ans+=k;
    }
    For(i,n-1) cin>>c.at(i);
    for(int i=1;i<n;i++){
        if(a.at(i-1)+1==a.at(i)){
            ans+=c.at(a.at(i-1));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main(n, k, x, y):
    if n <= k:
        result = n * x
    else:
        result = k * x
        result += (n - k) * y
    return result


if __name__ == '__main__':
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    print(main(N, K, X, Y))


Measured memory_bytes: 3060
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
from sys import stdin
N,M=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
min_=0
max_=10**5

for j in data:
    if j[0] > min_:
        min_ = j[0]
    if j[1] < max_:
        max_ = j[1]
ans = max_ - min_
if ans < 0:
  print(0)
else:
  print(ans+1)

Measured memory_bytes: 21156
#include <stdio.h>
#include <strings.h>

int
main(int argc, char *argv[])
{
    int N, K, Q;
    int A[100000], a;
    int i, j;

    bzero(A, sizeof(A));

    scanf("%d%d%d", &N, &K, &Q);
    for (i=0; i<Q; i++) {
        scanf("%d", &a);
        A[a-1]++;
    }
    for (i=0; i<N; i++) {
        if (K-Q+A[i]>0) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 896