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

using namespace std;

int main(int argc, char const *argv[]) {
        string taro, hanako;
        int turn, taro_score = 0, hanako_score = 0;
        cin >> turn;
        for(int i = 0; i < turn; i++) {
                cin >> taro >> hanako;
                if(taro > hanako) taro_score += 3;
                else if(taro < hanako) hanako_score += 3;
                else if(taro == hanako) {
                        taro_score++;
                        hanako_score++;
                }
        }
        cout << taro_score << ' ' << hanako_score << endl;


        return 0;
}



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

int main() {
  string s;
  getline(cin, s);
  for(int i=0; i<s.size(); i++) {
    if(s[i]>='a' && s[i]<='z') s[i]-='a'-'A';
  }

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 1172
package main

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

func popCount(x int) int {
	result := 0
	for x != 0 {
		result += x & 1
		x >>= 1
	}
	return result
}

func f(x int) int {
	if x == 0 {
		return 0
	}
	return 1 + f(x%popCount(x))
}

func main() {
	defer flush()

	N := readInt()
	X := readString()

	c := 0
	for _, b := range []byte(X) {
		if b == '1' {
			c++
		}
	}

	t1, t2 := make([]int, N), make([]int, N)
	t1[0] = 1 % (c + 1)
	if c-1 != 0 {
		t2[0] = 1 % (c - 1)
	}
	for i := 1; i < N; i++ {
		t1[i] = (t1[i-1] << 1) % (c + 1)
		if c-1 != 0 {
			t2[i] = (t2[i-1] << 1) % (c - 1)
		}
	}

	x1, x2 := 0, 0
	for i, b := range []byte(X) {
		if b == '1' {
			x1 += t1[N-1-i]
			if c-1 != 0 {
				x2 += t2[N-1-i]
			}
		}
	}

	for i, b := range []byte(X) {
		if b == '0' {
			n := (x1 + t1[N-1-i]) % (c + 1)
			println(f(n) + 1)
		} else if b == '1' {
			if c-1 == 0 {
				println(0)
				continue
			}
			n := (x2 - t2[N-1-i] + (c - 1)) % (c - 1)
			println(f(n) + 1)
		}
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 7184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<vector<int>> graph(n);
    ll x = 0, y = (n+2) * (n+1) * n / 6;
    rep (i, n - 1) {
        int u, v; cin >> u >> v; 
        if (u > v) swap(u, v);
        x += (ll)u * (n + 1 - v);
        u--; v--;
        graph[u].push_back(v);
    }
    eprintf("%lld %lld\n", x, y);
    cout << y - x << "\n";
    return 0;
}

Measured memory_bytes: 14248
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll INF = 1e18;

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  int a[m], b[m];
  ll c[m];
  REP(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    c[i] = -1 * (c[i] - p);
  }
  ll dist[n];
  REP(i, n) dist[i] = INF;
  dist[0] = 0;
  REP(loop, n - 1) REP(i, m) {
    if (dist[a[i]] == INF) continue;
    if (dist[b[i]] > dist[a[i]] + c[i]) {
      dist[b[i]] = dist[a[i]] + c[i];
    }
  }
  bool negative[n];
  REP(i, n) negative[i] = false;
  REP(loop, n) REP(i, m) {
    if (dist[a[i]] == INF) continue;
    if (dist[b[i]] > dist[a[i]] + c[i]) {
      dist[b[i]] = dist[a[i]] + c[i];
      negative[b[i]] = true;
    }
    if (negative[a[i]]) {
      negative[b[i]] = true;
    }
  }
  if (negative[n - 1]) {
    puts("-1");
  } else {
    cout << max(0ll, -dist[n - 1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int start = sc.nextInt();
    int[] cost = new int[M];
    int  countMin = 0;
    int countMax = 0;
    for (int i = 0; i < M; i++) {
      cost[i] = sc.nextInt();
      if (cost[i] >= start) {
        countMax++;
      } else {
        countMin++;
      } 
    }
    System.out.println(Math.min(countMin, countMax));
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();//赤
		int B = sc.nextInt();//緑
		int C = sc.nextInt();//青

		int K = sc.nextInt();

		sc.close();

		// 処理
		if (C > B && B > A) {
			System.out.print("Yes");
			return;
		}

		for (int i = 0; i < K; i++) {
			if (C > B && B > A) {
				System.out.print("Yes");
				return;
			}
			if (C > B && B <= A) {
				B = 2 * B;
				continue;
			}
			if (C <= B && B > A) {
				C = 2 * C;
				continue;
			}
			if (C <= B && B <= A) {
				B = 2 * B;
				continue;
			}
		}
		if (C > B && B > A) {
			System.out.print("Yes");
			return;
		}

		System.out.print("No");
	}

}


Measured memory_bytes: 35712
//12
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  for(double seq[10];cin>>seq[0];){
    double sum=seq[0];
    for(int i=1;i<10;i++){
      if(i%2!=1){
	seq[i]=seq[i-1]/3;
      }else{
	seq[i]=seq[i-1]*2;
      }
      sum+=seq[i];
    }
    cout<<fixed<<setprecision(6)<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	string s;
	cin >> s;
	string t = s;
	int c = 0; 
	
	
	
	reverse(s.begin(), s.end());
	
	if (s == t)
	{ cout <<"0" <<endl;
	return 0;
	}
	else {
		for (int i = 0; i<t.size(); i++)
		{
			if (s[i]!=t[i]) {
				c++;
			}
		}
	}
	
	cout << c/2 <<endl;	
	
	
	
	
	
	return 0;
}



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 998244353LL;

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<ll> X(M);
  rep(i,M) cin>>X[i];
  priority_queue<ll,vector<ll>,greater<ll>> q;
  sort(X.begin(),X.end());
  rep(i,M-1) q.push(X[i+1]-X[i]);
  ll ans = 0;
  rep(i,M-N){
    ans += q.top();
    q.pop();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5108
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int res;
	if (a >= 13) {
		res = b;
	}
	else if (a >= 6) {
		res = b / 2;
	}
	else {
		res = 0;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }

    ll mx = 0;
    ll ans = 0;
    rep(i, n){
        if(i){
            mx = max(mx, a[i] - a[i-1]);
            ans += a[i]-a[i-1];
        }
    }
    if(a[0]+k-a[n-1] < mx){
        ans -= mx;
        ans += a[0]+k-a[n-1] ;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x>0 && y>0 )
    {if(x+r<=W && y+r<=H)printf("Yes\n");
      else printf("No\n");
    }
  else printf("No\n");
return 0;
}

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if(a.back() == b[0] && b.back() == c[0]) 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<(int)(n); ++i)

const double EPS = 1e-8;
const int INF = 100000000;

using namespace std;

struct Point{
    int x, y, z;
    double dx, dy, dz;
    Point() : x(INF), y(INF), z(INF) {}
    bool operator < (const Point& p) const {
        if(x != p.x) return x < p.x;
        if(y != p.y) return y < p.y;
        return z < p.z;
    }
    bool operator == (const Point& p) const {
        return x == p.x && y == p.y && z == p.z;
    }
};

void produce(int N, int S, int W, vector<Point>& ps){
    int g = S;
    for(int i = 0; i < N; i++){
        Point p;
        p.x = (g/7)    %100 + 1;
        p.y = (g/700)  %100 + 1;
        p.z = (g/70000)%100 + 1;
        if( g%2 == 0 ) { g = (g/2); }
        else           { g = (g/2) ^ W; }
        ps.push_back(p);
    }
}

double dist(double x, double y, double z){
    return sqrt(x * x + y * y + z * z);
}

double dist(const Point& p, const Point& q){
    return dist(p.dx - q.dx, p.dy - q.dy, p.dz - q.dz);
}

void normlize(vector<Point>& ps){
    for(int i = 0; i < ps.size(); i++){
        int x = ps[i].x, y = ps[i].y, z = ps[i].z;
        double l = dist(x, y, z);
        ps[i].dx = 1.0 * x / l;
        ps[i].dy = 1.0 * y / l;
        ps[i].dz = 1.0 * z / l;
    }
}

pair<Point, Point> make(Point a, Point b){
    if(b < a) swap(a, b);
    return make_pair(a, b);
}

void output(pair<Point, Point> p){
    printf("%d %d %d %d %d %d\n", p.first.x, p.first.y, p.first.z, p.second.x, p.second.y, p.second.z);
}

int main(){
    int M, N, S, W;
    while(cin >> M >> N >> S >> W){
        if(M + N < 2) break;

        vector<Point> ps(M);
        REP(i, M){
            cin >> ps[i].x >> ps[i].y >> ps[i].z;
        }
        produce(N, S, W, ps);
        normlize(ps);

        sort(ps.begin(), ps.end(), [](const Point& a, const Point& b){
                if(a.dx != b.dx) return a.dx < b.dx;
                if(a.dy != b.dy) return a.dy < b.dy;
                return a.dz < b.dz;
                });

        double min_dist = 1e16;

        for(int i = 0; i < ps.size(); i++){
            for(int j = i + 1; j < ps.size(); j++){
                if(ps[j].dx - ps[i].dx > min_dist + EPS) break;
                double d = dist(ps[i], ps[j]);
                if(d < EPS) continue;
                min_dist = min(min_dist, d);
            }
        }

        pair<Point, Point> answer = make_pair(Point(), Point());
        for(int i = 0; i < ps.size(); i++){
            for(int j = i + 1; j < ps.size(); j++){
                if(ps[j].dx - ps[i].dx > min_dist + EPS) break;
                double d = dist(ps[i], ps[j]);
                if(d < EPS) continue;
                if(abs(d - min_dist) < EPS){
                    answer = min(answer, make(ps[i], ps[j]));
                }
            }
        }

        assert(answer.first.x < INF);

        output(answer);

    }
    return 0;
}

Measured memory_bytes: 9936
(function(input) {
    var p = input.replace(/\n$/, '').split('\n').map(Number);
    for (var i = 0; i < p.length; i++) {
        var n = p[i];
        var count = 0;
        for (var a = 0; a < 10; a++) {
            //console.log('a = ' + a);
            var sa = n - a;
            if (sa < 0) {
                break;
            }
            for (var b = 0; b < 10; b++) {
                //console.log('b = ' + b);
                var sb = sa - b;
                if (sb < 0) {
                    break;
                }
                for (var c = 0; c < 10; c++) {
                    //console.log('c = ' + c);
                    var sc = sb - c;
                    if (sc < 0) {
                        break;
                    }
                    for (var d = 0; d < 10; d++) {
                        //console.log('d = ' + d);
                        var sd = sc - d;
                        if (sd === 0) {
                            //console.log(a, b, c, d);
                            count++;
                            break;
                        }
                    }
                }
            }
        }
        console.log(count);
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8540
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int dp[3005][3005];
string s ,t;

int solve(int i , int j){

    if(i == s.size() || j == t.size()) return 0; 

    int& ret = dp[i][j];
    if(~ret) return ret;
    //ret =-OO;
    ret = max(solve(i+1 , j) , solve(i , j+1));
    if(s[i] == t[j])
        ret = max(ret , solve(i+1 , j+1)+1);
    return ret;
}

string ans;

void build(int i , int j){

    if(i == s.size() || j == t.size()) return ;
    int& ret = dp[i][j];
    if(ret == solve(i+1 , j)){
        build(i+1, j);
        return ;
    }
    if(ret == solve(i , j+1)){
        build(i, j+1);
        return ;
    }
    if(ret == solve(i+1 , j+1)+1){
        ans += s[i];
        build(i+1 , j+1);
        return;
    }
    return ;
}


    
int main(){
    

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);

    
    cin >> s >> t;
    memset(dp , -1, sizeof dp);
    int tmp = solve(0 , 0);
    build(0 , 0);
    cout << ans << "\n";
    
    
    


    return 0;
}

Measured memory_bytes: 35968
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hs = readLine()!!.split(" ").map { it.toInt() }

    var ans = 1
    for (i in 1 until n) {
        var taller = false
        for (j in 0..i) {
            if (hs[i] < hs[j]) {
                taller = true
                break
            }
        }
        if (!taller) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 36080
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n,res=0;
	cin >> n;
	vector<pair<int,int>> arm(n);
	for(int i=0;i<n;++i){
		int x,l;
		cin >> x >> l;
		arm[i] = make_pair(x+l,x-l);
	}
	sort(arm.begin(),arm.end());
	int min = -1000000000;
	for(int i=0;i<n;++i){
		if(min <= arm[i].second){
			min = arm[i].first;
			res++;
		}
	}
	cout << res << endl;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a+b==c) ||(a==b+c) ||(b==a+c)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int vec[200004],vv[200004];
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N;
  cin >> N;
  for (int X=0; X<N-1; X++){
    cin >> vec[X];
    vv[vec[X]]++;
  }
  for (int X=1; X<=N; X++){
    cout << vv[X] << "\n";
  }
}


Measured memory_bytes: 5184
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()

    ans_list = []
    alpabet = [chr(ord('a') + i) for i in range(26)]

    for al in alpabet:
        if al not in s:
            ans_list.append(al)

    print(ans_list[0] if len(ans_list) > 0 else 'None')

if __name__ == '__main__':
    main()


Measured memory_bytes: 77040
import itertools
import math

l = [int(input()) for i in range(5)]
ans = 999

for i in itertools.permutations(l, 5):
    time = 0
    for j in range(5):
        time += i[j]
        if j != 4:
            time = math.ceil(time / 10) * 10
    ans = (min(ans, time))

print(ans)

Measured memory_bytes: 3060
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
        r: i32
    }
    let ans = r * r;
    println!("{}", ans);
}


Measured memory_bytes: 2148
N, M = map(int, raw_input().split())

A = [[0 for j in range(M)]for i in range(N)]
B = [0 for j in range(M)]
C = [0 for i in range(N)]

# Input
for i in range(N):
    Ai = map(int, raw_input().split())
    for j in range(M):
        A[i][j] = Ai[j]

for j in range(M):
    B[j] = input()

# Calc
for i in range(N):
    for j in range(M):
        C[i] = C[i] + A[i][j]*B[j]

for i in range(N):
    print C[i]

Measured memory_bytes: 6492
/*input

*/
/*
Contest: 
Problem: 
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
#define int long long int
 
const int MOD = 1e9 + 7, MAXN = 410;

int h, w, cnt1, cnt2, cnt = 0;
char grid[MAXN][MAXN];
bool vis[MAXN][MAXN];
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, 1, -1};

bool valid(int x, int y){
	return (x >= 1 and y >= 1 and x <= h and y <= w and !vis[x][y]);
}

void dfs(int x, int y){
	if(grid[x][y] == '#')
		cnt1++;
	else
		cnt2++;
	vis[x][y] = true;
	for(int i = 0; i < 4; i++){
		if(valid(x + dx[i], y + dy[i]) and grid[x][y] != grid[x + dx[i]][y + dy[i]])
			dfs(x + dx[i], y + dy[i]);
	}
}

signed main(){
    
    cin>> h >> w;

    for(int i = 1; i <= h; i++)
    	for(int j = 1; j <= w; j++)
    		cin>> grid[i][j];

    mem(vis, 0);

    for(int i = 1; i <= h; i++){
    	for(int j = 1; j <= w; j++){
    		if(!vis[i][j]){
    			cnt1 = cnt2 = 0;
    			dfs(i, j);
    			cnt += cnt1*cnt2;
    		}

    	}
    }

    cout << cnt << endl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

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

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int MAX = LLONG_MAX / 3;
	if ((a & 1) == 0 || (b & 1) == 0)MAX = 0;
	else {
		MAX = min(MAX, min(a, b)*c);
	}
	if ((b & 1) == 0 || (c & 1) == 0)MAX = 0;
	else {
		MAX = min(MAX, min(b, c)*a);
	}
	if ((a & 1) == 0 || (c & 1) == 0)MAX = 0;
	else {
		MAX = min(MAX, min(a, c)*b);
	}
	cout << MAX << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

l=[]
for i in range(n):
    for j in range(a[i]):
      l.append(i+1)
ans=[]
for i in range(h):
    if i%2==1:
        x=l[i*w:(i+1)*w]
        ans.append(x[::-1])
    else:
        ans.append(l[i*w:(i+1)*w])
for i in range(h):
    print(*ans[i])

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  string s;
  cin >> s;
  rep2(i, 1, s.size()) {
    if (s[i-1] == s[i]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


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

int n, m;

const int limit=50;
int a[limit+1], b[limit+1];
bool graph[limit+1][limit+1];
bool visited[limit+1];

void dfs(int i);
int main(){
  cin >> n >> m;
  for(int i=1; i<=m; i++){
    cin >> a[i] >> b[i];
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }

  int ans=0;

  for(int i=1; i<=m; i++){
    //a[i] to b[i]の枝を削除
    graph[a[i]][b[i]] = false; graph[b[i]][a[i]] = false;

    for(int j=1; j<=n; j++) visited[j]=false;//visitedの初期化

    dfs(1);//頂点1からdfs

    //頂点1からdfsを行なった結果を探索
    for(int j=1; j<=n; j++){
      if(!visited[j]){
        ans++;
        break;
      }
    }

    //削除した枝を戻しておく
    graph[a[i]][b[i]] = true; graph[b[i]][a[i]] = true;
  }

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

void dfs(int i){
  visited[i]=true;
  for(int j=1; j<=n; j++){
    //もし枝が存在しないなら飛ばす
    if(!graph[i][j]) continue;
    //探索ずみなら飛ばす
    if(visited[j]) continue;
    dfs(j);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;

typedef long long ll;

int main(int argc, char **argv)
{
    string S;
    cin >> S;

    int start = 0;
    int end = S.length();
    int len = (end - start) / 2;

    for (int i = start; i < len; ++i) {
        if (S[i] != S[end - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    start = 0;
    end = (S.length() - 1) / 2;
    len = (end -start) / 2;
    for (int i = start; i < len; ++i) {
        if (S[i] != S[end - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    start = ((S.length() + 3) / 2) - 1;
    end = S.length();
    len = (end - start) / 2;
    for (int i = start; i < len; ++i) {
        if (S[i] != S[end - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int N=2333;
int n,ans=0x3f3f3f3f;
char s[N],ss[N];
vector<int>pos;
vector<pair<int,int> >vc;
int main(){
	scanf("%s%s",s+1,ss+1);
	n=strlen(s+1);
	bool ok1=0,ok2=0;
	for(int i=1;i<=n;++i)ok1|=s[i]=='1',ok2|=ss[i]=='1';
	if(!ok2){puts(ok1?"-1":"0");return 0;}
	for(int i=1;i<=n;++i)if(ss[i]=='1')
	pos.push_back(i-n),pos.push_back(i),pos.push_back(i+n);
	sort(pos.begin(),pos.end());
	for(int t=0;t<n;++t){
		vc.clear();
		int tot=0;
		for(int i=1;i<=n;++i)if(s[i]!=ss[(i+t-1)%n+1]){
			++tot;
			int L=*(upper_bound(pos.begin(),pos.end(),i)-1);
			int R=*lower_bound(pos.begin(),pos.end(),i);
			int pre=i+(t-n)%n,nxt=i+t;
			int lft=i-L,rgt=R<=nxt?0:R-nxt;
			vc.emplace_back(lft,rgt);
		}
		sort(vc.begin(),vc.end());
		int mx=0;
		for(int i=vc.size()-1;~i;--i)
		ans=min(ans,tot+2*(mx+vc[i].first)+t),mx=max(mx,vc[i].second);
		ans=min(ans,tot+2*mx+t);
		vc.clear();
		tot=0;
		for(int i=n;i;--i)if(s[i]!=ss[(i-t+n-1)%n+1]){
			++tot;
			int L=*(upper_bound(pos.begin(),pos.end(),i)-1);
			int R=*lower_bound(pos.begin(),pos.end(),i);
			int pre=i-t,nxt=i-(t-n)%n;
			int lft=pre<=L?0:pre-L,rgt=R-i;
			vc.emplace_back(lft,rgt);
		}
		sort(vc.begin(),vc.end());
		mx=0;
		for(int i=vc.size()-1;~i;--i)
		ans=min(ans,tot+2*(mx+vc[i].first)+t),mx=max(mx,vc[i].second);
		ans=min(ans,tot+2*mx+t);
	}
	printf("%d\n",ans);
	return 0;
}

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

template<class M>
struct Treap{
	struct Node{
		M val;
		Node *lch, *rch;
		unsigned long long pri;
		int cnt;
		M sum;
		Node(){}
		Node(M v, unsigned long long p): val(v), pri(p), cnt(1), sum(v){
			lch = rch = (Node *)NULL;
		}
	};

	M def;
	using F = function<M(M, M)>;
	F add;

	Node *root = NULL;
	vector<Node> node;


	Treap (int n, M d, const F f): node(n), def(d), add(f){}

	int count(Node *t){ return !t ? 0 : t->cnt;}
	M sum(Node *t){ return !t ? def : t->sum;}

	unsigned long long xor128(){
		static unsigned long long x=123456789, y=362436069, z=521288629, w=88675123;
  		unsigned long long t=(x^(x<<11));
  		x=y; y=z; z=w;
  		return ( w=(w^(w>>19))^(t^(t>>8)) );
	}

	Node *getNewNode(M v){
		static int i = 0;
		node[i] = Node(v, xor128());
		return &(node[i++]); 
	}

	Node *update(Node *t){
		t->cnt = count(t->lch) + 1 + count(t->rch);
		t->sum = add(add(sum(t->lch), t->val), sum(t->rch)) ;
		return t;
	}

	Node *merge(Node *l, Node *r){
		if(!l || !r) return !l ? r : l;
		if(l->pri > r->pri){
			l->rch = merge(l->rch, r);
			return update(l);
		}else{
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}

	pair<Node*, Node*> split(Node *t, int k){
		if(!t) return make_pair((Node *)NULL, (Node *)NULL);
		if(k <= count(t->lch)){
			auto s = split(t->lch, k);
			t->lch = s.second;
			return make_pair(s.first, update(t));
		}else{
			auto s = split(t->rch, k-count(t->lch)-1);
			t->rch = s.first;
			return make_pair(update(t), s.second);
		}
	}

	void insert(int k, M val){
		auto t1 = split(root, k);
		auto nd = getNewNode(val);
		root = merge(merge(t1.first, nd), t1.second);
	}

	void erase(int k, M val){
		auto t1 = split(root, k);
		auto t2 = split(t1.second, 1);
		root = merge(t1.first, t2.second);
	}
	
	void update(int k, M val){
		auto t1 = split(root, k);
		auto t2 = split(t1.second, 1);
		t2.first->val = t2.first->sum = val; 
		root = merge(t1.first, merge(t2.first, t2.second));
	}

	M get(int l, int r){
		auto t1 = split(root, l);
		auto t2 = split(t1.second, r-l);
		M ret = sum(t2.first);
		root = merge(t1.first, merge(t2.first, t2.second));
		return ret;
	}
};

int main(){
	int n, q;
	cin >> n >> q;
	Treap<int> tree(n, INT_MAX, [](int a, int b){ return min(a, b);});
	for(int i = 0;i < n;i++) tree.insert(i, INT_MAX);
	while(q--){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			tree.update(x, y);
		}else{
			cout << tree.get(x, y+1) << endl;
		}
	}

	return 0;

}



Measured memory_bytes: 6760
N,A,B = map(int,input().split())


if (A-B)%2 == 0:
    print(abs(A-B)//2)
else:
    a = abs(A+B-1)//2 ##壁にぶつからない 
    b = abs(2*N-A-B+1)//2 ##壁にぶつかる
 
    print(min(a,b))

Measured memory_bytes: 2940
/*twitter:@chigaphys
  atcoder:chiga
  所属:久留米大学附設中学校
  color:gray*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,r;
  cin>>n>>r;
  int k=max(10-n,0);
  cout<<r+100*k<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
#define inf 0x3f3f3f3f
#define eps 1e-6


int main()
{
	double a,b,c;
	ll x,y;
	cin>>a>>b>>c>>x>>y;
	double p=a/2+b/2;
	ll ans=0;
	if(p>c)
	{
		ans+=min(x,y)*2*c;
		ll q=min(x,y); 
		x-=q;
		y-=q;
		//cout<<x<<"　"<<y<<endl;
	//	cout<<ans<<endl;
		ans+=x*min(a,2*c);
		ans+=y*min(b,2*c);
	}
	else
	{
		ans=a*x+b*y;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	char c[n];
	rep(i,n){
		cin>>c[i];
	}
	int ans=1;
	char last=c[0];
	rep(i,n){
		if(c[i]!=last){
			ans++;
			last=c[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	int min = Integer.MAX_VALUE;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		for (int i=0;i<M;i++) {
			int a= sc.nextInt();
			N-=a;
		}
		if (N<0) {
			System.out.println(-1);
			return;
		}
		System.out.println(N);
	}

}

Measured memory_bytes: 46376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    string str;
    cin >> str;

    for (int bit = 0; bit < 8; bit++)
    {
        ll sum = 0;
        sum += str[0] - '0';
        string ans = "";
        ans += str[0];
        for (int i = 0; i < 3; i++)
        {
            if (bit & (1 << i))
            {
                sum += str[i + 1] - '0';
                ans += '+';
                ans += str[i + 1];
            }
            else
            {
                sum -= str[i + 1] - '0';
                ans += '-';
                ans += str[i + 1];
            }
        }

        if (sum == 7)
        {
            cout << ans << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
p = [int(num) for num in input().split(" ")]
counter = 0
for i in range(N-2):
  if (p[i] < p[i+1] < p[i+2]) or (p[i+2] < p[i+1] < p[i]):
    counter	+= 1

print(counter)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll H, W;
  cin >> H >> W;
  if(H==1 or W==1){
    cout << 1;
  }else{
    ll a=(H+1)/2;
    ll b=(W+1)/2;
    ll c=H/2;
    ll d=W/2;
    cout << a*b + c*d;
  }
  return 0;
}


Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
using namespace std;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a

long long arr[500005];

int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0;
    cin>>m>>n;
    p=0;
    for(i=0; i<n; i++)
    {
        cin>>k;
        p+=k;
    }
    if(p<m)
    cout<<"No"<<endl;
    else cout<<"Yes\n";



    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
#include <random>
#include <cassert>
#include <sstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ln(i, n) " \n"[i == n]
typedef long long LL;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
//////////////////////
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const LL  INFF = (LL)1e15;
const int mod = 998244353;
const int MXN = (int)1e2 + 7;
int main(){
	int n, a, b; scanf("%d %d %d", &n, &a, &b);
	int v1 = min(a, b);
	int v2 = a + b >= n ? a + b - n : 0;
	printf("%d %d\n", v1, v2);
	return 0;
}


Measured memory_bytes: 764
INF = 10**18

def main():

    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    ch, cw = ch-1, cw-1
    dh, dw = dh-1, dw-1
    #M = [list(str(input())) for _ in range(h)]

    M = [str(input()) for _ in range(h)]
    #M = ['#'*w] + M + ['#'*w]
    #M = ['#'+c+'#' for c in M]

    from collections import deque
    q = deque()
    q.append((ch, cw))

    visit = [[-1]*w for _ in range(h)]
    visit[ch][cw] = 0
    C = [[INF]*w for _ in range(h)]
    C[ch][cw] = 0

    import itertools
    cnt = 0
    while q:
        y, x = q.popleft()
        #if y == dh and x == dw:
            #break
        for dy, dx in (-1, 0), (1, 0), (0, -1), (0, 1):
            ny, nx = y+dy, x+dx
            if 0 <= ny < h and 0 <= nx < w:
                #C[ny][nx] = min(C[y][x], C[ny][nx])
                if C[ny][nx] != C[y][x] and M[ny][nx] != '#':
                    visit[ny][nx] = visit[y][x]
                    C[ny][nx] = min(C[y][x], C[ny][nx])
                    q.appendleft((ny, nx))
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                if dy == 0 and dx == 0:
                    continue
                ny, nx = y+dy, x+dx
                if 0 <= ny < h and 0 <= nx < w:
                    #C[ny][nx] = min(C[y][x]+1, C[ny][nx])
                    if visit[ny][nx] == -1 and M[ny][nx] != '#':
                        visit[ny][nx] = visit[y][x]
                        C[ny][nx] = min(C[y][x]+1, C[ny][nx])
                        q.append((ny, nx))
    #print(visit)
    #print(C)
    if visit[dh][dw] == -1:
        print(-1)
    else:
        print(C[dh][dw])

if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[]){
	int num1, num2;
	scanf("%d %d", &num1, &num2);
	if((num1*num2)%2 != 0){
		printf("Odd\n");
	} else {
		printf("Even\n");
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int ans= 30; // 2^30 > 10^9
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    
    int cnt= 0;
  	while( A%2==0 && cnt<ans ){
      A /= 2;
      cnt++;
    }
    ans= cnt;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  
  int N =0;
  std::string S;
  
  std::cin >> N >> S;
  
  // 一つ目の条件が当てはまるものを数える
  long long R = 0;
  long long G = 0;
  long long B = 0;
  for(char c : S){
    if(c == 'R'){
      R++;
    }
    else if(c == 'G'){
      G++;
    }
    else{
      B++;
    }
  }
  long long first_sum = R*G*B;
  
  // 二つ目の対象に当てはまらないものを数える
  long long second_sum = 0;
  
  if( 3 <= N ){
    for(int i = 0; i < N-2; i++){
      for(int j = i+1; j < N-1; j++){
        int k = 2*j-i;
        if( N <= k ){
          continue;
        }
        else if(S.at(i) != S.at(j)){
          if(S.at(i) != S.at(k)){
            if(S.at(j) != S.at(k)){
              second_sum++;
            }
          }
        }
      }
    }
  }
  
  std::cout << first_sum-second_sum << std::endl;
  
  return 0;
}

Measured memory_bytes: 3652
# https://atcoder.jp/contests/abc090/tasks/arc091_b

import itertools
import collections
import bisect


def main():
    N, K = map(int, input().split())
    ans = 0
    for b in range(K+1, N+1):
        p = N // b
        r = N - b * p
        tmp = p * (b - K) + (max(0, r - K + 1) if K != 0 else max(0, r - K))  # 該当する部分をまとめて計算する
        # print("b = {}, c = {}, p = {}, tmp = {}".format(b, b - K, p, tmp))
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main(){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);

  if(A <= C && C <= B) puts("Yes");
  else puts("No");

  return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    b = LI()
    need = 0
    ans = 0
    surplus = []
    for i in range(n):
        if a[i]>=b[i]:
            surplus.append(a[i]-b[i])
        else:
            need += b[i] - a[i]
            ans += 1
    
    surplus.sort(reverse=True)

    if need <= 0:
        print(0)
        exit(0)
    else:
        for r in surplus:
            need -= r
            ans += 1
            if need <= 0:
                print(ans)
                exit(0)
        
        print(-1)
main()


Measured memory_bytes: 97176
import math
import os
import sys


def kochCurve(depth, p0, p1):

    if depth == 0:
        return

    sx = 2 / 3 * p0[0] + 1 / 3 * p1[0]
    sy = 2 / 3 * p0[1] + 1 / 3 * p1[1]
    s = (sx, sy)

    tx = 1 / 3 * p0[0] + 2 / 3 * p1[0]
    ty = 1 / 3 * p0[1] + 2 / 3 * p1[1]
    t = (tx, ty)

    angle = math.radians(60)

    ux = math.cos(angle) * (tx - sx) - math.sin(angle) * (ty - sy) + sx
    uy = math.sin(angle) * (tx - sx) + math.cos(angle) * (ty - sy) + sy
    u = (ux, uy)

    kochCurve(depth - 1, p0, s)
    print(*s)
    kochCurve(depth - 1, s, u)
    print(*u)
    kochCurve(depth - 1, u, t)
    print(*t)
    kochCurve(depth - 1, t, p1)


n = int(input())
p0 = (0, 0)
p1 = (100, 0)

print(*p0)
kochCurve(n, p0, p1)
print(*p1)



Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string S; cin >> S; 
	int sum = 0; 
	for(auto c : S){
		sum += c - '0'; 
	}
	if(sum % 9 == 0) cout << "Yes" << "\n"; 
	else cout << "No" << "\n"; 
}

Measured memory_bytes: 3700
n = int(input())
a = list(map(int, input().split()))
if len(a) == 1:
    res = a[0]
elif len(a) % 2 == 0:
    res = " ".join(map(str, a[-1::-2] + a[::2]))
else:
    res = " ".join(map(str, a[-1::-2] + a[1::2]))
print(res)

Measured memory_bytes: 27936
N = int(input())
p = [i for i in map(float, input().split(" "))]

dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1.0
for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1.0-p[i])

res = 0.0
for i in range(N//2+1, N+1):
    res += dp[N][i]
print("{:.10f}".format(res))

Measured memory_bytes: 253960
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("Yes\n")
#define ptn printf("No\n")
//==========================Code here==========================
char s[10];
int main() {
	cin >> s;
	sort(s, s + 4);
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) pty; else ptn;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main()
{	
	int N, T, A;
	cin >> N;
	cin >> T >>A;

	int h[1005] = {};
	double tem[1005] = {};
	double ans[2] = {100000,-1};
	rep(i, N) {
		cin >> h[i];
	
		tem[i] = T - h[i] * 0.006;
	}

	rep(i, N) {
		if (abs(A - tem[i]) < ans[0]) {
			ans[0] = abs(A - tem[i]);
			ans[1] = i;
		}


		//cout << tem[i] << " " << ans[0] <<" "  <<ans[1]<<endl;
	}


	cout << ans[1] + 1 <<endl;
}


Measured memory_bytes: 256
#!/usr/bin/perl
use Data::Dumper;
my ($h,$w,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);

if( $w == 1 ){
  print "1\n"; exit(0);
}

my @p = ();
$#p = 7;
my $w1 = 2 ** ($w-1);
for(my $i=0;$i<$w1;$i++){
  my $p = unpack('B8',pack('C',$i));
  substr($p,0,9-$w) = '';
  next unless index($p,'11') < 0;
  for(my $j=0;$j<$w;$j++){
    if( $j > 0 and substr($p,$j-1,1) eq '1' ){
      $p[$j]->[$j-1] ++;
    }
    if( $j < $w-1 and substr($p,$j,1) eq '1' ){
      $p[$j]->[$j+1] ++;
    }
    if( ($j==0 and substr($p,$j,1) ne '1') or ($j==$w-1 and substr($p,$j-1,1) ne '1') or ( substr($p,$j,1) ne '1' and substr($p,$j-1,1) ne '1' ) ){
      $p[$j]->[$j] ++;
    }
  }
}

#print &Dumper(\@p);

my @r = ();
$#r = 7;

$r[0]=1;

for(my $i=0;$i<$h;$i++){
  my @n = ();
  $#n = $#r;
  for($j=0;$j<$w;$j++){
    my $t = 0;
    for(my $k=0;$k<$w;$k++){
      $t += &f($r[$k] * $p[$k]->[$j]);
    }
    $n[$j] = &f($t);
  }
  @r = (@n);
}
print "$r[$k-1]\n";

exit(0);
sub f {
  my $v = shift;
  return $v % 1000000007;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
unsigned long long int ull;
vector<int>adj[200105];
int visited[200105];
//int b[1000000];
//ll cnt,n,d;
#define mod 1000000007

void solve()
{
 
 int  k;
 cin>>k;
 int y;
 ll sum=0,cnt=0;
 for(int i=1;i<=k;i++)
 {
     for(int j=1;j<=k;j++)
     for(int l=1;l<=k;l++)
     sum+=__gcd(i,__gcd(j,l));
 }
 
 cout<<sum;
}
int main()
{
//int t;cin>>t;while(t--)
  solve();
  return 0;
}

Measured memory_bytes: 8304
#include <stdio.h>

int main(int argc, const char * argv[])
{

    double ax, by, c, dx, ey, f;
    double x, y;
    
    while (scanf("%lf %lf %lf %lf %lf %lf", &ax, &by, &c, &dx, &ey, &f) != EOF) {
        y = (c * dx - ax * f) / (by * dx - ax * ey);
        x = (c - by * y) / ax;
        printf("%.3lf %.3lf\n", x, y);
    }
    
    return 0;
}

Measured memory_bytes: 652