akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut ws = buf.split_whitespace();
    let r: usize = ws.next().unwrap().parse().unwrap();
    let c: usize = ws.next().unwrap().parse().unwrap();

    let mut mat: Vec<Vec<i32>> = vec![vec![0; c+1]; r+1];

    for i in 0..r {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        for (j, v) in buf.split_whitespace().enumerate() {
            let d: i32 = v.parse().unwrap();
            mat[i][j] = d;
            mat[r][j] += d;
            mat[i][c] += d;
            mat[r][c] += d;
        }
    }

    for i in 0..r+1 {
        for j in 0..c+1 {
            print!("{}", mat[i][j]);
            if j!=c {
                print!(" ");
            }
        }
        println!("");
    }
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int each(int n){
	int res = 0;
	int n1 = n;
	while(n1){
		res += n1 % 10;
		n1 /= 10;
	}
	return res;
}
int32_t main(){ fast;
	int n, a, b; cin>>n>>a>>b;
	int ans = 0;
	for(int mask = 1; mask <= n; mask++){
		int t = each(mask);
		if(t >= a && t <= b){
			ans += mask;
		}
	}
	cout<<ans<<endl;
}


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

int main(){
	int a;
	cin>>a;
	int c=0;
	for(int i=0;i<a;i++){
		int b[100];
		cin>>b[i];
		if(b[i]%2==0){
			c++;
		}
		
	}
	cout<<c<<endl;
}


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

using namespace std;

typedef long long ll;

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


  int n, x;
  ll c = 0, s = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 0) {
      s += c / 2;
      c = 0;
    } else {
      c += x;
    }
  }
  s += c / 2;
  cout << s << "\n";
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
std::random_device rnd_dev;
std::mt19937 rnd(rnd_dev() ^ time(NULL));

std::vector<int> init(int n, const std::vector<int> &c, const std::vector<std::vector<int> > &val) {
	(void) val;
	double par[26];
	for (int i = 0; i < 26; i++) par[i] = std::sqrt(c[i]);
	double sum = std::accumulate(par, par + 26, 0.0);
	int times[26];
	double acc = 0;
	for (int i = 0; i < 26; i++) {
		acc += par[i];
		times[i] = (acc + 0.00001) / sum * n;
	}
	for (int i = 25; i--; ) times[i + 1] -= times[i];
	// for (auto &i : times) i--;
	//for (auto i : times) std::cerr << i << std::endl;
	std::vector<int> res;
	for (int i = 0; i < 26; i++) for (int j = 0; j < times[i]; j++) res.push_back(i);
	std::shuffle(res.begin(), res.end(), rnd);
	assert(res.size() == n);
	return res;
}


std::vector<int> solve(int n, const std::vector<int> &c, const std::vector<std::vector<int> > &val) {
	auto score = [&] (const std::vector<int> &all) {
		int last[26];
		for (auto &i : last) i = -1;
		int res = 0;
		for (int i = 0; i < n; i++) {
			int cur = all[i];
			last[cur] = i;
			for (int j = 0; j < 26; j++) res -= c[j] * (i - last[j]);
			res += val[i][cur];
		}
		return res;
	};
	clock_t start = clock();
	
	auto r26 = init(n, c, val);
	
	std::vector<int> cur = r26;
	int cur_score = score(cur);
	int best_score = -1000000000;
	std::vector<int> best;
	
	while (1) {
		clock_t cur_time = clock();
		if (cur_time - start > 1.95 * CLOCKS_PER_SEC) break;
		int r0 = std::uniform_int_distribution<>(0, n - 1)(rnd);
		int r1 = std::uniform_int_distribution<>(0, n - 1)(rnd);
		std::swap(cur[r0], cur[r1]);
		double threshold = 1.95 - (double) (cur_time - start) / CLOCKS_PER_SEC;
		// std::cerr << threshold << std::endl;
		int new_score = score(cur);
		if (new_score > best_score * (1 - threshold * 0.01)) cur_score = new_score;
		else std::swap(cur[r0], cur[r1]);
		if (best_score < cur_score) best_score = cur_score, best = cur;
	}
	
	return best;
}

void input() {
	int n = ri();
	std::vector<int> c(26);
	for (auto &i : c) i = ri();
	std::vector<std::vector<int> > val(n, std::vector<int>(26));
	for (auto &i : val) for (auto &j : i) j = ri();
	for (auto i : solve(n, c, val)) printf("%d\n", i + 1);
}

