akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n;
    cin >> n;
    map<string, int> a;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        a[s]++;
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
        string s;
        cin >> s;
        a[s]--;
    }
    int ans = 0;;
    for(auto &i : a){
        ans = max(i.second, ans);
    }
    cout << ans;
    
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e12 + 17;
const int maxn = 3e3 + 10;
const int maxq = 1e2 + 10;
const int alf = 26;
const ll dlm = 1e9 + 7;
const int del = 998244353 ;
const int eps = 1e-7 ;

ll dp1[maxn][maxn];
ll dp2[maxn][maxn];
//      i      j
ll a[maxn];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int dif=0;dif<n;dif++){
        for(int i=1;i<=n;i++){
            int j = i + dif;
            if(j>n)break;
            if(i==j){
                dp1[i][j] = a[i];
                dp2[i][j] = -a[i];
            }
            dp2[i][j] = min(dp1[i+1][j]-a[i] , dp1[i][j-1]-a[j]);
            dp1[i][j] = max(dp2[i+1][j]+a[i] , dp2[i][j-1]+a[j]);
        }
    }
    cout<<dp1[1][n];
    return 0;
}


Measured memory_bytes: 141568
import sys
input = sys.stdin.readline

mm = 10**10
k = mm.bit_length()
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(200001)]]

n,m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0]*100001

for i in a:
    b[i] += 1
    
c = li(st(nu(b)*nu(b)))
ans = 0
for i in range(200001)[::-1]:
    if c[i] > 0:
      p = min(m,c[i])
      m -= p
      ans += i*p
      if m == 0:
        break
print(ans)

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

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



int main() {
	long long N;
  cin>>N;
  long long A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  long long now=1000;
  long long maisu=0;
  for(int i=0;i<N-1;i++){
    if(A[i]<A[i+1]){
      maisu+=now/A[i];
      now-=(now/A[i])*A[i];
    }else{
      now+=maisu*A[i];
      maisu=0;
    }
  }
  now+=maisu*A[N-1];
  cout<<now<<endl;

  
}


Measured memory_bytes: 3632
sx,sy,tx,ty = map(int, input().split())
dx = abs(tx-sx)
dy = abs(ty-sy)
ans = "U"*dy + "R"*dx +"D"*dy + "L"*dx
ans += "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans += "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using P = std::pair<int, int>;

int H, W, D;
std::map<int, P> m;
int d[90001], a[90001];
int Q;

int main()
{
  scanf( "%d%d%d", &H, &W, &D );
  rep( i, H ) rep( j, W )
  {
    int A;
    scanf( "%d", &A );

    m[A] = P( i, j );
  }

  repi( i, 1, H*W+1-D )
  {
    P p = m[i], q = m[i+D];

    d[i] = abs(p.first-q.first)+abs(p.second-q.second);
  }

  for( int i = H*W-D; i >= 0; --i )
    a[i] = a[i+D]+d[i];

  scanf( "%d", &Q );

  rep( i, Q )
  {
    int L, R;
    scanf( "%d%d", &L, &R );
    printf( "%d\n", a[L]-a[R] );
  }

  return 0;
}

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

bool binarySearch(int key, int S[], int n) {
	int head, tail;
	head = 0;
	tail = n;
	while (head < tail) {
		int tempKey = (tail + head)/2;
		if (S[tempKey] != key) {
			if (S[tempKey] > key) {
				tail = tempKey;
			}
			else {
				head = tempKey + 1;
			}
		}
		else {
			return true;
		}
	}
	return false;
}

int main() {
	int sum = 0;
	int n, q;
	int S[100000];
	int key;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (binarySearch(key, S, n)) sum++;
	}

	cout << sum << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


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

  vector<ll> minus;
  vector<ll> plus;
  plus.PB(0);
  REP(i, N) {
    int x;
    cin >> x;
    if (x < 0) minus.PB(-x);
    else plus.PB(x);
  }
  minus.PB(0);
  reverse(ALL(minus));
