akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // includes cin to read from stdin and cout to write to stdout
#include <map>
using namespace std; // since cin and cout are both in namespace std, this saves some text
#define REP(i, n) for (int (i)=0; i < (n); ++(i))

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    int res = 0;
    for (int i = 1; i < N -1; ++i)
    {
        int sum = 0;
        map<char, int> back;
        for (int s = i; s < N; ++s) {
            ++back[S[s]];
        }
//        for (auto it = back.begin(); it != back.end(); ++it)
//        {
//            cout << it->first << "," << it->second << endl;
//        }
        for (int s = 0; s < i; ++s) {
            if (back[S[s]] > 0) {
                ++sum;
                back[S[s]] = 0;
//                cout << i << ":find:" << S[s] << endl;
            }
        }
        if (res < sum) res = sum;
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
def isValid(row, col, ROWS, COLS):
    return row >= 0 and row < ROWS and col >= 0 and col < COLS

def search(matrix, row, col, ROWS, COLS, memo):
    if (row, col) in memo:
        return memo[(row, col)]
    
    numStrA = ''
    numStrB = ''

    rr = row + 1
    cc = col
    if isValid(rr, cc, ROWS, COLS) and matrix[rr][cc].isdigit():
        numStrA = search(matrix, rr, cc, ROWS, COLS, memo)

    rr = row
    cc = col + 1
    if isValid(rr, cc, ROWS, COLS) and matrix[rr][cc].isdigit():
        numStrB = search(matrix, rr, cc, ROWS, COLS, memo)

    numStrA = matrix[row][col] + numStrA
    numStrB = matrix[row][col] + numStrB

    if len(numStrA) > len(numStrB):
        val = numStrA
    elif len(numStrB) > len(numStrA):
        val = numStrB
    else:
        if numStrA > numStrB:
            val = numStrA
        else:
            val = numStrB

    memo[(row, col)] = val
    return val

if __name__ == '__main__':
    while True:
        COLS, ROWS = [ int(x) for x in list(filter(lambda x: x != '', \
            input().strip().split(' '))) ]
        if ROWS == 0 and COLS == 0:
            break

        matrix = []
        for _ in range(ROWS):
            matrix.append(input().strip())
        
        maxNum = 0
        memo = {}
        for row in range(ROWS):
            for col in range(COLS):
                if matrix[row][col].isdigit() and matrix[row][col] != '0':
                    maxNum = max(maxNum, int(search(matrix, row, col, ROWS, COLS, memo)))

        print(maxNum)


Measured memory_bytes: 5904
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string ans;
    if(n == 0)ans = "a";
    while(n){
        n--;
        ll t = n % 26;
        ans += 'a' + t;
        n /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;
}

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

class Main{
	public static void main(String[] args)throws IOException {
		String str="";
		BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
		String[] datas;
		int[] rika=new int[4];
		int[] syakai=new int[2];
		int rikamin=100;
		int syamin=100;

		int sum=0;

		for(int i=0; i<6; i++) {
			if(i<4) {
				rika[i]=Integer.parseInt(bfr.readLine());
				if(rika[i]<rikamin) {
					rikamin=rika[i];
				}
				sum+=rika[i];
			}
			else if(i>=4) {
				syakai[i-4]=Integer.parseInt(bfr.readLine());
				if(syakai[i-4]<syamin) {
					syamin=syakai[i-4];
				}
				sum+=syakai[i-4];
			}
		}
		sum=sum-syamin-rikamin;
		System.out.println(sum);
	}
}


Measured memory_bytes: 24240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  bool flag = 1;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a%2 == 0) {
      if (a%3!=0 && a%5!=0) flag = 0;
    }
  }
  if (flag) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
int main()
{ ll N , X, T , a, b;
  cin>>N>>X>>T;
   a=N%X;
   b=N/X;
   if(a==0)
     cout<<T*b;
    else
      cout<<T*(b+1);
  
}

Measured memory_bytes: 3544
w=eval(input())
n=eval(input())
edge=[]
for i in range(n):
    edge.append(tuple(map(int,input().split(','))))
for i in range(1,w+1):
    temp=i
    for j in range(n):
        if temp in edge[n-j-1]:
            temp=edge[n-j-1][edge[n-j-1].index(temp)-1]
    print(temp)

Measured memory_bytes: 7504
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=4e2+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n,p;

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> p;
	For(i,0,n)
	{
	    ll x;
	    cin >> x;
	    if (x%2) RET((1LL<<(n-1)));
	}
	if (p) RET(0);
	RET((1LL<<n));
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#include <iomanip>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 100000
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
double PI = atan2(0, -1);
 
