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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;

    if (a < b) {
        cout << "Bob\n";
    } else if (a > b) {
        cout << "Alice\n";
    } else {
        cout << "Draw\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )

class Cube{
public:
  char G[7][3][3]; // 6 for temp
  int cost;
  Cube(){ cost = 0;}
  bool operator < ( const Cube &c) const{
    rep(k, 6) rep(i, 3) rep(j, 3){
      if ( G[k][i][j] == c.G[k][i][j] ) continue;
      return G[k][i][j] < c.G[k][i][j];
    }
    return false;
  }

  void clock90(int k){
    char T[3][3];
    rep(i, 3) rep(j, 3) T[i][j] = G[k][i][j];
    rep(i, 3) rep(j, 3) G[k][i][j] = T[3-j-1][i];
  }
  void assign(int s, int t){
    rep(i, 3) rep(j, 3) G[t][i][j] = G[s][i][j];
  }
  void clock180(int k){ rep(i, 2) clock90(k); }
  void rotateF(){
    assign(5, 6);
    assign(0, 5);
    assign(4, 0);
    clock180(2);
    assign(2, 4);    
    clock180(6);
    assign(6, 2);    
    clock90(1);
    rep(i, 3) clock90(3);
  }

  void rotateR(){
    assign(1, 6);
    clock90(4);
    assign(4, 1);
    clock90(3);
    assign(3, 4);
    clock90(5);
    assign(5, 3);
    clock90(6);
    assign(6, 5);
    clock90(2);
    rep(i, 3) clock90(0);
  }

  void rotateB(){ rep(i, 3) rotateF(); }
  void rotateL(){ rep(i, 3) rotateR(); }

  bool isGoal(){
    bool f = false;
    bool b = false;
    rep(j, 3) if ( G[0][2][j] == '*' ) f = true;
    rep(j, 3) if ( G[2][2][j] == '*' ) b = true;
    return f && b;
  }
};

void update(queue<Cube> &Q, set<Cube> &V, Cube &u, Cube &v){
  if ( V.find(v) == V.end() ){
    V.insert(v);
    v.cost = u.cost + 1;
    Q.push(v);
  }
}

int bfs(Cube C){
  queue<Cube> Q;
  set<Cube> V;
  C.cost = 0;
  Q.push(C);
  V.insert(C);
  Cube u, v;
  while(!Q.empty()){
    u = Q.front(); Q.pop();
    if ( u.isGoal() ) return u.cost;
    v = u;
    v.rotateF();
    update(Q, V, u, v);
    v = u;
    v.rotateB();
    update(Q, V, u, v);
    v = u;
    v.rotateL();
    update(Q, V, u, v);
    v = u;
    v.rotateR();
    update(Q, V, u, v);
  }
}

bool input(Cube &C){
  rep(k, 6) rep(i, 3) rep(j, 3){
    cin >> C.G[k][i][j];
    if ( C.G[k][i][j] == '#' ) return false;
  }
  return true;
}

main(){
  Cube C;
  while(input(C)) cout << bfs(C) << endl;
}

Measured memory_bytes: 1192
n = int(input())
a = list(map(int,input().split()))
res = []
for k in range(n):
    for ii,j in enumerate(a[::-1]):
        i = (n - k) - ii - 1
        # print(i, j)
        if j == i + 1:
            res.append(j)
            a = a[:i] + a[i + 1:]
            break
    else:
        print(-1)
        exit()
print(*res[::-1], sep='\n')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

    if(n%k==0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){

		
		Scanner sc = new Scanner(System.in);
		String str = null;
		while(sc.hasNext()){
			str = sc.nextLine();
			String result = str;
			for(int i = 0; i < 27; i++){
				result = shiftString(i, str);
				if(strContainsKeywords(result, "the", "this", "that")) break;
			}
			System.out.println(result);
		}
		sc.close();
	}
	
	static String shiftString(int shift, String str) {
		char[] result = str.toCharArray();
		for(int i = 0; i < result.length; i++) {
			if(result[i] != '.' && result[i] != ' ' && result[i] != '\n') {
				if(result[i] + shift >= 'a' && result[i] + shift <= 'z') result[i] += shift;
				else if(result[i] + shift < 'a') result[i] = (char) ('z' + 1 - 'a' + result[i] + shift);
				else result[i] = (char) ('a' - 1 - 'z' + result[i] + shift);
			}
		};
		return new String(result);
	}
	
	static boolean strContainsKeywords(String str, String... keys) {
		boolean result = false;
		for(String s: keys) if(str.contains(s)) result = true;
		return result;
	}
}

Measured memory_bytes: 17360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
string s, t;

