akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int X[100005],L[100005];
pair<long long int,long long int>XL[100005];
int main() {
	cout << fixed << setprecision(18);
	long long int N,H,W;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>X[i]>>L[i];
		XL[i]={X[i]+L[i],X[i]-L[i]};
	}
	sort(XL,XL+N);
	long long int res=0,now=-INF;
	for(int i=0;i<N;i++){
		if(now<=XL[i].second){
			res++;
			now=XL[i].first;
		}
	}
	cout<<res<<endl;
	
} 

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

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

void dfs(vector<vector<int>>& g, vector<int>& in, vector<bool>& used, int pos, vector<bool>& p){
	used[pos] = true;
	for(auto to : g[pos]){
		if(used[to]) continue;
		dfs(g, in, used, to, p);
	}
	if(in[pos] == 1 and pos != 0){
		for(auto i : g[pos]){
			in[i]--;
		}
		p[pos] = true;
	}
}

int bfs(vector<vector<int>>& g, vector<bool>& used, vector<int>& w){
	int n = g.size();

	queue<int> q;
	rep(i,n){
		if(not used[i]) q.emplace(i);
	}

	vector<int> dis(n,0);
	while(not q.empty()){
		int pos = q.front(); q.pop();
		for(auto to : g[pos]){
			if(not used[to]) continue;
			used[to] = false;
			dis[to] = dis[pos] + w[to];
			q.emplace(to);
		}
	}

	return *max_element(all(dis));
}

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

	vector<int> w(n);
	cin >> w;

	vector<vector<int>> g(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	vector<int> in(n);
	rep(i,n) in[i] = g[i].size();

	vector<bool> p(n,0);
	vector<bool> used(n,0);
	dfs(g, in, used, 0, p);

	int res = 0;
	rep(i,n){
		if(not p[i]) res += w[i];
	}

	cout << bfs(g, p, w) + res << endl;
}



Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define endl ("\n")
#define deb(x) cout << (#x) << " = " << (x) << endl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    int a, b;
    cin >> a >> b;
    if(a < b)
    {
        cout << 0;
    }
    else
    {
        cout << 10;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    if ( n<15)
    {
        cout<<n*800;
    }
    else if (n==15) 
    {cout<<(n*800)-200;
    }
    else if(n>15)
    {
        x=n/15;
        cout<<(n*800)-(x*200);
    }
    return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    res += 2 * min(x, K - x);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())
a_arr = [int(a) for a in input().split()]
div_nums = []

for n in range(N):
    d = 0
    a = a_arr[n-1]
    while a%2 == 0:
        d+=1
        a/=2
    div_nums.append(d)

print(min(div_nums))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using ll = long long;
using pii = std::pair<int,int>;
using pll = std::pair<ll, ll>;
using pss = std::pair<std::string, std::string>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using vpll = std::vector<pll>;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 1e9 + 19;
const ll INFL = 1e18 + 19;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

bool pairsort(pll pl, pll pr){
  if(pl.first == pr.first)return pl.second > pr.second;
  return pl.first < pr.first;
}
//_____________________　following sorce code_________________________//
int n,m,k;
vvi dp;
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vi v;
vll u;

bool check(){
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n,S);
  map<pss,int> mp;
  rep(i,1<<n){
    string A = "", B = "";
    rep(j,n){
      if(i &(1 << j))A+= S[j];
    }
    repd(j,n-1){
      if(!(i & (1 << j)))B += S[j];
    }
    mp[pss(A,B)]++;
  }

  ll ans = 0;
  rep(i,1<<n){
    string A = "", B = "";
    rep(j,n){
      if(i & (1 << j))A += S[n+j];
    }
    repd(j,n-1){
      if( !(i & (1 << j)))B += S[n+j];
    }
    ans += mp[pss(B,A)];
  }
  cout << ans << endl;
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 92416
mod = 998244353
import sys
sys.setrecursionlimit(10**9)
S = input()
N = len(S)
Sum = [0]*(N+1)
for i in range(1, N+1):
    Sum[i] = Sum[i-1]+int(S[i-1])
