akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 1<<18;
const int MM = 1000000007;

ll A[MX], S[MX];

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%lld", A+i);

	S[1] = max(A[1], 0ll), S[2] = max(A[2], 0ll);
	for(int i = 3; i <= N; i++){
		S[i] = S[i-2] + (A[i] > 0? A[i] : 0);
	}
	ll mn = 0, ans = 0, st = 0, s = -1, e = -1;

	ans = max(S[N], S[N-1]);
	if(S[N] >= S[N-1]) e = N, s = (N+1)%2+1;
	else s = N%2+1, e = N-1;
	vector<int> L;
	if(ans <= 0){
		int mn = 1;
		for(int i = 2; i <= N; i++) if(A[i] > A[mn]) mn = i;
		for(int i = N; i > mn; i--) L.push_back(i);
		for(int i = 1; i < mn; i++) L.push_back(1);
		ans = A[mn];
	}
	else{
		int l = 1, r = N;
		for(int i = N;; i--){
			if(i <= e && (e-i)%2 == 0 && A[i] >= 0 ) break;
			L.push_back(i); r--;
		}
		for(int i = 1;; i++){
			if(i >= s && (s-i)%2 == 0 && A[i] >= 0 ) break;
			l++;
		}
		int cnt = (r-l)/2;
		for(int i = r; i >= l; i-=2) if(A[i] < 0) L.push_back(i), cnt--;
		for(int i = 1; i < l; i++) L.push_back(1);
		for(int i = 1; i <= cnt; i++) L.push_back(2);
	}
	printf("%lld\n", ans);
	printf("%d\n", L.size());
	for(int c : L) printf("%d\n", c);
}


Measured memory_bytes: 2304
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  
  int n, i, j;
  int A[N+1];
  
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  /*your code*/
  int key;
  
  for( j = 2; j <= n; j++){
    key = A[j];
    i = j - 1;
    while(i > 0 && A[i] > key){
      A[i+1] = A[i];
      i--;
      A[i+1] = key;
    }
    trace(A,n);
  }

  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    ll n,m;
    cin >> n >> m;
    ll count=0;
    if(n>=m/2) {
        count += m/2;
    }
    else{
        ll rest = m-2*n;
        count += n;
        count += rest/4;
    }
    cout << count << endl;
}

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


Measured memory_bytes: 256
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    s = input()
    k = intin()

    nlist = [(ord(c), i) for i, c in enumerate(s)]
    nlist.sort()

    prev_oc = None
    slist = []

    for oc, i in nlist:
        kcount = len(slist)
        if prev_oc is not None and oc != prev_oc and kcount >= k:
            break
        for j in range(min(k, len(s) - i)):
            slist.append(s[i:(i+j+1)])
        slist = list(set(slist))
        prev_oc = oc

    slist = list(set(slist))
    slist.sort()
    print(slist[k-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        for w in range(W):
            if h == 0 or w == 0 or h == H-1 or w == W-1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()


Measured memory_bytes: 7000
n,m=map(int,input().split())
a=set()
for i in range(m):
    ai=int(input())
    a.add(ai)


mod=10**9+7

t=[0]*(n+1)
t[0]=1

if 1 in a:
    t[1]=0
else:
    t[1]=1

for i in range(2,n+1):
    if i in a:
        t[i]=0
    else:
        t[i]=(t[i-1]+t[i-2])%mod

print(t[n])

Measured memory_bytes: 11884
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    int h, w;
    cin>>h>>w;
    string maze[h];
    for (int i = 0; i < h; i++) {
        cin>>maze[i];
    }
    int dist[22][22][22][22];
    for (int i = 0; i < 22; i++) {
        for (int j = 0; j < 22; j++) {
            for (int k = 0; k < 22; k++) {
                for (int l = 0; l < 22; l++) {
                    if (i == k && j == l) {
                        dist[i][j][k][l] = 0;
                    } else {
                        dist[i][j][k][l] = INF;
                    }
                }
            }
        }
    }
    const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < 4; k++) {
                if (
                    j + dx[k] >= 0 && j + dx[k] < w &&
                    i + dy[k] >= 0 && i + dy[k] < h &&
                    maze[i][j] == '.' &&
                    maze[i + dy[k]][j + dx[k]] == '.'
                ) {
                    dist[i][j][i + dy[k]][j + dx[k]] = dist[i + dy[k]][j + dx[k]][i][j] = 1;
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                    for (int m = 0; m < h; m++) {
                        for (int n = 0; n < w; n++) {
                            dist[k][l][m][n] = min(
                                dist[k][l][m][n],
                                dist[k][l][i][j] + dist[i][j][m][n]
                            );
                        }
                    }
                }
            }
        }
    }
    int mx = -INF;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                    if (
                        dist[i][j][k][l] < INF &&
                        maze[i][j] == '.' &&
                        maze[k][l] == '.'
                    ) {
                        mx = max(mx, dist[i][j][k][l]);
                    }
                }
            }
        }
    }
    cout<<mx<<endl;
}