map<ll,int> prime_factors;
void prime_factorization(ll n) {
	while (n%2 == 0) {
		n /= 2;
		prime_factors[2]++;
	}
	for (ll i = 3; i * i <= n; i = i+2) {
		while (n%i == 0) {
			n /= i;
			prime_factors[i]++;
		}
	}
	if (n > 2) {
		prime_factors[n]++;
	}
}
 
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
 
int main () {
	ll A, B;
	cin >> A >> B;
	ll g = gcd(A,B);
	prime_factorization(g);
	cout << prime_factors.size() + 1 << endl;
    return 0;
}

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

int main() {

    ll a, b, k;
    cin >> a >> b >> k;

    rep(i, k){
        if(i%2 == 0){
            if(a&1) --a;
            a /= 2;
            b += a;
        }
        else{
            if(b&1) --b;
            b /= 2;
            a += b;
        }
    }
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h, w, a):
    da = [[0] * w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1, w):
        da[0][i] = da[0][i - 1] + a[0][i]
    for i in range(1, h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i - 1][j] + cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p, q, x, y):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y] - da[x][q - 1]
    if q == 0:
        return da[x][y] - da[p - 1][y]
    return da[x][y] - da[p - 1][y] - da[x][q - 1] + da[p - 1][q - 1]

H, W, K = map(int, sys.stdin.readline().rstrip().split())
grid = [list(map(int, list(sys.stdin.readline().rstrip()))) for _ in range(H)]
da = da_generate(H, W, grid)

ans = 10 ** 18
for i in range(2**(H - 1)):
    res = 0
    s = [k for k, j in enumerate(range(H), 1) if i >> j & 1] # s行は含まない
    res += len(s)
    s.append(H)
    y = 0
    for w in range(1, W + 1): # w行は含まない
        x = 0
        flag = False
        for s_i in s:
            if da_calc(x, y, s_i - 1, w - 1) > K:
                if y + 1 < w:
                    res += 1
                    y = w - 1
                else:
                    flag = True
                break
            x = s_i
        else:
            pass
        if flag:
            break
    else:
        ans = min(ans, res)

print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

ll dp[110][10][5][2];

ll calc(ll n, ll k) {
    if(n < k) return 0;
    ll ret = 1LL;
    for(ll i = n; i > n - k; --i) ret *= i;
    REP(i, 1, k+1) ret /= i;
    return ret;
}

int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    ll ans = calc(n-1, k)*pow(9, k);
    // cout << ans << endl;
    {
        int d = s[0]-'0';
        REP(num, 1, d+1) {
            dp[0][num][1][(num==d?1:0)] = 1;
        }
    }
    REP(i, 1, n) {
        int d = s[i] - '0';
        rep(num, 10) rep(pre, 10) {
            rep(j, k+1) {
                dp[i][num][j+(num != 0 ? 1 : 0)][0] += dp[i-1][pre][j][0];
                if(d == num) dp[i][num][j+(num != 0 ? 1 : 0)][1] += dp[i-1][pre][j][1];
                if(num < d) dp[i][num][j+(num != 0 ? 1 : 0)][0] += dp[i-1][pre][j][1];
            }
        }
    }
    rep(num, 10) {
        ans += dp[n-1][num][k][0] + dp[n-1][num][k][1];
        // cout << num << " " << dp[n-1][num][k][0] << " " << dp[n-1][num][k][1] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] candy = new int[3];
		for(int i = 0; i < 3; i++) {
			candy[i] = sc.nextInt();
		}
		Arrays.sort(candy);
		if(candy[0] + candy[1] == candy[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'

int N;
int color[100005];
vector<int> tree[100005];
vector<int> path;

bool dfs1(int s, int bef) {
  if (s == N - 1) {
    path.push_back(s);
    return true;
  }

  for (int t: tree[s]) {
    if (t == bef) continue;
    if (dfs1(t, s)) {
      path.push_back(s);
      return true;
    }
  }

  return false;
}

void dfs2(int s, int bef) {
  color[s] = 1;

  for (int t: tree[s]) {
    if (t == bef) continue;
    if (color[t] == -1) continue;
    dfs2(t, s);
  }
}

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

  cin >> N;
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  dfs1(0, -1);
  reverse(path.begin(), path.end());

  //rep(i, path.size()) cout << path[i] << " ";
  //cout << endl;

  rep(i, path.size()) {
    if (color[path[i]] == 0) color[path[i]] = 1;
    if (color[path[path.size() - i - 1]] == 0) color[path[path.size() - i - 1]] = -1;
  }

  dfs2(0, -1);

  int cnt = 0;
  rep(i, N) if (color[i] == 1) cnt++;

  //cout << cnt << endl;
  cout << (cnt > N - cnt ? "Fennec":"Snuke") << endl;

  return 0;
}


Measured memory_bytes: 11384
import math
a, b, x = map(int, input().split())

v = a*a*b
# 台形
if v/2 < x:
    c = (v - x) * 2 / (a ** 2)
    print(math.atan2(c, a)/math.pi*180)
# 三角形
else:
    c = x * 2 / (a*b)
    print(math.atan2(b, c)/math.pi*180)


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;++i)cin >> arr[i];
	int vis[n];
	memset(vis, 0, sizeof(vis));
	int temp = arr[0];
	int steps = 1, c= 1;
	while(temp != 2){
		if(vis[temp - 1] == 0){
			steps++;
			vis[temp - 1]++;
			temp = arr[temp - 1];	
		}
		else {
			c = 0;
			break;
		}
	}
	(c == 1)?cout << steps:cout << -1;
}




Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll k,a,b;cin>>k>>a>>b;
    if(b-a <= 2){
        cout << 1+k << endl;
        return 0;
    }
    ll tap = a-1;
    ll change = (k-tap)/2;
    if(k-tap <= 0){
        cout << 1+k << endl;
        return 0;
    }
    if((k-tap)%2)tap++;
    cout << 1+tap+(b-a)*change << endl;
}



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

