akhauriyash/Code-Regression huggingface dataset:
// ARC097 C
#include<iostream>
#include<string>

using namespace std;

int current_index = 0;

string func(string str, string prefix, int target_index) {
  char a_char = 'a';
  int i;

  for (i = 0; i < 26; i++) {
    // 付け足す文字列
    char c = a_char + i;

    int pos = str.find(prefix + c);
    // cout << "search: " << (prefix + c) << endl;
    if (pos != string::npos) {
      // 見つかった場合
      current_index++;
      // cout << "  matched!, current_index: " << current_index << endl;
      if (current_index == target_index) {
        // 目的の順番の場合
        return prefix + c;
      }
      else {
        // 目的の順番より若い場合
        string ret = func(str, prefix + c, target_index);
        if (ret != "") {
          // 結果が戻って来たら正解
          return ret;
        }
      }
    }
  }
  return "";
}


int main(void) {
    string str;
    int k;

    char c = 'a';

    cin >> str;
    cin >> k;

    cout << func(str, "", k) << endl;

    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	cout << (n + 1)	/ 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
int main(){
  int n,k;
  std::cin >> n>>k;
  string s;
  std::cin >> s;
  std::vector<int> a;
  int c=0,cc=0;
  if(s[0]=='0'){
    c++;
    a.pb(0);
    
  }
  rep(i,n){
    if(c%2==0){
      if(s[i]=='1'){
        a.pb(cc);
        c++;
        cc=1;
      }
      else{
        cc++;
      }
    }
    else{
      if(s[i]=='0'){
        a.pb(cc);
        c++;
        cc=1;
      }
      else{
        cc++;
      }
    }
  }
  c++;
  a.pb(cc);
  if(s[s.size()-1]=='0'){
    c++;
    a.pb(0);
  }
  std::vector<int> b(c+1,0);
  rep(i,c){
    b[i+1]=b[i]+a[i];
  }
  int ans=0;
  
  //rep(i,c+1)std::cout << b[i] << std::endl;
  if(2*k>=a.size()){
    std::cout << b[b.size()-1]-b[0] << std::endl;
    exit(0);
  }
  rep(i,b.size()-(2*k+1)){
    if(i%2==1)ans=max(ans,b[i+2*k+1]-b[i]);
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 1272
#[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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
    input!{
      n: usize,
      m: usize,
      aa: [usize; n],
    }
    //  1<=l<=r<=N
    // SUM(A[l]..A[r]) = aM
    let mut s = vec![0; n+1];
    for i in 1..n+1 {
        s[i] = s[i-1] + aa[i-1];
    }
    let mut map: HashMap<usize, usize> = HashMap::new();
    for i in 0..n+1 {
        let x = s[i] % m;
        let e = map.entry(x).or_insert(0);
        (*e) += 1
    }
    let mut ans = 0;
    for (_k, v) in map {
        ans += (v*(v-1))/2;
    }
    println!("{}", ans);
}


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

const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(false);

	int N, W;
	cin >> N >> W;
	vector<ll> w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	int C = 1000 * N;
	vector<vector<ll>> dp(N, vector<ll> (C + 1, INF));
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= C; j++) {
			if (j < v[i]) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = min(dp[i - 1][j], w[i] + dp[i - 1][j - v[i]]);
		}
	}
	ll answer = 0;
	for (int i = 0; i <= C; i++) {
		if (dp[N - 1][i] <= W) {
			answer = i;
		}
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 79616
S = input()
a = S[:len(S)//2]
b = S[len(S)//2+1:]
ans = 'Yes'
for i in range(len(a)//2):
    if a[i] != a[len(a)-i-1]:
        ans = 'No'
        break
for i in range(len(b)//2):
    if b[i] != b[len(b)-i-1]:
        ans = 'No'
        break
for i in range(len(S)):
    if S[i] != S[len(S)-i-1]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(m[x]==0) 
		{
			v.push_back(x);
		}
		m[x]++;
	}
	int s=0;
	for(int i=0;i<v.size();i++)
	{
		if(v[i]>m[v[i]])
		{
			s+=m[v[i]];
		} 
		else 
		{
			if(v[i]<m[v[i]]) 
			{
				s+=m[v[i]]-v[i];
			}
		}
	}
	cout<<s;
	return 0; 
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	
	int a,b,c;
	cin>>a>>b>>c;
	a=abs(a);
	int m=a/c;
	if(b<=m)
	cout<<(a-b*c)<<endl;
	else
	{
		a-=(m*c);
		if((b-m)%2==0)
		{
			cout<<min(a,abs(a-(2*c)));
		}
		else
		{
			cout<<min(abs(a-c),min(abs(a+c),abs(a-3*c)))<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3596
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int X,Y,Z; cin >> X >> Y >> Z;
    cout << (X-Z)/(Y+Z) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int nums[105][105];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

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

    for (int i = 0; i < a; ++i) {
        for (int j = 0; j < b; ++j) {
            scanf("%d", &nums[i][j]);
            nums[i][b] += nums[i][j];
        }
    }

    for (int j = 0; j <= b; ++j) {
        for (int i = 0; i < a; ++i) {
            nums[a][j] += nums[i][j];
        }
    }

    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j < b; ++j) {
            printf("%d ", nums[i][j]);
        }
        printf("%d\n", nums[i][b]);
    }
    return 0;
}



Measured memory_bytes: 2072
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

kyori = abs(A-B)
sa =abs(V-W)

if V<=W:
  print('NO')
else:
  if kyori <= sa*T:
    print('YES')
  else:
    print('NO') 


Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
     ll n ; cin >> n ;
     cout << (n+1)/2 << endl;
}

Measured memory_bytes: 3612
I = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(I[K-1])

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

int main(){
  string s;
  cin >> s;
  int l = s.length();
  if(s[0] == '0' || s[l-1] == '1' || s[l-2] == '0') {
    cout << -1 << endl;
    return 0;
  }
  rep(i,l-1) {
    if(s[i] != s[l-2-i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  int p = l;
  for(int i = l-2; i >= 0; i--) {
    cout << i+1 << " " << p << endl;
    if(s[i] == '1') p = i+1;
  }
  return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

//        int cnt = 0;
//        for (int i = 1; i <= N; i++) {
//            if (String.valueOf(i).length() % 2 != 0) {
//                cnt++;
//            }
//        }
//        System.out.println(cnt);

        long cnt = IntStream.rangeClosed(1, N).filter(i -> String.valueOf(i).length() % 2 != 0).count();
        System.out.println(cnt);
    }
}


Measured memory_bytes: 32588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
	  string s, t;
    cin >> s >> t;
		int ct=0;
		rep(i, s.length()){
			if(s[i]!=t[i]) ct++;
		}
	      
	  cout << ct << endl;
	  return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int x,y;
    cin >> x >> y;
    if(y>=x*2&&y<=x*4&&y%2==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main(void)
{
    int n;
  char a[104],b[104],c[208];
  scanf("%d%s%s",&n,&a,&b);

  int i;
  for(i=0;i<n;i++)
  {
      printf("%c%c",a[i],b[i]);
  }
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
const int MAXN = 2e6 + 10;
const int mod = 1e9 + 7;
ll r1, c1, r2, c2;
ll fac[MAXN], inv[MAXN];
ll fastpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1)
            ret = ret * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return ret;
}
ll getC(ll a, ll b) {
    return (a < b ? 0 : (fac[a] * inv[b] % mod * inv[a - b] % mod));
}
int main() {
    scanf("%lld%lld%lld%lld", &r1, &c1, &r2, &c2);
    ll n = max(c1, c2) + r2 + 2;
    fac[0] = inv[0] = 1;
    for(reg int i = 1; i <= n; ++i)
        fac[i] = fac[i - 1] * i % mod;
    inv[n] = fastpow(fac[n], mod - 2);
    for(reg int i = n; i; i--)
        inv[i - 1] = inv[i] * i % mod;
    ll ret1 = 0, ret2 = 0;
    for(reg int i = r1; i <= r2; ++i)
        ret1 = (ret1 + getC(i + c2 + 1, i + 1)) % mod;
    for(reg int i = r1; i <= r2; ++i)
        ret2 = (ret2 + getC(i + c1, i + 1)) % mod;
    printf("%lld\n", (ret1 - ret2 + mod) % mod);
    return 0;
}


Measured memory_bytes: 31488
#include<iostream>

using namespace std;
int N;
int a[20][20];
int memo[1<<16];

int rec(int state){

   if(memo[state]) return memo[state];
   if(state==(1<<N)-1) return 0;
   int ret=1e8;
   for(int i=0; i<N; i++){
      if((state>>i)&1) continue;
      int cost=a[i][0];
      for(int j=0; j<N; j++){
         if((state>>(j))&1) cost=min(cost, a[i][j+1]);
      }
      ret=min(ret, cost+rec(state+(1<<i)));
   }

   return memo[state]=ret;
}

void hoge(){

   for(int i=0; i<N; i++){
      for(int j=0; j<N+1; j++){
         cin>> a[i][j];
      }
   }

   cout<< rec(0)<< endl;

}

int main(){

   while(1){
      cin>> N;
      if(!N) break;
      for(int i=0; i<(1<<16); i++) memo[i]=0;
      hoge();
   }

   return 0;
}

Measured memory_bytes: 3276
# Here your code !


n=gets.to_i
array=[]
n.times{
    array<<gets.to_i
    
    
}

if n==1 
   puts array[0]

else

a=array[0]
i=1

(array.length-1).times{
 b=array[i]
 c=a.lcm(b)
 a=c
 
 i=i+1
    
    
    
    
}


puts a
end
    
    

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

int main(){
	ll n,x,t;
	cin>>n>>x>>t;
	
	ll k=n/x,r=n%x;
	
	if(r>0)r=1;
	
    cout<<k*t+r*t;
	

}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s, s2;
    cin >> s;
    string t1, t2;
    s2 = string(s);
    ll n = s.size();
    reverse(all(s2));
    if (s == s2) {
        rep(i, (n - 1) / 2) {
            t1 += s[i];
            t2 += s[i];
        }
        reverse(all(t2));
        if (t1 == t2) {
            string t1, t2;
            for (ll i = (n + 3) / 2 - 1; i < n; i++) {
                t1 += s[i];
                t2 += s[i];
            }
            reverse(all(t2));
            if (t1 == t2) {
                cout << "Yes" << '\n';
                return;
            }
        }
    }
    cout << "No" << '\n';
}

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


Measured memory_bytes: 256
fun main() {
  val s = readLine()!!
  val t = readLine()!!
  
  val sLen = s.length
  val tLen = t.length
  var ans = tLen
  for(i in 0 until sLen-tLen+1) {
    var count = 0
    for(j in 0 until tLen){
      if(s[i+j]!=t[j]) count++
    }
    if(ans>count) ans=count
  }
  println(ans)
}

Measured memory_bytes: 35880
s = input()
s = list( map(int,s) )

ansa = 0
ansb = 0

a = 0 #01010101
b = 1 #10101010

for i in s:

  if i != a:
    ansa += 1
  
  if i != b:
    ansb += 1

  a = (a+1)%2
  b = (b+1)%2

print(min(ansa,ansb))

Measured memory_bytes: 3956
#include <stdio.h>
int main(void){
    long long x;
    scanf("%lld",&x);
    long long ans = 0;
    ans += 2 * (x/11);
    x -= 11 * (x/11);
    if(x > 0){
        x -= 6;
        ans += 1;
    }
    if(x > 0){
        x -= 5;
        ans += 1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
#ABC80 C

from operator import itemgetter
import collections

n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

ma = -float('inf')
for i in range(1,2**10):
    b = [0]*10
    s = 0
    sum = 0
    for j in range(10):
        if (i>>j) & 1:
            b[j] = 1
    for j in range(n):
        for k in range(10):
            if f[j][k] & b[k]:
                s += 1
        sum += p[j][s]
        s = 0
    ma = max(ma,sum)
print(ma)


Measured memory_bytes: 43116
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infd DBL_MAX
#define infl 10e17
#define mod 1000000007ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
    os << "[";
    typename multiset< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}
#define pr(x) cerr << #x << " = " << x << endl;

int main()
{
    int n,flag=0;
    scanf("%d",&n);
    int a[n+5][2];
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&a[i][0],&a[i][1]);
    }
    for(int i=1;i<=n-2;++i)
    {
        if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}



Measured memory_bytes: 3720
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  int x;

  cin >> a >> b >> x;

  if ( x < a + b  && x >= a) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return (0);
}



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

int main()
{
  int a , b , c;
  cin>>a>>b>>c;
  a+=b;
  b=a-b;
  a-=b;
  a+=c;
  c=a-c;
  a-=c;
  cout<<a<<" "<<b<<" "<<c;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 2e5 + 5, MAXM = 3e5 + 5, BOUND = 1e7, MOD = 1073741824, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))

int a, b;
db t;
int main() {
	cin >> a >> b >> t;
	t += 0.5;
	cout << (int)(t / a) * b << '\n';
	return 0;
}

Measured memory_bytes: 384
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = warshall_floyd(c)
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1 and A[i][j] != 1:
            ans += d[A[i][j]][1]
print(ans)

Measured memory_bytes: 73772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int n;
	long long k[1000];
	long long ans = 0 , min = 100000007;
	long long ans1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k[i];
	}
	for (int j = 0; j < 1000; j++) {
		for (int l = 0; l < n; l++) {
			ans += (k[l] - j) * (k[l] - j);
		}
		if (ans < min) {
			min = ans;
		}
		ans = 0;
	}
	cout << min << endl;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	string s; cin >> s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
