akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N,A;
  cin>>N>>A;
  cout<<(N%500<=A?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
A=[int(input()) for _ in range(3)]
N=int(input())
ans=0

for i in range(A[0]+1):
  for j in range(A[1]+1):
    for k in range(A[2]+1):
      if N==(500*i+100*j+50*k):
        ans+=1
        
print(ans)

Measured memory_bytes: 3060
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
t,a = MAP()
h = MAP()

res = MOD
for i in range(n):
    tmp = abs(a-(t-(h[i]*0.006)))
    if res>tmp:
        res = tmp
        ans = i+1
print(ans)



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

int main()
{
    int n, i, s=0, s1=0, cnt=0, ans=100000;
    cin>>n;
    int a[n];
    for(i=0; i<n; i++) cin>>a[i];
    for(i=0; i<n; i++) s=s+a[i];
    for(i=0; i<n; i++) {
        s1=s1+a[cnt];
        s=s-a[cnt];
        cnt++;
        ans=min(ans, abs(s1-s));
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 202;

int n;
char a[N][N];

bool c[N];
int d[N];
void bfs(int x)
{
    memset(c, false, sizeof c);
    queue<int> q;
    c[x] = true;
    d[x] = 0;
    q.push(x);
    while (!q.empty())
    {
        x = q.front();
        q.pop();
        for (int h = 0; h < n; ++h)
        {
            if (a[x][h] == '1')
            {
                if (!c[h])
                {
                    c[h] = true;
                    d[h] = d[x] + 1;
                    q.push(h);
                }
            }
        }
    }
}

int main()
{
    #ifdef SOMETHING
    //freopen("input.txt", "r", stdin);
    #endif // SOMETHIN
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf(" %s", &a[i]);
    bfs(0);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (a[i][j] == '1' && (d[i] % 2) == (d[j] % 2))
            {
                printf("-1\n");
                return 0;
            }
        }
    }
    int maxu = 0;
    for (int i = 0; i < n; ++i)
    {
        bfs(i);
        for (int j = 0; j < n; ++j)
            maxu = max(maxu, d[j]);
    }
    printf("%d\n", maxu + 1);
    return 0;
}


Measured memory_bytes: 256
#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 n;
    cin >> n;
    vector<vector<int>> A(n, vector<int>(n-1));
    rep(i, n) {
        rep(j, n-1) {
            cin >> A[i][j];
            A[i][j]--;
        }
        reverse(A[i].begin(), A[i].end());
    }
    vector<P> p;
    auto check = [&](int i) {
        if (!A[i].size()) return;
        int j = A[i].back();
        if (A[j].back()==i) {
            if (i > j) swap(i, j);
            p.push_back(make_pair(i, j));
        }
    };
    rep(i, n) check(i);
    int day = 0;
    while(!p.empty()) {
        day++;
        sort(p.begin(), p.end());
        p.erase(unique(p.begin(), p.end()), p.end());
        vector<P> q;
        swap(p, q);
        for (P m : q) {
            A[m.first].pop_back();
            A[m.second].pop_back();
        }
        for (P m : q) {
            check(m.first);
            check(m.second);
        }
    }
    bool flg = true;
    rep(i, n) {
        if (A[i].size()) {
            flg = false;
        }
    }
    if (flg) cout << day << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18
#define setbits(x) (__builtin_popcount(x))
 
void solve(){
	int n;
	cin>>n;
	fill(int,h,n);
	fill(int,a,n);
	int ans=0;
	map<int,int> dp;
	dp.insert({0,0});

	rep(i,0,n){
		auto it=dp.lb(h[i]);
		it--;
		int x=it->se+a[i];
		it++;
		vector<int> del;
		while(it!=dp.end()&&x>=it->se){
			del.pb(it->fi);
			it++;
		}
		for(auto x:del)
			dp.erase(x);

		dp.insert({h[i],x});
		ans=max(ans,x);
	}

	cout<<ans;
}
 	
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 18680
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    string S;
    cin >> S;
    sort(S.begin(), S.end());

    char ch = 'a';
    for (int i = 0; i < S.size() && ch <= 'z'; ++i)
    {
        if (ch != S[i] && (ch != 'a' && ch - 1 != S[i]))
            break;
        if (ch == S[i])
            ch++;
    }

    if (ch <= 'z')
    {
        cout << ch << endl;
    }
    else
    {
        cout << "None" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
#include<queue>
#include<unordered_map>
 
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a;
	cin >> a;
	unordered_map<char, long long> cnt;
	for (int i = 0; i < a.size(); ++i) {
		cnt[a[i]]++;
	}
	long long ans = a.size()*(a.size() - 1) / 2;
	for (const auto & e : cnt) {
		ans -= e.second*(e.second - 1) / 2;
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 848
class Node:
	def __init__(self, key):
		self.key = key
		self.left = self.right = self.parent = None

class BST:
	def __init__(self):
		self.root = None
	
	def insert(self, key):
		parent = None
		current = self.root
		while current != None:
			parent = current
			if key < current.key:
				current = current.left
			else:
				current = current.right
		new = Node(key)
		new.parent = parent
		if parent == None:
			self.root = new
		elif key < parent.key:
			parent.left = new
		else:
			parent.right = new		
	
	def find(self, key):
		current = self.root
		while current != None:
			if key == current.key:
				return current
			if key < current.key:
				current = current.left
			else:
				current = current.right
		return None
		
	def delete(self, key):
		target = self.find(key)
		if target == None:
			return

		parent = target.parent
		if target.left == None or target.right == None:
			child = None
			if target.left != None:
				child = target.left
			elif target.right != None:
				child = target.right
			
			if child != None:
				child.parent = parent
	
			if parent == None:
				self.root = child
			elif parent.left == target:
				parent.left = child
			else:
				parent.right = child
		else:
			current = target.right
			while current.left != None:
				current = current.left
			target.key = current.key
			parent = current.parent
			if current.right != None:
				parent.left = current.right
				current.right.parent = parent
			else:
				if parent.left == current:
					parent.left = None
				else:
					parent.right = None
	
	def print(self):
		self.print_in_order(self.root)
		print()
		self.print_pre_order(self.root)
		print()
		
	def print_in_order(self, node):
		if node != None:
			self.print_in_order(node.left)
			print(' ' + str(node.key), end='')
			self.print_in_order(node.right)
		
	def print_pre_order(self, node):
		if node != None:
			print(' ' + str(node.key), end='')
			self.print_pre_order(node.left)
			self.print_pre_order(node.right)		

n = int(input())
bst = BST()
for i in range(n):
	cmd = list(map(str, input().split()))
	if cmd[0] == 'print':
		bst.print()
	else:
		key = int(cmd[1])
		if cmd[0] == 'insert':
			bst.insert(key)
		elif cmd[0] == 'find':
			if bst.find(key) != None:
				print('yes')
			else:
				print('no')
		else:
			bst.delete(key)



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

using namespace std;

typedef pair<int,int> P;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};

int main(){
  int Tc,M,N;

  cin >> Tc;
  while(Tc--){
    vector<P> vec;
    for(int i = 0 ; i < 4 ; i++){
      vec.push_back(P(dx[i],dy[i]));
    }
    cin >> M >> N;
    vec.push_back(P(M,N));
    vec.push_back(P(-N,M));
    vec.push_back(P(-M,-N));
    vec.push_back(P(N,-M));
    int cnt = 0;

    for(int m = 0 ; m <= 50 ; m++){
      for(int n = 0 ; n <= 50 ; n++){
        if(m == n && m == 0) continue;
        int X = m*m + n*n;
        if(!((m*M+n*N) % X == 0 && (m*N-n*M)%X == 0)) continue;
        int Y = (m*M+n*N)/X;
        int Z = (m*N-n*M)/X;
        if((M*M+N*N)/X == Y*Y+Z*Z){
          bool ok = true;
          for(int i = 0 ; i < 8 ; i++){
            if(vec[i].first == m && vec[i].second == n){
              ok = false;
              break;
            }
          }
          if(ok) cnt++;
        }
      }
    }
   
    if(cnt == 0) cout << "P" << endl;
    else cout << "C" << endl;
  }

  return 0;
}

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

int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> ans(N);
  const int INF = 1000000007;
  vector<int> d(N, INF);
  d.at(0) = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int nx : G.at(cur)) {
      if (d.at(nx) != INF) continue;
      d.at(nx) = d.at(cur) + 1;
      ans.at(nx) = cur;
      q.push(nx);
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) cout << ans.at(i) + 1 << endl;
}

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

