akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0

# 0をoffとして2進数でパターンを表現

for i in range(2 ** N):
	x = bin(i)[2:].rjust(N, "0")
	light = True  # 着目している電球が点灯していないときはこれがFalseになる
	for j in range(M):
		tmp = 0  # 着目している電球について、スイッチのonの個数をカウントする
		for k in range(1, s[j][0] + 1):
			if x[s[j][k] - 1] == "1":
				tmp += 1
		if tmp % 2 != p[j] % 2:
			light = False
	if light:
		ans += 1
print(ans)


Measured memory_bytes: 3188
def chess(h,w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'

while True:
  H, W = map(int, input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    for j in range(W):
      print(chess(i,j), end='')
    print()
  print()



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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<ii> v;
    for(int i = 1; i <= n; i++) {
        int x; cin >> x;
        v.eb(x,i);
    }
    sort(v.begin(),v.end());
    for(auto ok : v) cout << ok.se << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
 
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
 
template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}
 
template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}
 
template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 1e6 + 5;

char c[N];
int n, ans;

int main() {
	read(n); scanf("%s", c + 1);
	for (int i = 1; i <= n; i++) if (((n - 1) & (i - 1)) == i - 1 && c[i] == '2') ans ^= 1;
	if (ans == 1) {
		print(1, '\n');
		return 0;
	}
	ans = 0;
	for (int i = 1; i <= n; i++) if (c[i] == '2') { ans = 1; break; }
	if (ans) {
		print(0, '\n');
		return 0;
	}
	for (int i = 1; i <= n; i++) if (((n - 1) & (i - 1)) == i - 1 && c[i] == '3') ans ^= 1;
	print(ans << 1, '\n');
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(int argc,char *args[]){
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if((y-r>=0 && y+r<=h) && (x-r>=0 && x+r<=w)){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 2108
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

bef = -2
ans = 0
for i in range(n):
    if bef == -2:
        ans += b[a[i]-1]
        bef = a[i]
    else:
        ans += b[a[i]-1]
        if (bef+1) == a[i]:
            ans += c[bef-1]
        bef = a[i]

print(ans)


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

int main(){

   int n,d;
   cin>>n>>d;

   int shou;
   shou=n/(2*d+1);
   int amari;
     amari=n%(2*d+1);
     //cout<<"SHOU"<<shou<<endl;
     //cout<<"AMARI"<<amari<<endl;

if(amari>=1){
    cout<<shou+1<<endl;
}else{
    cout<<shou<<endl;
}


return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int i,n,sum=1,j,flag;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=1;i<n;i++){
    flag=1;
    for(j=0;j<i;j++){
      if(a[i]<a[j]){
        flag=0;
        break;
      }
    }
    if(flag)
      sum++;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def dfs(N, nodes, src):
    """ DFS(木、スタック、重みなし) """

    stack = [(src, -1, 0)]
    dist = [INF] * N
    while stack:
        u, prev, c = stack.pop()
        dist[u] = c
        for v in nodes[u]:
            if v != prev:
                stack.append((v, u, c+1))
    return dist

N = INT()
nodes = [[] for i in range(N)]
for _ in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

# 木の直径
dist1 = dfs(N, nodes, 0)
u = dist1.index(max(dist1))
dist2 = dfs(N, nodes, u)
L = max(dist2)

if L % 3 != 1:
    print('First')
else:
    print('Second')


Measured memory_bytes: 60048
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int a[n];
    int bucket[200001];
    for (int i = 1; i < 200001; ++i) {
        bucket[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        bucket[a[i]]++;
    }
    sort(bucket + 1, bucket + 200001, greater<int>());
    int ans = 0;
    for (int i = 1; i < 200001; ++i) {
        if (i <= k) continue;
        if (bucket[i] == 0) break;
        ans += bucket[i];
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
	int m, d;
	cin>>m>>d;
	int ans = 0;
	for (int mi=1; mi<=m; mi++)
		for (int i=22; i<=d; i++) {
			int d10 = i/10;
			int d1 = i%10;
			if (d1>=2 && d10>=2 && d1*d10 == mi)
				ans++;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <typename T> struct monoid {
    const T identity;
    const function<T(T, T)> combine;
};
template <typename T> struct segtree {
    using Type = T;
    using DeltaType = T;
    const int size;
    vector<T> tree;
    const monoid<T> m;
    segtree(int size, const monoid<T>& m) : size(size), tree(2 * (size + 1), m.identity), m(m) {}
    void update(int i, T x) {
        for(tree[i += size] = x; i >>= 1; )
            tree[i] = m.combine(tree[i << 1], tree[(i << 1) | 1]);
    }
    T query(int a, int b, bool inclusive) {
        assert(a <= b);
        T ans_l = m.identity, ans_r = m.identity;
        for(a += size, b += size + inclusive; a < b; a >>= 1, b >>= 1) {
            if(a & 1) ans_l = m.combine(ans_l, tree[a++]);
            if(b & 1) ans_r = m.combine(tree[--b], ans_r);
        }
        return m.combine(ans_l, ans_r);
    }
    T query(int i) { return query(i, i, true); }
    friend ostream& operator<<(ostream& os, segtree& t) {
        os << "[";
        for(int i = 0; i <= t.size; i++) {
            if(i != 0) os << ", ";
            os << t.query(i);
        }
        return os << "]";
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int total = 0, need = 0, mid = 0;
    map<int, vector<int>> m;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int neg = 0, val = 0;
        for(char c : s) {
            if(c == '(') {
                val++;
            } else if(val == 0) {
                neg++;
            } else {
                val--;
            }
        }
        if(all_of(s.begin(), s.end(), [](char c) { return c == '('; })) {
            total += val;
        } else if(all_of(s.begin(), s.end(), [](char c) { return c == ')'; })) {
            need += neg;
        } else {
            m[neg].push_back(val);
            mid++;
        }
    }
    segtree<pair<int, int>> s(1'000'000, {{-1'000'001, -1}, [](const auto& x, const auto& y) { return max(x, y); }});
    for(auto& [k, v] : m) {
        sort(v.begin(), v.end());
        s.update(k, {v.back() - k, k});
    }
    bool can = true;
    for(int i = 0; i < mid and can; i++) {
        auto [v, k] = s.query(0, total, true);
        if(can &= (k != -1)) {
            total += v;
            m[k].pop_back();
            if(m[k].empty()) {
                s.update(k, {-1'000'001, -1});
            } else {
                s.update(k, {m[k].back() - k, k});
            }
        }
    }
    cout << (can and (total == need) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 20524
n,m=map(int,raw_input().split())

A = [[0 for j in range(m)] for i in range(n)]
b = [0 for j in range(m)]

for i in range(n):
    A[i]=map(int, raw_input().split())
for j in range(m):
    b[j]=input()
 
for i in range(n):
    c=0
    for j in range(m):
        c+=A[i][j]*b[j]
    print(c)

Measured memory_bytes: 6644
#include<stdio.h>
long unsigned int diff(long unsigned int a, long unsigned int b, long unsigned int c) {
    long unsigned int max=a,min=a;
    if(max < b) {
        max = b;
    }
    if(max < c) {
        max = c;
    }
    if(min > b) {
        min = b;
    }
    if(min > c) {
        min = c;
    }
    return max - min;
}

long unsigned int main(void) {
    long unsigned int h,w;
    long unsigned int i;
    long unsigned int a,b,c;
    scanf("%lu%lu",&h,&w);
    long unsigned int min = h*w;
    long unsigned int area = h*w;
    if (h%3==0 || w%3==0) {
        printf("0\n");
        return 0;
    }
    for (i=0; i<h/2; i++) {
        a = (h/2-i)*w;
        b = (w/2)*(h-(h/2-i));
        c = area - a - b;
        if(min > diff(a,b,c)) {
            min = diff(a,b,c);
        }
    }
    long unsigned int memo = h;
    h = w;
    w = memo;
    for (i=0; i<h/2; i++) {
        a = (h/2-i)*w;
        b = (w/2)*(h-(h/2-i));
        c = area - a - b;
        if(min > diff(a,b,c)) {
            min = diff(a,b,c);
        }
    }
    if(min > h) {
        min = h;
    }
    if(min > w) {
        min = w;
    }
    printf("%lu\n", min);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

bool from[1000000];
bool to[1000000];

void solve() {
  int n, m;
  cin >> n >> m;
  while(m--) {
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    if(a == 1) from[b] = true;
    if(b == n) to[a] = true;
  }
  string ans = "IMPOSSIBLE";
  for(int i = 2; i < n; i++) {
    if(from[i] && to[i]) ans = "POSSIBLE";
  }
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main(){

	ll N,mod=1000000007;
	cin >> N;

	ll dp[N+1][2][2] = {};
	dp[0][0][0] = 1;


	for(int i=1;i<=N;i++){
		dp[i][0][0] = dp[i-1][0][0] * 8 % mod;
		dp[i][1][0] = (dp[i-1][0][0] + dp[i-1][1][0] * 9 ) % mod;
		dp[i][0][1] = (dp[i-1][0][0] + dp[i-1][0][1] * 9 ) % mod;
		dp[i][1][1] = (dp[i-1][1][1] * 10 + dp[i-1][1][0] * 2) % mod;
	}

	cout << dp[N][1][1] << endl;
}




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

int main(){
    int n, k; int64_t ans = 0; cin >> n >> k;
    vector<int64_t> cnt(k, 0);
    for (auto i = 1; i <= n; i++) cnt[i % k]++;
    for (auto a = 0; a < k; a++) {
        int b = (k - a) % k;
        if((2 * b) % k != 0) continue;
        ans += cnt[a] * cnt[b] * cnt[b];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4800
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll x[n];
    for (ll i=0;i<n;i++)cin >> x[i];
    ll ans=0;
    for (ll i=1;i<n;i++){
        if ((x[i]-x[i-1])*a<b){
            ans+=(x[i]-x[i-1])*a;
        }else{
            ans+=b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ABC104B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string s = ConsoleInput.String();
            if (s[0] != 'A')
            {
                Console.WriteLine("WA");
                return;
            }

            int cPos = 0;
            for (int i = 2; i < s.Length - 1; i++)
            {
                if (s[i] == 'C')
                {
                    if (cPos != 0)
                    {
                        Console.WriteLine("WA");
                        return;
                    }
                    cPos = i;
                }
            }

            if (cPos == 0)
            {
                Console.WriteLine("WA");
                return;
            }

            string chars = "abcdefghijklmnopqrstuvwxyz";
            for (int i = 1; i < s.Length; i++)
            {
                if (i == cPos)
                {
                    continue;
                }

                if (!chars.Contains(s[i]))
                {
                    Console.WriteLine("WA");
                    return;
                }
            }
            Console.WriteLine("AC");
        }
    }

    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=2e5+7;
#define abs(x) ((x)<0?-(x):(x))

int a[N],n;

int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i),a[i]-=i;
	sort(a+1,a+n+1);
	int b=a[(n+1)/2];
	ll ans=0;
	rep(i,1,n) ans+=abs(a[i]-b);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int k,t,mx = 0;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; ++i) {
        cin >> a[i];
        mx = max(mx,a[i]);
    }
    cout << max(0,2*mx-k-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 753;
int main(){
	int time;
	int n,k;
	string s;
	cin>>s;
	int minn=1000000;
	for(int i=0;i<s.length()-2;i++){
		int ans=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
		minn=min(abs(ans-N),minn);
	}
	printf("%d\n",minn);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int ispalindrome(char a[],int begin,int end){
	int flag=1;
	while(begin<end){
		if(a[begin]!=a[end]){
			flag=0;
			break;
		};
		begin++;
		end--;
	}
	if(flag) return 1;
	else return 0;
}
int main()
{
	char a[100];
	gets(a);
	int n=strlen(a);
	if(ispalindrome(a,0,n-1)&&ispalindrome(a,0,(n-1)/2-1)&&ispalindrome(a,(n-1)/2+1,n-1)){
		printf("Yes");
	}	
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    int k,i;
    string s;
    cin>>k>>s;
    if(s.size()<=k)
      cout<<s<<endl;
    else{
      for(i=0;i<k;i++)
        cout<<s[i];
      cout<<"..."<<endl;
    }
  }


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int rez = 0, curr = 0, x, prev;
    for(int i = 0; i < N; i++) {
        cin >> x;
        if(i != 0 && prev >= x)
            curr++;
        else
            curr = 0;
        rez = max(rez, curr);
        prev = x;
    }
    cout << rez;
}

Measured memory_bytes: 256
N = int(raw_input())

prime_string = "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 "
prime_list = map(int,prime_string[:-1].split())

power_list = [0 for l in range(len(prime_list))]

for n in range(N):
    for i in range(len(prime_list)):
        for j in range(9):
            if (n+1)%(prime_list[i]**(j+1))==0:
                power_list[i]+=1
result = 1
for power in power_list:
    result=(result*(power+1))%(10**9+7)

print result

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
V<int> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ll ans = 0;
  FOR(i, 0, n){
    int a, b;
    cin >> a >> b;
    ans += a;
    v.pb(a+b);
  }
  sort(all(v));
  reverse(all(v));
  FOR(i, 0, n) if(i&1) ans -= v[i];
  cout << ans << endl;
}

Measured memory_bytes: 892
#include<stdio.h>
#include <string.h>

int main(){
	int a[3], b[2], lowp, lowj, i, m = 0;
	for(i = 0; i < 3; i++) scanf("%d", &a[i]);
	for(i = 0; i < 2; i++) scanf("%d", &b[i]);
	lowp = a[0];
	lowj = b[0];
	for(i = 1; i < 3; i++){
		if(a[i] < lowp) lowp = a[i];
	}
	if(b[1] < lowj) lowj = b[1];
	m = lowp + lowj - 50;
	printf("%d\n", m);
	return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,cnt=0,ans=0,wa=0;
    cin>>n;
    vector<int> x(n);

    rep(i,0,n){
        cin>>x[i];
        if(x[i] % 2 != 0) ++cnt;
        else if((x[i]/2) % 2 == 0) ++ans;
        else ++wa;
    }

    if(cnt <= ans) cout<<"Yes\n";
    else if(cnt-1 <= ans && wa == 0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(int loop_dump=0; loop_dump<(int)ar.size(); loop_dump++) cout << "[" << loop_dump << "]:" << ar[loop_dump] << endl
#define DUMPL(ar) for(int loop_dump=0; loop_dump<(int)ar.size(); loop_dump++) { cout << ar[loop_dump]; if(loop_dump<(int)ar.size()-1) cout << ' '; } cout << endl;
#define COUT(x) cout << x << endl
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl
using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];

    int cnt = 0;
    int target = 1;
    for(int i=0; i<n; i++){
        if(a[i] != target){
            cnt++;
        }else{
            target++;
        }
    }

    if(cnt == n){
        COUT(-1);
    }else{
        COUT(cnt);
    }

    return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN,'%d%d',$N,$M);
$A=[];
$B=[];
$C=[];
$D=[];
for ($i=0; $i <$N ; $i++) {
  // code...
  fscanf(STDIN,'%d%d',$X,$Y);
  $A[$i]=$X;
  $B[$i]=$Y;
}
for ($i=0; $i <$M ; $i++) {
  // code...
  fscanf(STDIN,'%d%d',$X,$Y);
  $C[$i]=$X;
  $D[$i]=$Y;
}
$kyori=0;
$ans=0;
$ans=0;
$minkyori=100000000000;
for ($i=0; $i <$N ; $i++) {
  // code...
  $ans=0;
  $minkyori=100000000000;
  for ($j=0; $j <$M ; $j++) {
    // code...
      $kyori=0;
      $kyori=abs($A[$i]-$C[$j])+abs($B[$i]-$D[$j]);
      if($kyori<$minkyori){
        $minkyori=$kyori;
        $ans=$j+1;

      }
  }
  echo $ans;
  echo "\n";
}
 ?>


Measured memory_bytes: 3576
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque, defaultdict
    n = int(readline())
    edge = defaultdict(list)

    for _ in range(n - 1):
        a, b = map(int, readline().split())
        edge[a].append(b)
        edge[b].append(a)

    c = list(map(int, readline().split()))
    c.sort(reverse=True)

    nums = [0] * (n + 1)

    que = deque()
    que.append((1, 0))

    cnt = 0
    m = 0

    while que:
        cur, prev_num = que.popleft()
        num = c[cnt]
        nums[cur] = num
        m += min(num, prev_num)
        cnt += 1
        for nx in edge[cur]:
            if nums[nx] == 0:
                que.append((nx, num))

    print(m)
    print(*nums[1:])


if __name__ == '__main__':
    main()


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

using namespace std;

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


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


int main()
{
  int X; cin >> X;
  if (X == 7 || X == 5 || X == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,j,k,l,i;
    cin>>n;
    long long dp[n+1][3]={0},a[n+1][3];
    for(i=1;i<=n;i++){
        for(j=0;j<3;j++){
            cin>>a[i][j];
            dp[i][j]=0;
        }
    }dp[1][0]=a[1][0];
    dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
    for(i=2;i<=n;i++){
        dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
         dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
          dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][0]+a[i][2]);
          
    }cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

string s;
int n;

int main() {
	cin >> s;
	n = s.size();
	if (s[n - 1] == '1' || s[0] == '0') {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0;i < n / 2;i++) {
		if (s[n - i - 2] != s[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	int now = 2, back = 1;
	cout << n << ' ' << 1 << endl;
	for (int i = 2;i < n;i++) {
		if (s[i - 1] == '1')cout << back << ' ' << now << endl, back = now;
		else cout << back << ' ' << now << endl;
		now++;
	}
	return 0;
}


Measured memory_bytes: 1664
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}

/* [入力]
  const [H,W]=o.nn(2)
  const [N,M]=o.nn(2)
  const N=o.n()
  const S=o.s()
  const arr1=[]
  for(let i=0;i<N;i++)arr1.push(o.n())
 */

/* [BFS,DFS]
  const [H,W]=o.nn(2),map=new Array(H),save=new Array(H)
  const DH=[0,0,-1,1]
  const DW=[1,-1,0,0]
  for(let i=0;i<H;i++){
    map[i]=o.s().split('')
    save[i]=new Array(W)
    save[i].fill(-1)
  }
  // let queue=[[?,?,1]]
  // save[?][?]=0
  while(queue.length>0){
    let [h,w,c]=queue.shift()
    for(let i=0;i<4;i++){
      if(h+DH[i]<0 || h+DH[i]>=H || w+DW[i]<0 || w+DW[i]>=W){
        continue
      }
      if(map[h+DH[i]][w+DW[i]]==?){
        continue
      }
      if(save[h+DH[i]][w+DW[i]]==-1){
        queue.push([h+DH[i], w+DW[i], c+1])
        save[h+DH[i]][w+DW[i]]=c
      }
    }
  }
*/
const o = new AtCoder()

let [h,w,x]=o.nn(3)
o.o(o.ceil(x/o.max(h,w)))

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

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

while( N>=0 ) :
  if N % 10 == 0:
    N = int(N / 10)
    if N == 1:
      print(10)
      break
    continue
  else:
    print(digitSum(N))
    break
  

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  int result = (m1 != m2) ? 1 : 0;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    string n;
    cin>>n;
    ll sum = 0;
    rep(i,n.size()){
        sum += n[i] - '0';
    }
    if(sum % 9 == 0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



Measured memory_bytes: 3736
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

int n, d = 0;
int o[1000][1000];
int cp[1000];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    memset(o, -1, sizeof(o));
    F0R(i, n) 
    {
        F0R(j, n - 1) 
        {
            cin >> o[i][j];
            o[i][j]--;
        }
    }
    // for(auto i : o) 
    // {
    //     for(auto j : i) cout << j << " ";
    //     cout << "\n";
    // }
    bool c = true;
    map<ll, int> m;
    stack<int> tc;
    F0R(i, n) tc.push(i);
    int tot = 0;
    while(c)
    {
        c = false;
        tot += sz(tc);
        vector<pair<int, int>> e;
        while(!tc.empty())
        {
            int j = tc.top();
            tc.pop();
            if(cp[j] < n - 1)
            {
                int a = o[j][cp[j]], b = j;
                if(a > b) swap(a, b);
                m[1005 * (a + 1) + (b + 1)]++;
                if(m[1005 * (a + 1) + (b + 1)] == 2) 
                {
                    // cout << a << " " << b << "\n";
                    c = true;
                    e.pb({a, b});
                }
            }
        }
        for(auto i : e) 
        {
            cp[i.f]++;
            cp[i.s]++;
            tc.push(i.f);
            tc.push(i.s);
            m.erase((i.f + 1) * 1005 + (i.s + 1));
        }
        // cout << "\n";
        d++;
        if(!c) break;
    }
    bool pos = true;
    F0R(i, n) if(cp[i] != n - 1) pos = false;
    cout << (pos ? d - 1 : -1);
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

long long gcd(long long a, long long b)
{
	long long tmp, r;
	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;
	
	ll n;
	cin >> n;

	string s;
	cin >> s;
	vector<vector<ll>> m(n, vector<ll>(3, 0));

	ll ans = 0;

	if (s[0] == 'R')
		m[0][0]++;
	if (s[0] == 'G')
		m[0][1]++;
	if (s[0] == 'B')
		m[0][2]++;

	for (ll i = 1; i < n; i++)
	{
		if (s[i] == 'R')
			m[i][0]++;
		if (s[i] == 'G')
			m[i][1]++;
		if (s[i] == 'B')
			m[i][2]++;

		m[i][0] += m[i - 1][0];
		m[i][1] += m[i - 1][1];
		m[i][2] += m[i - 1][2];
	}



	for (ll i = 0; i < n - 2; i++)
	{

		for (ll j = i + 1; j < n - 1; j++)
		{
			bool r = false, g = false, b = false;

			if (s[i] == 'R')
				r = true;
			if (s[i] == 'G')
				g = true;
			if (s[i] == 'B')
				b = true;
			if (s[j] == 'R')
				r = true;
			if (s[j] == 'G')
				g = true;
			if (s[j] == 'B')
				b = true;

			if (r + g + b == 2)
			{
				if (!r)
				{
					ans += m[n - 1][0] - m[j][0];
					if (j + j - i < n)
						if (s[j + j - i] == 'R')
							ans--;
				}
				if (!g)
				{
					ans += m[n - 1][1] - m[j][1];
					if (j + j - i < n)
						if (s[j + j - i] == 'G')
							ans--;
				}
				if (!b)
				{
					ans += m[n - 1][2] - m[j][2];
					if (j + j - i < n)
						if (s[j + j - i] == 'B')
							ans--;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, d, A;
    cin >> n >> d >> A;
    vector <pii> a(n);
    for (auto &i : a) {
        cin >> i.x >> i.y;
    }
    sort(all(a));
    ll ans = 0;
    set <pair<int, ll> > have;
    ll cur = 0;
    for (int i = 0; i < n; i++) {
        while (!have.empty() && have.begin()->x < a[i].x) {
            cur -= have.begin()->y;
            have.erase(have.begin());
        }
        ll h = a[i].y - cur;
        if (h > 0) {
            ll cnt = (h + A - 1) / A;
            ans += cnt;
            cur += cnt * A;
            have.insert({a[i].x + d + d, cnt * A});
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12680
#include <iostream>
#include <string>

using namespace std;

int main(void){
	string str;

	while(cin >> str){
		int n = str.size(),a=0,b=0;
		if(str[0] == '0') break;
		for(int i=0;i<n-1;i++){
			if(str[i] == str[i+1]){
				if(str[i] == 'A'){
					a++;
				}else{
					b++;
				}
			}else{
				if(str[i] == 'A'){
					b++;
				}else{
					a++;
				}
			}
		}
		if(a > b){
			a++;
		}else{
			b++;
		}
		cout << a << " " << b << endl;
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

// a^b
template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

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

    vector<ll> fact(222222, 1), inv(222222, 1);
    for (ll i = 2; i < 222222; i++)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
        inv[i] = mypow(fact[i], MOD - 2LL);
    }
    int H, W, N;
    cin >> H >> W >> N;
    vector<P> v(N);
    for (int i = 0; i < N; i++)
    {
        ll r, c;
        cin >> r >> c;
        r--;
        c--;
        v[i] = P(r, c);
    }
    sort(v.begin(), v.end());
    v.push_back(P(H - 1, W - 1));
    vector<ll> dp(N + 1, 0);
    dp[0] = fact[v[0].first + v[0].second];
    dp[0] *= (inv[v[0].first] * inv[v[0].second] % MOD);
    dp[0] %= MOD;
    for (int i = 1; i <= N; i++)
    {
        ll r = v[i].first, c = v[i].second;
        dp[i] = fact[r + c];
        dp[i] *= (inv[r] * inv[c] % MOD);
        dp[i] %= MOD;
        for (int j = 0; j < i; j++)
        {
            if (c < v[j].second)
                continue;
            ll dr = r - v[j].first, dc = c - v[j].second;
            ll p = fact[dr + dc];
            p *= (inv[dr] * inv[dc] % MOD);
            p %= MOD;
            p *= dp[j];
            p %= MOD;
            dp[i] = (dp[i] + MOD - p) % MOD;
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 3840
s=input()
count=0
for i in range(len(s)):
    if i==0:
        if s[i] != "A":
            print("WA")
            exit()
    elif s[i] == "A":
        if i!=0:
            print("WA")
            exit()
    elif s[i] == "C":
        if 2<=i<=len(s)-2:
            count += 1
            if count >= 2:
                print("WA")
                exit()
        else:
            print("WA")
            exit()
    else:
        if not s[i].islower():
            print("WA")
            exit()
print('AC') if count==1 else print('WA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    int n;
    cin>>n;
    int a[n+5];
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    int j = 0;
    for(int i = 1; i <= n; i++)
    {
        if(j+1==a[i])
        {
            j++;
        }
    }
    if(!j)
        cout<<"-1"<<endl;
    else
    {
        cout<<n-j<<endl;
    }

    //End();
    return 0;
}


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

const int MAX_N = 100000;
int path[MAX_N];
bool arrived[MAX_N];

int main() {
  int N;
  cin >> N;
  fill(arrived, arrived+N, false);
  int ans = 0;
  int pos = 0;
  for (int i = 0; i < N; ++i) {
    cin >> path[i];
    path[i]--;
  }
  for (int i = 0; i < N; ++i) {
    arrived[pos] = true;
    if (arrived[path[pos]]) {
      ans = -1;
      break;
    }
    pos = path[pos];
    ans++;
    if (pos == 1) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
N = input()

def search(digit, isLess):
    if digit >= len(N):
        return 0

    ret = 0
    if isLess:
        ret = max(ret, search(digit + 1, True) + 9)
    else:
        for i in range(int(N[digit])):
            ret = max(ret, search(digit + 1, True) + i)
        ret = max(ret, search(digit + 1, False) + int(N[digit]))
    return ret

ans = search(0, False)
print(ans)


Measured memory_bytes: 3060
# 2019/08/08

Q,H,S,D=map(int,input().split())
n=int(input())

q=Q*4
h=H*2
s=S
d=D/2
ls=sorted([q,h,s,d])
if ls[0]==d and ls[1]!=d:
    if n%2:
        ans=D*(n//2)+ls[1]
    else:
        ans=D*(n//2)

else:
    ans=int(ls[0]*n)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<int>g[200005];
int a, b;
bool used[200005];
const int offset = 1e5;
void dfs(int s){
    if(s < offset)a++;
    else b++;
    used[s] = true;
    for(int x : g[s]){
        if(!used[x]){
            dfs(x);
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y + offset);
        g[y + offset].push_back(x);
    }
    ll ans = -n;
    for(int i = 0; i < offset; i++){
        if(!used[i]){
            a = b = 0;
            dfs(i);
            ans += (long long) a * b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10240
/*********************************
Date: Fri Mar  9 13:03:20 CST 2018
Author: ycl
*********************************/
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <sstream>
using namespace std;
#define CL(a) memset(a,0,sizeof(a))
#define Cl(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define INF 0x7fffffff
#define LL long long
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 100;
struct Node
{
	int x,y,t;
	friend bool operator <(Node a,Node b)
	{
		return a.t<b.t;
	}
}node[maxn];
bool check(int v,int u)
{
	int d=abs(node[v].x-node[u].x) + abs(node[u].y-node[v].y) ;
	int t = node[u].t-node[v].t ;
	if (d<=t && (t-d)%2==0)
		return true;
	else
		return false;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d%d%d",&node[i].t,&node[i].x,&node[i].y);
	}
	sort(node,node+n);
	bool f=1;
	for (int i=0;i<n;++i){
		if (!check(i,i+1)){
			f=0;
			break;
		}
	}
	if (f)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 1408