int a;
  int b=0,c=0,d=0,e=0;
  cin>>a;
  for(int i=0;i<a;i++){
  string s;
    cin>>s;
    if(s=="AC"){b++;}
    if(s=="WA"){c++;}
    if(s=="TLE"){d++;}
    if(s=="RE"){e++;}
  }
  cout<<"AC"<<" "<<"x"<<" "<<b<<endl
    <<"WA"<<" "<<"x"<<" "<<c<<endl
    <<"TLE"<<" "<<"x"<<" "<<d<<endl
    <<"RE"<<" "<<"x"<<" "<<e<<endl;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

using ll = long long;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

signed main() {
    int N, P;cin >> N >> P;
    map<int, int> mp;
    COMinit();
    for(int i = 0;i < N;i++){
        int a;cin >> a;
        mp[a % 2]++;
    }
    ll zero = 1;
    for(int i = 0;i < mp[0];i++)zero *= 2;
    if(P == 0){
        ll one = 0;
        for(int i = 0;i <= mp[1];i+=2){
            one += COM(mp[1], i);
        }
        if(mp[1] == 0)one = 1;
        cout<<zero * one<<endl;
    }else{
        ll one = 0;
        for(int i = 1;i <= mp[1];i+=2){
            one += COM(mp[1], i);
        }
        cout<<zero * one<<endl;
    }
}


