akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){
	int x,y;
	while(scanf("%d %d",&x,&y)!=EOF){
		if(x >= y)
			printf("%d\n",calc(x,y));
		else{
			printf("%d\n",calc(y,x));
		}
	}
}

Measured memory_bytes: 2576
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a, b, c, d, x, y, z, w, s, t;
	
	while(cin >> a >> b >> c >> d){
		s = a+b+c+d;
		cin >> a >> b >> c >> d;
		t = a+b+c+d;
		
		cout << ((s > t)? s : t) << endl;
	}
	
	return 0;
}

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

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:i32,_b:i32,s:chars};

    for i in 0..s.len() {
        if i as i32 == a {
            if s[i] != '-' {
                println!("No");
                return ();
            }
        }
        else {
            if s[i] == '-' {
                println!("No");
                return ();
            }
        }
    }
    println!("Yes");

}

Measured memory_bytes: 4352
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
ll fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll x,y;
	cin>>x>>y;
	if(y<=4*x&&y>=2*x)
	{
		if((y-2*x)%2==0)
		cout<<"Yes";
		else
		cout<<"No";
	}
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int H = 310;
string c[H];
const int inf = 1e9;
int dp[H][H][H];
int diff[H][H][H];

int h, w;

void build_tbl(int v) {
  REP(i, 0, h + 1) {
    REP(j, 0, h + 1) {
      int tmp = 0;
      if (i >= 1 && j >= 1) {
	tmp = diff[v][i - 1][j - 1] + (c[i - 1][v] == c[j - 1][v + 1] ? 1 : 0);
      }
      diff[v][i][j] = tmp;
    }
  }
}

