akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <functional>

using namespace std;

int main(){
    int N, M;
    int K[10];
    int S[10][10];
    int P[10];
    int ans = 0;
    int tmpp=0;
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        cin >> K[i];
        for(int j=0; j<K[i]; j++) {
            cin >> S[i][j];
        }
    }
    for(int i=0; i<M; i++) {
        cin >> P[i];
    }
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> aaa;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) {
                aaa.push_back(i+1);
            }
        }
        for(int m=0; m<M; m++){
          tmpp = 0;
          for(int nn = 0; nn < K[m]; nn++){
            for(int ll = 0; ll < (int)aaa.size(); ll++){
              if(S[m][nn] == aaa[ll]){
                tmpp++;
                break;
              }
            }
          }
          if(tmpp % 2 == P[m]){
            if(m == M - 1){
              ans++;
            }
          }
          else break;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int p = a[0];
		int q = a[1];
		int r = a[2];
		
		int[] c= new int[3] {p+q,q+r,r+p};
		
		int lowest = 1000;
		
		for(int b=0; b!=3; b++){
			if(c[b] <= lowest){
				lowest = c[b];
			}
		}
		
		Console.WriteLine(lowest);
		
		
		
		
		
		
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#define INF 2147483647
using namespace std;

int v, e, A[100][100];

bool Warshall() {
	for (int l = 0; l < v - 1; l++) {
		for (int i = 0; i < v; i++) {
			for (int j = 0; j < v; j++) {
				for (int k = 0; k < v; k++) {
					if (A[i][k] != INF && A[k][j] != INF && A[i][j] > A[i][k] + A[k][j]) {
						A[i][j] = A[i][k] + A[k][j];
					}
				}
			}
		}
	}

	for (int i = 0; i < v; i++) {
		if (A[i][i] < 0) return 0;
	}

	return 1;
}

int main() {
	int s, t, d;
	cin >> v >> e;
	for (int i = 0; i < v; i++) {
		for (int j = 0; j < v; j++) {
			if (i == j) A[i][i] = 0;
			else A[i][j] = INF;
		}
	}

	for (int i = 0; i < e; i++) {
		cin >> s >> t >> d;
		A[s][t] = d;
	}

	if (Warshall() == 0) cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < v; i++) {
			for (int j = 0; j < v; j++) {
				if (A[i][j] == INF) cout << "INF";
				else cout << A[i][j];

				if (j == v-1) cout << endl;
				else cout << " ";
			}
		}
	}
	
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>


double theta_min(int min) {
  return ((double) min)/60*2*M_PI;
}
double theta_hour(int min, int hour) {
  double dmin = ((double)min)/60*2*M_PI/12;
  double dhour = ((double) hour)/12*2*M_PI;
  return dmin + dhour;
}

class point{
public:
  double x;
  double y;

  point(double r, double theta) {
    x = r * cos(theta);
    y = r * sin(theta);
  }

};

double dist(point p1, point p2) {
  double dx = pow((p1.x - p2.x ),2);
  double dy = pow((p1.y - p2.y ),2);
  return pow((dx+dy),0.5);
}

void label(std::vector<std::vector<bool>> &map,std::vector<int> &to_1,std::vector<int> &depth_map, int i, int depth) {
  for(int j=0; j<to_1.size() ;j++) {
    if (map.at(i).at(j)) {
      if(to_1[j] == -1 || depth_map[j] > depth) {
        to_1[j] = i;
        depth_map[j] = depth;
        label(map,to_1,depth_map,j,depth+1);
      }
    }
  }
}


int main() {

  std::string in;

  int64_t n,m;

  std::cin >> in;
  n = std::stoll(in);
  int64_t buf = 1;
  int64_t max = pow(10,18);

  for(int i=0; i<n; i++) {
    std::cin >> in;
    m = std::stoll(in);
    if(buf == -1) {
      if(m == 0) {
        buf = 0;
      }
      continue;
    }
    if((UINT64_MAX/buf) < m) {
      buf = -1;
    }else if (buf * m > max) {
      buf = -1;
    } else {
      buf = buf * m;
    }
  }
  std::cout << buf << std::endl;
  return 0;

}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define ll long long
using namespace std;