Measured memory_bytes: 15572
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readLongList()
    val aList = readLongList()

    if (k == 0L) {
        out.println(aList.max())
        return
    }

    fun check(value: Long): Boolean {
        var count = 0L
        for (a in aList) {
            count += (a - 1) / value
        }
        return count <= k
    }

    var ng = 0L
    var ok = 1_000_000_001L
    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (check(mid)) {
            ok = mid
        } else {
            ng = mid
        }
    }

    out.println(ok)
}




fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
ll A[MAX_N];
ll C[MAX_N];

int main2() {
  CLR(A, 0);
  CLR(C, 0);

  int N = nextInt();
  REP(i, N + 1) A[i] = nextInt();

  if (N == 0) {
    if (A[0] == 1) cout << 1 << endl; else cout << -1 << endl;
    return 0;
  }

  if (A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

  // pv(A, A+N+1);

  bool ng = false;
  C[0] = 1;
  for (int i = 1; i < N; i++) {
    C[i] = min(1LL << 59, C[i-1] * 2 - A[i]);
    if (C[i] < 0) ng = true;

  }
  // pv(C, C+N+1);

  for (int i = N - 1; i >= 0; i--) {
    ll x = C[i+1] + A[i+1];
    if (C[i] < (x+1)/2) ng = true;
    if (C[i] > x) { C[i] = x; }
  }

  // pv(C, C+N+1);

  if (ng) {
    cout << -1 << endl;
  } else {
    ll ans = 0;
    REP(i, N+1) ans += C[i] + A[i];
    cout << ans << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 5560
N, W = list(map(int, input().split()))
dp = [-1] * (W + 1)
dp[0] = 0
for i in range(N):
    w, v = list(map(int, input().split()))
    for i in range(W, -1, -1):
        left = i - w
        if left >= 0 and dp[left] >= 0:
            dp[i] = max(dp[i], dp[left] + v)

print(max(dp))


Measured memory_bytes: 41836
import itertools
import copy

n,m,q = map(int,input().split())
a = [[0]*4]*q
for i in range(q):
	a[i] = list(map(int,input().split()))

candidate = list(itertools.combinations_with_replacement(range(1,m+1), n))

chanpion=0
for cand in candidate:
  point=0
  for l in range(q):
    if cand[a[l][1]-1]-cand[a[l][0]-1]==a[l][2]:
    	point += a[l][3]
  if point>chanpion:
    chanpion=copy.copy(point)
    
print(chanpion)

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s=to_string(n);
    int div=0;
    for(int i=0;i<s.length();i++){
        div+=s[i]-'0';
    }
    if(n%div) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void insertionSort(int A[],int N){
	int i,j,k;
	for(k=0;k<N-1;k++)
		printf("%d ",A[k]);
	
	printf("%d\n",A[N-1]);
	
	for(i=1;i<N;i++){
		int v=A[i];
		j=i-1;			
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for(k=0;k<N-1;k++)
			printf("%d ",A[k]);
		printf("%d\n",A[N-1]);
	}
			
}

int main(void){
		int n;
		int array[1001];
		scanf("%d",&n);
		for(int i=0;i<n;i++)
			scanf("%d",&array[i]);

		insertionSort(array,n);
		
			
		return 0;
}

Measured memory_bytes: 1744
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, m;
	cin >> n >> m;

	Graph g(n);

	REP(i, m) {
		ll s, t;
		cin >> s >> t;
		s--; t--;
		add_edge(g, s, t, 1, false, 0);
	}
	double ans = INF;
	REP(i, n) {
		vector<double> dp(n, INF);
		dp[n - 1] = 0.0;
		for (int j = n - 2; j >= 0; j--) {
			if (i == j) {
				double max = 0.0;
				ll max_k = -1;
				double sum = 0.0;
				for (auto e : g[j]) {
					sum += dp[e.to]+e.cap;
					if (max < dp[e.to]+e.cap) {
						max = dp[e.to]+e.cap;
						max_k = e.to;
					}
				}
				if (sum - max != 0) {
					sum -= max;
					dp[j] = sum / (double)(g[j].size() - 1);
				}
				else {
					dp[j] = sum / (double)(g[j].size());
				}
			}
			else {
				double sum = 0.0;
				for (auto e : g[j]) {
					sum += dp[e.to] + e.cap;
				}
				dp[j] = sum / (double)(g[j].size());
			}
		}
		//cout << i << ":" << dp[0] << endl;
		chmin(ans, dp[0]);

	}

	cout << fixed << setprecision(7)<<ans << endl;

	return 0;
}

Measured memory_bytes: 6656
from collections import deque

n = int(input())
a = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    a[u - 1].append((v - 1, w))
    a[v - 1].append((u - 1, w))
d = [-1] * n
todo = deque([(0, 0)])
seen = set()
while todo:
    p, e = todo.popleft()
    if p in seen:
        continue
    seen.add(p)
    d[p] = e
    for pi, ei in a[p]:
        todo.append((pi, e + ei))
for di in d:
    print(di % 2)


Measured memory_bytes: 52564
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>

#define rep(i, j) for(int i = 0; i < j; i++)
#define rep2(i, j) for(int i = 0; i <= j; i++)
#define all(i) i.begin(), i.end()
#define pint(i) printf("%d\n", i)

using namespace std;

vector<bool> era(1000010, true);
void makePrimeTable(int n)
{
	era[0] = false; era[1] = false;
	for (int i = 2; i <= n; i++)
	{
		if (era[i]) { for (int j = i * 2; j <= n; j += i) { era[j] = 0; } }
	}
}
int main()
{
	makePrimeTable(500000);
	int N, P; while (cin >> N >> P && N != -1)
	{
		vector<int> dat(0);
		vector<int> prm(0);
		while (1)
		{
			N++;
			if (era[N]) { prm.push_back(N);}
			if (prm.size() == P) { break; }
		}
		for (int i = 0; i < P; i++) for (int j = i; j < P; j++) { dat.push_back(prm[i] + prm[j]); }
		sort(all(dat)); 
		printf("%d\n", dat[P - 1]);
	}
	return 0;
}

Measured memory_bytes: 3424
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

int d[500000];
vector <pair <int, int> > edges[500000];
void dijikstra(int S, int N){
    for(int i = 0; i < N; i++){
      d[i] = INT_MAX;
    }

    priority_queue < pair <long long, int>, vector <pair <long long, int> >, greater<pair <long long, int> > > pq;
    d[S] = 0;
    pq.push(make_pair(0, S));
    while(!pq.empty()){
        auto cur = pq.top();
        auto cur_cost = cur.first;
        auto cur_node = cur.second;
        pq.pop();
        if(d[cur_node] < cur_cost){
            continue;
        }

        for(int i = 0; i < edges[cur_node].size(); i++){
          int next_node = edges[cur_node][i].second;
          long long next_d = d[cur_node] + edges[cur_node][i].first;
          if(d[next_node] > next_d){
            d[next_node] = next_d;
            pq.push(make_pair(next_d, next_node));
          }
        }
      }
}

vector <pair <int, int> > org_edges[100000];
map <pair<int, int>, int> pair_to_ind;
//pair<int, int> ind_to_pair[500000];
int main(void){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int p;
    int q;
    int c;
    cin >> p >> q >> c;
    org_edges[p - 1].push_back(make_pair(q - 1, c));
    org_edges[q - 1].push_back(make_pair(p - 1, c));
  }

  for(int i = 0; i < N; i++){
    pair_to_ind[make_pair(i, 0)] = i;
    //ind_to_pair[i] = make_pair(i, 0);
  }

  int cur_ind = N;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < org_edges[i].size(); j++){
      pair<int, int> cur_edge = org_edges[i][j];
      pair_to_ind[make_pair(i, cur_edge.second)] = cur_ind;
      //ind_to_pair[cur_ind] = make_pair(i, cur_edge.second);
      edges[i].push_back(make_pair(1, cur_ind));
      edges[cur_ind].push_back(make_pair(0, i));
      cur_ind ++;
    }
  }
  int new_N = cur_ind;
  for(int i = 0; i < org_edges[N - 1].size(); i++){
    pair<int, int> cur_edge = org_edges[N - 1][i];
  }

  for(int i = 0; i < N; i++){
    for(int j = 0; j < org_edges[i].size(); j++){
      pair<int, int> cur_edge = org_edges[i][j];
      int s_ind = pair_to_ind[make_pair(i, cur_edge.second)];
      int t_ind = pair_to_ind[make_pair(cur_edge.first, cur_edge.second)];
      edges[s_ind].push_back(make_pair(0, t_ind));
    }
  }

  dijikstra(0, new_N);
  if(d[N - 1] == INT_MAX){
    cout << -1 << endl;
  } else {
    cout << d[N - 1] << endl;
  }

  /*
  for(int i = 0; i < new_N; i++){
    cout << ind_to_pair[i].first << " " << ind_to_pair[i].second << ": " << d[i] << endl;
  }
  */
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  int c = 0;
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    c += (P[i] != i+1);
  }
  if(c > 2){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
g=[[] for _ in range(3*n)]
v=[-1 for _ in range(3*n)]
for i in range(m):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    g[x].append(y+n)
    g[x+n].append(y+2*n)
    g[x+2*n].append(y)
s,t=map(int,input().split())
s,t=s-1,t-1

def bfs(x,y):
    q=deque()
    q.append(x)
    v[x]=0
    while q:
        p=q.popleft()
        for nb in g[p]:
            if v[nb]==-1:
                q.append(nb)
                v[nb]=v[p]+1
                if nb==t:
                    return v[t]//3
    return -1
    
print(bfs(s,t))

Measured memory_bytes: 82980
import sys

n = int(input())

dic = {}

for i in range(n):
  a, b = map(int,input().split())
  if not (b in dic.keys()):
    dic[b] =[]
    
  dic[b].append(a)
  
minute = 0
for k, arr in sorted(dic.items()):
  minute += sum(arr)
  if minute > k:
    print('No')
    sys.exit(0)
    
print('Yes')

Measured memory_bytes: 63628
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/


int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'A') {
			k = i;
			v.push_back(k);
		}
		if (s[i] == 'Z') {
			k = i;
			vi.push_back(k);
		}
	}
	n = vi[vi.size() - 1] - v[0] + 1;
	cout << n << endl;
}

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