Measured memory_bytes: 2048
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # 1文字のみを読み込み
    # s = input().rstrip()
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 1文字ずつ標準入力を文字列として読み込み
    # s = list(input().rstrip())
    
    # 位置文字ずつ標準入力を数値配列として読み込み
    # X = [int(_) for _ in input().split()]
    
    SA = list(input().rstrip())
    SB = list(input().rstrip())
    SC = list(input().rstrip())
    SA.reverse()
    SB.reverse()
    SC.reverse()
    
    next = ''
    ans = ''
    for i in range(0,100+100+100+1):
        cur = next
        # print(cur)
        # print(SA)
        # print(SB)
        # print(SC)
        if i == 0:
            next = SA.pop()
        else :
            if next == 'a':
                if len(SA) > 0:
                    next = SA.pop()
                else:
                    ans = 'A'
                    break
            if next == 'b':
                if len(SB) > 0:
                    next = SB.pop()
                else:
                    ans = 'B'
                    break
            if next == 'c':
                if len(SC) > 0:
                    next = SC.pop()
                else:
                    ans = 'C'
                    break
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, i, j, k, l, m, n, ans, tmp, hoge;

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

    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];

    sort(p.begin(), p.end(), std::greater<int>());

    int alice = 0,
        bob = 0;
    rep(i, n)
    {
        if (i % 2 == 0)
            alice += p[i];
        else
            bob += p[i];
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
count=0
listnum=0
countlist=list()
countlist.append(0)
for i in range(n-1):
    if h[i]>=h[i+1]:
        
        countlist[listnum]+=1
        
    else:
            count=0
            listnum+=1
            countlist.append(0)
        
            
    
        
      
print(max(countlist))
        

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

vector<int> par;

int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
}

int size(int x) {
    return -par[root(x)];
}

void merge(int x, int y) {
    if (size(x) < size(y)) swap(x, y);
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] += par[ry];
    par[ry] = rx;
}



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

    ll n, m; cin >> n >> m;

    par.assign(n * 2, -1);
    
    rep(i, 0, m) {
        int a, b; cin >> a >> b;
        --a, --b;
		merge(a, b + n);
		merge(b, a + n);
    }

    if (root(0) != root(n)) {
        // 二部グラフの左側*右側
        ll cnt = 0;
        rep(i, 0, n)
            if (root(0) == root(i)) ++cnt;
        cout << cnt * (n - cnt) - m << endl;
    }
    else {
        cout << n * (n - 1) / 2 - m << endl;
    }

	return 0;
}


Measured memory_bytes: 3996
<?php
$n = fgets(STDIN);
$list = trim(fgets(STDIN));
$a = explode(" ", $list);
sort($a);

$s = 0;
for ($i = 0; $i < count($a) - 1; $i++){
    $s += $a[$i];
}

if ($a[count($a) - 1] < $s){
    echo 'Yes';
}else{
    echo 'No';
}
?>


Measured memory_bytes: 4728
#include<stdio.h>
#define N 20
#define Q 2000

//int rec(int,int [N],int [N],int,int,int);
int solve(int ,int ,int ,int [N],int);

