akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int main(){
  ll n, k;
  cin >> n >> k;
  ll fact[2000];
  ll inv[2000];
  inv[0] = 1;
  fact[0] = 1;
  for(int i = 1; i <= 2000; i++){
    fact[i] = fact[i-1] * i % MOD;
    ll p = MOD-2, tmp = fact[i];
    inv[i] = 1;
    while(p > 0){
      if(p&1) inv[i] = inv[i] * tmp % MOD;
      tmp = tmp * tmp % MOD;
      p >>= 1;
    }
  }
  inv[0] = 1;
  //出力
  for(int i = 1; i <= k; i++){
    ll ans = fact[k-1]*fact[n-k+1] % MOD;
    ans = ans * inv[k-i] % MOD;
    ans = ans * inv[i-1] % MOD;
    ans = ans * inv[i] %MOD;
    ans = ans * inv[n-k+1-i] % MOD;
    
    ll a = fact[k-1] * inv[i-1] % MOD;
    a = a * inv[k-i] % MOD;
    ll b = fact[n-k+1] * inv[i] %MOD;
    b = b * inv[n-k+1-i] % MOD;
    if(n-k+1-i < 0) ans = 0;
    cout << ans <<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
res = []
res.append(0 - dat[0])

import bisect

for i in range(1, n):
    #print(res)
    a = bisect.bisect_right(res, 0 - dat[i])
    #print("a={0}".format(a))

    if a == len(res):
        res.append( (0 - dat[i]) )
    else:
        res[a] = (0 - dat[i])

print(len(res))

Measured memory_bytes: 11036
#include <stdio.h>

using namespace std;

void output(int H[3][10]){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			printf(" %d",H[i][j]);
		}
		printf("\n");
	}
}


int main(){
	int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
		}
	}
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d",&h_num,&f_num,&r_num,&div_num);
		switch(h_num){
		case 1:
			H1[f_num-1][r_num-1] += div_num;
			break;
		case 2:
			H2[f_num-1][r_num-1] += div_num;
			break;
		case 3:
			H3[f_num-1][r_num-1] += div_num;
			break;
		case 4:
			H4[f_num-1][r_num-1] += div_num;
			break;
		}
	}

	output(H1);
	printf("####################\n");
	output(H2);
	printf("####################\n");
	output(H3);
	printf("####################\n");
	output(H4);

}






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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
  int N, i;

  cin >> N >> i;

  cout << (N-i+1) << endl;

  return 0;
}


Measured memory_bytes: 256
while True:
  n = input()
  if n == "0000":
    break
  if n.count(n[0]) == 4:
    print("NA")
    continue
  cnt = 0
  while n != "6174":
    cnt += 1
    l = "".join(sorted(list(n), reverse=True))
    s = "".join(sorted(list(n)))
    n = str(int(l) - int(s)).zfill(4)
  print(cnt)





Measured memory_bytes: 5612
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define dbg(x) cerr<<"["<<#x<<" = "<<x<<"]"

int D;
vector<vector<int>> s;
vector<int> c;

int get_score(vector<int> &sc) {
    unordered_map<int, int> last;
    int S = 0;
    for (int i = 0; i < D; ++i) {
        S += s[i][sc[i] - 1];
        last[sc[i] - 1] = i + 1;
        for (int j = 0; j < 26; j++)S -= c[j] * (i + 1 - last[j]);
        cout << S << endl;
//        dbg(S) << endl;
    }
    return max(1000000 + S, 0ll);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    cin >> D;
    c = vector<int>(26);
    s = vector<vector<int>>(D, vector<int>(26));
    for (auto &i:c)cin >> i;
    for (auto &i:s) {
        for (auto &j:i)cin >> j;
    }

    vector<int> ans(D);
    for (auto &i:ans)cin >> i;
//    unordered_map<int, int> last;
//    int tm = 1 + rand() % 26;
//    int S = s[0][tm - 1];
//    ans[0] = tm;
//    last[tm] = 1;
//
//    for (int i = 1; i < D; ++i) {
//        int cur = -1e18, pos = -1;
//        for (int j = 0; j < 26; ++j) {
//            int sc = S + s[i][j];
//
//            for (int k = 0; k < 26; ++k) {
//                if (k == j)continue;
//                sc -= c[k] * (i + 1 - last[k]);
//            }
//
//            if (sc > cur) {
//                cur = sc;
//                pos = j;
//            }
//        }
//        ans[i] = pos + 1;
//        last[pos] = i + 1;
//    }
//    for (auto i:ans)cout << i << endl;

    int score = get_score(ans);
//    dbg(score) << endl;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n;
    scanf("%d", &n);
    int x[n];
    rep(i, n) scanf("%d", &x[i]);
    int l;
    scanf("%d", &l);
    int lim[n][30];
    rep(i, n) lim[i][0] = lower_bound(x, x+n, x[i]+l+1) - x-1;
    rep(j, 29)rep(i, n) lim[i][j+1] = lim[lim[i][j]][j];
    int q;
    scanf("%d", &q);
    while(q--){
        int a, b;
        scanf("%d%d", &a, &b);
        --a; --b;
        if(a > b) swap(a, b);
        int ans = 0;
        rrep(i, 30)if(lim[a][i] < b){
            ans += 1 << i;
            a = lim[a][i];
        }
        printf("%d\n", ans + 1);
    }
}