int main()
{
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  
  sort(a.begin(), a.end());
  
  int sum = 0;
  int num = 0;
  for(int i = 0; i < n; ++i)
  {
    sum += a[i];
    if(sum < x)
    {
      num++;
    }
    else if(sum == x)
    {
      num++;
      break;
    }
    else
    {
      break;
    }
  }
  if(sum < x) num--;
  cout << num << endl;
}


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

using namespace std;

int a[4], c[4];
double d[333][333][333];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		c[a]++;
	}
	for (; a[3] <= c[3]; a[3]++) {
		for (a[2] = 0; a[2] <= n - c[1]; a[2]++) {
			for (a[1] = 0; a[1] <= n; a[1]++) {
				int t = a[1] + a[2] + a[3];
				if (!t) continue;
				double x = n;
				if (a[1]) x += d[a[1] - 1][a[2]][a[3]] * a[1];
				if (a[2]) x += d[a[1] + 1][a[2] - 1][a[3]] * a[2];
				if (a[3]) x += d[a[1]][a[2] + 1][a[3] - 1] * a[3];
				d[a[1]][a[2]][a[3]] = x / t;
			}
		}
	}
	cout.precision(18);
	cout << d[c[1]][c[2]][c[3]] << endl;
	return 0;
}


Measured memory_bytes: 262272
#include<cstdio>

