akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long

int foo(vector<string> group,vector<string> member[110]){
  int count = 0, flag[110] = {};
  map<string, int> ms;
  for(int j = 0; j < member[0].size(); j++){
    string temp = member[0][j];

    //cout<<temp<<endl;
    //cout<<temp<<endl;

    if(ms[temp]) continue;
    else ms[temp] = 1;
    int i = 0;
    for(string temp2 : group){
      if(temp2 == temp){
	//member[0][j].pop();
	if(flag[i] == false){
	  count++;
	  flag[i] = true;
	}
	//cout<<"aaa "<<member[0][j]<<endl;
	for(string temp3 : member[i]){
	  member[0].push_back(temp3);
	}
	break;
      }
      i++;
    }
  }
  set<string> st;
  for(string temp : member[0]){//cout<<temp<<endl;
    st.insert(temp);
  }
  return st.size()-count;
}

signed main(){
  int n;
  while(true){
    string temp;
    vector<string> group;
    vector<string> member[110];
    cin>>n;

    if(!n) break;

    for(int i = 0; i < n; i++){
      cin>>temp;
      int j;
      string strt;
      
      for(j = 0; ; j++){
	if(temp[j] == ':')break;
	strt += temp[j];
      }
      j++;
      
       group.push_back(strt);
      strt.clear();

      for(;; j++){
	if(temp[j] == '.'){
	  member[i].push_back(strt);
	  strt.clear();
	  break;
	}else if(temp[j] == ','){
	  member[i].push_back(strt);
	  strt.clear();
	} else strt += temp[j];
      }
      
    }
    
    cout<<foo(group,member)<<endl;
  }

  return 0;
}



Measured memory_bytes: 3408
target=gets.chomp
number=target.to_i
keta = target.to_s.length.to_i
total=0
1.step(keta-1,2) do |num|
  total=total+(9*10**(num-1))
end
if keta%2 == 1
  total=total+(number-(10**(keta-1)))+1
end
puts total
  

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

long long mygcd(long long a,long long b){
    return b ? mygcd(b,a % b) : a;
}

long long mylcm(long long a, long long b){
    return a * b / mygcd(a,b);
}

