akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

H, W = map(int, input().split())

S = [input() for _ in range(H)]




es = defaultdict(list)
for i in range(H):
    for j in range(W):

        # 縦の経路
        if i == 0 and H != 1:
            if S[i][j] != S[i+1][j]:
                es[(i,j)].append((i+1,j))
                es[(i+1,j)].append((i,j))
        elif 0 < i < H-1:
                if S[i][j] != S[i+1][j]:
                    es[(i,j)].append((i+1,j))
                    es[(i+1,j)].append((i,j))
                if S[i][j] != S[i-1][j]:
                    es[(i,j)].append((i-1,j))
                    es[(i-1,j)].append((i,j))
        elif i == H-1 and H != 1:
                if S[i][j] != S[i-1][j]:
                    es[(i,j)].append((i-1,j))
                    es[(i-1,j)].append((i,j))

        # 横の経路
        if j == 0 and W != 1:
            if S[i][j] != S[i][j+1]:
                es[(i,j)].append((i,j+1))
                es[(i,j+1)].append((i,j))
        elif 0 < j < W-1:
            if S[i][j] != S[i][j+1]:
                es[(i,j)].append((i,j+1))
                es[(i,j+1)].append((i,j))
                if S[i][j] != S[i][j-1]:
                    es[(i,j)].append((i,j-1))
                    es[(i,j-1)].append((i,j))
        elif j == W-1 and W != 1:
                if S[i][j] != S[i][j-1]:
                    es[(i,j)].append((i,j-1))
                    es[(i,j-1)].append((i,j))

checked = [[False for _ in range(W)] for H in range(H)]


ans = 0
for i in range(H):
    for j in range(W):
        if checked[i][j] == True:
            continue
        
        cnt_b = 0
        cnt_w = 0

        if S[i][j] == "#":
            cnt_b += 1
        else:
            cnt_w += 1
        checked[i][j] = True
        stack = es[(i,j)]

        while stack:
            new_stack = []
            for p,q in stack:
                if checked[p][q] == False:
                    checked[p][q] = True
                    if S[p][q] == "#":
                        cnt_b += 1
                    else:
                        cnt_w += 1

                    new_stack.extend(es[(p,q)])
            if len(new_stack) == 0:
                break
            else:
                stack = new_stack
        
        ans += cnt_b * cnt_w

print(ans)

