akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

struct unionfind{
  vector<int> par;
  unionfind(int n):par(n,-1){}
  void init(int n){par.assign(n,-1);}
  int root(int x){
    if(par[x]<0) return x;
    else return par[x]=root(par[x]);
  }
  bool issame(int x,int y){
    return root(x)==root(y);
  }
  bool merge(int x,int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(par[x]>par[y]) swap(x,y);
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  unionfind uf(n);
  vector<int> ans(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    ans[a]--; ans[b]--;
    uf.merge(a,b);
  }
  rep(i,n){
    ans[i]+=uf.size(i)-1;
  }
  rep(i,k){
    int a,b;
    cin >> a >> b;
    a--; b--;
    if(uf.issame(a,b)){
      ans[a]--; ans[b]--;
    }
  }
  rep(i,n){
    cout << ans[i] << " ";
  }cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll ans = 1;
	Vec color(3);
	rep(i, n){
		ll cnt = 0, id = 0;
		rep(j, 3){
			if(color[j] == a[i]){
				if(!cnt) id = j;
				cnt++;
			}
		}
		ans *= cnt;
		ans %= MOD;
		color[id]++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000

ll N,K,ans=INF;
ll D[501][501],C[31][31];
ll cr[4][31];


int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>K;
    REP(i,K)REP(j,K){cin>>C[i][j];}
    REP(i,N)REP(j,N){cin>>D[i][j];D[i][j]--;}
    REP(i,N)REP(j,N){
        if((i+j)%3==0)cr[0][D[i][j]]++;
        if((i+j)%3==1)cr[1][D[i][j]]++;
        if((i+j)%3==2)cr[2][D[i][j]]++;
    }
    REP(i,K)REP(j,K)REP(k,K){
        if(i==j||j==k||k==i)continue;
        ll temp=0,mode;
        ll a[]={i,j,k};
        REP(x,3)REP(y,K){
            mode=x%3;
            temp+=cr[x][y]*C[y][a[mode]];
        }
        ans=min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

ll dp[110][100100]={0};

int main(void){
    int N,W;
    cin >> N >> W;
    int w[110],v[110];
    REP(i,N) cin >> w[i] >> v[i];

    REP(i,N){
        for(int sum_w=0;sum_w<=W;sum_w++){
            if(sum_w-w[i]>=0){
                chmax(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
            }
            chmax(dp[i+1][sum_w],dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;


    return 0;
}

Measured memory_bytes: 81728
# -*- coding: utf-8 -*-
"""
"""
import sys
from sys import stdin
from bisect import bisect_right
input = stdin.readline


def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    nums = [x for x in range(2, limit+1)]
    while nums[0]<=x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x%current_prime != 0]
    primes.extend(nums)
    return primes


def main(args):
    # ??????????´???°?????????
    primes = create_prime_list(10000)
    twin_primes = []
    prev = primes[0]
    for p in primes[1:]:
        if p == prev + 2:
            twin_primes.append([prev, p])
        prev = p

    keys = [x[1] for x in twin_primes]
    while True:
        n = int(input())
        if n == 0:
            break
        r = bisect_right(keys, n)
        print(*twin_primes[r-1])


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8380
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long a,b,x,c,d;
	cin>>a>>b>>x;
	c=b/x;
	if(a==0){
		d=-1;
	}
	else{
		d=(a-1)/x;
	}
	cout<<c-d<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int people=scan.nextInt();
    int sweet=scan.nextInt();
    int[] swenum=new int[people];
    for(int a=0; a<sweet; a++){
      int num=scan.nextInt();
      for(int b=0; b<num; b++){
        int stuck=scan.nextInt();
        swenum[stuck-1]++;
      }
    }
    int ans=0;
    for(int a=0; a<people; a++){
      if(swenum[a]==0){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 46164
N, Y = map(int, input().split())

'''
if Y/N > 10000 or Y%1000 != 0:
  print("-1 -1 -1")
'''
flag = 0
  
for x in range(N+1):
  x = x
  if flag == 1:
    break
  for y in range(N-x+1):
    y = y
    z = N-x-y
    if x*10000+y*5000+z*1000 == Y:
      print(x,y,z)
      flag = 1
      break

if flag == 0:
  print('-1 -1 -1')

Measured memory_bytes: 3064
#include <iostream>


int D[100];
int F[100];
int V[100][100];

int cnt = 0;
int n;

void dfs(int r) {
    D[r] = ++cnt;
    for (int i = 0; i < n; i++) {
        if ((V[r][i] == 1) && (D[i] == 0)) {
            dfs(i);
        }
    }
    F[r] = ++cnt;
}

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int id, e_num;
        std::cin >> id >> e_num;
        for (int j = 0; j < e_num; j++) {
            int t;
            std::cin >> t;
            V[id - 1][t - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        if (!D[i]) dfs(i);
    }

    for (int i = 0; i < n; i++) {
        std::cout << i + 1 << " " << D[i] << " " << F[i] << std::endl;
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    string s, t; cin >> s >> t;

    int cnt = 0;
    while(cnt!=s.size()){
        if(s==t){
            cout << "Yes" << endl;
            return 0;
        }
        
        string u;
        u.push_back(t.at(t.size()-1));
        rep(i, t.size()-1) u.push_back(t.at(i));
        t = u;

        cnt++;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;

const int MAX_N = 100005;
int par[MAX_N];
int rank_[MAX_N];
 
// n要素で初期化
void init(int n) {
    rep(i,n) {
        par[i] = i;
        rank_[i] = 0;
    }
}
 
// 木の根を求める
int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
    // if (par[x] == x) return x;
    // else return par[x] = root(par[x]);
}
 
// xとyが同じ根に属するかどうか
bool same(int x, int y) {
    return root(x) == root(y);
}
 
// xとyが属する集合を併合
void unit(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    
    if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }
}
 
 
int main() {
    int n, m, k;
    cin >> n >> m >> k;
 
    init(n);
 
    vector<pair<ll,ll>> fbNum(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (!same(a, b)) unit(a, b);
        fbNum[a].first++;
        fbNum[b].first++;
    }
 
    rep(i,k) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (same(a, b)) {
            fbNum[a].second++;
            fbNum[b].second++;
        }
    }
    vector<int> gNum(n);
    rep(i,n) gNum[root(i)]++;
    rep(i,n) {
        int ans = gNum[root(i)] - 1 - fbNum[i].second - fbNum[i].first;
        cout << ans << " ";
    }
 
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>
#define  int long long
int32_t main(){ fast;
	int n; cin>>n;
	vi a(n);
	rep(i, n){
		cin>>a[i];
	}
	int now = a[0];
	int answer = 0;
	for(int i = 1; i < n; i++){
		now = max(now, a[i]);
		answer += now - a[i];
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 4784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            int ans = a * a * a;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
int table[10];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<10;i++)table[i]=0;
		for(int i=0;i<a;i++){
			int b;
			scanf("%d",&b);
			table[b]++;
		}
		for(int i=0;i<10;i++){
			if(table[i]==0)printf("-\n");
			else{
				for(int j=0;j<table[i];j++)printf("*");
				printf("\n");
			}
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    
    vector<int> z(n+1);
    z[0]=3;
    ll ans=1;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(z[tmp]==0) {
            printf("0\n"); return 0;
        }
        ans=ans*z[tmp]%MOD;
        z[tmp]--;
        z[tmp+1]++;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, D = readnums()
    xy = [list(readnums()) for _ in range(N)]
    ans = 0
    for x, y in xy:
        if x ** 2 + y ** 2 <= D ** 2:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
  int N;

  cin >> N;
  int res=0;
  for(int i=1;i<=N;i++)
  {
    if(i%2 == 0) continue;
    int count=0;
    for(int j=1;j<=i;j++)
    {
      if(i%j == 0) count++;
    }
    if(count == 8) res++;
  }
  cout << res << endl;
  return 0;
}

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

int main() {
	string str; int joi, ioi;
	while (cin >> str) {
		joi = 0; ioi = 0;
		for (int i = 0; i < str.size() - 2; i++)
			if (str[i + 1] == 'O'&&str[i + 2] == 'I') {
				if (str[i] == 'J') joi++;
				if (str[i] == 'I') ioi++;
			}
		cout << joi << endl << ioi << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
//    すべてが素　同じものがない
    // 最大公約数が1 やるだけ

    val n = readInteger()
    val aList = readLongList()
    val tmp = IntArray(1000001)

    val primeTable = primeTable(1000000)
    for (a in aList) {
        var target = a.toInt()
        while (target > 1) {
            val prime = primeTable[target].toInt()
            tmp[prime]++

            while (target > 1 && target % prime == 0) {
                target /= prime
            }
        }
    }

    if (tmp.max()!! <= 1) {
        out.println("pairwise coprime")
        return
    }

    val aaaa = aList.reduce { acc, a -> gcd(acc, a) }
    if (aaaa == 1L) {
        out.println("setwise coprime")
        return
    }

    out.println("not coprime")
}

/** O(nlog(logn)) // n * n <= Int.MAX_VALUE, n <= 10^6 */
fun primeTable(n: Int): LongArray {
    val table = LongArray(n + 1) { it.toLong() }
    if (n >= 0) table[0] = 0
    if (n >= 1) table[1] = 1
    var i = 2
    while (i * i <= n) {
        if (table[i] == i.toLong()) {
            for (j in (i + i)..n step i) { table[j] = i.toLong()}
        }
        i++
    }
    return table
}

/** O(log(n)): n = min(a, b) */
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 166692
n=int(input())
a = list(map(int,input().split()))
even=[el for el in a if el % 2==0]
try:
  for a in even:
    if a % 3 == 0 or a % 5 == 0:
      flg = 1
    else:
      raise
except:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 38384
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>=13) printf("%d\n",b);
	else if(a>=6 && a<=12) printf("%d\n",b/2);
	else printf("0\n");
	return 0;
}



Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

ll combination(ll n, ll r) {
    ll nf = 1, rf = 1;
    if (r * 2 > n) r = n - r;
    for (ll i = 1; i <= r; ++i) {
        nf = ((n - r + i) * nf) % MOD;
        rf = (i * rf) % MOD;
    }

    return (nf / rf);
}

ll kaijo(ll a) {
    ll ans = 1;
    for (ll i = 2; i <= a; ++i) {
        ans *= i;
        ans %= MOD;
    }

    return ans;
}

ll kaijo2(ll n, ll a) {
    ll ans = 1;
    for (ll i = 0; i < a; ++i) {
        ans *= (n - i);
        ans %= MOD;
    }

    return ans;
}

ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

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

    c = calc(2, n);
    ll ans = (MOD * 3L + c - comb(n, a) - comb(n, b) - 1) % MOD;

    cout << ans << endl;
    

    return 0;
}



Measured memory_bytes: 256
//file_name:ABC95_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {

    ll ans = 700;
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]=='o'){
            ans+=100;
        }
    }

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



Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9


if __name__ == "__main__":
    s = int(input())
    MOD = 10**9 + 7
    dp = [0]*(s + 1)
    if s>=3:
        dp[3] = 1
    for i in range(4,s+1):
        dp[i] = (dp[i-3] + dp[i-1])%MOD
    print(dp[s])

Measured memory_bytes: 69880
def main():
    MOD = 10**9+7
    N, K = map(int, input().split())
    fact = [1]
    max_len = max(2*K, N)
    for i in range(1, N+1):
        fact.append((fact[i-1]*i)%MOD)
    gyakugen = []
    for a in fact:
        gyakugen.append(pow(a, MOD-2, MOD))

    ans = []
    for i in range(1, K+1):
        if i-1 > N-K:
            ans.append(0)
            continue
        Bpattern = (fact[K-1] * gyakugen[(K-i)] * gyakugen[i-1])%MOD
        Rpattern = (fact[N-K+1] * gyakugen[N-K-i+1] * gyakugen[i])%MOD
        # print(Bpattern, Rpattern)
        ans.append((Bpattern * Rpattern) % MOD)
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 41840
#include<iostream>
#include<map>
using namespace std;
const int maxn=200005;
int root1[maxn],root2[maxn];
map<pair<int,int>,int> mp;
int ufind(int x,int *root)
{
    if(root[x]==x)
    {
        return x;
    }else
        return root[x]=ufind(root[x],root);
}
void umerge(int p,int q,int*root)
{
    int rp=ufind(p,root);
    int rq=ufind(q,root);
    if(rp!=rq)
    {
        root[rq]=rp;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    int n,k,l,x,y;
    cin>>n>>k>>l;
    for(int i=1;i<=n;++i)
    {
        root1[i]=i;
        root2[i]=i;
    }
    for(int i=1;i<=k;++i)
    {
        cin>>x>>y;
        umerge(x,y,root1);
    }
    for(int i=1;i<=l;++i)
    {
        cin>>x>>y;
        umerge(x,y,root2);
    }
   for(int i=1;i<=n;++i)
    {
        ufind(i,root1);
        ufind(i,root2);
    }
    for(int i=1;i<=n;++i)
    {
        mp[make_pair(root1[i],root2[i])]++;
    }
    for(int i=1;i<=n;++i)
    {
        cout<<mp[make_pair(root1[i],root2[i])]<<" ";
    }cout<<endl;
    return 0;
}

Measured memory_bytes: 13568
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            //var line = consoleReader.SplitInt32();
            var N = consoleReader.Int32();
            int amari;
            var d = Math.DivRem(N, 111, out amari);
            return amari == 0 ? 111 * d : 111 * (d + 1);
        }

        public const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int32() => int.Parse(String()); public long Int64() => long.Parse(String()); public ulong UInt64() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray(); public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt32(int count) { for (int i = 0; i < count; i++) yield return Int32(); } public IEnumerable<long> RepeatInt64(int count) { for (int i = 0; i < count; i++) yield return Int64(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt32(int count) { for (int i = 0; i < count; i++) yield return SplitInt32(); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i=0;i+2<N;i++){
        if(S.substr(i,3)=="ABC") ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 998244353;//1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max() / 100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, acost, bcost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<Pll, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, b[200000];
Pll a[310000];
string str;
bool f;
char c[1100][1100];
Pll dpdp(LL cur) {
	LL nex = cur + (str[cur] == 'L' ? -1 : 1);
	if (a[cur].first != -1)return a[cur];
	if (str[cur] != str[nex]) {
		a[cur] = Pll(cur, nex);
		return Pll(cur, nex);
	}
	else {
		a[cur]=dpdp(nex);
		return a[cur];
	}
}
int main() {
	cin >> str;
	rep(i, str.size())a[i].first = -1;
	rep(i, str.size()) {
		dpdp(i);
		if ((a[i].first - i) % 2)
			b[a[i].second]++;
		else
			b[a[i].first]++;
	}
	rep(i, str.size()) {
		if (i)cout << " ";
		cout << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6656
n, m = map(int, input().split())		# 5 7

if n > m: n,m=m,n

ans=0
if n==1:
	if m==1: ans = 1
	if m==2: ans = 0
	if m>=3: ans = m-2

if n>=2: ans = (n-2)*(m-2)

print(ans)


Measured memory_bytes: 3060
sa = list(input())
sb = list(input())
sc = list(input())
tmp = 'a'
for i in range(10000):
    if tmp == 'a':
        if len(sa) == 0:
            print('A')
            break
        tmp = sa[0]
        del sa[0]
    elif tmp == 'b':
        if len(sb) == 0:
            print('B')
            break
        tmp = sb[0]
        del sb[0]
    else:
        if len(sc) == 0:
            print('C')
            break
        tmp = sc[0]
        del sc[0]


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
int main() {
    IO;
    int n, k;
    cin >> n >> k;
    int arr[n+1];
    ll dp[n+1];
    for(int i = 1; i <= n; ++i)
        cin >> arr[i];
    dp[1] = 0;
    for(int i = 2; i <= n; ++i){
        dp[i] = 1e9;
        for(int j = max(i-k,1);j<i;j++){
            dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1408
#!python3

iim = lambda: map(int, input().rstrip().split())
from math import gcd

def resolve():
    K = int(input())

    cache = {}
    def gcd3(a, b, c):
        ab = gcd(a, b)
        if ab == 1:
            return 1


    ans = K * K + K * (K-1) + (K-1)**2
    ans += (K-1) * (2+K) // 2
    K += 1

    for i in range(2, K):
        for j in range(i+1, K):
            ab = gcd(i, j)
            for k in range(j+1, K):
                ans += 6 * gcd(ab, k)

    for i in range(2, K):
        for j in range(2, K):
            if i == j:
                continue
            ans += 3 * gcd(i, j)
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
      ll a,b,c,k,ans;
      cin>>a>>b>>c>>k;
     if((a+b>=k))ans=min(k,a);
     else ans = min(k,a)-(k-(a+b));
     cout<<ans<<endl;
}

Measured memory_bytes: 3624
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    let mut counts: HashMap<char, usize> = HashMap::new();
    for _ in 0..h {
        let line: Vec<char> = iterator.next().unwrap().chars().collect();
        for c in line {
            *counts.entry(c).or_insert(0) += 1;
        }
    }

    if h % 2 == 0 && w % 2 == 0 {
        let mut ok = true;
        for (_, count) in counts {
            if count % 4 != 0 {
                ok = false;
                break;
            }
        }
        return if ok {
            "Yes".to_string()
        } else {
            "No".to_string()
        };
    }

    if h % 2 == 0 && w % 2 == 1 || h % 2 == 1 && w % 2 == 0 {
        let even = if h % 2 == 0 { h } else { w };
        let mut mod4_2: usize = 0;
        for key in counts.clone().keys() {
            if counts.get(key).unwrap() % 4 == 2 {
                mod4_2 += 1;
                *counts.entry(*key).or_insert(0) -= 2;
            }
        }
        if mod4_2 > even / 2 {
            return "No".to_string();
        }
        let mut ok = true;
        for (_, count) in counts {
            if count % 4 != 0 {
                ok = false;
                break;
            }
        }
        return if ok {
            "Yes".to_string()
        } else {
            "No".to_string()
        };
    }

    for key in counts.clone().keys() {
        if counts.get(key).unwrap() % 2 == 1 {
            *counts.entry(*key).or_insert(0) -= 1;
            break;
        }
    }

    let mut mod4_2: usize = 0;
    for key in counts.clone().keys() {
        if counts.get(key).unwrap() % 4 == 2 {
            mod4_2 += 1;
            *counts.entry(*key).or_insert(0) -= 2;
        }
    }
    if mod4_2 > h / 2 + w / 2 {
        return "No".to_string();
    }
    let mut ok = true;
    for (_, count) in counts {
        if count % 4 != 0 {
            ok = false;
            break;
        }
    }
    return if ok {
        "Yes".to_string()
    } else {
        "No".to_string()
    };
}


Measured memory_bytes: 2196
void main() {
	auto ip = readAs!(int[]), S = ip[0], W = ip[1];
	if(W >= S) writeln("unsafe");
	else writeln("safe");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2716
#include<stdio.h>
int main(){
  int max,min,n,k,d,t;
  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%d",&d);
    int i,j,s[8]={0};
    for(i=0;d!=0;i++){
      s[i]=d%10;
      d/=10;
    }
    for(i=0;i<8;i++){
      for(j=1;j+i<8;j++){
	if(s[j-1]<s[j]){
	  t=s[j-1];
	  s[j-1]=s[j];
	  s[j]=t;
	}
      }
    }
    max=0;
    for(i=0;i<8;i++){
      max*=10;
      max+=s[i];
    }
    for(i=0;i*2<8;i++){
      t=s[i];
      s[i]=s[7-i];
      s[7-i]=t;
    }
    min=0;
    for(i=0;i<8;i++){
      min*=10;
      min+=s[i];
    }
    printf("%d\n",max-min);
  }
  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
int main() {
	int a, b, c, d, i, ans;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	for(ans=i=0; i<100; i++)
		if(i>=a && i<b && i>=c && i<d) ans++;
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	int N;
	bool seat[100001] = {0};
	cin >> N;
	for (int i = 0; i < N; i++) {
		int l, r;
		cin >> l >> r;
		for (int j = l ; j <= r; j++) {
			seat[j] = true;
		}
	}
	int count = 0;
	for (int i = 1; i < 100001; i++)
		if (seat[i])
			count++;
	cout << count << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i = 0;i < n;i++) {
    cin >> v[i];
  }
  for(int i = k;i < n;i++) {
    cout << (v[i-k] < v[i] ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 4060
using Yorukatsu025.Questions;
using Yorukatsu025.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu025.Questions
{
    /// <summary>
    /// ABC056 C
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var x = inputStream.ReadInt();

            var position = 0;
            for (int time = 1; true; time++)
            {
                position += time;
                if (position >= x)
                {
                    yield return time;
                    yield break;
                }
            }
        }
    }
}


namespace Yorukatsu025
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu025.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu025.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
//$ node B.js < B.txt
function Main(input) {
  input = input.split('\n') // 1行目がinput[0], 2行目がinput[1], …に入る
  var ans = input[1].match(/ABC/g)
  console.log(ans ? ans.length : 0)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

using lint = long long;
const lint LINF = 1e18;

lint digit_sum(lint n, lint b) {
    lint res = 0;
    while (n > 0) {
        res += n % b;
        n /= b;
    }
    return res;
}

int main() {
    lint n, s;
    cin >> n >> s;

    lint ans;
    if (n == s) {
        ans = n + 1;
    } else {
        ans = LINF;
        for (lint b = 2; b * b <= n; b++) {
            if (digit_sum(n, b) == s) {
                ans = min(ans, b);
            }
        }
        for (lint p = 1; p * p < n; p++) {
            if ((n - s) % p == 0) {
                lint b = lint(1) + (n - s) / p;
                if (0 <= p and p < b and 0 <= s - p and s - p < b) {
                    ans = min(ans, b);
                }
            }
        }
    }
    if (ans == LINF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
INF = 10**12
n = gets.to_i
arr = gets.split.map(&:to_i).sort_by!{|x|x}
# p arr
ans = INF
arr[0].upto(arr[-1]) do |t|
  pre = 0
  n.times do |i|
    pre += (arr[i] - t)**2
  end
  ans = [ans, pre].min
end
puts ans

Measured memory_bytes: 1788
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
  a, b, c = A[i], B[i], C[i]
  if a == b == c:
    continue
  if a == b or b == c or c == a:
    ans += 1
  else:
    ans += 2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  if(n<10){
    cout << n << endl;
  }
  
  else if(10<=n && n<100){
    cout << 9 << endl;
  }
  
  else if(100<=n && n<1000){
    cout << 9+(n-99) << endl;
  }
  
   else if(1000<=n && n<10000){
    cout << 909 << endl;
  }  
  
  else if(10000<=n && n<100000){
    cout << 909 + (n-9999) << endl;
  }
  
  else{
    cout << 90909 << endl;
  }
}
    


Measured memory_bytes: 256
/*
ID: varunra2
LANG: C++
TASK: a
*/

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif

#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second

const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions

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

  int n;
  cin >> n;

  if (n % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  // x*10 + 7

  MPII see;

  int cur = 0;
  int cnt = 0;

  for (int i = 0; i < 2 * n; i++) {
    cur *= 10;
    cur += 7;
    cur %= n;
    cnt++;
    if (cur == 0) {
      cout << cnt << endl;
      return 0;
    } else if (see[cur]) {
      cout << -1 << endl;
      return 0;
    }
    see[cur]++;
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 50512
// https://atcoder.jp/contests/dp/tasks/dp_k


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    int dp[n][k+1] = { -1 };
    // a[0]
    for(int i = 0;i<n;i++) {
        cin >> a[i];
    }

    // for(int j = 1;j<=k;j++){

    // }

    for(int i = 0;i<n;i++) {
        for(int j = 1;j<=k;j++) {
            if( i == 0){
                if(j < a[0]){
                    dp[i][j] = 0;
                }
                if(j == a[0]){
                    dp[i][j] = 1;
                }
                // for()
            } else {
                if(j < a[i]){
                    dp[i][j] = dp[i-1][j];
                }
                if(j == a[i]){
                    dp[i][j] = 1;
                }
            }
            if( j> a[i]){
                int win = 0;
                for(int k = 0;k<=i;k++){
                    if(dp[i][j-a[k]] == 0){
                        win = 1;
                    }
                }
                if(win == 1){
                    dp[i][j] = 1;
                } else {
                    dp[i][j] = 0;
                }
            }
        }
    }
    if(dp[n-1][k]){
        cout << "First";
    } else {
        cout << "Second";
    }
    // for(int i = 0;i<n;i++){
    //     // for(int j = 1;j<)
    // }
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
const int mod=1e9+7;
const int N=2e5+10;
ll fac[N],inv[N];
ll qpow(ll x, int k)
{
    x=x%mod;
    ll ans=1;
    while(k)
    {
        if(k&1) ans=ans*x%mod;
        x=x*x%mod;
        k>>=1;
    }
    return ans;
}
void init()
{
    fac[0]=1;
    for(int i=1; i<N; i++)
        fac[i]=fac[i-1]*i%mod;
    inv[N-1]=qpow(fac[N-1],mod-2);
    for(int i=N-1; i>0; i--)
        inv[i-1]=inv[i]*i%mod;
}
ll comb(int n, int m)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    init();
    int h,w,a,b;
    ll ans=0,t;
    cin>>h>>w>>a>>b;
    for(int i=b+1; i<=w; i++)
    {
        t=comb(i-1+h-a-1,i-1)*comb(a-1+w-i,a-1)%mod;
        ans=(ans+t)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>


int main(){
	int a,b;
	char op;
	
	while(scanf("%d %c %d", &a, &op, &b) != EOF){
		if(op == '?'){
			break;
		}
		
		switch(op){
			case'+':
				printf("%d\n", a+b);
				break;
			case'-':
				printf("%d\n", a-b);
				break;
			case'*':
				printf("%d\n", a*b);
				break;
			case'/':
				printf("%d\n", a/b);
				break;
		}
	}
		
			
	return 0 ;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 

int main()
{
  ll n,x[110],y[110],h[110],ans[110][110],t;
  t=0;
  cin >> n;
  rep(i,101)rep(j,101)ans[i][j]=0;
  rep(i,n)cin >> x[i] >> y[i] >> h[i];
  rep(i,101){
    rep(j,101){
      rep(k,n){if(h[k]!=0&&ans[i][j]!=0&&ans[i][j]!=h[k]+abs(i-x[k])+abs(j-y[k])){
                                                                            goto A;
                                                                           }
               else if(h[k]!=0)ans[i][j]=h[k]+abs(i-x[k])+abs(j-y[k]);
              }
      rep(k,n)if(h[k]!=max(ans[i][j]-abs(i-x[k])-abs(j-y[k]),t))goto B;
      printf("%lld %lld %lld",i,j,ans[i][j]);
      B:;
      A:;
    }
  }
}

Measured memory_bytes: 384
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N, A, B, C = map(int, input().split())
l = [0]*(N+1)
for i in range(1, N+1):
    l[i] = int(input())


ans = int(1e18)
for n in range(1 << N * 2):
    use = [0]*(N+1)
    for i in range(1, N+1):
        use[i] = (n >> ((i-1)*2)) % 4

    hoge = [[], [], [], []]
    for i in range(1, N+1):
        hoge[use[i]].append(i)

    flag = False
    for e in hoge[:3]:
        if len(e) == 0:
            flag = True
    if flag:
        continue

    tmp = 0
    fuga = [A, B, C]
    for i in range(3):
        now = hoge[i]
        tmp += 10 * (len(now) - 1)
        tmp += abs(fuga[i] - sum(map(lambda x: l[x], now)))

    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 45020
#include <iostream>

using namespace std;

int main(){
	int N, K;
	int X, Y;
	int sum = 0;

	cin >> N >> K >> X >> Y;

	for(int i = 1; i <= N; i++){
		if(i <= K){
			sum += X;
		}else if(i > K){
			sum += Y;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int sum[1001];
int main()
{
    for(int i=1;i<=999;i++){
        sum[i]=i+sum[i-1];
       // printf("%d\n",sum[i]);
    }

    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",sum[b-a]-b);
    return 0;
}


Measured memory_bytes: 256