akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

string s;

int solve() {
  int zero = count(s.begin(), s.end(), '0');
  int one = (int) s.size() - zero;
  return one + zero - abs(zero - one);
}

int main() {
  cin >> s;
  cout << solve() << endl;
}


Measured memory_bytes: 512
_,s=open(0)

sl=list(s)

n=len(sl)

i=int(0)

while i<n-1:
    if sl[i]==sl[i+1]:
        sl[i]="rep"
        i+=1
    else:
        i+=1



print(len([j for j in sl if j!="rep"])-1)



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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AGoodInteger {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string n;
	    in >> n;

	    if(n[0] == n[1] && n[1] == n[2]) ans(true, out);
	    else if(n[1] == n[2] && n[2] == n[3]) ans(true, out);
	    else ans(false, out);
	}
};


int main() {
	AGoodInteger solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll>a;
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll ans=0;
	for(ll i=0;i<n-2;i++){
		for(ll j=i+1;j<n-1;j++){
			for(ll k=j+1;k<n;k++){
				ll A=a[i];
				ll B=a[j];
				ll C=a[k];
				if(C<A+B){
					ans++;
				}
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for j in range(N):
            a, b = AB[j]
            if dp[i] + b < dp[i + a]:
                dp[i + a] = dp[i] + b
    print(min(dp[H:]))


main()


Measured memory_bytes: 41452
#include<queue>
#include<vector>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int inf=1000000;
const int maxn=20010;

struct edge{
	int to,cost,val;
	edge(){} 
	edge(int a,int b,int c){
		to=a;cost=b;val=c;
	}
};

vector<edge> G[maxn];
int dis[maxn],value[maxn];

void dij(int st){
	priority_queue<P,vector<P>,greater<P> > que;
	fill(dis,dis+maxn,inf);
	fill(value,value+maxn,inf);
	dis[st]=0;
	que.push(P(0,st));
	while(!que.empty()){
		P p=que.top();que.pop();
		int v=p.second;
		if(dis[v]<p.first) continue;
		for(unsigned int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(dis[e.to]>dis[v]+e.cost){
				 dis[e.to]=dis[v]+e.cost;
				 value[e.to]=e.val;
				 que.push(P(dis[e.to],e.to));
			}else if(dis[e.to]==dis[v]+e.cost) value[e.to]=min(value[e.to],e.val);
		}
	}
} 

int main(){
	ios::sync_with_stdio(false);
	int n,m,a,b,c,d;
	while(cin>>n>>m){
		if(n==0 && m==0) break;
		for(int i=0;i<maxn;i++) G[i].clear();
		for(int i=0;i<m;i++){
			cin>>a>>b>>c>>d; 
			G[a].push_back(edge(b,c,d));
			G[b].push_back(edge(a,c,d));
		}
		dij(1);
		int ans=0;
		for(int i=2;i<=n;i++) ans+=value[i];
		cout<<ans<<endl;
	} 
	return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl
#define absi(a) (((a) >= 0) ? (a) : (-(a))) 

ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	ll a[n];
	rep(i, n) cin >> a[i];

	ll ret = gcd(a[0], a[1]);
	repd(i, 2, n) ret = gcd(ret, a[i]);
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
import collections
d = collections.Counter()
MOD = int(1e9 + 7)

max_i = 0
for a in map(int, input().split()):
  inv_bin = bin(a)[2:][::-1]
  for i, b in enumerate(inv_bin):
    if (b == '1'):
      d[i] += 1
  max_i = max(i, max_i)

ans = 0
for k, v in d.items():
  ans += (N - v) * v * (2 ** k) 
  ans %= MOD
print(ans)


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

int main(){
  int i,count;
  char a[3];
  cin >> a[0]>> a[1]>> a[2];
  for(i=0;i<3;i++){
    if(a[i]=='1'){count++;}
  }
  cout << count;
}

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

n = int(input().rstrip('\n'))
s = input().rstrip('\n')
q = int(input().rstrip('\n'))
Q = []

for _ in range(q):
    Q.append(input().rstrip().split())

class SegTree():
    def __init__(self, n_):
        self.n = 1
        while self.n < n_:
            self.n *= 2
        self.tree = []
        for _ in range(2 * self.n - 1):
            self.tree.append(2)
    def update(self, k, a):
        k += self.n - 1
        self.tree[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.tree[k] = min(self.tree[k * 2 + 1], self.tree[k * 2 + 2])
    def query(self, l, r):
        l += self.n - 1
        r += self.n - 2
        res = 2
        while r-l>1:
            if l&1 == 0:
                res = min(res,self.tree[l])
            if r&1 == 1:
                res = min(res,self.tree[r])
                r -= 1
            l = l//2
            r = (r-1)//2
        if l == r:
            res = min(res,self.tree[l])
        else:
            res = min(min(res,self.tree[l]),self.tree[r])
        return res

d = { c: SegTree(n) for c in "abcdefghijklmnopqrstuvwxyz"}
l = []

for i, c in enumerate(s):
    d[c].update(i, 1)
    l.append(c)

for a, b, c in Q:
    if a == "1":
        b = int(b) - 1
        d[l[b]].update(b, 2)
        d[c].update(b, 1)
        l[b] = c
    else:
        res = 0
        b, c = int(b), int(c)
        for key in d:
            if d[key].query(b-1, c) == 1:
                res += 1
        print(res)


Measured memory_bytes: 397240
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  
  ll ans = x;
  for (int i = 0; i < 10; i++) {
    ans = r * ans - D;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
S=input()
keta=len(S)
N=int(S)
dp = [0,9,0,900,0,90000,0]
ans = 0
for i in range(keta+1):
  if i==keta and i%2:
    ans += N-10**(i-1)+1
  else:
    ans += dp[i]
    
print(ans)

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

typedef pair<int,int> P;
int N, M;

bool check(vector<vector<char> > &v) {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (v[i][j] != '.' && v[i][j] != 'x') return true;
        }
    }

    return false;
}

bool check2(vector<vector<char> > &v, int sx, int sy, int gx, int gy, char str) {
    set<char> res;
    for (int i = sx; i <= gx; i++) {
        for (int j = sy; j <= gy; j++) {
            if (v[i][j] == 'x' || v[i][j] == str);
            else return false;
        }
    }

    return true;
}

vector<int> found(vector<vector<char> > &v, char str) {
    int sx = 1 << 28, sy = 1 << 28, gx = -1, gy = -1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (v[i][j] == str) {
                sx = min(sx, i);
                gx = max(gx, i);
                sy = min(sy, j);
                gy = max(gy, j);
            }
        }
    }

    if (check2(v, sx, sy, gx, gy, str)) {
        return vector<int>{sx, sy, gx, gy};
    }

    return vector<int>{-1, -1, -1, -1};
}

void solve() {
    cin >> N >> M;
    vector<vector<char> > v(N, vector<char>(M));
    set<int> s;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> v[i][j];
            if (v[i][j] != '.') s.insert(v[i][j]);
        }
    }

    bool res = true;

    while (check(v)) {
        bool flag = false;
        auto tmp = s;
        for (auto str : tmp) {
            auto L = found(v, str);

            if (L[0] < 0) {
                continue;
            }
            s.erase(str);
            flag = true;
            for (int i = L[0]; i <= L[2]; i++)
                for (int j = L[1]; j <= L[3]; j++)
                    v[i][j] = 'x';
        }
        if (!flag) {
            res = false;
            break;
        }
    }

    cout << (res ? "SAFE" : "SUSPICIOUS") << endl;
}

int main() {
    int Q; cin >> Q;
    for (int q = 0; q < Q; q++) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int n,i,j,k=1000000007,x,y,m;
 cin>>n>>m;
 vector<int> v[n+1];
 for(i=0;i<m;i++)
 {
   cin>>x>>y;
   v[x].push_back(y);
   v[y].push_back(x);
 }
 vector<int> v1(n+1),v2(n+1);
 for(i=0;i<=n;i++)
  {v1[i]=v2[i]=100000000;}
 queue<int> q;
  if(v[1].empty())
   cout<<"No";
  else
  {
    for(i=0;i<v[1].size();i++)
    { q.push(v[1][i]);
      v2[v[1][i]]=1;
      v1[v[1][i]]=1;
    }
    while(!q.empty())
    {
      x=q.front();
      q.pop();
      for(i=0;i<v[x].size();i++)
      {
        y=v[x][i];
        if(y==1) continue;
        if(v1[y]==100000000)
          q.push(y);
        if(v2[y]>(v2[x]+1))
         {v1[y]=x;
           v2[y]=v2[x]+1;
         }
      }
    }
    bool hi=true;
    for(i=2;i<=n;i++)
    {
      if(v1[i]==100000000)
      {
        hi=false;
        break;
      }
    }
    if(hi)
    { cout<<"Yes\n";
      for(i=2;i<=n;i++)
       cout<<v1[i]<<"\n";
    }
    else
     cout<<"No";
  }
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, a, b; cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a + b - n, 0) << endl;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl

const long long MOD = 1000000007;


int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll> > > city(n+1);
    rep(i, m){
        ll p, y;
        cin >> p >> y;
        city[p].push_back(make_pair(y, i));
    }
    rep(i, n+1){
        sort(city[i].begin(), city[i].end());
    }
    vector<pair<ll, pair<ll, ll> > > id;
    rep(i, n+1){
        rep(j, city[i].size()){
            id.push_back(make_pair(city[i][j].second, make_pair(i, j)));
        }
    }
    sort(id.begin(), id.end());

    rep(i, id.size()){
        printf("%06lld%06lld\n", id[i].second.first, id[i].second.second+1);
    }

    return 0;
}