int main(){
    int n,m;
    string s,t;
    cin >> n >> m >> s >> t;
    long long ans = mylcm(n,m);
    int x,y;
    x = n / mygcd(n,m);
    y = m / mygcd(n,m);
    
    for(int i = 0; i < mygcd(n,m); i++){
        if(s[i*x] != t[i*y]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    string s;
    cin>>s;

    int res = 0;
    for(int i = 0; i < (int)s.length(); i++){
        for(int j = i; j<(int)s.length();j++){
            int tmp = 0;
            for(int k = i; k <= j; k++){
                if(s[k]!='A' && s[k]!='C' && s[k]!='G' && s[k]!='T') break;
                else tmp++;
            }
            res = max(res, tmp);
        }
    }
    cout<<res;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
*a, = map(int, open(0).read().split())
ans = 0
m = 10
for i in a:
    if i % 10 != 0:
        m = min(m, i % 10)
        ans += i//10*10 + 10
    else:
        ans += i//10*10
print(ans-10+m)


Measured memory_bytes: 2940
//
// Created by Hideaki Imamura on 2020-03-22.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
const ll mod = 998244353;

inline ll take_mod(ll a) {
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b) {
    return take_mod(a + b);
}

inline ll sub(ll a, ll b) {
    return take_mod(a - b);
}

inline ll mul(ll a, ll b) {
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n) {
    ll res = 1LL;
    while (n > 0) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x) {
    return mod_pow(x, mod - 2);
}

int N, S;
vector<int> A;

int main() {
    cin >> N >> S;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    ll ans = 0;
    vector<vector<ll>> f(N + 1, vector<ll>(S + 1, 0));
    for (int i = 1; i <= N; ++i) {
        f[i][0] = add(f[i-1][0], 1);
        for (int j = 1; j <= min(A[i-1]-1, S); ++j) f[i][j] = f[i-1][j];
        //cout << A[i-1] << " " << S << endl;
        if (A[i-1] <= S) {
            f[i][A[i-1]] = add(1, add(f[i-1][0], f[i-1][A[i-1]]));
            for (int j = A[i-1] + 1; j <= S; ++j) f[i][j] = add(f[i-1][j], f[i-1][j - A[i-1]]);
        }
        ans = add(ans, f[i][S]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
string S;
map<pair<string,string>,int> mp1,mp2;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> S;
  string S1 = S.substr(0,N);
  string S2 = S.substr(N,N);
  REV(S2);
  REP(ms,PW(N)) {
    string s,t;
    REP(i,N) {
      if (ms & PW(i)) s += S1[i];
      else t += S1[i];
    }
    mp1[MP(s,t)]++;
  }
  REP(ms,PW(N)) {
    string s,t;
    REP(i,N) {
      if (ms & PW(i)) s += S2[i];
      else t += S2[i];
    }
    mp2[MP(s,t)]++;
  }
  int ans = 0;
  for (auto p : mp1) {
    ans += p.second*mp2[p.first];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 108288
N,M=map(int,input().split())
from collections import defaultdict
branch=defaultdict(set)
for m in range(M):
    a,b=map(int,input().split())
    branch[a]|={b,}
    branch[b]|={a,}
    
now=1
ans=0
def go(N,now,branch,visited,ans):
    if len(visited)==N:return ans+1
    for b in branch[now]:
        if b in visited:continue
        ans=go(N,b,branch,visited|{now,b},ans)
    return ans
print(go(N,1,branch,{1,},0))

Measured memory_bytes: 3316
import sys

nm=input().split(" ")
N=int(nm[0])
M=int(nm[1])
xi=input().split(" ")

if N>=M:
  print("0")
  sys.exit(0)

X=[]
for i in range(M):
  X+=[int(xi[i])]
X.sort()
dX=[]
for i in range(M-1):
  dX+=[X[i+1]-X[i]]
dX.sort()
#print(N)
#print(M)
#print(X)
#print(dX)

#dXから上位N-1個を取り除いたあとの総和が多分答え
ans=0
for i in range(M-N):
  ans+=dX[i]
print(ans)

Measured memory_bytes: 14724
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  int A, B, K, i = A + B;
  ci(A, B, K);
  wh(K > 0){
    i--;
    if(A % i == 0 && B % i == 0){
      K--;
    }
    if(K == 0){
      co(i);
      rt;
    }
  }
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int f(int x) {
	if (x <= 0) return -x;
	int ans = 0;
	if (x % 2) x++, ans++;
	ans += x / 2;
	return ans;
}

int main() {
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	int mi = INT_MAX;
	for (int x = -1000; x <= 1000; x++) {
		int sum = 0;
		rep(i, 3) sum += f(x - a[i]);
		mi = min(mi, sum);
	}
	cout << mi << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [0] * (M - 1)
for i in range(M - 1):
    l[i] = x[i + 1] - x[i]
l.sort()
if N == 1:
    print(x[-1] - x[0])
else:
    print(x[-1] - x[0] - sum(l[-N + 1:]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define inf 2000000000 // 1e17
using namespace std;

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

// 0-indexed
template <class T>
struct Dinic {
  struct edge {
    int to;
    T cap;
    int rev;
  };
  vector<vector<edge>> lst;
  vector<int> completed;
  vector<int> dist;
  Dinic(int n = 1) {
    // if 1-indexed
    //++n;
    lst.resize(n);
    completed.resize(n);
    dist.resize(n);
  }
  bool add(int start, int goal, T capacity) {
    lst[start].push_back(
        (edge){goal, capacity, (int)lst[goal].size()});
    lst[goal].push_back(
        (edge){start, 0, (int)lst[start].size() - 1});
    return 1;
  }
  // dist = time from start to now number
  void distbfs(int start) {
    fill(dist.begin(), dist.end(), -1);
    queue<int> bfsqu;
    dist[start] = 0;
    bfsqu.push(start);
    while(bfsqu.size() > 0) {
      int now = bfsqu.front();
      bfsqu.pop();
      for(int i = 0; i < lst[now].size(); ++i) {
        edge* nowe = &lst[now][i];
        if(nowe->cap > 0 && dist[nowe->to] < 0) {
          dist[nowe->to] = dist[now] + 1;
          bfsqu.push(nowe->to);
        }
      }
    }
  }
  T pathdfs(int now, int goal, T nf) {
    if(now == goal) return nf;
    for(int& i = completed[now]; i < lst[now].size(); ++i) {
      edge* e = &lst[now][i];
      if(e->cap > 0 && dist[now] < dist[e->to]) {
        T ans = pathdfs(e->to, goal, min(nf, e->cap));
        if(ans > 0) {
          e->cap -= ans;
          lst[e->to][e->rev].cap += ans;
          return ans;
        }
      }
    }
    return 0;
  }
  T solve(int start, int goal) {
    T ans = 0, nf = 0;
    while(1) {
      // bfs
      distbfs(start);
      // cannnot go to goal from start
      if(dist[goal] < 0) return ans;
      // reset
      fill(completed.begin(), completed.end(), 0);
      while((nf = pathdfs(start, goal, inf)) > 0) ans += nf;
    }
    return -1;
  }
};

int n, m;
vector<int> b, r;

int solve();

int main() {
  while(1) {
    cin >> m >> n;
    if(n + m == 0) break;
    b.resize(m);
    r.resize(n);
    for(int i = 0; i < m; ++i) cin >> b[i];
    for(int i = 0; i < n; ++i) cin >> r[i];
    cout << solve() << endl;
  }
  return 0;
}

int solve() {
  Dinic<int> din(n + m + 2);
  for(int i = 0; i < n; ++i) din.add(n + m, i, 1);
  for(int i = 0; i < m; ++i) din.add(i + n, n + m + 1, 1);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      if(GCD(b[j], r[i]) > 1) din.add(i, j + n, 1);
  return din.solve(n + m, n + m + 1);
}



Measured memory_bytes: 7380
#include <iostream>

using namespace std;

long long INF = 1ll << 60;
long long dp[100001] = {};
long long h[100001] = {};
int K;

long long rec(int index) {
    if(dp[index] < INF) return dp[index];
    else {
        long long min_dp = INF;
        for(int i = 1; i <= K && index - i >= 0; ++i) {
            min_dp = min(min_dp, rec(index-i) + abs(h[index] - h[index-i]));
        }

        return dp[index] = min_dp;
    }
}

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

    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < N; ++i) dp[i] = INF;
    cout << rec(N-1) << endl;
}


Measured memory_bytes: 8064
/**************************
  * Writer : Leo101
  * Problem : Luogu AT2370 Piling Up
  * Tags : Dp
**************************/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define File(s) freopen(#s".in", "r", stdin); freopen(#s".out", "w", stdout)
#define gi get_int()
const long long Max_N = 5001, Mod = 1e9 + 7;
int get_int()
{
	int x = 0, y = 1; char ch = getchar();
	while ((ch < '0' || ch > '9') && ch != '-')
		ch = getchar();
	if (ch == '-') y = -1,ch = getchar();
	while (ch <= '9' && ch >= '0') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * y;
}

long long Dp[Max_N][Max_N];

long long Get_ans(int n, int m)
{
	memset(Dp, 0, sizeof(Dp));
	for (int i = 0; i <= n; i++) Dp[0][i] = 1;
	for (int i = 1; i <= m; i++) 
		for (int j = 0; j <= n; j++) {
			if (j != 0)
				Dp[i][j] = (Dp[i][j] + Dp[i - 1][j] + Dp[i - 1][j - 1]) % Mod;
			if (j != n)
				Dp[i][j] = (Dp[i][j] + Dp[i - 1][j] + Dp[i - 1][j + 1]) % Mod;
		}
	long long Ans = 0;
	for (int i = 0; i <= n; i++) Ans = (Ans + Dp[m][i]) % Mod;
	return Ans;
}

int main()
{
	int n = gi, m = gi;

	printf("%lld", (Get_ans(n, m) -  Get_ans(n - 1, m) + Mod) % Mod);

	return 0;
}


Measured memory_bytes: 195712
# https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_c
H,W = map(int,input().split())
A = [input().strip() for _ in range(H)]
C = {chr(i):0 for i in range(97,123)}
for i in range(H):
    for j in range(W):
        C[A[i][j]] += 1
if H%2==0 and W%2==0:
    flag = 0
    for a in C:
        if C[a]%4!=0:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
elif (H%2==0 and W%2==1) or (H%2==1 and W%2==0):
    n = (H//2)*(W//2)
    for a in C:
        if C[a]>=4:
            n -= C[a]//4
            C[a] = C[a]%4
    if n>0:
        print("No")
    else:
        flag = 0
        for a in C:
            if C[a]%2==1:
                flag=1
                break
        if flag==0:
            print("Yes")
        else:
            print("No")
else:
    n = (H//2)*(W//2)
    for a in C:
        if C[a]>=4:
            n -= C[a]//4
            C[a] = C[a]%4
    if n>0:
        print("No")
    else:
        cnt = 0
        for a in C:
            cnt += C[a]%2
        if cnt==1:
            print("Yes")
        else:
            print("No")


# 1つの行において列数が偶数の場合、例えば左端にaを置いた場合は、
# その列がpalindromeになる関係上必然的に右端にもaを置くことになる。
# さらに、列方向に見た場合は、今置いた2つのaに対して、一番下の行で
# それぞれを置く必要がある。したがって、1つのaを置くと、芋づる式に
# 合計４つのaを置くことになる。
# 行・列のどちらかが奇数の場合は、その真ん中のところにおいては
# 2個でよかったり、3個でよかったり、1個で良かったりするので、場合分けする。

Measured memory_bytes: 65220
#if 0
2019.08.08

两个不互质的数的左右关系被第一次操作安排后就不会因第二次操作再改变了。
考虑将不互质的数连无向边，那么第一次操作实际上就是给所有边定向，且不能成环，
之后就是 DAG ，第二次操作就是求一个拓扑序。

考虑两次操作分别如何做到最优。
先考虑第二次操作，显然就是求最大拓扑序，每次在入度为 0 的点中选值最大的放前头即可。
在考虑第一次操作，要求定向后第二次操作的结果字典序最小。
不同联通快之间只受第二次操作支配，那么只考虑每个联通块如何安排。
首先选最小值作为 DAG 的唯一根，第二次操作中它一定在联通块中最先被选，删掉它，
第二次操作中一定会第二选与它相连的点，为了让第二个选的尽量小，把根连接的点中的边从小向大连，
以此类推，具体地，用 dfs 实现，每次当前节点向连接的点中从小到大贪心定向即可。
#endif
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef std::pair<int, int> Par;
inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 2020;
int du[maxn];
int a[maxn];
bool link[maxn][maxn];
bool vis[maxn];
std::vector<int> G[maxn];

void dfs(int u, int n) {
	vis[u] = true;
	for(int v = 1; v <= n; v ++)
		if(not vis[v] and link[u][v] and u != v) {
			link[u][v] = link[v][u] = false;
			// debug("%d -> %d\n", u, v);
			G[u].push_back(v);
			du[v] ++;
			dfs(v, n);
		}
}

int main() {
	int n = input();
	for(int i = 1; i <= n; i ++)
		a[i] = input();
	std::sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			if(std::__gcd(a[i], a[j]) > 1)
				link[i][j] = true;
	for(int i = 1; i <= n; i ++)
		if(not vis[i])
			dfs(i, n);
	std::priority_queue<Par> q;
	for(int i = 1; i <= n; i ++)
		q.push(Par(- du[i], i));
	while(not q.empty()) {
		int d = - q.top().first, u = q.top().second;
		q.pop();
		if(d != du[u]) continue;
		for(int v : G[u]) {
			du[v] --;
			q.push(Par(- du[v], v));
		}
		printf("%d ", a[u]);
	}
	puts("");
}

Measured memory_bytes: 4480
s=str(input())
if s.count("W")==0 and s.count("E")==0 and s.count("S")==0 and s.count("N")==0:
    print("Yes")
elif s.count("W")>0 and s.count("E")>0 and s.count("S")==0 and s.count("N")==0:
    print("Yes")
elif s.count("W")==0 and s.count("E")==0 and s.count("S")>0 and s.count("N")>0:
    print("Yes")
elif s.count("W")>0 and s.count("E")>0 and s.count("S")>0 and s.count("N")>0:
    print("Yes")
else:
    print("No")

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a == 1){
        if(b == 1) cout << "Draw" << endl;
        else  cout << "Alice" << endl;
    }
    else if(b == 1) cout << "Bob" << endl;
    else if(a>b) cout << "Alice" << endl;
    else if(a == b) cout << "Draw" << endl;
    else cout << "Bob" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input()) 
s = [input() for i in range(N)] 
def count_ac (s):
    n = 0
    for i in range (0, N):
        if s[i] == "AC":
            n = n + 1
        else:
            n = n
    return n
def count_wa (s):
    n = 0
    for i in range (0, N):
        if s[i] == "WA":
            n = n + 1
        else:
            n = n
    return n
def count_tle (s):
    n = 0
    for i in range (0, N):
        if s[i] == "TLE":
            n = n + 1
        else:
            n = n
    return n
def count_re (s):
    n = 0
    for i in range (0, N):
        if s[i] == "RE":
            n = n + 1
        else:
            n = n
    return n
C0 = count_ac (s)
C1 = count_wa (s)
C2 = count_tle (s)
C3 = count_re (s)
t = [0, 0, 0, 0]
t[0] = "AC x " + str(C0)
t[1] = "WA x " + str(C1)
t[2] = "TLE x " + str(C2)
t[3] = "RE x " + str(C3)
for i in t:
    print(i)

Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
int H, W; 
char C[410][410] = {}; 
int A[410][410] = {}; 
int a; 
void dfs(int x, int y, int a){
	if(A[x][y] > 0) return; 
	A[x][y] = a; 
	if(x < H && C[x][y] != C[x+1][y]) dfs(x+1, y, a); 
	if(x > 0 && C[x][y] != C[x-1][y]) dfs(x-1, y, a); 
	if(y < W && C[x][y] != C[x][y+1]) dfs(x, y+1, a); 
	if(y > 0 && C[x][y] != C[x][y-1]) dfs(x, y-1, a); 
}
int main(){
    cin >> H >> W; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> C[i][j]; 
		}
	}
	a = 1; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			dfs(i, j, a); 
			a++;
		}
	}
	long long int X[160010][2] = {}; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			X[A[i][j]][(i + j) % 2] ++;
		}
	}
	long long int ans = 0; 
	for(int i = 1; i <= H * W; i++){
		ans += X[i][0] * X[i][1];
	}
	cout << ans << endl; 
}

Measured memory_bytes: 16000
import java.io.*;

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

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str1 = br.readLine();
      String str2[] = str1.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      int c =a*b;
      int d = 2*(a+b);
     System.out.println( c + " " + d );

     }
}

Measured memory_bytes: 24132
#include <bits/stdc++.h>
using namespace std;
int main(void){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n,k;
	double ans=0;
	cin>>n>>k;
	double a[n+1];
	a[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]=(a[i]+1)/2;
		a[i]+=a[i-1];
		if(i>=k){
			ans=max(ans,a[i]-a[i-k]);
		}
	}
	cout<<fixed<<setprecision(12)<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, Q; cin >> N >> Q;
  vector<unordered_map<int,int>> vec(N, unordered_map<int,int>());
  rep(i, N-1) {
    int a, b; cin >> a >> b;
    vec[a-1][b-1]++;
    vec[b-1][a-1]++;
  }
  vector<int> X(N, 0);
  rep(i, Q) {
    int p, x; cin >> p >> x;
    X[p-1] += x;
  }
  
  queue<pair<int,int>> q;
  q.push(make_pair(0, 0));
  
  vector<int> ans(N);
  
  while(!q.empty()) {
    auto p = q.front();
    q.pop();
    
    ans[p.first] = p.second+X[p.first];
    
    for(auto r : vec[p.first]) {
      q.push(make_pair(r.first, p.second+X[p.first]));
      vec[r.first].erase(p.first);
    }
  }
  
  rep(i, N) cout << ans[i] << " ";
  cout << endl;

}