int main(void) {
  int i, j, k;
  int *number;
  int *digits;
  int N, M;
  int s, c;
  int flag = 0;
  scanf("%d %d", &N, &M);
  number = new int[N];
  digits = new int[N];
  for(i = 0;i < N;i++) {
    digits[i] = 0;
    number[i] = 0;
  }
  for(i = 0;i < M;i++) {
    int s, c;
    scanf("%d %d", &s, &c);
    if(!flag) {
      if(number[s - 1] != c && digits[s - 1]) flag = 1;
      digits[s - 1] = 1;
      number[s - 1] = c;
    }
  }
  if(N != 1 && number[0] == 0) {
    if(digits[0]) {
      flag = 1;
    } else {
      number[0] = 1;
    }
  }
  if(flag) {
    puts("-1");
  } else {
    for(i = 0;i < N;i++) printf("%d", number[i]);
    puts("");
  }
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

immutable long inf = 10L^^16L;

int n, k;
int[] a;

void main() {
    scan(n, k);
    a = iota(n).map!(i => readln.chomp.to!int).array;
    a[] -= k;

    auto ac = new long[](n + 1);
    iota(n).each!(i => ac[i + 1] = ac[i] + a[i]);

    auto acc = compress(n + 1, ac.dup);

    debug {
        writeln("ac:", ac);
        writeln("acc:", acc);
    }

    auto ft = FenwickTree(n + 1);

    long ans;

    foreach (i ; 0 .. n + 1) {
        ans += ft.psum(acc[i]);
        ft.add(acc[i], 1);
    }

    writeln(ans);
}

auto compress(int n, long[] a) {
    auto res = new int[](n);
    auto idx = iota(n).array;

    sort(zip(a, idx));

    int num = 0;
    long p = -inf;

    foreach (i ; 0 .. n) {
        if (a[i] != p) num++;
        res[idx[i]] = num;
        p = a[i];
    }

    return res;
}

struct FenwickTree {
    private {
        int n;
        int[] data;
    }

    this(int N) {
        this.n = N;
        data = new int[](n + 1);
    }

    void add(int i, int x) {
        while (i <= n) {
            data[i] += x;
            i += i & (-i);
        }
    }

    int psum(int i) {
        return i > 0 ? psum(i - (i & (-i))) + data[i] : 0;
    }
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
const int maxM=(2e5)+5;

long long a[maxM],sp[maxM],f[maxM];
long long n;
long long x,m,dim;
int pos;
int main()
{
  	cin >> n >> x >> m;

    a[1]=x;
    f[a[1]]=1;

    dim=1;

    while(dim<n)
    {
        dim++;
        a[dim]=(1LL*a[dim-1]*a[dim-1])%m;
        if(f[a[dim]])
        {
            pos=f[a[dim]];
            dim--;
            break;
        }
            else f[a[dim]]=dim;

    }

    for(int i=1;i<=dim;i++)
    {
        sp[i]=(sp[i-1]+a[i]);
    }


    long long sol=0;

    if(n<=dim) sol=sp[n];
        else
    {
        sol=sp[pos-1];
        int len=dim-pos+1;
        long long add=sp[dim]-sp[pos-1];

        sol=(sol+(n-pos+1)/len*add+sp[pos+(n-pos+1)%len-1]-sp[pos-1]);


    }
    cout << sol;



    return 0;
}

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

int long long ryu[3];

int main(){
    int N;
    cin>>N;
    if(N==0) cout<<2<<endl;
    else if(N==1) cout<<1<<endl;
    else {
        ryu[0]=2;
        ryu[1]=1;
        int long long tmp;
        for(int i=0;i<N-1;i++){
            tmp=ryu[0]+ryu[1];
            ryu[0]=ryu[1];
            ryu[1]=tmp;
        }
        cout<<ryu[1]<<endl;
    }
}

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

typedef vector<int> vi;
int K;
vector<vi> G;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main(void) {
	cin >> K;
	G.resize(K + 1, vi(K + 1, 0));
	for (int a = 1; a <= K; ++a) {
		for (int b = 1; b <= K; ++b)
			G[a][b] = gcd(a, b);
	}

	int sum = 0;
	for (int a = 1; a <= K; ++a) {
		for (int b = 1; b <= K; ++b) {
			for (int c = 1; c <= K; ++c)
				sum += G[a][G[b][c]];
		}
	}

	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 3660
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = (N+"").length();
		for (long i = 1; i * i <= N; i++) {
			if (N % i == 0 && ((N/i)+"").length() < ans) {
				ans = ((N/i)+"").length();
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
    int m;
    int f;
    int r;
    while(1){
        scanf("%d%d%d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1){
            break;
        }
        else if(m==-1||f==-1){
            printf("F\n");
        }
        else if(m+f>=80){
            printf("A\n");
        }
        else if(m+f>=65&&m+f<80){
            printf("B\n");
        }
        else if((m+f>=50&&m+f<65)||(m+f>=30&&m+f<50&&r>=50)){
            printf("C\n");
        }
        else if(m+f>=30&&m+f<50&&r<50){
            printf("D\n");
        }
        else{
            printf("F\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, A, B;
    in3(N, A, B);
    if(A>B || (A!=B&&N==1)) puts("0");
    else put((B-A)*(N-2)+1);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
using namespace std;

// int c[maxn][maxn];
// int d[maxn];
// bool vis[maxn];
// int V;
struct node{int u,v;};
int res[maxn];
vector<vector<int>> G(maxn);
queue<node> q;

/*void dij(int s) {
	fill(d, d+V, INF);
	fill(vis, vis+V, false);
	d[s]=0;
	while(true) {
		int v=-1;
		rep(u, 0, V) {
			if (!vis[u] && (v==-1 || d[u] < d[v])) v=u;
		}
		if (v==-1) break;
		vis[v] = true;
		rep(u, 0, V) {
			d[u] = min(d[u], d[v]+c[v][u]);
		}
	}
}*/
void bfs() {
	node st = {1, 0};
	q.push(st);
	while(!q.empty()) {
		node cur = q.front();
		q.pop();
		for(auto c:G[cur.u]) {
			if (res[c] != 0) continue;
			node nxt = {c, cur.v+1};
			//cout << "cur:" << c << "val:" << nxt.v << '\n';
			res[c] = cur.u;
			q.push(nxt);
		}
	}
}

void slove() {
	ll n, m, a, b;
	cin >> n >> m;
	rep(i, 0, maxn) res[i]=0;
	rep(i, 0, m) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
		//c[a][b] = c[b][a] = 1;
	}
	bfs();
	int flag = 1;
	rep(i, 2, n+1) {
		if (res[i]==0) {
			flag=0; cout << "No"; return;
		}
	}
	cout << "Yes\n";
	rep(i, 2, n+1) {
		cout << res[i] << '\n';
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	slove();

	return 0;
}

Measured memory_bytes: 10448
n,y = map(int, input().split())

for i in range(n, -1, -1):
  if  y - 10000*i < 0: continue
  for j in range(n-i, -1, -1):
    k = n-i-j
    if y - 10000*i - 5000*j - 1000*k < 0: continue
    elif y - 10000*i - 5000*j - 1000*k == 0:
      print(i,j,k)
      exit()
print(-1,-1,-1)

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}


int main() {
int N;
cin>>N;
map<string,int> mapa;
int mx = 0;
for(int i=0;i<N;i++) {
    string s;
    cin>>s;
    mapa[s]++;
    mx = max(mapa[s],mx);
}
for(auto x: mapa) {
    if(x.second==mx) cout<<x.first<<endl;
}
return 0;
}


Measured memory_bytes: 25216
n,y = [int(x) for x in input().split()]

for i in range(n+1):
    for j in range(n+1-i):
        res = 10000*i+5000*j+1000*(n-i-j)
        if (res == y):
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> a,b;
int c[100005];
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='L') a.push_back(i);
        if(s[i]=='R') b.push_back(-i);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(int i=0;i<s.length();i++){
        if(s[i]=='L') continue;
        int x=*lower_bound(a.begin(),a.end(),i);
        if((x-i)%2==0) c[x]++;
        else c[x-1]++;
    }
    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='R') continue;
        int x=-*lower_bound(b.begin(),b.end(),-i);
        if((i-x)%2==0) c[x]++;
        else c[x+1]++;
    }
    for(int i=0;i<s.length();i++){
        cout<<c[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 2032
n = input()
n = input()
ans = 0
for i in range(len(n)):
    a = n[0:i+1]
    b = n[i+1:len(n)]
    al = sorted(list(set(list(a))))
    bl = sorted(list(set(list(b))))
    temp = 0
    for j in range(len(al)):
        if al[j] in bl:
            temp += 1
    if ans < temp:
        ans = temp
print(ans)

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int count=0, m=0;
	for (int i = 0;i < n;i++) {
		if (s.at(i) == 'I')count++;
		if (s.at(i) == 'D')count--;
		m = max(m, count);
	}
	cout << m << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#include <iomanip>

using namespace std;
vector<vector<int> > to, cost;

void dfs(vector<int>& v, int num, int c, int from) {
	v[num] = c;
	for (size_t i = 0; i < to[num].size(); i++)
	{
		if(to[num][i] == from) continue;
		dfs(v, to[num][i], c + cost[num][i], num);
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > to_l(n+1), cost_l(n+1);
	for (size_t i = 0; i < n-1; i++)
	{
		int a, b, w;
		cin >> a >> b >> w;
		to_l[a].push_back(b);
		cost_l[a].push_back(w);
		to_l[b].push_back(a);
		cost_l[b].push_back(w);
	}
	// to = vector<vector<int> >(to_l);
	// cost = vector<vector<int> >(cost_l);
	vector<int> v(n+1, -1);
	v[1] = 0;
	queue<int> q;
	q.push(1);
	while(!q.empty()) {
		int j = q.front();
		q.pop();
		for (size_t i = 0; i < to_l[j].size(); i++)
		{
			int u = to_l[j][i];
			int w = cost_l[j][i];
			if(v[u] != -1) continue;
			v[u] = w + v[j];
			q.push(u);
		}
	}
	// dfs(v, 1, 0, 1);
	for (size_t i = 1; i < n+1; i++)
	{
		if(v[i] % 2 == 0) cout << 1 << endl;
		else cout << 0 << endl;
	}
}


Measured memory_bytes: 11904
#include<iostream>
#include<algorithm>
#include<string>


using namespace std;


int main()
{
	string t, p;

	ios::sync_with_stdio(false);

	cin >>t>>p;

	int n = t.find(p);
	while (n!=-1)
	{
		cout << n << endl;
		n = t.find(p, n + 1);
	}

	return 0;

}


Measured memory_bytes: 3252
#include <stdio.h>
int main(void){
  int a,b,c,i;
  scanf("%d%d%d",&a,&b,&c);
  for (i=1;i<=b;i++){
    if (a*i%b==c) break;
  }
  printf("%s\n",(i==b+1)? "NO":"YES");
  return 0;
}

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

int main() {
  int A,N,x;
  cin >> N >> A;
  
  x = N % 500;
  x = A - x;

  if (x >= 0) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		int[] h = new int[N + 1];
		int[] d = new int[N + 1];
		for (int i=1; i <= N; i++) {
			h[i] = in.nextInt();
			d[i] = INF;
		}
		d[1] = 0;
		d[2] = Math.abs(h[2] - h[1]);
		for(int i=3; i<=N; i++) {
			for(int j=1; j<=K && i-j >= 1; j++) {
				d[i] = Math.min(d[i], d[i-j] + Math.abs(h[i-j]-h[i]));
			}
		}
		System.out.println(d[N]);
	}
}

Measured memory_bytes: 57860
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_num = a[-1] + 1
cnt = [0] * (max_num)
a.sort()
ans = 0


for i in a:
    cnt[i] += 1

a = set(a)

for k in a:
    for l in range(k * 2, (max_num), k):
        cnt[l] += 1

for m in a:
    if cnt[m] == 1:
        ans += 1
    


print(ans)


Measured memory_bytes: 39444
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[1050] = {}, f[100010] , counto = 0, counto1 = 1145148;
double syo = 0, su = 0;
bool mazi = false, gi[110] = { false };
pair<int, int>n[110];
vector<int> r;
int main() 
{
	cin >> a >> b >> c;
	for (int i = 0; i < a; i++) {
		cin >> e[i];
		e[i] = b*1000 - e[i] * 6;
		e[i] = abs(c*1000 - e[i]);
	}
	for (int i = 0; i < a; i++) {
		counto1 = min(counto1, e[i]);
		if (counto1 == e[i]) {
			counto = i + 1;
		}
	}
	cout << counto << endl;
	return 0;
}

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

int main(){
    long long n;
    cin >> n;
    if (n % 2){
        cout << 0 << endl;
        return 0;
    }
    long long cnt_two = 0;
    for (int i = 1; i <= 60; i++) cnt_two += n / (long long)pow(2, i);
    long long cnt_five = 0;
    for (int i = 1; i <= 26; i++) cnt_five += n / ((long long)pow(5, i) * 2);
    cout << min(cnt_two, cnt_five) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll i) {
	ll sum = 1;
	for (ll j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
#define int long long
const long long iinf = 4523372036854775807;
const int inf = 1500000000;
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int k, a[100000];
signed main() {
	cin >> k;
	for (int i = 0; i < k; i++)
		cin >> a[i];
	int s = 2, e = 2;
	for (int i = k - 1; i >= 0; i--) {
		int s1 = floor(e*1.0 / a[i])*a[i];
		int s2 = ceil(s*1.0 / a[i])*a[i];
		if (s2 > s1) {
			cout << -1 << endl;
			return 0;
		}
		e = s1 + a[i] - 1;
		s = s2;
	}
	cout << s << " " << e << endl;
	getchar(); getchar();
}

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

#define int long long

using namespace std;

const int N = 105, M = 1e6 + 123;

int n, s;

int w[N], a[N], can[M], dp[M], ans;

main () {
    cin >> n >> s;
    for (int i = 1;i <= n;i ++) {
        cin >> w[i] >> a[i];
    }can[0] = 1;
    for (int i = 1;i <= n;i ++) {
        for (int j = s - 1;j >= 0;j --) {
            if (can[j]) {
                can[j + w[i]] = 1;
                dp[j + w[i]] = max (dp[j + w[i]], dp[j] + a[i]);
                if (j + w[i] <= s)ans = max (ans, dp[j + w[i]]);
            }
        }
    }cout << ans;
}


Measured memory_bytes: 5888
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
void solve(){
	ll n , m ;
	cin>> n >> m ;
	char arr[n][m];
	ll dp[n][m];
	memset(dp , 0, sizeof dp);
	for(ll i=0;i<n ;i++){
		for(ll j=0;j<m ; j++){
			cin>>arr[i][j];
		}
	}
	if(arr[0][0]=='#'){
		dp[0][0]=1;
	}
	else dp[0][0]=0;
	for(ll i=1;i<n ;i++){
		dp[i][0] = arr[i][0]=='#' && arr[i-1][0]=='.'? dp[i-1][0]+1 : dp[i-1][0];
	}
	for(ll i=1;i<m ;i++){
		dp[0][i] = arr[0][i]=='#' && arr[0][i-1]=='.' ? dp[0][i-1]+1 : dp[0][i-1];
	}
	for(ll i=1;i<n ;i++){
		for(ll j= 1 ; j<m ; j++){
			ll a =0 , b=0;
			if(arr[i][j]=='#'){
				if(arr[i-1][j]=='.')a=1;
				if(arr[i][j-1]=='.')b=1;
			}
			dp[i][j]=min(dp[i-1][j]+a , dp[i][j-1]+b);
		}
	}
	
	cout<<dp[n-1][m-1]<<endl;
}
int main(){
	//mahakal(),fast;
	solve();

	return 0;
}

Measured memory_bytes: 384
/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}
typedef long long LL;
int n; char S[30];
inline LL calc(int s) {
	s |= 1 << (n - 1);
	LL res = 0, fi = 0;
	for (rg int i = 1; i <= n; ++i) {
		fi = 1ll * fi * 10ll + (LL) (S[i] - 48);
		if (s >> (i - 1) & 1) res += fi, fi = 0ll;
	}
	return res;
}
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("in.in", "r", stdin);
// #endif
	scanf("%s", S + 1), n = strlen(S + 1);
	LL res = 0;
	for (rg int s = 0; s < 1 << (n - 1); ++s) res += calc(s);
	printf("%lld", res);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	/*
	 * idea : 
	 * 	suppose output_m1 is a snukeNumber
	 *  first plus 1 and check whether 10^numberOfTrailNine()*S(output)≥output
	 *  if true then output
	 *  else plus 10^i and verify again until find next value;
	 */

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int k=1;
		long output = 0;
		labelB:
		while(k<=K) {
			labelA:
			while(output < Math.pow(10, 15)){
				long temp = output;
				for(int i = 0; i < 15 ; i++) {
					temp += (long) Math.pow(10, i);
					if(Math.pow(10, countNineNumber(temp))*digitSum(temp) >= temp) {
						output = temp;
						System.out.println(output);
						k++;
						break labelA;
					}else {
						temp = output;
					}
				}
			}
			if(output > Math.pow(10, 15)) {
				break;
			}
		}

	}

	private static int countNineNumber(long n) {
		int count = 0;
		while(n!=0) {
			if(n%10==9) {
				count ++;
			}else {
				break;
			}
			n /= 10;
		}
		return count;
	}
	public static int digitSum(long n) {
		int sum = 0;
		while(n != 0) {
			sum += n%10;
			n /= 10;
		}
		return sum;
	}

}

Measured memory_bytes: 20436
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}



void oneCase () {
    int n;
    cin  >> n;
    string line;
    cin >> line;
    int x = 0;
    int b = 0;
    for (auto s : line) {
        if (s == '(') {
            ++b;
        } else {
            --b;
            x = min(x, b);
        }
    }
    for (int i = 0; i < -x; ++i) {
        cout << "(";
    }
    cout << line;
    b += (-x);
    for (int i = 0; i < b; ++i) {
        cout << ")";
    }
    cout << "\n";
}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define FREE -1
#define N_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void printboard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printboard();return;
  }
  for(j=0;j<N;j++){
    if(N_FREE==col[j] || N_FREE==dpos[i+j] || N_FREE==dneg[i-j+N-1])continue;

    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=N_FREE;

    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
  
}

int main(){
  int i,j,k,r,c;
  initialize();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++)X[i][j]=0;
  }
    scanf("%d",&k);
    for(i=0;i<k;i++){
      scanf("%d %d",&r,&c);
      X[r][c]=1;
    }
    recursive(0);
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int m,n;
double t[16][16];
double mem[16][(1<<16)];
bool visited[16][(1<<16)];

double rec(int x,int S){
  if(visited[x][S])return mem[x][S];
  visited[x][S]=true;
  double res=0;
  for(int i=0;i<m;i++){
    if(S>>i&1)continue;
    double p=1.0,k=0;
    for(int j=x;j<n;j++){      
      k+=rec(j,S|(1<<i))*p*(1.0-t[i][j]);
      p*=t[i][j];
    }
    res=max(res,k+p);
  }
  return mem[x][S]=res;
}

int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      cin>>t[i][j];
  printf("%.12f\n",rec(0,0));  
  return 0;
}

Measured memory_bytes: 10464
#include<stdio.h>

int main(void)
{
   char A[4];
   char B[4];
   scanf("%s %s",A,B);
   if(A[0]==B[2]&&A[1]==B[1]&&A[2]==B[0])
   		printf("YES\n");
   else
   		printf("NO\n");			
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n, k;
	cin >> n >> k;
	Array h(n+1, 0);
	REP(i, n)cin >> h[i+1];

	vector<Matrix> dp(n + 1, Matrix(k + 1, Array(n + 1, INF)));
	//i番目のものに対してk回まで処理を行った際に、左側がlであるときの最小値を保存

	dp[0][0][0] = 0;
	ll pre = 0;
	REP(i, n) {
		REP(j, k+1) {
			REP(l, i+1) {
				//cout << i << " " << j << " " << l << endl;
				if (dp[i][j][l] != INF) {
					
					chmin(dp[i + 1][j][i+1], dp[i][j][l] + max(0LL,h[i+1]-h[l]));
					if (j + 1 <= k) dp[i + 1][j + 1][l] = dp[i][j][l];
				}
			}
		}
	}

	ll ans = INF;
	REP(i, k+1) {
		REP(j, n+1) {
			chmin(ans, dp[n][i][j]);
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 216832
m = 10**9+7
n = 1
a = ab = abc = 0
for c in input():
    if c == 'A':
        a += n
    elif c == 'B':
        ab += a
    elif c == 'C':
        abc += ab
    else:
        ta, tab = a, ab
        a *= 3
        ab *= 3
        abc *= 3
        a += n
        ab += ta
        abc += tab
        n *= 3
    a %= m
    ab %= m
    abc %= m
    n %= m
print(abc)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ran(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N;
    int i, j, k;
    int dp[3][100010] = {0};
    vector<int> a(100010), b(100010), c(100010);

    cin >> N;

    ran(i, 1, N)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    ran(i, 1, N)
    {
        dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
        dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
        dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
    }

    int x = max({dp[0][N], dp[1][N], dp[2][N]});

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <climits>
#include <cassert>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a, i##_END_ = b; i < i##_END_; ++i)
#define per(i, a, b) for(int i = (b)-1, i##_BEGIN_ = a; i >= i##_BEGIN_; --i)
typedef long long ll;
typedef double db;
const int inf = (int)1e9;
const ll linf = (ll)1e18;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define pb(x) push_back(x)
#define sz(x) (int)(x).size()
template<class T>
inline void read(T &x){
	char c; x = 0;
	bool neg = false;
	while(c = getchar(), c!='-' && (c<'0'||c>'9'));
	if(c == '-') neg = true, c = getchar();
	do x = (x*10) + (c^48);
	while(c = getchar(), c>='0'&&c<='9');	
	if(neg) x = -x;
}
template<class T>
inline void print(T x){
	if(x == 0){ putchar('0'); return;}
	if(x < 0){ putchar('-'); x = -x;}
	static char stk[30]; int top = 0;
	while(x) stk[++top] = x%10^48, x /= 10;
	while(top) putchar(stk[top--]);
}
#ifdef Leefir
	#define ast(x) assert(x)
	#define dig(...) fprintf(stderr, __VA_ARGS__)
#else
	#define ast(x) ;
	#define dig(...) ;
#endif

namespace Program{

const int N = 100;
int n, x;
int a[N+5];
void input(){
	scanf("%d %d", &n, &x);
	rep(i, 0, n) scanf("%d", &a[i]);
}
void solve(){
	sort(a, a+n);
	int ans = 0;
	rep(i, 0, n){
		if(x >= a[i]) x -= a[i], ++ans;
		else break;
	}
	if(ans == n && x != 0) --ans;
	printf("%d\n", ans);
}
void Main(){
	input();
	solve();
}

} //namespace Program
int main(){
#ifdef Leefir
	dig("**********define Leefir***********\n");
#endif
	srand(time(NULL));
	
	Program::Main();
	
	return 0;
}


Measured memory_bytes: 256