X = []
K = 0
def fullsearch():
    for l, r in zip(X, X[K-1:]):
        distance = abs(r - l)
        yield distance + abs(r)
        yield distance + abs(l)

def main():
    global X, K
    _, K = map(int, input().split())
    X = list(map(int, input().split()))

    print(min(fullsearch()))

main()

Measured memory_bytes: 14172
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();
        int max = Math.max(Math.max(A + B, A - B), A * B);
        System.out.println(max);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        printf("%lld\n", b / x + 1);
    } else {
        printf("%lld\n", b / x - (a - 1) / x);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int limit = in.nextInt();
		int[][] graph = new int[limit][limit];
		for(int i = 0; i < limit; i++) {
			int index = in.nextInt();
			int neighbors = in.nextInt();
			for(int j = 0; j < neighbors; j++) {
				graph[i][in.nextInt() - 1] = 1;
			}
		}
		in.close();
		for(int i = 0; i < limit; i++) {
			for(int j = 0; j < limit; j++) {
				if(j == limit - 1) {
					System.out.println(graph[i][j]);
				} else {
					System.out.print(graph[i][j] + " ");
				}
			}
		}
	}

}


Measured memory_bytes: 32616
# coding: utf-8
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())
ans=0

for i in range(N):
    if T[i]=="r":
        if i>=K:
            if T[i-K]==T[i]:
                T[i]="o"
            else:
                ans+=P
        else:
            ans+=P
    elif T[i]=="s":
        if i>=K:
            if T[i-K]==T[i]:
                T[i]="o"
            else:
                ans+=R
        else:
            ans+=R
    elif T[i]=="p":
        if i>=K:
            if T[i-K]==T[i]:
                T[i]="o"
            else:
                ans+=S
        else:
            ans+=S