Measured memory_bytes: 40264
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int,int>> vii;
#define rep(i,n) for (int i=0;i<n;i++);

ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll ans = INT64_MAX;
    for (int i=1;i<=int(sqrt(n));i++){
        if (n%i==0 && i+n/i-2<ans){
            ans = i+n/i-2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
lr = np.array(lr)
l = list(lr[:, 0])
r = list(lr[:, 1])
d = min(r)-max(l)+1
if d>0:
	print(d)
else:
	print(0)

Measured memory_bytes: 31632
import math

a, b, c= [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for n in range(n)]
#light = [int(i) for i in input().split()]
#s = input()
#list = list(s)

#print(n, m)
#print(table)
#print(light)

kotae = 0

kotae = a + b + c - max(a, b, c)

print(kotae)

Measured memory_bytes: 3060
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)


Measured memory_bytes: 27240
n, s = [input() for i in range(2)]

l = [chr(i) for i in range(65,65+26)] + [chr(i) for i in range(65,65+26)]
#print(l)
#print(s)

t = ""
for i in s:
    #print(i)
    found = False
    j = 0
    while j<26 and found == False:
        if i == l[j]:
            t += l[j+int(n)]
            #print(t)
            found = True
        j += 1
print(t)

Measured memory_bytes: 41564
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define mod 2019
using namespace std;
int mini = mod;
int main(){
	int l,r;
	int aida;
	cin >> l >> r;
	if(r-l>=2018){
		rep(i,l,l+mod){
			int tmpi = i % mod;
			rep(j,i+1,l+mod){
				int tmpj = j % mod;
				if(mini > (tmpi*tmpj)%mod) mini = (tmpi*tmpj)%mod;
			}
		}
	}else{
		aida = r-l;
		rep(i,l,l+aida+1){
			int tmpi = i % mod;
			rep(j,i+1,l+aida+1){
				int tmpj = j % mod;
				if(mini > (tmpi*tmpj)%mod) mini = (tmpi*tmpj)%mod;
			}
		}
	}
	cout << mini << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll a, b;
int main(){
	cin >> a >> b;
	if(a <= b){
		puts("unsafe");
	} else {
		puts("safe");
	}
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define N 200010
using namespace std;
int n,m=0;
int a[N];
int f[N];
int main() {
	memset(f,0,sizeof(f));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=n;i>=1;i--) {
		int tot=0;
		for(int j=1;i*j<=n;j++)
			tot+=f[i*j];
		if(tot%2!=a[i])
			f[i]=1;
	}
	for(int i=1;i<=n;i++)
		m+=f[i];
	printf("%d\n",m);
	for(int i=1;i<=n;i++)
		if(f[i]) printf("%d ",i);
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  if(s[n-1]=='1'||s[0]=='0'){
    cout << -1 << endl;
    return 0;
  }
  int c=-1;
  for(int i=0;i<n/2;i++){
    if(s[i]+s[n-i-2]=='0'+'1'){
      cout << -1 << endl;
      return 0;
    }
  }
  queue<int> q;
  for(int i=1;i<=n/2;i++){
    if(s[i-1]=='1'){
      while(!q.empty()){
        cout << i SP q.front() << endl;
        q.pop();
      }
    }
    q.push(i);
  }
  while(!q.empty()){
    cout << n SP q.front() << endl;
    q.pop();
  }
  for(int i=n/2+1;i<n;i++){
    cout << n SP i << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
N = int(input())
x_list = list(map(int,input().split()))
Min_pow = 100*100*100
for i in range (1,101):
    pow_sum = 0
    for j in range(N):
        pow_sum += (x_list[j]-i)*(x_list[j]-i)
    if pow_sum < Min_pow:
        Min_pow = pow_sum

print(Min_pow)

Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-
x,y = map(int,raw_input().split(" "))
 
lista = [1,3,5,7,8,10,12]
listb = [4,6,9,11]
 
if(x in lista):
	if(y in lista):
		print "Yes"
	else:
		print "No"
 
elif(x in listb):
	if(y in listb):
		print "Yes"
	else:
		print "No"
 
 
else:
	print "No"


Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    int a;
    int ans[n];
    for(int i = 1;i<=n;i++){
        cin >> a;
        ans[a-1]=i;
    }
    for(int i = 0;i<n;i++) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    int a;
    cin >> a;
    vector<int> z(a);
    for (int i = 0; i < a; i++) {
        cin >> z.at(i);
    }
    int y = 0;
    for (int i = 0; i < a - 2; i++) {
        if ((z.at(i) < z.at(i + 1) && z.at(i + 1) < z.at(i + 2)) || (z.at(i) > z.at(i + 1) && z.at(i + 1) > z.at(i + 2)))y++;
    }
    cout << y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<utility>
#include<string.h>
#include<set>
#include<stdlib.h>
#include<string>
#include<utility>
#include<stack>
using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=9;i++){
		if(i*111>=n) {cout<<i*111; return 0;}
	}
	
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    P a[110], c[110];

    cin >> n;
    REP(i, n)
    cin >> a[i].second >> a[i].first;
    REP(i, n)
    cin >> c[i].first >> c[i].second;

    sort(a, a + n);
    sort(c, c + n);

    int res = 0;
    REP(j, n)
    {
        for (int i = n - 1; i >= 0; i--)
        {
            if (a[i].second < c[j].first && a[i].first < c[j].second)
            {
                res++;
                a[i] = {1000, 1000};
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

int main(void){

    char str[100001];

    scanf("%s",str);

    int num=1;
    int flag=0;
    while(str[num]!='\0'){
        if(str[num]!=str[num-1]) flag++;
        num++;
    }

    if(flag==0){
        printf("0\n");
        return 0;
    }

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

    return 0;
}


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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
//#define fastIO 
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); }
int arr[2];
int main() {
	fastIO();
	bool b = true;
	int n; in(n); while (n--) {
		int t; in(t); if (t & 1)b =!b ;
	}
	std::cout << (b?"YES":"NO");
}


Measured memory_bytes: 256
def fact_mod(n, mod):
    r = 1
    for i in range(n):
        r = r * (n - i) % mod
    return r


def FLT(n, mod):
    m = fact_mod(n, mod)
    return pow(m, mod - 2, mod)


X, Y = map(int, (input().split()))
x2y1 = (2 * X - Y) // 3
x1y2 = (-X + 2 * Y) // 3
p = 10 ** 9 + 7

if (X + Y) % 3 != 0 or x2y1 < 0 or x1y2 < 0:
    print(0)
    exit()

print(fact_mod(x2y1 + x1y2, p) * FLT(x2y1, p) * FLT(x1y2, p) % p)


Measured memory_bytes: 3064
#include <iostream>

int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    std::cin >> a >> b >> c;
    if(a < b && b< c){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

int res = 0;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    for(auto &ch : s){
        if(ch == '?') ch = 'D';
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;

#define ll long long
void read(__int128 &x)
{
    x = 0;
    char ch;
    int flag = 1;
    while ((ch = getchar()))
    {
        if (ch == '-') flag = -1;
        if (ch >= '0' && ch <= '9') break;
    }
    x = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9')
    {
        x = x * 10 + ch - '0';
    }
    x *= flag;
}

void out(__int128 x)
{
    if (x < 0)
    {
        x = -x;
        putchar('-');
    }
    if (x >= 10) out(x / 10);
    putchar(x % 10 + '0');
}

int vis[105];
int main()
{
    int n, k;
    cin >> n >> k;

    int ans = 0;
    for(int i = 1; i <= k; i++)
    {
        int d;
        scanf("%d", &d);
        for(int j = 1; j <= d; j++)
        {
            int x;
            scanf("%d", &x);
            if(vis[x] == 0)
            {
                ans++;
                vis[x] = 1;
            }
        }
    }
    printf("%d\n", n - ans );
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int N,T;

        cin >> N >> T;
        vector <int> c(N,0),t(N,0);
        rep(i,N){
                cin >> c[i] >> t[i];
        }
        int ans= 1000000;
        rep(i,N){
                if(t[i]<=T) {
                        ans =min(ans,c[i]);
                }
        }
        if(ans==1000000) {
                cout << "TLE" <<endl;
        }else{
                cout << ans << endl;
        }


        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> read_vec(int n){
    vector<int> ret(n);
    for (int i = 0; i < n; i++){
        cin >> ret[i];
    }
    return ret;
}

int main() {
    long long n, ans = 0, a = 0;
    cin >> n;
    vector<string> save(n);
    map<string, int> cnt;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        save[i] = s;
        sort(s.begin(), s.end());
        sort(save[i].begin(), save[i].end());
        cnt[s]++;
    }
    for (int i = 0; i < n; i++){
        ans += (cnt[save[i]] - 1);
    }
    cout << ans / 2 << endl;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> inp(n);

	for(int i=0;i<n;i++) {
		cin >> inp[i];
	}

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

	return 0;
}


Measured memory_bytes: 4048
from functools import lru_cache

H, W, K = map(int, input().split())
def f(k):
  return 1 if k <= 0 else f(k-1) + f(k-2)
@lru_cache(maxsize=H*W)
def a(i, j):
  if j < 1 or j > W or (i == 0 and j != 1):
    return 0
  if i == 0 and j == 1:
    return 1
  return (f(j-3) * f(W-j-1) * a(i-1, j-1) + f(j-2) * f(W - j - 1) * a(i - 1, j) + f(j - 2) * f(W - j - 2) * a(i - 1, j + 1)) % 1000000007
ans = a(H, K)
print(ans)

Measured memory_bytes: 4196
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	int N,t[100000]={},x[100000]={},y[100000]={};
	bool ans=true;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
		if(i!=0){
			if((abs(x[i]-x[i-1])+abs(y[i]-y[i-1])-(t[i]-t[i-1]))%2==1||(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))>(t[i]-t[i-1])){
				ans=false;
				break;
				}
			}
		else {
			if(abs(x[i]+y[i]-t[i])%2==1||(x[i]+y[i])>t[i]){
				ans=false;
				break;
				}
			}
	}
	cout<<((ans)?"Yes":"No");
	}

Measured memory_bytes: 1408
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int u = sc.nextInt();
    int v = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    for (int i = 1; i < N; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    sc.close();

    List<Integer>[] tree = new ArrayList[N + 1];
    for (int i = 1; i < tree.length; i++) tree[i] = new ArrayList<>();
    for (int i = 1; i < N; i++) {
      tree[A[i]].add(B[i]);
      tree[B[i]].add(A[i]);
    }

    IntFunction<int[]> dist = r -> {
      int[] ds = new int[N + 1];
      Deque<Integer> stack = new ArrayDeque<>();
      stack.push(r);
      while (0 < stack.size()) {
        int i = stack.pop();
        for (int t : tree[i])
          if (ds[t] == 0 && t != r) {
            ds[t] = ds[i] + 1;
            stack.push(t);
          }
      }
      return ds;
    };
    int[] dist_u = dist.apply(u);
    int[] dist_v = dist.apply(v);

    int d = 0;
    for (int i = 1; i < N + 1; i++)
      if (dist_u[i] < dist_v[i] && dist_v[d] < dist_v[i]) d = i;

    long ans = dist_v[d] - 1;
    System.out.println(ans);
  }
}

Measured memory_bytes: 80216
#include<stdio.h>
long long dp[2];
int main(int argc, char const *argv[]){
	int n,p,i,a;
	long long pp[2];
	scanf("%d %d",&n,&p);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(i==0){
			if(a%2==0) dp[0]=2;
			else{
				dp[0]=1;
				dp[1]=1;
			}
		}else{
			pp[0]=dp[0];
			pp[1]=dp[1];
			if(a%2==0){
				dp[0]+=dp[0];
				dp[1]+=dp[1];
			}else{
				dp[0]=pp[0]+pp[1];
				dp[1]=dp[0];
			}
		}
	}
	printf("%lld\n",dp[p]);
	return 0;
}

Measured memory_bytes: 128
while True:
  a, op, b = input().split()
  if op == "+":
    print(int(a) + int(b))
  elif op == "-":
    print(int(a) - int(b))
  elif op == "*":
    print(int(a) * int(b))
  elif op == "/":
    print(int(a) // int(b))
  elif op == "?":
    break



Measured memory_bytes: 5596
[n,k] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

"""
初期条件
dp[0] = 0
dp[1] = h[1] - h[0]
"""

dp = [10 ** 9 + 7] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
if n > 2:
    for i in range(2,n):
        for j in range(1,min(i - 0,k)+1):
            dp[i] =min(dp[i - j] + abs(h[i]-h[i - j]),dp[i])
    print(dp[n-1])
else:
    print(dp[1])


Measured memory_bytes: 52320
package main

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

func main() {
	n := readi()
	a := readi()
	b := readi()

	d := b - a
	if d%2 == 0 {
		fmt.Println(d / 2)
		return
	}
 
	aa := a - 1
	bb := n - b
	if aa > bb {
		fmt.Println(bb + 1 + (((n - a) - bb - 1) / 2))
		return
	}
	fmt.Println(aa + 1 + ((b - aa - 1) / 2))
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 640
#include <cstdio>
#include <list>
#include <algorithm>

using namespace std;

int  main(){
  int q,x;
  char com[20];
  list<int> v;
  scanf("%d",&q);
  for(int i = 0;i < q;i++){
    scanf("%s", com);
    if( com[0] == 'i'){
      scanf("%d",&x);
      v.push_front(x);
    }else if(com[6] == 'L'){
      v.pop_back();
    }else if(com[6] == 'F'){
      v.pop_front();
    }else if(com[0] == 'd'){
      scanf("%d",&x);
      for(list<int>::iterator it = v.begin();it != v.end();it++){
        if(*it == x){
          v.erase(it);
          break;
        }
      }
    }
  }
  int i = 0;
  for(list<int>::iterator it = v.begin();it != v.end();it++){
    if(i++) printf(" ");
    printf("%d",*it);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 34008
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<algorithm>

using namespace std;

void InsertGroup(string, map< string, set<string> >&);
void SearchGroup(string, map< string, set<string> >, set<string>&, set<string>&);

int main(){
  int i, n;
  string str, group1;
  map< string, set<string> > group;
  set<string> employee, member;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> str;
      InsertGroup(str, group);
      if(i == 0) group1 = group.begin()->first;
    }

    SearchGroup(group1, group, employee, member);
    cout << employee.size() << endl;
    employee.clear();
    member.clear();
    group.clear();
  }
  return 0;
}

void InsertGroup(string str, map< string, set<string> >& group){
  string str1, str2;
  string::iterator i, j;
  set<string> member;

  i = find(str.begin(), str.end(), ':');
  copy(str.begin(), i, back_inserter(str1));
  ++i;
  while(1){
    j = find(i, str.end(), ',');
    if(j == str.end()) break;
    copy(i, j, back_inserter(str2));
    member.insert(str2);
    i = j+1;
    str2.clear();
  }
  copy(i, str.end()-1, back_inserter(str2));
  member.insert(str2);

  group.insert(make_pair(str1, member));
}

void SearchGroup(string top, map< string, set<string> > group,
		 set<string>& employee, set<string>& member){
  map< string, set<string> >::iterator i;
  set<string>::iterator j;

  i = group.find(top);
  for(j=i->second.begin(); j!=i->second.end(); ++j){
    if(group.find(*j) == group.end()){
      if(employee.find(*j) == employee.end())
	employee.insert(*j);
    }else if(member.find(*j) == member.end()){
      member.insert(*j);
      SearchGroup(*j, group, employee, member);
    }
  }
}

Measured memory_bytes: 2804