int main(){
  int num,n[N],qu,q[Q],i,S[N];

  scanf("%d",&num);

  for(i=0;i<num;i++) scanf("%d",&n[i]);

  scanf("%d",&qu);

  for(i=0;i<qu;i++) scanf("%d",&q[i]);

  for(i=0;i<qu;i++){
    //if(rec(0,S,n,q[i],num,0)==1) printf("yes\n");
    if(solve(0,q[i],num,n,0)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



/*
int rec(int i,int S[N],int n[N],int q,int num,int flag){
  int j,sum=0;
  if(i==num){
    if(flag==0){
      for(j=0;j<num;j++){
	if(S[j]==1)sum+=n[j];
	if(sum>=q)break;
      }
      if(sum==q) flag=1;
    }
    return flag;
  }
  
  S[i]=1;
  flag=rec(i+1,S,n,q,num,flag);
  S[i]=0;
  flag=rec(i+1,S,n,q,num,flag);

  return flag;
}
*/

int solve(int i,int q,int num,int n[N],int res){
  if(q==0 || res==1) return 1;
  if(i>=num) return 0;
  res = solve(i+1,q,num,n,res);
  res = solve(i+1,q-n[i],num,n,res);
  return res;
}

Measured memory_bytes: 588
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = float('inf')
X = []
Y = []
for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(a[x - 1] + b[y - 1] - c, ans)

print(min(ans, min(a) + min(b)))


Measured memory_bytes: 18608
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(){
	int n,h;
	while(true){
		cin >> n >> h;
		set<int> deletecube;
		if(n == 0 && h == 0){
			break;
		}

		for(int i=0;i<h;i++){
			string m;
			int a,b;
			cin >> m >> a >> b;
			a--;
			b--;
			if(m == "xy"){
				for(int j=0;j<n;j++){
					deletecube.insert(a + n*b + n*n*j);
				}
			}
			if(m == "xz"){
				for(int j=0;j<n;j++){
					deletecube.insert(a + n*j + n*n*b);
				}
			}
			if(m == "yz"){
				for(int j=0;j<n;j++){
					deletecube.insert(j + n*a + n*n*b);
				}
			}
		}
		int ans = n*n*n - deletecube.size();
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>


using namespace std;

int main(){
    int n,m,p;
    while(cin >> n >> m >> p){
        if((n|m|p) == 0) break;
        int v[n],sum=0,ret;
        for(int i=0;i<n;i++){
            cin >> v[i];
            sum += v[i];
        }
        //1-T¦ð|¯Äzª³êéàzÉ·é
        sum *= 100 - p;
        //zª³êéàz/I=1 ½è
        ret = v[m-1]?sum / v[m-1]:0;
        cout << ret << endl;
            
    }
}

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

int main()
{
	std::vector<int> cars;
	int input;
	while (std::cin >> input) {
		if (input != 0) {
			cars.push_back(input);
		} else if (!cars.empty()) {
			std::cout << cars.back() << std::endl;
			cars.pop_back();
		}
	}

	return 0;
}

Measured memory_bytes: 1212
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end

def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(ym){Array.new(l,d)}}end

def yn(f) return (f)? "Yes": "No" end

def ynb(f) return (f)? "YES": "NO" end

def ap(a) a.each{|u| p u} end

def bit(n) n.to_s(2).split("").map(&:to_i) end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def answer(tree,counter)
  ans = na(counter.size)
  que = [[1,1,0]]
  used = na(counter.size,false)
  while que.size > 0
    pa, x, c = que.shift
    c += counter[x]
    ans[x] = c
    tree[x].each do |xx|
      next if(xx == pa)
      que.push([x,xx,c])
    end
  end
  return ans
end

n,q = inp
tree = na2(n+1,0)
counter = na(n+1,0)
(n-1).times do |i|
  d = inp
  tree[d[0]].push(d[1])
  tree[d[1]].push(d[0])
end
q.times do |j|
  d = inp
  counter[d[0]] += d[1]
end
ans = answer(tree,counter)
(1...n).each do |i|
  print "#{ans[i]} "
end
puts ans[n]

Measured memory_bytes: 35040
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 10007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

int n, m;
vector<int> res;

int main()
{
//	gen();
//	freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    m = 1;
    while(m * (m + 1) / 2 < n) m++;

    for(int i = m; i >= 1; i--){
    	if(n == 0) break;
    	if(n >= i){
    		n -= i;
    		res.pb(i);
    	}
    }

    sort(all(res));
    Rep(i, sz(res)) cout << res[i] << "\n";

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 500005
#define M 500005
using namespace std;
inline int read(){
    int ans=0;
    char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
    return ans;
}
int n,m,first[N],cnt=0,d[N];
bool vis[N];
struct edge{int v,next,c;}e[M<<1];
inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;}
struct heap{int u,v;};
inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;}
priority_queue<heap>q;
set<int>col[N];
/*inline void dijkstra(){
    for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false;
    d[1]=0;
    q.push((heap){1,d[1]});
    while(!q.empty()){
        heap x=q.top();
        q.pop();
        if(vis[x.u])continue;
        vis[x.u]=1;
        for(int i=first[x.u];i;i=e[i].next){
            int v=e[i].v,w=col[x.u].count(e[i].c)?0:1;
            if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c);
            else if(d[v]==d[x.u]+w)col[v].insert(e[i].c);
        }
    }
}*/
inline void dijkstra(){
    for(int i=2;i<=n;i++){
        d[i]=0x3f3f3f3f;vis[i]=false;
    }
    d[1]=0;q.push((heap){1,d[1]});
    while(!q.empty()){
        heap cur=q.top();q.pop();if(vis[cur.u])continue;vis[cur.u]=true;
        int u=cur.u;
        for(int i=first[u];i;i=e[i].next){
            int v=e[i].v;int w=col[u].count(e[i].c)?0:1;
            if(d[v]>d[u]+w){
                d[v]=d[u]+w;q.push((heap){v,-d[v]});col[v].clear();col[v].insert(e[i].c);
            }
            else if(d[v]==d[u]+w){
                col[v].insert(e[i].c);
            }
        }
    }
}
signed main(){
    n=read();m=read();
    for(int i=1;i<=m;i++){
        int x=read();int y=read();int z=read();
        add(x,y,z);add(y,x,z);
    }
    memset(d,0x3f,sizeof(d));
    dijkstra();
    if(d[n]==0x3f3f3f3f)cout<<-1<<endl;
    else cout<<d[n]<<endl;
    return 0;
}

Measured memory_bytes: 42744
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> word;
  string s,ans_a,ans_b;
  int con_a = 0,con_b = 0;
  while(cin >>s){
    word[s]++;
  }
  map<string,int>::iterator pos;
  for(pos = word.begin(); pos != word.end(); pos++){
    if(pos->second > con_a){con_a = pos->second; ans_a = pos->first;}
    if((pos->first).size() > con_b){con_b = (pos->first).size(); ans_b = pos->first;}
  }
  cout <<ans_a<<" "<<ans_b<<endl;
  return 0;
}

Measured memory_bytes: 1192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OJcsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            double[] ansx = new double[n];
            double[] ansy = new double[n];
            double[] ansr = new double[n];
            for (int m = 0; m < n; m++)
            {
                string[] str = Console.ReadLine().Split(' ');
                double x1 = double.Parse(str[0]), y1 = double.Parse(str[1]), x2 = double.Parse(str[2]),      y2 = double.Parse(str[3]), x3 = double.Parse(str[4]), y3 = double.Parse(str[5]);
                ansx[m] = (2 * (y2 - y1) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3) - 2 * (y3 - y1) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2)) / (2 * (x2 - x1) * 2 * (y3 - y1) - 2 * (x3 - x1) * 2 * (y2 - y1));
                ansy[m] = ((x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) * 2 * (x3 - x1) - (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3) * 2 * (x2 - x1)) / (2 * (x2 - x1) * 2 * (y3 - y1) - 2 * (x3 - x1) * 2 * (y2 - y1));
                ansr[m] = Math.Sqrt((ansx[m] - x1) * (ansx[m] - x1) + (ansy[m] - y1) * (ansy[m] - y1));
            }
            for (int m = 0; m < n; m++)
                Console.WriteLine(string.Format("{0:0.000}",ansx[m])+" "+string.Format("{0:0.000}",ansy[m])+" "+string.Format("{0:0.000}",ansr[m]));
        }
    }
}