/*
  REP(i, minus.size()) cout << minus[i] << ' ';
  cout << endl;
  REP(i, plus.size()) cout << plus[i] << ' ';
  cout << endl;
*/
  ll ans = LLINF;
  int ps = plus.size();
  int ms = minus.size();
  for (int i = 1; i <= K; i++) {
 //   cout << "(" << i << ", " << ps << ") "
 //       << "(" << (K - i) << ", " << ms << ")" << endl;
    if (i >= ps || K - i >= ms) continue;
    ans = min(ans, 2 * plus[i] + minus[K - i]);
  }
  for (int i = 1; i <= K; i++) {
 //   cout << "(" << i << ", " << ps << ") "
 //       << "(" << (K - i) << ", " << ms << ")" << endl;
    if (i >= ms || K - i >= ps) continue;
    ans = min(ans, 2 * minus[i] + plus[K - i]);
  }
  if (ps > K) ans = min(ans, plus[K]);
  if (ms > K) ans = min(ans, minus[K]);
  cout << ans << endl;

	return 0;
}



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

using Graph=vector<vector<int>>;
int main(){
    int n;
    cin>>n;
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>c[i];
    int m;
    cin>>m;

    Graph inputG(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        inputG[a].push_back(b);
        inputG[b].push_back(a);
    }
    
    Graph g(n);
    {
        vector<set<int>> tmpG(n);
        for(int i=0;i<n;i++){
            sort(inputG[i].begin(),inputG[i].end(),[&](int lhs,int rhs){return c[lhs]>c[rhs];});
            for(int j=0;j<inputG[i].size();j++){
                if(c[i]>=c[inputG[i][j]]) tmpG[i].insert(inputG[i][j]);
                if(j+1<inputG[i].size()){
                    tmpG[inputG[i][j]].insert(inputG[i][j+1]);
                    if(c[inputG[i][j]]==c[inputG[i][j+1]]) tmpG[inputG[i][j+1]].insert(inputG[i][j]);
                }
            }
        }
        for(int i=0;i<n;i++) g[i]=vector<int>(tmpG[i].begin(),tmpG[i].end());
    }
    
    vector<int> idx(n);
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),[&](int lhs,int rhs){return c[lhs]<c[rhs];});
    vector<int> p(n);
    for(auto id:idx){
        vector<int> vs;
        function<void(int)> dfs=[&](int v){
            if(p[v]!=0) return;
            p[v]=-1;
            vs.push_back(v);
            for(auto to:g[v]){
                if(c[to]==c[v]) dfs(to);
            }
        };
        dfs(id);
        int x=1;
        for(auto v:vs){
            for(auto to:g[v]){
                x=max(x,p[to]+1);
            }
        }
        for(auto v:vs) p[v]=x;
    }
    cout<<accumulate(p.begin(),p.end(),0LL)<<endl;
    return 0;
}


Measured memory_bytes: 41492
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Dec  1 21:00:11 JST 2019
 **/

signed main() {
    Int n = in();
    Int rem = n % 100;
    Int num = n / 100;
    cout << (rem <= num * 5) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i ++)
#define for1(i, n) for (int i = 1; i <= n; i ++)
#define repn(i, n) for (int i = n-1; i >= 0; i --)
#define rep1(i, n) for (int i = n; i >= 1; i --)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<pii> qpii;

void test_case() {
	string a, b; cin >> a >> b;
	int ans = 0;
	for (int i = 0; i < (int)a.size(); i ++) {
		if (a[i] != b[i]) ans ++;
	}
		cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin >> q; 
	while (q--) {
		test_case();
	}
	return 0;
}


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

using namespace std;