dp = [[0]*(N*2+1) for _ in range(N*2+1)]
for i in range(N*2+1)[::-1]:
    for j in range(N*2+1)[::-1]:
        if i+j == N*2:
            dp[i][j] = 1
            continue
        n = min(i+j+1, N)
        s = Sum[n]
        if i<s:
            dp[i][j]+=dp[i+1][j]
        if 2*n-s>j:
            dp[i][j]+=dp[i][j+1]
        dp[i][j]%=mod
print(dp[0][0])   

Measured memory_bytes: 166108
menu=[]
menu2=[]
total=False
c=0
total2=0
for i in range(5):
    a=int(input())
    menu.append(a)
    menu2.append(a%10)
    if a%10==0:
        total2+=1
if total2==5:
    print(sum(menu))
else:
    for i in range(1,10):
        for k in range(5):
            if menu2[k]==i:
                total=True
                c=k
                break
        if total==True:
            break
    print(sum(menu)+10*(4-total2)-sum(menu2)+menu2[c])

Measured memory_bytes: 9104
/**
题意：有n个开关和m盏灯，
m行：对于第i盏灯，有x个开关控制这盏等，x1，x2，x3.....
第m+2行有m个数，由0 1构成，若控制（第i盏灯开关打开数量）%2与其一致时，则该灯可以亮，反之则不能。
问：当所有灯打开时，开关打开的方案数。
*/

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2<<11;
int dp[15][MAXN];
int ha[15][15];
int a[15];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int t;
        scanf("%d",&t);
        while(t--){
            int x;  scanf("%d",&x);
            ha[i][x]=1;
        }
    }
    for(int i=1;i<=m;i++)   scanf("%d",&a[i]);
    for(int i=0;i<=(1<<10)-1;i++)   dp[0][i]=1;
    for(int i=1;i<=m;i++){
        //cout<<i<<":"<<endl;
        for(int j=0;j<=(1<<n)-1;j++){
            //cout<<j<<endl;
            int cnt=1,ans=0,k=j;
            while(k){
                if(k&1){
                    if(ha[i][cnt])  ans++;
                }
                k>>=1;   cnt++;
            }
            //cout<<endl;
            if(!k && ans%2 == a[i] && dp[i-1][j]){
                //cout<<"*****"<<j<<endl;
                dp[i][j]=1;
            }
        }
    }
    int sum=0;
    for(int i=0;i<=(1<<10)-1;i++)
        if(dp[m][i])    sum++;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<string.h>
using namespace std;
int main(){
    int i,j;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
	return 0;
}

Measured memory_bytes: 0
N, T = map(int, input().split())

c_min = 1001
t_ = None
for _ in range(N):
    c, t = map(int, input().split())
    if T >= t and c_min > c:
        c_min = c
        t_ = t
if t_ == None:
    print("TLE")
else:
    print(c_min)

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    const ll INF = 1e18;
    int n,W; cin >> n >> W;
    int w[n],v[n],m = 1000*n;
    forn(i,n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1);
    forn(i,n+1) dp[i] = vector<ll>(m+1,INF);
    forn(i,n+1) dp[i][0] = 0;
    dforn(i,n) forsn(j,1,m+1){
        ll skip = dp[i+1][j];
        int d = j-v[i];
        ll take = d >= 0 && dp[i+1][d] != INF ? w[i] + dp[i+1][d] : INF;
        dp[i][j] = min(skip, take); 
    }
    int r = 0;
    forn(i,m+1) if(dp[0][i] <= W) r = i;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

const int Max = 1000005;
int main(void) 
{
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i,n) cin >> a[i];

   vector<int> memo(Max);
   rep(i,n)
   {
       if(memo[a[i]] != 0){
           memo[a[i]] =2;
       }
       else
       {
           for(int x = a[i]; x < Max; x+=a[i]) memo[x]++;
       }
   }
   int ans =0;
   rep(i,n) if(memo[a[i]] == 1) ans++;
   cout << ans << endl;
}