Measured memory_bytes: 9972
import sys

res=10**9+7
def permutation(n):
  x=1
  for i in range(n):x=(x*(i+1))%res
  return(x%res)
n,m=map(int,input().split())
n%=res
m%=res
if(n>m+1 or m>n+1):
  print(0)
elif(n==m):
  p=permutation(n)
  print((2*p*p)%res)
else:
  mi=min(n,m)
  p=permutation(mi)
  p2=p*max(n,m)
  print((p*p2)%res)


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

int main()
{
  int n, h;
  cin >> n >> h;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  int amax = 0;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i) >> b.at(i);
    if(a.at(i) > amax) amax = a.at(i);
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  int ans = 0;
  for(i = 0; i < n; i++)
  {
    if(b.at(i) <= amax) break;
    h -= b.at(i);
    ans++;
    if(h <= 0) break;
  }
  if(h <= 0) cout << ans << endl;
  else cout << ans+(h+amax-1)/amax << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long int;
const ll MOD = 998244353;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    for(int i = 0; i < k; i++) cin >> l[i] >> r[i];

    vector<int> isexist_s(n+5, 0);
    for(int i = 0; i < k; i++){
        isexist_s[l[i]]++;
        isexist_s[r[i]+1]--;
    }
    for(int i = 1; i < n+5; i++) isexist_s[i] += isexist_s[i-1];

    vector<int> move;
    for(int i = 1; i <= n; i++){
        if(isexist_s[i]) move.push_back(i);
    }

    vector<ll> memo(n+1, 0);
    vector<ll> submemo(k, 0);
    memo[1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 0; j < k; j++){
            if(i-r[j]-1 >= 1) submemo[j] -= memo[i-r[j]-1];
            if(i-l[j] >= 1) submemo[j] += memo[i-l[j]];

            memo[i] += submemo[j];
            memo[i] %= MOD;
        }
    }

    cout << memo[n] << endl;
    return 0;
}

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