Measured memory_bytes: 135836
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct R {
	int64_t l;
	int64_t r;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<R> rs(n);
	FOR_LT(i, 0, n) {
		int64_t x, l;
		cin >> x >> l;
		rs[i].l = x - l;
		rs[i].r = x + l;
	}
	sort(rs.begin(), rs.end(), [](const auto& lhs, const auto& rhs) {
		return lhs.l < rhs.l;
		});

	int ans = 0;
	int64_t r = -1;
	FOR_LT(i, 0, n) {
		if (r <= rs[i].l) {
			r = -1;
		}

		if (r == -1) {
			ans++;
			r = rs[i].r;
			continue;
		}

		r = min(rs[i].r, r);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int H, W, D;
int X[500][500];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W >> D;
  rep(x, W) rep(y, H) {
    int color = 0;
    if (((x+y+INF)/D) % 2) color ^= 1;
    if (((x-y+INF)/D) % 2) color ^= 2;
    X[x][y] = color;
  }

  rep(y, H) {
    rep(x, W) {
      cout << "RYGB"[X[x][y]];
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    public static void Main()
    {
        Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = x[0];
        int K = x[1];
        string readline = Console.ReadLine();
        int[] V = readline.Split().Select(int.Parse).ToArray();
        long maxscore = long.MinValue;
        List<int> haveplus = new List<int>();
        List<int> haveminus = new List<int>();

        for (int fromleft = Math.Min(K,N); fromleft >= 0; fromleft--)
        {
            haveplus = new List<int>();
            haveminus = new List<int>();
            for (int i = 0; i < fromleft; i++)
            {
                if (V[i] >= 0)
                    haveplus.Add(V[i]);
                else
                    haveminus.Add(V[i]);
            }
            var haveplus_escape = new List<int>(haveplus);
            var haveminus_escape = new List<int>(haveminus);
            

            for (int fromright = Math.Min(K, N) - fromleft; fromright >= 0; fromright--)
            {
                haveplus = new List<int>(haveplus_escape);
                haveminus = new List<int>(haveminus_escape);

                for (int i = 0; i < fromright; i++)
                {
                    if (V[N-1-i] >= 0)
                        haveplus.Add(V[N-1-i]);
                    else
                        haveminus.Add(V[N - 1 - i]);
                }


                //最大(N-fromright-fromleft)回捨てられる。
                if (K - fromright - fromleft >= haveminus.Count)
                {
                    haveminus = new List<int>();
                }
                else
                {
                    haveminus.Sort();
                    for (int dispose = K - fromright - fromleft; dispose > 0; dispose--)
                    {
                        haveminus.RemoveAt(0);

                    }
                }

                long score = haveplus.Sum();
                score += haveminus.Sum();

                if (score > maxscore) maxscore = score;
                
            }


        }
        Console.WriteLine(maxscore);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
const int mod = (int) (7.5 + 1e9);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] != n - i / 2 * 2 - 1) {
      cout << 0 << "\n";
      return 0;
    }
  }
  int res = 1;
  for (int i = 0; i < n / 2; i++) res = res * 2 % mod;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
const double PI = 3.1415926535;

int main() {
  double x[1000], nx = 1, y[1000], ny = 0;
  double t = PI / 2;
  REP(i,1000) {
    nx += cos(t);
    ny += sin(t);

    x[i] = nx; y[i] = ny;
    t = atan(ny/nx) + PI / 2;
    if (nx < 0) t += PI;
    // cout << t << endl;
    // cout << nx << " " << ny << endl;
  }
  int n;
  while(cin >> n, n != -1) {
    cout << x[n-2] << endl;
    cout << y[n-2] << endl;
  }
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define pi 3.141592653
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int rem = n % 10;
    if(rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9)
    {
        cout << "hon" << endl;
    }
    else if(rem == 0 || rem == 1 || rem == 6 || rem == 8)
    {
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll k,a,b;
    cin >> k >> a >> b;
    if ((b-a)>=k){
        cout << "OK" << endl;
    }else{
        if((a/k)*k == a){
            cout << "OK" << endl;
        }else{
            if(((a/k)+1)*k <= b){
                cout << "OK" << endl;
            }else{
                cout << "NG" << endl;
            }
        }
    }
}

Measured memory_bytes: 3680
import java.io.*;
import java.util.*;

public class Main {
	
	static final int INF = Integer.MAX_VALUE / 3;

	void submit() {
		int a = nextInt();
		int b = nextInt();
		int[][] d = new int[a + 1][b + 1];
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				d[i][j] = nextInt();
			}
		}
		
		int[][] x = new int[X + 1][X + 1];
		for (int[] row : x) {
			Arrays.fill(row, -INF);
		}
		for (int ca = 0; ca <= X; ca++) {
			for (int cb = 0; ca + cb <= X; cb++) {
				for (int i = 1; i <= a; i++) {
					for (int j = 1; j <= b; j++) {
						x[ca][cb] = Math.max(x[ca][cb], d[i][j] - ca * i - cb * j);
					}
				}
			}
		}
		
		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {
				int got = Integer.MAX_VALUE;
				for (int ca = 0; ca <= 100; ca++) {
					for (int cb = 0; ca + cb <= X; cb++) {
						if (0 <= x[ca][cb] && x[ca][cb] <= X) {
							got = Math.min(got, x[ca][cb] + ca * i + cb * j);
						}
					}
				}
				if (got != d[i][j]) {
					out.println("Impossible");
					return;
				}
			}
		}
		
		int m = 2 * X;
		
		for (int ca = 0; ca <= X; ca++) {
			for (int cb = 0; ca + cb <= X; cb++) {
				if (0 <= x[ca][cb] && x[ca][cb] <= X) {
					m++;
				}
			}
		}
		
		out.println("Possible");
		int n = 2 * (X + 1);
		
		out.println(n + " " + m);
		
		for (int i = 0; i < X; i++) {
			out.println((i + 1) + " " + (i + 2) + " X");
			out.println((X + i + 3) + " " + (X + i + 2) + " Y");
		}
		
		for (int ca = 0; ca <= X; ca++) {
			for (int cb = 0; ca + cb <= X; cb++) {
				if (0 <= x[ca][cb] && x[ca][cb] <= X) {
//					m++;
					out.println((ca + 1) + " " + (X + 2 + cb) + " " + x[ca][cb]);
				}
			}
		}
		
		out.println(1 + " " + (X + 2));
	}
	
	static final int X = 100;

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int n,q,d,cur[N],lea[N],dis[N];
int main() {
  int tmp;
  scanf("%d%d",&n,&d);
  cur[0] = d;
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d",&tmp);
    dis[i] = tmp;
    cur[i] = min(cur[i-1],abs(cur[i-1] - tmp));
  }
  lea[n+1] = 1;
  for (int i = n ; i >= 1 ; -- i) {
    if (lea[i+1] <= dis[i] - lea[i+1])
      lea[i] = lea[i+1];
    else lea[i] = lea[i+1] + dis[i];
  }
  scanf("%d",&q);
  for (int i = 1 ; i <= q ; ++ i) {
    scanf("%d",&tmp);
    if (cur[tmp-1] >= lea[tmp+1])
      puts("YES");
    else puts("NO");
  }
  return 0;
}

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