Measured memory_bytes: 8020
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

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

typedef long long ll;
const ll MOD = 1000000007; // 10^9+7
const ll INF = 100000000;

int main(void){
    int n,cnt=0;
    cin >> n;

    vector<ll> l(n,0);
    rep(i,n) cin >> l[i];

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if(abs(l[j]-l[k]) < l[i] && l[i] < l[j]+l[k]) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		Set<Integer> intersection = new HashSet<Integer>();

		for(int i=0; i<m; i++){
			intersection.add(i+1);
		}

		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			Set<Integer> set = new HashSet<Integer>();
			for(int j=0; j<k; j++){
				set.add(Integer.parseInt(sc.next()));
			}
			intersection.retainAll(set);
		}
		System.out.println(intersection.size());
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

int main( void ) {

    string s;
    cin >> s;

    int ans;

    for ( int i = s.size() - 1; i >= 0; i-- ) {
        if ( s.at(i) == 'Z' ) {
            ans = i;
            break;
        }
    }
    for ( int i = 0; i < s.size(); i++ ) {
        if ( s.at(i) == 'A' ) {
            ans -= (--i);
            cout << ans << endl;
            break;
        }
    }
 
    return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(M)]
judge = [[] for i in range(N)]
ans = [1 for i in range(N)]

#j[x][y]は、x個目の灯台からたどり着ける場所を列挙している。
for i in range(M):
  for j in range(2):
    judge[A[i][j]-1].append(A[i][j-1])
    
for k in range(N):
  for l in range(len(judge[k])):
    if H[k] > H[judge[k][l]-1]:
      continue
      
    else:
      ans[k] -= 1
      break
      
print(sum(ans))

Measured memory_bytes: 41956
#!/usr/bin/env python
# coding: utf-8
#
    
def main(n, t, ct):
    rtl = []
    for i in range(n):
        if ct[i][1] <= t:
            rtl.append(ct[i][0])
    if rtl == []:
        print('TLE')
    else:
        print(min(rtl))
    
    
if __name__ == '__main__':
    try:
        n, t  = list(map(int,input().strip().split(' ')))
        ct = []
        for i in range(n):
            ct.append(list(map(int, input().strip().split(' '))))
        main(n, t, ct)
    except EOFError:
        pass


Measured memory_bytes: 3064
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

_INPUT = """\
5 3
1 2
3 4
5 1
"""

def main(*, input=input):
    sr = lambda: input()
    ir = lambda: int(sr())
    lr = lambda: list(map(int, sr().split()))

    n,m = lr()
    uf = UnionFind(n)
    for i in range(m):
        a,b = lr()
        a-=1
        b-=1
        uf.union(a,b)
    ans = min(uf.parents)
    print(-ans)

if __name__ == "__main__":
    import io, sys

    # sys.stdin = io.StringIO(_INPUT)

    main()

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

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

#define pb push_back
#define pf push_front
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

//各位の和
template <typename T>
T sod(T n){
    T sum=0;
    while(n) {
        sum+=(n%10);
        n/=10;
    }
    return sum;
}