Measured memory_bytes: 12928
#include<stdio.h>
#include<stdlib.h>
#define TYPE int
cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }

int main() {
	int N;
	long long tmp = 0, ans = 0;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * 3 * N);
	for (int i = 0; i < 3 * N; i++)
	{
		scanf("%d", &A[i]);
	}
	qsort(A, 3 * N, sizeof(TYPE), cmp_r);
	//for (int i = 0; i < 3 * N; i++)
	//{
	//	printf("%d", A[i]);
	//}
	for (int i = 1; i < 2 * N; i += 2)
	{
		tmp += (long long)A[i];
	}
	ans = tmp;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2556
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> numList = new ArrayList<Integer>();
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 0 && b == 0){
                break;
            }else if(a < b){
                numList.add(a);
                numList.add(b);
            }else{
                numList.add(b);
                numList.add(a);
            }
        }
        for(int i = 0; i < numList.size() / 2; i++){
            System.out.println(numList.get(i * 2) + " " + numList.get(i * 2 + 1));
        }
    }
}


Measured memory_bytes: 36792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int mod=1e9+7;
const int nax=1e7;
const ll inf=1e10+17;
vector<int> prime(nax,-1);

int main()
{
   int n;
   cin>>n;
   ll a[n];
   ll x1=0;
   for(int i=0;i<n;i++) {cin>>a[i];x1=x1^a[i];}

   for(int i=0;i<n;i++)
   {
       cout<<(a[i]^x1)<<" ";
   }
  
}

Measured memory_bytes: 43808
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int n,tot,ans,a[200001];
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		ans=(ans+tot*a[i]%mod)%mod;
		tot=(tot+a[i])%mod;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 5316
from enum import Enum

class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    Even = 2

def comp_str(A, B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.Even

N = int(input())

point_Taro = 0
point_Hanako = 0

for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0], line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1

print("%d %d"%(point_Taro, point_Hanako))


Measured memory_bytes: 6332
#include<bits/stdc++.h>
using namespace std;
int n,a[1000001],x;
bool check(int mid){
    int res=1,now=0;
    for(int i=0;i<n;i++){
        now+=a[i];
        if(now>mid)res++,now=a[i];
        if(a[i]>mid)return 0;
    }
    return res<=x;
}
int main(){
    cin>>n>>x;
    for(int i=0;i<n;i++)cin>>a[i];
    int l=0,r=1e9;
    while(l<r){
        int mid=(l+r)/2;
        if(check(mid))r=mid;
        else l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 3480
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H =sc.nextInt();
        int W =sc.nextInt();
        int field[][] = new int[H][W];
        for(int i=0;i<H;i++) {
            for(int j=0;j<W;j++) {
                int a = sc.nextInt();
                field[i][j]= a;
            }     
        }
        sc.close();
        
        int mul = 0;
        
        StringBuilder sb = new StringBuilder();
        
        for(int i=0;i<H;i++) {
            for(int j=0;j<W;j++) {
                if(j+1>=W)continue;
                if(field[i][j]%2==0)continue;
                int tmp1 = i+1;
                int tmp2 = j+1;
                int tmp3 = j+2;
                sb.append(tmp1+" "+tmp2+" "+tmp1+ " "+ tmp3 + "\n");
                field[i][j]--; field[i][j+1]++;mul++;
                
            }     
        }
        
        for(int i=0;i<H;i++) {
            if(i+1>=H)continue;
            if(field[i][W-1]%2==0)continue;
            int tmp1 = i+1;
            int tmp2 = i+2;
            int tmp3 = W;
            sb.append(tmp1+" "+tmp3+" "+tmp2+" "+tmp3+ "\n");
            field[i][W-1]--; field[i+1][W-1]++;mul++;
        }

        System.out.println(mul);
        System.out.println(sb.toString());
        
    }
}