int main() {
    cin >> n >> s >> t;
    rep(i,s.size()) {
        bool ok = true;
        for (int j = i; j < s.size(); j++) {
            if (s[j] != t[j-i]) {
                ok = false;
            }
        }
        if (ok) {
            for (int j = s.size()-i; j < t.size(); j++) {
                s.push_back(t[j]);
            }
            cout << s.size() << endl;
            return 0;
        }
    }
    cout << s.size()+t.size() << endl;
}

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<long long>a(n);
  for(int i=0;i<n;i++) a[i]=0;
  long long ans=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      for(int i=0;i<n;i++) a[i]=0;
      long long y=0;
      for(int j=i+1;j<n;j++){
        if(s[j]=='G'){
          y++;
          if(2*j-i<n){
            a[2*j-i]++;
          }
        }
        if(s[j]=='B'){
          ans+=y-a[j];
        }
      }
    }
  }
  for(int i=0;i<n;i++) a[i]=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      for(int i=0;i<n;i++) a[i]=0;
      long long y=0;
      for(int j=i+1;j<n;j++){
        if(s[j]=='B'){
          y++;
          if(2*j-i<n){
            a[2*j-i]++;
          }
        }
        if(s[j]=='G'){
          ans+=y-a[j];
        }
      }
    }
  }
  for(int i=0;i<n;i++) a[i]=0;
  for(int i=0;i<n;i++){
    if(s[i]=='G'){
      for(int i=0;i<n;i++) a[i]=0;
      long long y=0;
      for(int j=i+1;j<n;j++){
        if(s[j]=='B'){
          y++;
          if(2*j-i<n){
            a[2*j-i]++;
          }
        }
        if(s[j]=='R'){
          ans+=y-a[j];
        }
      }
    }
  }
  for(int i=0;i<n;i++) a[i]=0;
  for(int i=0;i<n;i++){
    if(s[i]=='G'){
      for(int i=0;i<n;i++) a[i]=0;
      long long y=0;
      for(int j=i+1;j<n;j++){
        if(s[j]=='R'){
          y++;
          if(2*j-i<n){
            a[2*j-i]++;
          }
        }
        if(s[j]=='B'){
          ans+=y-a[j];
        }
      }
    }
  }
  for(int i=0;i<n;i++) a[i]=0;
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
      for(int i=0;i<n;i++) a[i]=0;
      long long y=0;
      for(int j=i+1;j<n;j++){
        if(s[j]=='R'){
          y++;
          if(2*j-i<n){
            a[2*j-i]++;
          }
        }
        if(s[j]=='G'){
          ans+=y-a[j];
        }
      }
    }
  }
  for(int i=0;i<n;i++) a[i]=0;
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
      for(int i=0;i<n;i++) a[i]=0;
      long long y=0;
      for(int j=i+1;j<n;j++){
        if(s[j]=='G'){
          y++;
          if(2*j-i<n){
            a[2*j-i]++;
          }
        }
        if(s[j]=='R'){
          ans+=y-a[j];
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int a,b ;
  cin >> a >> b;
  if ( (a+1)/2 == a/2 || (b+1)/2 == b/2) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

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

typedef pair<int, int> pi;
int h, w;
string s[1000];
int cost[1000][1000];
pi dyx[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

void bfs() {
  queue<pair<int, pi>> q;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s[i][j] == '#') {
        cost[i][j] = 0;
        q.push(make_pair(0, make_pair(i, j)));
      }
    }
  }
  while (!q.empty()) {
    auto front = q.front();
    q.pop();
    int c;
    pi p;
    tie(c, p) = front;

    for (auto d: dyx) {
      int dy, dx;
      tie(dy, dx) = d;
      int y = p.first + dy;
      int x = p.second + dx;
      if (y < 0 || y >= h || x < 0 || x >= w) {
        continue;
      }
      if (cost[y][x] != -1) {
        continue;
      }
      cost[y][x] = c + 1;
      q.push(make_pair(c + 1, make_pair(y, x)));
    }
  }
}
int main() {
  cin>>h>>w;
  for (int i=0; i<h; i++) cin>>s[i];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cost[i][j] = -1;
    }
  }
  bfs();
  int max_cost = 0;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      max_cost = max(cost[i][j], max_cost);
    }
  }
  cout<<max_cost<<endl;
}

Measured memory_bytes: 17296
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    S = SI()
    T = SI()
    ans = 0
    for s, t in zip(S, T):
        if s != t:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9668
A,B,C,D,E,F=map(int,input().split())

W=[]
for i in range(30):
  for j in range(30):
    if (i*A+j*B)*100<=F:
      W.append((i*A+j*B)*100)
W=sorted(set(W))

S=[]
for i in range(F):
  for j in range(F):
    if i*C+j*D<=F:
      S.append(i*C+j*D)
S=sorted(set(S))

nou=0
for w in W:
  for s in S:
    if w+s<=F:
      if E*w//100>=s:
        if w!=0 or s!=0:
          if nou<=s/(w+s):
            nou=s/(w+s)
            ans=[w+s,s]
        
print(ans[0],ans[1])

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

int cmpnum(const void * n1, const void * n2)
{
	if(*(int *)n1 >*(int *)n2)
	{
		return -1;
	}
	else if(*(int *)n1 < *(int *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
}
}

int main(void)
{
	int n,i;
	int a[200000]={0};
	int k;
	int score=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&k);
		a[i]=k;
	}
	qsort(a, sizeof(a)/ sizeof(a[0]),sizeof(int),cmpnum);
	for(i=0;i<n-1;i++){
		if(a[i]==a[i+1])
			score++;
	}
	
	if(score>0)
		printf("NO");
	else
		printf("YES");
}

Measured memory_bytes: 1788
N, x = map(int, input().split())
A = sorted(map(int, input().split()))

