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

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

        int N;
        std::cin >>  N;

        for(int i = 1; i <= 9; i++)
        {
                if(N % i == 0)
                {
                        if(N / i <= 9)
                        {
                                std::cout << "Yes" << std::endl;
                                return 0;
                        }
                }
        }
        std::cout << "No" << std::endl;

        return 0;
}


Measured memory_bytes: 256
/***
 **   A S M Atikur Rahman
 **   Update: 17-12-2019
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}




int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);
    double l,ans;
    scd(l);
    l=l/3;
    ans=pow(l,3);
    pfd(ans),pn;





    return 0;
}
























Measured memory_bytes: 384
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;

int main(){
	char str[1200];
	int j;
	cin.getline(str, 1200);
	size_t len = strlen(str);
	
	for(j = 0; j <= len-1; j++){
		if(islower(str[j]) != 0){
			str[j] = toupper(str[j]);
			// continue;
		}
		else if(isupper(str[j]) != 0){
			str[j] = tolower(str[j]);
			// continue;
		}
	}
	
	for(j = 0; j <= len-1; j++){
		cout << str[j];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1124
import java.util.*;
import java.util.Arrays;

public class Main {
    public static long[][] memo;
    public static long INF = -1;
    public static long[][] point_list;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        memo = new long[N][3];
        for (int i = 0; i<N; i++) {
            Arrays.fill(memo[i], INF);
        }
        //System.out.println(memo[1][1]);
        point_list = new long[N][3];
        for (int i=0; i<N; i++) {
            for (int j=0; j<3; j++){
                point_list[i][j] = sc.nextInt();
            }
        }
        long[] ans_list = tilAns(N-1);
        long ans = INF;
        for (int i=0; i<3; i++){
            if (ans_list[i] > ans) {
                ans = ans_list[i];
            }
        }
        System.out.println(ans);
        //Sy)stem.out.println(point_list[0][1]);
        
    }
    public static long[] tilAns(int n) {
        if (memo[n][0] != INF) {
            return memo[n];
        }
        if (n == 0) {
            for (int i = 0; i<3; i++) {
                memo[0][i] = point_list[0][i];
            }
            return memo[0];
        }
        
        memo[n][0] = Math.max(tilAns(n-1)[1] + point_list[n][0], tilAns(n-1)[2] + point_list[n][0]);
        memo[n][1] = Math.max(tilAns(n-1)[0] + point_list[n][1], tilAns(n-1)[2] + point_list[n][1]);
        memo[n][2] = Math.max(tilAns(n-1)[0] + point_list[n][2], tilAns(n-1)[1] + point_list[n][2]);
        return memo[n];
    }
}


Measured memory_bytes: 82452
N = int(raw_input())
P = map(int, raw_input().split())

ans = 0
for i in xrange(1, N-1):
    if P[i] > P[i-1] and P[i] < P[i+1]:
        ans += 1
    elif P[i] < P[i-1] and P[i] > P[i+1]:
        ans += 1

print ans


Measured memory_bytes: 2568
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, M = map(int, input().split())

    ans = min(N, M // 2)
    N -= ans
    M -= 2 * ans

    ans += M // 4
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
const int inf = 0x3f3f3f3f;
const ll linf = 123456789012345678;
const ll mod = 1000000007;
#pragma GCC optimize("Ofast")
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define sz(x) ((int)(x).size())


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

    int n, d;
    cin >> n >> d;
    int o = 2*d+1;
    int ans = n/o;
    if(ans*o<n)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

  vector<vector<vector<ll>>>
    dp(N+1, vector<vector<ll>>(2, vector<ll>(3, -longinf))); // index, select(1) or not(0), not select count
  dp[0][0][0] = 0;
  rep(i, N) {
    rep(k, 3) { // select
      dp[i+1][1][k] = max(dp[i][0][k]+A[i], dp[i+1][1][k]);
    }
    if(i) { // not select
      rep(k, 3) { // selected previous index
        dp[i+1][0][k] = max(dp[i][1][k], dp[i+1][0][k]);
      }
      rep(k, 2) { // not selected previous index
        dp[i+1][0][k+1] = max(dp[i][0][k], dp[i+1][0][k+1]);
      }
    } else {
      dp[i+1][0][1] = 0;
    }
  }

  ll ans = -longinf;
  if(N%2) ans = max(dp[N][1][2], dp[N][0][1]);
  else ans = max(dp[N][1][1], dp[N][0][0]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34388
#include <stdio.h>

int judge_same(int, int, int*);

int main(){
  int ns,nt,i,j,count,judge;
  scanf("%d",&ns);

  int s[ns];

  for(i=0;i<ns;i++) scanf("%d",&s[i]);

  scanf("%d",&nt);

  int t[nt];

  for(i=0;i<nt;i++) scanf("%d",&t[i]);

  for(i=0;i<ns;i++){

    judge=judge_same(i,ns,s);
    
    if(judge==1) continue;

    for(j=0;j<nt;j++){
      if(s[i]==t[j]) count++;
    }
  }

  printf("%d\n",count);

  return 0;
}

int judge_same(int x,int ns,int *s){
  int i,a=0;
  for(i=x+1;i<ns;i++){
    if(s[x]==s[i]){
      a=1;
    }
  }

  return a;
}
    
    
    



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

int main()
{
  string str;
  int d[9];
  int N;
  int K;
  bool f;

  cin >> N >> K;

  for (int i = 0; i < K; i++){
    cin >> d[i];
  }

  f = true;

  for (int i = N; ; i++){
    f = true;
    str = to_string(i);
    for (int j = 0; j < K; j++){
      if (str.find(to_string(d[j])) != -1){
        f = false;
        break;
      }
    }
    if (f){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int r = scanner.nextInt();
		r -= n * m;
		if (r < 0) {
			System.out.println(0);
			return;
		}
		BigInteger ans = BigInteger.ONE;
		for (int i = 0; i < n-1; i++)
			ans = ans.multiply(BigInteger.valueOf(r + n - 1 - i)).divide(
					BigInteger.valueOf(i + 1));
		System.out.println(ans);
	}
}

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

const int N = 111;

int a[N];

int sq(int x) {
	return x * x;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, ans = 0x3f3f3f3f; cin >> n;

	for(int i = 1; i <= n; i++) cin >> a[i];

	for(int i = -1000; i <= +1000; i++) {
		int t = 0;
		for(int j = 1; j <= n; j++) {
			t += sq(a[j] - i);
		}
		ans = min(ans, t);
	}
	cout << ans << endl;
}

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

class Main{
    static private node t = null;
    final static private StringBuilder sb = new StringBuilder();
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        String in;
        for(int i = 0; i<n; i++){
            in = br.readLine();
            if(in.charAt(0)=='p'){
                inorder(t);
                sb.append('\n');
                preorder(t);
                sb.append('\n');
            }else{
                insert(new node(Integer.parseInt(in.substring(7))));
            }
        }
        System.out.print(sb);
    }
    static void inorder(node t){
        if(t==null) return;
        inorder(t.left);
        sb.append(' ').append(t.key);
        inorder(t.right);
    }
    static void preorder(node t){
        if(t==null) return;
        sb.append(' ').append(t.key);
        preorder(t.left);
        preorder(t.right);
    }
    static void insert(node z){
        node y = null;
        node x = t;
        while(x!=null){
            y = x;
            if(z.key<x.key){
                x = x.left;
            }else{
                x = x.right;
            }
        }
        if(y==null){
            t = z;
        }else if(z.key<y.key){
            y.left = z;
        }else{
            y.right = z;
        }
    }
}
class node{
    final public int key;
    public node left;
    public node right;
    node(int key){
        this.key = key;
        left = right = null;
    }
}



Measured memory_bytes: 94936
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
    fast();
    double n;
    cin>>n;
    cout<<ceil(n/2);
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){ 
  int N;
  cin >> N;
  vector<int> a(3*N);
  REP(i, 3*N){
    cin >> a[i];
  }
  ll ans = 0;
  sort(a.begin(), a.end());
  REP(i, N){
    ans += a[N+2*i];
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
    string S, T;
    cin >> S >> T;

    uint_fast64_t N(S.size()), M(T.size());

    vector<vector<uint_fast64_t>> ans(N + 1, vector<uint_fast64_t>(M + 1));

    for(auto i = 0; i < N; ++i)
        for(auto j = 0; j < M; ++j)
            ans[i + 1][j + 1] = max({ans[i][j + 1], ans[i + 1][j], ans[i][j] + (S[i] == T[j])});
    
    deque<char> A;

    for(auto i = N, j = M; (i >= 0 || j >= 0) && ans[i][j];){
        if(i && ans[i][j] == ans[i - 1][j]){
            --i;
        }else if(ans[i][j] == ans[i][j - 1]){
            --j;
        }else{
            --i;
            --j;
            A.push_front(S[i]);
        }
    }

    for(auto c : A)printf("%c", c);
    puts("");

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string N;
    cin >> N;
    if(N.front() == N.back()) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3516
H,W = map(int,input().split())
a = ''
for i in range(W + 2):
  a += '#'
L = []
L.append(a)
for j in range(H):
  b = str(input())
  c = '#' + b + '#'
  L.append(c)
L.append(a)
for k in range(H + 2):
  print(L[k])


Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  vector<vector<ll>> A(3, vector<ll>(3));
  for (ll i = 0; i < 3; i++)
  {
    for (ll j = 0; j < 3; j++)
    {
      cin >> A.at(i).at(j);
    }
  }
  vector<vector<bool>> B(3, vector<bool>(3, false));
  ll N;
  cin >> N;
  for (ll q = 0; q < N; q++)
  {
    ll b;
    cin >> b;
    for (ll i = 0; i < 3; i++)
    {
      for (ll j = 0; j < 3; j++)
      {
        if (A.at(i).at(j) == b)
          B.at(i).at(j) = true;
      }
    }
  }

  for (ll i = 0; i < 3; i++)
  {
    bool ok = true;
    for (ll j = 0; j < 3; j++)
    {
      if (!B.at(i).at(j))
      {
        ok = false;
        break;
      }
    }
    if (ok)
      FINALANS("Yes");

    ok = true;
    for (ll j = 0; j < 3; j++)
    {
      if (!B.at(j).at(i))
      {
        ok = false;
        break;
      }
    }
    if (ok)
      FINALANS("Yes");
  }

  bool ok2 = true;
  for (ll i = 0; i < 3; i++)
  {
    if (!B.at(i).at(i))
    {
      ok2 = false;
      break;
    }
  }
  if (ok2)
    FINALANS("Yes");

  bool ok3 = true;
  for (ll i = 0; i < 3; i++)
  {
    if (!B.at(i).at(2 - i))
    {
      ok3 = false;
      break;
    }
  }
  if (ok3)
    FINALANS("Yes");

  FINALANS("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    int a,b,deg;
    double x,y,z;
double rad;
double PI = acos(-1);
 scanf("%d", &a);
 scanf("%d", &b);
scanf("%d", &deg);
rad = deg * PI / 180;
double t=a*a+b*b-2*a*b*cos(rad);;
double s=0;
s=sqrt(t);
 x=a*b*sin(rad)/2;
 y=a+b+s;
 z=b*sin(rad);
printf("%f\n%f\n%f\n", x, y,z);
}



Measured memory_bytes: 2108
#ABC 074 B

N = int(input())
K = int(input())
x = list(map(int,input().split()))

cnt = 0

for i in range(N):
    if abs(x[i]-0) > abs(x[i]-K):
        cnt += 2* abs(x[i]-K) 
    else:
        cnt += 2*x[i]
print(cnt)

Measured memory_bytes: 61344
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int digitSum(ll a){
    int res = 0;
    while(a > 0){
        res += a % 10;
        a /= 10;
    }
    return res;
}

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

    int cnt = 0;
    ll ans = 1, base = 1;
    while(cnt < k){
        cout << ans << endl;
        ll tmp1 = ans + base;
        ll tmp2 = ans + 10 * base;
        if (tmp1 * digitSum(tmp2) <= tmp2 * digitSum(tmp1)) ans = tmp1;
        else ans = tmp2, base *= 10;
        cnt++;
    }

    return 0;
}


Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    string s;
    cin >> s;
    map<char, int> map;
    for (char i : s)map[i]++;
    int MIN = INF, MAX = 0;
    string abc = "abc";
    for (char i : abc) {
        chmin(MIN, map[i]);
        chmax(MAX, map[i]);
    }
    cout << (MAX - MIN <= 1 ? "YES\n" : "NO\n");
}


Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <vector>
#include <cstring>
#include <cmath>
using namespace std;

typedef complex<double> P;

#define EPS (1e-6)

int n;
P p[3002];
bool flg[5002][5002];

bool ISINT(double x){
  double diff = fabs(x - round(x));
  return diff < EPS;
}

bool check(const P &p){
  if(!ISINT(p.real()) || !ISINT(p.imag())) return false;

  int x = (int)round(p.real());
  int y = (int)round(p.imag());

  if(x < 0 || 5000 < x) return false;
  if(y < 0 || 5000 < y) return false;

  return flg[x][y];
}

void solve(){
  double res = 0;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) continue;

      P a = p[i];
      P b = p[j];
      P ab = b - a; //aからbへ向かうベクトル
      P n1 = ab * P(0, 1); //abの法線

      P c = a + n1;
      P d = b + n1;

      if(check(c) && check(d)){
        res = max(res, abs(ab) * abs(ab));
      }
    }
  }

  cout << (int)round(res) << endl;
}

int main(){
  while(cin >> n, n){
    memset(flg, 0, sizeof(flg));

    for(int i = 0; i < n; i++){
      cin >> p[i].real() >> p[i].imag();
      flg[(int)p[i].real()][(int)p[i].imag()] = true;
    }
    solve();
  }
}

Measured memory_bytes: 25740
#include <iostream>
        #include <vector>
        #include <stack>
        #include <algorithm>
        using namespace std;

        int binarySearch(vector<int> input, int target){
            int start = 0;
            int end = input.size() -1;
            int result = -1;
            while(start<=end){
                int mid = end - (end-start)/2;
                if(input[mid]==target){
                    result = mid;
                    start = mid+1;
                }else if(input[mid]>target){
                    end = mid-1;
                }else{
                    start = mid+1;
                }
            }
            return result;
        }
        int lis(vector<int> v, int n, int maxVal){
            if(n==0)
                return 0;
            if(v[n-1]<maxVal){
                return max( 1+lis(v, n-1, v[n-1]), lis(v, n-1, maxVal) );
            }else
            return lis(v, n-1, maxVal);
        }
        void sw(string &s, int i, int j){
            char temp = s[i];
            s[i] = s[j];
            s[j] = temp;
        }
        void swap(string &s, int i, int j){
            for(int l=j; l>i; l--){
                sw(s, l, l-1);
            }
        }

        int get(int n){
            if(n%2==1)
                return n;
            return get(n/2);
        }
int dp[100005];
        int get(int a[], int n){
            if(n==0) return 0;
            if(n==1)
                return abs(a[n]-a[n-1]);
            if(dp[n]!=-1)
                return dp[n];
            return dp[n]  = min(  abs(a[n]-a[n-1]) + get(a,n-1) ,   abs(a[n]-a[n-2]) + get(a,n-2)   );
        }

        int main(){
            #ifndef ONLINE_JUDGE
            freopen("input.in", "r", stdin);
            freopen("output.in", "w", stdout);
            #endif

        for(int i=0; i<100005; i++)
            dp[i] = -1;

          int n; cin>>n;
          int a [n];
          for(int i =0; i<n; i++){
            cin>>a[i];
          }
          int minVal = get(a, n-1);
          cout<<minVal<<"\n";
        }


Measured memory_bytes: 8200
#include <stdio.h>
#include <string.h> 
int main()
{
	char a[100005];
	int b,n=0,i;
	scanf("%s",&a);
	b = strlen(a);
	for(i=0;i<b-1;i++){
		if(a[i]!=a[i+1]){
			n++;
		}
	}
	printf("%d\n",n);
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false
 
typedef long long				ll;
typedef pair <int, int> ii;

int main() {
	
	vector<int>a(12);
	rep(i, 12) cin >> a[i];
	SORT(a);
	
	bool flag = true;
	rep(i, 3){
		if(a[i*4] != a[i*4+1] || a[i*4] != a[i*4+2] || a[i*4] != a[i*4+3]) {
			flag = false;
			break;
		}
	}
	
	cout << (flag ? "yes" : "no") << endl;
	
	return 0;
}

Measured memory_bytes: 3152
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: i64,
        B: i64,
        H: [f64; N]
    }
    let mut ok = 1000000001_i64;
    let mut ng = 0_i64;
    while (ok-ng).abs() > 1{
        let mid = (ok+ng)/2;
        let mut cnt = 0_i64;
        for i in 0..N{
            cnt += max(0, ((H[i] - (B*mid) as f64)/(A-B) as f64).ceil() as i64);
        }
        if cnt <= mid{
            ok = mid;
        }else{
            ng = mid;
        }
    }
    println!("{}", ok);
}

Measured memory_bytes: 4352
def main():
    s = input()
    rem_l = [0]*2019
    rem_l[0] = 1
    curr_rem = 0
    for i, s_i in enumerate(s[::-1]):
        num = int(s_i)
        curr_rem = (curr_rem + num*pow(10,i,2019))%2019
        rem_l[curr_rem] += 1

    ans = 0
    for r in rem_l:
        ans += r*(r-1)//2

    print(ans)

if __name__ == "__main__":
    main()

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,m,s,t;
    cin>>n>>m;
    Vi a(m),b(m);
    REP(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
    }
    cin>>s>>t;
    s--;t--;
    
    VVi connect(3*n);
    Vi used(3*n,0);
    REP(i,0,m){
        connect[3*a[i]].pb(3*b[i]+1);
        connect[3*a[i]+1].pb(3*b[i]+2);
        connect[3*a[i]+2].pb(3*b[i]);
    }
    
    queue<Pii> q;
    int ans=-3;
    q.push(mp(3*s,0));
    while(!q.empty()){
        int now,dnow;
        tie(now,dnow)=q.front();
        q.pop();
        if(now==3*t){
            ans=dnow;
            break;
        }
        REP(i,0,connect[now].size()){
            int next=connect[now][i];
            if(used[next]==0){
                q.push(mp(next,dnow+1));
                used[next]=1;
            }
        }
    }
    cout<<ans/3<<endl;
    return 0;
}


Measured memory_bytes: 20608
import sys
import numpy as np
readline=sys.stdin.readline
read=sys.stdin.read

n,c,*stc=map(int,read().split())
m=2*10**5
cht=np.zeros((c,m+1),dtype='int64')
for s,t,ch in zip(*[iter(stc)]*3):
  cht[ch-1,2*s-1:2*t]=np.ones(2*t-2*s+1)
print(max(np.sum(cht,axis=0)))


Measured memory_bytes: 84584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int s (int n) {
    while (n >= 10) n /= 10;
    return n;
}
int e (int n) {
    return n % 10;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int b[10][10] = {};
    rep (j, n) {
        int i = j + 1;
        b[s(i)][e(i)]++;
    }
    int ans = 0;
    rep (i, 10) {
        rep (j, 10) {
            ans += b[i][j] * b[j][i];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#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 pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    int n,k; cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    ll ans = 0;
    rep(i,k) ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = sc.nextInt(), K = sc.nextInt();
		int g = 0, m = 0;
		while(N-->0)
		{
			int x = sc.nextInt();
			g = gcd(g, x);
			m = Math.max(m, x); 
		}
		out.println(K <= m && K % g == 0 ? "POSSIBLE" : "IMPOSSIBLE");
		out.close();
	}
	
	static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();} 
	}
}

Measured memory_bytes: 35600
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>s;
    (s=="ABC")? cout<<"ARC\n": cout<<"ABC\n";
    return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int N, K; 
cin >> N >> K; 
long long int A = N / K; 
if(K % 2 == 1){
cout << A * A * A << endl; 
}
if(K % 2 == 0){
long long int B = (N + K / 2)/ K; 
cout << A * A * A + B * B * B << endl; 
}
}

Measured memory_bytes: 256
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<map>//ll dx[4]={0,0,-1,1};ll dy[4]={-1,1,0,0};  
#include<set>//  
#include<vector>  
#include<cmath>  
#include<stack>  
#include<string.h>  
#include<stdlib.h>  
#include<cstdio>  
#define mod 1e9+7  
#define ll long long
using namespace std;  
int y[10100];
int x[1010];
int main(){
		int n;
		cin>>n;
		for(int i=0;i<n;++i){
			cin>>x[i];
		}
		for(int i=0;i<n;++i){
			int s=0;
			for(int j=i;j<min(i+3,n);++j){
				s=s*10+x[j];
				y[s]=1;
			}
		}
		for(int i=0;i<=1005;++i){
			if(y[i]==0){
				cout<<i<<endl;
				break;
			}
		}
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>

void call(int n) {
	for(int i=1; i<=n; i++) {
		if(i % 3 == 0) {
			std::cout << " " << i;
		} else {
			int x = i;
			while(x) {
				if(x % 10 == 3) {
					std::cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	std::cout << std::endl;
}

int main()
{
	int n;
	while(std::cin >> n) {
		call(n);
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <pair <int, int>> vec(n);
	for (int i = 0; i < n; ++i){
		cin >> vec[i].first >> vec[i].second;
	}
	bool f = false;
	for (int i = 2; i < n; ++i) {
		if (vec[i].first == vec[i].second and vec[i - 1].first == vec[i - 1].second and vec[i - 2].first == vec[i - 2].second)
			f = true;
	}
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3624
//Resting_Prince
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000009
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define all(v) v.begin(),v.end()
#define rep(i,a,b)    for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    ll dp[100055][3],n,i,j,k,o,l,c[100055][3],p;
    cin>>n;
    rep(i,0,n-1)rep(j,0,2)cin>>c[i][j];
    dp[0][0]=c[0][0],dp[0][1]=c[0][1],dp[0][2]=c[0][2];
    rep(i,1,n-1)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+c[i][0];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i][2];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+c[i][1];
    }cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end



int main(){
    int n,m; scanf("%d%d",&n,&m);
    vector<int> g[1010]; int cnt[1010];
    rep(i,0,m){
        int a,b; scanf("%d%d",&a,&b); a--; b--;
        g[a].push_back(b); cnt[b]++;
    }
    queue<int> q;
    rep(i,0,n)if(!cnt[i])q.push(i);
    int val=0;
    while(q.size()){
        int v=q.front(); q.pop();
        val++;
        for(int to:g[v]){
            cnt[to]--;
            if(!cnt[to])q.push(to);
        }
    }
    printf("%d\n",-(val==n));
    return 0;
}

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

const int MAX=1e9;

signed main()
{
  int S; cin>>S;
  int a,b,c,d;
  a=MAX;
  b=1;
  d=(S+MAX-1)/MAX;
  c=a*d-S;
  cout<<0<<' '<<0<<' '<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
  //cout<<a*d-b*c<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

int N,M,K,T;

int main(void){
	ll x; cin >> x;
	ll ans = 0;
	ans = x/11*2;
	x %= 11;
	if( x > 6 ) ans += 2;
	else if( x >= 1 && x <= 6) ans += 1;
	cout << ans;
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.readline

for _ in range(int(readline())):
    a = int(readline())
    y = int(readline())
    n = int(readline())
    ans = a
    for _ in range(n):
        t, rate, fee = [f(x) for f, x in zip((int, float, int), readline().split())]
        if t == 1:
            res = a
            for _ in range(y):
                res = res + int(res * rate) - fee
        else:
            res = a
            r = 0
            for _ in range(y):
                r += int(res * rate)
                res = res - fee
            res += r
        ans = max(ans, res)
    print(ans)

Measured memory_bytes: 6744
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
 
#define INF 1000000000000000000

ll n,k;
ll a[101];
ll dp[101][100001];
ll mod = 1000000007;
vector<ll> sum;
vector<ll> sum2;

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

    cin >> n >> k;

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

    dp[0][0] = 1;
    fr(i,0,k)
    {
        sum.pb(1);
    }

    fr(i,1,n)
    {
        fr(j,0,k)
        {
            ll x = sum[j];
            ll y = 0;
            if(j-a[i-1]-1>=0)
                y = sum[j-a[i-1]-1];

            dp[i][j] = ((dp[i][j]%mod) + ((x-y)%mod))%mod;
            if(j==0)
                sum2.pb(dp[i][j]);
            else
                sum2.pb(sum2[sum2.size()-1]+dp[i][j]);

            // cout << x << " " << y << " " << i << " " << j << " " << dp[i][j] << endl;
        }

        sum = sum2;
        sum2.clear();
    }

    cout << dp[n][k] << endl;
}

Measured memory_bytes: 80116
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val array = IntArray(n + 1) { 0 }
    array[0] = 1
    for (i in 1..k) {
        val d = readLine()!!
        val aList = readLine()!!.split(' ').map(String::toInt)
        aList.forEach { array[it]++ }
    }
    println(array.count { it==0 })
}

Measured memory_bytes: 39020
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;

const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> smod(n+1);
    for(int i = n-1; i >= 0; i--) {
        smod[i] = (smod[i+1] + a[i]) % mod;
    }
    ll ans = 0;
    rep(i,n-1) {
        ans += a[i] * smod[i+1];
        ans %= mod;
    }
    cout << ans%mod << endl;

    return 0;
}


Measured memory_bytes: 6412
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int t[n+1], x[n+1], y[n+1];
  t[0]=0;
  x[0]=0;
  y[0]=0;
  REP(i, n){
    cin>>t[i+1]>>x[i+1]>>y[i+1];
  }
  bool ans=true;
  REP(i, n){
    if(t[i+1]-t[i]<abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])) {
      ans=false;
      break;
    }
    if(abs(t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i]))%2) {
      ans=false;
      break;
    }
  }

  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 1408
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            if ("0".equals(line))
                break;
 
            char[] nums = line.toCharArray();
            int sum = 0;
            for (char num : nums) {
                sum += num - '0';
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 24228
#include <iostream>

using namespace std;

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	if((a+b) > (c+d))
	{
		cout << "Left" << endl;
	}
	else if((a+b) < (c+d))
	{
		cout << "Right" << endl;
	}
	else
	{
		cout << "Balanced" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll INF=1e18;



int main(){
 int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
  
  if(n%2==0){//偶数個の場合
    int med2a=a[n/2-1]+a[n/2];
    int med2b=b[n/2-1]+b[n/2];
    
    cout<<med2b-med2a+1<<endl;
    return 0;
    
  }else{//奇数個の場合
    int meda=a[n/2];
    int medb=b[n/2];
    cout<<medb-meda+1<<endl;
    return 0;
    
    
    
  }
 
 

}

Measured memory_bytes: 4732
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>//"geometry.cpp"
using namespace std;
#define pb push_back//Can be used for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
typedef pair<int,int> pii;//Add other types in the same way.

int n,d[200000];
bool f[200000];
vector<int> g[200000];
const int inf=3;

int main(){
	int m;
	cin>>n>>m;
	for(int j=0;j<m;++j){
		int a,b;
		cin>>a>>b;
		g[--a].pb(--b);
		g[b].pb(a);
	}
	queue<int> q;
	fill(f,f+n,false);
	d[0]=0;
	f[0]=true;
	q.push(0);
	while(!q.empty()){
		int v=q.front();
		q.pop();
		for(int j=0;j<g[v].size();++j){
			int w=g[v][j];
			if(!f[w]){
				f[w]=true;
				d[w]=d[v]+1;
				q.push(w);
			}
		}
	}
	if(d[n-1]==2) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  bool flag=true;
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0) flag=false;
    }
  }
  if(flag){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
}

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b;
    cin >> a >> b;
    int ans=0;
    if(a<b){
        ans=a;
        for(int i=1;i<b;i++){
            ans+=(a*pow(10,i));
        }
        cout << ans<<endl;
        return 0;
    }else{
        ans=b;
        for(int i=1;i<a;i++){
            ans+=(b*pow(10,i));
        }
        cout << ans << endl;
        return 0;
    }

}

Measured memory_bytes: 256
x, y, a, b, c = map(int,input().split())
datp = list(map(int, input().split()))
datq = list(map(int, input().split()))
datr = list(map(int, input().split()))
datp.sort(reverse=True)
datq.sort(reverse=True)
datr.sort(reverse=True)
res = sum(datp[:x]) + sum(datq[:y])
pl, pr = 0, x - 1
ql, qr = 0, y - 1
#print(datp)
#print(datq)
#print(datr)
#print("defaultt", res)

for i in range(c):
    #print(" musyoku ", i , "=", datr[i])
    #print("pr{0}, qr{1}".format(pr, qr))
    diffp, diffq = -1, -1
    if pr >= 0:
        diffp = datr[i] - datp[pr] # この無色を取ったときのメリット
    if qr >= 0:
        diffq = datr[i] - datq[qr] # この無色を取ったときのメリット
    #print("diffp", diffp, "diffq", diffq)
    if diffp <= 0 and diffq <= 0: # デメリットしか両者ないならいらない
        #print("break")
        break
    if diffp >= diffq and pr >= 0: # pを押し出したほうがいいなら
        #print("get p")
        res += diffp
        pr -= 1
    elif qr >= 0 and diffq > 0: #qを押し出したほうがいいなら
        #print("get q")
        res += diffq
        qr -= 1

print(res)


Measured memory_bytes: 105444