akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 100001

#define ll long long 



int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;
	
}

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

const int INF = 1000000000;

int main() {
    int n;
    cin >> n;
    vector< vector<int> > cost(n, vector<int>(n, INF));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int a;
            cin >> a;
            cost[i][j] = (a == -1) ? INF : a;
        }
    }

    vector<int> mincost(n, INF);
    vector<bool> used(n, false);
    mincost[0] = 0;

    int res = 0;
    while (true) {
        int v = -1;
        for (int u = 0; u < n; u++) {
            if (!used[u] && (v == -1 || mincost[u] < mincost[v])) {
                v = u;
            }
        }
        if (v == -1) break;
        used[v] = true;
        res += mincost[v];

        for (int u = 0; u < n; u++) {
            mincost[u] = min(mincost[u], cost[u][v]);
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        System.out.println((a * b) + " " + (2 * (a + b)));
    }
}

Measured memory_bytes: 24088
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;
	vector<P> v(N);
	for (int i = 0;i < N;i++) {
		ll x;
		cin >> x;
		v[i] = P(x, i);
	}
	sort(v.begin(), v.end());
	vector<ll> ans(2);
	ans[0] = v[N / 2 - 1].first;
	ans[1] = v[N / 2].first;
	vector<ll> answer(N);
	for (int i = 0;i < N;i++) {
		if (i <= N / 2 - 1)
			answer[v[i].second] = ans[1];
		else
			answer[v[i].second] = ans[0];
	}
	for (int i = 0;i < N;i++)
		cout << answer[i] << endl;
	return 0;
}


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