if sum(A) == x:
    print(N)

else:
    c = 0
    for ai in A:
        x -= ai
        if x <= 0:
            break
        c += 1

    if c == N:
        print(N - 1)
    else:
        print(c + 1 if x == 0 else c)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  vector<ll>results;
  rep(i, n){
    if(i==0){results.insert(results.begin(), a[i]);continue;}
    auto it = lower_bound(results.begin(), results.end(), a[i]);
    if( it==results.end() ){
      if(it==results.begin()) results.insert(results.begin(), a[i]);
      else *prev(it) = a[i];
    }else{
      if(it==results.begin()) results.insert(results.begin(), a[i]);
      else *prev(it) = a[i];
    }
  }
  cout<<results.size()<<endl;

  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vector<pll> Asort(N);
	rep(i, N) {
		cin >> Asort[i].first;
		Asort[i].second = i;
	}
	sort(Asort.begin(), Asort.end(), greater<pll>());
	vector<vl> DP(N + 1);
	rep(i, N + 1)
		DP[i].resize(N, -InfLL);
	DP[0][0] = 0;
	rep(i, N) {
		ll Atmp = Asort[i].first;
		int idx = Asort[i].second;
		rep(k, N) {
			DP[i + 1][k] = max(DP[i + 1][k], DP[i][k] + Atmp * abs(N - 1 - (i - k) - idx));
			DP[i + 1][k + 1] = max(DP[i + 1][k + 1], DP[i][k] + Atmp * abs(k - idx));
		}
	}

	ll ans = -InfLL;
	rep(k, N) {
		ans = max(ans, DP[N][k]);
	}

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

Measured memory_bytes: 35004
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

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

ll n,a,b,c,d;
map<ll, ll> dp;

ll dfs(ll now){
    if(now == 0) return 0;
    if(now == 1) return d;
    if(dp.count(now)) return dp[now];
    ll res = LINF;
    if((LINF)/d > now) res = now*d;
    vector<ll> v = {a,b,c};
    rep(i,3){
        int next = vector<int>{2,3,5}[i];
        if(now % next == 0){
            res = min(res,dfs(now/next)+v[i]);
        }
        else{
            ll l = now/next*next, r = l+next;
            res = min(res,dfs(l/next)+v[i]+(now-l)*d);
            res = min(res,dfs(r/next)+v[i]+(r-now)*d);
        }
    }
    return dp[now] = res;

}

int main(){
    int t; cin >> t;
    while(t--){
        cin >> n >> a >> b >> c >> d;
        dp.clear();
        cout << dfs(n) << endl;
    }
}



Measured memory_bytes: 4328
#include <stdio.h>

void depth(int,int);

int d[20],k[100000],c[100000][20],g[100000],root,id;

int main()
{
  int i,n,id,j,p[100000],type[100000];

  scanf("%d",&n);

  for(j=0;j<n;j++) d[j]=0;

  for(j=0;j<n;j++){
    scanf("%d",&id);
    scanf("%d",&k[id]);

    for(i=0;i<k[id];i++){
      scanf("%d",&c[id][i]);

	d[c[id][i]]= d[id] + 1;
  
      p[c[id][i]] = id;
    }

    if(d[id]==0){
 p[id] =-1;
    }
  }

  /*type*/
  for(j=0;j<n;j++){
    if(p[j]==-1) {
type[j] = 0;
 root = j;
    }
    else if(k[j]==0) type[j] = 1;
    else type[j] = 2;
  }

  depth(root,0);

  for(j=0;j<n;j++){
    printf("node %d: parent = %d, depth = %d, ",j,p[j],g[j]);

    if(type[j]==0) printf("root, ");
    else if(type[j]==1) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(i=0;i<k[j];i++){
      printf("%d",c[j][i]);  
      if(i!=k[j]-1) printf(", ");
    }
    printf("]\n");
  }

  return 0;
}

void depth(int v,int dep){
  int i;
  g[root]=0;
  if(k[v]==0) return;
  dep++;
  for(i=0;i<k[v];i++){    
    g[c[v][i]]=dep;
  }

  for(i=0;i<k[v];i++){
    depth(c[v][i],dep);
  }

}

Measured memory_bytes: 2964
import sys
n=int(input())

oddn=0
if n<10:
  oddn+=n
  print(oddn)
  sys.exit()
else:
  oddn+=9
if n<100:
  print(oddn)
  sys.exit()
  
if n<1000:
  oddn+= n-99
  print(oddn)
  sys.exit()
else:
  oddn+=900

if n>=10000:
  oddn+=n-9999
if n==100000:
  oddn-=1

print(oddn)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

vector<bool> isPrime(int n){
  vector<bool> p(n+1, true);
  p[0] = false;
  p[1] = false;
  for(int i=2; i<=sqrt(n); i++){
    if( p[i] == false ) continue;
    for(int j=i+i; j<n; j+=i){
      p[j] = false;
    }
  }
  return p;
}