Measured memory_bytes: 5844
lst = [int(i) for i in input().split()]
if len(set(lst))==1:
    print(0)
    exit()

lst.sort()
dist1 = lst[2] - lst[0]
dist2 = lst[2] - lst[1]

if dist1 == dist2:
    print(dist1)
else:
    cnt = dist2
    dist1 -= dist2
    if dist1 % 2 == 0: 
        cnt += dist1 // 2
    else:
        cnt += dist1 // 2 + 2
    print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int k; cin >>k; ll t=7,q=1;
  if(k%2==0){cout <<-1; return;}
  while(q<1000000){
    if(t%k==0) break;
    t*=10; t+=7; t%=k; q++;
  }
  if(q==1000000) cout <<-1;
  else cout <<q;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3616
#include<iostream>  
#include<cstdio>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<climits>   
#include<cmath>
#include<stack>
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;


int a[100005];
int n,k;
int gcd(int x, int y)  
{  
    if (y == 0)  
    {  
        return x;  
    }  
    gcd(y, x%y);  
}  
int main()
{
	int t,i;
	cin>>n>>k;
	bool flag=0;
	for(i=1;i<=n;i++) 
	{
		cin>>a[i];
		if(k==a[i])
			flag=1;
	}
	if(flag==1)
	{
		cout<<"POSSIBLE"<<endl;
		return 0;
	}
	sort(a+1,a+1+n);
	if(a[n]<k)
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	t=a[1];
	for(i=1;i<=n;i++)
		t=gcd(t,a[i]);
	flag=0;
	for(i=1;i<=n;i++)
	{
		if((a[i]-k)%t==0)
			flag=1;
	}
	if(flag==1)
	{
		cout<<"POSSIBLE"<<endl;
	}
	else
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
}

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