using namespace std;

int main()
{
  int a, b, c, d; cin >> a >> b >> c >> d;
  a = (a+d-1)/d;
  c = (c+b-1)/b;
  if(a >= c)
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;
    cin>>s;
    int n=s.size();
    vector<ll>a(n+1,0);
    for(int i=0;i<n;i++)
        if(s[i]=='<')
            a[i+1]=a[i]+1;
    for(int i=n-1;i>=0;i--)
        if(s[i]=='>')
            a[i]=max(a[i],a[i+1]+1);
    ll sum=0;
    for(int i=0;i<=n;i++)
        sum+=a[i];
    cout<<sum<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 4764
A, B = map(int, input().split())
ans = 1
for i in range(2, 1+int(min(A**.5, B**.5))):
    if A % i == 0 and B % i == 0:
        ans += 1
    while A % i == 0:
        A //= i
    while B % i == 0:
        B //= i
if A != 1 and B != 1 and (A % B == 0 or B % A == 0):
    ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	/** 数字の和 */
	private static final int SUM = 999 + 111;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(SUM - n);
		}
	}
}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 998244353;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    string T;
    cin >> T;
    string ans;
    for (int i = 0; i < T.length(); i++) {
        if (T[i] == '?') {
            ans.push_back('D');
        } else {
            ans.push_back(T[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, b, h[100008];//b < a

bool canbeat(ll x){
	ll ans = 0;
	for(ll i = 0; i < n; i++){
		ll buf = h[i]-b*x;
		if(buf > 0){
			if(buf%(a-b) == 0){ans += buf/(a-b);}
			else{ans += buf/(a-b)+1;}
		}
	}
	return x >= ans;
}

int main() {
	cin >> n >> a >> b;
	for(ll i = 0; i < n; i++){cin >> h[i];}
	ll hmax = h[0];
	for(ll i = 1; i < n; i++){hmax = max(h[i], hmax);}
	
	ll max = hmax/b+1;//can
	ll min = 0;//cannnot
	while(max != min+1){
		ll mid = (max+min)/2;
		if(canbeat(mid)){max = mid;}
		else{min = mid;}
	}
	
	cout << max;
	return 0;
}

Measured memory_bytes: 1024
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (a,b,c) = get!(i32,i32,i32);

    println!("{}", if a+b+c >= 22 { "bust"} else {"win"});
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int N;
    cin >> N;
    char a[N];
    FOR(i,0,N)
        cin >> a[i];
    int ans = 0;
    FOR(i,1,N) {
        int cnt = 0;
        for(char c='a';c<='z';c++){
            bool left = false, right = false;
            FOR(j,0,i)
                if (a[j] == c) {
                    left = true;
                }
            FOR(j,i,N)
                if (a[j] == c) {
                    right = true;
                }
            if (left && right) {
                cnt++;
            }
            if (ans < cnt) {
                ans = cnt;
            }
        }
    }
    cout << ans << endl;  
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    char S[20];
    char T[20];
    int i,f;
 
    f=1;
 
  for(i=0;i<20;i++){
        S[i]= 0;
        T[i]= 0;
    }

    scanf("%s",&S);
    scanf("%s",&T);
 
    for(i=0;S[i]!=0;i++){
        f=f*(S[i] == T[i]);
    }
 
    if(f)
        printf("Yes");
    else
    {
        printf("No");
    }
    
 
    return 0;
}

Measured memory_bytes: 1732
N = int(input())
*v, = map(int, input().split())
for _ in range(N - 1):
    min_v = min(v)
    v.remove(min_v)
    min_v_2 = min(v)
    v.remove(min_v_2)
    v.append((min_v + min_v_2) / 2)
print(*v)

Measured memory_bytes: 3064
N = int(input())
num_list = [[int(item) for item in input().split()] for _ in range(N)]
num_list2 = []
for x, l in num_list:
    num_list2.append([x-l, x+l])

num_list2.sort(key=lambda x: x[1]) 
# print(num_list2)

temp_max = num_list2[0][1]
cnt = 1

for l, h in num_list2:
    if l >= temp_max:
        cnt += 1
        temp_max = h

print(cnt)


Measured memory_bytes: 39464