int main(void) {

  vector<bool> p = isPrime(50000);
  vector<int> a;
  for(int i=0; i<p.size(); i++){
    if( p[i] ) a.push_back(i);
  }

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    if( n % 2 == 1 ){
      if( p[n-2] ) cout << 1 << endl;
      else cout << 0 << endl;
    }else{
      int cnt = 0;
      for(int i=0; i<a.size(); i++){
        if( a[i] > n - a[i] ) break;
        // if( p[ n - a[i] ] ) cerr << a[i] << endl;
        if( p[ n - a[i] ] ) cnt++;
      }
      cout << cnt << endl;
    }
  }

  return 0;
}

// EOF

Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
long long n,a[200010],f[200010],g[200010];
long long w;
int main(){
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(long long i=1;i<=n;i++){
		f[i]=f[i-1]+a[i];
		g[i]=g[i-1]^a[i];
	}
	long long l=1;
	for(long long r=1;r<=n;r++){
		for(;f[r]-f[l-1]!=(g[r]^g[l-1]);l++);
		w+=r-l+1;
	}
	printf("%lld\n",w);
}

Measured memory_bytes: 4992
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double angleH = 0;
		double angleM = 0;
		angleH = H * 30 + M * 0.5;
		angleM = M * 6;
		double angle = angleH - angleM;
		double ans = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.print(ans);
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    int a[n+1]; FOR(i,1,n+1) cin >> a[i];

    ll dp[n+2][n+2][2];
    memset(dp, 0, sizeof dp);
    RFOR(i,n,1) FOR(j,1,n) FOR(t,0,1) {
        if (i>j) continue;

        if (t == 0) {
            dp[i][j][t] = max(a[i]+dp[i+1][j][!t], a[j]+dp[i][j-1][!t]);
        } else {
            dp[i][j][t] = min(dp[i+1][j][!t]-a[i], dp[i][j-1][!t]-a[j]);
        }
        //cout << i << ' ' << j << ' ' << t << " :: " << dp[i][j][t] <<  endl;
    }
    cout << dp[1][n][0] << '\n';
}



Measured memory_bytes: 141056
from collections import defaultdict
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]

cnt = defaultdict(int)
for d in D:
    cnt[d] += 1
for t in T:
    cnt[t] -= 1

if min(cnt.values()) >= 0:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 41572
s = list(input())
t = list(input())
f = False
l = len(s)
p = ["" for _ in range(l)]
if s == t: f = True
for i in range(l):
	for j in range(l):
		p[(j+i)%l] = t[j]
	if s == p: 
		f = True
if f: print("Yes")
else: print("No")

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