int main(){
  double a,b,c,d,e,f,x,y;
  while(cin >> a >> b >> c >> d >> e >> f){
	double x = (c*e - b*f) / (a*e - b*d);
	double y = (c - a*x) / b;
	if(x == -0) x = 0;
	if(y == -0) y = 0;
	cout << fixed << setprecision(3) << x << " " << y << endl;
  } 
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/06  Problem: abc112 A / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

int main() {

	int N; cin >> N;
	if (N == 1) {
		cout << "Hello World" << "\n";
	}
	else {
		int A, B; cin >> A >> B;
		cout << A + B << "\n";
	}


	return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    cnt = 0
    for i in range(h):
        cnt += a[i].count("#")
    print("Possible" if cnt == (h + w - 1) else "Impossible")


if __name__ == '__main__':
    slove()


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

int main() {
    int N, flag = 1, a;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (!(a & 1)) {
            if (!(a % 3 == 0 || a % 5 == 0)) {
                flag = 0;
                break;
            }
        }
    }
    if (flag) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    return 0;
}

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

int main(){
  map<char,string> e;
  e[' ']="101";
  e['\'']="000000";
  e[',']="000011";
  e['-']="10010001";
  e['.']="010001";
  e['?']="000001";
  e['A']="100101";e['B']="10011010";e['C']="0101";
  e['D']="0001";e['E']="110";e['F']="01001";
  e['G']="10011011";e['H']="010000";e['I']="0111";
  e['J']="10011000";e['K']="0110";e['L']="00100";
  e['M']="10011001";e['N']="10011110";e['O']="00101";
  e['P']="111";e['Q']="10011111";e['R']="1000";
  e['S']="00110";e['T']="00111";e['U']="10011100";
  e['V']="10011101";e['W']="000010";e['X']="10010010";
  e['Y']="10010011";e['Z']="10010000";
  string s,t,a;
  char d[32];
  for(int i=0;i<26;++i) d[i]=i+'A';
  d[26]=' ';d[27]='.';d[28]=',';d[29]='-';d[30]='\'';d[31]='?';
  while(getline(cin,s)){
    t="";a="";
    for(string::iterator it=s.begin();it!=s.end();++it) t+=e[*it];
    if(t.size()%5){
      for(int i=t.size()-t.size()/5*5;i<5;++i) t+='0';
    }
    for(int i=0;i<t.size()/5*5;i+=5) a+=d[strtol(t.substr(i,5).c_str(),NULL,2)];
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<cstdio>
using namespace std;
#define maxn 300005
int w[maxn],e[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		char c;
		cin>>c;
		w[i]=w[i-1],e[i]=e[i-1];
		if(c=='W')  
			w[i]++;
		else  
			e[i]++;
	}
	int minv=maxn;
	for(int i=1;i<=n;i++){
		int sum=0;
		sum=(i-1)-e[i-1]+(n-i)-(w[n]-w[i]);
		minv=min(sum,minv);
	}
	cout<<minv<<endl;
	return 0;
} 

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

int main() {

  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 4010;
const int MOD = 998244353;
const int INF = 1000000010;

ll F[MAXN][MAXN], C[MAXN][MAXN];

ll G(int a, int b)
{
	if (a == 0)
		return b == 0;
	else
		return C[(a)+(b)-1][(a)-1];
}

int main()
{
	
	F[0][0] = 1;
	for (int i = 1; i <= 2000; ++ i)
	{
		ll sum = 0;
		for (int j = 0; j <= 4000; ++ j)
		{
			sum = (sum+F[i-1][j])%MOD;
			F[i][j] = (sum*2+MOD-F[i-1][j])%MOD;
		}
	}
	
	C[0][0] = 1;
	for (int i = 1; i <= 4000; ++ i)
	{
		C[i][0] = 1;
		for (int j = 1; j <= 4000; ++ j)
			C[i][j] = (C[i-1][j-1]+C[i-1][j])%MOD;
	}
	
	
	int n, k;
	cin >> k >> n;
	for (int i = 2; i <= 2*k; ++ i)
	{
		int cnt = 0;
		for (int x = 1; x <= k; ++ x)
			if (1 <= i-x && i-x <= k) ++ cnt;
		if (i%2 == 0)
		{
			ll ans = 0;
			
			for (int j = 0; j <= n; ++ j)
				(ans += F[(cnt-1)/2][j]*G(k-cnt, n-j)) %= MOD;
			for (int j = 0; j <= n-1; ++ j)
				(ans += F[(cnt-1)/2][j]*G(k-cnt, n-j-1)) %= MOD;
			
			cout << ans << endl;
		}
		else
		{
			ll ans = 0;
			for (int j = 0; j <= n; ++ j)
				(ans += F[cnt/2][j]*G(k-cnt, n-j)) %= MOD;
			cout << ans << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 188672
N, W = (int(x) for x in input().split())
dp = [[-1 for i in range(301)] for j in range(N+1)]
dp[0][0] = 0
for k in range(N):
    w, v = (int(x) for x in input().split())
    if k == 0:
        base_w = w
    for i in range(N)[::-1]:    
        for j in range(301)[::-1]:
            if dp[i][j]!=-1:
                dp[i+1][j+w-base_w] = max([dp[i][j]+v, dp[i+1][j+w-base_w]])
        
ans=0
for index,item in enumerate(dp):
    if W-index*base_w+1<=0:
        break
    ans=max(max(item[:W-index*base_w+1]),ans)

print(ans)

Measured memory_bytes: 74252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int get() { int r; cin >> r; return r; }
int n, m, key, p;
int t[60][60], nm[30][60];
vector<int>v[60];
bool b[60];
bool f(int nd) {
	if (nd == key)return 1;
	b[nd] = 1;
	for (int i : v[nd]) {
		if (!b[i]) {
			if (f(i)) {
				nm[p][t[nd][i]] = 1;
				return 1;
			}
		}
	}
	b[nd] = 0;
	return 0;
}

signed main() {
	if (get() == get())cout << "Yes\n"; else cout << "No\n";
}

Measured memory_bytes: 256
S =  int(input())
   
hh = 0
mm = 0
ss = 0
   
while S >= 3600:
     S -= 3600
     hh += 1
       
while S >= 60:
     S -= 60
     mm += 1
        
       
ss = S
print(hh,mm,ss, sep=':') 


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  string S;
  
  if (N%2 == 1){
    cout << "No" << endl;
  }
  
  else{
    cin >> S;
    string ans="Yes";
    
    for(int i=0; i<N/2; i++){
      if(S.at(i) != S.at(i + N/2)){
        ans = "No";
        break;
      }
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 764
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
void solve()
{
	char s;
	cin>>s;
	if(s>='a'&&s<='z')
		cout<<"a"<<endl;
	else
		cout<<"A"<<endl;
}
int main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	int n, W;
	cin >> n >> W;
	int *v = new int[n];
	int *w = new int[n];
	int **dp = new int*[n+1];
	for(int i = 0; i < n; i++){
			dp[i] = new int[W+1];
			for(int j = 0; j < W+1; j++)dp[i][j] = 0;
			cin >> v[i] >> w[i];
	}
	dp[n] = new int[W+1];
	for(int i = 0; i < W+1; i++)dp[n][i] = 0;
	for(int i = 0; i < n; i++){
			for(int j = 0; j < W+1; j++){
					if(j < w[i]){
							dp[i+1][j] = dp[i][j];
					}else{
							dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
					}
			}
	}
	cout << dp[n][W] << endl;
	return 0;
}



Measured memory_bytes: 7040
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7




int main(){

    int n,c,k;
    cin >> n >> c >> k;
    vector<int> arr(n);
    REP(i,n){
        cin >> arr[i];
    }
    VSORT(arr);/*到着時間順にソート*/

    int count = 0;/*バスの台数*/

    for(int i = 0;i < n;){
        int tmp = arr[i];/*今考えているバスに最初に乗る乗客*/
        int j = i+1;
        bool flag = true;/*c人載せられるならtrue、それ以外はfalse*/
        if(i == n-1){
            /*最後の1人を乗せるバス*/
            count++;
            break;
        }

        for(j = i+1;j < i+c;j++){
            /*iからc人まで調べる*/
            if(arr[j] - tmp > k){
                /*K分いないの制約を満たさない乗客は別のバスに乗ることになる*/
                i = j;
                count++;
                flag = false;
                break;
            }
        }
        if(flag){
            /*c人乗る場合*/
            count++;
            i = j;
        }
    }
    cout << count << endl;


    return 0;
}

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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int A,B,C;
  cin>>A>>B>>C;
  if ((A==7&&B==5&&C==5)||(A==5&&B==7&&C==5)||(A==5&&B==5&&C==7)) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
XY = [list(map(int, input().split())) for _ in range(n)]
sum_dist = 0
for i in range(n-1):
    for j in range(i+1, n):
        sum_dist += math.sqrt(
            (XY[i][0] - XY[j][0]) ** 2 + (XY[i][1] - XY[j][1]) ** 2)
print(sum_dist * (n-1) / (n * (n-1) / 2))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	long long int sum = 0;
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	long long int kari = a[0];
	long long int ans = abs(kari-(sum - kari));
	for (long long int i = 1; i < n - 1; i++) {
		kari += a[i];
		ans = min(ans, abs(kari - (sum - kari)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    N, M = [int(x) for x in input().split()]
    A = []
    b = []

    for i in range(N):
        A.append([int(x) for x in input().split()])

    for i in range(M):
        b.append(int(input()))
    
    ans = mymath.mul(A,b)

    for i in ans:
        print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6068
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  set<int> st;
  rep(i, n)
  {
    int a;
    cin >> a;
    st.insert(a);
  }
  YES(st.size() == n);
  return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int main(){
  int i,j,minj,n,a[100],count=0,x;

  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i < n-1;i++){
    minj=i;
    for(j=i;j <= n-1;j++){
      if(a[j] < a[minj]){
	minj=j;
      }
    }
    if(minj != i){
      x=a[i];
      a[i]=a[minj];
      a[minj]=x;
      count++;
    }
  }
  for(i=0;i < n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",count);
  return 0;
}



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

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

int N;
ll x[105],y[105],h[105];
bool used[105][105];
ll stdx,stdy,stdh;

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

	cin >> N;

	for (int i = 0;i < N;i++){
		cin >> x[i] >> y[i] >> h[i];
		if(i == 0 ||(h[i] != 0 && stdh == 0)){
			stdx = x[i];
			stdy = y[i];
			stdh = h[i];
		}
		used[x[i]][y[i]] = true;
	}

	if(stdh == 0){
		for (int i = 0;i <= 100;i++){
			for (int j = 0;j <= 100;j++){
				if(used[i][j] == false){
					cout << i << " " << j << " " << 1 << endl;
					return 0;
				}
			}
		}
	}

	for (ll i = 0;i <= 100;i++){
		for (ll j = 0;j <= 100;j++){
			ll h_top = abs(i-stdx)+abs(j-stdy)+stdh;
			bool flag = true;
			for (ll k = 0;k < N;k++){
				ll d = abs(i-x[k])+abs(j-y[k]);
				if(max(h_top-d,ll(0)) != h[k]) flag = false;
			}
			if(flag)cout << i << " " << j << " " << h_top << endl;
		}
	}

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i, n)         for(int i=0; i<n; i++)
#define fo(i, k, n)     for(int i=k; i<n; i++)
#define forr(i, a, b)   for(int i=a; i<=b; i++)
#define rf(i,n)         for(int i=n;i>=0;i--)
typedef unsigned long long ull;
typedef pair<int ,int> pr;
#define MAX 100005
#define INF 1000000009
#define   sq(n)         (n*n)
#define p(n) cout<<n<<endl
#define pb push_back
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;
ll mod =1e9+7;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll lcm ( ll a, ll b )
{
    return ( a / __gcd ( a, b ) ) * b;
}


ll modpow(ll a,ll n, ll mod)
{
    ll res = 1;
    while(n>0)
    {
        if (n%2==1)
        {
            res = res * a % mod;
        }
        a = a * a % mod;
        n/=2;
    }
    return res;
}

int bin_ser(int *a,int n,int x)
{
    int l=0;
    int h=n-1;
    while(l<=h)
    {
        int mid=l+((h-l)/2);
        if(a[mid]==x)
        {
          return mid;
        }
        else if(a[mid]<x)
        {
            l=mid+1;
        }
        else
        {
            h=mid-1;
        }
    }
}

int main()
{
    __FastIO;

     string s;
     cin>>s;
     int l=s.length();
     if(s[l-1]=='s')
     {
         s+='e';
         s+='s';
     }
     else
     {
         s+='s';
     }
     cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 3648
n = input()
if n == 'SUN':
  print(7)
elif n == 'MON':
  print(6)
elif n == 'TUE':
  print(5)
elif n == 'WED':
  print(4)
elif n == 'THU':
  print(3)
elif n == 'FRI':
  print(2)
elif n == 'SAT':
  print(1)

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

int dp(vector<vector<int>>& points, vector<vector<int>>& memo, int idx, int prev) {
    if(idx >= points.size())
        return 0;

    if(prev == -1 || memo[idx][prev] == -1)
    {
        int ans = -1;
        for(int i=0; i<3; ++i)
        {
            if(i != prev)
                ans = max(ans, dp(points, memo, idx+1, i)+points[idx][i]);
        }
        if(prev == -1) return ans;
        memo[idx][prev] = ans;
    }

    return memo[idx][prev];
}


int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> points(n, vector<int>(3, 0));
    for(int i=0; i<n; ++i)
        cin >> points[i][0] >> points[i][1] >> points[i][2];

    vector<vector<int>> memo(n, vector<int>(3, -1));
    cout << dp(points, memo, 0, -1);

    return 0;
}

Measured memory_bytes: 22000
N , M = map( int , input().split())
k_s = []
for  _ in range(M):
    ks = list(map(int, input().split()))
    k_s.append(ks)
P = list(map(int, input().split()))

count = 0
for switch in range(2**N):
    on_off = []
    for i in range(N):
        on_off.append(switch//2**(N-i-1))
        switch %= 2**(N-i-1)
    all_light = 1
    for i in range(M):
        light = 1
        s = k_s[i]
        p_count = 0
        for j in range(s[0]):
            p_count = (p_count+on_off[s[j+1]-1])%2
        if p_count != P[i]:
            all_light *= 0
    if all_light == 1:
        count += 1
print(count)

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second


int r,g,b;

int main(){

	cin >> r >> g >> b;
	if((r*100+g*10+b) %4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


}

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

const int INF= 1e9;

struct edge{
  int from, to, cost;
  edge(int x,int y, int z):from(x),to(y),cost(z){}
  bool operator<(const edge &x)const{ return cost<x.cost; }
};

typedef pair<int,int> pii;

class Prim{
  int n;
  vector< vector<edge> > g;
public:
  Prim(int a=0):n(a){ g.resize(n); }

  void AddEdge(int a, int b, int cost){
    g[a].push_back(edge(a,b,cost));
    g[b].push_back(edge(b,a,cost));
  }

  int MinSpanningTree(){
    int res = 0;
    vector<int> d(n,INF); d[0] = 0;
    priority_queue<pii, vector<pii>, greater<pii> > q;
    q.push(pii(0,0));

    while(q.size()){
      int cost = q.top().first, v = q.top().second; q.pop();
      if(d[v] < cost)continue;
      res += cost; d[v] = -INF;

      for(int i=0;i<(int)g[v].size();i++){
	int to = g[v][i].to, nxtcost = g[v][i].cost;
	if(d[to] > nxtcost){
	  d[to] = nxtcost;
	  q.push( pii(nxtcost,to) );
	}
      }
    }
    return res;
  }
};

int main(){
  int n,m;
  while(scanf("%d",&n),n){
    Prim p(n);
    cin >> m;
    for(int i=0;i<m;i++){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c);
      p.AddEdge(a,b,c/100-1);
    }
    cout << p.MinSpanningTree() << endl;
  }
}

Measured memory_bytes: 1408
from collections import defaultdict as ddic, deque, Counter
from itertools import permutations, combinations, product
import bisect, heapq

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

def solve(r, D, x):
    ans = []
    for i in xrange(10):
        x = r * x - D
        ans.append(x)
    return ans
ans = solve(*rrm()) 
print "\n".join(map(str, ans))


Measured memory_bytes: 28268
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    long long n;
    scanf("%lld",&n);
    long long ans=0;
    for(long long i=1;i<=n;i++)
        if(i%3&&i%5)
            ans+=i;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1732
n = int(input())
t_c,x_c,y_c = 0,0,0

for i in range(n):
    t,x,y = map(int,input().split())
    dt, dx, dy = t-t_c, abs(x-x_c), abs(y-y_c)
    dd = dx + dy
    if dd > dt or dd % 2 != dt % 2:
        print('No')
        exit()
    else:
        t_c,x_c,y_c = t,x,y

print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 555555;
int n;
Pii s[N];ll res;
bool cmp(Pii a,Pii b){return a.fi+a.se>b.fi+b.se;}
int main() {
	read(n);rep(i,1,n){int x,y;read(x);read(y);s[i]=Pii(x,y);}
	sort(s+1,s+n+1,cmp);
	rep(i,1,n)res+=i&1?s[i].fi:-s[i].se;cout<<res;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
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;}
ll INF = 1e+18;
int iINF = 1e9;

int main()
{
  int N, M; cin >> N >> M;
  dvec G(N);
  rep(i, 0, M){
    int a, b; cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<bool> seen(N, false);
  vector<int> dist(N, -1);
  queue<int> q;
  q.push(0);
  dist[0] = 0;

  while(!q.empty()){
    int node = q.front();
    q.pop();
    for(int next: G[node]){
      if(seen[next]) continue;
      if(dist[next] == -1) dist[next] = node;
      seen[next] = true;
      q.push(next);
    }
  }

  cout << "Yes" << endl;
  rep(i, 1, N) cout << dist[i] + 1 << endl;


}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  string s, t;
  cin >> s >> t;
  vector<string> v(26), w(26);
  rep(i, 0, 26) {
    char c = static_cast<char>('a' + i);
    rep(j, 0, s.size()) {
      if (s[j] == c) {
        v[i] += "1";
      } else
        v[i] += "0";
      if (t[j] == c) {
        w[i] += "1";
      } else
        w[i] += "0";
    }
  }
  sort(all(v));
  sort(all(w));

  Yes(v==w);
  return 0;
}


Measured memory_bytes: 11156
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():

    n = ii()
    a = li()

    ans = list(sorted(range(n),key=lambda x: a[x]))
    ans = list(map(lambda x: x+1,ans))
    print(*ans)






main()


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p,ki=0,gu=0;
    cin>>n>>p;
    ll ans;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            gu++;
        }
        else{
            ki++;
        }
    }
    if(p==1&&ki==0){
        cout<<0<<endl;
    }
    else if(ki==0){
        ans=pow(2,n);
        cout <<ans<<endl;
    }
    else{
         ans=pow(2,n-1);
         cout <<ans<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int op[2] = { -1, 1 };

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b, c, d;
	string s;
	cin >> s;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				if (a + op[i] * b + op[j] * c + op[k] * d == 7) {
					char sign0 = op[i] == 1 ? '+' : '-';
					char sign1 = op[j] == 1 ? '+' : '-';
					char sign2 = op[k] == 1 ? '+' : '-';
					cout << s[0] << sign0
						<< s[1] << sign1
						<< s[2] << sign2 << s[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a = 0, b = 0, c = 0;
	int yakusu = 0;
	
	cin >> a >> b >> c;
	
	for( ; a <= b; a++){
		if((c % a) == 0)
			yakusu++;
	}
	
	cout << yakusu << endl;
	
	
	return 0;
}

Measured memory_bytes: 1160
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector< pair<int, int> > q;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        q.push_back(make_pair(b, a));
    }
    SORT(q);
    int ans = 0, j = 0;
    rep(i, n){
        if(q[j].first == i){
            ans++;
            while(q[j].second < i){
                j++;
                if(j == m){
                    break;
                }
            }
        }
        if(j == m){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400