int A[111111];
int main() {
    int N,K;
    cin>>N>>K;
    for(int i=1;i<=N;i++)
        cin>>A[i];
    
    int maxx=A[1];
    int g= A[1];
    for(int i=2;i<=N;i++) {
        g = __gcd(g, A[i]);
        maxx=max(maxx,A[i]);
    }
    if (K%g != 0 || maxx < K) {
        printf("IMPOSSIBLE\n");
    } else {
        printf("POSSIBLE\n");
    }
    
    
}

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

int div(int x){
    
    int cnt = 2;
    for(int i=2; i<x; i++){
        if(x%i == 0){
            cnt++;
        }
    }

    return cnt;
}


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

    int res = 0;
    for(int i=105; i<=n; i+=2){
        if(div(i) == 8){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}

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

int main() {
  string input;
  cin >> input;
  long long K;
  scanf("%d", &K);

  int N = input.length();

  int a[N];
  for(int i=0;i<N;++i){
    a[i] = (int)(input[i] - '0');
  }

  int ans=1;
  bool flug = true;

  //cout << a[0] << endl;
  //cout << a[1] << endl;  

  for(int i=0;i<K;++i){
    if(a[i]!=1){
      ans = a[i];
      flug = false;
    }
    if(!flug) break;
  }

  cout << ans << endl;

  

}



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

#define rep(i, from, to) for (int i = from; i < to; ++i)
#define REP(i, from, to) for (int i = from; i <= to; ++i)
#define dbp(x) cout<<#x<<": "<<x<<endl;
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl;
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl;
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl;

using namespace std;
struct team {
	int total, p, id;
	int miss[11], isOk[11], time[11];
	team() {
		fill(miss, miss + 11, 0);
		fill(isOk, isOk + 11, 0);
		fill(time, time + 11, 0);
		total = 0;
		p = 0;
		id = 0;
	}
};

bool cmp(const team &t1, const team &t2) {
	if (t1.p > t2.p)
		return true;
	if (t1.p < t2.p)
		return false;
	if (t1.total > t2.total)
		return true;
	if (t1.total < t2.total)
		return false;
	if (t1.id > t2.id)
		return true;
	return false;
}

bool cmp2(const team &t1, const team &t2) {
	if (t1.p == t2.p) {
		if (t1.total == t2.total) {
			return t1.id < t2.id;
		} else {
			return t1.total > t2.total;
		}
	} else {
		return t1.p < t2.p;
	}
}

bool eq(team t1, team t2) {
	return t1.p == t2.p && t1.total == t2.total;
}
team data[51];

void solve() {
	int M, T, P, R, m, t, p, j;

	while (cin >> M >> T >> P >> R, M || T || P || R) {
		fill(data, data + 51, team());
		rep(i, 0, R)
		{
			cin >> m >> t >> p >> j;
			if (j == 0) {
				data[t].isOk[p] = 1;
				data[t].time[p] = m;
				data[t].p++;
			} else {
				data[t].miss[p]++;
			}
		}

		REP(i, 1, T)
		{
			data[i].id = i;
			REP(j, 1, P)
			{
				data[i].total += data[i].isOk[j] * data[i].time[j]
						+ data[i].isOk[j] * data[i].miss[j] * 20;

			}
			team di = data[i];
//			dbp3(di.id, di.p, di.total);
		}
		sort(data + 1, data + T + 1, cmp2);
		reverse(data + 1, data + T + 1);
		team before = data[1];
		cout << data[1].id;
		REP(i, 2, T)
		{
			team now = data[i];
			if (eq(before, now))
				cout << "=" << now.id;
			else
				cout << "," << now.id;
			before = now;
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second



int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll N, K;
	cin >> N >> K;
	if(K >= (1<<N)) {
		cout << -1 << '\n';
		return 0;
	}
	if(N == 1) {
		if(K == 1) {
			cout << -1 << '\n';
			return 0;
		} else {
			cout << "0 0 1 1" << '\n';
			return 0;
		}
	}
	ll n = 1<<N;
	vl ret;
	rep(i,0,n) {
		if(i == K) continue;
		ret.pb(i);
	}
	ret.pb(K);
	per(i,0,n) {
		if(i == K) continue;
		ret.pb(i);
	}
	ret.pb(K);
	rep(i,0,sz(ret)) {
		cout << ret[i] << " ";
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 3952
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	var h, m float64
	fmt.Scan(&a, &b, &h, &m)

	hx := a * math.Sin(h*math.Pi/6+m*math.Pi/360)
	hy := a * math.Cos(h*math.Pi/6+m*math.Pi/360)
	mx := b * (math.Sin(m * math.Pi / 30))
	my := b * (math.Cos(m * math.Pi / 30))

	ans := math.Sqrt(math.Pow(hx-mx, 2) + math.Pow(hy-my, 2))
	fmt.Printf("%0.10f\n", ans)
}


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

int main(){
 	int n,ans,mx(0),sum(0),num;
  	cin >> n;
  	for(int i = 0 ; i < n ; i ++){
     	cin >> num;
      	sum += num;
      	if(mx < num) mx = num;
    }
  	cout << sum - mx / 2 << endl;
}


Measured memory_bytes: 256
listA=[]

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

a=listA[0]
b=listA[1]

x1=a*int(b)
x2=b*int(a)

if int(x1) > int(x2):
    print(x1)
else:
    print(x2)

Measured memory_bytes: 3060
const MOD: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();
    let xs: Vec<i64> = (0..n).map(|_| sc.read()).collect();
    let ys: Vec<i64> = (0..m).map(|_| sc.read()).collect();

    let mut top = 0;
    for i in 0..(n - 1) {
        let mut x = xs[i + 1] - xs[i];
        x = (x * (i + 1) as i64) % MOD;
        x = (x * (n - 1 - i) as i64) % MOD;
        top = (top + x) % MOD;
    }

    let mut side = 0;
    for i in 0..(m - 1) {
        let mut y = ys[i + 1] - ys[i];
        y = (y * (i + 1) as i64) % MOD;
        y = (y * (m - 1 - i) as i64) % MOD;
        side = (side + y) % MOD;
    }

    let ans = (top * side) % MOD;
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 6396
using System;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        if (s.Length + 1 == t.Length && t.StartsWith(s))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 26080
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






string S; int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    N = S.length();

    ll ans = 0;
    int w = 0;
    rep(i, 0, N) {
        if (S[i] == 'W') {
            ans += i - w;
            w++;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

int main () {
  	string s;
  	cin >> s;
  	ll sum = 0;
  	for (int i=0; i<s.size(); i++) {
    	int di = s[i]-'0';
      	sum = (sum + di%9)%9;
    }
  	if (sum == 0)
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG

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

int count = 0;

void insertionSort(vector<int>& data, int N, int g, int& count)
{
    for(int i = g; i < N; i++){
        int d_i = data.at(i);
        int j = i - g;
        while((j >= 0) && (data.at(j) > d_i)){
            swap(data.at(j + g), data.at(j));
            j -= g;
            count++;
        }
    }
}

void shellSort(vector<int> &data, int N){
    int count = 0;
    int g = (N / 2) + 1;
    int m = 0;

    while(true){
        insertionSort(data, N, g, count);
        m++;
        if(g == 1) break;
        g = ceil(g / 2);
    }
    
    cout << m << endl;

    g = (N / 2) + 1;
    cout << g;
    while(true){
        if(g == 1) break;
        g = ceil(g / 2);
        cout << ' ' << g;
    }
    cout << endl;
    cout << count << endl;
}

int main(){
    int N;
    cin >> N;
    
    vector<int> data(N);

    rep(i, N)
    {
        cin >> data.at(i);
    }

    shellSort(data, N);
    rep(k, N){
        cout << data.at(k) << endl;
    }

    return 0;
}


Measured memory_bytes: 6688
#include <iostream>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int s[M],c[M];
  int ans=0;
  int count1=0;
  int count2=0;
  int count3=0;
  for(int i=0;i<M;++i) cin >> s[i] >> c[i];
  for(int j=0;j<M;++j) {
    if(s[j]==1&&c[j]==0&&N>1) {
      cout << -1;
      return 0;
    }
    for(int k=0;k<M;++k) {
      if(j==k) continue;
      if(s[j]==s[k]&&c[j]!=c[k]) {
        cout << -1;
        return 0;
      }
    }
    if(s[j]==1&&count1==0) {
      if(N==1) ans += c[j];
      if(N==2) ans += c[j] * 10;
      if(N==3) ans += c[j] * 100;
      count1 = 1;
    }
    if(s[j]==2&&count2==0) {
      if(N==2) ans += c[j];
      if(N==3) ans += c[j] * 10;
      count2 = 1;
    }
    if(s[j]==3&&count3==0) {
      if(N==3) ans += c[j];
      count3=1;
    }
  }
  if(count1==0&&N==2) ans += 10;
  if(count1==0&&N==3) ans += 100;
  cout << ans;
}


Measured memory_bytes: 256
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
cost = []
for i in range(N+1):
    cost.append(abs(A[i]-A[i+1]))
sum_cost = sum(cost)
for i in range(N):
    print(sum_cost-cost[i]-cost[i+1]+abs(A[i]-A[i+2]))

Measured memory_bytes: 14040
# -*- coding: utf-8 -*-

SA,SB,SC = [input().strip() for _ in range(3)]

ia,ib,ic=0,0,0
turn="a"

while True:
  if turn == "a":
    if SA == "":
      print("A")
      break
    
    turn = SA[0]
    SA = SA[1:]

  if turn == "b":
    if SB == "":
      print("B")
      break
    
    turn = SB[0]
    SB = SB[1:]

  if turn == "c":
    if SC == "":
      print("C")
      break
    
    turn = SC[0]
    SC = SC[1:]


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int a,b,ans;
    while(cin>>a>>b){
        ans=0x7fffffff;
        for(int i=1000000;i>=0;i--){
            if((int)(i*0.08)==a && (int)(i*0.1)==b){
                ans=min(ans,i);
            }
        }
        if(ans==0x7fffffff){
            cout<<-1<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}


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

bool str(int a[])
{
	if((a[0]==a[1]+1&&a[1]==a[2]+1&&a[2]==a[3]+1&&a[3]==a[4]+1)){
		return true;
	}else if(a[0]==13&&a[1]==12&&a[2]==11&&a[3]==10&&a[4]==1){
		return true;
	}else{
		return false;
	}
}
		
			

int main()
{
	int a[5];
	int count;
	while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4]) != EOF){
		count = 0;
		sort(a,a+5,greater<int>());
		for(int i=0;i<4;++i){
			for(int j=i+1;j<5;++j){
				if(a[i]==a[j])count++;
			}
		}
		
		switch(count){
		  case 6:
			cout << "four card" << endl;
			break;
		  case 4:
			cout << "full house" << endl;
			break;
		  case 3:
			cout << "three card" << endl;
			break;
		  case 2:
			cout << "two pair" << endl;
			break;
		  case 1:
			cout << "one pair" << endl;
			break;
		  default:
			if(str(a)){
				cout << "straight" << endl;
			}else{
				cout << "null" << endl;
			}
		}
	}
}
		

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 998244353

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll count=C+D-A-B;

  vector<vector<ll>> dp(C+1,vector<ll>(D+1,0));
  dp.at(A).at(B)=1;
  for(ll i=A;i<=C;i++){
    for(ll j=B;j<=D;j++){
      if(i==A&&j==B){
        continue;
      }
      dp.at(i).at(j)=dp.at(i-1).at(j)*j+dp.at(i).at(j-1)*i-(i-1)*(j-1)*dp.at(i-1).at(j-1);
      if(dp.at(i).at(j)<0){
        dp.at(i).at(j)+=(i-1)*(j-1)*MOD;
      }
      dp.at(i).at(j)%=MOD;
    }
  }
/*
  for(int i=A;i<=C;i++){
    for(int j=B;j<=D;j++){
      cout<<dp.at(i).at(j)<<" ";
    }
    cout<<endl;
  }
*/
  cout<<dp.at(C).at(D)<<endl;
}


Measured memory_bytes: 73656
#include <climits>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#include <queue>
#define px first
#define py second
#define fi first
#define se second
#define LD long double

//#define DEBUG
#ifdef DEBUG
#include "Debug.h"
#endif // DEBUG

using namespace std;

const int INF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a - b + 1 << endl;
    return 0;
}


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

using namespace std;

void print_count(string key, int count) {
    cout << key << " x " << count << endl; 
}

int main() {
    int N; cin >> N;
    map<string, int> m;
    m["AC"] = 0, m["WA"] = 0, m["TLE"] = 0, m["RE"] = 0;
    for (int i = 0; i < N; i++) {
        string S; cin >> S;
        m[S] += 1;
    }
    
    print_count("AC", m["AC"]);
    print_count("WA", m["WA"]);
    print_count("TLE", m["TLE"]);
    print_count("RE", m["RE"]);

    return 0;
}

Measured memory_bytes: 3576
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int N = readln.chomp.to!int;
    long[] a = readln.split.to!(long[]);
    auto list = DList!(long)();
    int ans = 0;
    foreach(i; 0..N) {
        while(!list.empty && list.back > a[i]) {
            list.removeBack;
        }
        if (list.empty || list.back != a[i]) {
            ans++;
            list.insertBack(a[i]);
        }
    }
    ans.writeln;
}

Measured memory_bytes: 17616
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

ll rec(int A[],int N){
    int B[100000] = {};
    REP1(i,N){
        B[i] = A[i];
    }
    //順当に始めるペア作りと，始めを無視したペア作り．
    ll max1 = 0,max2 = 0;
    REP1(i,N){
        if(A[i] != 0){
            if(i != 0){//前との兼ね合い
                if (A[i-1] != 0) {
                    A[i]--;
                    max1++;
                }
            }
            
            if(0 < A[i]){//メイン処理
                max1 += A[i]/2;
                A[i] -= (A[i]/2)*2;
            }
            
        }
    }
    
    REP1(i,N){
        if(B[i] != 0){
            B[i]--;
            break;
        }
    }
    
    REP1(i,N){
        if(B[i] != 0){
            if(i != 0){//前との兼ね合い
                if (B[i-1] != 0) {
                    B[i]--;
                    max2++;
                }
            }
            
            if(0 < B[i]){//メイン処理
                max2 += B[i]/2;
                B[i] -= (B[i]/2)*2;
            }
            
        }
    }
    
    return max(max1,max2);
}

int main(){
    INT(N);
    int A[100000] = {};
    REP1(i,N){
        INT(v);
        A[i] = v;
    }
    cout << rec(A,N) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res) * (a))%mod;
      a = ((a) * (a))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void dfs(vector<string> grid,vector<vector<int>> &dist,int sx,int sy,int ex,int ey,int n,int m){
    deque<ii> dq;
    dq.push_front({sx,sy});
    dist[sx][sy]=0;
    while(!dq.empty()){
      int x=dq.front().ff;
      int y=dq.front().ss;
      dq.pop_front();
      for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx>=0 && ny>=0 && nx<n && ny<m && grid[nx][ny]=='.'){
          if(dist[nx][ny]>dist[x][y]){
            dist[nx][ny]=dist[x][y];
            dq.push_front({nx,ny});
          }
  
        }
      }
      for(int i=x-2;i<=x+2;i++){
        for(int j=y-2;j<=y+2;j++){
          if(i>=0 && j>=0 && i<n && j<m && grid[i][j]=='.'){
            if(dist[i][j]>dist[x][y]+1){
              dist[i][j]=dist[x][y]+1;
              dq.push_back({i,j});
            }
            else
              continue;
          }
        }
      }
    }  
}