signed main() {
    ll n, ans=0;
    cin >> n;

    for (int i = 1; i <= n; i+=2) {
        ll ct=0;
        for (int j = 1; j <= i; ++j) {
            if(i%j==0)ct++;
        }
        if(ct==8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

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

    if(abs(n-m) > 1){
        P(0);
        ret 0;
    }
    ll ans = 1,ans2 = 1;
    rep(i,1,n+1){
        ans = mod(ans*i);
    }
    //P(ans);
    rep(i,1,m+1){
        ans2 = mod(ans2*i);
    }
   // P(ans2);
    ans = mod(ans * ans2);
    // P(ans);
    if((n+m)%2 == 0)ans = mod(ans * 2);
    P(ans);
    
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

map<char, pair<int, map<int, int> > > arr;

int parse(string &str, int &pos){
	if(isdigit(str[pos])){
		int res = 0;
		while(pos<str.size()&&isdigit(str[pos]))
			res = 10*res + str[pos++]-'0';
		return res;
	}
	char c = str[pos]; pos += 2;
	int idx = parse(str, pos);
	if(0 <= idx && idx < arr[c].first && arr[c].second.count(idx))
		return arr[c].second[idx];
	return -1;
}

int solve(vector<string> vs){
	arr.clear();
	for(int i=0;i<vs.size();i++){
		int p = vs[i].find("=");
		if(p!=string::npos){
			int pos = p+1;
			int val = parse(vs[i], pos);
			if(val==-1) return i+1;
			char c = vs[i][0];
			pos = 2;
			int idx = parse(vs[i], pos);
			if(idx==-1||idx>=arr[c].first) return i+1;
			arr[c].second[idx] = val;
		} else {
			int pos = 2;
			int size = parse(vs[i], pos);
			arr[vs[i][0]].first = size;
		}
	}
	return 0;
}

int main(){
	string str;
	while(cin >> str){
		if(str == ".") break;
		vector<string> vs; vs.push_back(str);
		while(cin >> str){
			if(str == ".") break;
			vs.push_back(str);
		}
		printf("%d\n", solve(vs));
	}
}

Measured memory_bytes: 0
sx, sy, tx, ty = map(int, input().split())
print('R'*(tx-sx)+'U'*(ty-sy+1)+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'RD'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'*(tx-sx+1)+'D'*(ty-sy))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x ,ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n ,k;
  cin >> n >> k;
  vl vec(n);
  ll g;
  rep(i,n){
    cin >> vec[i];
    if(vec[i]==k){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  if(k>*max_element(all(vec))){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  g=vec[0];
  rep(i,n){
    g=gcd(g,vec[i]);
  }
  if(k%g==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;     
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int sum=0;
    int maxp=0;

    for(int i=0;i<N;i++){
        int p;
        cin>>p;
        sum+=p;
        maxp=max(maxp,p);

    }
    cout<<sum-maxp/2<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val h = (1..n).map { sc.nextInt() }.toIntArray()

  var count = 1
  for (i in 1 until n) {
    val hi = h[i]
    var ok = true
    for (j in 0 until i) {
      val hj = h[j]
      if (hj > hi) {
        ok = false
        break
      }
    }
    if (ok) count++
  }

  println(count)
}


Measured memory_bytes: 37580
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

/* next combination */
ll next_combination(ll sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned long long N;
    cin >> N;
    vector<ll> d(N);
    REP(i, N) cin >> d[i];

    ll ans = 0;
    REP(j, N) {
        FOR(i, j, N) {
            if (i == j) continue;
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

'''for i in range(n):
	if i==0:
		conf = {A[i]:1}
		ans = 0
	else:
		add=max(conf.keys())
		ans+=add
		conf[A[i]] =2
		if conf[add] >1:
			conf[add] -= 1
		else:
			conf.pop(add)'''

if n%2==0:
	print(sum(A[:n//2]) *2 -A[0])
else:
	print(sum(A[:n//2]) *2 -A[0] +A[n//2])


Measured memory_bytes: 31428
def i2():
 return [int(i) for i in input().split()]

[n,h]=i2()
a=[]
for i in range(n):
 b=i2()
 a+=[[b[0],0],[b[1],1]]
a.sort()
a=a[::-1]
i=0
c=0
while a[i][1]==1 and h>0:
 h-=a[i][0]
 c+=1
 i+=1

if h>0:
 c+=h//a[i][0]
 if h%a[i][0]:c+=1
print(c)

Measured memory_bytes: 78040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  char c = '#';
  for (int i=0; i < b + 2; i++) {
    cout << c;
  }
  cout << endl;
  string s;
  for (int i=0; i < a; i++) {
    cin >> s;
    cout << c << s << c << endl;
  }
  for (int i=0; i < b + 2; i++) {
    cout << c;
  }
}

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

int main(){
  int N;
  cin >> N;
  int least = N;
  for(int i = 0; i <= N ;++i){
    int counter = 0;
    int t = i;
    while(t > 0){
      counter += t % 6;
      t /= 6;
    }
    t = N - i;
    while(t > 0){
      counter += t % 9;
      t /= 9;
    }
    if(least > counter) least = counter;
  }
  cout << least << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
int n,m,x[N],a[N],p[N],s[N],cnt;
long long k;
int be[N],num[N],v[N];
vector<int>q[N];
void dfs(int x,int dep)
{
    num[x]=dep;v[x]=1;be[x]=cnt;
    q[cnt].push_back(x);
    if(!v[p[x]])dfs(p[x],dep+1);
}
signed main()
{
    memset(v,0,sizeof(v));
    cin>>n;
    for(int i=1;i<=n;i++)cin>>x[i];
    for(int i=1;i<n;i++)s[i]=x[i+1]-x[i];
    cin>>m>>k;
    for(int i=1;i<n;i++)p[i]=i;
    for(int i=1;i<=m;i++){cin>>a[i];swap(p[a[i]],p[a[i]-1]);}
    for(int i=1;i<n;i++)if(!v[i])cnt++,dfs(i,0);
    cout<<x[1]<<endl;
    int now=x[1];
    for(int i=1;i<n;i++)
    {
        now+=s[q[be[i]][(num[i]+k)%q[be[i]].size()]];
        cout<<now<<endl;
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n/2){
    s.pop_back();
    s.pop_back();
    if(s.substr(0,s.size()/2) == s.substr(s.size()/2,s.size()/2)){
      cout << s.size() << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

class remainder():
    def __init__(self, mod=(10**9 + 7)):
        self.mod = mod
    
    def sub(self, a, b):

        return (a + self.mod - b) % self.mod
    
    def mul(self, a, b):

        return ((a % self.mod) * (b % self.mod)) % self.mod

    def pow(self, a, b):
        bp = []
        #bp.append(1)
        bp.append(a)

        n = len(bin(b)) - 2
        for x in range(n):
            bp.append(bp[x]**2 % self.mod)

        res = 1
        for x in range(n):
            if b >> x & 1:
                #res = re.mul(res, bp[x])
                res = (res * bp[x]) % self.mod
        
        return res

    def div(self, a, b):
        
        return self.mul(a, self.pow(b, self.mod - 2))

com = [0] * (B + 1)
com[0] = 1

re = remainder()

ans = re.pow(2, N) - 1
for x in range(1, B + 1):
    s = re.sub(N, x) + 1
    d = re.div(s, x)
    com[x] = re.mul(com[x - 1], d)


subA = com[A]
subB = com[B]

ans = re.sub(ans, subA)
ans = re.sub(ans, subB)

print(ans)


Measured memory_bytes: 45148
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using P = pair<int, int>;
#define LARGE 1000000

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
	}
	return x;
}

//オーバフローしないようにかける順番を気を付ける
ll lcm(ll x,ll y){
    return ll(x/gcd(x,y))*y;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ret;
    ret = gcd(a, b);

    const auto &res = prime_factorize(ret);
    ll z = 1;
    for(auto p : res) z++;
    cout << z << endl;

	return 0;
}

Measured memory_bytes: 3632
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    a = LIR(n)
    if n == 1:
        print(*a[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                if h > 0:
                    H = abs(x-cx)+abs(y-cy)+h
                    break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()
#D
def D():
    def factorize(n):
        if n == 1:
            return [1]
        if n<4:
            return [1,n]
        l = [1,n]
        m = n
        z = 2
        while z**2 <= n:
            if m%z == 0:
                l.append(z)
                if m//z != z:
                    l.append(m//z)
            z += 1
        l = list(set(l))
        l.sort()
        return l

    n,m = LI()
    l = factorize(m)
    for i in l[::-1]:
        if n*i <= m:
            print(i)
            quit()

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define IN(a) scanf("%d",&a);
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
	int a[3];
	REP(i,3){
		IN(a[i])
	}

	sort(a,a+3);

	REP(i,3){
		printf("%d",a[i]);
		if (i != 2)
			printf(" ");
	}
	printf("\n");
	return 0;
 }

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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("a_in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    int K = 0;

    if (A == B)
    {
        cout << 0;
    }
    else
    {
        if ((A+B) % 2)
        {
            cout << "IMPOSSIBLE";
        }
        else {
            cout << (A+B) / 2;
        }
    }

    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };
const int MOD=1e9+7;

int main() {
  // それぞれのポイント
  // ワーシャルフロイトで全ての点から点の最短距離を計算
  // 次に順列でどの順番が一番短いか

  ll n,m,r; cin >> n >> m >> r;
  vector<ll> r_vec(r);
  REP(i,r){
    cin >> r_vec[i];
    r_vec[i]--;
  }
  sort(ALL(r_vec));
  vector<vector<ll>> ab(n,vector<ll>(n,LLONG_MAX/4));
  REP(i,m){
    ll a,b,c; cin >> a >> b >> c;
    a--;b--;
    ab[a][b] = c;
    ab[b][a] = c;
  }

  REP(k,n)REP(i,n)REP(j,n){
    ab[i][j] = min(ab[i][j], ab[i][k] + ab[k][j]);
  }

  ll res = LLONG_MAX/4;
  do{
    ll temp = 0;
    REP(i,r-1){
      temp += ab[r_vec[i]][r_vec[i+1]];
    }
    res = min(res,temp);
  }while(next_permutation(ALL(r_vec)));

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
string s;
int main()
{
    int n;cin>>n;
    cin>>s;
    int ans=1;
    for(int i=1;i<s.size();i++)
        ans+=(s[i]!=s[i-1]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<string, int>> guide(n);
  vector<int> rank(n,n);
  for(int i=0;i<n;i++){
    cin>>guide[i].first>>guide[i].second;
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(guide[i].first<guide[j].first){rank[i]--;}
      else if(guide[i].first==guide[j].first&&guide[i].second<guide[j].second){rank[j]--;}
      else if(guide[i].first==guide[j].first&&guide[i].second>guide[j].second){rank[i]--;}
      else{rank[j]--;}
    }
  }
  vector<int> ans(n);
  for(int i=1;i<=n;i++){
      for(int j=0;j<n;j++){
          if(rank[j]==i){ans[i-1]=j+1;}
      }
  }  for(int i=0;i<n;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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


using namespace std;



int main() {

	int g[10] = {};

	int ans = 0;
	int n;
	cin >> n;

	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a < 400)g[0]++;
		else if (a < 800)g[1]++;
		else if (a < 1200)g[2]++;
		else if (a < 1600)g[3]++;
		else if (a < 2000)g[4]++;
		else if (a < 2400)g[5]++;
		else if (a < 2800)g[6]++;
		else if (a < 3200)g[7]++;
		else g[8]++;

	}

	for (int i = 0; i < 8; i++) {
		if (g[i])ans++;
	}
	int y = ans;
	y+=g[8];
//	y = min(y, 8);
ans=max(ans,1);
	cout << ans << " " << y << endl;
	

		return 0;

}




Measured memory_bytes: 256
#include <iostream>

using namespace std;
char a[55][55];
int h,w,i,j,k,l;
int main()
{
    cin>>h>>w;
    for(i=0;i<=50;++i)
    {
        for(j=i;j<=50;++j)
        {
            a[i][j]=a[j][i]='.';
        }
    }
    for(i=1;i<=h;++i)
    {
        for(j=1;j<=w;++j)
        {
            cin>>a[i][j];
        }
    }

    for(i=1;i<=h;++i)
    {
        for(j=1;j<=w;++j)
        {
            int sum=0;
            if(a[i][j]!='#')
            {
                for(k=-1;k<=1;++k)
                {
                    for(l=-1;l<=1;++l)
                    {
                        if(a[i+k][j+l]=='#')
                        {
                            sum++;
                        }
                    }
                }
                a[i][j]='0'+sum;
            }
        }
    }
    for(i=1;i<=h;++i)
    {
        for(j=1;j<=w;++j)
        {
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*input
7
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int x;
    cin>>x;
    cout<<(360/__gcd(360,x));
}

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

int main() {
  int N, count = 1;
  cin >> N;
  
  vector<int> mochi(N);
  
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  
  sort(mochi.begin(), mochi.end());
  
  for (int j = 1; j < N; j++) {
    
    if (mochi.at(j-1) < mochi.at(j))
      count++;
    else
      continue;
  
  }
  
  cout << count << endl;  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<string>
using namespace std;

inline int ReadInt() {
  char c;
  int ret(0);
  bool f(false);
  do c = getchar();
  while ((c < '0' || c > '9') && c != '-');
  if (c == '-') f = true, c = getchar();
  do ret = ret * 10 + c - '0', c = getchar();
  while ( c >= '0' && c <= '9');
  return f ? -ret : ret;
}

void Solve(const int &n, const int &k, const int &s, int &ans, 
	   const int &deep = 0,
	   const int &last = 0,
	   const int &sum = 0) {
  if (deep == k) {
    if (sum == s) ++ans;
    return;
  }
  for (int i(last+1); i <= n; ++i) {
    Solve(n, k, s, ans, deep + 1, i, sum + i);
  }
}

int main() {
  //freopen("t.txt","r",stdin);
  ios::sync_with_stdio(false);
  int n, k, s;
  while (cin >> n >> k >> s && n && k && s) {
    int ans(0);
    Solve(n, k, s, ans);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int l[10];
int N, A, B, C;

int dfs(int i, int a, int b, int c)
{
    if (i == N) 
    {
        // 竹を伸縮させるコスト. ただしどれかを無から生成し始めるパタンは棄却し、
        // 無の材料に合成したコストも引いておく
        return ((a*b*c>0) ? abs(A-a) + abs(B-b) + abs(C-c) - 30 : (int)1e9);
    }
    int ptn0 = dfs(i+1, a, b, c); // i本目の竹を無視する
    // 竹をa/b/cの材料へ合成する
    int ptn1 = dfs(i+1, a + l[i], b, c) + 10;
    int ptn2 = dfs(i+1, a, b + l[i], c) + 10;
    int ptn3 = dfs(i+1, a, b, c + l[i]) + 10;
    return min(min(ptn0, ptn1), min(ptn2, ptn3));
}

void solve()
{
  cin >> N >> A >> B >> C;
  REP0(i, N) cin >> l[i];
  cout << dfs(0, 0, 0, 0) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define print(x) cout << x << '\n';

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    string a;
    cin >> a;
    int res = 0;
    for(int i = 0; i < 3; i++){
        if(a[i] == '1') res++; 
    }
    printf("%d\n", res);

    
    return 0;
}


Measured memory_bytes: 256
a = {1, 3, 5, 7, 8, 10, 12}
b = {4, 6, 9, 11}
c = {2}
x, y = map(int, input().split())
if (x in a and y in a) or (x in b and y in b):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n = int(input())
p = dict()
for i in range(2, 10**6+1):
	if n%i == 0:
		p[i] = 1
		n //= i
		while n%i == 0:
			p[i] += 1
			n //= i
if n != 1:
	p[n] = 1

ans = 0
for v in p.values():
	res = 0
	cnt = 1
	while v >= cnt:
		res += 1
		v -= cnt
		cnt += 1
	ans += res
print(ans)

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

class Main {
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      int R = sc.nextInt();
      if (R < 1200) {
        System.out.println("ABC");
      } else if (R < 2800) {
        System.out.println("ARC");
      } else {
        System.out.println("AGC");
      }
    }
  }
}


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

public class Solution
{
    static int Solve(int N, long[] A, string S)
    {
        var basis = new List<long>();

        for (int i = N - 1; i >= 0; i--)
        {
            var e = A[i];
            foreach (var b in basis)
            {
                e = Math.Min(e, e ^ b);
            }
            if (e > 0)
            {
                if (S[i] == '0')
                {
                    basis.Add(e);
                }
                else
                {
                    return 1;
                }
            }
        }
        return 0;
    }

    public static void Main()
    {
        var answers = new List<int>();
        var T = int.Parse(Console.ReadLine());
        for (int i = 0; i < T; i++)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var S = Console.ReadLine();
            answers.Add(Solve(N, A, S));
        }

        Console.WriteLine(string.Join(Environment.NewLine, answers));
    }
}

Measured memory_bytes: 31768
function Main(input) {
  "use strict"
  const temp = input.split("\n")[0]
  if(temp === "AAA" || temp === "BBB") console.log("No")
  else (console.log("Yes"))
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>

using namespace std;

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

int main(){

    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;

    A--;
    int64_t Bnum = B - (B / C) - (B / D) + (B / lcm(C, D));
    int64_t Anum = (A) - (A / C) - (A / D) + (A / lcm(C, D));

    cout << Bnum - Anum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int MAXN = 510;

int N, C;
int board[MAXN][MAXN];
int clen[MAXN][MAXN];
int cdiff[3][MAXN];

int main()
{
    cin >> N >> C;
    for (int i = 0; i < C; i++)
        for (int j = 0; j < C; j++)
            cin >> clen[i][j];
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
        {
            cin >> board[i][j];
            board[i][j]--;
        }

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < C; j++)
        {
            cdiff[i][j] = 0;
            for (int k = 0; k < N; k++)
                for (int l = 0; l < N; l++)
                    if ((k + l) % 3 == i)
                        cdiff[i][j] += clen[board[k][l]][j];
        }

    int res = 1e9;
    for (int i = 0; i < C; i++)
        for (int j = 0; j < C; j++)
            for (int k = 0; k < C; k++)
                if (i != j && i != k && j != k)
                    res = min (res, cdiff[0][i] + cdiff[1][j] + cdiff[2][k]);
    cout << res << "\n";
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

vector<ll> dijkstra(int s,WeightedGraph  & G){
  using P = pair<ll, int>;
  int n=G.size();
  vector<ll> ds(n,INF);
  vector<int> bs(n,-1);
  priority_queue<P, vector<P>, greater<P> > pq;
  ds[s]=0;
  pq.emplace(ds[s],s);
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int v=p.second;
    if(ds[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      ll c=e.second;
      if(ds[u]>ds[v]+c){
        ds[u]=ds[v]+c;
        bs[u]=v;
        pq.emplace(ds[u],u);
      }
    }
  }
  return ds;
}


int main(){
  int n,m; cin >> n >> m;
  WeightedGraph G(n);
  for(int i = 1; i < n; ++i){
    G[i].push_back({i-1, 0});
  }
  for(int i = 0; i < m; ++i){
    int s,t,c;cin >> s >> t >> c;
    --s; --t;
    G[s].push_back({t,c});
  }
  auto d = dijkstra(0,G);
  ll ans = d[n-1];
  if(ans == INF)ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 10488
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  vector<int> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  if(n%2==1){
    for(i=n-1;i>=0;i-=2){
      cout<<a.at(i);
      if(i>0) cout<<' ';
    }
    for(i=1;i<n;i+=2) cout<<' '<<a.at(i);
  }
  else if(n%2==0){
    for(i=n-1;i>=0;i-=2){
      cout<<a.at(i);
      if(i>1) cout<<' ';
    }
    for(i=0;i<n;i+=2) cout<<' '<<a.at(i);
  }
  cout<<endl;
}

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

int main(void){
   
   int N;
   double sum_A = 0,sum_B = 1;
   cin >> N;
   int data[N];
   for(int i=0;i<N;i++){
       cin >> data[i];
       sum_B *= data[i];
   }
   
   for(int i=0;i<N;i++){
       sum_A += (sum_B / data[i]);
   }
   printf("%.16f\n",1 /  (sum_A / sum_B));
}

Measured memory_bytes: 3700