akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

const int N_MAX=144,T_MAX=6;
int Dreyfus_Wagner(int n,int d[N_MAX][N_MAX],int nt,int *t){
	rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

	static int dp[1<<T_MAX][N_MAX];
	rep(S,1<<T_MAX) rep(i,n) dp[S][i]=INF;
	rep(i,nt) rep(j,n) dp[1<<i][j]=d[t[i]][j];

	rep(S,1<<nt) if(S && S&S-1) { // |S|>=2
		for(int T=S-1&S;T;T=T-1&S) rep(p,n) {
			rep(q,n) dp[S][p]=min(dp[S][p],d[p][q]+dp[T][q]+dp[S&~T][q]);
		}
	}

	return dp[(1<<nt)-1][t[0]];
}

int main(){
	for(int h,w;scanf("%d%d",&h,&w),h;){
		int d[N_MAX][N_MAX];
		rep(i,h) rep(j,w) rep(y,h) rep(x,w) d[i*w+j][y*w+x]=(i==y&&j==x?0:INF);

		int n=0,heart[6];
		rep(i,h) rep(j,w) {
			int choco; scanf("%d",&choco);
			if(choco) heart[n++]=i*w+j;
			rep(k,4){
				int y=i+dy[k],x=j+dx[k];
				if(0<=y && y<h && 0<=x && x<w) d[i*w+j][y*w+x]=1;
			}
		}

		printf("%d\n",h*w-Dreyfus_Wagner(h*w,d,n,heart)-1);
	}

	return 0;
}

Measured memory_bytes: 880
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class C {
	int n;
	vector<vector<int>> info;
public:
	C()
	{
		cin >> n;
		info.resize(n, vector<int>(3));

		REP(i, n)
			cin >> info[i][0] >> info[i][1] >> info[i][2];

	}
	void solve()
	{
		REP(i, n)
		{
			int t{ 0 };

			for (int j{ i }; j < n - 1; j++)
			{
				if (t < info[j][1])
					t = info[j][1];
				else
					t = info[j][1] + (t - info[j][1] + info[j][2] - 1) / info[j][2] * info[j][2];
				t += info[j][0];
			}

			cout << t << endl;

		}

	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    unsigned long long int a, b, x;
    cin >> a >> b >> x;
    if (a%x != 0)
        cout << b/x - a/x << endl;
    else
        cout << b/x - a/x + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
iN = int(input())
#aR = [(i,[int(_) for _ in input().split()]) for i in range(iN)]
#aB = [(i,[int(_) for _ in input().split()]) for i in range(iN)]
aR = sorted([[int(_) for _ in input().split()] for i in range(iN)],key=lambda x:x[1])
aB = sorted([[int(_) for _ in input().split()] for i in range(iN)])

dDicided = set()
for bx,by in aB:
    dCand = []
    for i,[rx,ry] in enumerate(aR):
        if i in dDicided:
            continue
        if bx > rx and by > ry:
            dCand.append([ry,i])
    if dCand != []:
        dDicided.add(sorted(dCand ,reverse=True)[0][1])

print(len(dDicided))


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        String s = buffer.readLine();
        if (s.charAt(s.length()-1)=='s')
            System.out.println(s+"es");
        else
            System.out.println(s+'s');
    }
}