int main(){
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  bool a=1;
  for(int i=0; i<S.size()-1; i++){
    if(S.at(i)==S.at(i+1)){
      a=0;
    }
  }
  if(a){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }
}

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

int main(){
    string s;
    int ans =0;
    cin >> s;
    if(s[0]=='0'){
        for(int i=1;i<s.size();i++){
            if(i%2==0){
                if(s[i]=='1'){
                    ans++;
                }
            }else{
                if(s[i]=='0'){
                    ans++;
                }
            }
        }
    }else{
        for(int i=1;i<s.size();i++){
            if(i%2==1){
                if(s[i]=='1'){
                    ans++;
                }
            }else{
                if(s[i]=='0'){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;



double s(int i,int K,int cnt){
  while(i < K){
    i *= 2;
    cnt++;
  }
  double now = 1;
  for(int i = 0; i < cnt; i++){
    now *= (double)1/(double)2;
  }
  return now;
}


int main(){
  int  N,K;
  cin >> N >> K;
  int cnt = 0;
  double ans = 0;
  for(int i = 1; i <= N; i++){
     ans += (double)1/(double)N* s(i,K,cnt);
  }
  cout << fixed;
  cout << setprecision(11) <<  ans << endl;
}

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

namespace abc146
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc146B();
        }

        public static void solve_abc146B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();
            List<char> res = new List<char>();

            for (int i = 0; i < s.Length; i++)
            {
                Console.Write("{0}", Convert.ToChar(s[i] + n > 'Z' ? 'A' + (s[i] + n - 'Z' - 1) : s[i] + n));
            }
        }

        public static void solve_abc146A()
        {
            string s = Console.ReadLine();
            Dictionary<string, int> week = new Dictionary<string, int>();

            week.Add("MON", 1);
            week.Add("TUE", 2);
            week.Add("WED", 3);
            week.Add("THU", 4);
            week.Add("FRI", 5);
            week.Add("SAT", 6);
            week.Add("SUN", 7);

            Console.WriteLine(s == "SUN" ? 7 : 7 - week[s]);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main(){
	LL a,b,k;scanf("%lld%lld%lld",&a,&b,&k);
	printf("%lld %lld",max(0ll,a-k),max(0ll,min(b,b+a-k)));
	return 0;
}

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

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

signed main(){
	int H,W;cin>>H>>W;
	vector<string> field(H);
	bool pro=true;
	for(int i=0;i<H;i++)cin>>field[i];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(field[i][j]=='.')continue;
			bool pro2=false;
			for(int k=0;k<4;k++){
				int x=i+dx[k];
				int y=j+dy[k];
				if(x<0 || y<0 || x>=H || y>=W)continue;
				if(field[x][y]=='#')pro2=true;
			}
			if (!pro2)pro=false;
		}
	}
	cout<<(pro?"Yes":"No")<<endl;
}

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  int n = sz(s);
  
  int ans = 0;
  
 
    rep(i,n/2){
      if(s[i] != s[n-1-i]){
        ans++;
      }
    }
  
  cout << ans << endl;
  


}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long int ll;
int num[100001]={0};
int main()
{
    int n,x,q,b,c;ll sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        num[x]++;
        sum+=x;
    }
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d %d",&b,&c);
        sum-=(long long)num[b]*b;
        sum+=(long long)num[b]*c;
        num[c]+=num[b];
        num[b]=0;
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 2108
_n, p = gets.split.map(&:to_i)
s = gets.chomp

count = tmp = 0
e = 1
l = %w[0 5]
h = Hash.new(0)
h[0] += 1

if p == 2
  s.each_char.with_index { |c, idx| count += idx + 1 if c.to_i.even? }
elsif p == 5
  s.each_char.with_index { |c, idx| count += idx + 1 if l.include?(c) }
else
  s.size.times do |i|
    tmp += s[-1 - i].to_i * e
    e = e * 10 % p
    h[tmp % p] += 1
  end

  h.each_value { |i| count += i * (i - 1) }
  count /= 2
end

puts count

Measured memory_bytes: 2812
h, w = gets.chomp.split(" ").map(&:to_i);

if (h == 1 || w == 1)
  puts 1
  exit 0
end
w1 = w / 2 + w%2
w2 = w - w1
 
h1 = h / 2 + h%2
h2 = h - h1
 
puts w1*h1 + w2*h2

Measured memory_bytes: 1788
N = int(input())
A,B = map(int, input().split())
P = list(map(int, input().split()))
list = [0, 0, 0]
for i in range(N):
	if P[i] <= A:
		list[0] = list[0] + 1
	elif P[i] > A and P[i] <= B:
		list[1] = list[1] + 1
	else:
		list[2] = list[2] + 1
print(min(list))

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  string result;
  
  if (s == "Sunny") {
    result = "Cloudy";
  } else if (s == "Cloudy") {
    result = "Rainy";
  } else if (s == "Rainy") {
    result = "Sunny";
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp28 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];

            if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
                Console.WriteLine("Possible");
            } else {
                Console.WriteLine("Impossible");
            }
           
        }
    }
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string s;cin>>s;
    sort(s.begin(),s.end());

    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}



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