int main() {
  int N, K;
  int R, S, P;
  string T;

  cin >> N >> K >> R >> S >> P >> T;

  int result = 0;

  vector<bool> win(N);
  for (int i = 0; i < N; i++) {
    char t = T[i];
    if (t == 'r' && !((i - K >= 0) && ((T[i - K]) == 'r') && win[i - K])) {
      result += P;
      win[i] = true;
    } else if (t == 's' && !((i - K >= 0) && ((T[i - K]) == 's') && win[i - K])) {
      result += R;
      win[i] = true;
    } else if (t == 'p' && !((i - K >= 0) && ((T[i - K]) == 'p') && win[i - K])) {
      result += S;
      win[i] = true;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long arr[10000007] ;
int main()
{
    long long n , sum = 0 , i , j  ;
    scanf("%lld",&n);
    for ( i=1 ; i<=n ; i++)
    {
         for ( j = i ; j<=n ; j+= i )
             {
                  arr[j]++;
        }
    }
    for (i=1 ; i<=n ; i++)
    {
         sum += (arr[i])*i ;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 81784
N = int(input())
ans = [0] * (N+1)
 
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n] += 1
print(*ans[1:], sep='\n')

Measured memory_bytes: 9368
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ALphabet {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        char c;
        cin >> c;
        if ('a' <= c && c <= 'z') {
            cout << 'a' << endl;
        } else {
            cout << 'A' << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ALphabet solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  int A=0;
for (int i = 0; i < N-1; i++) {
  if(vec.at(i+1)-vec.at(i)>A){
    A=vec.at(i+1)-vec.at(i);
 
}
}
if(A>K-vec.at(N-1)+vec.at(0)){
  cout<<K-A<<endl;
}
  else{
    cout<<vec.at(N-1)-vec.at(0)<<endl;
  }
  

  
}

Measured memory_bytes: 1024
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
P = list(map(int, sys.stdin.buffer.readline().split()))

P = np.array(P, dtype=int)
ans = (P == np.minimum.accumulate(P)).sum()
print(ans)


Measured memory_bytes: 32000
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};


int main() {
    int n;cin>>n;
    vector<int>a(n);cin>>a;
    sort(all(a),greater<int>());
    
    int diff=0;

    rep(i,n){
        if(i%2==0)diff+=a[i];
        else diff-=a[i];
    }
    cout<<diff<<endl;
    
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int x,y;
cin >> x >> y;

int ans;
if(x == 0) {
    if(y >= 0) ans = y;
    else ans = abs(y)+1;
}
else if(y == 0) {
    if(x < 0) ans = abs(x);
    else ans = x+1;
}
// |x|>=1 and |y|>=1
else {
    if(abs(x) < abs(y)) {
        int cnt = 0;
        if(x < 0) cnt++;
        if(y < 0) cnt++;
        ans = abs(y) - abs(x) + cnt;
    }
    else if(abs(x) > abs(y)) {
        int cnt = 0;
        if(x > 0) cnt++;
        if(y > 0) cnt++;
        ans = abs(x) - abs(y) + cnt;
    }
    else {
        if(x == y) ans = 0;
        else ans = 1;
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] a = Console.ReadLine().ToCharArray();
        int m = 0;
        for(int z = 0; z < n; z++)
        {
            string b = Console.ReadLine();
            int[,] c = new int[a.Length,b.Length];
            int[] d = new int[a.Length];
            for(int i = 0; i < b.Length; i++)
            {
                for(int j = 0; j < a.Length; j++)
                {
                    if (b[i] == a[j])
                    {
                        c[j,d[j]] = i;
                        d[j]++;
                    }
                }
            }
            bool t = false;
            for(int i = 0; i < d[0]; i++)
            {
                for(int j = 0; j < d[1]; j++)
                {
                    int e = c[1,j] - c[0,i];
                    if (e >= 0)
                    {
                        for (int x = 2; x < a.Length; x++)
                        {
                            bool r = true;
                            for (int y = 0; y < d[x]; y++)
                            {
                                if (c[x, y] == c[0, i] + e * x)
                                    r = false;
                            }
                            if (r) goto stop;
                        }
                    }
                    else
                        goto stop;
                    t = true;
                    goto go;
                    stop:;
                }
            }
            go:;
            if (t) m++;
        }
        Console.WriteLine(m);
    }
}

Measured memory_bytes: 9108
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}

/*
dp[i][0] := 上の桁からi桁目を決めてあり，Lと一致しているa+bの場合の数
dp[i][1] := 上の桁からi桁目を決めており，L未満が確定しているa＋bの場合の数．

*/

const MOD: usize = 1_000_000_000 + 7;
fn main() {
    input!(L: Chars);
    let L = L
        .iter()
        .map(|&c| c.to_digit(10).unwrap() as usize)
        .collect::<Vec<_>>();
    let n = L.len();
    let mut dp = vec![vec![0; 2]; n + 1];
    // init
    dp[0][0] = 1;
    for (i, &d) in L.iter().enumerate() {
        // a + b == 0
        if d == 0 {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][1];
        } else {
            dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD;
        }

        // a + b = 1
        if d == 0 {
            dp[i + 1][1] += 2 * dp[i][1] % MOD;
        } else {
            dp[i + 1][0] += dp[i][0] * 2 % MOD;
            dp[i + 1][1] += dp[i][1] * 2 % MOD;
        }
        dp[i + 1][0] %= MOD;
        dp[i + 1][1] %= MOD;
    }

    let ans = (dp[n][0] + dp[n][1]) % MOD;
    println!("{}", ans);
}


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

if (V-W)<=0:
    print ("NO")
    exit(0)
if A > B:
    if (A-B) / (V-W) <= T:
        print("YES")
    else:
        print("NO")
else: 
    if (B-A) / (V-W) <= T:
        print("YES")
    else:
        print("NO")

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

int main()
{
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }
    bool flag = true;
    for (auto itr : mp)if (itr.second > 1)flag = false;
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 9600
H,W,i,j,t,u;
main(){
    for(;scanf("%d %d",&H,&W),H;puts("")){
        for(i=0,t=H;t--;i++){
            for(j=0,u=W;u--;j++){
                printf("%s%s",i>0 && i<H-1 && j>0 && j<W-1?".":"#",u==0?"\n":"");
            }
        }
    }
}

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

using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
    ll s=0;

    for(ll i=1;i*i<=n;i++){
	if(n%i==0){
	    ll m = (n/i) - 1;
	    if(m!=0 && (n/m)==(n%m))
		s+=m;
	    if(i!=1 && ((n/i)!=i)){
		m = i-1;
		if((n/m)==(n%m))
		    s+=m;
	    }
	}
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll n,k,a[110],dp[110][100010]={};
bool f[110][100010]={};

const ll MOD=1e9+7;
ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll c(ll i,ll m){
  if(i<0||m<0) return 0;
  if(!f[i][m]){
    f[i][m]=1;
    dp[i][m]=ad(ad(c(i,m-1)+c(i-1,m)),MOD-c(i-1,m-1-a[i]));
  }
  return dp[i][m];
}

int main(){
  cin>>n>>k;
  fr(i,n) cin>>a[i];
  fr(i,a[0]+1) dp[0][i]=1;
  fr(i,k+1) f[0][i]=1;
  cout<<c(n-1,k)<<endl;
}

Measured memory_bytes: 96640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string n;
    cin >> n;
    lli ans = 0;
    rep(i, n.size()) {
        if(n[i]=='2')
        {
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x, s, m, h;
    cin >> x;
    s = x % 60;
    x = x / 60;
    m = x % 60;
    h = x / 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

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

  vector<int> a(n+1, 0);
  vector<int> b(n+1, 0);
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }

  int sum = 0, count = 0;
  for(int i = n; 0 < i; i--){
    sum = 0;
    b[i] = 0;
    for(int j = 2 * i; j <= n; j += i){
      sum += b[j];
    }
    if(sum % 2 != a[i]){
      b[i] = 1;
      count++;
    }
  }

  cout << count << endl;
  for(int i = 1; i <= n; i++){
    if(i != 1) cout << " ";
    if(b[i] == 1) cout << i;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
        char a;
        cin>>a;
        switch(a)
        {
        case 'A':
            cout<<'T'<<endl;
            break;
        case 'T':
            cout<<'A'<<endl;
            break;
        case 'C':
            cout<<'G'<<endl;
            break;
        default:
            cout<<'C'<<endl;
            break;
        }
        return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)2e5 + 9;
const int LG = 20;

int tab[2][N][LG];
int pos[N];
int p[N];

int LOG[N];

int query(int bit, int L, int R){
    int p = LOG[R-L+1];
    return min(tab[bit][L][p], tab[bit][R-(1<<p)+1][p]);
}

pii compute(int L, int R){
    int res1 = query(L%2, L, R);
    int id = pos[res1];
    int res2 = query(!(L%2), id + 1, R);
    return mp(res1, res2);
}

struct Q{
    pii pr;
    int Lef;
    int Rig;
    bool operator< (const Q &f) const {
        return pr > f.pr;
    }
};

int main(){
    fastIO;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++ ){
        cin >> p[i];
        pos[p[i]] = i;
    }
    int pr = 0;
    for(int i = 1; i <= n; i ++ ){
        while((1 << (pr + 1)) <= i)
            pr ++ ;
        LOG[i] = pr;
    }
    for(int bit = 0 ; bit < 2; bit ++ ){
        for(int i = 1; i <= n; i ++ ){
            if(i % 2 == bit){
                tab[bit][i][0] = p[i];
            }
            else{
                tab[bit][i][0] = (int)1e9;
            }
        }
        for(int j = 1; j < LG; j ++ ){
            for(int i = 1; i <= n ; i ++ ){
                if(i + (1 << j) - 1 <= n){
                    tab[bit][i][j] = min(tab[bit][i][j-1], tab[bit][i+(1<<(j-1))][j-1]);
                }
            }
        }
    }
    priority_queue<Q> pp;
    pp.push({compute(1,n),1, n});
    Q cur;
    
    int cl, cr;
    int id1, id2;
    while(!pp.empty()){
        cur = pp.top();
        pp.pop();
        cout << cur.pr.fi << " " << cur.pr.se << " ";
        id1 = pos[cur.pr.fi];
        id2 = pos[cur.pr.se];
        cl = cur.Lef;
        cr = cur.Rig;
        // cl..id1-1 | id1 + 1..id2-1 | id2+1..cr
        if(cl < id1){
            pp.push({compute(cl, id1-1), cl, id1-1});
        }
        if(id1 + 1 <= id2 - 1){
            pp.push({compute(id1+1, id2-1), id1 + 1, id2 - 1});
        }
        if(id2+1 <= cr){
            pp.push({compute(id2+1, cr), id2 + 1, cr});
        }
    }
    return 0;
}


Measured memory_bytes: 35956
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

using Data = pair<LL,LL>;
int main(){
    int N,M;cin >> N >> M;
    map<LL,vector<LL>> Work;
    rep(i,N){
        LL A,B;cin >> A >> B;
        Work[A].push_back(B);
    }
    LL sum = 0;
    priority_queue<LL> money;
    for(int i = 1;i<=M;i++){
        rep(j,Work[i].size()){
            money.push(Work[i][j]);
        }
        if(money.empty())continue;
        sum += money.top();
        money.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 10880
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define N 100

int main(){
  int n,p[N+1],m[N+1][N+1];
  int i,j,k,l;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=99999999;
      for(k=i;k<=j-1;k++){
	m[i][j]=fmin(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int n,m;
int dy[8]={0,1,-1,0,1,-1,1,-1},dx[8]={1,0,0,-1,1,1,-1,-1};
int t[100][100];
bool u[100][100]={};
stack<pair<int,int>>S;
void DFS(int a,int b)
{
	S.push(make_pair(a,b));
	u[a][b]=true;
	while(!S.empty())
	{	
		bool flag=true;
		int h=S.top().first,w=S.top().second;
		for(int i=0;i<8;i++)
		{
			int p=h+dy[i],q=w+dx[i];
			if(t[p][q]==1&&!u[p][q])
			{
				S.push(make_pair(p,q));
				u[p][q]=true;
				flag=false;
			}
		}
		if(flag)S.pop();
	}
}

int main()
{	
	while(cin>>n>>m)
	{
		int ans=0;
		if(n==0&&m==0)break;
		for(int i=0;i<=m+1;i++)
		{
			for(int j=0;j<=n+1;j++)
			{
				if(i==0||i==m+1||j==0||j==n+1)t[i][j]=0;
				else cin>>t[i][j];
			}
		}
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(u[i][j]||t[i][j]==0)continue;
				ans++;
				DFS(i,j);
			}
		}
		cout<<ans<<endl;
		for(int i=0;i<100;i++)
		{
			for(int j=0;j<100;j++)u[i][j]=false;
		}
	}
	return 0;
}



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

int main() {
  int A, B, H, M; cin >>A >>B >>H >>M;

  long double rad = M_PI * 2 *
                    (   (long double)H / 12.0 + ( (long double)M / 60.0 ) / 12.0
                      - (long double)M / 60.0 );

  long double rsq = (long double)(A*A + B*B) - (long double)( 2*A*B ) * cosl(rad);

  cout <<fixed <<setprecision(20) <<sqrtl(rsq) << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 2e5 + 5;

string s, s1;
int n;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	cin >> s;
	cin >> s1;
	REP(i, n) cout << s[i] << s1[i];
	return 0;
}


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

 using namespace std;

 #define mp make_pair
 #define fi first
 #define se second
 #define all(v) v.begin(),v.end()
 #define allarr(a) a , a + n
 #define ll long long
 #define pb push_back
 #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
 typedef pair<int, int> pi;
 typedef pair<ll,ll> pll; 
 typedef pair<int,pi> trp ;
 typedef vector<pi> vpi;
 typedef vector<pll> vpll ; 
 int _abs (int x ) { return (x>0?x:-x); }

const int N =1e5+5  , H = 1e4 ; 
int dp[N]; 
int h[N]; 
int main(){
    int n , k ;
    cin>>n >>k; 
    for(int  i=0;i<n;i++){
        cin>>h[i]; 
        dp[i]=2e9; 
    }
    dp[0]=0 ; // base case 
    for(int i = 1 ; i < n ; i++ ){
        for(int j = max(0,i-k) ; j<i ; j++  )
            dp[i] = min( dp[i] , dp[j] + _abs( h[i]-h[j])); 
    }
    cout<<dp[n-1]<<endl; 
}

Measured memory_bytes: 1024
import sys

def solve():
    s = input()
    t = input()
    alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"\
        , "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
    convert = dict()
    for i in range(26):
        convert[alphabet[i]] = i

    behind = [{i:-1 for i in range(26)} for _ in range(len(s) + 1)]
    canuse = set()
    for i in reversed(range(len(s))):
        for j in range(26): behind[i][j] = behind[i+1][j]
        behind[i][convert[s[i]]] = i
        canuse |= {s[i]}
    
    k = 0
    counter = 0
    for i in range(len(t)):
        if t[i] not in canuse:
            print(-1)
            break
        else:
            if behind[counter][convert[t[i]]] > -1:
                counter = behind[counter][convert[t[i]]] + 1
            else:
                k += 1
                counter = behind[0][convert[t[i]]] + 1
    else: print(k * len(s) + counter)
    #print(behind)

    return 0

if __name__ == "__main__":
    solve()

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

int main(){
  int n; cin>>n;
  set<int> st;
  for (int i=0; i<n; i++){
    int a; cin>>a;
    st.insert(a);
  }
  int ss=st.size();
  if (ss%2==1) cout<<ss<<endl;
  else cout<<ss-1<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
            for(int j=i+1;j<s.size();j++){
                if(s[j]=='F'){
                    cout<<"Yes\n";
                    return 0;
                }
            }
        }
    }
    cout<<"No\n";
    return 0;

}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    vector<char> ch(26);
    for (int i = 0; i < 26; i++)
    {
        ch[i] = 'A' + i;
    }
    int shift;
    cin >> shift;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        int t = s[i] - 'A';
        s[i] = ch[(t + shift) % 26];
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

int main()
{
	int N,a;
	int memo[15]={};
	int nmin=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> a;
		memo[a/400]++;
	}
	
	for(int i=9;i<=12;i++)
		memo[8]+=memo[i];
	
	if(memo[8]==N)
	{
		cout << 1 << " " << N << endl;
		return 0;
	}
	for(int i=0;i<=7;i++)
		if(memo[i]!=0)
			nmin++;
	cout << nmin << " " << nmin+memo[8] << endl;
	
	return 0;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
map<ll,ll> mapi;
ll a[212345];
int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll i;
    rep(i,n){
    	cin>>a[i];
    	if(i!=0)
    		a[i]+=a[i-1];
    	mapi[a[i]]++;
    	
    }
    ll ans=mapi[0];
    rep(i,n){
    	mapi[a[i]]--;
    	ans+=mapi[a[i]];
    }
    cout<<ans<<endl;


    return 0;  
    
}



Measured memory_bytes: 14336
X,N = map(int,input().split())

if N == 0:
  print(X)
  exit();

p = [int(i) for i in input().split()]

if X not in p:
  print(X)
  exit();

if N == 1 and p[0] == X:
  print(X-1)
  exit();

for j in range(101):
  if X-j not in p:
    print(X-j)
    exit();
  if X+j not in p:
    print(X+j)
    exit();


Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int x, a;
    while(cin>>x>>a){
        if(x<a)
            cout<<0<<endl;
        else{
            cout<<10<<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 < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

template<typename T>
T power(T x, T y) {
    T res = 1;
    for(;0 < y;) {
        if(y%2 == 0) {
            x *= x;
            y /= 2;
        }else{
            res *= x;
            y--;
        }
    }
    return res;
}

LL root5(LL x) {
    bool plus = 0 <= x;
    if(!plus) {
        x *= -1;
    }

    LL left = 0;
    LL right = 1000;
    for(;1 < right - left;) {
        LL mid = (left + right)/2;
        if(power<LL>(mid, 5) <= x) {
            left = mid;
        }else{
            right = mid;
        }
    }
    if(!plus) {
        left *= -1;
    }
    return left;
}

int main() {
    LL X;
    cin >> X;
    LL B = 114514;
    FOR(i, -1000, 1001) {
        LL x = X + power<LL>(i, 5);
        LL rt = root5(x);
        if(power<LL>(rt, 5) == x) {
            B = i;
            break;
        }
    }
    LL A = root5(X + power<LL>(B, 5));
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 3636
n = gets.to_i
as = gets.split.map(&:to_i)

h = Hash.new(0)
any = 0

def color(n)
  case n
  when 1..399
    0
  when 400..799
    1
  when 800..1199
    2
  when 1200..1599
    3
  when 1600..1999
    4
  when 2000..2399
    5
  when 2400..2799
    6
  when 2800..3199
    7
  else
    8
  end
end

as.each do |a|
  c = color(a)
  if c == 8
    any += 1
  else
    h[c] = 1
  end
end

total_color_num = 8
min = h.values.reduce(0){|a,e|a+=e}
if min > 0
  max = min + any
elsif any > 0
  min = 1
  max = any
else
  min = 0
  max = min
end

puts "#{min} #{max}"

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

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

  int ans = N / (1 + 2 * D);
  if ( N % (1 + 2 * D) != 0) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int parity=s.size()%2;
    int edge;
    if (s[0]==s[s.size()-1]){
        edge=0;
    }else {
        edge=1;
    }
    (edge+parity)%2==1? cout <<"Second"<<endl :cout << "First"<<endl;
}

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

int main(){
int n;
cin >> n;
vector<int> v(n);
vector<int> c(n);
int count = 0;
for (int i = 0;i < n;i++){
  cin >> v.at(i);
}
for (int i = 0;i < n;i++){
  cin >> c.at(i);
}
for (int i = 0;i < n;i++){
  count += max(0,v.at(i)-c.at(i));
}
cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 2e5+5;

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

   ll ans = 0;
   for(int i=1; i<=n; i++)
      ans += 1LL * i * (n - i + 1);


   for(int i=1; i<n; i++) {
      int u, v;
      scanf("%d %d", &u, &v);
      if(u > v) swap(u, v);
      ans -= 1LL * u * (n - v + 1);
   }

   cout << ans << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>

int f(int n)
{
    if(n%2==0) return n/2;
    else return 3*n+1;
}

int main()
{
    // std::cout << std::fixed << std::setprecision(5);
    int n; std::cin >> n;
    int l[n], sum=0, ma=-10;
    for(int i=0; i<n; i++)
    {
        std::cin >> l[i];
        sum += l[i];
        ma = std::max(ma, l[i]);
    }
    bool ans = false;
    for(int i=0; i<n; i++)
    {
        if(sum-ma>ma) ans = true;
    }

    std::cout << ((ans)?"Yes":"No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int sosu[1000003];
long long int NN;
long long int func(int a){
    if(a==0)return 0;
    for(long long int i=1;;i++){
        a-=i;
        if(a<0)return i-1;
    }

}
vector<long long int> sosulis;
int main(){
    for(long long int i=2;i<=1000000;i++){
        if(sosu[i]==0){
            sosulis.push_back(i);
            for(int j=i;j<1000003;j+=i){
                sosu[j]=1;
            }
        }
    }
    long long int N;
    cin>>N;
    NN=N;
    long long int ans=0;
    //for(int i=0;i<20;i++)cout<<sosulis[i]<<endl;
    for(long long int i=0;i<sosulis.size();i++){
        long long int cou=0;
        while(N%sosulis[i]==0){
            N/=sosulis[i];
            cou++;
        }
        //if(i<10)printf("[%d][%lld]\n",cou,func(cou));
        ans+=func(cou);
    }
    /*
    if(ans==0&&N!=0&&N!=1){
        cout<<1<<endl;
        return 0;
    }
    */
    if(N!=1)ans++;
    if(ans==0&&NN!=1)ans++;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11972
#include <iostream>

using namespace std;

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

int main(int argc, char** argv){
    long long int A, B, C, D;
    cin >> A >> B >> C >> D;
    long long int E = C * D / gcd(C, D);

    long long int N_C = B/C - A/C + ((A%C == 0) ? 1 : 0);
    long long int N_D = B/D - A/D + ((A%D == 0) ? 1 : 0);
    long long int N_E = B/E - A/E + ((A%E == 0) ? 1 : 0);

    cout << B - A + 1 - N_C - N_D + N_E << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char str[100001];
int main(void){
    int res=0;
    scanf("%s",str);
    int len = strlen(str);
    for(int i=0;i<len;i++){
        if(str[i]=='p') res--;
    }
    printf("%d\n",res+len/2);
}


Measured memory_bytes: 256
import itertools
import math

n = int(input())
cities = [list(map(int, input().split())) for i in  range(n)]
          
lis = [x for x in range(n)] # 0からn-1までのリスト
permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成

dist_list = []
for one_case in permutations_lis:
  dist = 0
  #print(one_case)
  for i, cur in enumerate(one_case):
    if i == 0:
      prev_city = cities[cur]
    else:
      cur_city = cities[cur]
      #print("check", prev_city, cur_city)
      dist += math.sqrt((cur_city[0] - prev_city[0])**2 + (cur_city[1] - prev_city[1])**2)
      #print(dist)
      prev_city = cur_city
  dist_list.append(dist)
    
print(sum(dist_list) / len(dist_list))

Measured memory_bytes: 4404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI = 3.14159265358979;

struct Point {
	double x, y;
};

void koch(int deep, Point p1, Point p2) {
	if (deep == 0) return;

	Point s, t, u;
	double th = PI * 60.0 / 180.0;

	s.x = (2 * p1.x + p2.x) / 3.0;
	s.y = (2 * p1.y + p2.y) / 3.0;
	u.x = (p1.x + 2 * p2.x) / 3.0;
	u.y = (p1.y + 2 * p2.y) / 3.0;

	t.x = (u.x - s.x) * cos(th) - (u.y - s.y) * sin(th) + s.x;
	t.y = (u.x - s.x) * sin(th) + (u.y - s.y) * cos(th) + s.y;


	koch(deep - 1, p1, s);
	printf("%.8lf %.8lf\n", s.x, s.y);
	koch(deep - 1, s, t);
	printf("%.8lf %.8lf\n", t.x, t.y);
	koch(deep - 1, t, u);
	printf("%.8lf %.8lf\n", u.x, u.y);
	koch(deep - 1, u, p2);

}

int main() {

	int n; cin >> n;
	Point p1{ 0.0, 0.0 };
	Point p2{ 100.0, 0.0 };
	printf("%.8lf %.8lf\n", p1.x, p1.y);
	koch(n, p1, p2);
	printf("%.8lf %.8lf\n", p2.x, p2.y);

	return 0;
}



Measured memory_bytes: 3116
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))+[0]

prev = N
cnt = 0
for a, b in zip(As,Bs):
    # print("b",b,"a,",a,"prev",prev)
    cnt += b
    if prev + 1 == a:
        cnt += Cs[a-2]
        # print("add c",Cs[a-2])
    prev = a
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <utility>

#define INF 1e9+7
#define pow2(x) (1LL<<(x))
#define mod2(A,x) (((A)>>(x)) % 2)

using namespace std;
using llng = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int main() {
    llng A, B; cin >> A >> B;
    int r, k;
    for (int i = 64; i >= 1; i--) {
        if (mod2(A, i-1) == mod2(B, i-1)) continue;
        r = i;
        break;
    }
    for (int i = r-1; i >= 1; i--) {
        if (mod2(B, i-1) == 0) continue;
        k = i;
        break;
    }

    A %= pow2(r);

    llng ans = 0;
    ans += pow2(r-1) - A;
    if ((pow2(r-1) + pow2(k)) < (pow2(r-1) + A)) {
        ans += (pow2(r-1) + pow2(k)) - (pow2(r-1));
        ans += pow2(r) - (pow2(r-1) + A);
    } else {
        ans += pow2(r) - pow2(r-1);
    }

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

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

#define fore(i, a, b) for(int i = a; i < b; i++)
#define forn(i, n) fore(i, 0, n)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ford(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;

typedef long long ll;

const int N = 4000006;

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

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

	printf("%s\n", (a-b)&1 ? "Borys" : "Alice");



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int a[4][4] , c[4][4];
int b[200] ;
int main()
{
	for(int i = 1; i <= 3 ;i ++)
	 for(int j = 1; j <= 3 ;j ++)
	  cin >> a[i][j] ;
	int n ;
	cin >> n ;
	for(int i = 1 , x ; i <= n ;i ++) cin >> x , b[x] = 1 ;
	for(int i = 1 ; i <= 3 ;i ++)
	 for(int j = 1; j <= 3 ;j ++)
	  if(b[a[i][j]]) c[i][0] ++ , c[0][j] ++ ;
int x = 0 , y = 0 ;
	for(int i = 1 ;i <= 3 ;i ++)
	 if(b[a[i][i]])
	  x ++ ;
	for(int i = 1; i <= 3 ;i ++)
	 if(b[a[4 - i][i]]) y ++ ;
	for(int i = 1; i <= 3 ;i ++)
	 if(c[i][0] >= 3 || c[0][i] >= 3)
	  return 0 * puts("Yes") ;
	if(x >= 3 || y >= 3)
	 return 0 * puts("Yes") ;
	puts("No") ;
	return 0 ;
}


Measured memory_bytes: 256