int main(){

    go();
    fast_io
    int n,m;
    cin>>n>>m;
    vector<string> graph(n);
    vector<vector<int>> dist(n,vector<int>(m,1e7));
    int sx,sy,ex,ey;cin>>sx>>sy>>ex>>ey;
    sx--;
    sy--;
    ex--;
    ey--;
    for0(i,n){
      cin>>graph[i];
    }
   
    dfs(graph,dist,sx,sy,ex,ey,n,m);
    if(dist[ex][ey]>=1e7)
      cout << "-1" <<"\n";
    else
      cout << dist[ex][ey] <<"\n";
    
}



/*
3
17
4
*/






















Measured memory_bytes: 9760
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, A, B;

int main()
{
    cin >> N;
    if (N == 1) puts("Hello World\n");
    else
    {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func sum(x, n int) int {
	ans := 0
	for i := 0; i < n; i++ {
		ans += (x - i)
	}
	return ans
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)

	s := nextString()

	ls := make([]int, len(s)+1)
	ls[0] = 0

	rs := make([]int, len(s)+1)
	rs[len(rs)-1] = 0

	for i := 0; i < len(ls)+1; i++ {
		ri := len(s) - 1 - i

		if i+1 <= len(s) {
			if s[i] == '<' {
				ls[i+1] = ls[i] + 1
			} else if s[i] == '>' {
				ls[i+1] = 0
			}
		}

		if ri > -1 {
			if s[ri] == '>' {
				rs[ri] = rs[ri+1] + 1
			} else if s[ri] == '<' {
				rs[ri] = 0
			}
		}
	}

	ans := 0
	for i := 0; i < len(ls); i++ {
		ans += max(ls[i], rs[i])
	}

	fmt.Println(ans)
}


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

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

int main()
{
    ll N;
    cin >> N;

    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    ll ans = A[0];
    ll cnt = 0;
    repd(i, 1, N) {
        A[i] = gcd(A[i - 1], A[i]);
    }

    cout << A[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
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 MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

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

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b){
  if(a == 0) return b;
  if(b == 0) return a;
  return a/GCD(a,b) * b;
}

int main(){
	int N,M; cin >> N >> M;
    string S,T; cin >> S >> T;
    ll K = LCM(M,N);
    int s = K/N;
    int t = K/M;
    map<ll,char> res;
    rep(i,N){
        res[i*s] = S[i];
    }
    rep(i,M){
        res[i*t] = T[i];
    }
    rep(i,N){
        if(res[i*s] != S[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << K << endl;
}
   


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
const int N=100100;
typedef long long ll;
pair<int,int>a[N],b[N];
ll sumx,sumy,sa[N],sb[N],ans;
int n,ia[N],ib[N];
int main(){
#ifdef ONLINE_JUDGE
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif
	cin>>n;
	for(int i=1;i<=n;++i){
		int x,y;cin>>x>>y;
		a[i]=make_pair(x,i);b[i]=make_pair(y,i);
		sumx+=x;sumy+=y;
	}
	ans=min(sumx,sumy);
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	for(int i=1;i<=n;++i){
		ia[a[i].second]=i;ib[b[i].second]=i;
		sa[i]=sa[i-1]+a[i].first;sb[i]=sb[i-1]+b[i].first;
	}
	int rg=n+1;
	for(int i=1;i<n;++i){
		rg=min(rg,ib[a[i].second]);
		if(rg<=n-i)ans=min(ans,sa[i]+sb[n-i]);
		else ans=min(ans,min(sa[i-1]+a[i+1].first+sb[n-i],sa[i]+sb[n-i-1]+b[n-i+1].first));
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4096
import fractions

A,B,C,D= map(int,input().split())


#A-BまでのCの個数

Cnum=int((B-A+1)//C)+ ((B-A+1)%C >= (C-(A-1)%C))
Dnum=int((B-A+1)//D)+ ((B-A+1)%D >= (D-(A-1)%D))

CD= int(C*D/(fractions.gcd(C,D)))

CDnum=int((B-A+1)//CD)+ ((B-A+1)%CD >= (CD-(A-1)%CD))

print(B-A+1-Cnum-Dnum+CDnum)

Measured memory_bytes: 5472
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if(N <= K){
        cout  << X*N << endl;
    }
    else{
        cout << X*K+Y*(N-K) << endl;
    }
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int n,m;
int main() {
    cin >> n >> m;
    cout << n-m+1 << endl;
    return 0;
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    
    if ((n - 1) * (n - 2) / 2 < k) cout << -1 << endl;
    else {
        vector<int> u, v;
        for (int i = 0; i < n - 1; i++) {
            u.push_back(0);
            v.push_back(i + 1);
        }
        
        int p = (n - 1) * (n - 2) / 2;
        if (p == k) {
                    cout << u.size() << endl;
                    for (int l = 0; l < u.size(); l++) {
                        cout << u[l]+1 << " " << v[l]+1 << endl;
                    }
                    return 0;
                }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                u.push_back(i + 1);
                v.push_back(j + 1);
                p--;
                if (p == k) {
                    cout << u.size() << endl;
                    for (int l = 0; l < u.size(); l++) {
                        cout << u[l]+1 << " " << v[l]+1 << endl;
                    }
                    return 0;
                }
            }
        }
        cout << -1 << endl;
        
    }
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
const ll INF = 10000000000;
ll n,a,b;
vector<ll> h;
bool pos(ll x);
int main(){
    cin >> n >> a >> b;
    ll sum = 0;
    for(int i = 0;i < n;i++){
        ll H;
        cin >> H;
        h.push_back(H);
    }
    ll r,l;
    l = 1;r = INF;
    while(r-l > 1){
        if(pos(((r+l)/2)) == true){
            r = (r+l)/2;
        }else{
            l = (r+l)/2;
        }
        //cout << r <<" "<< l << endl;
    }
    if(pos(l) == true)cout << l << endl;
    else cout << r << endl;
    cin >> n;
}
bool pos(ll x){
    ll count = 0;
    for(int i = 0;i < n;i++){
        ll remain = h[i]-b*x;
        count += max(zero,(remain+a-b-1)/(a-b));
    }
    //cout << x << " "<< count << endl;
    if(count <= x)return true;
    else return false;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i = 0;i < n;i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = 0;i < k;i++){
        ans += l[n - i - 1];
    }
    cout << ans;
 }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N,K;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> K;
  cout << N - K + 1 << endl;

  return 0;
}


Measured memory_bytes: 888
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(long N, long[] A){
    return 1 / A.map!(to!double).map!"1/a".sum;
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A);
    else
        solve(N, A).writeln;
}


Measured memory_bytes: 256
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

capa = [A,B,C,D,E]
r1 = A
r2 = min(A,B)
r3 = min(r2,C)
r4 = min(r3,D)
r5 = min(r4,E)

t = 4+N//r5+1*(N%r5!=0)

print(int(t))

Measured memory_bytes: 3064
"""
タグ：区間
"""
import sys
input = sys.stdin.readline
N, P = map(int, input().split())
S = input().strip()

if P == 5:
    res = 0
    i = 0
    for s in reversed(S):
        if int(s)%5==0:
            res += N-i
        i += 1
    print(res)
elif P == 2:
    res = 0
    i = 0
    for s in reversed(S):
        if int(s)%2==0:
            res += N-i
        i += 1
    print(res)
else:
    T = [0]
    p = 1
    for s in reversed(S):
        T.append(int(s)*p + T[-1])
        p = p*10%P

    cnt = [0]*P
    for i in range(N+1):
        cnt[T[i]%P] += 1

    res = 0
    for c in cnt:
        res += c*(c-1)//2
    print(res)

Measured memory_bytes: 84456
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
string s[3];
bool ok[3][3][2001];
int calc(int i,int j,int k){
    int n = s[i].size();
    int m = s[j].size();
    int l = s[k].size();
    int mi = inf;
    for(int x=0;x<n;x++){
        if(ok[i][j][x]){
            chmin(mi,max({x+m+l,n+l}));
            for(int y= x;y<max(n,x+m);y++){
                if(y<n){
                    if(ok[i][k][y]&&(ok[j][k][y-x]||y-x>=m)){
                        chmin(mi,max({n,x+m,y+l}));
                    }
                }else{
                    if(ok[j][k][y-x]){
                        chmin(mi,max({n,x+m,y+l}));    
                    }
                }
            }
        }
    }
    return mi;
}
void init(){
    rep(i,3){
        rep(j,3){
            if(i==j)continue;
            int n = s[i].size();
            int m = s[j].size();
            for(int k=0;k<n;k++){
                bool flag = 1;
                for(int x=0;x<m;x++){
                    if(k+x>=n||s[i][k+x]==s[j][x]||s[i][k+x]=='?'||s[j][x]=='?')continue;
                    else flag = 0;
                }
                ok[i][j][k] = flag;
            }
        }
    }
}
int main(){
    cin >> s[0] >> s[1] >> s[2];
    init();
    int mi = s[0].size()+s[1].size()+s[2].size();
    int p = calc(0,1,2);
    chmin(mi,p);
    p = calc(0,2,1);
    chmin(mi,p);
    p = calc(1,0,2);
    chmin(mi,p);
    p = calc(1,2,0);
    chmin(mi,p);
    p = calc(2,0,1);
    chmin(mi,p);
    p = calc(2,1,0);
    chmin(mi,p);
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
int main(){
  int A,B,C,X;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&X);
  int count=0;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        int Y=500*i+100*j+50*k;
        if(X==Y)
          count++;
      }
    }
  }
  printf("%d",count);
  return 0;
}


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

ans = [0]*n

for x in range(1, int(n**0.5)+1):
    for y in range(1, int(n**0.5)+1):
        for z in range(1, int(n**0.5)+1):
            tmp_n = x*y+x*z+y*z+x**2+y**2+z**2
            if tmp_n <= n:
                ans[tmp_n-1] += 1
for a in ans:
    print(a)

Measured memory_bytes: 69556
#include <iostream>

using namespace std;
int K;
int main(void) {

	cin >> K;
	int ans;
	int a, b;
	if (K % 2 == 0) { ans = K / 2 * K / 2; }
	else { a = (K + 1) / 2; b = K / 2; ans = a*b; }

	cout << ans << endl;

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int a, b;

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

    cin >> a >> b;
    if (a==1) {
      cout << 1 << endl;
      return 0;
    }
    if (a>b){
      cout << a-1 << endl;
    }else{
      cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())
    inf = float('inf')
    d = [[inf] * N for i in range(N)]

    for i in range(N):
        d[i][i] = 0

    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        if d[a][b] > c:
            d[a][b], d[b][a] = c, c

    for k in range(N):
        for i in range(N):
            for j in range(N):
                temp = d[i][k] + d[k][j]
                if d[i][j] > temp:
                    d[i][j] = temp

    ans = inf
    for i in permutations(r):
        temp = 0
        for j in range(len(i)-1):
            temp += d[i[j] - 1][i[j + 1] - 1]
            if temp > ans:
                break
        if ans > temp:
            ans = temp

    print(ans)


main()


Measured memory_bytes: 4620
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
s  = input()
t  = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()
print('Yes' if s == t[:-1] else 'No')


Measured memory_bytes: 9336
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char

main = do
    [n,x] <- map read . words <$> getLine
    xs <- VU.map (\a -> abs $ x - a) . VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ VU.foldl1' gcd xs

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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, press Ctrl+Shift+P and select "ICIE Template configure" from the list 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    int h[100005], dp[100005];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    dp[1] = abs(h[1] - h[0]); 
    for (int i = 2; i < N; i++) {
        int c1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        int c2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(c1, c2);
    }
    cout << dp[N - 1];
    


}


Measured memory_bytes: 4368
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

long long solve(long long k, long long a, long long b)
{    
    k -= a;
    if(k <= 0)
        return 1;
    else if(a <= b)
        return -1;
    else
        return 1 + (k + a - b - 1) / (a - b) * 2;
}

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

    cout << solve(k, a, b) << endl;

    return 0;
}


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

int main(){
  int n, i;
  long int sum=0;

  cin >> n;

  for(i=1; i<n+1; i++){
	if((i%5 != 0) && (i%3 != 0)){
        sum += i;
    }
  }
  cout << sum << endl;
}

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

int i,look,first,prev,n,dex;
int dic[105][2],page[105];
char s[105][35],word[35];

int main(void){
	while(scanf("%s %d",s[n],&page[n])!=EOF){
		dic[n][0]=n;dic[n][1]=999;

		look=first;prev=-1;
		while(look!=n){
			dex=dic[look][0];
			if(strcmp(s[n],s[dex])<0 || (strcmp(s[n],s[dex])==0 && page[n]<page[dex]) ){
				dic[n][1]=look;
				if(prev<0){first=n;}
				else{dic[prev][1]=n;}
				break;
			}
			else{
				if(dic[look][1]>111){
					dic[look][1]=n;
					break;
				}
				else{
					prev=look;
					look=dic[look][1];
				}
			}
		}
		n++;
	}

	i=first;
	while(i<111){
		if(strcmp(word,s[dic[i][0]])!=0){
			strcpy(word,s[dic[i][0]]);
			if(i!=first)printf("\n");
			printf("%s\n",word);
			printf("%d",page[dic[i][0]]);
		}
		else{
			printf(" %d",page[dic[i][0]]);
		}

		i=dic[i][1];
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
typedef long long ll;
typedef pair<int ,int> numn;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	numn u[N];
	int n,a,b,ans,i;
	ll k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a >> b;
		u[i] = pair<int,int>(a,b);
	}
	sort( u , u+n );
	i = 0;
	while(1){
		a = u[i].first;
		b = u[i].second;
		if((ll)b>=k){
			ans = a;
			break;
		}
		k -= (ll)b;
		++i;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  for(int i = 0;i < 7;i++){
    cin >> a >> b;
    cout << a - b << endl;
  }
  return 0;
}




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

int main() {
  int N;
    cin >> N;
  
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    
     if(S == "Y"){
       cout << "Four" << endl;
       break;
     }
    
    else{
      if(i + 1 != N){
      }
      
      if(i + 1 == N){
        cout << "Three" << endl;
        break;
      }
    }
  }
}


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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<bool> vb;
mt19937_64 rnd(time(0));

void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

signed main() {
    start();
    int n;
    cin >> n;
    vector<vi> a, d;
    a = d = vector<vi>(n, vi(3, 1e18));
    for (int i = 0; i < n; ++i) cin >> a[i][0] >> a[i][1] >> a[i][2];
    d[0] = a[0];
    for (int i = 1; i < n; ++i) {
        d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i][0];
        d[i][1] = max(d[i - 1][0], d[i - 1][2]) + a[i][1];
        d[i][2] = max(d[i - 1][1], d[i - 1][0]) + a[i][2];
    }
    cout << max({d[n - 1][0], d[n - 1][1], d[n - 1][2]});


}


Measured memory_bytes: 14216