using namespace std;

int T;
long long N,A,B,C,D;
vector<long long> ans;


int main()
{
	cin >> T;
	ans = vector<long long>(T);
	for (int t = 0; t < T; t++) {
		cin >> N;
		cin >> A;
		cin >> B;
		cin >> C;
		cin >> D;

		map<long long, long long> m;
		m.insert(make_pair(N,0));

		auto it = m.end();
		while (it != m.begin()) {
			it--;
			long long i = (*it).first;
			
			m.insert(make_pair(i/2, 0));
			if(i % 2){ m.insert(make_pair(i / 2 + 1, 0)); }

			m.insert(make_pair(i / 3, 0));
			if (i % 3) { m.insert(make_pair(i / 3 + 1, 0)); }

			m.insert(make_pair(i / 5, 0));
			if (i % 5) { m.insert(make_pair(i / 5 + 1, 0)); }
		}

		int e = 0;
		while (it != m.end()) {
			long long i = (*it).first;
			long long cost = 0;

			long long a1 = m[i / 2] + A + D * (i % 2);
			//cost = min(cost,a1);
			cost = a1;
			long long a2 = 0;

			if (i % 2) {
				a2 = m[i / 2 + 1] + A + D * (2 - i % 2);
				cost = min(cost, a2);
			}

			long long b1 = m[i / 3] + B + D * (i % 3);
			cost = min(cost, b1);
			long long b2 = 0;
			if (i % 3) {
				b2 = m[i / 3 + 1] + B + D * (3 - i % 3);
				cost = min(cost, b2);
			}

			long long c1 = m[i / 5] + C + D * (i % 5);
			cost = min(cost, c1);
			long long c2 = 0;
			if (i % 5) {
				c2 = m[i / 5 + 1] + C + D * (5 - i % 5);
				cost = min(cost, c2);
			}

			if (i <= cost / D) {
				cost = min(cost,i*D);
			}

			m[i] = cost;

			it++;
		}

		ans[t] = m[N];
	}


	for (int t = 0; t < T; t++) {
		cout << ans[t] << endl;
	}
	return 0;
}



Measured memory_bytes: 4304
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        
        
        int height = 0;
        for (int i = 1; i <= b-a; i++) {
            height += i;
        }
        
        System.out.println(height-b);
    }
}


Measured memory_bytes: 21204
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    odd  = 0
    for a in A:
        if a % 2 == 1:
            odd += 1

    if odd % 2 == 0:
        print("YES")
    else:
        print("NO")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 19976
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define mx 1000002
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {
	
	int n,i;
	cin>>n;
	if(n<=12)
		cout<<n<<"\n";
	else
	{
		priority_queue<int,vector<int>,greater<int>> pq;
		for(i=1;i<=9;i++)
			 pq.push(i);
		int c=1;
		while(1)
		{
			int num=pq.top();
			int r=num%10;
			pq.pop();
			
			if(c==n)
			{	cout<<num<<"\n";
				break;
			}
			c++;
			int nxt=num*10;
			pq.push(nxt+r);
			if(r!=0)
				pq.push(nxt+r-1);
			if(r!=9)
				pq.push(nxt+r+1);
		}
	}
}	

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