Measured memory_bytes: 93624
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: i32 = input();
    println!("{}", if x < 1200 { "ABC" } else { "ARC" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
inline void solve()
{
	double n;cin>>n;
	printf("%.6lf\n",n*PI*2);

}
int main()
{
	solve();
	return 0;
}




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

int main(){
  int a,b;
  cin >> a >> b;
  int ans =10000;
   rep(i,10000){
   if(i*8/100 == a && i*10/100 == b && i<ans) ans = i;
  }
  if(ans == 10000) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3596
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, m, l;
LL s[101010], k[101010], sum[101010], dp[2020][2020];

LL calc(int a, int b) {
	return (sum[b + 1] - sum[a]) / l;
}

LL solve(int a, int b) {
	if (a < b)swap(a, b);
	if (dp[a][b] >= 0)return dp[a][b];
	int pos = max(a, b);
	if (pos == n - 1) {
		return dp[a][b] = calc(k[min(a, b)], k[pos]);
	}
	return dp[a][b] = min(solve(pos + 1, b) + calc(k[a], k[pos + 1]), solve(a, pos + 1) + calc(k[b], k[pos + 1]));
}

int main() {
	cin >> n >> m >> l;
	REP(i, 2020)REP(j, 2020)dp[i][j] = -1;
	REP(i, n) {
		cin >> k[i];
		k[i]--;
	}
	sort(k, k + n);
	REP(i, m) {
		cin >> s[i];
	}
	REP(i, m + 1) {
		sum[i] += sum[i - 1] + s[i - 1];
	}
	cout << solve(0, 0) << endl;
}


Measured memory_bytes: 36748
#include<stdio.h>

int main(void) {
	int X, Y;
	int min, max;
	int tmp;

	scanf("%d %d", &X, &Y);

	max = X >= Y ? X : Y;
	min = X >= Y ? Y : X;

	while (max%min) {
		tmp = max % min;
		
		max = tmp >= min ? tmp : min;
		min = tmp >= min ? min : tmp;
	}
	
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 2004
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

int main() {
  char buf[262144];
  scanf("%s", buf);
  std::string s = buf;

  if (s.length() == 1) return puts("1"), 0;

  size_t n = s.length();
  auto dp = make_vector<int>({n, 2_zu}, 0);
  dp[0][0] = dp[1][1] = 1;
  for (size_t i = 1; i < n; ++i) {
    if (s[i-1] != s[i]) {
      dp[i][0] = std::max(dp[i][0], dp[i-1][0]+1);
    }
    if (i > 1) {
      dp[i][0] = std::max(dp[i][0], dp[i-1][1]+1);
      dp[i][1] = std::max(dp[i][1], dp[i-2][0]+1);
    }
    if (i > 2 && (s[i-3] != s[i-1] || s[i-2] != s[i])) {
      dp[i][1] = std::max(dp[i][1], dp[i-2][1]+1);
    }
  }

  // for (size_t i = 0; i < n; ++i)
  //   fprintf(stderr, "%d%c", dp[i][0], i+1<n? ' ': '\n');
  // for (size_t i = 0; i < n; ++i)
  //   fprintf(stderr, "%d%c", dp[i][1], i+1<n? ' ': '\n');

  printf("%d\n", std::max(dp[n-1][0], dp[n-1][1]));
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
 	ll n;
 	cin>>n;
 	vl vec;
 	int i = 1;
 	vec.pb(0);
 	ll sum = 0;
 	while(sum<=pows(10,9))   
 	{
 		sum = sum + i;
 		vec.pb(sum);
 		++i;
 	}
 	int idx = -1;
 	for(int i=0; i<vec.size(); ++i)
 	{
 		if(vec[i]>=n)
 		{
 			idx = i;
 			break;
 		}
 	}
 	cout<<idx<<"\n";

}

Measured memory_bytes: 7932
#!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
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, a = LI()
    if x < a:
        print(0)
    else:
        print(10)
    return

#B
def B():
    n, x = LI()
    L = LI()
    ans = 0
    c = 1
    for i in L:
        ans += i
        if ans <= x:
            c += 1
            continue
        break
    print(c)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39024
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  import math
  from fractions import Fraction
  n = int(input())
  x = [1,1]
  for i in range(n):
    au,bu = x
    a,b = [int(i) for i in input().split()]
    
    nya = math.ceil(max(Fraction(au,a),Fraction(bu,b)))
    x = [nya*a, nya*b]
  print(int(sum(x)))
if __name__ == '__main__':
  main()

Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int N, K;
long long res = 1;
vector<vector<int>> G;
void dfs(int cur, int pre, int num) {
    //すでに処理が完了した距離2以内の頂点がi個ある場合、(K-i)を掛ける、ということを行っていこう。
    res = res * num % MOD;
    num = K - 1;
    if(pre != -1) {
        num--; //親でない
    }
    // cout << cur << endl;
    for(auto e : G[cur]) {
        if(e != pre) {
            //親には行かない
            dfs(e, cur, num);
            num--;
        }
    }
}
int main() {
    cin >> N >> K;
    G.resize(N);
    vector<int> a(N), b(N);
    REP(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(0, -1, K);
    cout << res << endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main(){
    string S, T, U;
    int A, B;
    cin>>S>>T>>A>>B>>U;
    int Sz=S.size();
    int SzU=U.size();
    if(Sz!=SzU){
        cout<<A<<" "<<B-1<<endl;
        return 0;
    }
    
    for(int i=0; i<Sz; i++){
        if(S.at(i)!=U.at(i)){
            cout<<A<<" "<<B-1<<endl;
            return 0;
        }
    }
    cout<<A-1<<" "<<B<<endl;
    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int tmp=k,cnt=1;
  while(n>=tmp){
    tmp*=k;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define watch(x) cout << (#x) << " is " << (x) << endl
 
bool isPrime(int i) {
	if(i < 2) {
		return false;
	}
	if(i == 2) {
		return true;
	}
	if(!(i % 2)) {
		return false;
	}
	for(int j = 3; j * j <= i; j += 2) {
		if(!(i % j)) {
			return false;
		}
	}
	return true;
}
void solve() {
	ll n, d;
	cin >> n >> d;
	ll ans = 0;
	set<pi> s;
	while(n--) {
		ll a, b;
		cin >> a >> b;
		a = abs(a);
		b = abs(b);
		if (d * d >= a * a + b * b) {
				ans++;
		}
	}
	cout << ans << "\n";

}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
    int T = 1; 
    // cin >> T;
    while(T--) {
    	solve();
    }
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    long long a[n+1],sum=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    a[n]=a[0];
    long long c=0;
    for(int i=1;i<n;i+=2){
        c+=a[i];
    }
    c*=2;
    vector<long long> ans(n);
    ans[0]=sum-c;
    for(int i=1;i<n;i++){
        ans[i]=(a[i-1]*2-ans[i-1]);
    }
    for(int i=0;i<n;i++){
        if(i)printf(" ");
        printf("%lld",ans[i]);
    }
    puts("");
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

bool nagomi(ll n){
    set<int> set1;
    while(n!=0){
        set1.insert(n%10);
        n /= 10;
	}
    if(set1.size()==3) return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    queue<ll> cho;
    for(int i=3;i<=7;i+=2){
        cho.push(i);
    }
    int count = 0;
    while(1){
        ll num = cho.front();
        cho.pop();
		 if(num>n)break;
        if(nagomi(num))count++;
        for(int i=3;i<=7;i+=2){
            ll b = num*10+i;
            cho.push(b);
        }
    }
    COUT(count);
    return 0;
} 


Measured memory_bytes: 768
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let M = scan.word::<usize>();
    let X = scan.word::<i64>();

    let mut T = vec![];
    for _ in 0..N {
        let c = scan.word::<i64>();
        let A = scan.list::<i64>(M);
        T.push((c, A));
    }

    let mut m = std::i64::MAX;
    let mut Y = vec![0; M];

    for s in 0..1 << N {
        let mut cost = 0;
        Y.clear();
        Y.resize(M, 0);

        for i in 0..N {
            if (s >> i) & 1 != 0 {
                cost += T[i].0;

                for j in 0..M {
                    Y[j] += T[i].1[j];
                }
            }
        }

        if Y.iter().all(|&y| y >= X) {
            m = m.min(cost);
        }
    }

    if m == std::i64::MAX {
        println!("-1");
    } else {
        println!("{}", m);
    }
}


Measured memory_bytes: 2152
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
 
using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
 
//debugger
 
#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger
 
//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const ll &a , const ll &b)
{
    return a>b;
}
const ll xyz=2e5+10;
ll fact[xyz];
void mod_fact(ll m=1)
{
    fact[0]=1;
    loop(i,(2e5)) 
    {
        ll p=i+1;
        //if(p%2==0) p/=2;
        fact[i+1]=(((fact[i])%m)*(p%m))%m;
    }
}

//functions


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FASTIO;
    int a,b;
    cin>>a>>b;
    ll n=1;
    ll ans=0;
    while(n<b)
    {
        n+=(a-1);
        ans++;
    }
    cout<<ans<<endl;
}
 

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

ll n,K;
ll dp[101][10001];
ll p[100000];

ll dfs(ll i,ll j){
  if(i==0)return 0;
  if(dp[i][j]!=-1)return dp[i][j];
  ll res=0;
  rep(k,K+1){ // ini val
    if(k>i||(j+k)<i){ // muri
      (res+=((j+k)*p[i-1])%mod)%=mod;
      (res+=dfs(i-1,j))%=mod;
    }else{ // dekiru
      ll cnt=(j+k)/i;
      (res+=(((j+k)%i)*p[i-1])%mod)%=mod;
      (res+=dfs(i-1,j+cnt))%=mod;
    }
  }
  return dp[i][j]=res;
}

int main(){
  cin>>n>>K;
  p[0]=1;
  rep(i,100000)p[i+1]=(p[i]*(K+1))%mod;
  memset(dp,-1,sizeof(dp));
  cout<<dfs(n,0)<<endl;
	return 0;
}


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

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

    vector<string> a(n) ;
  for(int i=0;i<n;i++){
    cin >> a.at(i) ;
}

 sort(a.begin(), a.end());

 for(int i=0;i<n;i++){
  cout << a.at(i) ;
}
 cout << endl ;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int n = sc.nextInt();
			if(n != 0){
				calc(n);
			}
			else{
				break;
			}
		}
	}
	public void calc(int n){
		int[] ans = new int[1000];
		int[] ent = new int[1000];
		String today = "";
		
		for(int i = 0; i < n; i++){
			String day = sc.next();
			if(!day.equals(today)){
				today = day;
				ent = new int[1000];
			}
			String time = sc.next();
			int t = calcTime(time);
			String inout = sc.next();
			int p = sc.nextInt();
			
			if(inout.equals("I")) ent[p] = t;
			else if(p == 0){
				for(int k = 1; k < n; k++){
					if(ent[k] != 0){
						ans[k] += Math.min(t - ent[k], t - ent[0]);
					}
				}
				ent[p] = 0;
			}
			else{
				if(ent[0] != 0){
					ans[p] += Math.min(t - ent[p], t - ent[0]);
				}
				ent[p] = 0;
			}
		}
		
		int max = 0;
		for(int i = 1; i < 1000; i++){
			if(max < ans[i]) max = ans[i];
		}
		
		System.out.println(max);
	}
	
	public int calcTime(String time){
		int hour = Integer.valueOf(time.substring(0,2));
		int minute = Integer.valueOf(time.substring(3));
		
		return hour * 60 + minute;
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 46328
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;

int main() {
  long long X,Y;
  cin >> X >> Y;
  int ans = 1;
  while(X*2 <= Y) {
    ans++;
    X *= 2;
  }
  cout << ans << endl;
  
  return 0;
}

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

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

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

    vector<int> bucket(110, 0);
    for (size_t i = 0; i < N; i++)
    {
        bucket[d[i]]++;
    }

    int res = 0;
    for (size_t i = 1; i <= 100; i++)
    {
        if (bucket[i])
            res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
const ll mod = 998244353;
const ll sz = 1e3 + 10, inf = 2 * 1e18 + 10;

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

	ll n, m;
	cin >> n >> m;
	ll s = 0;
	for (int i = 0; i < m; i++)
	{
		ll x; cin >> x;
		s += x;
	}
	if (s <= n)cout << n - s << '\n';
	else cout << "-1\n";

	return 0;
}

Measured memory_bytes: 3644
import java.util.*

fun main(args:Array<String>):Unit {
    val prime = primes(10000)
    var n = readLine()!!.toLong()
    while (n != 0L){
        var sumOfFactor:Long = 1L
        var restFactor = n
        prime.forEach {
            restFactor = divideWhile(restFactor, it)
            sumOfFactor *= sumOfExp(it, log(n, it))
        }
        if (restFactor != 1L) sumOfFactor *= restFactor + 1
        sumOfFactor -= n
        println(when{
            sumOfFactor < n -> "deficient number"
            sumOfFactor > n -> "abundant number"
            else -> "perfect number"
        })
        n = readLine()!!.toLong()
    }
}
fun log(n:Long, prime:Int):Int {
    return when{
        n % prime == 0L -> 1 + log(n / prime, prime)
        else -> 0
    }
}
fun divideWhile(n:Long, prime:Int):Long {
    return when{
        n % prime == 0L -> divideWhile(n / prime, prime)
        else -> n
    }
}
fun sumOfExp(prime:Int, exp:Int):Long {
    return when(exp){
        0 -> 1L
        else -> 1L + sumOfExp(prime, exp - 1) * prime
    }
}
fun primes(upper:Int):Array<Int> {
    val res = Stack<Int>()
    val memo = Array(upper + 1){true}
    res.push(2)
    for (i in 2 .. upper step  2)
        memo[i] = false
    for (i in 3 .. upper step 2)
        if (memo[i]){
            res.push(i)
            for (j in i * 2 .. upper step i)
                memo[j] = false
        }
    return res.toTypedArray()
}



Measured memory_bytes: 28272
import sys
from bisect import bisect_left
INF = 1 << 30

def main():
    N = int(input())
    for i in range(100):
        for j in range(100):
            if 4*i + 7*j == N:
                print('Yes')
                return
    print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys

N,M = map(int,input().split())
A = list(map(int,input().split()))

s = sum(A)
res = 0
tmp = sorted(A,reverse=True)

c = s/(4*M)
for i in range(M):
    if c > tmp[i]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll dp[4000][4000];

int main() {
  ll n, t;
  cin >> n >> t;
  vector<P> p(n);
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    p[i] = P(a, b);
  }

  REP(i, t) dp[0][i] = 0;
  sort(ALL(p));

  REP(i, n) REP(j, t) {
    if (j < p[i].first)
      dp[i + 1][j] = dp[i][j];
    else
      dp[i + 1][j] = max(dp[i][j], dp[i][j - p[i].first] + p[i].second);
  }

  ll ans = 0;
  REP(i, n) { ans = max(ans, dp[i][t - 1] + p[i].second); }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 94208
#include<cstdio>
using ll = long long;

int main(){
	int R, G, B, N;
	scanf("%d %d %d %d", &R, &G, &B, &N);
	int G_ = G, B_ = B, gcd = B;
	while(G_ % B_ != 0){
		gcd = G_ % B_;
		G_ = B_;
		B_ = gcd;
	}
	ll answer = 0;
	for (int r = 0; r*R <= N; ++r){
		if((N - R*r) % gcd == 0){
			for (int g = 0; g < B/gcd; ++g){
				if(N - R*r - G*g >= 0 && (N - R*r - G*g) % B == 0){
					answer += (N - R*r - G*g)/B/(G/gcd) + 1;
					break;
				}
			}
		}
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <tuple>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

class SegTree {
public:
    int f;
    vector<int> dat;

    SegTree(ll n) {
        f = 1;
        while (f < n) f *= 2;
        dat.assign(2 * f, /* INIT */ 0);
    }

    void add(int k, int v) {
        k += f - 1;
        dat[k] += v;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
        }
    }

    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
};

int main() {
    int n;
    char s[500050];
    cin >> n >> s;

    vector<SegTree> ST;
    for (int i = 0; i < 26; i++) {
        SegTree st(n);
        ST.push_back(st);
    }
    
    for (int i = 0; i < n; i++) {
        ST[s[i] - 'a'].add(i, 1);
    }    

    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int idx;  char c;
            cin >> idx >> c;
            idx--;
            if (c != s[idx]) {
                ST[s[idx] - 'a'].add(idx, -1);
                ST[c - 'a'].add(idx, 1);
            }
            s[idx] = c;
        }
        else {
            int l, r, ans = 0;
            cin >> l >> r;
            for (int i = 0; i < 26; i++) {
                ans += (ST[i].query(l - 1, r, 0, 0, ST[i].f) > 0);
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 111356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A_CanyougetAC
{
    class Program
    {
        static void Main(string[] args)
        {
            string strS = Console.ReadLine();

            for (int i = 0; i < strS.Length - 1; i++) {

                if (strS.Substring(i, 2) == "AC") {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");

        }
    }
}


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

using namespace std;

typedef  long long ll;

const ll MOD = 1e9 + 7;

const int maxN = 2 * 1e6 + 7;

int fact[maxN];

ll power(ll n, ll k){
	ll res = 1;
	while(k){
		if(k % 2) res = (res * n) % MOD;
		n = (n * n) % MOD;
		k /= 2;
	}
	return res;
}

ll inverse(ll n){
	return power(n, MOD - 2);
}

ll ncr(ll n, ll k){
	if(n < k) return 0;
	if(k == 0 || n == k) return 1;
	ll fact_n = fact[n];
	fact_n = (fact_n * inverse(fact[n - k])) % MOD;
	fact_n = (fact_n * inverse(fact[k])) % MOD;
	return fact_n;
}

int main(){
	int k;
	string s;
	cin >> k >> s;
	int size_s = s.size();
	int n = k + size_s;
	fact[0] = fact[1] = 1;
	for(int i = 2; i < maxN; i++){
		fact[i] = (fact[i - 1] * 1LL * i) % MOD;
	}
	int ans = 0;
	for(int i = size_s; i <= n; i++){
		int cur = (power(25, n - i) * 1LL *  ncr(n, i)) % MOD;
		ans = (ans + cur) % MOD;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 12152
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int flag[11][3];
int main(){
	int n;
	cin>>n;
	int a[11]={0};
	char b[11];
	while(n--){
		for(int i =0;i <11;i++){
			for(int j =0;j <3;j++){
				flag[i][j]=0;
			}
		}
		for(int i =0;i < 9;i++){
			cin>>a[i];
		}
		for(int i =0;i <9;i++){
			cin>>b[i];
		}
		/*rep(i,9)cout <<" "<<b[i];
		cout <<endl;*/
		for(int i =0;i <9;i++){
			if(b[i]=='R'){
				flag[a[i]][0]++;
			}else if(b[i]=='G'){
				flag[a[i]][1]++;
			}else{
				flag[a[i]][2]++;
			}
		}
		//bool ok[100]={false};
		//int pos = 0;
		
		for(int i =0;i <3;i++){
			for(int j =1;j <=9;){
				if(flag[j][i]&&flag[j+1][i]&&flag[j+2][i]){
					flag[j][i]--;
					flag[j+1][i]--;
					flag[j+2][i]--;
				}else if(flag[j][i]>=3){
					flag[j][i]-=3;
				}else{
					j++;
				}
			}
		}
		bool suc =true;
		for(int i =1;i <=9;i++){
			for(int j =0;j <3;j++){
				if(flag[i][j]){
					suc =false;
					break;
				}
			}
		}
		if(suc){
			cout <<1<<endl;
		}else{
			cout <<0<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int diff1 = x2 - x1;
    int diff2 = y2 - y1;
    int x3 = x2 - diff2;
    int y3 = y2 + diff1;
    diff1 = x3 - x2;
    diff2 = y3 - y2;
    int x4 = x3 - diff2;
    int y4 = y3 + diff1;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int n, k;
	cin >> n >> k;
	long long int ans = k;
	for (int i = 1; i < n; i++) {
		ans = ans * (k - 1);
	}
	cout << ans;
}

Measured memory_bytes: 256