print(ans)
    




Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

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


Measured memory_bytes: 256
import numpy as np
N,K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A = np.sort(A)
F = np.sort(F)[::-1]
Asum = A.sum()

def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K

left = -1
right = np.amax(A * F)

while right - left > 1:
    mid = (right + left)//2
    if test(mid) == 1:
        right = mid
    else:
        left = mid
print(right)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    int i;

    for (i = 111; i <= 999; i += 111) {
        if (n <= i) {
            Out(i);

            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	static void log(long i) {
		System.out.println(i);
	}
	static void log(String s) {
		System.out.println(s);
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		

		long total=0;
		
		for(int i=0; i<=n; i++) {
			if(i%15==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			total+=i;
		}
		
		sc.close();
		log( total );
	}
}


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

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    vector<long long> C(N);
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++) cin >> B[i];
    for (int i=0; i<N; i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long answer=0;
    for (int i=0; i<N; i++)
    {
        long long target_B = B[i];
        long long A_upper_limit = lower_bound(A.begin(), A.end(), target_B) - A.begin();
        long long C_lower_limit = lower_bound(C.begin(), C.end(), target_B+1) - C.begin();
        answer += A_upper_limit * (N - C_lower_limit);
    }
    
    cout << answer << endl;
}

Measured memory_bytes: 5616
N = int(input())
F = []
for i in range(N):
    A = list(map(int, input().split()))
    F.append(A[::-1])
 
P = []
for i in range(N):
    A = list(map(int, input().split()))
    P.append(A)
 
result = float("inf")*(-1)
for i in range(1, 2**10):
    ans = 0
    for l in range(N):
        c = 0
        for j in range(10):
            if ((i>>j) & 1):
                if F[l][j] == 1:
                    c += 1
        ans += P[l][c]
    result = max(ans, result)
print(result)

Measured memory_bytes: 68568
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.math;

void main() {
  int N = readln.chomp.to!int;
  auto a = readln.chomp.split.map!(to!int).array;

  int odd;

  for (int i = 0; i < N; ++i) {
    if (a[i] % 2 == 1) {
      odd++;
    }
  }

  if (odd % 2 == 1 && N > 1) {
    "NO".writeln;
  }
  else {
    "YES".writeln;
  }

  return;
}


Measured memory_bytes: 4220
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, j, h, w;
    char[][] f;
    String s;
    int[][] v;

    for(;;){
      h = sc.nextInt(); w = sc.nextInt();
      if(h == 0 && w == 0)break;
      f = new char[h][w]; v = new int[h][w];

      for(i = 0;i < h;i++){
        s = sc.next();
        for(j = 0;j < w;j++)f[i][j] = s.charAt(j);
      }

      i = 0; j = 0; v[0][0] = 1; s = "GO";
      for(;;){
        if(f[i][j] == '>'){
          v[i][++j]++;
          if(v[i][j] == 2){
            s = "LOOP"; break;
          }
        }else if(f[i][j] == '<'){
          v[i][--j]++;
          if(v[i][j] == 2){
            s = "LOOP"; break;
          }
        }else if(f[i][j] == '^'){
          v[--i][j]++;
          if(v[i][j] == 2){
            s = "LOOP"; break;
          }
        }else if(f[i][j] == 'v'){
          v[++i][j]++;
          if(v[i][j] == 2){
            s = "LOOP"; break;
          }
        }else break;
      }
      if("LOOP".equals(s))out.println(s);
      else out.println(j + " " + i);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 21992
#include <iostream>
using namespace std;
#define nmax 8
bool G[nmax][nmax];
int dfs(int v,int N,bool visited[nmax]){
  bool all_visited = true;
  for(int i=0;i<N;i++){
    if(visited[i] == false){
      all_visited = false;
    }
  }
  if(all_visited)return 1;
  int ret = 0;
  for(int i=0;i<N;i++){
    if(G[v][i] == false)continue;
    else if(visited[i] == true)continue;
    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i] = false;
  }
  return ret;
}
int main(){
  int N,M;
  int x,y;
  bool visited[nmax];
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> x >> y;
    G[x-1][y-1] = G[y-1][x-1] = true;
  }
  for(int i=0;i<N;i++){
    visited[i] = false;
  }
  visited[0] = true;
  cout << dfs(0,N,visited) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long int
#define mod 1000000007
int fac[1000001];
void function()
{
	fac[0]=1;
	int j;
	for(j=1;j<=1000000;j++)
	{
		fac[j]=(j*fac[j-1])%mod;
	}
}
int power(int x, int y, int p) 
{ 
    int res = 1;      
    x = x % p; 
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
int modInverse(int n, int p) 
{ 
    return power(n, p-2, p); 
} 
int nCrModPFermat(int n, int r, int p) 
{ 
   if (r==0) 
       return 1;
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
int32_t main()
{
	function();
	int answer=0;
	int x,y;
	cin>>x>>y;
	int j;
	for(j=0;j<=x;j++)
    {
		if((x-j)%2==0)
		{
			int p=2*j+(x-j)/2;
			if(p==y)
			{
				int total=j+(x-j)/2;
				answer=answer+nCrModPFermat(total,j,mod);
				answer=answer%mod;
			}
		}
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 8064
n=int(input())
inf=10**10
dp=[inf]*(n+1)
dp[0]=0
dp[1]=1
m6=[]
m9=[]
j6=1
while j6<=n:
    m6.append(j6)
    dp[j6]=1
    j6*=6
j9=1
while j9<=n:
    m9.append(j9)
    dp[j9]=1
    j9*=9
for i in range(1,n+1):
    if dp[i]==1:
        continue
    for j in m6:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)
    for k in m9:
        if i-k>=0:
            dp[i]=min(dp[i],dp[i-k]+1)
print(dp[n])

Measured memory_bytes: 42732
@_=<>=~/./g;
if($_[-1]||$_[0]==0||grep$_[$_]!=$_[-2-$_],0..$#_-1){
	print-1
}else{
	for(0..$#_-1){
		print$%+1,$",$_+2,$/;
		$%=$_+1if$_[$_]
	}
}


Measured memory_bytes: 17408
mod = 10**9+7
k = input()
d = int(input())

l = len(k)

dp = [[0 for _ in range(d)] for _ in range(l+1)]
dp2 = [[0 for _ in range(d)] for _ in range(l+1)]

dp[0][0] = 1
dp2[0][0] = 1

for i in range(1, l+1):
    if i == 1:
        for p in range(10):
            if p > int(k[i-1]):
                continue
            for j in range(d):
                if p < int(k[i-1]):
                    dp[i][(j+p) % d] += dp[i-1][j]
                    dp[i][(j+p) % d] %= mod
                elif p == int(k[i-1]):
                    dp2[i][(j+p) % d] += dp2[i-1][j]
                    dp2[i][(j+p) % d] %= mod
        continue

    for p in range(10):
        for j in range(d):
            dp[i][(j+p) % d] += dp[i-1][j]
            dp[i][(j+p) % d] %= mod

        if p > int(k[i-1]):
            continue

        for j in range(d):
            if p < int(k[i-1]):
                dp[i][(j+p) % d] += dp2[i-1][j]
                dp[i][(j+p) % d] %= mod
            elif p == int(k[i-1]):
                dp2[i][(j+p) % d] += dp2[i-1][j]
                dp2[i][(j+p) % d] %= mod

print((dp[l][0]+dp2[l][0]-1) % mod)


Measured memory_bytes: 62428
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int ways(int f, int l, int n){
	int ans = 0;
	if(l*10 + f <= n)
		ans++;
	// 1
	int temp = l*100 + f;
	for(int i = 0; i < 10; i++){
		if(temp + i*10 <= n)
			ans++;
		else
			return ans;
	}
	// 2
	temp = l*1000 + f;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			if(temp + i*100 + j*10 <= n)
				ans++;
			else
				return ans;
		}
	}
	// 3
	temp = l * 10000 + f;
	for(int k = 0; k < 10; k++){
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				if(temp + k*1000 + i*100 + j*10 <= n)
					ans++;
				else
					return ans;
			}
		}
	}
	// 4
	if(l == 1){
		temp = l * 100000 + f;
		for(int m = 0; m < 10; m++){
			for(int k = 0; k < 10; k++){
				for(int i = 0; i < 10; i++){
					for(int j = 0; j < 10; j++){
						if(temp + m*10000 + k*1000 + i*100 + j*10 <= n)
							ans++;
						else
							return ans;
					}
				}
			}
		}
	}
	return ans;
}