Measured memory_bytes: 36264
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll D;
    cin >> D;

    vector<ll> c(26);
    ll sum_c = 0;
    rep(0, i, 26)
    {
        cin >> c.at(i);
        sum_c += c.at(i);
    }

    vector<vector<ll>> s(D, vector<ll>(26, 0));
    rep(0, i, D)
    {
        rep(0, j, 26)
        {
            cin >> s.at(i).at(j);
        }
    }

    ll score = 0, dec = 0; // i日目のスコア、スコアの減少量
    vector<ll> t(D), last(26, 0), ans(D, 0);
    rep(0, i, D)
    {
        // 今日開くコンテストと得られる満足度
        ll today_i = 0, today_score = 0;
        // i日目に各コンテストを開催したと仮定して満足度を求める
        rep(0, j, 26)
        {
            ll sum = s.at(i).at(j);
            sum = sum - (dec + sum_c - (c.at(j) * (last.at(j) + 1)));
            if (score + today_score < score + sum)
            {
                today_i = j;
                today_score = sum;
            }
        }

        // ループが終了したら今日開くコンテストが決まるので、last(d,i)を更新する
        rep(0, j, 26)
        {
            last.at(j) += 1;
        }
        last.at(today_i) = 0;

        // decの更新
        dec = 0;
        rep(0, j, 26)
        {
            dec += c.at(j) * last.at(j);
        }

        // scoreの更新
        score += today_score;

        // 答え
        t.at(i) = today_i + 1;
        ans.at(i) = score;
    }

    rep(0, i, D)
    {
        cout << t.at(i) << endl;
    }
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1; i<=n; ++i){
        int x; cin>>x;
        a[x]=i;
    }
    for(int i=1; i<=n; ++i){
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main() {
    int N; scanf("%d",&N);
    vector<int> a, b;
    for(int i=0; i<N; i++) {
        int foo; scanf("%d",&foo);
        if(i%2) a.push_back(foo);
        else b.push_back(foo);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    vector<pii> as, bs;
    {
        int c, p = -1;
        for(auto& it: a) {
            if(p != it) {
                if(p != -1) as.push_back({c, p});
                p = it;
                c = 1;
            }
            else ++c;
        }
        as.push_back({c, p});
    }
    {
        int c, p = -1;
        for(auto& it: b) {
            if(p != it) {
                if(p != -1) bs.push_back({c, p});
                p = it;
                c = 1;
            }
            else ++c;
        }
        bs.push_back({c, p});
    }

    sort(as.begin(), as.end()); reverse(as.begin(), as.end());
    sort(bs.begin(), bs.end()); reverse(bs.begin(), bs.end());
    as.push_back({0, 1e9}); bs.push_back({0, 1e9});

    if(as[0].second == bs[0].second)
        printf("%d", min(N - as[0].first - bs[1].first, N - as[1].first - bs[0].first));
    else
        printf("%d", N - as[0].first - bs[0].first);
    return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <string.h>
#include <algorithm>

using namespace std;

int N;
int main(){
    cin >> N;
    vector<int> d(N);
    vector<int> c;
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    int cnt;
    int pnt;
    sort(d.begin(),d.end(),greater<int>());

    for(int i = 0; i < N; i++){
        cnt = 0;
        pnt = d[i];
        for(int j = 0; j < N; j++){
            if(pnt > d[j]){
                cnt++;
                pnt = d[j];
            } 
        }
      //  cout << cnt << endl;
        c.push_back(cnt);
    }

    int max = 0;
    for(int i = 0; i < N; i++){
        if(max < c[i]) max = c[i];
       // cout << max << endl;
    }

    cout << max+1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N;

void solve() {
    if (N % 2 == 1) {
        cout << 0 << endl;
    } else {
        int M = N / 2;
        int ans = 0;
        int tmp = 1;
        while (M >= 5) {
            ans += tmp * (int)(M / 5);
            M /= 5;
        }
        cout << ans << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#define N 100010
using namespace std;
struct Dis{
	int x,z;
};
queue<Dis>Q;
int a[N],c[N],d[N],e[N],f[N],num,h[N],n,m,p,q,t,col;
bool bo[N];
struct Edge{
	int p,q,n;
}b[N*2];
void ljb(int p,int q){
	b[++num].n=h[p];
	h[p]=num;
	b[num].p=p;
	b[num].q=q;
}
void Bfs(){
	int x,y,z;
	while(!Q.empty()){
		x=Q.front().x; z=Q.front().z; Q.pop(); 
//		printf("%d %d\n",x,z);
		if(!f[x])f[x]=col;
		e[x]=max(e[x],z);
		if(z==0)continue;
		for(int i=h[x];i!=0;i=b[i].n){
			y=b[i].q;
			if(e[y]<z-1)Q.push((Dis){y,z-1});
		}
	}
}
int main(){
	memset(e,-1,sizeof(e));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&p,&q);
		ljb(p,q);
		ljb(q,p);
	}
	scanf("%d",&t);
	for(int i=1;i<=t;i++)scanf("%d%d%d",&a[i],&d[i],&c[i]);
	for(int i=t;i>=1;i--){
		if(e[a[i]]>=d[i])continue;
		col=c[i];
		Q.push((Dis){a[i],d[i]});
		Bfs();
	}
//	for(int i=1;i<=n;i++)printf("%d %d\n",i,e[i]);
	for(int i=1;i<=n;i++)printf("%d\n",f[i]);
}

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

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

#define mp make_pair
#define pb push_back
#define put(x) { cout << #x << " = "; cout << (x) << endl; }

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef double db;

const ll M = 1e6 + 15;
const ll Q = 1e9 + 7;

inline ll mult(ll a, ll b) { return ll(((1LL * a * b) % Q + Q) % Q); }
inline ll sum(ll a, ll b) { return a + b >= Q ? a + b - Q : a + b; }
void inc(ll &a, ll b) { a = sum(a, b); }
void dec(ll &a, ll b) { a = (a - b >= 0 ? a - b : a - b + Q); }

ll dp[2 * M];



int main() {
    srand(time(NULL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);


	ll n;
	cin >> n;
	for (ll i = n + 1; i < 2 * n; i++) dp[i] = 1;
	dp[n] = n;
	dp[n - 1] = mult(n, n);
	ll su = 0;
	for (ll i = n + 1; i < 2 * n; i++) inc(su, dp[i]);
	for (ll i = n - 2; i >= 1; i--) {
//	cout << i << " " << su << endl;
		inc(dp[i], dp[i + 1]);
		inc(dp[i], mult(n - 1, n - 1));
		inc(dp[i], su);
//		cout << "+" << dp[i + 2] << endl;
		inc(su, dp[i + 2]);
//		cout << "-" << dp[i + n + 1] <<endl;
		dec(su, dp[i + n + 1]);
	}
//	for (int i = 1; i < 2 * n; i++) cout << dp[i] << endl;
	cout << dp[1] << endl;

	 return 0;
}   

Measured memory_bytes: 15872
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

A,B,C = I()
if max(A,B,C) == A:
    print(A*10+B+C)
elif max(A,B,C) == B:
    print(B*10+A+C)
else:
    print(C*10+A+B)

Measured memory_bytes: 10096
import java.util.*;
public class Main {
	public static void main(String[] args){
	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> W = new ArrayList<>();
	    for (int i = 0; i < N; i++) {
	      W.add(sc.nextInt());
	    }
		sc.close();

		Integer A = 0;
		Integer B = 0;

		while (W.size() != 0) {
			if(A < B){
				A += W.get(0);
				W.remove(0);
			} else {
				B += W.get(W.size() - 1);
				W.remove(W.size() - 1);
			}
		}
		
		System.out.println(Math.abs(A-B));
	
	}
}

Measured memory_bytes: 22996
n = int(input())
p = list(map(int, input().split()))

if p == sorted(p):
    print("YES")
    exit()
else:
    for i in range(n):
        for j in range(n):
            if i != j:
                q = p.copy()
                q[i], q[j] = q[j], q[i] 
                if q == sorted(q):
                    print("YES")
                    exit()

print("NO")

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var val = Console.ReadLine();
        while (val.IndexOf("hi", StringComparison.Ordinal) == 0)
        {
            val = val.Replace("hi", "");
        }
        Console.WriteLine(val.Length > 0 ? "No" : "Yes");
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int f(int n){
    if(n % 2 == 0){
        return n / 2;
    }
    else {
        return 3 * n + 1;
    }
}

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

    int x; cin >> x;
    const int M = 1000000;
    vi used(M+1);

    int res = 1;
    do {
        if(used[x]){
            cout << res << endl;
            break;
        }
        used[x] = true;
        x = f(x);
        res++;
    } while(1);

    return 0;
}


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

int a[20][20], n;

int main(){

    cin >> n;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++)
            a[i][j] = -1;
        int sz;
        cin >> sz;
        for (int j = 1; j <= sz; j++){
            int x, y;
            cin >> x >> y;
            a[i][x] = y;
        }
    }
    int ans = 0;
    for (int mask = 1; mask < (1<<n); mask++){
        bool bb = 1;
        for (int i = 0; i < n; i++){
            if (!(mask & (1<<i)))
                continue;
            for (int j = 0; j < n; j++){
                if (a[i+1][j+1] == -1)
                    continue;
                int kek = ((mask & (1<<j)) != 0);
                if (a[i+1][j+1] != kek){
                    bb = 0;
                    break;
                }
            }
            if (bb == 0){
                break;
            }
        }
        if (bb)
            ans = max(ans, __builtin_popcount(mask));
    }
    cout << ans;

}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
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; }

ll ngcd(const vector<ll>& a){
  ll res;
  res = a[0];
  for(int i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
ll nlcm(const vector<ll>& numbers) {
  ll res;
  res = numbers[0];
  for (int i = 1; i < numbers.size(); i++) {
    res = lcm(res, numbers[i]);
  }
  return res;
}

int main() {
  int k;
  cin >> k;

  ll res = 0;
  for(int a = 1; a <= k; a++) {
    for(int b = 1; b <= k; b++) {
      for(int c = 1; c <= k; c++) {
        vector<ll> v = {a, b, c};
        res += ngcd(v);
      }
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n;
double xp1,xp2,xp3,xp4,yp1,yp2,yp3,yp4,xu,xw,xv,yu,yw,yv,k;
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lf%lf%lf%lf",&xp1,&yp1,&xp2,&yp2);
		scanf("%lf%lf%lf%lf",&xp3,&yp3,&xp4,&yp4);
		xu=xp1-xp3;
		yu=yp1-yp3;
		xv=xp2-xp1;
		yv=yp2-yp1;
		xw=xp4-xp3;
		yw=yp4-yp3;
		k=abs((xw*yu-xu*yw)/(xw*yv-xv*yw));
		printf("%.8lf %.8lf\n",xp1+xv*k,yp1+yv*k);
	}
}


Measured memory_bytes: 3248
// why am I so weak
#include<bits/stdc++.h>
using namespace std;
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define pb             emplace_back
#define mp             make_pair
#define F              first
#define S              second
#define rep(i, x)      for (__typeof(x) i = 0; i < x; i++)
#define repp(i, x, y)  for (__typeof(x) i = x; i < y; i++)
#define all(a)         (a).begin(),(a).end()
#define sz(x)          (int)x.size()
#define endl           '\n'
#define DB(x)          cerr << #x << " is " << x << endl;
#define TEST(T)        int T; cin >> T; rep(_i, T)
#define MOD            1000000007
typedef long long          ll;
typedef vector<int>        vi;
typedef vector<ll>         vl;
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pll;
typedef vector<pii>       vii;
typedef vector<pll>       vll;
typedef set<int>           si;

int main(){ _
    int x; cin >> x;
    if (x < 1200) cout << "ABC";
    else cout << "ARC";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int N;
ll K;
// vector<int> a(N),f(N);
ll a[200010],f[200010];

bool ok(ll mid) {
  ll cnt = 0;
  rep(i,N) {
    if(f[i]*a[i] <= mid) continue;
    cnt += (f[i]*a[i] -mid - 1)/f[i] + 1;
  }
  return (cnt <= K);
}

ll bi_search() {
  ll l = -1,r = 10000000000000,mid;
  while(r-l>1) {
    mid = (r+l)/2;
    // cout<<mid<<endl;    
    if(ok(mid)) r = mid;
    else l = mid;
  }
  return r;
}

int main() {
  cin>>N>>K;
  // a = vector<int>();
  // f = vector<int>();
  rep(i,N) cin>>a[i];
  rep(i,N) cin>>f[i];
  sort(a,a+N);
  sort(f,f+N);
  reverse(f,f+N);
  ll ans = bi_search();
  cout<<ans<<endl;
}


Measured memory_bytes: 6796
// A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 220;

typedef long long ll;

int T, n;
ll base[MAX_N], ai[MAX_N];
char str[MAX_N];

void insert(ll x)
{
    for (int i = 62; i >= 0; i--)
        if (x & (1LL << i))
        {
            if (base[i] == 0)
            {
                base[i] ^= x;
                break;
            }
            x ^= base[i];
        }
}

bool query(ll x)
{
    for (int i = 62; i >= 0; i--)
        if (x & (1LL << i))
            x ^= base[i];
    return x == 0;
}

int main()
{
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        for (int i = 1; i <= n; i++)
            scanf("%lld", &ai[i]);
        scanf("%s", str + 1);
        for (int i = 0; i <= 62; i++)
            base[i] = 0;
        bool flag = false;
        for (int i = n; i >= 1; i--)
        {
            if (str[i] == '0')
                insert(ai[i]);
            else if (!query(ai[i]))
            {
                flag = true;
                break;
            }
        }
        puts(flag ? "1" : "0");
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    string s;
    cin >> N >> s;
    int cntE[N + 1];
    int cntW[N + 1];
    fill(cntE, cntE + N + 1, 0);
    fill(cntW, cntW + N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        if (s[i - 1] == 'E')
        {
            cntE[i] = cntE[i - 1] + 1;
            cntW[i] = cntW[i - 1];
        }
        else
        {
            cntW[i] = cntW[i - 1] + 1;
            cntE[i] = cntE[i - 1];
        }
    }
    int ans = 10000000;
    int tmp = 0;
    for (int i = 0; i <= N; i++)
    {
        tmp = cntW[i] + cntE[N] - cntE[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6132
#include <iostream>
#include <iomanip>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <list>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <ctime>
#include<numeric>


using namespace std;
#define vec vector
#define pb push_back
#define en '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pull;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef long double ld;
typedef pair<ld, int> pli;
typedef unsigned int ui;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vi2;
typedef vector<vector<ll>> vll2;
typedef vector<vector<ll>> matrix;
typedef vec<vec<vec<int>>> vi3;

#define _DEBUG

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);
#pragma warning(disable : 4996)
/*
 #pragma GCC optimize("Ofast")
 #pragma GCC target("avx,avx2,fma")
 */
const int inf = 2e9;
const ll linf = 2e18;
const ld LDINF = 2e18;


void solve()
{
	ll mod = 1e9 + 7;
	ll n;
	cin >> n;
	vector<vector<ll>> dp(n+1, vector<ll>(4, 0));
	dp[0][0] = 1;
	//cout << dp[0][0] << " " << dp[0][1] << " " << dp[0][2] << " " << dp[0][3] << en;
	for1(i, n + 1) {
		dp[i][1] = (dp[i - 1][0] + dp[i-1][1] * 9)%mod;
		dp[i][2] = (dp[i - 1][0] + dp[i-1][2] * 9)%mod;
		dp[i][0] = dp[i - 1][0] * 8 % mod;
		dp[i][3] = (dp[i - 1][3] * 10 + dp[i - 1][1] + dp[i - 1][2]) % mod;
		//cout << i << en;
		//cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << en;
	}
	cout << dp[n][3];
}


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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
	return 0;
}

Measured memory_bytes: 73300
#include <iostream>

using namespace std;

int main(){
	int M, D;
	cin >> M >> D;

	int ans = 0;
	int d_1, d_10;
	
	for (int i = 4; i <= M; i++){
	    for(int d_ini = 22; d_ini <= D; d_ini++){
    		
    		d_10 = d_ini / 10;
    		d_1 = d_ini % 10;
    		
    		if (d_1 * d_10 == i && d_1 >1) ans++;
	    }   
	}

	

	cout << ans << endl;

}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n;cin>>n;
    VL a(5);
    REP(i,5){
        cin>>a[i];
    }

    LL result = 0;
    LL neck = INF_LL;
    result = (n+a[0]-1)/a[0];
    neck = min(neck,a[0]);

    FOR(i,1,5){
        if(a[i] >= neck){
            result ++ ;
        }
        else{
            LL time = (n+neck-1)/neck - 1;
            LL nokori = n - time*a[i];
            result += (nokori + a[i] - 1)/a[i];
        }

        neck = min(neck,a[i]);
    }


    cout<<result<<endl;


    
	return;
}

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

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int n,m;
pair<int,int> gates[100005];
pair<int,int> ans;
int32_t main(){
	cin>>n>>m;
	ans = {1,n};
	for(int i=1;i<=m;i++){
		cin>>gates[i].first>>gates[i].second;
		ans = {max(ans.first,gates[i].first),min(ans.second,gates[i].second)};
	}
	if(ans.second-ans.first<0) cout<<0;
	else cout<<ans.second-ans.first+1;
}


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

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    int ans(0),prev(0);
    rep(i,n){
        if(prev < v[i]) ++ans;
        prev = v[i];
    }
    cout << ans << endl;
    return 0;    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
long n,i,j,m;
string s,t;
cin>>n;
for(i=0;i<n;i++){
cin>>s;
m=s.size();t=s[0];
for(j=0;j*3+3<m;j++){
if(t.find(s[j*3+3])==string::npos){
if(s[j*3+2]=='>')t+=s[j*3+3];
else t.insert(0,1,s[j*3+3]);
}
}
cout<<t<<endl;
}
return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>

int main(void){
  int i,j;
  int hand[5];
  int tmp,flag;
  int pair,three,four;

  while(1){
    if(scanf("%d,",&hand[0])==EOF)break;
    for(i=1;i<5;i++)scanf("%d,",&hand[i]);

    for(i=0;i<4;i++){
      for(j=i+1;j<5;j++){
	if(hand[i]>hand[j]){
	  tmp = hand[i];
	  hand[i] = hand[j];
	  hand[j] = tmp;
	}
      }
    }

    pair = 0;
    three = 0;
    four = 0;

    j = 1;
    for(i=0;i<4;i++){
      while(hand[i] == hand[j]){
	j++;
	if(j==5)break;
      }

      if(j - i == 2)pair++;
      if(j - i == 3)three++;
      if(j - i == 4)four++;

      i = j-1;
      j++;
    }

    flag = 0;
    if(four){
      printf("four card\n");
      flag = 1;
    }else if(three){
      if(pair){
	printf("full house\n");
	flag = 1;
      }else{
	printf("three card\n");
	flag = 1;
      }
    }else if(pair){
      if(pair == 1){
	printf("one pair\n");
	flag = 1;
      }else{
	printf("two pair\n");
	flag = 1;
      }
    }else{
      if(hand[4]-hand[3] == 1){
	if(hand[3]-hand[2] == 1){
	  if(hand[2]-hand[1] == 1){
	    if(hand[1]-hand[0] == 1){
	      printf("straight\n");
	      flag = 1;
	    }else if(hand[0] == 1){
	      if(hand[1] == 10){
		if(hand[2] == 11){
		  if(hand[3] == 12){
		    if(hand[4] == 13){
		      printf("straight\n");
		      flag = 1;
		    }
		  }
		}
	      } 
	    }
	  }
	}
      }
    }

    if(!flag)printf("null\n");

  }

  return 0;
}

Measured memory_bytes: 0
import bisect
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
x = bisect.bisect_left(p,a+1)
y = bisect.bisect_left(p,b+1)
one = p[:x]
two = p[x:y]
three = p[y:]
print(min(len(one),len(two),len(three)))

Measured memory_bytes: 3064
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if A[i]==A[i+1]-1:
        ans += C[A[i]-1]
ans += sum(B)
print(ans)


Measured memory_bytes: 3060
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = [0, 0]
for i in range(N - 1):
    if ans[0] < A[i + 1] - A[i]:
        ans = [A[i + 1] - A[i], i]
if (K - A[-1]) + A[0] > ans[0]:
    ans = [(K - A[-1]) + A[0], 0]
print(K - ans[0])


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

typedef long long ll;

const int N = 2e5;
int n, h[N];

ll dp[N];

ll calc(int i) {
    if(i == n - 1) return 0;
    if(dp[i] != -1) return dp[i];
    ll res = 1e15;
    fore(j, i + 1, min(n, i + 3)) {
        res = min(res, abs(h[j] - h[i]) + calc(j));
    }
    dp[i] = res;
    return res;
}
int main() {
    cin >> n;
    fore(i, 0, n) cin >> h[i];
    memset(dp, -1, sizeof dp);
    cout << calc(0) << endl;
    return 0;
}

// https://codeforces.com/group/KwBzUrrGrr/contest/243386/problem/C


Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int main(){
    int x, y, a;
    cin >> x >> y;
    while(x != 0 || y != 0){
        if(x > y){
            a = x;
            x = y;
            y = a;
        }
        cout << x << " " << y << endl;
        cin >> x >> y;
    }

    return 0;
}


Measured memory_bytes: 3068
use std::io::Read;

fn normalize(s: &str) -> String {
    let mut c = s.chars().collect::<Vec<char>>();
    c.sort();
    return c.into_iter().collect();
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut s: Vec<String> = (0..n)
        .map(|_| iter.next().unwrap())
        .map(|s| normalize(&s))
        .collect();
    s.sort();
    let mut current = String::from("");
    let mut cnt: i64 = 0;
    let mut ans: i64 = 0;
    for c in s {
        if c.eq(&current) {
            cnt += 1;
        } else {
            current = c;
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }
    ans += cnt * (cnt - 1) / 2;
    println!("{}", ans);
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	double n, d;
	cin >> n >> d;
	cout << ceil(n / (2 * d + 1)) << '\n';

	return 0;
}

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

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

    string s;
    cin >> s;

    int ans = 1;
    char che = s[0];

    for(int i = 1; i < n; i++){
        if(s[i] != che){
            che = s[i];
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toLong()

    // 5000兆 -> 5 x 10^15

    // 先頭に１があってそれを使う場合 or 長さが１の場合
    if (s.length == 1) {
        println(s[0])
        return
    }

    // WA 同じ数字が何回でも出て良い -> １が連続するケース を考慮漏れ
//    if (s.first() == '1') {
//
//        if (k == 1L) {
//            println(s.first())
//            return
//        }
//
//        println(s[1])
//        return
//    }
//
//    println(s[0])

    // ケース分類
    // 12 : 1が最初だけ -> 12222222222222222・・・
    // 11112 : 1が複数最初からつながる -> 1111222222222222222222222・・・
    // 23 : １以外が最初にある -> 22222222222222222・・・
    // 2 : 一文字 -> 22222222222222・・・

    // -> 最初の状態で k or 最後の文字目までに 1 以外を見つけたらそれを出力，なければ１を出力

    for (i in 0 until k) {
        if (s[i.toInt()] != '1') {
            println(s[i.toInt()])
            return
        }

        if(i.toInt() == (s.length-1)){
            break
        }
    }

    println(1)
}

Measured memory_bytes: 33664
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

long long factorial(long long i){ // 階乗
  if(i > 0)
    return i * factorial(i-1);
  else
    return 1;
}

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

// a^(-1) mod
long long modinv(long long a, long long mod) {
  return modpow(a, mod-2, mod);
}

int main() {
  long long Q;
  const long long mod = 1000003;
  
  cin >> Q;
  
  // あらかじめ必要な階乗(mod)を計算しておく
  vector<long long> factmod;
  factmod.push_back(1); // 0! = 1
  long long tmp = 1;
  for(int i=1; i<2*mod+10; i++) { // 1000003!(mod 1,000,003) まで計算しておく ちょっと多めに
    tmp = (tmp*i)%mod;
    factmod.push_back(tmp);
  }
  
  long long ans = 1;
  rep(i, Q) {
    long long x, d, n;
    cin >> x >> d >> n;
    
    if(d!=0) {
      // 求める積は d^n * (x/d) * (x/d + 1) * ... * (x/d + (n-1))
      // つまり d^n * (x/d + (n-1))! / (x/d - 1)!
      long long xbyd = x * modinv(d, mod) %mod; // x/d (mod)
      if(xbyd+n-1 > mod) {
        // x/d+n-1 が modより大きい時 (x/d + (n-1))! がゼロになる．
        ans = 0;
      } else {
		if(xbyd==0) xbyd += mod; // xbyd-1 が負になるのを防ぐ
        ans = modpow(d, n, mod) * factmod[xbyd+n-1] %mod * modinv(factmod[(xbyd-1)%mod], mod) %mod;
      }
    } else { // d = 0
      // 求める積は x^n
      ans = modpow(x, n, mod);
    }

    if(ans<0) ans += mod;
    cout << ans << endl;
  }
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 300500;

int n, m, a[N], b[N], cnt[N], ans;

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

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;

	cin >> n >> m;

	for(int i = 1; i <= n; ++i){
		cin >> a[i] >> b[i];
		cnt[a[i]]++, cnt[b[i]]++;
	}	

	for(int i = 1; i <= n; ++i)
		ans = (ans + cnt[i] % 2);

	if(ans)
		cout << "NO";
	else cout << "YES";

	return 0;
}

Measured memory_bytes: 1408
/*Largest Independent Set Problem

Definindo que dp[atual][0] é o máximo do vértice PRETO atual e
que dp[atual][1] é o máximo do vértice BRANCO atual (como exercício).

Percorrer os vértices recursivamente até a raiz e ir calculando
o máximo permitido no PRETO e BRANCO. O resultado final será
a soma do máximo deles.

Restrições:

PRETO: todos os seus filhos (ou vértices ligados) precisam ser BRANCOS! (evento dependente)
BRANCO: a cor de qualquer um dos seus filhos (vértices) NÃO IMPORTA! (evento independente)

*Eventos Dependentes: multiplicação
*Eventos Independentes: soma e multiplicação
*/

#include <bits/stdc++.h>

#define MAX 100003
#define MODULO 1000000007

using namespace std;

vector<int> grafo[MAX];
long long dp[MAX][2]; //valores das colunas -> 0 - PRETO e 1 - BRANCO 
long N;

//Semelhante ao conceito de DFS: marcar os visitados na matriz e percorrer recursivamente
void LIS(int vAtual, int vPosterior){

    dp[vAtual][0] = dp[vAtual][1] = 1; //Visitado

    //Percorrendo o grafo
    for(int i = 0; i < grafo[vAtual].size(); i++){
        int elemento = grafo[vAtual][i];
        
        if(elemento != vPosterior){
            //DFS
            LIS(elemento, vAtual);

            //PRETO
            dp[vAtual][0] = dp[vAtual][0] * dp[elemento][1] % MODULO;

            //BRANCO
            dp[vAtual][1] = dp[vAtual][1] * ((dp[elemento][0] + dp[elemento][1]) % MODULO) % MODULO;
        }
    }
}

int main(){

    cin >> N;

    for(long i = 1; i < N; i++){
        long valor1, valor2;
        cin >> valor1 >> valor2;

        grafo[valor1].push_back(valor2);
        grafo[valor2].push_back(valor1);
    }

    //Vértice de Início = 1
    LIS(1, 0);

    //Os resultados são armazenados nas primeiras posições do grafo (recursão)
    cout << (dp[1][0] + dp[1][1]) % MODULO << endl;
    
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    rep (i, N)
        cin >> x[i];
    rep (i, M)
        cin >> y[i];

    int xmax = *max_element(all(x));
    int ymin = *min_element(all(y));

    if (xmax < ymin and X <= xmax and ymin <= Y)
        print("No War");
    else
        print("War");

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}



int main(){
    int d,t,s;cin >> d >> t  >>s;
    if(d<=t*s)cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;

}



Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N, M;
  cin >> N >> M;
  vll A(N);
  rep(i, N) {
    cin >> A[i];
  }
  
  //累積和の余りを求める！余りのパターン数は，高々M通り！
  vll B(N+1);
  unordered_map<int, vector<int>> mp;
  rep(i, N) {
    B[i+1] = B[i] + A[i];
  }
  
  rep(i, N + 1) {
    ll m = B[i] % M;
    if(mp.find(m) == mp.end()) {
      mp.emplace(m, vector<int>());
    }
    mp[m].push_back(i);
  }
  
  ll sum = 0;
  rep(i, N) {
    //B[i]と余りが等しい個数をカウント
    //一つ先以降の数とする．
    ll m = B[i] % M;
    //B[i]と余りが等しく，iより後のインデックスの数を求める
    auto found = upper_bound(all(mp[m]), i);
    auto diff = (mp[m].end() - found);
    sum += diff;
  }
  
  fin(sum);
  
  
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int a, b;
  cin >> a >> b;
  string res;
  if(a > 0) {
    res = "Positive";
  }else if(a == 0) {
    res = "Zero";
  }else if(b >= 0) {
    res = "Zero";
  }else if(b < 0) {
    if((b - a) % 2 == 1) res = "Positive";
    else res = "Negative";
  }
  cout << res << 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);
    int N=sc.nextInt();
    int max=0;
    for(int i=0;i*i<=N;i++){
        max=i*i;
    }
    System.out.println(max);
    
    
    }
}

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

using namespace std;
char mp[105][105];
int flag[105][105];

int main()
{
    memset(flag,0,sizeof(flag));
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            cin>>mp[i][j];
    for(int i=1; i<=n; i++)
        for(int j=2; j<=m; j++)
        {
            if(mp[i][j] == '#')
            {
                if(mp[i][j-1] == '#')
                {
                    flag[i][j] = 1;
                    flag[i][j-1] = 1;
                }
            }
        }
    for(int j=1; j<=m; j++)
        for(int i=2; i<=n; i++)
        {
            if(mp[i][j] =='#')
                if(mp[i-1][j] == '#')
                {
                    flag[i][j] = 1;
                    flag[i-1][j] = 1;
                }
        }
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
        {   if(mp[i][j] == '#')
            if(flag[i][j] == 0)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256