void random_test() {
	int n = 365;
	std::vector<int> c(26);
	for (auto &i : c) i = std::uniform_int_distribution<>(0, 100)(rnd);
	std::vector<std::vector<int> > val(n, std::vector<int>(26));
	for (auto &i : val) for (auto &j : i) j = std::uniform_int_distribution<>(0, 20000)(rnd);
	
	auto res = solve(n, c, val);
	
	
	int last[26];
	for (auto &i : last) i = -1;
	int score = 0;
	for (int i = 0; i < n; i++) {
		last[res[i]] = i;
		for (int j = 0; j < 26; j++) score -= c[j] * (i - last[j]);
		score += val[i][res[i]];
	}
	printf("%d\n", score);
}

int main() {
#	ifdef LOCAL
	random_test();
#	else
	input();
#	endif
	return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 dy[6] = {0, 1, 1, 0, -1, -1};
int64 dx[6] = {1, 1, 0, -1, -1, 0};

int main(void) {
  int64 t, n;
  while (cin >> t >> n && t+n) {
    vector<vector<int>> obj(200, vector<int>(200, 0));
    REP(i, n) {
      int64 x, y;
      cin >> x >> y; y += 100; x += 100;
      obj[y][x] = 1;
    }
    vector<vector<int>> d(200, vector<int>(200, INF));
    queue<PII> q;
    int64 sy, sx;
    cin >> sx >> sy;
    int64 res = 0;
    q.emplace(100+sy, 100+sx);
    d[sy+100][sx+100] = 0;
    while (q.size()) {
      int64 y, x;
      tie(y, x) = q.front(); q.pop();
      if (obj[y][x]) continue;
      res++;
      obj[y][x] = 1;
      if (d[y][x] >= t) continue;
      REP(k, 6) {
        int64 yy = y + dy[k], xx = x + dx[k];
//        cout << yy << " " << xx << " " << obj[yy][xx] << endl;
        if (obj[yy][xx]) continue;
        chmin(d[yy][xx], d[y][x] + 1);
        q.emplace(yy, xx);
      }
    }
    cout << res << endl;
  }
}



Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        String s = in.next();

        int total = 0;
        int oversea = 0;
        for (int i = 0; i < n; i++) {
            switch (s.charAt(i)) {
                case 'a':
                    if (total < a + b) {
                        total++;
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    break;
                case 'b':
                    if (total < a + b && oversea < b) {
                        total++;
                        oversea++;
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                    break;
                case 'c':
                    System.out.println("No");
                    break;
            }
        }
    }
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

ll n;
ll a[100005];
ll dp[100005];

ll func(ll i) {
	if (i <= 1) {
		return 0;
	}
	if (i == 2) {
		dp[i] = abs(a[2] - a[1]);
		return dp[i];
	}
	if (dp[i] != -1) {
		return dp[i];
	}
	dp[i] = min(func(i - 1) + abs(a[i] - a[i - 1]),  func(i - 2) + abs(a[i] - a[i - 2]));
	return dp[i];
}

void solve() {
	cin >> n;
	rep(i, n) {
		cin >> a[i + 1];
	}
	mem(dp, -1);
	cout << func(n);

}

int main() {
	IOS;
	//io_set();
	ll tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3328
import math

A,B,H,M=map(int,input().split())

long_degree=(math.pi/30*(60*H+M))%(2*math.pi)
short_degree=(math.pi/360*(60*H+M))%(2*math.pi)

degree=long_degree-short_degree
C=math.sqrt(A*A+B*B-2*A*B*math.cos(degree))

print(C)

Measured memory_bytes: 9432
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


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


class Main {
	private static	int num;
	private static	card[]  array;
	
	public static void main(String args[]) {
		//実行処理
		try {
			run();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
	
	//実質メイン
	public static void run() throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		num = Integer.parseInt(br.readLine());
		array = new card[num];
		//配列作成
		for (int i = 0;i < num;i ++){
            String[] ope = br.readLine().split(" ");
            array[i] = new card(ope[0],Integer.parseInt(ope[1]),i);
        }
		//ソート処理
		quicksort(0, num - 1 );
		//出力
		String message = "Stable";
        for (int i = 0; i < num - 1; i ++){
            if(array[i].num == array[i+1].num && array[i].index > array[i + 1].index){
                message = "Not stable";
                break;
            }
        }
		System.out.println(message);
		output();
		//後処理
		br.close();
	}
	
	//クイックソート
	public static void quicksort(int par, int rim){
		int q;
		if ( par < rim ){
			q = partition(par, rim);
			quicksort(par, q - 1);
			quicksort(q + 1, rim);
		}
	}
	
	//パーティション
	public static int partition(int par,int rim){
		card work;
		int x = array[rim].num;
		int i = par - 1;
		//ソート処理
		for (int j = par ; j < rim ; j ++ ){
			if ( array[j].num <= x ) {
				work = array[++i];
				array[i] = array[j];
				array[j] = work;
			}
		}
		//最後に入れ替え
		work = array[++i];
		array[i] = array[rim];
		array[rim] = work;
		return i;
	}
	
	//出力
	public static void output(){
		StringBuilder sb = new StringBuilder("");
		for (int i = 0; i < num; i++) {
			sb.append(array[i].mark).append(" " + array[i].num).append("\n"); 
		}
		System.out.print(sb);
	}
	
}
//class宣言
class card{
    String mark;
    int num,index;
    public card(String mark,int num,int index){
        this.mark = mark;
        this.num = num;
        this.index = index;
	}
}


Measured memory_bytes: 71192
N = int(input())

A = [0] * (N+1)

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      wk = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if wk <= N:
        A[wk] += 1
        
for i in range(1,N+1):
  print(A[i])

Measured memory_bytes: 9136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

vector<int> Prime(100, 1);  // Prime[i] : iが素数のとき1、iが素数でないとき0

void Eratosthenes(int n) {  // n未満の素数を求める

    Prime[0] = Prime[1] = 0;
    for(int i = 2; i*i < n; i++) {
        if(Prime[i]) {
            for(int j = 2; i*j < n; j++) {
                Prime[i*j] = 0;
            }
        }
    }
}

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

    Eratosthenes(100);

    vector<int> e(100);  // e[i] : n!を素因数分解したときの素因数iの指数(iが素数でないとき0)
    for(int i = 2; i <= n; i++) {
        int a = i;
        for(int j = 2; j*j <= i; j++) {
            if(Prime[j]) {
                while(a%j == 0) {
                    a /= j;
                    e[j]++;
                }
            }
        }
        if(a != 1) {
            e[a]++;
        }
    }

    // p^74パターン
    int cnt1 = 0;
    for(int p = 2; p < 100; p++) {
        if(e[p] >= 74) {
            cnt1++;
        }
    }

    // p^24*q^2パターンとp^14*q^4パターン
    int cnt2 = 0, cnt3 = 0;
    for(int p = 2; p < 100; p++) {
        for(int q = 2; q < 100; q++) {

            if(p == q) {
                continue;
            }

            if(e[p] >= 24 && e[q] >= 2) {
                cnt2++;
            }

            if(e[p] >= 14 && e[q] >= 4) {
                cnt3++;
            }
        }
    }

    // p^4*q^4*r^2パターン
    int cnt4 = 0;
    for(int p = 2; p < 100; p++) {
        for(int q = 2; q < 100; q++) {
            for(int r = 2; r < 100; r++) {

                if(p == q || p == r || q == r) {
                    continue;
                }

                if(e[p] >= 4 && e[q] >= 4 && e[r] >= 2) {
                    cnt4++;
                }
            }
        }
    }
    cnt4 /= 2;  // pとqを入れ替えても同じ数になるのでその分を2で割る

    int ans = cnt1 + cnt2 + cnt3 + cnt4;

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

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

using namespace std;

int main()
{
	int n,m,i,j,ss,ans;
	vector<int> num;
	
	for(;;)
	{
		cin >> n >> m ;
		
		if(n==0 && m==0)
			break;
		
		num.clear();
		ss=0;
		
		for(i=0;i<n;i++)
		{
			int a;
			cin >> a ;
			num.push_back(a);
		}
		
		for(i=0;i<m;i++)
		{
			ss+=num[i];
		}
		
		ans=ss;
		m--;
		
		for(i=1;i<n-m;i++)
		{
			ss-=num[i-1];
			ss+=num[i+m];
			if(ans<ss)
			{
				ans=ss;
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<62)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int mp[55][55];

int main(void){
	int n,k,i,j,p,q;
	ll xi,yi,ans=INFLL;
	vector<P> v;
	vector<ll> x,y;
	fill(mp[0],mp[55],0);
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> xi >> yi;
		v.push_back(P(xi,yi));
		x.push_back(xi);
		y.push_back(yi);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for(i=0; i<n; ++i){
		xi = v[i].first;
		yi = v[i].second;
 		for(p=0; p<n; ++p){
			if(xi == x[p]){
				break;
			}
		}
 		for(q=0; q<n; ++q){
			if(yi == y[q]){
				break;
			}
		}
		++mp[p+1][q+1];
	}
	for(i=0; i<=n; ++i){
		for(j=1; j<=n; ++j){
			mp[i][j] += mp[i][j-1];
		}
	}
	for(j=0; j<=n; ++j){
		for(i=1; i<=n; ++i){
			mp[i][j] += mp[i-1][j];
		}
	}
	for(i=0; i<n; ++i){
		for(j=i; j<n; ++j){
			for(p=0; p<n; ++p){
				for(q=p; q<n; ++q){
					if(mp[j+1][q+1]-mp[i][q+1]-mp[j+1][p]+mp[i][p] < k){
						continue;
					}
					ans = min(ans,(x[j]-x[i])*(y[q]-y[p]));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
X=tx-sx
Y=ty-sy

print("U"*Y + "R"*X + "D"*Y + "L"*X + "L" + "U"*(Y+1) + "R"*(X+1) + "DR" +"D"*(Y+1) + "L"*(X+1) + "U")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 20;
vector<int> honest[N], unkind[N];

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; ++i) {
		int a; cin >> a;
		for(int j=0; j<a; ++j) {
			int x, y;
			cin >> x >> y;
			--x;
			if(y)
				honest[i].push_back(x);
			else
				unkind[i].push_back(x);
		}
	}
	int res = 0;
	for(int b=0; b<(1<<n); ++b) {
		vector<int> sub;
		for(int i=0; i<n; ++i) {
			if(b & (1 << i)) {
				sub.push_back(i);
			}
		}
		map<int, int> honest_;
		for(int x: sub) {
			honest_[x] = 1;
		}
		int flag = 0;
		for(int x: sub) {
			for(int h: honest[x]) {
				if(honest_[h] == 0) {
					flag = 1;
					break;
				} 
			}
			for(int u: unkind[x]) {
				if(honest_[u]) {
					flag = 1;
					break;
				}
			}
			if(flag) break;
		}
		if(!flag)
			res = max(res, (int)sub.size());
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	
	vector<string> s(H), t(H);
	for (int i = 0; i < H; i++) cin >> s[i];

	int num_of_K = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') num_of_K++;
		}
	}

	int count = 0;

	for (int bit1 = 0; bit1 < (1 << H); bit1++) {
		for (int bit2 = 0; bit2 < (1 << W); bit2++) {
			int temp = num_of_K;
			t = s;
			for (int i = 0; i < H; i++) {
				if (bit1 & (1 << i)) {
					for (int j = 0; j < W; j++) {
						if (t[i][j] == '#') temp--;
						t[i][j] = 'r';
					}
				}
			}
			for (int j = 0; j < W; j++) {
				if (bit2 & (1 << j)) {
					for (int i = 0; i < H; i++) {
						if (t[i][j] == '#') temp--;
						t[i][j] = 'r';
					}
				}
			}
			if (temp == K) count++;
		}
	}

	cout << count << endl;

	return 0;
}


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

int solve(int n, int k, int h[]){
  long long int dp[n];
  fill(dp, dp + n, 1000000000);
  dp[0] = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j <= i + k && j < n; ++j){
      dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
    }
  }
  return dp[n-1];
}


int main(){
  int n, k;
  cin >> n >> k;
  int hs[n];
  for(int i = 0; i < n; ++i){
    cin >> hs[i];
  }
  cout << solve(n, k, hs) << endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int[] dice = new int[6];
	int[] temp = new int[4];
	int[] num = new int[4];
	
	void change() {
		for (int i = 0; i < 4; i++)
			temp[i] = dice[num[i]];
		for (int i = 0; i < 4; i++)
			dice[num[i]] = temp[(i+1)%4];
	}
	
	void run() {
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			dice[0] = 1; dice[1] = 2;dice[2] = 3; dice[3] = 5; dice[4] = 4; dice[5] = 6;
			String s;
			int res = 1;
			for (int i = 0; i < n; i++) {
				s = sc.next();
				switch (s.charAt(0)) {
				case 'N':
					num[0] = 0; num[1] = 1; num[2] = 5; num[3] = 3;
					break;
				case 'E':
					num[0] = 0; num[1] = 4; num[2] = 5; num[3] = 2;
					break;
				case 'W':
					num[0] = 0; num[1] = 2; num[2] = 5; num[3] = 4;
					break;
				case 'S':
					num[0] = 0; num[1] = 3; num[2] = 5; num[3] = 1;
					break;
				case 'R':
					num[0] = 1; num[1] = 2; num[2] = 3; num[3] = 4;
					break;
				case 'L':
					num[0] = 1; num[1] = 4; num[2] = 3; num[3] = 2;
					break;
				}
				change();
				res += dice[0];
			}
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 25600
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){

int a=0,b=0,d=0,r=0;    /*?????°?????????*/
double f=0;

cin >> a >> b;      /*??????????????????????????\???*/

d=a/b;        /*???*/
r=a%b;        /*??????*/
f=1.0*a/b;    /*???????°???°???????????????*/

cout << d << " " << r << " " << fixed << setprecision(8) << f << endl;
/* fixed << setprecision(8)??§???????°???°???????±????*/ 

return 0;

}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	vi a(n);
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll op=0;op<min(60LL ,k);op++){
		vi b(n,0);
		for(ll i=0;i<n;i++){
			ll l= max(0LL, i-a[i]);
			ll r = min(n-1,i+a[i]);
			b[l]++;
			if(r+1<n) b[r+1]--;
		}
		for(ll i=1;i<n;i++) b[i]+=b[i-1];
		
		a=b;
	}
	for(ll i=0;i<n;i++) cout<<a[i]<<" ";
	
	
	
	return 0;
}

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

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> a(m), b(m);
  for (auto& x : b) cin >> x;
  int ans = 0;
  rep(i, n) {
    for (auto& x : a) cin >> x;
    int v = 0;
    rep(j, m) v += a[j] * b[j];
    ans += v + c > 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<pair<string, int>> v(N);
    for(auto &x : v) {
        cin >> x.first >> x.second;
    }
    string s;
    cin >> s;
    int ans = 0;
    bool flag = false;
    for(int i = 0; i < N; i++) {
        if(flag) {
            ans += v[i].second;
        }
        if(v[i].first == s) {
            flag = true;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys


def main():
    n, m = map(int, sys.stdin.readline().split())
    matrix = []
    for i in range(n):
        matrix.append(list(map(int, sys.stdin.readline().split())))
    vector = []
    for i in range(m):
        vector.append(int(sys.stdin.readline()))
    product = [0] * n
    for i in range(n):
        for j in range(m):
            product[i] += matrix[i][j] * vector[j]
    for i in product:
        print(i)
    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 6004
#キューを使っている。ところどころマイナスにしているのはキューの性質のため。実行時間が全然違うのはソートが早いから
n,m = map(int,input().split())
a = list(map(lambda x: -int(x) ,input().split()))

import heapq
heapq.heapify(a)
for _ in range(m):
  tmp = -heapq.heappop(a)
  tmp //= 2
  heapq.heappush(a,-tmp)
print(-sum(a))

Measured memory_bytes: 14224
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    P = LI()
    ans = 0
    min = N+1

    for i in range(N):
        if P[i]<min:
            ans += 1
            min = P[i]

    print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> count(n, 0);
  for (int i = 1; i <= n; i++)
  {
    int temp = i;
    while (1)
    {
      if (temp % 2 == 0)
      {
        temp = temp / 2;
        count[i - 1]++;
      }
      else
      {
        break;
      }
    }
  }

  cout << distance(count.begin(), max_element(count.begin(), count.end())) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << (n + min({a, b, c, d, e}) - 1) / min({a, b, c, d, e}) + 4 << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
int n,k;
int a[100005],b[100005];
vector<int> G[100005];
bool visited[100005];//その点を訪れたかどうか記録
ll ans=1;
ll mod=1e9+7;
void dfs(int v,int f,int s){
	visited[v]=true;
	ans*=(k-f-s);
	ans%=mod;
	for(auto p:G[v]){
		if(visited[p])continue;
		dfs(p,1,f);
		f++;
	}
}
int main(){
	cin >> n >>k;
	for(int i=0;i<n-1;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	dfs(0,0,0);
	cout << ans%mod << endl;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<ll,mp> mmp;//cost,now,sumdis
#define inf 1e9
typedef struct edge{
	ll to,cost,dis;
}edge;

int main(){
	while(1){
		ll n,m,l;
		cin>>n>>m>>l;
		if(n==0)break;
		vector<vector<edge> > g(n);
		priority_queue<mmp,vector<mmp>,greater<mmp> > q;
		for(ll i=0;i<m;i++){
			ll a,b;
			edge e;
			cin>>a>>b>>e.dis>>e.cost;
			a--,b--;
			e.to = b;
			g[a].push_back(e);
			e.to = a;
			g[b].push_back(e);
		}
		vector<vector<ll> > dp(n,vector<ll>(l+1,inf) );
		q.push( mmp( 0,mp(0,0) ) );
		dp[0][0] = 0;
		while(!q.empty()){
			mmp now = q.top();
			q.pop();
			ll dan  = now.first;
			//cout<<dan<<endl;
			mp tmp = now.second;
			//cout<<tmp.first<<' '<<tmp.second<<endl;
			if(tmp.second>l)continue;
			if(dp[tmp.first][tmp.second] < dan) continue;
			for(int i=0;i<g[tmp.first].size();i++){
				//cout<<i<<' '<<"ok"<<endl;
				edge e = g[tmp.first][i];
				if(e.cost+dan < dp[e.to][tmp.second]){
					dp[e.to][tmp.second] = e.cost+dan;
					q.push( mmp(dp[e.to][tmp.second], mp(e.to ,tmp.second ) ) );
				}
				
				if(tmp.second+e.dis <=  l){
					//cout<<"l "<<l<<' '<<tmp.second+e.dis<<endl;
					if( dan < dp[e.to][tmp.second+e.dis]) {
					//cout<<tmp.second+e.dis<<endl;
					dp[e.to][tmp.second+e.dis] = dan;
					q.push(mmp( dan, mp(e.to,tmp.second+e.dis) ) );
					}
				}
			}

		}
		ll res = inf ;
		for(int i=0;i<=l;i++)res = min(res,dp[n-1][i]);
		cout<<res<<endl;



	}
	return 0;
}



Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))
alice, bob = 0,0
for i in range(int(N/2)):
    alice += max(a)
    a.remove(max(a))
    bob += max(a)
    a.remove(max(a))
if(N%2)==1:
    alice+=max(a)
print(alice-bob)

Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
vector<vector<int> > LR;
vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	ll N,M,Q;
	cin>>N>>M>>Q;
	int C[509][509];
	LR=vector<vector<int> >(N+1, vector<int>(N+1,0));
	REP(i,M){
		int a,b;
		cin>>a>>b;
		LR[a][b]++;
	}
	FOR(i,1,N+1){
		REP(j,N+1)C[i][j]=C[i][j-1]+LR[i][j];
	}
	FOR(i,1,Q+1){
		int a,b;
		cin>>a>>b;
		ll ans=0;
		FOR(j,a,b+1)
				ans+=C[j][b]-C[j][a-1];
		cout<<ans<<endl;
	}
				
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define int long long
const int INF = (1 << 30);
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
void solve(){
    int k, t, m=0, a;
    cin >> k >> t;
    REP(i, t){
        cin >> a;
        m = max(m,a);
    }
    cout << max(0ll, k-(k-m)*2-1) << endl;
}

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

    solve();
}



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

typedef long long LL;

LL a, b;

LL f(LL x, LL y) {
	LL z = x/y;
	if(x%y == 0) return 2*x - y;
	return 2*z*y + f(y, x%y);
}

int main() {
	cin>>a>>b;
	cout<<a + f(b, a - b)<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
static const int N = 100;

int main()
{
  int M[N][N];
  int n, u, k, v;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      M[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++)
  {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++)
    {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (j)
      {
        cout << " ";
      }
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>

int main() {
   int a, b, i, j, v, n, l, c;
   int A[200][200] = { 0 };
   int V[200];

   scanf("%d", &n);

   for (i = 0; i < n; i++) {
      scanf("%d", &a);
      scanf("%d", &b);
      for (j = 0; j < b; j++) {
         scanf("%d", &v);
         A[a - 1][v - 1]++;
      }
   }

   for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
         printf("%d", A[i][j]);
         if (j != n - 1) {
            putchar(' ');
         }
      }
      putchar('\n');
   }
   return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;


// 素集合データ構造
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

  // データxが属する木の根を得る 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

  // 2つのデータx, yが属する木をマージする 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

  // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
      return root(x) == root(y);
    }

  // データxが含まれる木の大きさを返す
    ll size(int x) {
        return -r[root(x)];
    }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, q;
  cin >> n >> q;
  UnionFind UF(n);
  rep(i,q) {
    ll t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      UF.unite(u,v);
    }
    else {
      if (UF.same(u,v)) {
        cout << 1 << '\n';
      }
      else {
        cout << 0 << '\n';
      }
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3904
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = IR(3)
    a -= b
    print(a % c)
    return

#B
def B():
    a, b, c, x, ans = II(), II(), II(), II(), 0
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                if i * 500 + j * 100 + k * 50 == x:
                    ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    a = LI()
    dp = [[0] * (n + 1) for i in range(2)]
    for i in range(1, n + 1):
        dp[0][i] += dp[0][i - 1] + a[i - 1]
    a = LI()
    for i in range(1, n + 1):
        dp[1][i] = max(dp[0][i], dp[1][i - 1]) + a[i - 1]
    print(dp[1][-1])
    
    return


class Value_UnionFind():
    def __init__(self,n):
        self.par = [i for i in range(n)]
        self.differ_weight = [0] * n
        self.rank = [0] * n

    def root(self,x):
        if x == self.par[x]:
            return x
        r = self.root(self.par[x])
        self.differ_weight[x] += self.differ_weight[self.par[x]]
        self.par[x] = r
        return r

    def weight(self, x):
        self.root(x)
        return self.differ_weight[x]

    def unit(self, x, y, w):
        w += self.weight(x)
        w -= self.weight(y)
        x = self.root(x)
        y = self.root(y)
        if x == y: return False
        if self.rank[x] < self.rank[y]: x, y, w = y, x, -w
        if self.rank[x] == self.rank[y]: self.rank[x] += 1
        self.par[y] = x
        self.differ_weight[y] = w
        return True

    def differ(self, x, y):
        return self.weight(y) - self.weight(x)
#D
def D():
    n, m = LI()
    u = Value_UnionFind(n)
    for _ in range(m):
        l, r, d = LI_()
        if not u.unit(l, r, d + 1):
            if u.differ(l, r) != d + 1:
                print("No")
                return
    print("Yes")


    return

#Solve
if __name__ == '__main__':
    D()


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

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

ll func(ll x, ll y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}

int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 1;
  ll kk = k;
  while(1){
    if(n / (kk) == 0){
      cout << ans << endl;
      return 0;
    }
    ans++;
    kk *= k;
  }
}





Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var dx = new int[] { -1, 0, 1, 0 };
        var dy = new int[] { 0, 1, 0, -1 };
        while (true)
        {
            var map = new int[12, 12];
            for (int i = 0; i < 12; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < 12; j++)
                    if (s[j] == '1') map[i, j] = 1;
            }
            var count = 0;
            for (int i = 0; i < 12; i++)
                for (int j = 0; j < 12; j++)
                    if (map[i, j] == 1) { goDfs(map, dx, dy, i, j); count++; }
            Console.WriteLine(count);
            if (Console.ReadLine() == null) break;
        }
    }
    public static void goDfs(int[,] map, int[] dx, int[] dy, int x, int y)
    {
        map[x, y] = 0;
        for (int i = 0; i < dx.Length; i++)
        {
            var nx = x + dx[i];   var ny = y + dy[i];
            if (nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && map[nx, ny] == 1) goDfs(map, dx, dy, nx, ny);
        }
    }
}

Measured memory_bytes: 8940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    int K;
    int A;
    int B;

    int kati = 0;
    int count = 0;
    long bis = 1;

    cin >> K >> A >> B;

    if(B - A >= 3 || K - A <= 2){
        kati = 1;
    }

    if(kati == 0){
        cout << 1 + K;

    }else{
        count += A - 1;
        bis += A - 1;

        long j = (K - count) / 2; 
        
        count += 2 * j;

        bis += (B - A) * j;

        bis += K - count;

        cout << bis;
    }
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;



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

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

  bool water[3001] = {};
  bool sugar[3001] = {};

  for (int i = 0; i <= F; i += (100 * A)) {
    water[i] = true;
    for (int j = i; j <= F; j += (100 * B)) {
      water[j] = true;
    }
  }

  for (int i = 0; i <= F; i += C) {
    sugar[i] = true;
    for (int j = i; j <= F; j += D) {
      sugar[j] = true;
    }
  }

  double limit = 100.0 * E / (100 + E);

  double pct = -1.;
  int w = 0;
  int s = 0;

  for (int i = 0; i <= F; i++) {
    for (int j = 0; j <= F; j++) {
      if (water[i] && sugar[j] && (i + j) <= F) {
        double tmp = 100.0 * j / (i + j);
        if (tmp <= limit && pct < tmp) {
          w = i + j;
          s = j;

          pct = tmp;
        }
      }
    }
  }

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


Measured memory_bytes: 256
#include<stdio.h>
int main (void){

int H[300], W[300], i = 0,j[100];

H[0] = 1;
W[0] = 1;

while( H[i] != 0 || W[i]  != 0 ){
	i++;
	scanf("%d %d",&H[i],&W[i]);
}

for( j[1] = 1; j[1] < i; j[1]++){
	
	for( j[2] = 1; j[2] <= ( H[ j[1] ] / 2); j[2]++){
		
		 for( j[3] = 1; j[3] <= ( W[ j[1] ] / 2); j[3]++ ){

			printf("#.");
		}
		
		if( ( W[ j[1] ] % 2 ) == 1 ){
			printf("#");
		}
		
		printf("\n");

		for( j[4] = 1; j[4] <= ( W[ j[1] ] / 2); j[4]++ ){

			printf(".#");
		}
		
		if( ( W[ j[1] ] % 2 ) == 1 ){
			printf(".");
		}
		
		printf("\n");
		
	}
	if( ( H[ j[1] ]  % 2 ) == 1 ){

		for( j[5] = 1; j[5] <= ( W[ j[1] ] / 2); j[5]++ ){

			printf("#.");
		}
		
		if( ( W[ j[1] ] % 2 ) == 1 ){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}

return 0;
}

Measured memory_bytes: 1860
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    A = list(map(int,input().split()))

    b = [0 for i in range(N)]

    for i in A:
        b[i-1] += 1

    for i in b:
        print(i)



main()


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

int main(){
  int N;
  cin>>N;
  int S=0,M=0;
  for(int i=0;i<N;++i){
    int p;
    cin>>p;
    S += p;
    M = max(M,p);
  }
  int ans = S - M/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int inf=1e18;
int32_t main()
{
	int h1,s1,h2,s2;
	cin>>h1>>s1>>h2>>s2;
	bool won=1;
	while(s1>0 and s2>0)
	{
		h2-=s1;
		if(h2<=0)
		{
			won=1;
			break;
		}
		h1-=s2;
		if(h1<=0)
		{
			won=0;
			break;
		}
	}
	if(won)puts("Yes");
	else puts("No");
	
	
	
	
	
}

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

int main() {
  char c;
  cin >> c;

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	string str;
	cin>>n>>str;
	int sum=0,max=0;
	for(int i=0;i<n;i++)
	{
		if(str[i]=='I')
		{
			sum++;
			if(sum>max)
			{
				max=sum;
			}
		}
		else
		{
			sum--;
		}
	} 
	cout<<max;
	return 0;
} 

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

using namespace std;

int p[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf(" %d",&p[i]);
	}

	
	int ans=0;

 
	for(i=0;i<N-1;i++){
		if(p[i]==i+1){
			swap(p[i],p[i+1]);
			ans++;
		}
	}

	if(p[N-1]==N){
	swap(p[N-1],p[N-2]);
	ans++;
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){
    
    ll K, S;
    cin >> K >> S;
    ll ans = 0;
    for(ll X = 0; X <= K; X++){
        for(ll Y = 0; Y <= K; Y++){
            ll Z = S - X - Y;
            if(0 <= Z && Z <= K)ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

int main(void){
    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int ans=0;
    rep(i,N-1) if(A[i]==A[i+1]) ans++,A[i+1]=-1;
    cout << ans << endl;
}


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {               
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << (a[0] * a[1]) / 2.0;
    return Accepted;
}

// Coded By OB

Measured memory_bytes: 18688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
 

int main(){
  int N,D; cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  rep(i,N)rep(j,D) cin >> X[i][j];
  
  int ans = 0;
  rep(i,N-1){
    repr(j,i+1,N){
      int d = 0;
      rep(k,D){
        d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      bool ok = false;
      repr(k,1,d+1){
        if(k * k == d) ok = true;
      }
      if(ok) ans++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
from sys import stdin

def main():
  s = []
  read = stdin.readline
  N =int(read())
  data = [list(map(int,read().split(" "))) for _ in range(N)]
  A = sorted([i[0] for i in data])
  B = sorted([i[1] for i in data])
  if N%2 == 1:
    a1 = A[((N+1)//2)-1]
    b1 = B[((N+1)//2)-1]
    print(b1 - a1 + 1)
  else:
    l = []
    a1 = A[(N//2)-1]
    b1 = B[(N//2)-1]
    a2 = A[(N//2)]
    b2 = B[(N//2)]
    print(b1 + b2 + 1 - a1 - a2)
    
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 50936
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  	int N, L;
	cin >> N >> L;
  	int sum = 0;
  	for(int i = 0; i < N; i++){
    	sum += (i+L);
    }
  	if(L >=0) sum -= L;
  	else if(L <= -N){
    	sum -= (L+N-1);
    }
  
  	cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
flg = True
cnt = 0
while flg == True:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            flg = False
            print(cnt)
            exit()

    cnt += 1

print(cnt)



Measured memory_bytes: 9096
#include <stdio.h>
int main()
{
    int ar[50];
    int n,i,count=0;
    scanf("%d",&n);
    for (i=1; i<=n; i++)
    {
        scanf("%d",&ar[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(ar[i]!=i)
            count++;
    }
    if(count>2)
        printf("NO");
    else
        printf("YES");
    return 0;
    
}


Measured memory_bytes: 2084