int32_t main(){
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		string p = to_string(i);
		int f = p[0] - '0';
		int l = p.back() - '0';
		if(l == 0)
			continue;
		if(f == l){
			cnt++;
		}
		cnt += ways(f,l,n);
	}
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    vint a(n);
    int idx = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 1) idx = i;
    }
    n--;
    k--;
    int ans = (n + (k - 1)) / k;

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

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	map<char,bool>m;
	m['a']=true;
	m['i']=true;
	m['u']=true;
	m['e']=true;
	m['o']=true;
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		rep(i,n){
			string t="";
			t+=in[i][0];
			rep(j,in[i].size()-1)if(m[in[i][j]])t+=in[i][j+1];
			in[i]=t;
		}
		loop(i,1,51){
			map<string,bool>tmp;
			rep(j,n){
				int d=in[j].size();
				string t=in[j].substr(0,min(i,d));
				if(tmp[t])goto loop;
				tmp[t]=true;
			}
			cout<<i<<endl;
			goto end;
			loop:;
		}
		cout<<-1<<endl;
		end:;
	}
}

Measured memory_bytes: 1244
#include <stdio.h>

long int dfs(long int o, long int n);//0~nまでの七五三数の個数

int main(void)
{
	long int n;
	scanf("%ld", &n);
	printf("%ld", dfs(0, n));
	return 0;
}

