akhauriyash/Code-Regression huggingface dataset:
// 5/14
// 過去問ガリガリ
#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int N, S;
    cin >> N >> S;

    vector<int> A(N);
    rep(i, N) cin >> A[i];


    // ll dp[3010][3010];  // dp[i+1][j] = i番目まででj個作れるかどうか

    vector<vector<mint>> dp(N + 1, vector<mint>(S + 1, 0));
    // memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    rep(i, N) {
        for (int j = 0; j <= S; j++) {
            dp[i + 1][j] += dp[i][j] * 2;  // A[i]を使わない場合
            if (j >= A[i]) dp[i + 1][j] += dp[i][j - A[i]];  // A[i]を使う場合
            // if (j + A[i] <= S) dp[i + 1][j + A[i]] += dp[i][j];
        }
    }

    // mint ans = 0;

    // rep(i, N) {
    //     ans += dp[i + 1][S] * mint(2).pow(N - i - 1);
    // }

    // cout << ans << endl;

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


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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int acc = 0;
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) acc += 2;
            if (j * j == i) acc--;
        }
        if (acc == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

string m[1000];
string ans;
int h, w;
map<string, int> msi;

static const int dy[8] = {0,-1,-1,-1,0,1,1,1};
static const int dx[8] = {1,1,0,-1,-1,-1,0,1};

string big(string a, string b){
    if(a.size() > b.size()) return a;
    else if(a.size() < b.size()) return b;
    else{
        if(a < b) return a;
        else return b;
    }
}

void search(int y, int x){
    rep(i,8){
        string s;
        int j = 0;
        while(true){
            s += m[y + dy[i] * j][x + dx[i] * j];
            msi[s]++;
            if(msi[s] == 2){
                ans = big(ans, s);
            }
            j++;
            if(dy[i] * j % h == 0 && dx[i] * j % w == 0) break;
        }
    }
}

int main(){
    while(cin >> h >> w, h||w){
        rep(i,1000) m[i] = "";
        ans = "";
        msi.clear();
        rep(i,h){
            string s;
            cin >> s;
            rep(j,50) rep(k,50) m[i + j * h]+=s;
        }
        for(int i = h * 25; i < h * 26; i++){
            for(int j = w * 25; j < w * 26; j++){
                search(i,j);
            }
        }
        if(ans.size() < 2 ) cout << 0 << endl;
        else cout << ans << endl;
    }
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a + b == c || b + c == a || c + a == b) ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

int main(void)
{
    int n;
    cin >>n;

    int ct = 0;
    for(int i = 1; i <= n; i++){
        if(i <= 9 || (i >= 100 && i <= 999) || (i >= 10000 && i <= 99999)){
            ct++;
        }
    }

    printf("%d\n", ct);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int X = GetInt();
		var list = sieve(100103);

		for(int i = 0, L = list.Count; i < L; i++)
		{
			if(list[i] >= X)
			{
				WriteLine(list[i]);
				return;
			}
		}
	}

	private static List<int> sieve(int N)
	{
		List<int> primeList = new List<int>();
		bool[] isPrime = new bool[N+1];
		for(int i = 2; i <= N; i++)
			isPrime[i] = true;

		for(int i = 2; i <= N; i++)
		{
			if(isPrime[i])
			{
				primeList.Add(i);
				for(int j = 2 * i; j <= N; j += i)
					isPrime[j] = false;
			}
		}

		return primeList;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13152
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main(){
  int num;int blood_a=0,blood_b=0,blood_ab=0,blood_o=0;
  char blood_type[3];
  while(scanf("%d,%s",&num,blood_type)!=EOF){
      if(blood_type[0]=='A'){
        if(blood_type[1]=='B')blood_ab++;
        else blood_a++;
      }
      else if(blood_type[0]=='B')blood_b++;
      else if(blood_type[0]=='O')blood_o++;
  }
  cout<<blood_a<<endl<<blood_b<<endl<<blood_ab<<endl<<blood_o<<endl;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, d, x;
    int a[100];
    cin >> n >> d >> x;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        int idx = 0;
        while (idx++ * a[i] + 1 <= d)
            cnt++;
    }
    cout << cnt + x << endl;
}


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

struct Node {
    int parent, left, right;
};

Node T[30];
int D[30], H[30];

void preParse(int u){
    if(u == -1){
        return;
    }
    cout << " " << u;
    preParse(T[u].left);
    preParse(T[u].right);
}

void inParse(int u){
    if(u == -1){
        return;
    }
    inParse(T[u].left);
    cout << " " << u;
    inParse(T[u].right);
}

void postParse(int u){
    if(u == -1){
        return;
    }
    postParse(T[u].left);
    postParse(T[u].right);
    cout << " " << u;
}

int main() {
    int n; cin >> n;
    rep(i, n){
        T[i].parent = -1;
    }
    rep(i, n){
        int id; cin >> id;
        int L; cin >> L;
        int R; cin >> R;
        T[id].left = L;
        T[id].right = R;
        if (L != -1){
            T[L].parent = id;
        }
        if (R != -1){
            T[R].parent = id;
        }
    }

    int r;
    rep(i, n){
        if(T[i].parent == -1){
            r = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    preParse(r);
    cout << endl;

    cout << "Inorder" << endl;
    inParse(r);
    cout << endl;

    cout << "Postorder" << endl;
    postParse(r);
    cout << endl;


}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
 
int main(){
    int a, b, c;
    int temp1,temp2;
    cin>> a >> b >> c;
    if (a < b)
		temp1 = a, temp2 = b;
	else
		temp1 = b, temp2 = a;
	if (c < temp1 )
		cout<<c<<" "<<temp1<<" "<<temp2<<endl;
	else if (c<temp2)
		cout<<temp1<<" "<<c<<" "<<temp2<<endl;
	else
		cout<<temp1<<" "<<temp2<<" "<<c<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S, T; cin >> S >> T;
    cout << T + S << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e6+5;
const int mod=1e9+7;
ll n,s,val;
set<ll>st;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0) {
            st.insert(i);
            st.insert(n/i);
        }
        if((n-1)%i==0){
            st.insert(i);
            st.insert((n-1)/i);
        }
    }
    for(ll v:st){
        if(v==1) continue;
        val=n;
        while(val%v==0) val=val/v;
        if(val%v==1) s++;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 512
x = [0] * 3
y = [0] * 3
z = [0] * 3
for i in range(3):
    x[i], y[i], z[i] = map(int, input().split())

n = int(input())
b = [int(input()) for _ in range(n)]
ans = [x, y, z]

for i in range(3):
    ans.append([x[i], y[i], z[i]])

ans.append([x[0], y[1], z[2]])
ans.append([x[2], y[1], z[0]])

cnt_list = []
for i in range(len(ans)):
    cnt = 0
    for j in list(set(x + y + z) & set(b)):
        if j in ans[i]:
            cnt += 1
    cnt_list.append(cnt)

for cnt in cnt_list:
  if cnt >= 3:
    print('Yes')
    exit()
 
print('No')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
 	string s; getline(cin, s);
  	int start, end;
  	int i;
  	for(i=0;s[i]!='A';i++);
  	start=i;
  	for(i=start;i<s.size();i++){
    	if(s[i]=='Z')
        	end=i;
    }
  	cout << end-start+1;
}

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

namespace ext {
	using namespace std;
	template<class T>
	struct vector : std::vector<T> {
		using std::vector<T>::vector;
		char dil = ' ';
		vector<T> accum() {
			vector<T> res(this->size() + 1);
			for (size_t i = 0; i < this->size(); i++) {
				res[i+1] = (*this)[i] + res[i];
			}
			return res;
		}
		vector<T> zaatsu() {
			map<T, int> m;
			for (auto& e: *this) m[e] = 1;
			int count = 0;
			for (auto& e: m) e.second = count++;
			vector<T> res = *this;
			for (auto& e: res) e = m[e];
			return res;
		}
		friend istream& operator>>(istream& is, vector<T>& t) {
			for (auto& e: t) cin >> e;
			return is;
		}
		friend ostream& operator<<(ostream& os, vector<T>& t) {
			t.print(' ', os);
			return os;
		}
		void print(char del = ' ', ostream& os = cout) {
			for (size_t i = 0; i < this->size(); i++) {
				os << (*this)[i];
				if (i + 1 != this->size()) os << del;
				os.flush();
			}
		}
		void println(char del = ' ', ostream& os = cout) {
			print(del, os);
			cout << endl;
		}
		long long crossing_merge() {
			auto t = *this;
			return t.crossing_merge_sub();
		}
		// 半開区間
		long long crossing_bit(T min_v = -1, T max_v = -1) {
			if (min_v == -1) min_v = this->min();
			if (max_v == -1) max_v = this->max() + 1;
			vector<T> bit(max_v - min_v + 1, 0);
			long long res = 0;
			for (auto e: *this) {
				e = max_v - e;
				for (size_t x = e - 1; x; x -= x & -x) {
					res += bit[x];
				}
				for (size_t x = e; x < bit.size() ; x += x & -x) {
					bit[x]++;
				}
			}
			return res;
		}
		bool permutation() {
			return next_permutation(this->begin(), this->end());
		}
		T& max() {
			return *max_element(this->begin(), this->end());
		}
		T& min() {
			return *min_element(this->begin(), this->end());
		}
private:
		long long crossing_merge_sub() {
			if (this->size() == 1) return 0;
			int x = this->size() / 2;
			vector<T> left(this->begin(), this->begin() + x);
			vector<T> right(this->begin() + x, this->end());
			long long res = left.crossing_merge_sub() + right.crossing_merge_sub();
			left.push_back(numeric_limits<T>::max()); right.push_back(numeric_limits<T>::max());
			size_t l = 0, r = 0;
			while (l + r < this->size()) {
				if (left[l] < right[r]) {
					(*this)[l+r] = left[l];
					l++;
				} else {
					(*this)[l+r] = right[r];
					r++;
					res += x - l;
				}
			}
			return res;
		}
	};
}

using namespace std;

bool isok(int k, const ext::vector<int>& a) {
	ext::vector<int> v(a.size()+1);
	auto res = 0LL;
	for (int i = 0; i < a.size(); i++) {
		v[i+1] = (a[i] >= k) ? 1 : -1;
		v[i+1] += v[i];
	}
	res += v.crossing_bit() ;
	auto al = (long long) a.size() * (a.size() + 1) / 2;
	return res <= al - res;
}

int main() {
	namespace std = ext;
	using std::vector;
	int N;
	cin >> N;
	vector<int> a(N);
	cin >> a;
	int ng = 1e9 + 10;
	int ok = 0;
	int cnt = 0;
	while (ng - ok > 1) {
		int mid = (ng + ok) / 2;
		if (isok(mid, a)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 1472
N = gets.to_i
array = gets.split(' ').map(&:to_i)
array.unshift(0)
boxes = Array.new(N+1, 0)
N.downto(1).each do |i|
  selects = [i]
  nextnum = i
  loop do
    nextnum = nextnum + i
    break if nextnum > N
    selects.push(nextnum)
  end
  count = 0
  selects.each do |s|
    count += boxes[s]
  end
  boxes[i] = 1 if count % 2 != array[i]
end
sum = boxes.inject(:+)
puts sum
res = boxes.map.with_index do |b,i|
  b==1 ? i : nil
end.to_a.compact.join(' ')
puts res unless res.empty?


Measured memory_bytes: 45576
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int n;
char s[20] = {};

void f(int a, int b){
	if(a == n) printf("%s\n", s);
	else {
		REP(i, b+1){
			s[a] = 'a' + i;
			f(a+1, max(b, i+1));
		}
	}
}

int main(){
	scanf("%d", &n);
	f(0, 0);
}


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

typedef long long ll;

vector<bool>p(10);

int judge(int n){
  while(n!=0){
    int b=n%10;
    if(p[b]==true)return false;
    n/=10;
    }
return true;
}

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   
   int n,k;
   cin>>n>>k;
   rep(i,k){
     int a;
     cin>>a;
     p[a]=true;
   }
    
   for(int i=n;;i++){
     if(judge(i)){
       cout<<i<<endl;
       break;
      }
   }
   
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
    cin >> a >> b >> c;
	int ans1,ans2,ans3,x,y,z;
	
	x = c * 10 + b+a;
	y = a * 10 + c+b;
	z = b * 10 + a+c;
	ans1 = max(x, y);
	ans2 = max(y, z);
	ans3 = max(ans1, ans2);

	
	
	
	cout << ans3 << endl;

	
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

string tenki[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};

int main() {
    string today;
    cin >> today;
    REP (i, 3) {
        if (today == tenki[i]) cout << tenki[i+1] << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int xmax = Integer.MIN_VALUE;
        int ymin = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (xmax < tmp) {
                xmax = tmp;
            }
        }
        for (int i = 0; i < m; i++) {
            int tmp = sc.nextInt();
            if (ymin >= tmp) {
                ymin = tmp;
            }
        }
        sc.close();

        if (x < ymin && ymin <= y) {
            if (xmax < ymin) {
                System.out.println("No War");
                return;
            }
        }
        System.out.println("War");

    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
long long dp[1010][20100] = {};
 
int main(){
	int H,N;
	cin >> H >> N;
	vector<pair<long long,long long>> P(N);
	long long a,b;
	rep(i,N){
		cin >> a >> b;
		P[i] = make_pair(a,b);
	}
	rep(i,1010){
		rep(j,20100){
			dp[i][j] = INT_MAX;
		}
	}
	dp[0][0] = 0;
	rep(i,N){
		rep(j,10001){
			dp[i][j + P[i].first] = min(dp[i][j + P[i].first],dp[i][j] + P[i].second);
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
		}
	}
	long long res = LONG_LONG_MAX;
	for(int i = H;i<=20000;i++){
		res = min(res,dp[N-1][i]);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 158848
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    
    int x;
    cin >> x;

    cout << ( (x == 7 || x == 5 || x == 3) ? "YES": "NO" ) <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define catd I64d
#endif

cat mod = 998244353;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = (x * x) % mod;
	if(e%2 != 0) x = (x * a) % mod;
	return x;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	int sz = max(N, M);
	vector<cat> fac(N+M+1, 1), inv(N+M+1, 1), invn(N+M+1, 1);
	cat inv2 = pw(2, mod-2);
	for(int i = 1; i <= N+M; i++) {
		fac[i] = (i * fac[i-1]) % mod;
		if(i%2 == 0) invn[i] = inv2 * invn[i/2] % mod;
		else invn[i] = pw(i, mod-2);
		inv[i] = (invn[i] * inv[i-1]) % mod;
	}
	vector<cat> H(sz+1, 0), P(sz+1, 0);
	for(int i = 0; i <= N; i++) H[i] = inv[N-i] * inv[i] % mod;
	for(int i = 1; i <= M; i++) P[i] = inv[M-i] * inv[i-1] % mod;
	cat ans = 0, cnt = 0;
	for(int k = 0; k < 2; k++) {
		cnt = 0;
		M--;
		for(int i = 0; i <= N+M; i++) {
			if(i%2 != 0) {
				if((i-1)/2 <= M && (i+1)/2 <= N)
					cnt = (cnt - fac[N+M-i] % mod * inv[M-(i-1)/2] % mod * inv[N-(i+1)/2] % mod * fac[i-1] % mod * inv[i/2] % mod * inv[i/2]) % mod;
			}
			else {
				if(i/2 <= M && i/2 <= N)
					cnt = (cnt + fac[N+M-i] % mod * inv[M-i/2] % mod * inv[N-i/2] % mod * ((i == 0) ? 1 : (fac[i-1] * inv[i/2-1] % mod * inv[i/2] % mod))) % mod;
			}
			ans += cnt;
		}
		M++;
		swap(M, N);
	}
	for(int s = 2; s <= min(N, M) * 2; s += 2)
		ans += inv[N-s/2] * inv[s/2] % mod * inv[s/2-1] % mod * inv[M-s/2] % mod * fac[s-1] % mod * fac[N+M-s] % mod;
	ans %= mod;
	ans = (ans * inv[N+M] % mod * fac[N] % mod * fac[M]) % mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 31488
#include<stdio.h>
int main(void){
    int n,x;
    scanf("%d",&n);
    x = n * 25 / 27;
    if(n == x * 27 / 25){
        printf("%d", x);
    }
    else if(n == (x+1) * 27 / 25){
        printf("%d",x + 1);
    }
    else printf(":(");
    return 0;
}

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


int main(){
    ll N, M; cin >> N >> M;
    vector<int> V(N);
    for(int i = 0; i < N; i++) V[i] = 1;
    vector<bool> Flag(N);
    Flag[0] = true;
    for(int i = 0; i < M; i++){
        int x, y; cin >> x >> y; x--; y--;
        V[x]--; V[y]++;
        if(Flag[x]) {
            Flag[y] = true;
            if(V[x] == 0) Flag[x] = false;
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) if(Flag[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <cstdio>
#include <vector>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
vector<ll>v(2019);
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    v[0]=1;
    int len=s.size();
    ll ans=0;
    int cnt=1,temp=0;
    reverse(s.begin(),s.end());
    For(i,0,len-1)
    {
        temp=(temp+(s[i]-'0')*cnt)%2019;
        ans+=v[temp];
        v[temp]++;
        cnt=cnt*10%2019;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3708
dat = [None] * 400000
m = 0

def init():
    global dat, m
    for i in range(2 * m - 1):
        dat[i] = 2 ** 31 - 1

def update(i, x):
    global dat, m
    i += m - 1
    dat[i] = x
    while i > 0:
        i = (i - 1) // 2
        dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2])

def query(a, b, k, l, r):
    global dat, m
    if r <= a or b <= l:
        return 2 ** 31 - 1
    if a <= l and r <= b:
        return dat[k]
    else:
        vl = query(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = query(a, b, k * 2 + 2, (l + r) // 2, r)
        return min(vl, vr)

n, q = map(int, input().split())
m = 1

while m < n:
    m *= 2

init()

for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        update(x, y)
    else:
        print(query(x, y + 1, 0, 0, m))



Measured memory_bytes: 10280
n = int(input())
A = list(map(int, input().split()))
B = set()
C = []
for i in A:
    if 1<= i <= 399:
        B.add("grey")
    elif 400 <= i <= 799:
        B.add("brown")
    elif 800 <= i <= 1199:
        B.add("green")
    elif 1200 <= i <= 1599:
        B.add("sky")
    elif 1600 <= i <= 1999:
        B.add("blue")
    elif 2000 <= i <= 2399:
        B.add("yellow")
    elif 2400 <= i <= 2799:
        B.add("orange")
    elif 2800 <= i <= 3199:
        B.add("red")
    else:
        C.append("X")

if C:
    S = len(B)
    T = len(B) + len (C)
    if S == 0:
        S = 1
    print(str(S) + " " + str(T))
else:
    print(str(len(B)) + " " + str(len(B)))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
	int key;
	Node *next;
	Node *prev;
};

Node *nil;

void initNode(void)
{
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

//連結リストの先頭にキーkeyを持つ要素を追加する
void insert(int key)
{
	Node *new_node = (Node *)malloc(sizeof(Node));
	new_node->key = key;
	new_node->next = nil->next;
	nil->next->prev = new_node;
	nil->next = new_node;
	new_node->prev = nil;
}

//双方向リストの要素の探索
Node* listSearch(int key)
{
	Node *cur = nil->next;	//番兵の次の要素から辿る
	while( (cur != nil) && (cur->key != key) )
	{
		cur = cur->next;
	}
	return cur;
}

//指定したNodeを削除する
void deleteNode(Node *t)
{
	if (t == nil) 
	{
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

//キーkeyを持つ最初の要素を連結リストから削除する
void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

//連結リストの先頭の要素を削除する
void deleteFirst(void)
{
	deleteNode(nil->next);
}

//連結リストの末尾の要素を削除する
void deleteLast(void)
{
	deleteNode(nil->prev);
}

//リストの出力
void printList()
{
	Node *cur = nil->next;
	int ifs = 0;

	while (1)
	{
		if (cur == nil) break;
		if (ifs++ > 0)
		{
			printf(" ");
		}
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

int main(void)
{
	int key, n, i;
	int size = 0;
	int np = 0, nd = 0;
	char command[20];
	scanf("%d", &n);
	initNode();

	for( i = 0; i < n; i++)
	{
		scanf("%s%d", command, &key);
		if( command[0] == 'i')
		{
			insert(key);
			np++; size++;
		}
		else if (command[0] == 'd')
		{
			if (strlen(command) > 6 )
			{
				if (command[6] == 'F') deleteFirst();
				else if( command[6] == 'L' ) deleteLast();
			}
			else
			{
				deleteKey(key);
				nd++;
			}
			size--;
		}
		//printList();
	}
	printList();
	return 0;
}



Measured memory_bytes: 33900
N , K =map(int,input().split())
MOD=10**9+7
ans=0
if N<K:
    print(1)
else:
    tmp_low = sum(range(K))
    tmp_high = sum(range(N-K+1,N+1))
    r=tmp_high-tmp_low+1
    ans+=r
    ans%=MOD
    for sel in range(K+1,N+2):
        tmp_low += sel-1
        tmp_high += N-sel+1
        r= tmp_high-tmp_low+1
        ans+=r
        ans%=MOD
    print(ans%MOD)


Measured memory_bytes: 9232
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lld;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"NO"<<endl;return 0
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
const int hi=100000;
int main(void){
	int n,i,ans=0;cin>>n;
	vector<bool>a(n);
	for(i=0;i<n;i++){
		int q;cin>>q;
		a[i]=(i+1==q);
	}
	int ma=1;
	for(i=0;i<n;i++){
		if(a[i]){
			ma++;
			if(ma==2){ ma=0;ans++; }
		} else{
			ma=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if((a>=1 && a<=9) && (b>=1 && b<=9)){
    printf("%d\n",(a*b));
  }
  else{
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  int N,ans=0;
  cin >> N;
  int a[N];
  rep(i,N) cin >> a[i];
  rep(i,N) while(a[i]%2==0) ans++,a[i]/=2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}
impl<T: Iterator> IteratorExt for T {}

fn main() {
    let s = read!(String);
    let t = read!(String);

    let s = s.into_bytes();
    let t = t.into_bytes();

    let mut count = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            count += 1;
        }
    }
    println!("{}", count);
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> 
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}
  
  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
};

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<vector<int> > a(3,vector<int>(n));

  for(int i=0;i<3;i++)
    for(int j=0;j<n;j++) cin>>a[i][j];

  auto NG=[](){cout<<"No"<<endl;exit(0);};
  set<int> s;
  for(int j=0;j<n;j++){
    if(a[1][j]%3!=2) NG();
    if((a[1][j]/3)%2!=(j&1)) NG();
    if(j%4>=2) swap(a[0][j],a[2][j]);
    if(abs(a[0][j]-a[1][j])!=1) NG();
    if(abs(a[2][j]-a[1][j])!=1) NG();
    if(j%4<2) s.emplace(j*3+1);
    else s.emplace(j*3+3);
  }
    
  for(int j=0;j<n;j++)
    assert(s.count(a[0][j])||s.count(a[2][j]));
  
  auto rot=
    [&](int x){
      assert(0<x&&x+1<n);
      for(int i=0;i<3;i++)
        swap(a[i][x-1],a[i][x+1]);
      swap(a[0][x],a[2][x]);
    };

  for(int j=1;j+1<n;j++)
    if(!s.count(a[0][j])) rot(j),j-=2,chmax(j,0);
  if(!s.count(a[0][0])){
    rot(1);rot(2);rot(3);   
  }
  if(!s.count(a[0][n-1])){
    rot(n-2);rot(n-3);rot(n-4);   
  }
  for(int j=1;j+1<n;j++)
    if(!s.count(a[0][j])) rot(j),j-=2,chmax(j,0);
  
  for(int j=0;j<n;j++) assert(s.count(a[0][j]));  
  
  vector<int> eve,odd;
  for(int j=0;j<n;j++)
    (j&1?odd:eve).emplace_back(a[0][j]);

  const int MAX = 3e5+100;
  auto calc=
    [&](vector<int> v)->int{
      BIT<int> bit(MAX,0);
      int res=0;
      for(int i=0;i<(int)v.size();i++){
        res+=(i-bit.sum(v[i]))&1;
        bit.add(v[i],1);
      }
      return res&1;
    };
  
  if(calc(eve)) NG();
  if(calc(odd)) NG();
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 8184
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
  int a = 0, b = 0;
  cin >> a >> b;
  int result = max(a * 2 - 1, max(a + b, b * 2 - 1));
  cout << result << endl;
  return 0;
}

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

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

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> A(H);
    rep(i, H) cin >> A[i];

    queue<P> q;
    vector<vector<int>> ans(H, vector<int>(W, -1));

    rep(i, H)rep(j, W) {
        if (A[i][j] == '#') {
            ans[i][j] = 0;
            q.push(P(i, j));
        }
    }

    int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
    while (q.size()) {
        P p = q.front(); q.pop();
        int y = p.first, x = p.second;

        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];

            if (0 <= ny && ny < H && 0 <= nx && nx < W && ans[ny][nx] < 0) {
                ans[ny][nx] = ans[y][x] + 1;
                q.push(P(ny, nx));
            }
        }
    }

    int a = 0;
    rep(i, H)rep(j, W) chmax(a, ans[i][j]);

    cout << a << endl;
}

Measured memory_bytes: 13456
n = gets.to_i
a = gets.chomp.split(" ").map{|i| i.to_i}
rate = Array.new(8){0}
other = 0
a.each{|r|
  if r >= 3200
    other += 1
  else
    rate[r/400] += 1
  end
}
color = 0
rate.each{|x|
  if x != 0
    color += 1
  end
}
mini = color
maxi = color + other
if mini == 0 && other > 0
  mini += 1
end
puts "#{mini} #{maxi}"


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {cin >> a.at(i);}
    
    for(int i = 0; i < k; i++) {
        vector<int> b(n+1);
        for(int j = 0; j < n; j++) {
            int l = max(0, j-a.at(j));
            int r = min(j+a.at(j)+1, n);
            b.at(l)++; b.at(r)--;
        }
        for(int j = 0; j < n; j++) {b.at(j+1) += b.at(j);}
        b.pop_back();
        if(a == b) break;
        a = b;
    }
    for(int i = 0; i < n; i++) cout << a.at(i) << endl;
}


Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
//debugger
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//debugger
vector<int> thief(150);
int main()
{
    FASTIO;
    char x;
    cin>>x;
    if(x<'a') cout<<'A'<<endl;
    else cout<<'a'<<endl;
}

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

int main(void)
{
  int n;

  scanf("%d",&n);

  switch(n%10)
  {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon\n");
      break;
    default:
      printf("bon\n");
      break;
  }

  return 0;
}

Measured memory_bytes: 1608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    int n,l; cin >> n >> l;
    int cor=0;
    int ans;
    rep(i,n) cor+=l+i;
    rep(j,n){
        int tmp=0;
        rep(i,n){
            if(i==j) continue;
            tmp+=l+i;
        }
        if(j==0) ans=tmp;
        else if(abs(ans-cor)>abs(tmp-cor)) ans=tmp;
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n, k;
	cin >> n >> k;
	V num(k + 1, 0);
	rep1(i, n) {
		num[i % k]++;
	}
	ll ans = 0;
	rep1(i, n) {
		int amari = (k - (i % k)) % k;
		ll b = num[amari], c = num[amari];
		if ((amari + amari) % k == 0) ans += b * c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int H, W;
vector<vector<char>> fi(1010, vector<char>(1010, '#'));
vector<vector<ll>> dp(1010, vector<ll>(1010, 0));


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

    cin >> H >> W;
    repr(i, 1, H+1) repr(j, 1, W+1) cin >> fi[i][j];
    dp[H][W]=1;

    reprrev(i, 1, H+1) reprrev(j, 1, W+1){
        if(i==H && j==W) continue;
        if(fi[i][j]=='#') continue;
        if(i+1<=H) dp[i][j] += dp[i+1][j];
        if(j+1<=W) dp[i][j] += dp[i][j+1];
        chmod(dp[i][j]);
    }

    cout << dp[1][1] << endl;
    
    return 0;
}


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

whether_dict = {'Sunny': 1, 'Cloudy': 2, 'Rainy': 3}

s = input()

a = whether_dict[s] + 1

if a > 3:
    print('Sunny')
elif a == 2:
    print('Cloudy')
elif a == 3:
    print('Rainy')
    



Measured memory_bytes: 2940
while(True):
    sc = input().split()
    m = int(sc[0])
    f = int(sc[1])
    r = int(sc[2])
    if (m == -1) and (f == -1) and (r == -1):
        break;
    if (m == -1) or (f == -1):
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif (m + f >= 50) or ((m + f >= 30) and (r >= 50)):
        print('C')
    elif m + f >= 30:
        print('D')
    else:
        print('F')


Measured memory_bytes: 5596
n = int(input())

min_x = 10 ** 9
max_x = -(10 ** 9)
min_y = 10 ** 9
max_y = -(10 ** 9)

for i in range(n):
    a, b = map(int, input().split())
    x = a + b
    y = a - b
    min_x = min(min_x, x)
    max_x = max(max_x, x)
    min_y = min(min_y, y)
    max_y = max(max_y, y)

print(max(max_x - min_x, max_y - min_y))

Measured memory_bytes: 9140
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 - 1 << endl;
	}
	else {
		cout << n / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Bin_Search(vector<long long> &ans,long long k)
{
    int n = ans.size();
    int lo = 0;
    int hi = n-1;
    int sol = -1;
    while(lo<=hi)
    {
        int mid = (lo+hi)/2;
        if(ans[mid]<=k)
        {
            sol = mid;
            lo = mid+1;
        }
        else
        {
            hi = mid-1;
        }
    }
    return sol+1;
}
int main()
{
    long long n,m,k;
    cin>>n>>m>>k;
    vector<long long> A(n);
    vector<long long> B(m);
    for(int i=0;i<n;i++)
        cin>>A[i];
    for(int i=0;i<m;i++)
        cin>>B[i];
    vector<long long> pref_A(n);
    vector<long long> pref_B(m);
    pref_A[0] = A[0];
    pref_B[0] = B[0];
    for(int i=1;i<n;i++)
    {
        pref_A[i] = pref_A[i-1] + A[i];
    }
    for(int i=1;i<m;i++)
    {
        pref_B[i] = pref_B[i-1] + B[i];
    }
    int ans = Bin_Search(pref_B,k);
    for(int i=0;i<n;i++)
    {
        if(pref_A[i]>k)
        {
            break;
        }
        ans = max(ans,i+1+Bin_Search(pref_B,k-pref_A[i]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9604
#include <iostream>
#include <map>

using namespace std;

int main() {
    map<char, char> helix;
    helix['A'] = 'T';
    helix['C'] = 'G';
    helix['G'] = 'C';
    helix['T'] = 'A';

    char c;
    cin >> c;
    cout << helix[c] << "\n";
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	map<int, int> mp1, mp2;
	//mp1[0] = 1;
	//mp2[0] = 1;

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		int A; cin >> A;
		ans += mp1[A-i];
		//ans += mp2[A+i];
		mp1[-A-i]++;
		//mp2[-A+i]++;
	}
	cout << ans << el;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 20668