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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char alp;
    cin >> alp;
    if (alp == 'a' || alp == 'b' || alp == 'c' || alp == 'd' || alp == 'e' || alp == 'f' || alp == 'g' || alp == 'h' || alp == 'i' || alp == 'j' || alp == 'k' || alp == 'l' || alp == 'm' || alp == 'n' || alp == 'o' || alp == 'o' || alp == 'p' || alp == 'q' || alp == 'r' || alp == 's' || alp == 't' || alp == 'u' || alp == 'v' || alp == 'w' || alp == 'x' || alp == 'y' || alp == 'z') {
        cout << 'a' << '\n';
    } else {
        cout << 'A' << '\n';
    }
    return 0;
}

Measured memory_bytes: 3632
a=input()
n=len(a)
b=[]
for i in range(n):
    if i%2==0:
        b.append('0')
    else:
        b.append('1')
res=0
for i in range(n):
    if a[i]!=b[i]:
        res+=1
if res<n/2:
    print(res)
else:
    print(n-res)

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int n,m; cin>>n>>m;
    vector<int> c(m);
    REP(i,m){
        cin >> c[i];
    }

    vector<vector<int> > dp(m+1,vector<int>(n+1,INF));
    dp[0][0] = 0;
    REP(i,m){
        dp[i+1][0] = 0;
        FOR(j,1,n+1){
            if(j < c[i]) dp[i+1][j] = dp[i][j];
            else{
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-c[i]] + 1);
            }
        }
    }

    cout<< dp[m][n] << endl;
}


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    string a, b;
    if (S.size() % 2 == 0) //偶数
    {
        a = S.substr(0, (S.size() / 2));
        b = S.substr((S.size() / 2), S.size() / 2);
        reverse(b.begin(), b.end());
        for (int i = 0; i < (S.size() / 2); ++i)
        {
            if (a[i] != b[i])
            {
                ++ans;
            }
        }
    }
    else
    {
        string a, b;
        a = S.substr(0, (S.size() / 2));
        b = S.substr((S.size() / 2) + 1, (S.size() / 2) + 1);
        reverse(b.begin(), b.end());
        for (int i = 0; i < (S.size() / 2); ++i)
        {
            if (a[i] != b[i])
            {
                ++ans;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

typedef struct{
	int x;
	int y;
}point;

int main(){
	int n;
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		char f[9][9];
		int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

		for(int j=1; j<=8; ++j)
		for(int k=1; k<=8; ++k)
		scanf(" %c", &f[j][k]);
		
		point s;
		scanf(" %d %d", &s.x, &s.y);
		
		//bfs
		f[s.y][s.x]='0'; //既に爆発した
		queue<point> que;
		que.push(s);
		while( !que.empty() ){
			point v=que.front();
			que.pop();
			
			for(int j=0; j<4; ++j){
				for(int k=1; k<=3; ++k){
					int nx=v.x+dx[j]*k, ny=v.y+dy[j]*k;
					
					if(nx>0 && nx<=8 && ny>0 && ny<=8 && f[ny][nx]=='1'){
						f[ny][nx]='0';			
						point tmp;
						tmp.x=nx; tmp.y=ny;
						que.push(tmp);
						//printf("push\n");
					}
				}	
			}
	
		}
		
		//出力
		printf("Data %d:\n", i+1);
		for(int j=1; j<=8; ++j){
			for(int k=1; k<=8; ++k) printf("%c", f[j][k]);
			printf("\n");
		}
		
	}
}

Measured memory_bytes: 1200
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      c: usize,
      ds: [[usize; c]; c],
      cs: [[usize; n]; n],
    }
    let mut cost = vec![vec![0; c+1]; 3];
    for i in 0..n {
        for j in 0..n {
            for c1 in 1..c+1 {
                if cs[i][j] != c1 {
                    cost[(i + j + 2) % 3][c1] += ds[cs[i][j]-1][c1-1];
                }
            }
        }
    }

    let mut ans = 1 << 30;
    for c1 in 1..c+1 {
        for c2 in 1..c+1 {
            for c3 in 1..c+1 {
                if c1 == c2 || c2 == c3 || c3 == c1 {
                    continue;
                }
                let cost1 = cost[0][c1] + cost[1][c2] + cost[2][c3];
                ans = min(cost1, ans);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<bool> eratosthenes(int n) {
  vector<bool> prime(n + 1, true);
  if (n >= 0) prime[0] = false;
  if (n >= 1) prime[1] = false;
  for (int i = 2; i * i <= n; i++) {
    if (!prime[i]) continue;
    for (int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  auto prime = eratosthenes(1000000);
  for (int i = x; i < 1000000; i++) {
    if (prime[i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;

// 最大公約数のll版
ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	return b == 0 ? a : gcd(b, a%b);
}


int main() {
	ll A, B;
	cin >> A >> B;
	ll cnt = 0;

	ll n = gcd(A, B);

	for (ll i = 2; i * i <= n; i++) {
		if (n%i == 0) {
			cnt++;
		}
		while (n % i == 0) {
			n /= i;
		}
	}
	if (n != 1) cnt++;



	cout << cnt+1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

map<ll,ll>a;
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
	}
	ll ans=0;
	for(auto itr =a.begin();itr!=a.end();itr++){
		ll val=itr->second;
		if(val%2!=0){
			ans++;
		}
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 6528
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()


n -= k
k -= 1
print(n // k + (int(bool(n % k))) + 1)


Measured memory_bytes: 3316
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char in[110];
char name[10]="keyence";
int main(){
	scanf("%s",in);
	int n=strlen(in);
	bool ret=false;
	for(int i=0;i<=7;i++){
		bool ok=true;
		for(int j=0;j<i;j++){
			if(name[j]!=in[j])ok=false;
		}
		for(int j=0;j<7-i;j++){
			if(name[6-j]!=in[n-1-j])ok=false;
		}
		if(ok)ret=true;
	}
	if(ret)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
def mul (a, b)
  s = a.size
  c = s.times.map{ [0] * s }
  s.times do |i|
    s.times do |j|
      s.times do |k|
        if a[i][k] >= 1 && b[k][j] >= 1
          c[i][j] = 1
          break
        end
      end
    end
  end
  c
end

def pow (a, n)
  s = a.size
  b = s.times.map{ [0] * s }
  s.times.each{ |i| b[i][i] = 1 }
  while n > 0
    b = mul(b, a) if n & 1 == 1
    a = mul(a, a)
    n >>= 1
  end
  b
end

loop do
  n, m, z = gets.split.map(&:to_i)
  break if n == 0
  x = Array.new(2 * m)
  y = Array.new(2 * m)
  m.times.each do |i|
    x[i], y[i] = gets.split.map(&:to_i)
    x[m+i] = y[i]; y[m+i] = x[i]
  end
  mat = Array.new(2 * m){ Array.new(2 * m, 0) }
  (2 * m).times do |i|
    (2 * m).times do |j|
      if y[i] == x[j] && y[j] != x[i]
        mat[i][j] = 1
      end
    end
  end
  mat = pow(mat, z - 1)

  ret = 0
  (2 * m).times do |i|
    if x[i] == 1 && ret == 0
      (2 * m).times do |j|
        if y[j] == n && mat[i][j] >= 1
          ret = 1
          break
        end
      end
    end
  end
  puts ret == 1 ? 'yes' : 'no'
end

Measured memory_bytes: 15148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<cmath>
#include<ctime>
#include<string>
using namespace std;
string str;
int main()
{
	cin>>str;
	cout<<str[0]<<str.size()-2<<str[str.size()-1];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	string a, b;
	cin >> a >> b;
	string S = a + b;
	N = stoi(S);
	if (N == int(sqrt(N))*int(sqrt(N)))cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
import java.io.*;
    
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
    
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++){
if((i&(1<<0))!=0&&(i&pic[0])!=0) dp[0][i]=1;
}
for(int i=1;i<n;i++)
for(int j=1;j<(1<<3);j++)
for(int k=1;k<(1<<3);k++)
if((k&pic[i])!=0){
if((j&pic[i])!=0) dp[i][k]+=dp[i-1][j];
else if((j&k)!=0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
  
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
}

Measured memory_bytes: 18604
#include <iostream>

using namespace std;

int N, K, a[105];

int dp[100005];

int main(void) {

	cin >> N >> K;

	for (int i = 1; i <= N; i++) { cin >> a[i]; }

	dp[0] = 0;

	for (int i = 1; i <= K; i++) {
		int num_W = 0;
		int num_L = 0;
		for (int j = 1; j <= N; j++) {
			if ((i - a[j] >= 0) && (dp[i - a[j]] == 1)) { num_W++; }
			else if ((i - a[j] >= 0) && (dp[i - a[j]] == 0)) { num_L++; }
		}
		//cout << i << "  " << num_W << " " << num_L << endl;
		if (num_L > 0) { dp[i] = 1; }
	}

	/*for (int i = 0; i <= K; i++) {
		cout << "dp[" << i << "]= " << dp[i] << endl;
	}*/

	if (dp[K] == 1) { cout << "First" << endl; }
	else { cout << "Second" << endl; }

	//system("pause");
	return 0;
}

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

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

  int ans = 0;
  vector<int> foods(m+1);

  for(int i = 0; i <= m; i++) foods[i] = 0;

  for(int i = 0; i < n; i++){
    int k;
    cin >> k;

    for(int j = 0; j < k; j++){
      int a;
      cin >> a;

      foods[a]++;

      if(foods[a] == n) ans++;
    }
  }

  cout << ans << endl;

  return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 200002
using namespace std;
int tot,head[N];
struct E
{
	int to;
	int Next;
}edge[N<<1];
int a[N];
int n;
inline void add(int u,int v)
{
	tot++;
	edge[tot].to=v;
	edge[tot].Next=head[u];
	head[u]=tot;
}
int ans[N];
int f[N];
bool check(int mid,int x)
{
	return a[x]<=f[mid];
}
void dfs(int x,int father)
{
	int temp;
	int l=1,r=ans[father];
	if(father==0)
	{
		f[1]=a[x];
		ans[1]=1;
	}
	else
	{
		while(l<=r)
		{
			int mid=l+r>>1;
			if(check(mid,x)) r=mid-1;
			else l=mid+1;
		}
		temp=f[l];
		f[l]=a[x];
		ans[x]=ans[father];
		if(l>ans[father]) ans[x]++;
	}
	int i;
	for(i=head[x];~i;i=edge[i].Next)
	{
		int y=edge[i].to;
		if(y==father) continue;
		else dfs(y,x);
	}
	f[l]=temp;
}
int main()
{
	cin>>n;
	int i;
	for(i=1;i<=n;i++) scanf("%d",a+i);
	memset(head,-1,sizeof(head));
	for(i=1;i<=n-1;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	dfs(1,0);
	for(i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
long solve(string& k,int D,vector<vector<vector<long>>>& dp,int pos,int d,bool tight){
    if(dp[pos][d][tight]!=-1){
        return dp[pos][d][tight];
    }
     int ub;
    if(tight==1){
        ub=(k[pos]-'0');
    }
    else{
        ub = 9;
    }
    if(pos==(k.length())){
       if(d==0){
           return 1;
       }
       else{
           return 0;
       }
    }
    long long int ans =0 ;
    for(int i=0;i<=ub;i++){
     ans = (ans%mod + solve(k,D,dp,pos+1,(D + d -i%D)%D,(tight&&(i==ub)))%mod)%mod;
    }
    return dp[pos][d][tight] = ans;
    }
int main() {
	string k;
	cin>>k;
	int D;
	cin>>D;
	vector<vector<vector<long>>> dp(100001,vector<vector<long>>(101,vector<long>(2,-1)));
	cout<<(mod+solve(k,D,dp,0,0,1)-1)%mod<<'\n';
	return 0;
}

Measured memory_bytes: 556800
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const double PI = acos(0)*2;

int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;

  int HM = 60 * H + M;

  double h_y = A * sin(2.0*PI/720.0*HM);
  double h_x = A * cos(2.0*PI/720.0*HM);
  double m_y = B * sin(2.0*PI/60.0*M);
  double m_x = B * cos(2.0*PI/60.0*M);

  double ret = sqrt((h_y-m_y)*(h_y-m_y) + (h_x-m_x)*(h_x-m_x));

  printf("%.12lf\n", ret);
  return 0;
}


Measured memory_bytes: 4068
#include <iostream>
#include <cstdio>

int main(int argc, const char * argv[])
{
    int w, n;
    std::cin >> w >> n;
    int a[w];
    for (int i = 0; i < w; i++) {
        a[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        int aa, bb, tmp;
        scanf("%d,%d", &aa, &bb);
        tmp = a[aa - 1];
        a[aa - 1] = a[bb - 1];
        a[bb - 1] = tmp;
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", a[i]);
    }
    
    return 0;
}

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

def main():
    N,M = map(int,input().split())
    g_grid = [["#" for _ in range(100)] for _ in range(50)]
    h_grid = [["." for _ in range(100)] for _ in range(50)]
    
    grid = g_grid + h_grid
    
    N -= 1
    M -= 1
    for i in range(N):
        p = 2*i+1
        x = (p//100)*2
        y = p%100
        grid[x][y] = "."
        
    for i in range(M):
        p = 2*i+1
        x = -(p//100)*2-1
        y = -(p%100)
        grid[x][y] = "#"
    
    print(100,100)
    
    for i in range(100):
        L = "".join(grid[i])
        print(L)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y


N=II()
res = 0
D = 10
while N // D:
    res += N//D
    D *= 5

if N%2:
    print(0)
else:
    print(res)


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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    int s = 0;
    for(int i=0; i<n; ++i) cin >> d[i];

    for(int i=0; i<n; ++i) {
        for(int j=i; j<n; ++j){
            if(i != j) s += d[i] * d[j];
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int DP[101001];

int item[6] = {100, 101, 102,103,104,105};

int main() {
	int X;cin>>X;
	DP[0] = 1;
	for (int i = 0; i < 6; i++)
	{
		for (int j = 0; j <=X ; j++)
		{
			if(DP[j] == 0)continue;

			DP[j+item[i]] = true;
		}
	}

	if(DP[X])cout<<1<<endl;
	else cout<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Numeric

lpnorm p x = ((sum.map (\ a -> abs(a) ** p)) x) ** (1/p)
maxnorm x = foldr max 0 (map abs x)

main = do
    _ <- getLine
    x <- (map read.words) <$> getLine ::IO[Double]
    y <- (map read.words) <$> getLine ::IO[Double]
    let z = zipWith(-) x y
    putStrLn $ show ( lpnorm 1 z)
    putStrLn $ show ( lpnorm 2 z)
    putStrLn $ show ( lpnorm 3 z)
    putStrLn $ show ( maxnorm z )

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MAX=2001000;
int main(){
  ll N;
  cin>>N;
  vector<int>A(N);
  for(ll i=0;i<N;i++)cin>>A[i];
  vector<int>M(MAX,0);
  for(auto a:A){
    if(M[a]!=0){
      M[a]=2;continue;
    }
    for(ll i=a;i<=MAX;i+=a)M[i]++;
  }
  ll ans=0;
  for(auto a:A){
    if(M[a]==1)ans++;
  }
  cout<<ans<<endl;
}


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

    int A, B, C, D;
	cin >> A >> B >> C >> D;


	   while(1) {
		   C -= B;
		   if (C <= 0) {
			   cout << "Yes" << endl;
			   return 0;
		   }

		   A -= D;
		   if (A <= 0) {
			   cout << "No" << endl;
			   return 0;
		   }
	   }

return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()
{
  long long a, b, x, i;

  cin >> a >> b >> x;

  if(a > 0){
		cout << b / x - (a - 1) / x << endl;
	}
	if(a == 0){
		cout << b / x + 1 << endl;
	}
}

// better answer


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(int x) {
    string s = to_string(x);
    int res = 0;
    for (auto k: s) res += k-'0';
    return res;
}
int main () {
    int x;
    cin >> x;
    if (x % f(x) == 0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
n=gets.to_i
arr=gets.split.map(&:to_i)
num=0
0.upto(n-1) do |i|
  minj=i
  i.upto(n-1) do |j|
    if arr[j] < arr[minj]
      minj=j
    end
  end
  arr[i],arr[minj]=arr[minj],arr[i]
  if(i!=minj)
    num+=1
  end
end
puts arr.join(' ')
puts num

Measured memory_bytes: 8688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		boolean t = true;
		Scanner insert = new Scanner(System.in);
		String line = insert.nextLine();
		String array1[] = line.split(" ");
		int w = Integer.parseInt(array1[0]);
		int h = Integer.parseInt(array1[1]);
		int x = Integer.parseInt(array1[2]);
		int y = Integer.parseInt(array1[3]);
		int r = Integer.parseInt(array1[4]);
		insert.close();
		if((x+r) > w){
			t = false;
		}
		if((x - r) < 0) {
			t = false;
		}
		if((y+r) > h){
			t = false;
		}
		if((y - r) < 0) {
			t = false;
		}
		if(t) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26336
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

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

    vector<int> works[100001];

    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        works[A].push_back(B);
    }

    priority_queue<int> que;
    long long score = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 0; j < works[i].size(); j++) {
            que.push(works[i][j]);
        }
        if (!que.empty()) {
            score += que.top();
            que.pop();
        }
    }

    cout << score << endl;

    return 0;
}


Measured memory_bytes: 5632
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main() {
	
	ll a, b;
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", lcm(a, b));
	
	
	Please AC;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  for (int i = 0; i < (int)S.size(); i++) {
    int ne = (S[i] - 'A' + N) % 26;
    S[i] = ne + 'A';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>

using namespace std;

int main() {	
	char p[101], s[101];
	int plen, slen, n,j,i;
	scanf("%s", p);
	scanf("%s", s);
	plen = strlen(p);
	slen = strlen(s);
	for (i = 0; i < plen; i++) {
		if (p[i] == s[0]) {
			n = i;
			for (j = 1; j < slen; j++) {
				n++;
				if (n==plen) n = 0;
				if (p[n] != s[j]) break;
				
			}
		}
		if (j == slen) {
			printf("Yes\n");
			break;
		}
	}
	if (i == plen) printf("No\n");
	return 0;
}

Measured memory_bytes: 1112
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
abs_dict = dict()
abs_list = list()

for i in range(N):
	temp_abs = abs(A-(T-H[i]*0.006)) 
	abs_dict[temp_abs] = i
	abs_list.append(temp_abs)
print(abs_dict[min(abs_list)]+1)

Measured memory_bytes: 3188
n = int(input())
s1 = list(input())
s2 = list(input())
inf = 10**9+7

l = []
flag = False
for i in range(n):
    if s1[i] == s2[i]:
        l.append(1)
    else:
        if flag:
            l.append(2)
            flag = False
        else:
            flag = True

#print(l)

if l[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(1,len(l)):
    if l[i-1] == 1 and l[i] == 1:
        ans *= 2
    elif l[i-1] == 1 and l[i] == 2:
        ans *= 2
    elif l[i-1] == 2 and l[i] == 1:
        ans *= 1
    else:
        ans *= 3
    ans %= inf

print(ans)

Measured memory_bytes: 3064
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    A_cum_sum = [A[-1]]
    for a in A[::-1][1:]:
        A_cum_sum.append(a + A_cum_sum[-1])
    A_cum_sum = A_cum_sum[::-1]
    ans = 0
    for i in range(N-1):
        sum_mod = A_cum_sum[i+1] % mod
        mul_mod = (A[i] * sum_mod) % mod
        ans = (ans + mul_mod) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 111188
def f(a):
	s=0;q=a[:n];s=sum(q);heapify(q);r=[s]
	for e in a[n:2*n]:s+=e-heappushpop(q,e);r+=[s]
	return r
from heapq import*;r=reversed;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),r(f([-e for e in r(a)]))))))

Measured memory_bytes: 127704
#include<stdio.h>
int main()
{
    long long n,ans=0;
    int i;
    scanf("%lld",&n);
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1732
import itertools
N,M,Q = map(int, input().split())
L = [list(map(int, input().split())) for i in range(Q)]
tmp = [k+1 for k in range(M)]
ans = 0
for A in itertools.combinations_with_replacement(tmp,N):
    pre_ans = 0
    for i in range(Q):
        a,b,c,d = L[i]
        if A[b-1] - A[a-1] == c:
            pre_ans += d
        ans = max(ans,pre_ans)
print(ans)

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

using pp = pair<char, int>;

vector<pp> runLength(string S) {
    int c = 1;
    int s = S[0];
    vector<pp> ret;
    for (int i = 1; i < S.length(); i++) {
        if (s == S[i])
            c++;
        else {
            ret.push_back(make_pair(s, c));
            s = S[i];
            c = 1;
        }
        if (i + 1 == S.length()) {
            ret.push_back(make_pair(s, c));
            break;
        }
    }
    return ret;
}

vector<int> solve(string S) {
    vector<int> ret(S.length(), 0);
    vector<pp> rl = runLength(S);
    int index = 0;
    for (int i = 0; i < rl.size(); i++) {
        if (rl[i].first == 'R') {
            for (int j = rl[i].second; j > 0; j--) {
                if (j % 2 == 0)
                    ret[index + j]++;
                else
                    ret[index + j - 1]++;
                index++;
            }
        } else if (rl[i].first == 'L') {
            for (int j = 1; j <= rl[i].second; j++) {
                if (j % 2 == 0)
                    ret[index - j]++;
                else
                    ret[index - j + 1]++;
                index++;
            }
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    vector<int> ans = solve(S);
    for (int i = 0; i < ans.size() - 1; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[ans.size() - 1] << endl;
}

Measured memory_bytes: 1992
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int lli;

lli pow10(lli n){
  lli res = 1LL;
  if(n < 0)return 0;
  for (lli i = 0; i < n; i++) {
    res *= 10LL;
  }
  return res;
}

lli len(lli n){
  lli res = 0;
  while(n > 0){
    res += (lli)(log10l(n) + 1LL)*(n - pow10((lli)log10l(n)) + 1LL);
    lli tmp = pow10((lli)log10l(n)) - 1LL;
    //if(tmp == n)tmp /= 10;
    // std::cout << log10l(n) << std::endl;
    // std::cout << "tmp:" << tmp << std::endl;
    res += (4LL - (lli)(log10l(n) + 1LL))*
      (n/3LL + n/5LL - (tmp/3LL + tmp/5LL));
    res += (lli)(log10l(n) + 1LL)*(n/15LL - tmp/15LL);
    n = tmp;
  }
  //std::cout << "res:" << res << std::endl;
  return res;
}

lli pos(lli n){
  lli maxi = 2*1e18, mini = 0, med = (maxi + mini)/2LL;
  lli l;
  while(maxi - mini > 1){
    //l = len(med);
    l = len(n);
    //std::cout << "l:" << l << std::endl;
    //if(l > n){
    if(l < med){
      maxi = med;
    }else{
      mini = med;
    }
    med = (maxi + mini)/2;
  }
  //if(maxi > n)return mini;
  if(maxi > len(n))return mini;
  else return maxi;
}

int main(){
  lli n;
  std::cin >> n;
  lli maxi = 1.8*1e18, mini = 0, med = (maxi + mini)/2, p;
  while(maxi - mini > 1){
    if(pos(med) >= n){
      maxi = med;
    }else{
      mini = med;
    }
    med = (maxi + mini)/2;    
  }
  if(pos(maxi) >= n)p = mini;
  else p = maxi;
  //std::cout << "pos(3):" << pos(3)  << std::endl;
  // std::cout << "maxi:" << maxi << std::endl;
  // std::cout << "mini:" << mini << std::endl;

  lli diff = n - pos(p) - 1LL;
  // std::cout << n << std::endl;
  // std::cout << "pos(" << p << "):" << pos(p) << std::endl;
  // std::cout << "diff:" << diff << std::endl;
  // std::cout << (lli)1e18 << std::endl;
  // std::cout << diff + pos(p) + 1 << std::endl;
  string s;
  for (lli i = p + 1; s.length() < 20 + diff + 1; i++) {
    if(i%15 == 0)s += "FizzBuzz";
    else if(i%3 == 0)s += "Fizz";
    else if(i%5 == 0)s += "Buzz";
    else s += to_string(i);
  }
  // std::cout << s << std::endl;
  // std::cout << "   diff:" << diff << std::endl;
  // std::cout << "      p:" << p << std::endl;
  // std::cout << "pos(" << p << "):" << pos(p) << std::endl;
  std::cout << s.substr(diff, 20) << std::endl;
  //slow(n);
  //std::cout << len(310) << std::endl;
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
int main(){
	int n,m;
	cin>>n>>m;
	int tmp=0;
	if(n>1)tmp+=(n-1)*n/2;
	if(m>1)tmp+=(m-1)*m/2;
	cout<<tmp;
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int X = input[2];
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans0 = 0;
            int ansN = 0;
            for(var i = 0; i < M; i++)
            {
                if (a[i] < X)
                {
                    ans0++;
                }
                else
                {
                    ansN++;
                }
            }
            Console.WriteLine(Math.Min(ans0, ansN));
            

            //Console.Out.Flush();

        }
    }

    

    public class Calculation
    {

    }

    public class Graph
    {
       
    }
}




Measured memory_bytes: 13268
#include<stdio.h>
#include<stdlib.h>

int dice1[6],dice2[6];
int i,t,clear=0;

int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;

void Move2();
void eMove();
void nMove();
void sMove();
void wMove();

int main(){
	for(i=0;i<6;i++)scanf("%d",&dice1[i]);
	for(i=0;i<6;i++)scanf("%d",&dice2[i]);
	
	Move2();
	
	if(clear==1)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

void Move2(){
	for(i=0;i<5000;i++){
		int rnd=rand()%4;
		
		if(rnd==0)eMove();
		else if(rnd==1)nMove();
		else if(rnd==2)sMove();
		else wMove();
		
		if((dice1[0]==dice2[ue-1])&&(dice1[1]==dice2[mae-1])&&
			(dice1[2]==dice2[mig-1])&&(dice1[3]==dice2[hid-1])&&
			(dice1[4]==dice2[usi-1])&&(dice1[5]==dice2[sit-1])){
			clear=1;
			break;
		}
	}
	return;
}

void eMove(){
	t=ue;
	ue=hid;
	hid=sit;
	sit=mig;
	mig=t;
	return;
}

void nMove(){
	t=ue;
	ue=mae;
	mae=sit;
	sit=usi;
	usi=t;
	return;
}

void sMove(){
	t=ue;
	ue=usi;
	usi=sit;
	sit=mae;
	mae=t;
	return;
}

void wMove(){
	t=ue;
	ue=mig;
	mig=sit;
	sit=hid;
	hid=t;
	return;
}


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

int main(){
    int n;
    cin >> n;
    
    string ans = "Yes";
    
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    
    
    for(int i = n - 1; i > 0; i--){
        if(h.at(i - 1) > h.at(i) + 1){
            ans = "No";
            break;
        }else if(h.at(i - 1) == h.at(i) + 1){
            h.at(i - 1)--;
        }
    }
    
    cout << ans << endl;
}

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

using namespace std;

#define endl '\n'
#define ll long long
#define mod 998244353

void solve(){
    int n;
    cin>>n;
    map<ll,int> mp;
    ll x;
    ll sum = 0;
    for(int i = 0;i<n;i++){
        cin>>x;
        mp[x]++;
        sum += x;
    }
    int q;
    ll a,b;
    cin>>q;
    while(q--){
        cin>>a>>b;
        int cnt = mp[a];
        sum -= (cnt * a);
        // cout<<"===="<<endl;
        // for(auto it:mp){
        //     cout<<it.first<<" "<<it.second<<endl;
        // }
        // cout<<"===="<<endl;
        mp.erase(mp.find(a));
        if(mp.find(b) != mp.end()){
            mp[b] += cnt;
        }else{
            mp.insert({b,cnt});
        }
        sum += (cnt*b);
        cout<<sum<<endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

// 2
// 1 2
// 3
// 1 100
// 2 100
// 100 1000

Measured memory_bytes: 7568
n = int(input())

s_list = []
ac = wa = tle = re = 0
for i in range(n):
    s_list.append(input())

for x in range(len(s_list)):
    if s_list[x] == "AC":
        ac += 1
    elif s_list[x] == "WA":
        wa += 1
    elif s_list[x] == "TLE":
        tle += 1
    elif s_list[x] == "RE":
        re += 1

print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")

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

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

int main()
{
	LL x, y;
	cin >> x >> y;
	cout << (x*y)/__gcd(x,y) << endl;

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main()
{
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> vppsi;
    rep(i, n)
    {
        string s;
        int p;
        cin >> s >> p;
        vppsi.push_back(make_pair(make_pair(s, 100 - p), i + 1));
    }
    sort(all(vppsi));
    for (auto ppsi : vppsi)
        cout << ppsi.second << endl;
}


Measured memory_bytes: 256
import queue

ok_list = set()

q = queue.Queue()
q.put(0)
while not q.empty():
    current = q.get()
    for i in [4, 7]:
        n = current + i
        if n > 100:
            continue
        elif n in ok_list:
            continue
        else:
            ok_list.add(n)
            q.put(n)

n = int(input())
if n in ok_list:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
typedef long long ll;

char c;
 
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	cin >> c;
	if (isupper(c)) cout << "A\n";
	else cout << "a\n";

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	for(int i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int digit(int n){
   int H=0;
  	while(n!=0){
		H+=n%10;
    	n=n/10;
 	 }
    return H;
  }
  int main(){
    int n;
    cin >> n;
  if(n%digit(n)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  string x, y, z;
  cin >> x >> y >> z;
  x[0] = toupper(x[0]);
  y[0] = toupper(y[0]);
  z[0] = toupper(z[0]);
  cout << x[0] << y[0] << z[0] << endl; 
}

Measured memory_bytes: 3616
/*
    Author - FireDrake99
*/
#include<bits/stdc++.h>
using namespace std;

//------------Constants-----------------
#define ll long long int
//------------Variables-----------------
int n,k;
string s;
//------------Functions-----------------

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
//------------Input---------------------
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    cin >> s;
    cin >> k;
//------------Work----------------------
    char c=s[k-1];
    for (int i=0; i<n; i++)
        if (s[i]!=c) s[i]='*';
    cout << s;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;


int main(){
    vector<ll>x;
    vector<ll>y;
    ll A,B,C,D,E,F;
    cin >>A>>B>>C>>D>>E>>F;
    for (int a = 0; a <=F; ++a) {
        for (int b = 0; b <=F; ++b) {
            ll tmp=A*a*100+B*b*100;
            if(tmp>F)continue;
            x.push_back(tmp);
        }
    }
    for (int c = 0; c <= F; ++c) {
        for (int d = 0; d <= F; ++d) {
            if(c*C+d*D>F)continue;
            y.push_back(c*C+d*D);
        }
    }
    ll mx=0;
    ll wasu=0;
    ll sugar=0;
    for(auto i:x){
        for(auto j:y){
//            cout <<i <<" "<<j <<endl;
            if(i+j>F)continue;
            if(100*j>E*i)continue;
            if(j*wasu>=sugar*(i+j)){
                sugar=j;
                wasu=i+j;
            }
        }
    }
    cout <<wasu<<" "<<sugar<<endl;
    return 0;
}


Measured memory_bytes: 2420
build = range(1, 5)
floor = range(1, 4)
dic = {}
for b in build:
    dic[b] = {}
    for f in floor:
        dic[b][f] = [0]*10

n = input()
for i in range(n):
    info = map(int, raw_input().split())
    dic[info[0]][info[1]][info[2]-1] += info[3]
    if dic[info[0]][info[1]][info[2]-1] > 9:
        print 'error'

for b in build:
    for f in floor:
        print '',
        print ' '.join(map(str, dic[b][f]))
    if b != 4:
        print "#"*20

Measured memory_bytes: 6456
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n >> a >> b;

    cout << min(n*a, b) << '\n';
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            for (int i = 0; i < s.Length; i++)
            {
                if (0 == i % 2)
                {
                    if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }

            }

            Console.WriteLine("Yes");
        }
    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    bool flag[4];
    rep(i,4) flag[i] = false;
    string s;
    cin >> s;
    rep(i,s.length())
    {
        if (s[i]=='S')
        {
            flag[0] = true;
        }
        else if (s[i]=='N')
        {
            flag[1] = true;
        }
        else if (s[i]=='W')
        {
            flag[2] = true;
        }
        else
        {
            flag[3] = true;
        }
    }

    bool ans = false;
    if (flag[0] && flag[1] && flag[2] && flag[3])
    {
        ans = true;
    }
    else if (flag[0] && flag[1] && !flag[2] && !flag[3])
    {
        ans = true;
    }
    else if (!flag[0] && !flag[1] && flag[2] && flag[3])
    {
        ans = true;
    }

    if(ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}


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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> input;
		int m;
		cin >> m;
		for(int i = 0; i < m; ++i)
		{
			int x, y;
			cin >> x >> y;
			input.push_back(P(x, y));
		}
		vector< vector<P> > target(4);
		for(int i = 1; i < m; ++i)
		{
			target[0].push_back(P(input[i].first - input[i - 1].first, input[i].second - input[i - 1].second));
		}
		vector< vector<P> > target_reverse(4);
		for(int i = m - 2; i >= 0; --i)
		{
			target_reverse[0].push_back(P(input[i].first - input[i + 1].first, input[i].second - input[i + 1].second));
		}
		for(int i = 1; i < 4; ++i)
		{
			for(int j = 0; j < target[0].size(); ++j)
			{
				target[i].push_back(P(-target[i - 1][j].second, target[i - 1][j].first));
				target_reverse[i].push_back(P(-target_reverse[i - 1][j].second, target_reverse[i - 1][j].first));
			}
		}
		
		for(int i = 0; i < n; ++i)
		{
			cin >> m;
			vector<P> temp;
			for(int j = 0; j < m; ++j)
			{
				int x, y;
				cin >> x >> y;
				temp.push_back(P(x, y));
			}
			vector<P> line;
			for(int j = 1; j < m; ++j)
			{
				line.push_back(P(temp[j].first - temp[j - 1].first, temp[j].second - temp[j - 1].second));
			}
			bool flag1 = false;
			bool flag2 = false;
			for(int j = 0; j < 4; ++j)
			{
				if(target[0].size() != line.size())
				{
					break;
				}
				bool flag = true;
				for(int k = 0; k < line.size(); ++k)
				{
					if(line[k].first != target[j][k].first || line[k].second != target[j][k].second)
					{
						flag = false;
						break;
					}
				}
				if(flag)
				{
					flag1 = true;
					break;
				}

				flag = true;
				for(int k = 0; k < line.size(); ++k)
				{
					if(line[k].first != target_reverse[j][k].first || line[k].second != target_reverse[j][k].second)
					{
						flag = false;
						break;
					}
				}
				if(flag)
				{
					flag2 = true;
					break;
				}
			}
			if(flag1 || flag2)
			{
				cout << i + 1 <<  endl;
			}
		}
		cout << "+++++" << endl;
	}
}

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

Measured memory_bytes: 1200
#include <stdio.h>

int main() {
	
	int angka1 = 0;
	int angka2 = 0;
	int angka3 = 0;
	int angka4 = 0;
	int angka5 = 0;
	scanf("%d %d %d %d %d",&angka1,&angka2,&angka3,&angka4,&angka5);
	if(angka1 == 0){
		printf("1\n");
	}
	else if(angka2 == 0){
		printf("2\n");

	}
	else if(angka3 == 0){
		printf("3\n");

	}
	else if(angka4 == 0){
		printf("4\n");

	}
	else if(angka5 == 0){
		printf("5\n");

	}
	
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

// dp[i][j][k] = x0~xi からj選んで和がkな数
ll dp[60][60][10100];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n >> a;
  vector<ll> v(n);
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 2500; k++) {
        if(dp[i][j][k]){
          dp[i+1][j][k] += dp[i][j][k];
          dp[i+1][j+1][k + v[i]] += dp[i][j][k];
        }
      }
    }
  }

  ll res = 0;
  for (int i = 1; i <= n; i++) {
    res += dp[n][i][i * a];
  }
  cout << res << endl;
}


Measured memory_bytes: 196864
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w = readline() |> split |> parseMap
	s = String["" for i in 1:h]
	for i in 1:h
		s[i] = readline() |> chomp
	end
	dp = zeros(Int,h,w)
	dp[1,1] = s[1][1]=='#'?1:0
	for i in 2:w
		dp[1,i]=s[1][i]=='#'&&s[1][i-1]=='.'?dp[1,i-1]+1:dp[1,i-1]
	end
	for i in 2:h
		for j in 1:w
			dp[i,j] = s[i][j]=='#'&&s[i-1][j]=='.'?dp[i-1,j]+1:dp[i-1,j]
			if j>1
				v = s[i][j]=='#'&&s[i][j-1]=='.'?dp[i,j-1]+1:dp[i,j-1]
				dp[i,j] = min(dp[i,j],v)
			end
		end
	end
	println(dp[h,w])
end

main()

Measured memory_bytes: 123988