int main()
{
    ll n,i,t,a,b,f=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>t>>a>>b;
        if((a+b)>t)
        {
            f=1;
            continue;
        }
        if((a+b)%2 == 0 && (t%2)!=0)
        {
            f=1;
        }
        else if(((a+b)%2 == 1) && ((t%2)!=1))
        {
            f=1;
        }

    }
    if(f==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
using namespace std;
int main(){
	io;
	int x;
	cin >> x; 
	if(x < 600){
		cout << 8;
		return 0;
	}
	if(x < 800){
		cout << 7;
		return 0;
	}
	if(x < 1000){
		cout << 6;
		return 0;
	}
	if(x < 1200){
		cout << 5;
		return 0;
	}
	if(x < 1400){
		cout << 4;
		return 0;
	}
	if(x < 1600){
		cout << 3;
		return 0;
	}
	if(x < 1800){
		cout << 2;
		return 0;
	}
	cout << 1;
	return 0;
}

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

int main(){
    int N; cin >> N;
    int ans = 0;
    vector<vector<vector<int>>> tes(N);
    for(int i = 0;i < N;++i){
        int A;
        cin >> A;
        for(int j = 0;j < A;++j){
            int x,y;
            cin >> x >> y;
            tes[i].push_back({x-1,y});
        }
    }
    for(int bit = 0;bit < (1<<N);++bit){
        vector<bool> h(N,false);
        for(int i = 0;i < N;++i){
            if(bit & (1<<i)){
                h[i] = true;
            }
        }
        bool flag = true;
        for(int i = 0;i < N;++i){
            if(h[i]){
                for(auto xy : tes[i]){
                    if((h[xy[0]] && xy[1] == 0) || (h[xy[0]]== false && xy[1] ==1)) flag = false;
                }
            }
        }
        if(flag){
            int cnt = 0;
            for(int i = 0;i < N;++i){
                if(h[i]){
                    cnt++;
                }
            }
            ans = max(ans,cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
CAAA = [input().split() for i in range(N)]

ans=100000000000

for i in range(1, 2**N):
  price=0
  rikaido = [0]*M
  for j in range(N):
    if i>>j & 1:
      price += int(CAAA[j][0])
      for k in range(M):
        rikaido[k] += int(CAAA[j][k+1])
        for l in rikaido:
          if l < X:
            break
        else:
          ans = min(ans, price)
if ans == 100000000000:
  print(-1)
else:
  print(ans)

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < 1000; i++){
        vector<int> A = {i / 100, (i % 100) / 10, i % 10};

        int idx = 0;
        for(int j = 0; j < n; j++){
            if('0' + A[idx] == s[j]){
                idx++;
            }

            if(idx == 3){ 
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (a + b > c + d) {
            System.out.println("Left");
        } else if (a + b < c + d) {
            System.out.println("Right");
        } else {
            System.out.println("Balanced");
        }
    }
}

Measured memory_bytes: 21716
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    ans = A[0]
    if N % 2 == 0:
        ans += 2 * sum(A[1:(N-2)//2+1])
    else:
        ans += 2 * sum(A[1:(N-2)//2+1]) + A[(N-2)//2+1]
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

int main(void)
{
    int64_t n;
    string s;
    cin >> n;
    cin >> s;

    int ct = 1;
    for (size_t i = 0; i < s.size() - 1; i++)
    {
        if(s[i] != s[i + 1]) ct++;
    }
    cout << ct << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<ll> A(N-1);
	for (ll i = 0; i < N-1; ++i) cin >> A[i];

	vector<ll> B(N, 0);
	for (ll i = 0; i < N-1; ++i)
	{
		B[A[i]-1]++;
	}

	for (ll i = 0; i < N; ++i)
	{
		cout << B[i] << endl;
	}
}


Measured memory_bytes: 6364
# coding: utf-8

def bubblesort(ls):
    count = 0
    
    for i in range(1, len(ls)):
        for j in reversed(range(i, len(ls))):
            if ls[j] < ls[j-1]:
                ls[j], ls[j-1] = ls[j-1], ls[j]
                count += 1
    return count

def main():
    trash = input()
    ls = list(map(int, input().split(' ')))

    i = bubblesort(ls)

    print(' '.join((map(str,ls))))
    print(i)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#define ll long long

using namespace std;

// input
int a,b;

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

    cin >> a >> b;

    if(a * b % 2 == 0){
        cout << "No" << "\n";
    }
    else{
        cout << "Yes" << "\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int h, w;
    int sum=0,tmp=0;
    cin >> h >> w;
    int a[h][w];
    int mat[h*w][3];
    int ans[h*w][4];
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<h; i++){
        if(i%2==0){
            for(int j=0; j<w; j++){
                mat[tmp][0]=i;
                mat[tmp][1]=j;
                mat[tmp][2]=a[i][j];
                tmp++;
            }
        }else{
            for(int j=w-1; j>=0; j--){
                mat[tmp][0]=i;
                mat[tmp][1]=j;
                mat[tmp][2]=a[i][j];
                tmp++;
            }
        }
    }
    sum=0;
    for(int i=0; i<h*w-1; i++){
        if(mat[i][2]%2==1){
            mat[i+1][2]++;
            ans[sum][0]=mat[i][0]+1;
            ans[sum][1]=mat[i][1]+1;
            ans[sum][2]=mat[i+1][0]+1;
            ans[sum][3]=mat[i+1][1]+1;
            sum++;
        }
    }
    cout << sum << endl;
    for(int i=0; i<sum; i++){
        for(int j=0; j<4; j++){
            cout << ans[i][j];
            if(j<3){
                cout <<  " ";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 9856
def main():
    n, u, v = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    u -= 1
    v -= 1
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]
    da = [-1]*n
    dt = [-1]*n
    dt[u] = 0
    da[v] = 0
    q = [u]
    cnt = 0
    while q:
        cnt += 1
        qq = []
        for i in q:
            for j in g[i]:
                if dt[j] == -1:
                    dt[j] = cnt
                    qq.append(j)
        q = qq
    q = [v]
    cnt = 0
    while q:
        cnt += 1
        qq = []
        for i in q:
            for j in g[i]:
                if da[j] == -1:
                    da[j] = cnt
                    qq.append(j)
        q = qq
    priority = sorted([[i, j] for i, j in enumerate(da)], key=lambda x: -x[1])

    for i, j in priority:
        if da[i] > dt[i]:
            print(da[i]-1)
            return 0


main()


Measured memory_bytes: 66536
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

LL dp[100005][2]; //! [top i digits decided][small guaranteed]

int main()
{
    string L;
    cin >> L;
    int len = L.length();
    dp[0][0] = 1;

    for (int i = 1; i <= len; ++i) rep(s, 2) {
        if (s) {
            //! (1,0),(0,1),(0,0)
            dp[i][1] = (dp[i][1] + 3 * dp[i-1][1]) % MOD;
        } else {
            if (L[i-1] == '1') {
                //! (1,0),(0,1) => small not guaranteed yet
                dp[i][0] = (dp[i][0] + 2 * dp[i-1][0]) % MOD;
                //! (0,0) => small guaranteed
                dp[i][1] = (dp[i][1] + dp[i-1][0]) % MOD;
            } else {
                //! (0,0) => small not guaranteed yet
                dp[i][0] = (dp[i][0] + dp[i-1][0]) % MOD;
            }
        }
    }

    int ans = (dp[len][0] + dp[len][1]) % MOD;

    cout << ans << endl;

    return 0;
}


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

int mod = 1000000007;
long long dp[100005];;


int main(){

  int p,q,r;
 cin>>p>>q>>r;


  int mini = min(min(p+q,q+r),r+p);

  cout<<mini<<endl;

return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = s.length();
    int ans = 0;
    vvint dp(l,vint(3,0));
    if(l==1){
        cout << 1 << endl;
        return 0;
    }
    dp[0][0]=1;
    dp[0][2]=1;
    for(int i=1;i<l;i++){
        dp[i][1]=dp[i-1][0];
        if(dp[i-1][1]>0){
            if(i<l-1){
                if(s[i-2]==s[i]&&s[i-1]==s[i+1]){
                    
                }else{
                    dp[i][0]=dp[i-1][1]+1;
                }
            }
            dp[i][2]=dp[i-1][1]+1;
        }
        if(dp[i-1][2]>0){
            if(s[i]!=s[i-1]){
                dp[i][2]=max(dp[i][2],dp[i-1][2]+1);
            }
            if(i<l-1){
                dp[i][0]=max(dp[i][0],dp[i-1][2]+1);
            }
        }

    }
    ans = max(dp[l-1][1],dp[l-1][2]);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
  int n, m;
  while(1){
    cin >> n >> m ;
    if(n == 0 && m == 0){
      break;
    }else{
      int array_n[n], array_m[m], sum_n , sum_m ;
      sum_n = sum_m = 0;
      
      for(int i =0;i < n;i++){
	cin >> array_n[i];
	sum_n += array_n[i];
      }

      
      for(int i = 0;i < m;i++){
	cin >> array_m[i];
	sum_m += array_m[i];
      }
      
      //cout << sum_n << " " << sum_m << endl;

      int ans_n, ans_m, sum = 100000;
      ans_n = ans_m = -1;
      
      for(int i =0;i < n;i++){
	for(int j = 0; j < m;j++){
	  if(sum_n+array_m[j]-array_n[i] == sum_m+array_n[i]-array_m[j]){
	    
	    if(sum > array_m[j]+array_n[i]){
	      sum = array_m[j]+array_n[i];
	      ans_n = i;
	      ans_m = j;
	    }
	      
	  }
	  
	}
      }
      if(ans_n == -1){
	cout << -1 << endl;
      }else{
	cout << array_n[ans_n] << " " << array_m[ans_m] << endl;
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 3084
package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var N, X uint
	fmt.Scan(&N, &X)

	debug("X=%d\n", X)
	//時間がかかるので文字列を直接求めるのはダメ
	/*
		barger := makeBarger(N)
		debug("level:%d -> %s\n", N, barger)
	*/
	debug("length->%d\n", bargerLength(N))
	debug("all p num -> %d\n", countP(N))
	fmt.Printf("%d\n", eatP(N, X))
}

var bargers = make(map[uint]string)

//levelのハンバーガをしたからx枚食べた時のPの枚数
func eatP(level uint, x uint) uint {
	if level == 0 && x >= 1 {
		return 1
	}
	if x <= 1 {
		return 0
	}

	bargerLen := bargerLength(level)
	if x > bargerLen {
		return countP(level)
	}
	nextLen := bargerLength(level - 1)
	if x <= nextLen+1 {
		return eatP(level-1, x-1)
	} else if x == nextLen+2 {
		return eatP(level-1, x-1) + 1
	} else if x <= 2*nextLen+2 {
		return eatP(level-1, x-2-nextLen) + 1 + countP(level-1)
	} else {
		return 2*countP(level-1) + 1
	}

}

func bargerLength(level uint) uint {
	return 1<<(level+2) - 3
}

func countP(level uint) uint {
	return 1<<(level+1) - 1
}

func makeBarger(level uint) string {
	if barger, ok := bargers[level]; ok {
		return barger
	}
	if level == 0 {
		bargers[0] = "P"
		return bargers[0]
	} else {
		tmp := make([]string, 0)
		pBarger := makeBarger(level - 1)
		tmp = append(tmp, "B")
		tmp = append(tmp, pBarger)
		tmp = append(tmp, "P")
		tmp = append(tmp, pBarger)
		tmp = append(tmp, "B")
		bargers[level] = strings.Join(tmp, "")
		return bargers[level]
	}
}

//** DEBUG **/
const DEBUG_ENABLE = false

func debug(format string, a ...interface{}) (n int, err error) {
	if DEBUG_ENABLE {
		return fmt.Fprintf(os.Stdout, format, a...)
	} else {
		return 0, nil
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, a; cin >> n >> a;
    int na = n % 500;
    if(na <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    while (true) {
        int n, p;
        cin >> n >> p;
        if ((n | p) == 0) {
            break;
        }
        int stone = p, player = 0, win = 0;
        int* players = new int [n];
        for (int i = 0; i < n; i++) {
            players[i] = 0;
        }
        while (true) {
            if (stone > 0) {
                players[player]++;
                stone--;
                if (stone == 0) {
                    bool winFlag = true;
                    for (int i = 0; i < n; i++) {
                        if (i != player && players[i] > 0) {
                            winFlag = false;
                            break;
                        }
                    }
                    if (winFlag) {
                        win = player;
                        break;
                    }
                }
            } else {
                stone += players[player];
                players[player] = 0;
            }
            if (player < n - 1) {
                player++;
            } else {
                player = 0;
            }
        }
        cout << win << endl;
        delete[] players;
    }
}

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

int main(){
    int k;
    cin >> k;
    int even,odd;

    if ( k % 2 == 0 ){
        even = k/2;
        odd = even;
    }
    else{
        odd = (k+1)/2;
        even = odd-1;
    }
    int ans = odd * even;

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *H = map(int, read().split())

    H.sort()

    ans = INF
    for i in range(N - K + 1):
        if ans > H[i + K - 1] - H[i]:
            ans = H[i + K - 1] - H[i]
    print(ans)
    return


if __name__ == '__main__':
    main()


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

#define sz(a) int(a.size())

bool vis[2510];
vector <int> adj[2510];

void dfs (int u) {
	vis[u] = 1;
	for (int v : adj[u]) {
		if (!vis[v]) dfs(v);
	}
}

int main() {
	int n, m, p;
	cin >> n >> m >> p;

	vector <tuple<int,int,int>> edges;
	for (int i = 0; i < m; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--;
		edges.emplace_back(u, v, w);
		adj[v].push_back(u);
	}

	dfs(n-1);

	const int INF = 1<<30;
	vector <int> D (n, INF);
	D[0] = 0;

	for (int i = 1; i < n; i++) {
		for (auto t : edges) {
			int u = get<0>(t), v = get<1>(t), w = get<2>(t);
			int cost = D[u] != INF ? D[u]+p-w : INF;
			if (D[v] > cost) D[v] = cost;
		}
	}

	for (auto t : edges) {
		int u = get<0>(t), v = get<1>(t), w = get<2>(t);
		int cost = D[u] != INF ? D[u]+p-w : INF;
		if (vis[v] && D[v] > cost) {
			puts("-1");
			return 0;
		}
		if (D[v] > cost) D[v] = cost;
	}

	cout << max(0, -D[n-1]) << endl;
}


Measured memory_bytes: 640
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
object Main extends App {
  import scala.io.StdIn._

  solve
  def solve: Unit = {
    val Array(q, lim) = readLine.trim.split(' ').map(_.toInt)
    if (q == 0 && lim == 0) return
    val arrayBuffer = ArrayBuffer[Int]()
    val countBit = new CountBit(q)
    val map = new mutable.HashMap[Int, Int]()
    var count = 0
    for (_ ← 0 until q){
      val Array(query, x) = readLine.trim.split(' ').map(_.toInt)
      query match {
        case 0 ⇒
          countBit.increment(arrayBuffer.size, 1)
          map.put(x, arrayBuffer.size)
          count += 1
          arrayBuffer += x
          if (count > lim){
            count -= 1
            countBit.increment(lowerBound(countBit, 1), -1)
          }
        case 1 ⇒
          countBit.increment(lowerBound(countBit, x), -1)
          count -= 1
        case 2 ⇒
          println(arrayBuffer(lowerBound(countBit, x)))
        case 3 ⇒
          countBit.increment(map(x), -1)
          count -= 1
        case _ ⇒ ???
      }
    }
    println("end")
    solve
  }
  def lowerBound(bit: CountBit, target: Int): Int = {
    var left = 0
    var right = bit.size
    while (left < right){
      val mid = (left + right) / 2
      if (bit(mid) < target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  class CountBit(val size: Int) {
    private val mArray = Array.tabulate(size){_ ⇒ 0}
    def apply(position: Int): Int = {
      var index = position
      var result = 0
      while (index >= 0){
        result += mArray(index)
        index -= ~index & (index + 1)
      }
      result
    }
    def increment(position: Int, value: Int): Unit = {
      var index = position
      while (index < size){
        mArray(index) += value
        index += ~index & (index + 1)
      }
    }
  }
}


Measured memory_bytes: 459160
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)



Measured memory_bytes: 13504
K=int(input())

lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(lis[K-1])

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto week = ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"];
    string s;
    scan(s);
    auto ans = 6 - week.countUntil(s);
    if (s == "SUN") ans = 7;
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), r, i = 2, x = n * 2;
		scan.close();
		if (n < 2)
		{
			System.out.println(2);
		}
		else
		{
			r = n % 2;
			while (r != 0)
			{
				n = i;
				i = r;
				r = n % i;
			}
			System.out.println(x / i);
		}
	}
}



Measured memory_bytes: 21712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			while ((x = in.readLine()) != null) {
				String[] ab = x.split(" ");
				long a = Integer.parseInt(ab[0]);
				long b = Integer.parseInt(ab[1]);
				
				if (a > b) {
					long tmp = a;
					a = b;
					b = tmp;
				}
				
				long tmp;
				long ta = a;
				long tb = b;
				while ((tmp = tb % ta) != 0) {
					tb = ta;
					ta = tmp;
				}
				
				long gcd = ta;
				long lcm = a * (b / gcd);
				
				System.out.println(gcd + " " + lcm);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,m,s=0,c1;
    cin>>n>>m;
    ll a[(int)m];
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        s=s+a[i];
    }
    if((n-s)>=0)
        c1=n-s;
    else
        c1=-1;
    cout<<c1<<endl;
    return 0;
}
    

Measured memory_bytes: 3668
s = input()

mod = [0] * 2019
mod[0] = 1
d = 1
n = 0
ans = 0

for i in reversed(s):
    n += int(i) * d
    n %= 2019
    d *= 10
    d %= 2019
    mod[n % 2019] += 1

for x in range(2019):
    ans += mod[x] * (mod[x]-1) // 2

print(ans)


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

int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
  	rep(i, m) cin >> a[i];
    int b[m];
  	rep(i, m) cin >> b[i];
    map<int, int> mp;

    rep(i, m) mp[a[i]]++;
    
    rep(i, m) mp[b[i]]++;

    int ans[n] = {};
    
    for(auto x : mp) {
      	int s = x.first;
      	int t = x.second;
        ans[s-1] = t;
    }

    for(int i = 0; i < n; i++) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long min = 10000000000000000L;
		int p = 0;
		long n = sc.nextLong();

		// 整数の入力
		for(int t=0;t<5;t++){
			long val = sc.nextLong();
			if(val<min){
				min=val;
			}
		}

		// 出力
		System.out.println(n%min==0?n/min+4:n/min+5);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    for(int i=0; i< 1<<(n-1); i++)
    {
        ll u = i;
        ll sum=0;
        ll now = s[0] - '0';
        for(int j=1; j<n; j++)
        {
            if(u%2)
            {
                sum += now;
                now = s[j] - '0';
            }
            else
            {
                now *= 10;
                now += s[j] - '0';
            }
            u /= 2;
        } 
        sum += now;
        ans += sum;
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct segment_tree {
  public:
    const int infty = (int)((1LL << 31) - 1);
    int n, ht, N;
    vector<int> dat;
    segment_tree(int sz) {
      n = sz;
      ht = 1;
      N = 1;
      while (N < n) {
        ht++;
        N <<= 1;
      }
      dat.resize(2 * N, infty);
    }
    segment_tree(vector<int> v) {
      n = v.size();
      ht = 1;
      N = 1;
      while (N < n) {
        ht++;
        N <<= 1;
      }
      dat.resize(2 * N);
      for (int i = 0; i < n; i++) {
        dat[N + i] = v[i];
      }
      for (int i = N - 1; i >= 1; i--) {
        dat[i] = min(dat[2 * i], dat[2 * i + 1]);
      }
    }
    void update (int i, int x) {
      i += N;
      dat[i] = x;
      i >>= 1;
      for (; i; i >>= 1) {
        dat[i] = min(dat[2 * i], dat[2 * i + 1]);
      }
    }
    int find (int l, int r, int k = 1, int L = 0, int R = -1) {
      if (R == -1) R = N;
      if (R <= l || r <= L) {
        return infty;
      } else if (l <= L && R <= r) {
        return dat[k];
      } else {
        int C = (L + R) >> 1;
        return min(find(l, r, 2 * k, L, C), find(l, r, 2 * k + 1, C, R));
      }
    }
};
int main() {
  int n, q;
  cin >> n >> q;
  const int infty = (int)((1LL << 31) - 1);
  segment_tree sgt(vector<int>(n, infty));
  while (q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int i, x;
      cin >> i >> x;
      sgt.update(i, x);
    } else {
      int s, t;
      cin >> s >> t;
      cout << sgt.find(s, ++t) << '\n';
    }
  }
  return 0;
}


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

int main()
{
	unsigned long n, a[200000], tall;
	unsigned long long sum = 0;
	
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	tall = a[0];
	
	for(int i = 1;  i < n; i++)
	{
		if(tall > a[i])
		{
			sum += tall - a[i];
		}
		else
		{
			tall = a[i];
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 5168
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	string S;
	
	cin >> N >> S;
	
	int ma = 0;
	for(int i=0;i<=N;i++){
		unordered_set<char> l,r;
		for(int j=0;j<i;j++) l.insert(S[j]);
		for(int j=i;j<N;j++) r.insert(S[j]);
		int cnt = 0;
		for(int j=0;j<26;j++){
			char c = (char)('a' + j);
			if(l.find(c) != l.end() && r.find(c) != r.end()) cnt++;
		}
		ma = max(ma, cnt);
	}
	
	cout << ma << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const ll N = 1e5 + 5, MOD = 1e9+7;

ll n;
ll a[N],ans;
ll cntn,cnt;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n;

    for( ll i=1; i<=n; i++ ){
        cin>>a[i];
        ans+=abs(a[i]);
        if(a[i]<0)                     cntn++;
        else if(a[i]==0)               cnt++;
        a[i]=abs(a[i]);
    }
    sort(a+1,a+n+1);
    //cout<<cntn<<" "<<cnt<<" "<<ans<<endl;
    if(cntn&1){
        if(cnt%2==0)       ans-=2*a[1];
    }

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




Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))
B = [0] * n
ret = []
for i in range(n):
  j = n - i - 1
  count = A[j]
  num = j + 1
  while True:
    num += (j + 1)
    if num > n:
      break
    count += B[num - 1]
  if count % 2:
    B[j] = 1
    ret.append(j + 1)
print(len(ret))
print(*ret)

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

int main(int argc, char const *argv[])
{
    int A, B, C;
    cin >> A >> B >> C;

    bool y = false;
    for(int i = 1; i < B; i++){
        if( i* A % B == C) {
            y=true;
            break;
        }
    }

    if(y){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int n;
vector<pair<int,int> > a;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<i;j++)
            if(i+j!=n+!(n%2))
                a.push_back(make_pair(j,i));
    cout<<a.size()<<endl;
    for(int i=0;i<a.size();i++)
        cout<<a[i].first<<" "<<a[i].second<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);



void solve(int T){
    ll x,n;
    cin>>x;
    n=100;
    int ans=0;
    while(n<x){
        n+=(n/100);
        ans++;
    }
    cout<<ans<<"\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3628
n=int(input())
info=[[int(i)for i in input().split()]for i in range(n)]
info.insert(0,[0,0,0])
for i in range(n):
    t=info[i+1][0]-info[i][0]
    d=abs(info[i+1][1]-info[i][1])+abs(info[i+1][2]-info[i][2])
    if d<=t:
        if d%2==0 and t%2==0:
            pass
        elif d%2==1 and t%2==1:
            pass
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
else:
    print("Yes")


Measured memory_bytes: 21156
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

const int32_t M = 1000000007;

template <class T>
string sprint_arr(const vector<T>& arr) {
  stringstream ss;
  for (auto t : arr) {
    ss << t << " ";
  }
  return ss.str();
}

template <class T>
string sprint_matrix(const vector<vector<T>>& arr) {
  stringstream ss;
  for (auto t : arr) {
    ss << sprint_arr(t) << endl;
  }
  return ss.str();
}

vector<vector<int32_t>> m_mul(vector<vector<int32_t>>& a,
                              vector<vector<int32_t>>& b) {
  auto n = a.size();
  vector<vector<int32_t>> result(n, vector<int32_t>(n, 0));
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        result[i][j] = (result[i][j] + (((int64_t)a[i][k]) * b[k][j]) % M) % M;
      }
    }
  }
  return result;
}

int32_t m_sum(vector<vector<int32_t>>& m) {
  int32_t result = 0;
  rep(i, m.size()) {
    rep(j, m.size()) {
      result = (result + m[i][j]) % M;
    }
  }
  return result;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int64_t n, k;
  cin >> n >> k;

  vector<vector<int32_t>> m(n, vector<int32_t>(n, 0));
  vector<vector<int32_t>> result_m(n, vector<int32_t>(n, 0));

  rep(i, n) {
    result_m[i][i] = 1;
    rep(j, n) { cin >> m[i][j]; }
  }

  while(k > 0) {
    if (k & 1) {
      result_m = m_mul(result_m, m);
    }
    m = m_mul(m, m);
    k >>= 1;
  }

  cout << m_sum(result_m);
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())

uf = UnionFind(N)

for _ in range(M):
    X, Y, Z = map(int,input().split())
    uf.union(X-1, Y-1)

print(uf.group_count())

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, q; cin >> n >> m >> q;
    vector<array<int, 4>> qv;
    for (int i = 0; i < q; i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        qv.push_back({--a, --b, c, d});
    }
    int ans = 0;
    vector<int> v;
    v.emplace_back(1);
    auto f = [&](auto f, int c) -> void {
        if (c == n) {
            int curr = 0;
            for (auto &[a, b, c, d]: qv) {
                if (v[b] - v[a] == c) curr += d;
            }
            ans = max(ans, curr);
            return;
        }
        int x = v.back();
        for (int i = x; i <= m; i++) {
            v.emplace_back(i);
            f(f, c+1);
            v.pop_back();
        }
    };
    f(f, 1);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3656