int calc_tbl(int v) {
  dp[v][0][0] = 0;
  REP(i, 0, h + 1){
    REP(j, 0, h + 1) {
      if(i==0 && j==0) continue;
      int mi = inf;
      if (i >= 1)
	mi = min(mi, dp[v][i - 1][j] + diff[v][i][j]);
	if (j >= 1)
	  mi = min(mi, dp[v][i][j - 1] + diff[v][i][j]);
	dp[v][i][j] = mi;
      }
    }
  return dp[v][h][h];
}
int main(void){
  cin >> h >> w;
  REP(i, 0, h) {
    cin >> c[i];
  }
  REP(i, 0, w - 1) {
    build_tbl(i);
  }
  REP(i, 0, h + 1){
    REP(j, 0, h + 1) {
      REP(k, 0, h + 1) {
	dp[i][j][k] = inf;
      }
    }
  }
  int sum = 0;
  REP(i, 0, w - 1) {
    sum += calc_tbl(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 221568
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> as(N);
  F0R(i, N) {
    cin >> as[i];
    as[i] *= 2; // 隣接要素の和
  }

  // 山[N-1] - 山[0] を求める
  i64 d = 0;
  for (int i = 1; i < N; i += 2) {
    d += as[i] - as[i - 1];
  }

  // 山[0]
  int r = ((i64)as.back() - d) / 2;
  cout << r << ' ';
  F0R(i, N - 1) {
    r = as[i] - r;
    cout << r << ' ';
  }
}
#endif


Measured memory_bytes: 3640
s = gets.chomp.split(' ')
H = s[0].to_i
W = s[1].to_i
eigo = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
#puts eigo.index('F')
str = catch :escape do
  for i in 1..H
    ary = gets.chomp.split(' ')
    #puts ary.to_s
    for j in 0...W
      if ary[j] == 'snuke'
        throw :escape, eigo[j].to_s + i.to_s
      end
    end
  end
end

puts str

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int i,n,kotae=0;
  string s,t;
  cin>>s>>t;
  n=s.length();
  for(i=0;i<n;i++){
    if(s[i]!=t[i]){
      kotae++;
    }
  }
  cout<<kotae;
}

Measured memory_bytes: 3896
n = int(input())
p = [int(i) for i in input().split()]
s=0
for i in range(1,n-1):
    if p[i]>p[i-1] and p[i]<p[i+1]:
        s=s+1
    elif p[i]<p[i-1] and p[i]>p[i+1]:
        s=s+1
    else:
        s=s
print(s)

Measured memory_bytes: 3060
// Submitted by Subhash
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;



public class Main {
	
	public static boolean solve(char c[]) {
		int sum=0;
		for(char c1:c) sum+=c1-'0';
		
		return sum%9==0;
		
	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		char c[]=sc.next().toCharArray();
		System.out.println(solve(c)?"Yes":"No");
		out.close();

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 37176
s = gets.chomp
t = gets.chomp

h = {}
('a'..'z').each { |c| h[c] ||= [] }
(0...(s.length)).each { |i| h[s[i]].append(i) } 

if t.chars.any? { |c| h[c].empty? }
  puts '-1'
else
  i = -1
  answer = 0
  t.chars.each do |c|
    if h[c].empty?
      puts -1
      exit!
    end
    i = h[c].bsearch { |x| x > i }
    if i.nil?
      answer += s.length
      i = h[c].first
    end
  end
  puts answer + i + 1
end


Measured memory_bytes: 25324
#include <stdio.h>

	int main(void){

	int a, b, c;


	scanf("%d" "%d", &a, &b);

	if( a < b ){
	
	printf("a < b\n");
}
	if( a > b ){
	printf("a > b\n");

}
	if(a == b){
	printf("a == b\n");
}

return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
#define pi 3.14159265358979324
typedef long long int lint;

int main (){
  long double A,B,H,H_2,M,T,ans;
  cin >> A >> B >> H >> M;
  H_2 = (H/6 + M/360)*pi;
  M *= pi; M /= 30;
  T = abs(H_2 - M);
  if(T > pi){T = 2*pi - T;}
  ans = sqrt(A*A + B*B - 2*A*B*cos(T));
  cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4172
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, readline().split())
xyz = [list(map(int, readline().split())) for i in range(m)]
uf = UnionFind(n)
ans = 0
for x, y, z in xyz:
    uf.union(x - 1, y - 1)
for i in range(n):
    if uf.find(i) == i:
        ans += 1
print(ans)


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

int main() {

    int x, y;
    char i;

    while(-1) {
    cin >> x;
    cin >> i;
    cin >> y;

    if(i == '?') {
        return 0;
    }

    switch (i) {
        case '+':
            cout << x + y << endl;
            break;
        case '-':
            cout << x - y << endl;
            break;
        case '/':
            cout << x / y << endl;
            break;
        case '*':
            cout << x * y << endl;
            break;
        default:
            break;
    }
    }
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c - max({a, b, c}));
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3576
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/modint>
#include <atcoder/lazysegtree>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

using modint = ac::modint998244353;
using P = pair<modint, modint>;
using Q = pair<modint, int>;

Q op (Q x, Q y) { return {x.first+y.first, x.second+y.second}; }
Q e () { return {modint(0), 0}; }
Q mapping (P f, Q x) { return {f.first*x.first + f.second*x.second, x.second}; }
// P composition (P x, P y) { return {x.first*y.first, x.second*y.first + y.second}; }
P composition (P x, P y) { return {x.first*y.first, x.first*y.second + x.second}; }
P id () {return {modint(1), modint(0)}; }

int main() {
    int n,q; cin >> n >> q;
    vector<Q> da(n);
    rip(i,n,0) {
        int a; cin >> a;
        da[i] = {modint(a), 1};
    }
    ac::lazy_segtree<Q, op, e, P, mapping, composition, id> lst(da);
    vector<modint> ans(0);
    rip(i,q,0) {
        int t; cin >> t;
        if(t) {
            int l, r; cin >> l >> r;
            ans.push_back(lst.prod(l, r).first);
        }
        else {
            int l, r, b, c; cin >> l >> r >> b >> c;
            lst.apply(l, r, {modint(b), modint(c)});
        }
    }
    for(auto i: ans) printf("%d\n", i.val());
}


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

using namespace std;

int main(int argc, const char *argv[])
{
  int h, w;
  cin >> h >> w;

  vector<vector<int>> l(h, vector<int>(w));
  vector<vector<int>> r(h, vector<int>(w));
  vector<vector<int>> u(h, vector<int>(w));
  vector<vector<int>> d(h, vector<int>(w));
  vector<vector<char>> m(h, vector<char>(w));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> m[i][j];
      if (m[i][j] == '#') {
        l[i][j] = r[i][j] = u[i][j] = d[i][j] = 0;
        continue;
      }

      l[i][j] = j == 0 ? 1 : l[i][j - 1] + 1;
      u[i][j] = i == 0 ? 1 : u[i - 1][j] + 1;
    }
  }

  int ans = 0;
  for (int i = h - 1; i >= 0; i--) {
    for (int j = w - 1; j >= 0; j--) {
      if (m[i][j] == '#') {
        continue;
      }

      r[i][j] = j == w - 1 ? 1 : r[i][j + 1] + 1;
      d[i][j] = i == h - 1 ? 1 : d[i + 1][j] + 1;
      ans = max(ans, r[i][j] + d[i][j] + l[i][j] + u[i][j] - 3);
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 67072
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K;
i64 dp[2020][2020];

int main()
{
	scanf("%d%d", &N, &K);
	if (N == 1) {
		puts("1");
		return 0;
	}
	--K;
	dp[0][N] = 1;
	for (int i = 2; i <= N; ++i) dp[1][i] = 1;
	for (int i = 1; i < K; ++i) {
		for (int j = N; j >= 2; --j) {
			ADD(dp[i + 1][(i + j == N + 1 ? (j - 1) : j)], dp[i][j]);
		}
		for (int j = N; j >= 2; --j) {
			ADD(dp[i + 1][j - 1], dp[i + 1][j]);
		}
	}
	i64 ret = 0;
	for (int i = 2; i <= N; ++i) ADD(ret, dp[K][i]);
	if (K != N - 1) {
		for (int i = 0; i < N - K - 2; ++i) ADD(ret, ret);
	}
	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (int i=0; i<n; i++) {
		for (int j=0; j<d; j++) {
			cin >> x[i][j];
		}
	}

	int ans = 0;
	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			int norm = 0;
			for (int k=0; k<d; k++) {
				int diff = abs(x[i][k] - x[j][k]);
				norm += diff * diff;
			}
			bool flag = false;
			for (int k=0; k<=norm && !flag; k++) {
				if (k*k == norm)
					flag = true;
			}
			if (flag) ++ans;
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;

int main(){
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i+=2){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;int a[1010][8];map<int,int> d={{'J',0},{'O',1},{'I',2}};main(){int n;string s;cin>>n>>s;a[0][1]=1;r(i,n)r(j,8)r(k,8)if((j&k)&&((k>>d[s[i]])&1))(a[i+1][k]+=a[i][j])%=10007;r(i,7)(a[n][7]+=a[n][i])%=10007;cout<<a[n][7]<<endl;}

Measured memory_bytes: 1244
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))

from collections import defaultdict
from heapq import heappush, heappop
dd = defaultdict(list)

for _ in range(n):
    a,b = tuple(map(int,input().split()))
    dd[a].append(b)

hq = []
ret = 0
for i in range(1,m+1):
    for j in dd[i]:
        heappush(hq,-j)
    if hq:
        ret+=heappop(hq)
print(-ret)

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A == 1)
    {
        A += 13;
    }
    if (B == 1)
    {
        B += 13;
    }

    if (A > B)
    {
        cout << "Alice" << endl;
    }
    else if (A < B)
    {
        cout << "Bob" << endl;
    }
    else
    {
        cout << "Draw" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())

S = input()

t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  A.erase(unique(A.begin(),A.end()), A.end());
  cout<<A<<endl;
  return 0;
}



Measured memory_bytes: 3572
d, n = map(int, input().split())

if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(n * 100)
else:
    if n == 100:
        print(1010000)
    else:
        print(n * 10000)


Measured memory_bytes: 2940
#include <iostream>
#include <numeric>
#include <vector>

int main(int argc, char *argv[]) {
  int n, m, x;
  std::cin >> n >> m >> x;
  std::vector<int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    int c;
    std::cin >> c;
    a.at(c) = 1;
  }

  std::cout << std::min(std::accumulate(a.begin(), a.begin() + x, 0),
                        std::accumulate(a.begin() + x, a.end(), 0))
            << std::endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
al = list(map(int, input().split()))
al_abs = []
al_p = []
al_m = []
zero_cnt = 0
MOD = 10**9+7

if n == 1 and k == 1:
    print(al[0]%MOD)
    exit()

if n == k:
    ans = 1
    for a in al:
        ans *= a
        ans %= MOD
    print(ans)
    exit()

for a in al:
    if a == 0:
        zero_cnt+=1
    else:
        if a > 0: 
            al_abs.append((abs(a),1))
            al_p.append(a)
        elif a < 0: 
            al_abs.append((abs(a),-1))

al_abs.sort(reverse=True)
if len(al_abs) < k:
    print(0)
    exit()

if len(al_abs) == k:
    ans = 1
    m_cnt = 0
    for a,s in al_abs:
        if s == -1: m_cnt += 1
        ans *= a
        ans %= MOD
    if m_cnt%2 == 0:
        print(ans)
    else:
        print(0)
    exit()
    

if not al_p:
    if k%2 == 1 and zero_cnt > 0:
        print(0)
    else:
        if k%2 == 1:
            al_abs.sort()
        ans = 1
        for a,s in al_abs[:k]:
            ans *= (a*(-1))
            ans %= MOD
        print(ans)
    exit()



val = 1
m_cnt = 0
last_m = 0
last_p = 0
for i in range(k):
    v,sig = al_abs[i]
    val *= v
    val %= MOD
    if sig == -1:
        m_cnt += 1
        last_m = v
    else:
        last_p = v

if m_cnt %2 == 0:
    print(val)
    exit()


# minus -> plus 

## search next p
next_p = 0
for i in range(k,len(al_abs)):
    v,sig = al_abs[i]
    if sig == 1:
        next_p = v
        break

## search next m
next_m = 0
for i in range(k,len(al_abs)):
    v,sig = al_abs[i]
    if sig == -1:
        next_m = v
        break

# print(next_m, next_p)

if next_p == 0 and next_m == 0:
    print(0)
    exit()

# last_m -> next_p
if next_p*last_p >= next_m*last_m or last_p == 0:
# if next_p > 0 and next_m == 0:
    ans = 1
    skip_flag = False
    for i in range(k):
        v,sig = al_abs[i]
        if not skip_flag and v == last_m and sig == -1:
            ans *= next_p
            skip_flag = True
        else:
            ans *= v
        # print(ans)
        ans %= MOD
    print(ans)
    exit()


# last_p -> next_m
# if next_p == 0 and next_m > 0:
elif next_p*last_p <= next_m*last_m:
    ans = 1
    skip_flag = False
    for i in range(k):
        v,sig = al_abs[i]
        if not skip_flag and v == last_p and sig == 1:
            ans *= next_m
            skip_flag = True
        else:
            ans *= v
        ans %= MOD
    print(ans)
    exit()

Measured memory_bytes: 124700
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int pow(int p, int k) {
	int ret = 1;
	rep(i, k) ret *= p;
	return ret;
}

int main() {
	int n; cin >> n;
	int seki = 1;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2 == 0) seki *= 2;
	}
	cout << pow(3, n) - seki << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double d; cin >> d;
  ll x = floor(d/1.08);
  ll y = x+1;
  if(floor(x*1.08)==d){
    cout << x << endl;
  }else if(floor(y*1.08)==d){
    cout << y << endl;
  }else{
    cout << ":(" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n,k;
    cin>>n>>k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }

    for (int i = k; i < n; ++i)
    {
        if(a[i]>a[i-k]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,b) for (int i = 0; i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    int N;
    cin >> N;
    string s[N];

    int na,nb, nab;
    na = nb = nab = 0;
    int ans  = 0;
    rep(i,N) {
        cin >> s[i];
        if (s[i][0] == 'B' && s[i].back()=='A') {
            nab++;
        }
        else if (s[i][0] == 'B') {
            nb++;
        }
        else if (s[i].back()=='A') {
            na++;
        }
        rep(j,s[i].size()-1) {
            if (s[i][j]=='A' && s[i][j+1]=='B') {
                ans++;
            }
        }
    }

    if (na+nb==0) {
        ans += max(nab-1,0);
    }
    else {
        ans += nab+min(na,nb);
    }
    cout << ans << endl;


}


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>
#define MOD 998244353

char x[310];
int next[310];
int p[5];
long long int check[310][310][310];
long long int func(int k, int s, int t)
{
	if(k==0) return 1;
	else if(k<0) return 0;
	if(check[k][s][t]!=-1) return check[k][s][t];
	
	//s>0 : 1, s<0 : 0
	long long int s1 = 0, s2 = 0;
	if(x[k]=='0')
	{
		s1 = func(k-1,s,t);
		if(s>=1) s2 = func(k,s-1,t);
	}
	else
	{
		if(t>= (k-next[k])) s1 = func(next[k]-1,s + (k-next[k]), t - (k-next[k]));
		s2 = func(k-1,s,t);
	}
	return check[k][s][t] = (s1+s2)%MOD;
}

int main()
{
	int a,b;
	scanf("%s %d",x+1,&b);
	a = strlen(x+1);
	if(b>=300) b = 300;
	for(int i=0;i<=a;i++) for(int j=0;j<=b;j++) for(int k=0;k<=b;k++) check[i][j][k] = -1;
	
	for(int i=1;i<=a;i++)
	{
		int k = x[i]-'0';
		next[i] = p[1-k];
		p[k] = i;
	}
	
	printf("%lld",func(a,0,b));
	//n k 
}

Measured memory_bytes: 221620
class Dice:
    def __init__(self):
        # top, front, right, left, back, bottom
        self.numbers = map(int, raw_input().split())
    
    @property
    def top(self):
        return self.numbers[0]
    
    @property
    def front(self):
        return self.numbers[1]
        
    @property
    def right(self):
        return self.numbers[2]
        
    @property
    def left(self):
        return self.numbers[3]
    
    @property
    def back(self):
        return self.numbers[4]
        
    @property
    def bottom(self):
        return self.numbers[5]

    def roll(self, direction):
        if direction == "N":
            before_inds = [0, 1, 5, 4]
            after_inds  = [1, 5, 4, 0]
        elif direction == "S":
            before_inds = [0, 1, 5, 4]
            after_inds  = [4, 0, 1, 5]
        elif direction == "E":
            before_inds = [0, 2, 5, 3]
            after_inds  = [3, 0, 2, 5]
        elif direction == "W":
            before_inds = [0, 2, 5, 3]
            after_inds  = [2, 5, 3, 0]
        else:
            return False
        changed = [self.numbers[i] for i in after_inds]
        for c_i, n_i in enumerate(before_inds):
            self.numbers[n_i] = changed[c_i]
        return True
        
dice = Dice()
for d in raw_input():
    dice.roll(d)
    
print dice.top

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

using namespace std;
typedef long long ll;
int n;
ll a[ 19 ];

ll calc(int l, int r, ll xl, ll xr) {
      if (r - l == 1) return a[l] * xl + a[r] * xr;
      ll ans = 1ll << 60;
      for (int i = l + 1; i < r; i++) {
        ans = min(ans, calc(l, i, xl, xl + xr) + calc(i, r, xl + xr, xr) - (xl + xr) * a[i]);
      }
      return ans;
    }


int main()
{
    scanf( "%d", &n );
    for( int i = 1; i <= n; i ++ )
    {
        scanf( "%lld", &a[ i ] );
    }
    printf( "%lld", calc( 1, n, 1, 1 ) );
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int calc(int k){
    int sum=0;
    while(k>0){
        sum+=k%10;
        k/=10;
    }
    return sum;
}

signed main()
{
    int N,A,B; cin>>N>>A>>B;

    int ans=0;
    for(int i=1;i<=N;i++){
        int sum=calc(i);
        if(A<=sum and sum<=B) ans+=i;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
n, k = map(int, input().split())
P = tuple(map(lambda x: int(x)-1, input().split()))
C = tuple(map(int, input().split()))
CC = [[] for _ in range(n)]
for idx, p in enumerate(P):
    CC[idx].append(C[p])
    pp = P[p]
    for _ in range(n):
        CC[idx].append(C[pp])
        pp = P[pp]
        if pp == p:
            break
        
from itertools import accumulate
ans = -2*(10**9)
for cc in CC:
    cca = list(accumulate(cc))
    if cca[-1] <= 0:
        # 1周分のうちの最大値
        if k < len(cc):
            ans = max(ans, max(cca[:k]))
        else:
            ans = max(ans, max(cca))
    else:
        # kk周したほうが良い
        kk, r = divmod(k, len(cc))
        if r == 0:
            ans = max(ans, kk*cca[-1], (kk-1)*cca[-1]+max(cca))
        else:
            ans = max(ans, kk*cca[-1] + max(cca[:r]))
print(ans)


Measured memory_bytes: 298592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;
int main(){
int n;
int a[101];
int los=0,ans=1;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
}
a[n+1]=0;
for(int i=0;i<=n+1;i++){
if(a[i]==0){
ans=max(ans,i-los);
los=i;
}
}
cout << ans << endl;
return (0);
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int solve(vector<int> a){
	while(true){
		sort(ALL(a));
		bool update = false;
		vector<int> prev = a;
		int aind = -1;
		rep (i, (int)a.size()){
			if (a[i] == 0) continue;
			aind = i;
			break;
		} // end if

		for (int i = aind + 1; i < (int)a.size(); ++i){
			a[i] = a[i] % a[aind];
		} // end for
		rep (i, (int)a.size()){
			update |= (prev[i] != a[i]);
		} // end rep
		if (!update){
			break;
		} // end if
	} // end while

	rep (i, (int)a.size()){
		if (a[i] != 0){
			return a[i];
		} // end if
	} // end rep

	return -1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> A(N, 0);

	bool all_odd = true, all_even = true;
	set<int> all_same; all_same.clear();

	rep (i, N){
		cin >> A[i];
		all_odd &= (A[i] % 2 != 0);
		all_even &= (A[i] % 2 == 0);
		all_same.insert(A[i]);
	} // end rep

	if (all_same.size() == 1){
		cout << A[0] << endl;
		return 0;
	} // end if

	if (all_odd || all_even){
		int res = solve(A);
		cout << res << endl;
		return 0;
	} // end if

	vector<int> odd; odd.clear();
	vector<int> even; even.clear();
	rep (i, N){
		if (A[i] % 2 == 0){
			even.push_back(A[i]);
		}else{
			odd.push_back(A[i]);
		} // end if
	} // end rep

	vector<int> ans; ans.clear();
	if (!even.empty()){
		int curr = solve(even);
		ans.push_back(curr);
	} // end if

	if (!odd.empty()){
		int curr = solve(odd);
		ans.push_back(curr);
	} // end if

	int res = solve(ans);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6268
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){
    int n,m;
    I2(n ,m);
    int res = m * (m-1)/2 ;
    res += n * (n-1)/2;
    cout<<res<<endl;

    return 0;
}

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

old_t = 0
old_x = 0
old_y = 0

for _ in range(N):
    t, x, y = list(map(int, input().split()))
    rest_t = t - old_x
    diff = abs(x - old_x) + abs(y - old_y)
    if (rest_t < diff) or (old_t - t + old_x - x + old_y -y) % 2 != 0:
        print("No")
        exit()
    old_t = t
    old_x = x
    old_y = y

print("Yes")




Measured memory_bytes: 3060
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
vector<P>G[20000];
int n,u,k;
const int INF=100000000;
int ans[20000];

int main(){
	int from,cost;
	cin>>n;

	rep(i,n){
		cin>>u>>k;
		rep(i,k){
				cin>>from>>cost;
				G[u].push_back(mp(from,cost));
		}
	}
	rep(i,n)ans[i]=INF;
	//ans[0]=0;
	priority_queue<P,vector<P>,greater<P> >que;//firstスタートからの重みsecond頂点
	que.push(mp(0,0));
	
	while(!que.empty()){
		P now=que.top();
		que.pop();
		if(ans[now.second]!=INF)continue;
		int index=now.second;
		ans[index]=now.first;
		//cout<<now.first<<endl;
		for(int i=0;i<G[now.second].size();i++)que.push(mp(now.first+G[index][i].second,G[index][i].first));//次への経路長、頂点番号
	}
	for(int i=0;i<n;i++)cout<<i<<" "<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 12184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    cin >> s;
    ll N = s.size();
    vector<ll> c(N,0);
    ll l = 0, r = 1;
    rep(i, 1, N){
        if(s[i] == 'R'){
            if(s[i-1] == 'R'){
                r++;
            }else{
                r++;
                c[i-l] = l;
                l = 0;
            }
        }else{
            if(s[i-1] == 'L'){
                l++;
            }else{
                l++;
                c[i-1] = r;
                r = 0;
            }
        }
    }
    c[N-l] = l;

    rep(i, 0, N){
        if(c[i] != 0){
            if((c[i]+c[i+1])%2 == 0){
                cout << (c[i]+c[i+1])/2 << " " << (c[i]+c[i+1])/2 << " ";
            }else{
                ll t = (ll)((c[i]+c[i+1])/2);
                if(c[i] > c[i+1]){
                    if(c[i]%2 == 0){
                        cout << t << " " << t+1 << " ";
                    }else{
                        cout << t+1 << " " << t << " ";
                    }
                }else{
                    if(c[i+1]%2 == 0){
                        cout << t+1 << " " << t << " ";
                    }else{
                        cout << t << " " << t+1 << " ";
                    }
                }
            }
            i++;
        }else{
            cout << "0 ";
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	int ans=800;
	for (int i = 0; i < s.size() - 2; i++) {
		int k = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		ans = min(ans, abs(753 - k));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int a[4];
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  rep(i, 0, 4) cin >> a[i];
  int l = a[0] + a[1], r = a[2] + a[3];
  if (l < r) cout << "Right" << endl;
  else if (l == r) cout << "Balanced" << endl;
  else cout << "Left" << endl;
  return 0;
}



Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


vector<ll> divosor(ll n){
  vector<ll> ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  return ret;
}


bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

signed main(){
  int N;
  cin>>N;
  bool one=false;
  map<ll,int> num_map;
  int tmp;
  for(int i = 0; i < N;i++){
    cin>>tmp;
    auto itr=num_map.find(tmp);
    if(itr!=num_map.end()){
      ll m=itr->second;
      num_map[tmp]=m+1;
    }else{
      num_map[tmp]=1;
    }
    if(tmp==1)one=true;
  }
  int ans=0;
  bool found=false;
  for (const auto& [key, value] : num_map){
    found=false;
    if(value>1){
      found=true;
      continue;
    }
    if(IsPrime(key)&&!one){
      ans++;
      continue;
    }
    vector<ll> ret=divosor(key);
    for(auto itr=ret.begin();itr!=ret.end();++itr){
      if(key==*itr)continue;
      if(num_map.find(*itr)!=num_map.end()){
        found=true;
        continue;
      }
    }
    if(!found)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 16224
n = int(input())
a = [int(i) for i in input().split()]

cnt_4 = sum(i%4==0 for i in a)
cnt_2 = sum(i%2==0 for i in a) - cnt_4
cnt_0 = n - cnt_4 - cnt_2

if cnt_2 == 0:
  if cnt_4 >= cnt_0-1:
    print('Yes')
  else:
    print('No')
else:
  if cnt_4 >= cnt_0:
    print('Yes')
  else:
    print('No')
    

Measured memory_bytes: 14252
import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7
    
    fac = [0]*(N+1)
    invfac = [0]*(N+1)
    fac[0],fac[1] = 1,1
    invfac[0],invfac[1] = 1,1
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    invfac[-1] = pow(fac[-1],MOD-2,MOD)
    for i in range(N,0,-1):
        invfac[i-1] = (invfac[i]*i)%MOD
        
    def comb(x,y):
        return (fac[x]*invfac[y]*invfac[x-y])%MOD
        
    ans = 0
    for i in range(min(N,K+1)):
        a = comb(N,i)
        b = comb(N-1,N-i-1)
        ans += (a*b)%MOD
        
    print(ans%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 18804
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;

#define EPS (1e-7)
const long long INF = 1LL << 60;
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n,k;
ll h[100010];
ll dp[100010];

void input(){
    cin >> n >> k;
    for(int i=0;i<n;++i) cin >> h[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<n;++i) dp[i] = INF;
    dp[0] = 0;
    for(int i=0;i<n;++i){
        for(int j=1;j<=k && i+j<100010;++j){
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792