//比較用2次元配列
int wh_hako[6][2] = {{60 , 2},
					{80 , 5},
					{100 , 10},
					{120 , 15},
					{140 , 20},
					{160 , 25},};
//料金配列
int h_ryoukin[6] = {600 , 800 , 1000 , 1200 , 1400 , 1600};

typedef struct struct_data
{
	int tate;
	int yoko;
	int takasa;
	int omosa;
}S_data;

int main(void)
{
	int n = 0;
	//入力構造体
	S_data s_data = {0};

	while (1)
	{
		cin >> n;
		
		//合計金額
		int kane = 0;

		if (n == 0){	return 0;	}

		for (int i = 0; i < n; i++)
		{
			cin >> s_data.tate >> s_data.yoko >> s_data.takasa >> s_data.omosa;
			//長さの合計
			int length = s_data.tate + s_data.yoko + s_data.takasa;
			for (int j = 0; j < 6; j++)
			{
				//0が長さで1が重さ
				if (wh_hako[j][0] >= length && wh_hako[j][1] >= s_data.omosa)
				{
					kane += h_ryoukin[j];
					break;
				}
			}
		}

		cout << kane << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long int a[n],sum=0,l=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==0) l=a[i];
    else if(i>0&&l>a[i]){
      sum+=abs(a[i]-l);
      
    }
    else if(a[i]>l) l=a[i];

  }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5116
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    int h,w;
    cin >> h >> w;
    
    vector<vector<char>> s(h, vector<char>(w));
    FOR(i, 0, h){
        FOR(j, 0, w){
            cin >> s[i][j];
        }
    }
    
    int ans=1;
    FOR(i, 0, h){
        FOR(j, 0, w){
            if(s[i][j]=='#'){
                if(i==0){
                    if(j==0){
                        if(((s[i+1][j])=='.')&&((s[i][j+1])=='.')){
                            ans = 0;
                        }
                    }else if(j==w-1){
                        if(((s[i+1][j])=='.')&&((s[i][j-1])=='.')){
                            ans = 0;
                        }
                    }else{
                        if(((s[i+1][j])=='.')&&((s[i][j+1])=='.')&&((s[i][j-1])=='.')){
                            ans = 0;
                        }
                    }
                }else if(i==h-1){
                    if(j==0){
                        if(((s[i-1][j])=='.')&&((s[i][j+1])=='.')){
                            ans = 0;
                        }
                    }else if(j==w-1){
                        if(((s[i-1][j])=='.')&&((s[i][j-1])=='.')){
                            ans = 0;
                        }
                    }else{
                        if(((s[i-1][j])=='.')&&((s[i][j+1])=='.')&&((s[i][j-1])=='.')){
                            ans = 0;
                        }
                    }
                }else if(j==0){
                    if(((s[i-1][j])=='.')&&((s[i][j+1])=='.')&&((s[i+1][j])=='.')){
                        ans = 0;
                    }
                }else if(j==w-1){
                    if(((s[i-1][j])=='.')&&((s[i][j-1])=='.')&&((s[i+1][j])=='.')){
                        ans = 0;
                    }
                }else{
                    if(((s[i+1][j])=='.')&&((s[i-1][j])=='.')&&((s[i][j-1])=='.')&&((s[i][j+1])=='.')){
                        ans = 0;
                    }
                }
            }
        }
    }
    
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int A, B;
  cin >> A >> B;
  cout << A*B << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define int long long
#define forn(i,a,b) for (int i=a; i<b; i++)
#define MOD 1000000000+7;

using namespace std;

const int N=20;
int A[N];
int x[N][N],y[N][N];