int main(){

    int N, M;
    int sumA = 0;
    int qualified = 0;
    vector<int> A;

    cin >> N >> M;
    A.resize(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
        sumA += A[i];
    }

    float bordar = (float)sumA / (4 * M);

    for (int i = 0; i < N; i++){
        if(A[i] >= bordar){
            qualified++;
        }
        if(qualified >= M){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int Zeller(int,int,int);

int main(void){
  int i,j,sum,a,b;
  
  while(1){
    sum=0;
    scanf("%d %d",&a,&b);
    if(a==0 && b==0)break;

    switch(Zeller(2004,a,b)){
    case 0:
      printf("Sunday\n");
      break;
    case 1:
      printf("Monday\n");
      break;
    case 2:
      printf("Tuesday\n");
      break;
    case 3:
      printf("Wednesday\n");
      break;
    case 4:
      printf("Thursday\n");
      break;
    case 5:
      printf("Friday\n");
      break;
    case 6:
      printf("Saturday\n");
      break;
    }
  }
  return 0;
}

int Zeller(int year, int month, int day){
    if (month<3) {
        year--;
        month += 12;
    }
    return (year + year/4 - year/100 + year/400
            + (13*month+8)/5 + day) % 7;
}

Measured memory_bytes: 1012
#include <iostream>

using namespace std;

const int maxN = 1e5 + 5;
const int inf = 1e9 + 7;
int n, k, h[maxN], f[maxN];

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();
    cin >> n >> k;

    for(int i = 0; i < n; ++i)
        cin >> h[i];

    for(int i = 1; i < n; ++i)
    {
        f[i] = inf;
        for(int j = i-1; j >= max(0, i-k); j--)
            f[i] = min(f[j]+abs(h[i]-h[j]), f[i]);
    }
    cout << f[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 4384
#include <stdio.h>
#define SIZE 4

/* prototype declaration */
int hit(int* a, int* b);
int blow(int *a, int* b);

int main(int argc, const char *argv[])
{
	int a[SIZE], b[SIZE];
	
	while(scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]);
		printf("%d %d\n", hit(a, b), blow(a, b));
	}	

	return 0;
}

int hit(int* a, int* b)
{
	int i, cnt = 0;
	for(i=0; i<SIZE; i++)
		if(a[i] == b[i]) cnt++;
	return cnt;
}

int blow(int *a, int* b)
{
	int i, j, cnt = 0;
	for(i=0; i<SIZE; i++)
		for(j=0; j<SIZE; j++)
			if(a[i] == b[j]) cnt++;
	return cnt-hit(a, b);
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

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

	int n;
	cin >> n;

	unordered_set<string> d;
	while (n--)
	{
		string cmd, s;
		cin >> cmd >> s;

		if (cmd == "insert") d.insert(s);
		else cout << (d.find(s) != d.end() ? "yes" : "no") << endl;
	}

	return 0;
}

Measured memory_bytes: 28844
n = int(input())
a = list(map(int,input().split()))

cnt_fu = 0
cnt_0 = 0
ans = 0
b = []
for i in range(n):
    ans += abs(a[i])
    b.append(abs(a[i]))
    if a[i]<0:
        cnt_fu += 1
    if a[i]==0:
        cnt_0 += 1
#print(cnt_fu,cnt_0,ans,b)
if cnt_fu%2==0:
    print(ans)
else:
    print(ans-min(b)*2)


Measured memory_bytes: 20124
module aoj;
import std.array;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

class FixedQueue(T) {
  private T[] mData;
  private int mCapacity;
  private int mHead;
  private int mTail;

  this(int capacity) {
    mHead = mTail = 0;
    mCapacity = capacity;
    mData = new T[capacity];
  }

  void push(T x) {
    mData[mHead] = x;
    mHead = (mHead + 1) % mCapacity;
  }

  T pop() {
    scope(exit) { mTail = (mTail + 1) % mCapacity; }
    return mData[mTail];
  }

  bool empty() { return mHead == mTail; }
}

string getLine() {
  string ret;
  do {
    ret = chomp(readln());
  } while (ret.length == 0);
  return ret;
}

void main() {
  for (;;) {
    // Input
    string[] input = split(getLine());
    int H = to!int(input[0]);
    int W = to!int(input[1]);
    auto field = new char[][](H, W);
    if (H == 0 && W == 0) { break; }
    int ay = -1, ax = -1;
    int by = -1, bx = -1;
    foreach (y; 0 .. H) {
      string line = readln();
      foreach (x; 0 .. W) {
        if (line[x] == 'A') {
          ay = y;
          ax = x;
          field[y][x] = '.';
        } else if (line[x] == 'B') {
          by = y;
          bx = x;
          field[y][x] = '.';
        } else {
          field[y][x] = line[x];
        }
      }
    }
    string pattern = chomp(readln());

    // BFS
    immutable(int[]) dy = [-1, 0, 1, 0];
    immutable(int[]) dx = [0, -1, 0, 1];
    alias Tuple!(int, "y", int, "x") State;
    auto Q = new FixedQueue!State(2 * (H + W));
    auto cost = new int[][](H, W);
    foreach (c; cost) { c[] = -1; }
    Q.push(State(ay, ax));
    cost[ay][ax] = 0;
    while (!Q.empty()) {
      State s = Q.pop();
      foreach (k; 0 .. 4) {
        int ny = s.y + dy[k];
        int nx = s.x + dx[k];
        if (0 <= ny && ny < H && 0 <= nx && nx < W) {
          if (field[ny][nx] == '.' && cost[ny][nx] == -1) {
            cost[ny][nx] = cost[s.y][s.x] + 1;
            Q.push(State(ny, nx));
          }
        }
      }
    }

    // Simulation
    bool ok = false;
    int limit = cast(int)pattern.length * H * W;
    foreach (time; 0 .. limit) {
      if (cost[by][bx] != -1 && cost[by][bx] <= time) {
        writefln("%d %d %d", time, by, bx);
        ok = true;
        break;
      }
      switch (pattern[time % pattern.length]) {
      case '5': break;
      case '8': by -= 1; break;
      case '6': bx += 1; break;
      case '4': bx -= 1; break;
      case '2': by += 1; break;
      default: assert(false);
      }
      by = max(0, min(H - 1, by));
      bx = max(0, min(W - 1, bx));
    }
    if (!ok) { writeln("impossible"); }
  }
}

Measured memory_bytes: 1032
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __repr__(self):
        return str(self.__x)

    def __neg__(self):
        return mint(-self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md=998244353

def main():
    n,s=MI()
    aa=LI()
    dp=[0]*(s+1)
    dp[0]=mint(1)
    for a in aa:
        for i in range(s,-1,-1):
            pre=dp[i]
            if pre==0:continue
            dp[i]+=pre
            if i+a<=s:dp[i+a]+=pre
    print(dp[s])

main()

Measured memory_bytes: 103420
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	c = a % 500;
	if(b>=c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
  return 0;
}

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

int main(){
    vector<pair<int,int> > A(1000000);
    cin>>A[0].first;
    A[0].second=1;
    for(int i=1;i<1000000;i++){
        A[i].second=i+1;
        if(A[i-1].first%2==0){
            A[i].first=A[i-1].first/2;
        }else{
            A[i].first=3*A[i-1].first+1;
        }
    }
    sort(A.begin(),A.end());
    int mini=10000000;
    for(int i=1;i<1000000;i++){
        if(A[i-1].first==A[i].first){
            mini=min(mini,A[i].second);
        }
    }
    cout<<mini<<endl;
}


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

bool YM(int s){
  if(0 < s && s < 13){
    return true; //monthだとtrue
  }else{
    return false;
  }
}

int main(){
  int A;
  cin >> A;
  
  int s1, s2;
  s1 = A / 100; //千の位と百の位
  s2 = A % 100; //十の位と一の位
  
  if(YM(s1) && YM(s2)){
    cout << "AMBIGUOUS" << endl;
  }else if(YM(s1) && !YM(s2)){
    cout << "MMYY" << endl;
  }else if(!YM(s1) && YM(s2)){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int i = 0;
    int m[] = new int [50];
    int f[] = new int [50];
    int r[] = new int [50];

    while(true){
        m[i] = sc.nextInt();
        f[i] = sc.nextInt();
        r[i] = sc.nextInt();
        if(m[i] == -1 && f[i] == -1 && r[i] == -1) break;
        i++;
    }

    int times = 0;

    while(times<i){
      if(m[times] == -1 || f[times] == -1) System.out.printf("F\n");
      else if(m[times] + f[times] >= 80) System.out.printf("A\n");
      else if(m[times] + f[times] >=65 && m[times] + f[times] <80) System.out.printf("B\n");
      else if(m[times] + f[times] >=50 && m[times] + f[times] <65) System.out.printf("C\n");
      else if(m[times] + f[times] >=30 && m[times] + f[times] <50) {
        if(r[times] >= 50) System.out.printf("C\n");
        else System.out.printf("D\n");
      }
      else if(m[times] + f[times] < 30) System.out.printf("F\n");
      times++;
    }
  }
}



Measured memory_bytes: 26436
# from #15490827
import bisect

def solve(deg1, deg2, lis, magnification):
    tmpAns = 10 ** 10
    for dx in lis[deg1].keys():
        if dx not in lis[deg2].keys():
            continue
        for dy in lis[deg1][dx]:
            t = bisect.bisect_left(lis[deg2][dx], dy)
            if t < len(lis[deg2][dx]):
                tmpAns = min(tmpAns, (lis[deg2][dx][t] - dy) * magnification)
    return tmpAns

N = int(input())
fTof = {"U": {}, "D": {}, "R": {}, "L": {}}
urld = {"U": {}, "D": {}, "R": {}, "L": {}}
ulrd = {"U": {}, "D": {}, "R": {}, "L": {}}
for _ in range(N):
    x, y, u = input().split()
    x = int(x)
    y = int(y)
    if u == "U" or u == "D":
        if x in fTof[u]:
            fTof[u][x].append(y)
        else:
            fTof[u][x] = [y]
    else:
        if y in fTof[u]:
            fTof[u][y].append(x)
        else:
            fTof[u][y] = [x]
    if x+y in urld[u]:
        urld[u][x + y].append(y)
    else:
        urld[u][x + y] = [y]
    if x - y in ulrd[u]:
        ulrd[u][x - y].append(y)
    else:
        ulrd[u][x - y] = [y]

for i in fTof:
    for j in fTof[i]:
        fTof[i][j].sort()
for i in urld:
    for j in urld[i]:
        urld[i][j].sort()
for i in ulrd:
    for j in ulrd[i]:
        ulrd[i][j].sort()
ans = 10**10
ans = min(ans, solve("R", "L", fTof, 5))
ans = min(ans, solve("U", "D", fTof, 5))
ans = min(ans, solve("U", "R", urld, 10))
ans = min(ans, solve("L", "D", urld, 10))
ans = min(ans, solve("U", "L", ulrd, 10))
ans = min(ans, solve("R", "D", ulrd, 10))
print("SAFE" if ans == 10**10 else ans)

Measured memory_bytes: 111896
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k,q;std::cin>>n>>k>>q;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint ans=std::numeric_limits<lint>::max();
    for(lint Y:a){
        std::vector<lint>b;
        for(lint l=0,r=0;l<n;){
            for(l=r;l<n&&a.at(l)<Y;l++);
            for(r=l;r<n&&Y<=a.at(r);r++);
            if(r-l<k)continue;
            std::vector<lint>c={a.begin()+l,a.begin()+r};
            std::sort(c.rbegin(),c.rend());
            b.insert(b.end(),c.begin()+k-1,c.end());
        }
        if((lint)b.size()<q)continue;
        std::sort(b.begin(),b.end());
        cmn(ans,b.at(q-1)-Y);
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
        int i,j,k;
        int n,m,c;
        while(1){
                scanf("%d %d",&n,&m);
                if(n==0 && m==0)
                        break;
                c=0;
                for(i=1;i<=n;i++){
                        for(j=1;j<=n;j++){
                                for(k=1;k<=n;k++){
                                        if(i==j || i==k || j==k)
                                                continue;
                                        if((i+j+k) == m){
                                                //printf("%d+%d+%d==%d\n",i,j,k,i+j+k);
                                                c++;
                                        }
                                }
                        }
                }
                printf("%d\n",c/6);
        }
        return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,ans=0,k,c=1e10,l=0;cin>>n>>k;int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        c=min(c,a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(c==a[i] && l!=0)
        {
            ans++;
            i+=k-(l+1);
            l=0;
            continue;
        }
        if(c!=a[i])
            l++;
        if(l==k)
        {
            ans++;
            l=1;
        }
    }
    if(l)
    ans++;
    cout<<ans;
    
}
 

Measured memory_bytes: 1024
#include <cstdio>
using ll = long long;
ll f(ll n) {
    ll t = (n + 1) >> 1;
    if (n & 1) {
        return t & 1;
    }
    else {
        return (t & 1) ^ n;
    }
}
int main() {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", f(a-1)^f(b));
    return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n), bound(n + 1);
  bound.at(0) = 0;
  int memo;
  for (int i = 0; i < n; i++) {
    cin >> l.at(i);
    bound.at(i + 1) = bound.at(i) + l.at(i);
    if (bound.at(i + 1) > x) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << n + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
char s[4005],t[8005];
int main(){
	int i,j,sl,tl,ans,x;
	while(scanf("%s%s",s,t)!=EOF){
		sl=strlen(s);
		tl=strlen(t);
		//strcat(t,t);
		//for(i=tl;i<tl*2;i++)t[i]=t[i-tl];
		ans=0;
		//printf("%s\n%s\n",s,t);
		for(i=-tl;i<sl;i++){
			x=0;
			for(j=0;j<sl && i+j<tl;j++){
				if(0<=i+j && t[i+j]==s[j])x++;
				else{
					ans=Max(ans,x);
					x=0;
				}
			}
			if(x>ans)ans=x;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 420
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

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

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanLines)
	str := nextString()

	var lower = regexp.MustCompile(`^[a-z]$`)
	var upper = regexp.MustCompile(`^[A-Z]$`)

	for i := range str {
		c := str[i:(i + 1)]
		if lower.MatchString(c) {
			fmt.Print(strings.ToUpper(c))
		} else if upper.MatchString(c) {
			fmt.Print(strings.ToLower(c))
		} else {
			fmt.Print(c)
		}
	}
	fmt.Print("\n")
}



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

#M[u][v]:uからvへの重みを保存した隣接行列
M=[]
for n in range(N):
    input_temp = list(map(int,input().split()))
    M.append(input_temp)

#color:各頂点の訪問状態を示す
color=['white']*N

#d:TとV-Tを繋ぐ辺の中で重みが最小の辺の重みの値を保持
d=[10**10]*N

#p[v-1]:MSTにおけるvの親を保持
p=[-1]*N

#初期値
d[0] = 0
p[0] = -1

# ans=0
while True:
#     ans+=1
    mincost=10**10
    for i in range(N):
        if color[i] != 'BLACK' and d[i] < mincost:
            mincost = d[i]
            u = i
#     print(u,mincost)       
    if mincost == 10**10:
        break
    
    color[u] = 'BLACK'
    
    for v in range(N):
        if color[v] != 'BLACK' and M[u][v]!=-1:
#             print(u,v,color[v],M[u][v],d[v])
            if M[u][v] < d[v]:
                d[v] = M[u][v]
                p[v] = u
                color[v] = 'GRAY'
#     print(color,mincost,d,p)
    
print(sum(d))


Measured memory_bytes: 5888
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	
    int H; cin >> H;
    int N; cin >> N;
    vpi data(N);
    F0R(i, N) {
        int A, B; cin >> A >> B; data[i] = {A, B};
    }
    int dp[H+1]; dp[0] = 0; FOR(i, 1, H+1) dp[i] = 1000000000;

    FOR(h, 1, H+1) {
        F0R(i, N) {
            dp[h] = min(dp[h], dp[max(h-data[i].f, 0)] + data[i].s);
        }
    }

    cout << dp[H] << endl;

	
	return 0;
}
 



Measured memory_bytes: 256
S = input()
N = len(S)
# print(S, S[::-1], S[:(N-1)//2], S[:(N-1)//2:-1],
#   S[(N+3)//2-1:], S[(N+3)//2-1::-1])
if S == S[::-1] and S[:(N-1)//2] == S[:(N-1)//2][::-1] and S[(N+3)//2-1:] == S[(N+3)//2-1:][::-1]:
    print('Yes')
else:
    print('No')


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    string s;
    cin>>s;
    int num=s.size();
    int ans=0;
    for (int i=0;i<num;i++){
        for (int j=i;j<num;j++){
            int b=1;
            for (int k=i;k<j+1;k++){
                char ss=s.at(k);
                if (!(ss=='A'||ss=='T'||ss=='G'||ss=='C')){
                    b=0;
                    break;
                }
            }
            if (b){
                ans=max(ans,j-i+1);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
    if B[i] >= A[i]:
        a += (B[i] - A[i] + 1) // 2
        b += (B[i] - A[i]) % 2
    else:
        b += A[i] - B[i]
print('Yes' if a >= b else 'No')


Measured memory_bytes: 4596
unittest
{
	assert( [ "3 100 100", "10 1000 100" ].parse.expand.solve == 900 );
	assert( [ "3 100 1000", "10 100 100" ].parse.expand.solve == 900 );
	assert( [ "5 1 1", "1 1 1 1 1" ].parse.expand.solve == 0 );
	assert( [ "1 1 1", "1000000000" ].parse.expand.solve == 999999999 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nzw = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nzw[ 2 ], as );
}

auto solve( long w, long[] as )
{
	// 先手が as[ 0 .. $ - 2 ] のどれかを取っても後手が as[ $ - 2 ] を取ると無駄になるので
	// 選択肢が as[ $ - 2 ] か  as[ $ - 1 ] しかない
	if( as.length == 1 ) return abs( abs( as[ $ - 1 ] - w ) );
	else                 return max( abs( as[ $ - 1 ] - w ), abs( as[ $ - 2 ] - as[ $ - 1 ] ) );
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<double> S(N);
  for(int i=0; i<N; i++){
   cin >> S.at(i); 
  }
  
  double Total=0;
  
  for(int i=0; i<N; i++){
    Total+=1/S.at(i);
  }
  
  cout << 1/Total << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long 
#define MAX_N 2000010
#define MOD 1000000007

int inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<MAX_N;i++){
        inv[i] = MOD - (long long)inv[MOD%i] * (MOD/i) % MOD;
        fac[i] = (long long)fac[i-1] * i % MOD;
        finv[i] = (long long)finv[i-1] * inv[i] % MOD;
    }
}

int comb(int a,int b)
{
    if(a==0&&b==0)return 1;
    if(a<=0)return 0;
    if(a < b){
        return 0;
    }
    return fac[a] * ((long long)finv[b] * finv[a-b] % MOD) % MOD;
}

signed main(){
    make();
    ll n;
    cin >> n;  
    vector<ll> a(n);
    rep(i,n){
        if(i>=n-1){
            a[i] = fac[n-1];
            continue;
        }
        a[i] = comb(n-2-i,i)*fac[i]%mod;
        a[i] *= fac[n-1-i]%mod;
        a[i] = (fac[n-1]-a[i]+mod)%mod;
    }
    for(int i=n-1;i>=1;i--){
        a[i] += mod-a[i-1];
        a[i] %= mod;
    }
    //rep(i,n)cerr << a[i] << endl;
    ll sm = 0;
    rep(i,n){
        sm += (n-i)*a[i]%mod;
        sm %= mod;
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 54912
#include <iostream>
using namespace std;
int cnt[2];

int main() {
  string s;

  cin >> s;

  for ( int i = 0; i < s.length(); i++ ) {
    cnt[s[i]-'0']++;
  }
  cout << min(cnt[0],cnt[1])*2 << endl;
  return 0;
}


Measured memory_bytes: 512
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {

	while (true)
	{
		string s;
		cin >> s;
		if (s == "-") break;
		int n;
		cin >> n;
		for (size_t i = 0; i < n; i++)
		{
			int v;
			cin >> v;
			string b = "";
			for (size_t j = v; j < s.size(); j++)
			{
				b += s[j];
			}
			for (size_t j = 0; j < v; j++)
			{
				b += s[j];
			}
			s = b;
		}
		cout << s << endl;
	}

}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
void chmax(T &a, T b) {
    if (b > a) a = b;
}

constexpr int W = (int)1e+5, K = 10;

int dp[1 << K][W + 1];

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

    int n;
    cin >> n;
    n++;

    vector<int> v(n), w(n);
    for (int i = 1; i < n; i++) {
        cin >> v[i] >> w[i];
    }

    int n1 = min(1 << K, n);
    for (int i = 1; i < n1; i++) {
        int i0 = i / 2;
        for (int j = 0; j < w[i]; j++) {
            dp[i][j] = dp[i0][j];
        }
        for (int j = w[i]; j <= W; j++) {
            dp[i][j] = max(dp[i0][j], dp[i0][j - w[i]] + v[i]);
        }
    }

    vector<ll> s(1 << K);
    s[0] = 0;

    int q;
    cin >> q;

    while (q--) {
        int i, j;
        cin >> i >> j;

        int r;

        if (i < 1 << K) {
            r = dp[i][j];

        } else {
            ll p[K];
            int h0;
            for (int h = 0;;) {
                p[h++] = (ll)v[i] << 32 | w[i];
                i /= 2;
                if (i < 1 << K) {
                    h0 = h;
                    break;
                }
            }

            r = dp[i][j];
            for (int h = 0; h < h0; h++) {
                int m = 1 << h;
                for (int l = m; l < m << 1; l++) {
                    s[l] = s[l & ~m] + p[h];
                    int v1 = s[l] >> 32, w1 = s[l];
                    if (w1 > j) continue;
                    chmax(r, dp[i][j - w1] + v1);
                }
            }
        }

        cout << r << '\n';
    }

    return 0;
}

Measured memory_bytes: 404868
S = input()

num = len(S)

bra = ""
ket = ""
if (num == 1):
    print(0)
elif (num < 4):
    if (S[0] != S[int(num / 2) + (num % 2)]):
        print(1)
    else:
        print(0)
else:
    if (num % 2 == 0):
        bra = S[0:int(num/2)]
        ket = S[num:int(num/2) - 1:-1]
    else:
        bra = S[0:int(num/2)]
        ket = S[num:int(num/2) - 2:-1]

    count = 0
    for i in range(int(num/2)):
        if (bra[i] != ket[i]):
            count += 1

    print(count)

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

H, W = map(int, input().split())
s = [input().rstrip() for _ in range(H)]

dp = [[1000]*W for _ in range(H)]

if s[0][0] == '#': dp[0][0] = 1
else: dp[0][0] = 0

for j in range(W):
    for i in range(H):
        if i <= H - 2:

            if s[i][j] == '.' and s[i+1][j] == '#':
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + 1)
            else: dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        if j <= W - 2:

            if s[i][j] == '.' and s[i][j+1] == '#':
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + 1)
            else: dp[i][j+1] = min(dp[i][j+1], dp[i][j])


print(dp[H-1][W-1])

Measured memory_bytes: 3188