//0から初めて、3,5,7,以外の数字を無視すれば実行時間を小さくできる。
long int dfs(long int o, long int n)
{
	if (o > n)return 0;//再帰終了
	long int t = o, flag3 = 0, flag5 = 0, flag7 = 0, count = 0;

	//第一引数 o が753数かどうか調べる
	while (t > 0) {
		if ((t % 10) == 3)flag3 = 1;
		else if ((t % 10) == 5)flag5 = 1;
		else if ((t % 10) == 7)flag7 = 1;
		if ((flag3 + flag5 + flag7) == 3) {
			count++;
			break;
		}
		t /= 10;
	}

	//3,5,7,の数字のみが出てくるように数を大きくする
	count += dfs(o*10 + 3, n);
	count += dfs(o*10 + 5, n);
	count += dfs(o*10 + 7, n);

	return count;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
const int num = 16, ud[] = { 1, 0, 0, -1 }, lr[] = { 0, -1, 1, 0 }, nd = 4;
int md[num][num];
struct puzzle {
	int sp, p[num], mdp, cost;
	bool operator < (const puzzle &pu) const {
		for (int i = 0; i < num; i++) {
			if (p[i] == pu.p[i]) continue;
			return p[i] < pu.p[i];
		}
		return false;
	}
};
struct state {
	puzzle pu;
	int es;
	bool operator < (const state &s) const {
		//return pu.mdp + pu.cost > s.pu.mdp + s.pu.cost;
		return es > s.es;
	}
};
int astar(puzzle pz) {
	priority_queue<state> pq;
	int sum = 0;
	for (int i = 0; i < num; i++) {
		if (pz.p[i] == num) continue;
		sum += md[i][pz.p[i] - 1];
	}
	pz.mdp = sum;
	pz.cost = 0;
	map<puzzle, bool> m;
	puzzle u, v;
	state initial;
	initial.pu = pz;
	initial.es = pz.mdp;
	pq.push(initial);
	while (!pq.empty()) {
		state st = pq.top(); pq.pop();
		u = st.pu;
		if (!u.mdp) return u.cost;
		m[u] = true;
		int sx = u.sp / nd;
		int sy = u.sp % nd;
		for (int r = 0; r < nd; r++) {
			int tx = sx + ud[r];
			int ty = sy + lr[r];
			if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
			v = u;
			//v.mdp = p.mdp - md[tx * nd + ty][tmp.p[tx * nd + ty] - 1] + md[sx*nd + sy][tmp.p[tx * nd + ty] - 1];
			v.mdp -= md[tx * nd + ty][v.p[tx * nd + ty] - 1];
			v.mdp += md[sx*nd + sy][v.p[tx * nd + ty] - 1];
			swap(v.p[sx * nd + sy], v.p[tx * nd + ty]);
			v.sp = tx * nd + ty;
			if (!m[v]) {
				v.cost++;
				state news;
				news.pu = v;
				news.es = v.cost + v.mdp;
				pq.push(news);
			}
		}
	}
	return -1;
}

int main() {
	puzzle in;
	for (int i = 0; i < num; i++)
		for (int j = 0; j < num; j++)
			md[i][j] = abs(i / nd - j / nd) + abs(i%nd - j%nd);
	for (int i = 0; i < num; i++) {
		cin >> in.p[i];
		if (!in.p[i]) { in.sp = i;  in.p[i] = num; }
	}
	cout << astar(in) << endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = 1;
        long[] A = new long[n];
        for(int i = 0; i < n; i++) A[i] = Long.parseLong(sc.next());
        Arrays.sort(A);
        for(int i = 0; i < n; i++) {
            if(res * A[i] > 1000_000_000_000_000_000L || (res > res * A[i])) {
                res = -1;
                break;
            }
            res *= A[i];
        }
        if(A[0] == 0) res = 0;
        System.out.println(res);
    }
}


