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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N;
  cin >> N;
  vi64 A(N), B(N);
  cin >> A >> B;
  i64 cnt;
  {
    cnt = accumulate(all(B), 0ll) - accumulate(all(A), 0ll);
    if (cnt < 0) no();
  }
  i64 acnt = cnt, bcnt = cnt;
  rep(i, N) {
    i64 a = A[i], b = B[i];
    i64 c = 0;
    if (a < b) {
      c += (b - a + 1) / 2;
      a += c * 2;
      acnt -= c;
    }
    if (a > b) {
      c += a - b;
      bcnt -= a - b;
    }
    A[i] = a, B[i] = b;
  }
  if (acnt >= 0 && bcnt >= 0 && acnt * 2 == bcnt) yes(); no();
}


Measured memory_bytes: 384
/**
 *   author:  cryforthemoon46
 *   created: 25.05.2020 16:58:26
**/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)
#define FOREACH(x, a) for(auto&& x : (a))

const double EPS = (double)(1e-7);
const ll INF = (ll)1e18;
const int MOD = (int)1e9 + 7;
const ll dx[4] = { 0,  1,  0, -1};
const ll dy[4] = {-1,  0,  1,  0};

ll N, M, C;
ll B[21];
ll A;
ll sum;
ll ans = 0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M >> C;
    FOR(i, 1, M + 1) {
        cin >> B[i];
    }
    FOR(i, 1, N + 1) {
        sum = 0;
        FOR(j, 1, M + 1) {
            cin >> A;
            sum += A * B[j];
        }
        sum += C;
        if (sum > 0) ans++;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
lab=[]
for i in range(N):
    lab.append(list(map(int,input().split())))
lcd=[]
#for i in range(N):
for i in range(M):#間違えた(は？)
    lcd.append(list(map(int,input().split())))
for i in range(N):
    dmin=10**9
    ans=1
    for j in range(M):

        if abs(lab[i][0]-lcd[j][0])+abs(lab[i][1]-lcd[j][1])<dmin:
            #print(abs(lab[i][0]-lcd[j][0])+abs(lab[i][1]-lcd[j][1]))
            dmin=abs(lab[i][0]-lcd[j][0])+abs(lab[i][1]-lcd[j][1])
            ans=j+1
    #print(dmin)
    #答えるものを間違えていた(は？)
    print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = 0;
		if(n >= 1 && m >= 2) {
			if(n <= m / 2) {
				ans += Math.min(n, m) + (m - 2 * n) / 4;
			} else {
				ans += Math.min(n, m / 2);
			}
		} else if(n == 0 && m >= 4) {
			ans += m / 4;
		} else {
			ans = 0;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(){
		long long k,tmp=0,ans[100001]={0};
		int n;scanf("%d%lld",&n,&k);
		int a,b,i;
		for(i=0;i<n;i++){
				scanf("%d%d",&a,&b);
				ans[a]+=b;
		}
		for(i=1;i<100001;i++){
				tmp+=ans[i];
				if(tmp>=k){
						printf("%d\n",i);
						return 0;
				}
		}
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>

int main(int argc, char *argv[])
{
    int a,b,c;
    std::cin >> a >> b >> c;

    if(a < b && b < c){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  for (int i = 0; i < N - 2; ++i) {
    string T = S.substr(i, 3);
    if (T == "ABC") ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


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

n = int(readline())
h = list(map(int, readline().split()))
cnt = 0
ans = 0
for i in range(1, n):
    if h[i] > h[i - 1]:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
print(max(ans, cnt))


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

def main():
    N = int(input())
    def attack(x):
        if x == 1:
            return 1
        else:
            x //= 2
            return 2*attack(x)+1
            
    print(attack(N))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

// test code ==================================
test! {
    // example: 
    // "4 2 9" => "8",
    // "4 2 8" => "8"
    // r##""## => ""
    r#"2 16"# => "9",
    r#"0 3"# => "IMPOSSIBLE",
    r#"998244353 99824435"# => "549034394"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
    }
if (a+b)%2==0 {((a+b)/2).to_string()}else{String::from("IMPOSSIBLE")}
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b, --c;
    uf.unite(a, b);
  }
  int rot = 0;
  for(int i = 0; i < N; i++) {
    rot += uf.find(i) == i;
  }
  cout << rot << endl;
}






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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h, r;
    cin >> h >> r;
    if (r + h > 0) cout << 1 << '\n';
    if (r + h == 0) cout << 0 << '\n';
    if (r + h < 0) cout << -1 << '\n';
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

using ll = long long;
using ld = long double;
using ull = unsigned long long;

int N;
vector<pair<int, bool>> Y[15];

int check(bitset<15> b)  {
  rep(i, N) {
    if (!b[i]) continue;
    for (auto p : Y[i])
      if (b[p.first] != p.second) return 0;
  }
  return b.count();
}

int solve(int n, bitset<15> b) {
  if (n == N) return check(b);

  int maxi = 0;
  maxi = max(maxi, solve(n + 1, b));
  b |= 1 << n;
  maxi = max(maxi, solve(n + 1, b));

  return maxi;
}

int main(void) {
  cin >> N;
  rep(i, N) {
    int A; cin >> A;
    rep(a, A) {
      int x, y; cin >> x >> y;
      Y[i].push_back(pair<int, bool>(x - 1, bool(y)));
    }
  }
  cout << solve(0, bitset<15>(0)) << endl;
  return 0;
}


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

int main() {
	int D, N; cin >> D >> N;

	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int N,Q,l[100000],r[100000],i,A[100001];
  A[0]=0;A[1]=0;
  char S[100000];
  cin >> N >> Q >> S;
  for(i=0;i<Q;i++)cin >> l[i] >> r[i];
  for(i=1;i<N;i++) {
    if(S[i-1] == 'A' && S[i] == 'C')A[i+1]=A[i]+1;
    else A[i+1]=A[i];
  }
  for(i=0;i<Q;i++) {
    if(S[l[i]-1] == 'C')l[i]++;
    cout << A[r[i]]-A[l[i]-1] << endl;
  }
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;
#define ALL(x) x.begin(), x.end()

int main(){
  int a, b, c, cnt=1; cin >> a >> b >> c;
  if (a!=b) cnt++;
  if (b!=c) cnt++;
  if (c==a) cnt--;
  if (a==b && b==c) cnt=1;
  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
wlist = []

def is_unique(seq):
    return len(seq) == len(set(seq))

for i in range(N):
    if i == 0:
        wlist.append(input())
    
    else:
        bef = wlist[i-1]
        tmp = input()

        if bef[-1] == tmp[0]:
            wlist.append(tmp)
        
        else:
            print("No")
            exit()

if is_unique(wlist) == False:
    print("No")

else:
    print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    char s[3];
    int i,a = 0,b = 0;
    scanf("%s", &s);

    for (i = 0; i < 3; i++)
    {
        if (s[i] == 'A') a++;
        else b++;
    }

    if (a == 3 || b == 3) printf("No");
    else printf("Yes");
    
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MOD 1000000009

ll n, m, k;

int main(){
    cin.sync_with_stdio(false);
    cin >> n >> m >> k;

    bool ok = false;
    rep(i, n + 1) {
        rep(j, m + 1) {
            ll black = i * (m - j) + j * (n - i);
            if (black == k) ok = true;
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define over(msg)          cout << msg << endl, exit(0);
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n, m, cnt[35], ans;

int main() {
    cin >> n >> m;
    cont (i, n) {
        int s;
        cin >> s;
        cont (j, s) {
            int id;
            cin >> id;
            ++cnt[id];
        }
    }
    cont (i, m) {
        if (cnt[i] == n) {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

deque<int> lst;
int main() {
	int n, v;
	string s;
	cin >> n;
	rep(i,n) {
		cin >> s;
		if(s == "insert") {
			cin >> v;
			lst.push_front(v);
		} else if(s == "delete") {
			cin >> v;
			auto it = find(lst.begin(), lst.end(), v);
			if(it != lst.end()) lst.erase(it);
		} else if(s == "deleteFirst") {
			lst.pop_front();
		} else if(s == "deleteLast") {
			lst.pop_back();
		}
	}
	for(auto it = lst.begin(); it != --lst.end(); ++it) {
		cout << *it << " ";
	}
	cout << *--lst.end() << endl;
	return 0;
}

Measured memory_bytes: 5300
#include <stdio.h>

int main() {
    int a, b, result, sum;
    while (scanf("%d %d", &a, &b) != EOF) {
        result = 0;
        sum = a+b;
        while (sum != 0) {
            sum /= 10;
            result++;
        }
        printf("%d\n", result);
    }
}


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

int main(){
    string a,al = "abcdefghijklmnopqrstuvwxyz";
    cin >> a;
    for (int i=0;i<al.size();i++){
        if (al[i]==a[0]){
            cout <<al[(i+1)%al.size()]<<endl;
        }
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define N 200001

typedef struct node *link;
struct node{
  int key;
  link le,ri,pa;
};
link head;
void insert(int a);
void inorder(link h);
void preorder(link h);

int main(){
  char z[10];
  int m,k,i;

  head=NULL;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",z);
    if(strcmp(z,"insert")==0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(z,"print")==0){
      inorder(head);
      printf("\n");
      preorder(head);
      printf("\n");
    }
  }

  return 0;
}

void insert(int a){
  link x,y,z;
  z=malloc(sizeof(struct node));
  z->key=a; z->le=NULL; z->ri=NULL;
  y=NULL;  x=head;
  while(x!=NULL){
    y=x;
    if(z->key<x->key){ x=x->le;}
    else{ x=x->ri;}
  }
  z->pa=y;

  if(y==NULL){head=z;}
  else if(z->key<y->key){y->le=z;}
  else{y->ri=z;}
}


void inorder(link h){
  if(h==NULL) return;
  inorder(h->le);
  printf(" %d",h->key);
  inorder(h->ri);
}

void preorder(link h){
  if(h==NULL) return;
  printf(" %d",h->key);
  preorder(h->le);
  preorder(h->ri);
}



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

int main()
{
    int N;
    cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;++i)
        cin>>h[i];

    int i,j,k,ans=0;
    while(1)
    {
        if(*max_element(h.begin(),h.end())==0)
            break;

        for(i=0;i<N;++i)
        {
            if(h[i]==0)
                continue;
            for(j=i+1;j<N;++j)
                if(h[j]==0)
                    break;
            for(k=i;k<j;++k)
                --h[k];
            ++ans;
            i=j;
        }
    }
    cout<<ans<<endl;
}

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


//#define int long long 

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int d, t, s; cin >> d >> t >> s;
	cout << (d <= t * s ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3608
package main

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

func solve() {
	a, b := getInt()-1, getInt()
	c, d := getInt(), getInt()
	m := lcm(c, d)

	toA := a - a/c - a/d + a/(m)
	toB := b - b/c - b/d + b/(m)
	ans := toB - toA
	fmt.Fprintln(wr, ans)
}

func lcm(a, b int) int {
	d := gcd(a, b)
	return a / d * b
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,pii> pll;
priority_queue<pll,vector<pll>,greater<pll>> que;
vector<pll> G[55][2610];
ll d[60][2610],INF = 10000000000000000;
void dijkstra(int s,int m){
    que.push({0,{s,min(m,2500)}});
    for(int i=0;i<50;i++){
        for(int j=0;j<2600;j++){
            d[i][j] = INF;
        }
    }
    while(que.size()){
        pll p = que.top(); que.pop();
        int pos = p.second.first,sil = p.second.second;
        ll dis = p.first;
        if(d[pos][sil]<=dis) continue;
        d[pos][sil] = dis;
        for(pll e:G[pos][sil]){
            que.push({{dis + e.first},{e.second.first,e.second.second}});
        }
    }
}

int main(){
    int i,j,n,m,s;
    cin >> n >> m >> s;
    for(i=0;i<m;i++){
        int u,v; ll a,b;
        cin >> u >> v >> a >> b;
        u--; v--;
        for(j=a;j<=2500;j++){
            G[u][j].push_back({b,{v,j - a}});
            G[v][j].push_back({b,{u,j - a}});
        }
    }
    for(i=0;i<n;i++){
        ll c,d;
        cin >> c >> d;
        for(j=0;j<=2500;j++){
            G[i][j].push_back({d,{i,min(2500LL,j + c)}});
        }
    }
    dijkstra(0,s);
    for(i=1;i<n;i++){
        ll mn = INF;
        for(j=0;j<=2500;j++){
            mn = min(mn,d[i][j]);
        }
        cout << mn << endl;
    }
}

Measured memory_bytes: 26828
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

int main(){
    string s,t;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == '0'){
            t.push_back('0'); 
        }else if(s[i] == '1'){
            t.push_back('1');
        }else if(s[i] == 'B'){
          if(!t.empty()){
            t.pop_back();
          }
        }
    }
    cout << t << endl;
    return 0 ;
}

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

int main()
{
    int a,b,x=0,y=0;;
    while(~scanf("%d%d",&a,&b))
    {
        x=a*b;
        y=(1*a+1*b)-1;
        printf("%d\n",x-y);
    }
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a=0;
  vector<int> d(n);
  for(int i=0; i<n; i++)
    cin>>d[i];
  for(int i=0;i<n; i++){
    for(int j=i+1; j<n; j++){
      a+=d[i]*d[j];
    }
  }
  cout<<a<<endl;
}
    


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long int>a(n);
	long int s = pow(10, 9);
	long int tmp = -s;
	int count = 0;
	for (int i = 0; i < n; i++) {
            cin >> a[i];
	}
	long int minv = a[0];
	for(int i=1; i<n; i++){
		tmp = max(tmp, a[i] - minv);
		minv = min(minv, a[i]);
		//cout << tmp << endl;
	}

	cout << tmp << endl;
}



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

int main() {
  int n;
  cin >> n;
  int i = 0;
  int nth = 0;
  while (i<n){
    int a = i+1;
    int counter = 0;
    while (true){
      bool odd = false;
      if (a % 2 == 1){
        odd = true;
      }
      if (odd){
        break;
      }
      a = a/2;
      counter++;
    }
    if(nth < counter){
      nth = counter;
    }
    i++;
  }
  int ans=1;
  for (int j=0; j<nth; j++){
    ans *=2;
  }
  cout << ans << endl;
  return 0;
}

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

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

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		String[] elements = br.readLine().split(" ");
		
		for (int i = 0; i < n; i++){
			a[i] = Integer.parseInt(elements[i]);
		}
		
		int swapCount = 0; 
		
		for(int i = 0; i < a.length; i++){
			int mini = i;
			
			for(int j = i; j < a.length; j++){
				if(a[j] < a[mini]){
					mini = j;
				}
			}
			
			if (mini != i){
				int v = a[mini];
				a[mini] = a[i];
				a[i] = v;
				
				swapCount++;
			}
		}
		
		String ans = String.valueOf(a[0]);
		for (int i = 1; i < a.length; i++){
			ans += " " + a[i];
		}
		
		System.out.println(ans);
		System.out.println(swapCount);
	}
}

Measured memory_bytes: 17108
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
long long a,b,c,a1,b1,c1;
int main(){
		cin>>a>>b>>c;
		int f=0;
		for(int i=0;i<100;i++){
			if(a%2!=0||b%2!=0||c%2!=0){
				if(i==0){
				printf("0");
				return 0;
				
				}
				f=i;
				break;
			}
			a1=b/2+c/2;
			b1=a/2+c/2;
			c1=b/2+a/2;
			a=a1;
			b=b1;
			c=c1;
		}
	if(f)
		printf("%d",f);
	else 
		printf("-1");
}

Measured memory_bytes: 888
X, Y = map(int, input().split())

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range(2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

if (2*X-Y) % 3 == 0 and (2*Y-X) % 3 == 0:
    s = (2*X-Y)//3
    t = (2*Y-X)//3
    print(cmb(s+t,s, mod))
else:
    print(0)

Measured memory_bytes: 128584
/*氏名：保坂優介, 学籍番号：200441141
  概要：計算をするプログラム*/

#include<stdio.h>

int main(void)
{
    int a, b,ans;
    char op;

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

    while (op != '?')
    {
        if (op == '+')
        {
            ans = a + b;
        }

        if (op == '-')
        {
            ans = a - b;
        }

        if (op == '*')
        {
            ans = a * b;
        }

        if (op == '/')
        {
            ans = a / b;
        }

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

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

    }
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  string s;
  cin>>s;
  vector<int> cnt(3, 0);
  for (char c : s) {
    ++cnt[c-'a'];
  }
  int mx = *max_element(ALL(cnt));
  int mn = *min_element(ALL(cnt));
  if (mx <= mn + 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<map>
#include<queue>
#include <algorithm>
#include<string>
#include <unordered_map>
using namespace std;

const int N=2e6+5;

int t,n,m;
int a,b,c,d;

int main(){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1){
        c-=b;
        if(c<=0) break;
        a-=d;
        if(a<=0) break;
    }
    if(a>0) puts("Yes");
    else puts("No");


}


Measured memory_bytes: 3148
#include<stdio.h>

void trace(int A[], int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void InsertionSort(int A[], int N){
	int j, i, v;
	for(i = 1; i < N; i++){
		v = A[i];
		j = i-1;
		while( j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main(){
	int N,i,j;
	int A[100];
	scanf("%d", &N);
	for(i = 0; i < N; i++) scanf("%d", &A[i]);
	trace(A,N);
	InsertionSort(A, N);
	return 0;	
}

Measured memory_bytes: 604
#include <stdio.h>
int n;
int C[10000];
void swap(int* x,int* y){
    int temp;
    temp=*x;
    *x=*y;
    *y=temp;
}
int partition(int A[],int p,int r){
    int x,i,j;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i=i+1;
            swap(&A[i],&A[j]);
        }
    }
    swap(&A[i+1],&A[r]);
    return i+1;
}
int main(){
    int i,r;
    int A[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    r=partition(A,0,i-1);
    for(i=0;i<n-1;i++){
        if(i==r){
            printf("[");
        }
        printf("%d",A[i]);
        if(i==r){
            printf("] ");
        }
        else{
            printf(" ");
        }
    }
    printf("%d\n",A[i]);
    return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 100
using namespace std;



int main(){

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

	for(i=0;i<n;i++)
		scanf("%d",&b[i]);
	for(i=0;i<n-1;i++)
		scanf("%d",&c[i]);


	int total = 0;
	for(i=0;i<n;i++){
		if(i<n-1 && a[i]+1 == a[i+1]){
			total += c[a[i]-1];
		}
		total+=b[a[i]-1];
	}
	
	printf("%d\n",total);

	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    valarray<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    sum -= a.max() / 2;
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=998244353;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=2e5+10;
ll n,m,k;
ll power[mxn];
ll fact[mxn];


ll fastExpo(ll a,ll b){
    ll res=1ll;
    while(b > 0){
        if(b%2 == 1){
            res=mul(res,a);
        }
        a=mul(a,a);
        b/=2;
    }
    return res;
}

ll ncr(ll n,ll r){
    ll res=1ll;
    res=fact[n];
    ll res1=mul(fact[n-r],fact[r]);
    res=mul(res,fastExpo(res1,mod-2));
    return res;
}


void init(){

    ll temp=1;
    ll i,j;
    for(i=0;i<mxn;i++){
        power[i]=temp;
        temp=mul(temp,m-1);
    }
    fact[0]=1;
    for(i=1;i<mxn;i++){
        fact[i]=mul(fact[i-1],i);
    }

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    cin >> n >> m >> k;
    init();
    ll i,j;
    ll ans=0;
    ll temp=1;
    for(i=0;i<=k;i++){
        ans=add(ans,mul(power[n-1-i],ncr(n-1,i)));
        //deb(ans);
    }
    ans=mul(ans,m);
    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 6756
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>dp,vis;
int fun(vector<vector<char>>&v,int i,int j,int n,int m)
{
 if(i<0||j<0||i>=n||j>=m)
   return 0;
   if(i==n-1 && j==m-1)return 1;
  int &c=dp[i][j];
  if(vis[i][j])return c;
  if(v[i][j+1]=='.')
   c=c%1000000007+fun(v,i,j+1,n,m)%1000000007;
  if(v[i+1][j]=='.')
    c=c%1000000007+fun(v,i+1,j,n,m)%1000000007;
 vis[i][j]=1;
  return c%1000000007;
  
}


int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<char>>v(n+1,vector<char>(m+1));
  dp.resize(n,vector<int>(m,0));
  vis.resize(n,vector<int>(m,0));
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cin>>v[i][j];
  cout<<fun(v,0,0,n,m);
  return 0;
}


Measured memory_bytes: 9344
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s=s0()

n=len(s)
print("Yes" if s==s[::-1] and s[:n//2]==s[n//2-1::-1] and s[n//2+1:]==s[:n//2:-1] else "No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#include<string.h>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
const int maxn=200000+6;
#define mod 1000000007
#define INF 0x3f3f3f3f
double a[maxn];
double s[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    rep(i,1,n)
    {
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }
    double maxx=-1;
    rep(i,1,n-k+1)
    {
        //枚举起点
        maxx=max(maxx,s[i+k-1]-s[i-1]);
    }
    printf("%.10f\n",(maxx+k)*1.0/2);
}


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

int main() {
	int k; cin >> k;
	string s; cin >> s;
	if ((int)s.size() <= k){
		cout << s << "\n";
	} else {
		cout << s.substr(0, k) << "...\n";
	}
	
	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
     
     
    public class Main {
        

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int h =sc.nextInt();
            int n =sc.nextInt();
            int sum=0;
            for (int i=0;i<n;i++){
                 int a =sc.nextInt();
                 sum+=a;
            }

           if (h<=sum){
            System.out.println("Yes");
           }else{
            System.out.println("No");
           }
            
           } 
        }
    


Measured memory_bytes: 58628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int L = Integer.parseInt(sc.next());
		int[] Eval = new int[N];
		int sum = 0;
		for(int i = 0;i < N;i++) {
			Eval[i] = L+ i;
			sum += Eval[i];
		}
		sc.close();
		int num = 0;
		if(Eval[0] > 0) {
			num = Eval[0];
		}else if(Eval[N-1] < 0) {
			num = Eval[N-1];
		}else {
			num = 0;
		}
		System.out.println(sum - num);
	}
}

Measured memory_bytes: 24788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    int a,b,k,i,j;

    cin>>a>>b>>k;


    if ((b-a+1)%2==1)
    {
        if (k>(b-a+1)/2)
        {
            for (i=a;i<=b;i++)
            {
                cout<<i<<endl;
            }
        }

        else
        {
            for (i=a,j=0;j<k;i++,j++)
            {
                cout<<i<<endl;
            }

            for (i=b-k+1;i<=b;i++)
            {
                cout<<i<<endl;
            }
        }
    }


    if ((b-a+1)%2==0)
    {

        if (k>(b-a+1)/2)
        {
            for (i=a;i<=b;i++)
            {
                cout<<i<<endl;
            }
        }

        else
        {
            for (i=a,j=0;j<k;i++,j++)
            {
                cout<<i<<endl;
            }


            for (i=b-k+1;i<=b;i++)
            {
                cout<<i<<endl;
            }
        }
    }




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)

inline vll move(vll p, char d) {
	if (d == 'U') {
		p[0]--;
	}
	else if (d == 'D') {
		p[0]++;
	}
	else if (d == 'R') {
		p[1]++;
	}
	else if (d == 'L') {
		p[1]--;
	}
	return p;
}

int main() {
	string s;
	in(s);
	ll n = s.size() + 1, cntL, cntR, p,ans=0;
	vll a(n, -1);
	bool isR = false;


	cntL = 0;
	cntR = 0;

	if (s[0] != '<') {
		isR = true;
		cntR++;
	}
	else {
		a[0] = 0;
	}

	rep(i, 1, s.size()) {
		if (s[i] == '<') {
			if (isR) {
				isR = false;
				a[i] = 0;
				rep(j, 0, cntR) {
					if (i - j - 2 >= 0) {
						a[i - j - 1] = a[i - j - 2] + 1 > a[i - j] + 1 ? a[i - j - 2] + 1 : a[i - j] + 1;
					}
					else {
						a[i - j - 1] =  a[i - j] + 1;
					}
				}
				cntL = 0;
				cntR = 0;
			}
			else {
				a[i] = a[i - 1] + 1;
			}
			cntL++;
		}
		else {
			isR = true;
			cntR++;
		}
	}

	if (s[n - 2] == '>') {
		a[n - 1] = 0;
		rep(j, 0, cntR) {
			if (n - j - 3 >= 0) {
				a[n - j - 2] = a[n - j - 3] + 1 > a[n - j - 1] + 1 ? a[n - j - 3] + 1 : a[n - j - 1] + 1;
			}
			else {
				a[n - j - 2] = a[n - j - 1] + 1;
			}
		}
	}
	else {
		a[n - 1] = a[n - 2] + 1;
	}


	rep(i, 0, n) {
		ans += a[i];
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 4740
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<bitset>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=2005;
int n,ans;
bool a[N][N];
char s[N];
bitset <N> f[N],g[N];

int main()
{
	scanf("%d",&n);
	rep(i,2,n)
	{
		scanf("%s",s+1);
		rep(j,1,i-1)
		{
			int x=s[j]-'0';	
			a[i][j]=x,a[j][i]=x^1;
		}
	}
	rep(i,1,n)
	{
		f[i][i]=g[i][i]=1;
		rep(j,1,i-1)
			if(g[i-1][j] && a[i][j]) f[i]|=f[j];
		rep(j,1,i-1)
			if(f[i][j+1] && a[j][i]) g[i]|=g[j];
	}
	rep(i,1,n) if(f[i][1] && g[n][i]) ++ans;
	printf("%d\n",ans);
	return 0;
}

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

bool sieve[1000000];

int a, d, n;

void solve() {
  int count = 0, res;
  while (true) {
    if (sieve[a]) {
      count++;
      if (count == n) {
        res = a;
        break;
      }
    }
    a += d;
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  // set sieve
  memset(sieve, true, sizeof sieve);
  sieve[0] = sieve[1] = false;
  for(int i=4;i<1000000;i+=2) sieve[i] = false;

  for(int i=3;i<1000000;i+=2)
  if (sieve[i])
  for(int j=i+i;j<1000000;j+=i)
  if (sieve[j]) sieve[j] = false;
    
  while (cin>>a>>d>>n, a||d||n) {
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool cmp(char a,char b)
{
	return a>b;
}
int main()
{
	string x,y;
	cin>>x>>y;
	sort(x.begin(),x.end());
	sort(y.begin(),y.end(),cmp);
	if(x<y) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    long sum=0;
    int i;
    for(i=0;i<n;i++){
      sum+=a[i];
      if(sum>x){
        break;
      }
    }
    if(i==n&&sum!=x){
      System.out.println(i-1);
    }else{
      System.out.println(i);
    }
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
 
int main(){
    ll N;
    cin >> N;
    ll res = 0;
    for(ll n=1; n<=N; n+=2) {
        ll c = 0;
        FOR(i, 1, n+1) if (n%i==0) c++;
        if (c==8) res++;
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
w, h, x, y = list(map(int, input().split()))
diffx = x-w/2
diffy = y-h/2
if diffx >= 0:
  signx = 1
else:
  signx =-1
x2 = signx*diffx + w/2

if diffy >= 0:
  signy = 1
else:
  signy =-1
y2 = signy*diffy+ h/2

if diffx==0 and diffy==0:
  print("{} {}".format(w*h/2, 1))
else:
  print("{} {}".format(w*h/2, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    ios;
    ll n,a,b;
    cin>>a>>b>>n;
    if(n>=b)
        n=b-1;
    else
        n=n;
    cout<<((a*n)/b)-(a*(n/b));
}


Measured memory_bytes: 3664
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int ans = 0;
        if(inpt[0]%inpt[1]!=0) {
            ans++;
        }
        Console.WriteLine(ans);
    
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



7 3


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

int main(){
  int n;
  double a,  b = 0.0, j = 0;
  string s;
  cin >> n;
  
  for(int i = 0; i < n; i++){
    cin >> a >> s;
    
    if(s == "JPY"){
      j += a;
    }else{
      b += a * 380000;
    }
  }
  
  cout << j + b << endl;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a,b;
	char op;
	cin >> a >> op >> b;
	if(op == '+')cout << a + b << endl;
	else cout << a - b << endl;
	return 0; 
}

Measured memory_bytes: 256
s = list(input())

g = []

g.append(0)
g.append(1)
if len(s) > 1:
    if s[0] == s[1]:
        g.append(1)
    else:
        g.append(2)

    for i in range(3,len(s)+1):
        if s[i-1] != s[i-2]:
            g.append(g[i-1]+1)
        else:
            g.append(g[i-3]+2)

print(g[len(s)])

Measured memory_bytes: 12836
#include<iostream>
int main(){
	while (true){
		int H, W, i, j;
		std::cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		else{
			for (i = 1; i <= H; i++){
				for (j = 1; j <= W; j++){
					std::cout << "#";
				}
				std::cout << "\n";
			}
		}
		std::cout << "\n";
	}
return 0;
}

Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());
            String[] array = reader.readLine().split(" ");
            int[] H = new int[N];
            for (int i = 0; i < N; i++) {
                H[i] = Integer.parseInt(array[i]);
            }

            boolean ret = true;

            for (int i = N - 1; i > 0; i--) {
                if (H[i] <= H[i - 1] - 2) {
                    ret = false;
                    break;
                }

                if (H[i] == H[i - 1] - 1) {
                    H[i - 1]--;
                }
            }

            System.out.println(ret ? "Yes" : "No");
        }
    }

}


Measured memory_bytes: 43732
n = int(input())
a = input()
s = {a}
a = a[-1]
c = 1
for _ in range(n-1):
    b = input()
    if a == b[0]:
        a = b[-1]
        c += 1
        s.add(b)
    else:
        print('No')
        break
else:
    print('Yes' if len(s) == c else 'No')

Measured memory_bytes: 9088