int main()
{
   int n;
   
   scanf("%d",&n);
   if(n%2==0){
   printf("0.5000000000");}
   else
  {printf("%f",(n+1)/(2.0000000000*n)); }
 return 0;


   
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char c[3][3];
    for(int i=0; i<3; i++)
    {
    	for(int j=0; j<3; j++)
    	{
    		cin >> c[i][j];
    	}
    }

    for(int i=0; i<3; i++)
    {
    	cout << c[i][i];
    }    

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#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()
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int wa = 0;
    REP(i, n){
        cin >> a[i];
        wa += a[i];
    }
    sort(ALL(a));
    int ans = wa - a[n - 1] / 2;
    cout << ans << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int n,m,x,y,a[100100],ans,cnt[100100],cntPair[100100];
vector<int> v[100100];

int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<n;i++){
		cnt[a[i]%m]++;
		v[a[i]%m].pb(a[i]);
	}
	ans+=cnt[0]/2;
	for(int i=1;i<m;i++){
		for(int j=0;j<v[i].size();j++){
			if(j!=v[i].size()-1 && v[i][j]==v[i][j+1]){
				cntPair[i]++;
				j++;
			}
		}
		//for(int j=0;j<v[i].size();j++) cout<<v[i][j]<<" ";cout<<endl;
		if(i*2==m) x = cnt[i]/2;
		else x = min(cnt[i],cnt[m-i]);
		cnt[i]-=x;
		cnt[m-i]-=x;
		ans+=x;
		ans+=min(cntPair[i],cnt[i]/2);
		//cout<<ans<<" "<<x<<" "<<cnt[i]<<" "<<cntPair[i]<<endl;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(void)
{
    int N,m,ans;
    cin>>N;
    m=N;
    while(m>0){
        ans+=m%10;
        m/=10;
    }
    if(N%ans==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int main()
{
    int x,a,b,k,i,j;
    scanf("%d%d%d",&a,&b,&k);
    if(b-a+1<=k*2)
    {
        for(i=a;i<=b;i++)
            printf("%d\n",i);
    }
    else
    {

        for(i=0;i<k;i++)
        {
            printf("%d\n",a);
            a++;
        }

        for(i=b-k+1;i<=b;i++)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}


Measured memory_bytes: 256
import string

x = input()
if x == "zyxwvutsrqponmlkjihgfedcba":
	print(-1)
else:
	lis = list(x)
	letter = list(string.ascii_lowercase)
	
	if len(lis) != 26:
		for item in letter:
			if not item in lis:
				print(x+item)
				break
	else:
		n = 25
		box = []
		while n > 0:
			if lis[n] > lis[n-1]:
				box.append(lis.pop(n))
				set = "z"
				for st in box:
					if lis[n-1] < st and set >= st:
						set = st
				lis.pop(n-1)
				print("".join(lis)+set)
				break
			else:
				box.append(lis.pop(n))
			n -= 1

Measured memory_bytes: 3892
n,c,k = map(int,raw_input().split())


t = []
for i in range(n):
	t.append(int(input()))

t.sort()

ans = 0
depart = t[0]
people = 0

i = 0
while i < n:
	if t[i] <= depart + k and people < c :
		people += 1
		i += 1

	else :
		ans += 1
		people = 0
		depart = t[i]

print ans + 1


Measured memory_bytes: 8964
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

using ldouble = long double;

template <class T>
T sq(T a) { return a * a; }

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

    std::vector<std::pair<ldouble, ldouble>> ps(n);
    for (auto& p : ps) {
        std::cin >> p.first >> p.second;
    }

    std::vector<int> idx(n);
    std::iota(idx.begin(), idx.end(), 0);

    ldouble sum = 0;
    int cnt = 0;
    do {
        for (int i = 0; i + 1 < n; ++i) {
            sum += sqrt(sq(ps[idx[i]].first - ps[idx[i + 1]].first) +
                        sq(ps[idx[i]].second - ps[idx[i + 1]].second));
        }
        ++cnt;
    } while (std::next_permutation(idx.begin(), idx.end()));

    std::cout << std::fixed << std::setprecision(20)
              << sum / cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNext() == true) {
			int[][] map = new int[8][8];

			for (int i = 0; i < 8; i++) {
				String line = sc.nextLine();
				
				for (int j = 0; j < 8; j++) {
					map[i][j] = line.charAt(j) - '0';
				}
			}
			if (sc.hasNext() == true) sc.nextLine();
			
			int state = 0;
			int max = 8;
			int k = 0;
			int left = 0;
			
			boolean end = false;
			for (int i = 0; i < max; i++) {
				for (int j = (k + left); j < 8; j++) {
					if (map[i][j] == 1) {
						switch (state) {
						case 0:
							state = 1;
							max = i + 4;
							k = j - 1;
							
							if (j == 0) {
								left = 1;
							}
							break;
							
						case 1:
							state = 2;
							break;

						case 2:
							state = 3;
							break;

						case 3:
							System.out.println("C");
							end = true;
							break;
							
						case 4:
							if (j == k) {
								System.out.println("D");
								end = true;
							} else {
								state = 6;
							}
							break;
							
						case 5:
							if (j == k) {
								System.out.println("G");
								end = true;
							} else if (j == (k + 1)) {
								System.out.println("A");
								end = true;
							} else {
								System.out.println("E");
								end = true;
							}
							break;
								
						case 6:
							System.out.println("F");
							end = true;
							break;
						}
					}
					if (end == true) break;
				}

				if (end == false) {
					if ((state == 1) || (state == 2)) {
						state = state + 3;
					} if (state == 6) {
						System.out.println("B");
						end = true;
					}
				}
				
				if (end == true) break;
 			}
		}
	}
}

Measured memory_bytes: 26888
n=int(input())
A=list(map(int,input().split()))
from collections import Counter
Acount=Counter(A)
L=[[] for i in range(n)]
s=0
for i in Acount.keys():
    k=Acount[i]
    L[i-1].append(k*(k-1)//2)
    L[i-1].append((k-2)*(k-1)//2)
    s+=k*(k-1)//2
for i in range(n):
    b=A[i]
    print(s-L[b-1][0]+L[b-1][1])


Measured memory_bytes: 39100
MAX = 10 ** 6 + 1
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * MAX
f = [True] * MAX
for a in A:
    cnt[a] += 1
    if not f[a] or cnt[a] > 1:
        continue
    for j in range(2 * a, MAX, a):
        f[j] = False
res = 0
for a in A:
    if f[a] and cnt[a] == 1:
        res += 1
print(res)

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

using namespace std;

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

	string n;

	cin >> n;

	if(n[0]=='7' || n[1]=='7' || n[2]=='7')
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main(){
  int N,K,hp;
  long long ans=0;
  cin>>N>>K;
  
  vector<int> v;
  for(int i=0;i<N;i++){
    cin>>hp;
    v.push_back(hp);
  }
  
  //降順ソート
  sort(v.begin(),v.end());
  
  //必殺技でHPが多い順に倒していく
  for(int j=0;j<K;j++){
    v.pop_back();
    if(v.empty()){
      cout<<ans<<endl;
      return 0;
    }
  }
  
  //残りの敵のHP=攻撃回数
  ans=accumulate(v.begin(), v.end(), 0LL);
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1400
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()

for h in range(1, 3501):
    for m in range(h, 3501):
        if 4*h*m-n*m-n*h > 0 and n*h*m % (4*h*m-n*m-n*h) == 0:
            w = (n*h*m)//(4*h*m-n*m-n*h)
            print(h, m, w)
            exit()

Measured memory_bytes: 10316
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        l:usize,
        r:usize,
        d:usize,
    }
    (l..=r).filter(|v| v % d == 0).count().to_string()
}
test! {
    "5 10 2" => "3",
    "6 20 7" => "2",
    "1 100 1" => "100",
}


Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int sigma(int j,int block_length,int bits[1001]){
  int res = 0;
  for(int i = j; i < j+block_length-1;i++){
    res += bits[i];
  }
  return res;
}

string bit2str(int bits,int len){
  string res = "";
  for(int i=len-1;i>=0;i--){
    res.push_back((bits & (1<<i) ? '1' : '0'));
  }
  return res;
}

string conv_log(const vector<string>& log){
  string res = "";
  for(int i=0;i<log.size()-1;i++){
    res.push_back(log[i][0]);
  }
  res += log[log.size()-1];
  return res;
}

int next[1001][1<<12];

int main(){
  int sequence_length;
  int block_length;
  while(~scanf("%d %d",&sequence_length,&block_length)){
    if(sequence_length == 0 && block_length == 0) break;
    
    int sequence[1001];
    for(int seq_i=0; seq_i < sequence_length; seq_i++){
      scanf("%d",&sequence[seq_i]);
    }

    memset(next,-1,sizeof(next));
    for(int pos = (sequence_length + block_length - 1) - block_length; pos - 1 >= 0; pos--){
      for(int S = 0; S < (1<<block_length); S++){
        if(sequence[pos] == __builtin_popcount(S)){
          int inherit = S >> 1;

          for(int header = 0; header <= 1; header++){
            int prev = inherit | (header<<(block_length-1));
            if(sequence[pos-1] == __builtin_popcount(prev)){
              next[pos-1][prev] = S;
            }
          }
        }
      }
    }

    bool has_ans = false;
    for(int S = 0; S < (1<<block_length); S++){
      if(next[0][S] == -1) continue;
      bool isok = true;
      vector<string> log;
      int bit = S;
      for(int pos = 0; pos < sequence_length; pos++){
        log.push_back(bit2str(bit,block_length));
        if(bit == -1){
          isok = false;
          break;
        }
        bit = next[pos][bit];
      }
      
      if(isok){
        cout << conv_log(log) << endl;
        has_ans = true;
        break;
      }
    }

    if(!has_ans){
      printf("Goofy\n");
    }
  }
}

Measured memory_bytes: 17332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < (to); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<pair<int, int>> vii;

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

    int n;
    cin >> n;
    vi a;

    int bigabs = -1;
    int bigabsindex = -1;

    rep(i,0,n) {
        int ai;
        cin >> ai;
        a.push_back(ai);
        if (abs(ai) > bigabs) {
            bigabs = abs(ai);
            bigabsindex = i;
        }
    }

    cout << (2*(n-1)) << endl;

    rep(i,0,n) {
        if (i != bigabsindex) {
            cout << (bigabsindex+1) << " " << (i+1) << endl;
            a[i] += a[bigabsindex];
        }
    }

    if (a[bigabsindex] < 0) {
        for (int i = n; i >= 2; i--) {
            cout << i << " " << (i-1) << endl;
        }
    } else {
        rep(i,1,n) {
            cout << i << " " << (i+1) << endl;
        }
    }








    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,sum,i,r;
    cin >> a;
    sum=0;r=a;
    for(i=0;i<3;i++)
    {
        sum+=a;
        a*=r;


    }
    cout << sum << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector <int> d(n);
    for(int i =0; i<n; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[n/2]-d[n/2-1] << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()	{
  int n, k;
  cin >> n >> k;
  int val = 1;
  for (int i = 0; i < n; i++)	{
    if (val <= k)	{
      val *= 2;
    }
    else	{
      val += k;
    }
  }
  cout << val << endl;
  return 0;
}

Measured memory_bytes: 3592
//object B {
object Main {
  import InOut._
  def main(args: Array[String]): Unit = {

    val s, t = nextLine
    val n = s.zip(t).count {
      case (a, b) => a != b
    }

    out.println(n)

    out.flush()
  }
 
  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


Measured memory_bytes: 58064
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
const int inf=1e9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<string,string> pss;
int buy;
int juu,gojuu,hyaku,gohyaku;
int mincoin;
bool first=true;
int main(void)
{
  while(cin >> buy && buy)
    {
      if(!first) cout << endl;
      first=false;
      mincoin=inf;
      cin >> juu >> gojuu >> hyaku >> gohyaku;
      int lastjuu=0,lastgojuu=0,lasthyaku=0,lastgohyaku=0;
      for(int i=0;i<=juu;i++)
	{
	  for(int j=0;j<=gojuu;j++)
	    {
	      for(int k=0;k<=hyaku;k++)
		{
		  for(int l=0;l<=gohyaku;l++)
		    {
		      int restjuu,restgojuu,resthyaku,restgohyaku;
		      int restcoin;
		      if((10*i+50*j+100*k+500*l)<buy) continue;
		      else
			{
			  restcoin=(juu-i)+(gojuu-j)+(hyaku-k)+(gohyaku-l);
			  int oturi=(10*i+50*j+100*k+500*l)-buy;
			  restcoin+=(oturi/500);
			  restgohyaku=(oturi/500);
			  oturi%=500;
			  restcoin+=(oturi/100);
			  resthyaku=(oturi/100);
			  oturi%=100;
			  restcoin+=(oturi/50);
			  restgojuu=(oturi/50);
			  oturi%=50;
			  restcoin+=(oturi/10);
			  restjuu=(oturi/10);
			  oturi%=10;
			  if(restcoin<mincoin)
			    {
			      mincoin=restcoin;
			      lastjuu=i;
			      lastgojuu=j;
			      lasthyaku=k;
			      lastgohyaku=l;
			    }
			}
		    }
		}
	    }
	}
      if(lastjuu)
	{
	  cout << "10 " << lastjuu<<endl;
	}
      if(lastgojuu)
	{
	  cout << "50 " << lastgojuu << endl;
	}
      if(lasthyaku)
	{
	  cout << "100 " << lasthyaku << endl;
	}
      if(lastgohyaku)
	{
	  cout << "500 " << lastgohyaku << endl;
	}
    }
  return 0;
}



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

#define MAX 100001

vector<int> Tree[MAX];
int memo[MAX];
int memo2[MAX];
bool visited[MAX];

int main(){
	int n,u,v;	cin>>n>>u>>v;
	for(int i=1;i<n;i++){
		int a,b;	cin>>a>>b;
		Tree[a].push_back(b);
		Tree[b].push_back(a);
	}

	// Aoki
	memo[v]=0;	visited[v]=true;
	stack<int> s;	s.push(v);

	while(s.empty()==false){
		int now=s.top();	s.pop();
		for(int next:Tree[now]){
			if(visited[next])continue;

			visited[next]=true;
			memo[next]=memo[now]+1;		s.push(next);
		}
	}

	//for(int i=1;i<=n;i++)printf("cost[%d]: %d\n",i,memo[i]);

	for(int i=1;i<=n;i++)visited[i]=false;

	s.push(u);	memo2[u]=0;	visited[u]=true;
	while(s.empty()==false){
		int now=s.top();	s.pop();
		for(int next:Tree[now]){
			if(visited[next])continue;

			visited[next]=true;
			memo2[next]=memo2[now]+1;		s.push(next);
		}
	}

	int ans=0;
	for(int i=1;i<=n;i++){
		if(memo[i]<memo2[i])continue;

		ans=max(ans,memo[i]);
	}

	cout<<ans-1<<endl;

	return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
ll x;
struct edge {
    int u, v, w;
} e[2010];
vector < pair < int, int > > son[1010];
inline int operator < (edge a, edge b) {
    return a.w < b.w;
}
int dis[1010];
inline void dfs(int now, int fa) {
    for (auto x : son[now]) {
        int v = x.first, w = x.second;
        if (v != fa) dis[v] = max(dis[now], w), dfs(v, now);
    }
}
int a[2010], cnt;
const int mod = 1000000007;
inline int power(int a, int b) {
    long long res = a, ans = 1;
    for (; b; b >>= 1, res = res * res % mod) if (b & 1) ans = ans * res % mod;
    return ans;
}
int main() {
    scanf("%d%d%lld", &n, &m, &x);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
    }
    sort(e + 1, e + 1 + m);
    ll now = 0;
    for (int i = 1; i <= m; i++) {
        memset(dis, 0, sizeof dis);
        dfs(e[i].u, 0);
        if (dis[e[i].v] == 0) {
            now += e[i].w;
            son[e[i].u].push_back(make_pair(e[i].v, e[i].w));
            son[e[i].v].push_back(make_pair(e[i].u, e[i].w));
        }
        else {
            a[++cnt] = e[i].w - dis[e[i].v];
        }
    }
    sort(a + 1, a + 1 + cnt);
    int ans = 0;
    if (now == x) ans = 1ll * power(2, m - n + 1) * (mod - 2 + power(2, n - 1)) % mod;
    for (int i = 1; i <= cnt; i++) {
        if (a[i] + now == x) ans = (ans + power(2, cnt - i + 1)) % mod;
    }
    return cout << ans << endl, 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int w;
	
	while( cin >> w && w != -1 ){
		int money = 0;
		for( int i = 0;i <= w;i++ ){
			if( i > 30 ) money += 160;
			else if( i > 20 ) money += 140;
			else if( i > 10 ) money += 125;
		}
		money += 1150;
		cout << 4280 - money << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, K, A;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>K;
    REP(i,0,N) cin>>A;

    cout<<(N-1+K-2)/(K-1)<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		List<Integer> a = new ArrayList<>();
		
		for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
		}
		
		int key = a.indexOf(1);
      
      
		int re = N - 1;
        int div = K - 1;
        int yu = 0;
        if (re % div !=0) yu++;
    
    
		
		int ans = (re / div) + yu ;
	 
		System.out.println(ans);
	
	}
}
			

Measured memory_bytes: 61184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 87;
ll x[N],v[N],n,c;
ll pr[N],po[N];
ll solve()
{
    ll su = 0;
    for (int i = 1; i <= n; ++i) {
        su += v[i];
        pr[i] = max(pr[i-1], su - 2 * x[i]);
    }
    su = 0;
    for (int i = n; i >= 1; --i) {
        su += v[i];
        po[i] = max(su - (c - x[i]), po[i+1]);
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i)
        ans = max(ans, pr[i]+po[i+1]);
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> c;
    for (int i = 1; i <= n; ++i)
        cin >> x[i] >> v[i];
    ll ans = max(0LL,solve());
    for (int i = 1; i <= n; ++i)
        x[i] = c - x[i];
    reverse(x+1,x+n+1);
    reverse(v+1,v+n+1);
    cout << max(ans, solve()) << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void){
	int n,i,sum=0,r;
	int a[21],b[21],c[21];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(i=1;i<=n-1;i++){
		scanf("%d",&c[i]);
	}
	for(i=1,r=a[1];i<=n;i++){
		sum+=b[a[i]];
		if(a[i]==r+1){
			sum+=c[a[i-1]];
		}
		r=a[i];
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 1708
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, x;std::cin >> n >> x;
  ll P = 1000000007;
  vvl dp = vv(n+1, 100001, 0, ll);
  vll a(n);
  for(int i=0;i<n;i++) std::cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  dp[0][x] = 1;
  for(int i=0;i<n;i++){
    for(int j=0;j<100001;j++){
      dp[i+1][j%a[i]] = (dp[i+1][j%a[i]] + dp[i][j])%P;
      dp[i+1][j] = (dp[i+1][j] + (dp[i][j]*(n-1-i))%P)%P;
    }
  }
  ll ans = 0;
  for(int i=0;i<100001;i++){
    ans = (ans + (dp[n][i]*i)%P)%P;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 159856
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>
#include <math.h>
 
using namespace std;
typedef unsigned long ul;

int main() {
	long long n,c,x[100010],v[100010];
	long long r[100010],l[100010],ri[100010],li[100010];
	long long m = 0;
	cin>>n>>c;
	for(int i=0;i<n;i++){
		cin>>x[i]>>v[i];
	}

	r[0] = v[0] - x[0];
	ri[0] = 0;
	m = max(m, r[0]);
	for(int i=1;i<n;i++){
		r[i] = r[i-1] + v[i] - x[i] + x[i-1];
		ri[i] = r[i] > r[ri[i-1]] ? i : ri[i-1];
		m = max(m, r[i]);
	}
	l[n-1] = v[n-1] - c + x[n-1];
	li[n-1] = n-1;
	m = max(m, l[n-1]);
	for(int i=n-2;i>=0;i--){
		l[i] = l[i+1] + v[i] + x[i] - x[i+1];
		li[i] = l[i] > l[li[i+1]] ? i : li[i+1];
		m = max(m, l[i]);
	}

	for(int i=0;i<n-1;i++){
		m = max(m, r[i] - x[i] + l[li[i+1]]);
	}
	for(int i=n-1;i>0;i--){
		m = max(m, l[i] - c + x[i] + r[ri[i-1]]);
	}
	cout<<m<<endl;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int k;cin >>k;
   if(k%2==0){
      cout << k/2*k/2;
   }else{
      cout << k/2*(k+1)/2;
   }
   return 0;
}

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

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

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    set<int> even_pos;
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
        if(i % 2 == 0) {
            even_pos.insert(a[i]);
        }
    }
    int M = even_pos.size();
    auto b = a;
    sort(b.begin(), b.end());
    for(int i = 0; i < N; i += 2) {
        even_pos.insert(b[i]);
    }
    cout << even_pos.size() - M << endl;
}


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

int main()
{   ll n;
    scanf("%lld",&n);
    ll z[n][3];
    for(ll i=0;i<n;i++)
        scanf("%lld%lld%lld",&z[i][0],&z[i][1],&z[i][2]);
    for(ll i=1;i<n;i++)
    {   z[i][0]+=max(z[i-1][1],z[i-1][2]);
        z[i][1]+=max(z[i-1][0],z[i-1][2]);
        z[i][2]+=max(z[i-1][1],z[i-1][0]);
    }
    printf("%lld",max(z[n-1][0],max(z[n-1][1],z[n-1][2])));
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MOD = 1000000007;
int main(){
	int N;
	string S1, S2;
	cin >> N >> S1 >> S2;
	int behind_tile_num;
	ll ans = 1;
	for(int i = 0; i < N; i++){
		if(S1[i] == S2[i]){
			if(i == 0) ans *= 3;
			else if(behind_tile_num == 1) ans *= 2;
			else if(behind_tile_num == 2) ans *= 1;
			ans %= MOD;
			behind_tile_num = 1;
		}else if(S1[i] != S2[i]){
			if(i == 0) ans *= 6;
			else if(behind_tile_num == 1) ans *= 2;
			else if(behind_tile_num == 2) ans *= 3;
			ans %= MOD;
			behind_tile_num = 2;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef struct edge{
    int col;
    int x;
    int id;
    int r;
    struct edge* next;
}edge;

typedef struct node{
    int value;
    int num;
    edge* fst;
    edge* lst;
}node;

void init(node* p, int num){
    p->value = 0;
    p->num = num;
    p->fst = NULL;
    p->lst = NULL;
}

void add(node* p, edge* e){
    if(p->fst == NULL){
        p->fst = e;
        p->lst = p->fst;
    }else{
        p->lst->next = e;
        p->lst = p->lst->next;
    }
    p->value++;
}

 
void func(node* a, int x, int prec, int pre){
    edge* p = (a + x)->fst;
    int c = 1;
    while(p != NULL){
        if(p->x == pre){
            p = p->next;
            continue;
        }
        if(c == prec){
            c++;
        }
        p->col = c;
        func(a, p->x, c, x);
        p = p->next;
        c++;
    }
}

int main(){
    int n;
    scanf("%d", &n);
    node g[n+1];
    edge e[n-1];
    edge r[n-1];
    for(int i=1; i<=n; i++){
        init(&g[i], i);
    }
    int a[n], b[n];
    for(int i=0; i<n-1; i++){
        scanf("%d%d", &a[i], &b[i]);
    }
    for(int i=0; i<n-1; i++){
        e[i].x = b[i];
        e[i].id = i;
        e[i].col = -1;
        e[i].r = 0;
        e[i].next = NULL;
        r[i].x = a[i];
        r[i].id = i;
        r[i].col = -1;
        r[i].r = 1;
        r[i].next = NULL;
        add(&g[a[i]], &e[i]);
        add(&g[b[i]], &r[i]);
    }
    int max = 0;
    for(int i=1; i<=n; i++){
        if(g[i].value > max){
            max = g[i].value;
        }
    }
    func(g, 1, -1, -1);
    /*for(int i=0; i<n-1; i++){
        printf("%d %d\n", e[i].col, r[i].col);
    }*/
    printf("%d\n", max);
    for(int i=0; i<n-1; i++){
        if(e[i].col != -1){
            printf("%d\n", e[i].col);
        }else{
            printf("%d\n", r[i].col);
        }
    }

    return 0;
}

Measured memory_bytes: 9344
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int a,b;
	string s;
	cin>>a>>b>>s;
	bool ok=true;
	for(int i=0;i<s.size();i++){
		if(i==a)if(s[i]!='-')ok=false;
		if(i!=a)if(s[i]=='-')ok=false;
	}
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    c = Counter(map(int, input().split()))
    ans = 0
    for x in c:
        ans = max(ans, c[x - 1] + c[x] + c[x + 1])
    print(ans)


if __name__ == '__main__':
    main()


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

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

// the code that we provide requires everything above this line to compile

int N;
int dp[100001][3];
int ai, bi, ci;

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> ai >> bi >> ci;
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + ai;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + bi;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + ci;
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2]));
}


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

using namespace std;

const int maxn=305;
const int INF=1e9;
int dp[maxn][maxn][maxn];
char str[maxn];
int main()
{
    int s;
    scanf("%s%d",str,&s);
    int l=strlen(str);
    for(int i=0;i<=l+1;i++)
        for(int j=0;j<=l+1;j++)
            for(int k=0;k<=s;k++)
                dp[i][j][k]=-INF;
    for(int k=0;k<=s;k++)
        dp[1][l][k]=0;
    int ans=0;
    for(int i=1;i<=l;i++)
    {
        for(int j=l;j>=i;j--)
        {
            for(int k=s;k>=0;k--)
            {
                dp[i+1][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
                dp[i][j-1][k]=max(dp[i][j][k],dp[i][j-1][k]);

                if(str[i-1]==str[j-1]){
                    dp[i+1][j-1][k]=max(dp[i][j][k]+1+(i!=j),dp[i+1][j-1][k]);
                }
                else{
                    if(k){
                        dp[i+1][j-1][k-1]=max(dp[i][j][k]+2,dp[i+1][j-1][k-1]);
                    }
                }

            }
        }
    }
    for(int i=0;i<=l+1;i++)
        for(int j=0;j<=l+1;j++)
            for(int k=0;k<=s;k++)
                ans=max(ans,dp[i][j][k]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 110848
import sys
h, w, k = [int(i) for i in sys.stdin.readline().split()]
s_ls = {}
for i in range(h):
    s_ls[i] = [int(j) for j in sys.stdin.readline().strip()]

best = h - 1 + w - 1
for i in range(1 << (h - 1)):
    flg = True
    s = bin(i)[2:].zfill(h-1)
    ls = {i for i, j in enumerate(s) if j == "1"}
    dict = {i : 0 for i in range(len(ls) + 1)}
    cnt = 0
    for _w in range(w):
        j = 0
        col_sums = {i : 0 for i in range(len(ls) + 1)}
        for _h in range(h):
            val = s_ls[_h][_w]
            col_sums[j] += val
            dict[j] += val
            if _h in ls:
                j += 1
        if max(dict.values()) > k:
            cnt += 1
            dict = col_sums
        if max(col_sums.values()) > k:
            flg = False
        if not flg:
            break
    if flg:
        best = min(best , cnt + len(ls))
print(best)

Measured memory_bytes: 55424
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	string s;
 	cin>>s;
 	set<char>st;
 	for(char x:s)
 	{
 		st.insert(x);
 	}	
 	if(st.size()==2)
 	{
 		cout<<"Yes"<<endl;
 	}
 	else
 	{
 		cout<<"No"<<endl;
 	}
    return 0;
}

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

struct STsum{
private:
    int n;
    vector<int> dat;
public:
    STsum(int siz){
        n = 1;
        while(n < siz)   n *= 2;
        dat.resize(2*n-1, 0);
    }

    void update(int x, int val){
        x += (n-1);
        dat[x] += val;
        while(x > 0){
            x = (x-1)/2;
            dat[x] = dat[2*x+1]+dat[2*x+2];
        }
    }
    
    // focus on k-th node, who controls [l, r)
    int query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        if(a <= l && r <= b)    return dat[k];

        int lx = query(a, b, 2*k+1, l, (l+r)/2);
        int rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx+rx;
    }
};

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

    vector<int> xax, ax(n), ay(n), bx(n), by(n);
    for(int i = 0; i < n; i++){
        cin >> ax[i] >> ay[i] >> bx[i] >> by[i];
        xax.push_back(ax[i]);  xax.push_back(bx[i]);
    }
    sort(xax.begin(), xax.end());
    xax.erase(unique(xax.begin(),xax.end()),xax.end());
    auto f = [&](int val)->int{
        return lower_bound(xax.begin(),xax.end(),val)-xax.begin();
    };

    STsum seg(xax.size()+1);
    vector<pair<pair<int,int>, int>> vp;
    for(int i = 0; i < n; i++){
        if(ax[i] == bx[i]){
            vp.push_back({{min(ay[i],by[i]), 0}, i});
            vp.push_back({{max(ay[i],by[i]), 2}, i});
        }else if(ay[i] == by[i]){
            vp.push_back({{ay[i], 1}, i});
        }
    }
    sort(vp.begin(), vp.end());
    int ans = 0;
    for(auto p : vp){
        if(p.first.second == 0){
            seg.update(f(ax[p.second]), 1);
        }else if(p.first.second == 2){
            seg.update(f(ax[p.second]), -1);
        }else if(p.first.second == 1){
            ans += seg.query(f(min(ax[p.second],bx[p.second])), f(max(ax[p.second],bx[p.second]))+1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[210000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

}


Measured memory_bytes: 1024
import heapq
import copy
n=int(input())
a=list(map(int,input().split()))
ca=copy.deepcopy(a)
f=ca[:n]
heapq.heapify(f)
fs=sum(f)
fsl=[0 for i in range(n+1)]
fsl[0]=fs
for i in range(n,2*n):
    heapq.heappush(f,a[i])
    fs=fs+a[i]-heapq.heappop(f)
    fsl[i-n+1]=fs
l=list(map(lambda x:-x,ca[2*n:]))
heapq.heapify(l)
ls=sum(l)
lsl=[0 for i in range(n+1)]
lsl[-1]=ls
for i in range(n,2*n):
    heapq.heappush(l,-a[3*n-i-1])
    ls=ls-a[3*n-i-1]-heapq.heappop(l)
    lsl[2*n-i-1]=ls
ans=-float('inf')
for i in range(n+1):
    ans=max(ans,fsl[i]+lsl[i])
print(ans)

Measured memory_bytes: 37596
#include <iostream>
using namespace std ;
int main () {
 
int a , b;
cin >> a >> b ;
if (( b== 1 ) && ((a>=2 && a<=13))){
    cout << "Bob";
}
else if (( a== 1 ) && ((b>=2 && b<=13))){
    cout << "Alice";
}
else if (a> b){
    cout << "Alice";
}
else if (a< b){
    cout << "Bob";
}
else {
    cout << "Draw" ;
}
 
 return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char s[3];
    char t[3];
    int ans = 0;
    scanf("%s",s);
    scanf("%s",t);
    for(int i = 0; i<3 ; i++) {
        if(s[i] == t[i]) {
            ans += 1;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
string s;
cin>>s;
if(s=="Sunny")
	cout<<"Cloudy";
else if(s=="Cloudy")
	cout<<"Rainy";
else if(s=="Rainy")
	cout<<"Sunny";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a = 0, b = 0, c = 0, aa = 0, bb = 0, cc = 0; 
	string s, t, u; cin >> s >> t >> u;
	if (s[0] == 'a') { a = 1; b = 0; c = 0; aa++; }
	if (s[0] == 'b') { a = 0; b = 1; c = 0; aa++; }
	if (s[0] == 'c') { a = 0; b = 0; c = 1; aa++; }
	for (int h = 0; h < 300; h++) {
		if (a == 1 && b == 0 && c == 0) {
			if (s.size() - 1 < aa) { cout << 'A' << endl; cin >> n; return 0; }
			if (s[aa] == 'a') { a = 1; b = 0; c = 0; aa++; }
			else if (s[aa] == 'b') { a = 0; b = 1; c = 0; aa++; }
			else if (s[aa] == 'c') { a = 0; b = 0; c = 1; aa++; }
		}
		if (a == 0 && b == 1 && c == 0) {
			if (t.size() - 1 < bb) { cout << 'B' << endl; cin >> n; return 0; }
			if (t[bb] == 'a') { a = 1; b = 0; c = 0; bb++; }
			else if (t[bb] == 'b') { a = 0; b = 1; c = 0; bb++; }
			else if (t[bb] == 'c') { a = 0; b = 0; c = 1; bb++; }
		}
		if (a == 0 && b == 0 && c == 1) {
			if (u.size() - 1 < cc) { cout << 'C' << endl;  cin >> n; return 0; }
			if (u[cc] == 'a') { a = 1; b = 0; c = 0; cc++; }
			else if (u[cc] == 'b') { a = 0; b = 1; c = 0; cc++; }
			else if (u[cc] == 'c') { a = 0; b = 0; c = 1; cc++; }
		}
	}
	cin >> n;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main()
{
	/*string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u)a--;
	else b--;
	cout << a << " " << b;*/


	/*string s;
	cin >> s;
	rep(i, s.size()) {
		cout << "x";
	}*/


	/*int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	rep(i, n - 1) {
		if (a[i] == a[i + 1]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");*/


	int n, k;
	cin >> n >> k;
	vector<double>p(n);
	double x;
	rep(i, n) {
		cin >> x;
		p[i] = x * (x + 1) / 2 / x;
	}
	vector<double>r(n);
	r[0] = p[0];
	rep(i, n - 1) {
		r[i + 1] = r[i] + p[i + 1];
	}
	double ans = r[k - 1];
	rep(i, n - k) {
		ans = max(ans, r[i + k] - r[i]);
	}
	printf("%.12f", ans);



	return 0;
}

Measured memory_bytes: 3328
def matching(s,t):
    ret = True
    for s_, t_ in zip(s,t):
        if not (s_ == t_ or s_ == '?'):
            ret = False
            break
            
    return ret

def solve():
    S = input()
    T = input()
    L_S = len(S)
    L_T = len(T)
    pos = -1
    match = False
    for i in range(L_S-L_T+1)[::-1]:
        if matching(S[i:i+L_T],T):
            pos = i
            break
            
    if pos >= 0:
        result = ''.join(list(map(lambda x: 'a' if x=='?' else x, S)))
        print(result[:pos]+T+result[pos+L_T:])
    else:
        print('UNRESTORABLE')
        
solve()

Measured memory_bytes: 3064
from collections import deque
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
visited=[0]*n
def bfs(s):
    q=deque([s])
    visited[s]=1
    cnt=1
    while q:
        x=q.popleft()
        for nx in edge[x]:
            if visited[nx]==0:
                visited[nx]=1
                cnt+=1
                q.append(nx)
    return cnt
ans=0
for i in range(n):
    if visited[i]==0:
        ans=max(ans,bfs(i))
print(ans)

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

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;
const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
vector <i64> a;
vector <i64> dp;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);
    i64 h1, m1, h2, m2;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    i64 mn = (h2 - h1) * 60 + m2 - m1;

    cout << mn - k << endl;




    return 0;
}

Measured memory_bytes: 3188
n = gets.to_i
ar = Array.new(n)

n.times do |i|
  ar[i] = gets.to_i
end

ar.sort!

sum = ar.reduce(:+)

if sum % 10 != 0
  puts sum
  exit 0
end

ar.each do |num|
  if num % 10 != 0
    puts sum - num
    exit 0
  end
end

puts 0

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

int main() {

	char c;
	cin >> c;

	string ret;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
		ret = "vowel";
	}
	else{
		ret = "consonant";
	}
	cout << ret;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

ll digitSum(ll n) {
    ll sum = 0;
    while (n) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n, a, b, t;
    cin >> n >> a >> b;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        t = digitSum(i);
        if (t >= a && t <= b) ans += i;
    }
    cout << ans << endl;
}

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

int main() {
    int n; scanf("%d", &n);
    vector<int> a(3 * n);
    for (int& i : a) scanf("%d", &i);
    sort(a.rbegin(), a.rend());

    int64_t tot = 0;
    for (int i = 1; i < 2 * n; i += 2)
        tot += a[i];
    cout << tot << "\n";
    return 0;
}


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

int main() {
  string str;
  string kekka = "";
  int cnt = 0;
  
  cin >> str;
  
  if(str == "?"){
    cout << "D";
    return 0;
  }else if(str == "P" || str == "D"){
    cout << str;
    return 0;
  }
  
  for(int i = 0; i < str.size(); i++){
    cnt = 0;
    
    if(str.at(i) == '?'){
      if(i == 0){
        for(int j = i+1; j < str.size(); j++){
          if(str.at(j) == 'D' || str.at(j) == '?'){
            cnt++;
          }else{
            break;
          }
        }
        
        if(cnt >= 2){
          for(int j = i; j < i+cnt; j++){
            str.at(j) = 'D';
          }
          continue;
        }
        
        if(str.at(i+1) == 'P'){
          // ?P -> DP
          str.at(i) = 'D';
        }else if(str.at(i+1) == 'D'){
          // ?D -> PD
          str.at(i) = 'P';
        }else{
          // ?? -> P?
          str.at(i) = 'P';
        }
      }else if(i == str.size()-1){
        if(str.at(i-1) == 'P'){
          // P? -> PD
          str.at(i) = 'D';
        }else if(str.at(i-1) == 'D'){
          // D? -> DD
          str.at(i) = 'D';
        }
      }else{
        for(int j = i+1; j < str.size(); j++){
          if(str.at(j) == 'D' || str.at(j) == '?'){
            cnt++;
          }else{
            break;
          }
        }
        
        if(cnt >= 2){
          for(int j = i; j < i+cnt; j++){
            str.at(j) = 'D';
          }
          continue;
        }
        
        if(str.at(i-1) == 'P'){
          // P? -> PD
          str.at(i) = 'D';
        }else if(str.at(i-1) == 'D'){
          // D? -> DD
          if(str.at(i+1) == 'D'){
            str.at(i) = 'P';
          }else{
             str.at(i) = 'D';
          }
        }else if(str.at(i+1) == 'P'){
          // ?P -> DP
          str.at(i) = 'D';
        }else if(str.at(i+1) == 'D'){
          // ?D -> PD
          str.at(i) = 'P';
        }else{
          // ?? -> P?
          str.at(i) = 'P';
        }
      }
    }
  }

  cout << str;
}


Measured memory_bytes: 3724