Measured memory_bytes: 60704
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

//#define DEBUG_MODE

int main() {
        ll A, B, C, K;
        cin >> A >> B >> C >> K;

        ll ans = 0;

        // A (1)
        if (K <= A) {
                ans = K;
                K = 0;
        } else {
                ans = A;
                K -= A;
        }

#ifdef DEBUG_MODE
        cout << "K: " << K << ", ans: " << ans << endl;
#endif

        // B (0)
        K -= B;

#ifdef DEBUG_MODE
        cout << "K: " << K << ", ans: " << ans << endl;
#endif

        // C (-1)
        if (K > 0) ans -= K;

#ifdef DEBUG_MODE
        cout << "K: " << K << ", ans: " << ans << endl;
#endif

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 3628
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

b = sorted([a[i] - i for i in range(n)])
meds = []
out = []
if n % 2 == 1:
    meds.append(b[n//2])
else:
    meds.append(b[n//2])
    meds.append(b[n//2 - 1])

for med in meds:   
    ans = 0   
    for num in b:
        ans += abs(num - med)
    out.append(ans)

print(min(out))

Measured memory_bytes: 25820
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    stack<char> S;

    int sum = 0;
    vector<int> ans(N+1);
    for(int i=0; i<N; i++) {
        if(!(i > 0 and s[i-1] == 'A' and s[i] == 'C')) {
            ans[i+1] = sum;
            S.push(s[i]);
        }
        else {
            ans[i+1] = ++sum;
            S.pop();
        }
    }
    for(int i=0; i<Q; i++) {
        int l, r; scanf("%lld%lld", &l, &r);
        cout << ans[r] - ans[l] << endl;
    }
    return 0;
}


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

#define ll                  long long
#define ld                  long double
#define inf             1e18
#define w(x)            int x; cin>>x; while(x--)
#define en           "\n"
#define boostUP     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n)        for(int i=0;i<n;i++)
#define fcr(i,a,b)      for(int i=a;i<b;i++)
#define pb              push_back
#define sz(arr)         sizeof(arr)/sizeof(arr[0])
#define mod             1e9+7
#define setbits(x)      __builtin_popcountll(x)
#define COMPUTE_GCD(a, b)       std :: __gcd((a), (b))
#define COMPUTE_LCM(a, b)       (a * ((b) / COMPUTE_GCD(a, b)))


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
	//use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif





int main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w",  stdout);
#endif
	boostUP;
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n, mod);
	vector<ll> a(n, mod);
	a[0] = 0;

	for (ll i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	for (ll i = 0; i < n; i++)
	{
		for (ll j = 1 + i; j <= k + i; j++)
		{
			if (j < n)
				a[j] = min(abs(h[i] - h[j]) + a[i], a[j]);
		}

	}







	cout << a[n - 1];





	return 0;

}



Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m;
	//memset(a,0,sizeof)
	cin>>m;
	int t1=m/10;int t2=m%10;
	if(t1==9||t2==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(n,i) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

bool check(ll mid, ll arr[], ll n, ll m, ll v, ll p)
{
    //cout<<"at "<<mid+1<<"\n";
    ll maxi = arr[mid] + m;
    ll cnt = 0;
    rep(n)  
        if(arr[i]>maxi)
            cnt++;
    //cout<<"cnt = "<<cnt<<'\n';        
    if(cnt>=p)
        return 0;
    ll cnt1 = mid;
    if(cnt1+cnt>=v-1)
        return 1;
    ll pex = p-1-cnt;
    ll temp1 = 0;
    for(ll i=mid+1;i<n;i++)
    {
        if(arr[i] == arr[mid])
            temp1++;
    }
    
    if(cnt1+cnt+temp1 >= v-1)
        return 1;
    ll vextra = v-cnt1-cnt-temp1-1;        
    
    ll si = mid+temp1+1;
    ll ei = n-1-cnt;
    
   // cout<<"si = "<<si<<" and ri = "<<ei<<"\n";
    
    if(ei-si+1<=pex)
        return 1;
    multiset<ll,greater<ll>> ms;
    ll tot = m*vextra;
    for(ll i=si;i<=ei;i++)
    {
        tot-=maxi-arr[i];
        ms.insert(max(0ll,m-maxi+arr[i]));
    }
    
    if(tot<=0)
        return 1;
    ll fcnt = 0;
    while(tot>0)
    {
        tot-=*ms.begin();
        fcnt++;
        ms.erase(ms.begin());
    }
    
    if(fcnt>pex)
        return 0;
    return 1;    
}

int main()
{
   FAST/**/
   
   ll n,m,v,p;
   cin>>n>>m>>v>>p;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   sort(arr,arr+n);
   ll st = 0;
   ll end = n-1;
   
   while(end - st > 1)
   {
       ll mid = (st + end)/2;
       bool temp = check(mid,arr,n,m,v,p);
       if(temp)
            end = mid;
       else st = mid + 1;           
   }
   
   ll ans;
   bool temp = check(st,arr,n,m,v,p);
   if(temp) 
        ans = st;
   else ans = end;
   
   cout<<n-1-ans+1<<"\n";
   
   return 0;        
}  
   

Measured memory_bytes: 5760
str_n = str(input())

temp = int(str_n[0])
temp = 111*temp

int_n = int(str_n)

if int_n > temp:
  temp = int(str_n[0])
  temp = temp+1
  print(111*temp)
else:
  temp = int(str_n[0])
  print(111*temp)

Measured memory_bytes: 3060
import  java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int t = sc.nextInt();

        int[] c = new int[n];

        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            if (y <= t)
                c[cnt++] = x;
        }

        int min = c[0];
        for (int i = 1; i < cnt; i++) {
            min = Math.min(min, c[i]);
        }

        System.out.println(min > 0 ? min : "TLE");
    }
}


Measured memory_bytes: 21716
#include<stdio.h>


#include<stdlib.h>

#include<string.h>

int main(void)


{


char num_str[1002];


int num;


long sum = 0;


int i;


char tmp;


while (1)


{


fgets(num_str,sizeof(num_str),stdin);


if(num_str[0] == '0') break;


for (i = 0; i < strlen(num_str)-1; i++)

{


tmp = num_str[i];


num = atoi(&tmp);


sum = sum + num;


}


printf("%ld\n",sum);


sum = 0;


memset(num_str, 1002,0);


}


return 0;


}

Measured memory_bytes: 960
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

int N;
void input() {
    RI(N);
}

void solve() {
    cout << (double)((N/2) + (N%2))/N << endl;
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int n,i,max,c[10005];
  scanf("%d",&n);

  int a[n],b[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i>0){
      if(max<a[i]){
	max=a[i];
      }
    }
    else
      max=a[i];
 
  }
  
  for(i=0;i<=max;i++)
    {
      c[i]=0;
    }

  for(i=0;i<n;i++){
    c[a[i]]++;
  }

  for(i=1;i<=max;i++){
    c[i]=c[i]+c[i-1];
  }

  for(i=0;i<n;i++){
    b[c[a[i]]-1]=a[i];
    c[a[i]]--;
  }
 for(i=0;i<n;i++){
    if(i==n-1)
      printf("%d\n",b[i]);
    else
      printf("%d ",b[i]);
  }
 return 0;
}



Measured memory_bytes: 17392
int main() {
  int n, a, max = -1000000, min = 1000000;
  long sum = 0;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a > max) max = a;
    if (a < min) min = a;
    sum += a;
  }
  printf("%d %d %ld\n", min, max, sum);
}