void solve (){
	int n;
	cin>>n;
	forn(i,0,n) {
		cin>>A[i];
		forn(j,0,A[i]) {
			cin>>x[i][j]>>y[i][j];
			x[i][j]--;
		}
	}
	int ans=0;
	forn(bits,0,(1<<n)) {
		bool ok=true;
		forn(i,0,n) {
			if (!(bits & (1<<i))) continue;
			forn(j,0,A[i]) {
				if (bits & (1<<x[i][j])) ok&=y[i][j];
				else ok&=!y[i][j];
			}
		}
		if (ok) ans=max(ans,(int)__builtin_popcount(bits));
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int p,int q){
    if(p%q==0) return q;
    return gcd(q,p%q);
}

int main(void){
    int K,a,b,c,ans=0;
    scanf("%d",&K);
    for(a=1;a<=K;a++){
        for(b=1;b<=K;b++){
            for(c=1;c<=K;c++){
                ans+=gcd(gcd(a,b),c);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1704
n, k = map(int, input().split())
s = input()
tmp = ord(s[k-1])
tmp1 = (chr(tmp+32))
ans = []

for i in range(len(s)):
    if i == k-1:
        ans.append(tmp1)
    else:
        ans.append(s[i])

print("".join(map(str, ans)))

Measured memory_bytes: 3060
import numpy as np
S=input()
ans=np.zeros(len(S))
s=np.zeros(len(S))
if S[0]=='1':
    ans[0]=1
    s[0]=1
else:
    ans[0]=0
    s[0]=0
    
for i in range(1,len(S)):
    ans[i]=(ans[i-1]+1)%2
    s[i]=int(S[i])
    
print(sum(ans!=s))

Measured memory_bytes: 20496
#include <stdio.h>
#include <string.h>

int main() {
	int N;
	char S[10010];
	for (int i = 0; i < 1010; i++) S[i] = '\0';
	scanf("%d", &N);
	scanf("%s", S);
	int len = strlen(S);
	for (int i = 0; i < len; i++) {
		S[i] = (S[i] + N) <= 90 ? S[i] + N : S[i] + N - 26;
	}
	printf("%s\n", S);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int mod = (int) 1e9+7;

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

    int n;
    cin >> n;
    vi a(n);
    REP(i, n) {
        cin >> a[i];
        a[i] = a[i]%mod;
    }

    ll acc = 0;
    REP(i, n) {
        acc += a[i];
        acc %= mod;
    }

    ll ans = 0;
    REP(i, n) {
        //cout << acc << endl;
        acc -= a[i];
        // cerr << acc << endl;
        if (acc < 0) acc += mod;
        ans += (a[i]* acc)%mod;
        ans %= mod;
    }

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


Measured memory_bytes: 3992
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
int n,k;
vector<int> v;
int mod = 1e9+7;
int dp[101][100001];
int add_self(int &a,int b) {
    a+=b;
    if(a>=mod) a-=mod;
    return a;
}
void solve(){
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++){
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;
        }
        for(int j=0;j<=k;j++)
        {
            int tr=sums[j]; 
            int unreachable=j-a[i]-1;
            if(unreachable>=0)
            {
                tr=(tr-sums[unreachable]+mod)%mod;
            }
            dp[i][j]=tr;
        }
    }
  	cout << dp[n][k];

}

int32_t main()
{
IOS
int t=1;
// cin>>t;
while(t--) {
    solve();
}
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

#include <bits/stdc++.h>

using namespace std;

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

	ll n;
	cin >> n;
	ll ans = INF;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i) continue;
		ll j = n / i;
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
}

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

int main(void){
    int n,temp=0;
    int min=100;
    int max=0;
    int sum,ans=0;
    vector<int> x;

    cin >> n;
    if(n<1||100<n)
        return 0;
    for(int i=0;i<n;i++){
        cin >> temp;
        if(temp<1||100<temp)
            return 0;
        x.push_back(temp);
        if(temp<min)
            min=temp;
        if(temp>max)
            max=temp;
    }
    //cout << min << "||" << max << endl;
    for(int i=min;i<=max;i++){
        sum=0;
        //cout << "---" << endl;
        for(int j=0;j<n;j++){
            sum+=(x[j]-i)*(x[j]-i);
            //cout << (x[j]-i)*(x[j]-i) << endl;
        }
        if(i==min)
            ans=sum;
        if(ans>sum)
            ans=sum;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

adj = [[] for i in range(n)]
for i in range(n - 1):
    u, v, w = map(int, readline().split())
    u -= 1
    v -= 1
    adj[u].append((w, v))
    adj[v].append((w, u))
# print(adj)

visited = [False for _ in range(n)]
dist = [0 for _ in range(n)]
def dfs(x, depth):
    if visited[x]:
        return
    visited[x] = True
    dist[x] = depth
    for y in adj[x]:
        dfs(y[1], depth + y[0])

dfs(0, 0)

# print(dist)
for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 83340