Measured memory_bytes: 2112
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b + c
        || b == c + a
        || c == a + b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    int n;
    cin >> n;
    rep2(i,n){
        int ans=0;
        rep2(x,101){
            rep2(y,101){
                int r=1;int l=100;
                while(l-r>1){
                    int p=(r+l)/2;
                    if(p*p+(x+y)*p+(x*x+y*y+x*y-i)>0){
                        l=p;
                    }else{
                        r=p;
                    }
                }
                if(r*r+(x+y)*r+(x*x+y*y+x*y-i)==0){
                    ans++;
                }else if(l*l+(x+y)*l+(x*x+y*y+x*y-i)==0){
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3600
S = list(input())
L = len(S)

if L != 26:
  # まだ使ってないもので、最大ものもを最後につける
  USED = [False] * 26
  for s in S:
    USED[ord(s) - 97] = True
  
  for i in range(26):
    if not USED[i]:
      S.append(chr(97+i))
      break
  
  print("".join(S))
else:
  # 26文字ある場合
  prev = -1
  k = -1
  USED = []
  for i in range(26)[::-1]:
    d = ord(S[i]) - 97
    if prev < d:
      prev = d
      USED.append(S[i])
    else:
      k = i
      break
  
  if k == -1:
    print(-1)
  else:  
    nxt = min([s for s in USED if s > S[k]])
    S = S[:k] + [nxt]
    print("".join(S))


Measured memory_bytes: 9040
n = int(input())
lst = list(map(int,input().split()))

ans = None
for t in range(n-1):
    left = [x for x in lst[:t+1]]#t+1未満まで
    right = [x for x in lst[t+1:]]#t＋1以上

    sum_left=0
    for e in left:
        sum_left+=e

    sum_right=0
    for e in right:
        sum_right+=e

    if ans==None or abs(sum_left-sum_right)<ans:
        ans = abs(sum_left-sum_right)
    else:break
print(ans)
    

Measured memory_bytes: 3060
// 何で合わないのかわからない.考察が間違っている可能性がある.
#include<iostream>
#include<set>
#include<map>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

bool x[1000001] = {};
bool y[1000001] = {};

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

    int a[n], b[m];
    bool valid = true;
    map<int,int> reva, revb;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(x[a[i]]) valid = false;
        x[a[i]] = true;
        reva[a[i]] = i;
    }

    for(int i = 0; i < m; i++){
        cin >> b[i];
        if(y[b[i]]) valid = false;
        y[b[i]] = true;
        revb[b[i]] = i;
    }

    if(!valid){
        cout << 0 << endl;
        return 0;
    }

    int cnti = 0, cntj = 0;
    ll ans = 1;
    ll vacant = 0;
    
    for(int i = n*m; i >= 1; i--){
        int tmp = 0, add = 0;
        if(reva.count(i)){
            tmp++;
            vacant += cntj;
            add += cntj;
            cnti++;
        }
        if(revb.count(i)){
            tmp++;
            vacant += cnti;
            add += cnti;
            cntj++;
        }

        if(tmp == 2){
            // iは固定
            vacant--;
            continue;
        }

        if(vacant == 0){
            // 空きマス無し
            cout << 0 << endl;
            return 0;
        }

        if(add != 0){
            ans *= add;
        }else{
            ans *= vacant;
        }
        ans %= mod;
        vacant--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384