akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef long long ll;

ll topnum(ll x)
{
	ll ret = 0;

	ll a = 1;
	ll b = 10;
	while (b <= x)
	{
		ret += (b - 1LL - b / 10LL + 1LL) * a;
		a++;
		b *= 10LL;
	}
	b /= 10LL;

	ret += (x - b) * a + 1;

	return ret;
}

int main()
{
	/*cout << topnum(1) << endl;
	cout << topnum(10) << endl;
	cout << topnum(11) << endl;
	cout << topnum(1000000) << endl;
	cout << topnum(1000001) << endl;
	cout << topnum(1000001) << endl;
	return 0;*/

	while (1)
	{
		ll K, N; cin >> N >> K;
		if (K == 0) return 0;

		ll l = 1, r = 1;
		rep(i, 0, 10) r *= 10;
		while (l + 1 != r)
		{
			ll mid = (l + r) / 2LL;
			if (N < topnum(mid))
				r = mid;
			else
				l = mid;
		}

		ll top = topnum(l);
		bool init = true;
		string ans = "";
		while (ans.length() < K)
		{
			string s = to_string(l);
			if (init)
			{
				ans += s.substr(N - top);
				init = false;
			}
			else
			{
				ans += s;
			}
			l++;
		}

		rep(i, 0, K) cout << ans[i];
		cout << endl;
	}
}

Measured memory_bytes: 3288
#include<stdio.h>

int main(void){
    int h,w,a,b;
    scanf("%d %d", &h, &w);
    scanf("%d %d", &a, &b);
    int c,d = 0;
    c = h-a;
    d = w-b;
    printf("%d\n", c*d);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
/* global variables */
/* function */
int f(int x) {
    if (x == 1) return 300000;
    else if (x == 2) return 200000;
    else if (x == 3) return 100000;
    return 0;
}
/* main */
int main(){
    int x, y;
    cin >> x >> y;
    int ans = (x == 1 && y == 1) ? 400000 : 0;
    ans += f(x) + f(y);
    cout << ans << '\n';
}

Measured memory_bytes: 3564
# -*- coding: utf-8 -*-

def list_n():
    return [int(e) for e in input().split()]


def list_s():
    return [s for e in input().split()]


def main(s):
    ret = []
    for c in s:
        if c in ['0', '1']:
            ret.append(c)
        else:
            if ret:
                ret.pop()
    return ''.join(ret)


if __name__ == '__main__':
    s = input()
    print(main(s))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ft first
#define sd second
#define maxn 1000005
#define mod
#define PI 3.14159265
#define MP make_pair
#define PB push_back
#define heap priority_queue
#define Bjerg ""
using namespace std;
int n ,dem[maxn];
void read()
{
    cin >> n;
}
void solve()
{
    for(int i=1;i<=n;++i)
    {
        for(int j=i;j<=n;j+=i)
            dem[j]++;
    }
    for(int i=1;i<=n;++i)dem[i]+=dem[i-1];
    cout <<dem[n-1];
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Bjerg".inp","r",stdin);
    read();
    solve();
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] arr = new int[N];
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
		}
		Arrays.sort(arr);
		for (int i = N-1; i >= 0; i-=2) {
			a += arr[i];
			if (i > 0) {
				b += arr[i-1];
			}
		}


		System.out.print(a-b);
		reader.close();
	}
}

Measured memory_bytes: 21844
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  cin >> n;
  int x = n/2;
  int y = n-x;
  cout << x*y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)(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 all(X) (X).begin(), (X).end()
#define pb psuh_back

int main() {
  int n;
  cin	>> n;
  vector<int>	a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  vector<ll> sum(n);
  sum[0] = a[0];
  REP(i, 1, n) sum[i] = sum[i-1] + a[i];
  int cnt = 0;
  REP(i, 1, n) {
    if(sum[i-1]*2 >=a[i]) cnt++;
    else cnt = 0;
    //  cout << sum[i] << " " << cnt << endl;
  }
  cout << ++cnt << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M;cin>>N>>M;
  vector<int> a(N),b(N),c(M),d(M),ans(N);
  REP(i,0,N)cin>>a[i]>>b[i];
  REP(i,0,M)cin>>c[i]>>d[i];

  int e,f,g,h;

  int dist;
  REP(i,0,N){
    dist=INF;
    REP(j,0,M){
      if(abs(a[i]-c[j])+abs(b[i]-d[j])<dist){
        dist=abs(a[i]-c[j])+abs(b[i]-d[j]);
        ans[i]=j+1;
      }
    }
  }
  each(z,ans){
    print(z);
  }

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  std::map<ll, int> mp;
  rep(i, N) {
    ll x; cin >> x;
    mp[-x]++;
  }

  ll temp = 0;
  for (auto e: mp) {
    auto val = -e.first;
    if (!temp && e.second >= 4) {
      std::cout << val * val << std::endl;
      exit(0);
    }
    if (!temp && e.second >= 2) {
      temp = val;
    }
    else if (temp && e.second >= 2) {
      std::cout << temp * val << std::endl;
      exit(0);
    }
  }

  std::cout << "0\n";
  
  return 0;
}


Measured memory_bytes: 6528
class Queue:
    def __init__(self, n):
        self.n = n + 1
        self.array = [0]*self.n
        self.head = 0
        self.tail = 0

    def enqueue(self, x):
        if not self.isfull():
            self.array[self.tail] = x
            self.tail += 1
            self.tail = self.tail % self.n
        else:
            raise ValueError

    def dequeue(self):
        if not self.isempty():
            val = self.array[self.head]
            self.head += 1
            self.head = self.head % self.n
            return val
        else:
            return False

    def isempty(self):
        return self.head == self.tail

    def isfull(self):
        return (self.tail+1) % self.n == self.head


def main():
    n, q = map(int, input().split())
    queue = Queue(n)
    time = 0

    for _ in range(n):
        query = input().split()
        queue.enqueue(query)

    task = True
    while not queue.isempty():
        task = queue.dequeue()
        if int(task[1]) > q:
            time += q
            tmp_time = int(task[1]) - q
            task = [task[0], tmp_time]
            queue.enqueue(task)
        else:
            time += int(task[1])
            print(task[0], time)


if __name__ == "__main__":
    main()



Measured memory_bytes: 16848
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int n; ll K;
ll A[200005], F[200005];

bool check(ll mx) {
	ll ans = 0;
	for (int i = 0; i < n; ++ i) {
		if (A[i] * F[i] > mx) {
			ans += (A[i] * F[i] - mx + F[i] - 1) / F[i];
		}
	}
	return ans <= K;
}

int main() {
	scanf("%d%lld", &n, &K);
	for (int i = 0; i < n; ++ i) scanf("%lld", &A[i]); sort(A, A + n);
	for (int i = 0; i < n; ++ i) scanf("%lld", &F[i]); sort(F, F + n); reverse(F, F + n);
	ll ans = 0;
	for (int i = 0; i < n; ++ i) ans = max(ans, 1LL * F[i] * A[i]);
	ll lb = 0, rb = ans, md;
	while (lb < rb) {
		md = (lb + rb) >> 1;
		if (check(md)) rb = md;
		else lb = md + 1;
	}
	printf("%lld\n", lb);
	return 0;
}

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

int rec(int n, int k){
    if(n==1) return 0;
    else return (rec(n-1,k)+k)%n;
}

int main(){
    int n,k,m;
    while(cin>>n>>k>>m,n){
        cout<<(rec(n-1,k)+m)%n+1<<endl;
    }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    int ans = 0;
    while(0 < n){
        if(n % 10 == 2) ans++;
        n /= 10;
    }
    cout << ans << endl;

    return 0;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  char c; cin >> c;
  if('a' <= c and c <= 'z') {
    cout << 'a';
  } else {
    cout << 'A';
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main(){
    int n;
    while(cin >> n, n != 0){
        int sum = 1, left = 1, right = 1, ans = 0;
        while(right < n){
            if(sum < n){
                right++;
                sum += right;
            }else if(sum > n){
                sum -= left;
                left++;
            }else{
                ans++;
                sum -= left;
                left++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2980
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int c,n,i,k;
  int ans = 0;
  cin >> n;
  int a[n] = {};
  for(i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a,a + n);
  k = a[0];
  for(i = 1; i < n; i++){
    if(k == a[i]){
      ans = 1;
      break;
    }
    k = a[i];
  }
  if(ans == 0){
    cout << "YES";
  }else{
    cout << "NO";
  }
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[114514],cnt,num;
int main() {
	ll n,mi=1e10;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		num+=abs(a[i]);
		mi=min(abs(a[i]),mi);
		if(a[i]<0)cnt++;
	}
	if(cnt%2)num-=mi*2;
	cout<<num<<endl;
	return 0;
}

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

int main() {
    long long n, i, j;
    string s;
    cin >> n >> s;
    long long red[n], green[n], blue[n];
    long long numr = 0, numg = 0, numb = 0, ans = 0;
    for(i = n-1; i >= 0; i--){
        if(i != n-1){
            red[i] = numr;
            green[i] = numg;
            blue[i] = numb;
        }
        if(s[i] == 'R') numr++;
        if(s[i] == 'G') numg++;
        if(s[i] == 'B') numb++;
    }
    for(i = 0; i < n-2; i++){
        for(j = i + 1; j < n-1; j++){
            if(s[i] == 'R'){
                if(s[j] == 'G'){
                    ans += blue[j];
                    if((2*j - i) < n){
                        if(s[2*j-i] == 'B') ans--;
                    }
                }
                if(s[j] == 'B'){
                    ans += green[j];
                    if((2*j - i) < n){
                        if(s[2*j-i] == 'G') ans--;
                    }
                }
            }
            if(s[i] == 'B'){
                if(s[j] == 'G'){
                    ans += red[j];
                    if((2*j - i) < n){
                        if(s[2*j-i] == 'R') ans--;
                    }
                }
                if(s[j] == 'R'){
                    ans += green[j];
                    if((2*j - i) < n){
                        if(s[2*j-i] == 'G') ans--;
                    }
                }
            }
            if(s[i] == 'G'){
                if(s[j] == 'B'){
                    ans += red[j];
                    if((2*j - i) < n){
                        if(s[2*j-i] == 'R') ans--;
                    }
                }
                if(s[j] == 'R'){
                    ans += blue[j];
                    if((2*j - i) < n){
                        if(s[2*j-i] == 'B') ans--;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int n, q, x, y;
	cin >> n >> q;
	vector<vector<int>> links(n + 1, vector<int>());
	for (int i = 0; i < n - 1; i++) {
		cin >> x >> y;
		links[x].push_back(y);
		links[y].push_back(x);
	}
	vector<int> val(n + 1);
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		val[x] += y;
	}
	vector<int> vis(n + 1, 0);
	stack<int> s;
	s.push(1);
	vis[1] = 1;
	while (s.size()) {
		int u = s.top();
		s.pop();
		for (int v: links[u]) {
			if (!vis[v]) {
				val[v] += val[u];
				s.push(v);
				vis[v] = 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << val[i] << " \n"[i == n];
	}
	return 0;
}

Measured memory_bytes: 16372
n=gets.to_i
as=gets.split.map(&:to_i)
q=gets.to_i
sum=as.sum
ta=as.tally
q.times do |i|
  b,c=gets.split.map &:to_i
  v=ta[b].to_i
  sum += (c-b)*v
  ta[b]=0
  ta[c]=ta[c].to_i+v
  p sum
end

Measured memory_bytes: 26292
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }
  async function solve() {
    const sc = new Scanner();
    const [A, B, C]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    const t: number = Math.floor(B / A);
    if (t >= C) {
      console.log(C);
    } else {
      console.log(t);
    }
    sc.close();
  }

  solve();
}


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

int main() {
    int N, M;
    cin>>N>>M;
    vector<string> A, B;
    string tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        A.push_back(tmp);
    }
    for(int i=0;i<M;++i){
        cin>>tmp;
        B.push_back(tmp);
    }
    bool ans = false;
    bool tmpans;
    for(int i=0;i<N-M+1;++i){
        for(int j=0;j<N-M+1;++j){
            tmpans = true;
            for(int k=0;k<M;++k){
                for(int l=0;l<M;++l){
                    if(A[i+k][j+l] != B[k][l]){
                        tmpans = false;
                        break;
                    }
                }
                if(tmpans == false) break;
            }
            ans = tmpans;
            if(ans) break;
        }
        if(ans) break;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll A, B, C, D, E, F;
ll aw, am;
double ad;

int main(void) {
  cin >> A >> B >> C >> D >> E >> F;

  aw = A;
  am = 0;
  ad = 0;

  REP(i, 0, 31) REP(j, 0, 31) {
    if(i + j == 0) continue;
    ll w = (i * A + j * B);
    if(w * 100 > F) continue;
    REP(k, 0, 3001) REP(l, 0, 3001) {
      ll m = k * C + l * D;
      if(w * 100 + m > F) continue;
      if(w * E < m) continue;
      double d = (double) m / (w * 100 + m);
      if(ad < d) {
        aw = w;
        am = m;
        ad = d;
      }
    }
  }

  cout << (aw * 100 + am) << " " << am << endl;
}


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

int main() {
  int N;
  int64_t K;
  cin>>N>>K;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int64_t l=0,r=1167167167;
  while(l+1<r){
    int64_t D=(l+r)/2;
    int64_t A=0;
    for(int i=0;i<N;i++){
      A+=(p[i]-1)/D;
    }
    if(A>K){
      l=D;
    }
    else{
      r=D;
    }
  }
  cout<<r<<endl;
  
}



Measured memory_bytes: 4776
N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=float('inf')
for i in range(N-K+1):
  l,r=x[i],x[i+K-1]
  if r<=0:
    d=-l
  elif l<=0:
    d=min((-l)*2+r,(-l)+r*2)
  else:
    d=r
  ans=min(ans,d)
print(ans)

Measured memory_bytes: 20044
def solve():
  N, K = map(int, input().split())
  H = list(map(int, input().split()))
  dp = [float('inf')]*N
  dp[0]=0
  for i in range(N):
    for k in range(1,K+1):
      if i+k<N:
        dp[i+k] = min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
  ans = dp[N-1]
  return ans
print(solve())

Measured memory_bytes: 85816
import math

n=int(input())
n2=int(math.sqrt(n))

# 例題3だと割り切れないからこのまま
minimum=n-1
for i in range(1,n2+1):
    # 割り切れるなら以下の処理
    # 例題だとi=2の時割り切れるので
    if(n%i==0):
        # 例題だと
        # 10/3-1+3-1
        # 50/6-1+6-1
        minimum=min(minimum,(n//i-1)+(i-1))

print(minimum)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    map <string, int> mp;

    int n;
    cin >> n;

    string s;
    for(int i = 0; i < n; i ++)
    {
    	cin >> s;
    	mp[s] ++;
    }

    cout << mp.size() << endl;
}

Measured memory_bytes: 19268
pub fn gcd(x: usize, y: usize) -> usize {
    let mut xx = x;
    let mut yy = y;
    if xx < yy {
        std::mem::swap(&mut xx, &mut yy);
    }
    if yy == 0 {
        return xx;
    }
    gcd(xx % yy, yy)
}
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut a: Vec<usize> = sc.vec(n);
    a.sort();
    let mut result: usize = a[0];

    for &x in a.iter() {
        result = gcd(result, x);
    }
    println!("{}", result);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    Main(){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();

        long r=0,g=0,b=0;
        for(int i=0;i<N;i++){
            switch (S.charAt(i)){
                case 'R':
                    r++;
                    break;
                case 'G':
                    g++;
                    break;
                case 'B':
                    b++;
                    break;
            }
        }

        long total = r*g*b;

        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                int k = j + j - i;

                if(N <= k) continue;

                if(S.charAt(i) != S.charAt(j)
                    && (S.charAt(j) != S.charAt(k)
                    &&  S.charAt(i) != S.charAt(k))){
                    total--;
                }
            }
        }

        System.out.println(total);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 37260
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H == 0 && W == 0)
      break;
      for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
          if((i+j)%2==1){
          System.out.print(".");
        }else {
          System.out.print("#");
        }
        }
        System.out.print("\n");
      }
      System.out.println("");
    }
}
}


Measured memory_bytes: 35468
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>	
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define ld long double
#define put(x) printf("%d\n",x)
#define min(x,y) ((x)>(y)?(y):(x))
#define max(x,y) ((x)>(y)?(x):(y))
#define EPS 1e-12
#define pii pair<int,int> 
#define INF 1000000000
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const int MAXN=200010;
int n,len=1,m,flag;
int a[MAXN],vis[MAXN];
int lin[MAXN],ver[MAXN<<1],nex[MAXN<<1],e[MAXN<<1];
priority_queue<pii>q;
inline void add(int x,int y)
{
	ver[++len]=y;
	nex[len]=lin[x];
	lin[x]=len;
}
inline void dij()
{
	a[0]=INF;
	memset(vis,-1,sizeof(vis));
	while(q.size())
	{
		int x=q.top().second;q.pop();
		if(vis[x]!=-1)continue;
		vis[x]=1;
		int minn=0,op,p;
		for(int i=lin[x];i;i=nex[i])
		{
			int tn=ver[i];
			if(a[tn]<=a[minn])
			{
				minn=tn;p=i;
				op=vis[tn];
			}
		}
		if(a[minn]>a[x])
		{
			flag=1;
			return;
		}
		if(op==-1)
		{
			vis[minn]=vis[x]^1;
			e[p]=e[p^1]=a[x];
		}
		else
		{
			vis[x]=vis[minn]^1;
			e[p]=e[p^1]=a[x];
		}
	}
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();m=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		q.push(make_pair(-a[i],i));
	}
	for(int i=1;i<=m;++i)
	{
		int x,y;
		x=read();y=read();
		add(x,y);add(y,x);
	}
	dij();
	if(flag){puts("-1");return 0;}
	for(int i=1;i<=n;++i)printf(vis[i]?"W":"B");
	puts("");
	for(int i=2;i<=len;i+=2)
	{
		if(e[i])printf("%d\n",e[i]);
		else printf("%d\n",INF);
	}
	return 0;
}


Measured memory_bytes: 9972
#include<iostream>
using namespace std;
  int main() {
  int K;
  cin >> K;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[K-1] << endl;
  }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
//int fact[1000002];
const int mod = 1e9 + 7;
int gcdExtended(int a, int b, int *x, int *y); 
  
// Function to find modulo inverse of b. It returns 
// -1 when inverse doesn't 
int modInverse(int b, int m) 
{ 
    int x, y; // used in extended GCD algorithm 
    int g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
  
    // m is added to handle negative x 
    return (x%m + m) % m; 
} 
  
// Function to compute a/b under modlo m 
int modDivide(int a, int b, int m) 
{ 
    a = a % m; 
    int inv = modInverse(b, m); 
    return (inv * a) % m; 
} 
  
// C function for extended Euclidean Algorithm (used to 
// find modular inverse. 
int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    // fact[0] = 1;
    // for(int i=1;i<=1000000;i++) fact[i] = (fact[i-1]*i)%mod;
    int x,y; cin>>x>>y;
    int i = 2*x - y , j = 2*y - x;
    if(i < 0 || j < 0)
    {
        cout<<0;
        return 0;
    }
    if(i%3 != 0 || j%3 !=0){
        cout<<0;
        return 0;
    }
    i /= 3; j /= 3;
    //cout<<i<<" "<<j<<endl;
    int Nr = 1,Dr = 1;
    for(int s = j+1;s <= i+j;s++) Nr = (Nr*s)%mod;
    for(int s = 1;s<=i;s++) Dr = (Dr*s)%mod;
    //cout<<Nr<<" "<<Dr<<endl;
    int m = mod;
    int res = modDivide(Nr,Dr,m);
    cout<<res;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  double a[100];
  for(int j=0; j<N; j++){
      cin>>a[j];
  }
  double sum=0.0;
  sort(a,a+N);
  
  for(int i=0; i<N; i++){
     sum=sum+a[N-1]/a[i];
  }
  cout<<fixed<<setprecision(7)<<(1/sum)*a[N-1];
  return 0;
}  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

int board[10001];

int pop(int x) {
  int n = 0;
  while(x != 0) {
    n = n + 1;
    x = x & (x-1);
  }
  return n;
}

int main() {
  int n,i,j,k,r,c;
  while(scanf("%d %d", &r, &c), r|c) {
    memset(board, 0, sizeof(board));
    rep(i,r) {
      rep(j,c) {
	scanf("%d", &k);
	if(k) board[j] |= (1<<i);
      }
    }

    int ans = 0;
    rep(i,(1<<r)) {
      int t = 0,tt;
      rep(j,c) {
	tt = pop(board[j] ^ i);
	t += max(tt, r-tt);
      }
      ans = max(ans, t);
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 804
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long*)a>*(long long *)b)return 1;
    return -1;
}
int main()
{   int n,m,x,y,k,a,b;
    scanf("%d%d",&n,&k);
    printf("%d",n-k+1);

    return 0;
}


Measured memory_bytes: 128
from itertools import combinations
from copy import deepcopy
H, W, K = map(int, input().split())
field = [[c for c in input()] for i in range(H)]

def hmblack(field):
    count = 0
    for l in field:
        for c in l:
            if c == '#':
                count += 1
    return count

result = 0

for i in range(H+1):
    dline = combinations(range(H), i)
    for cl in dline:
        for j in range(W+1):
            draw = combinations(range(W), j)
            for cr in draw:
                cpf = deepcopy(field)
                for y in range(H):
                    for x in range(W):
                        if y in cl or x in cr:
                            cpf[y][x] = 'r'
                if hmblack(cpf) == K:
                    result += 1
print(result)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  int ans=0;
  string str="";
  string prev="";
  for(int i=0;i<s.size();i++){
    str.push_back(s[i]);
    if(str==prev){
      continue;
    }
    prev=str;
    str="";
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> a(13, 0), b(13, 0);
	a[0] = 1;
	for(int i=0; i<n; i++) {
		b.assign(13,0);
		if (s[i] == '?') {
			for(int j=0; j<13; j++) {
				for(int k=0; k<10; k++) {
					b[(j * 10 + k) % 13] += a[j];
					b[(j * 10 + k) % 13] %= mod;
				}
			}
		} else {
			int k = s[i] - '0';
			for(int j=0; j<13; j++) {
				b[(j * 10 + k) % 13] += a[j];
				b[(j * 10 + k) % 13] %= mod;
			}
		}
		a = b;
	}
	cout << b[5] << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
 
  int a = A / 500;
  int b = a * 500;
  int c = A - b;
  
  if (c <= B) {
  cout << "Yes" << endl;
  } else {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
			int a =sc.nextInt();
			int b =sc.nextInt();
			
			if((a+b)%2==0){
				System.out.println((a+b)/2);
			} else {
				System.out.println((a+b)/2+1);
			}
		}
}

Measured memory_bytes: 22100
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;
  return 0;
}


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

ans = [-1, -1, -1]
flag = 0
for i in range(n + 1):
    for j in range(n + 1 - i):
            if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
                ans = [i, j, n - i - j]
                break
print(' '.join(map(str, ans)))

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int i, j, n, w[100], wb[100], ws[100], a[100], ab[100], as[100], flag=1, tmp, minj, count=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)scanf(" %c%d", &w[i], &a[i]);
    for(i=0; i<n; i++){
        ab[i]=a[i];
        as[i]=a[i];
        wb[i]=w[i];
        ws[i]=w[i];
    }
    while(flag){
        flag=0;
        for(i=n-1; i>0; i--)if(ab[i]<ab[i-1]){
            tmp=ab[i];
            ab[i]=ab[i-1];
            ab[i-1]=tmp;
            tmp=wb[i];
            wb[i]=wb[i-1];
            wb[i-1]=tmp;
            flag=1;
        }
    }
    for(i=0; i<n; i++){
        minj=i;
        for(j=i; j<n; j++)if(as[j]<as[minj]){
                minj=j;
        }
        tmp=as[i];
        as[i]=as[minj];
        as[minj]=tmp;
        tmp=ws[i];
        ws[i]=ws[minj];
        ws[minj]=tmp;
    }
    for(i=0; i<n-1; i++)printf("%c%d ", wb[i], ab[i]);
    printf("%c%d\n", wb[n-1], ab[n-1]);
    printf("Stable\n");
    for(i=0; i<n-1; i++)printf("%c%d ", ws[i], as[i]);
    printf("%c%d\n", ws[n-1], as[n-1]);
    for(i=0; i<n; i++)if(wb[i]!=ws[i]){
        count=1;
        break;
    }
    if(count==0)printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,H[10007];
  double T,A;
    cin >> N >> T >>A;
    double k=MOD,c;
    rep(i,N){
      cin >>H[i];
      if(k>abs(A-T+0.006*H[i])){
        c=i;
        k=abs(A-T+0.006*H[i]);
      }
    }
    cout << c+1 << endl;
}

Measured memory_bytes: 256
/*
PROG: acf17a
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long x)
{
	return (((1ll << 31) * rand()) + rand()) % x;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

const long double PI = 4.0 * atan(1.0);
const long double EPS = 0.000000000000001;

#define SINF 10007
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define CO 1000037

long long normalize(long long x)
{
	return (((x % INF) + INF) % INF);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int pos = 0;
string s;
set<string> st;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	srand(time(0));
	//	cout << fixed << setprecision(12);	
	//	cerr << fixed << setprecision(12);
	if (fopen("acf17a.in", "r"))
	{	
		freopen ("acf17a.in", "r", stdin);
		freopen ("acf17a.out", "w", stdout);
	}
	cin >> s;
	//AKIHABARA
	st.insert("AKIHABARA");
	st.insert("KIHABARA");
	st.insert("AKIHBARA");
	st.insert("AKIHABRA");
	st.insert("AKIHABAR");
	st.insert("KIHBARA");
	st.insert("KIHABRA");
	st.insert("KIHABAR");
	st.insert("AKIHBRA");
	st.insert("AKIHBAR");
	st.insert("AKIHABR");
	st.insert("KIHBRA");
	st.insert("KIHBAR");
	st.insert("KIHABR");
	st.insert("AKIHBR");
	st.insert("KIHBR");
	if (st.find(s) != st.end())
	{
		cout << "YES\n";
	}
	else
	{
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

typedef pair<int,int> P;
int n,m;
vector<int> G[50];
vector<P> es;
bool used[50];

bool dfs(int u, int v, int w){
  used[w] = true;

  //LOG("u=%d, v=%d, w=%d: ", u,v,w);
  if(u==w){
    //LOG("true\n");
    return true;    
  }
  
  for(int x : G[w]){
    if(used[x] || (v==w && x==u))continue;
    
    if(dfs(u,v,x)){
      //LOG("true\n");
      return true;
    }
  }

  //LOG("false\n");
  return false;
}


int main(){
  cin>> n>>m;
  REP(i,m){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
    es.push_back(P(a,b));
  }

  int ans=0;
  for(auto e : es){
    fill(used, used+n, false);
    if(!dfs(e.first, e.second, e.second)){
      ans++;
    }      
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int a,b;
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

max_n = 0
(1...N).each do |i|
  cnt = 0
  S[0...i].chars.uniq.each do |c|
    cnt += 1 if S[i..(N-1)].include?(c)
  end
  max_n = cnt if cnt > max_n
end
puts max_n

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

using ll=long long; 

void solve(){
	int n;
	int x;
	cin>>n>>x;
	vector<int>L(n);
	for(int i=0; i<n; i++)cin>>L[i];
	int sum=0;
	int haneru=1;
	for(int i=0; i<n; i++){
		sum+=L[i];
		if(sum>x){
			break;
		}
		haneru+=1;
	}
	cout<<haneru<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

signed main()
{  
   int N,K; cin>>N>>K;
   vector<pair<int,int>> a;
   REP(i,N){
      int x,y; cin>>x>>y;
      a.push_back(make_pair(y,x));
   }
   sort(a.begin(),a.end(),greater<pair<int,int>>());
   
   int S=0,T=0;
   set<int> st;
   vector<int> x;
   REP(i,K){
      S+=a[i].first;
      if(!st.count(a[i].second)){
         T++;
         st.insert(a[i].second);
      }
      else x.push_back(a[i].first);
   }
   vector<int> y;
   for(int i=K;i<N;i++){
      if(!st.count(a[i].second)){
         y.push_back(a[i].first);
         st.insert(a[i].second);
      }
   }
   sort(x.begin(),x.end());
   //sort(y.begin(),y.end(),greater<int>());

   int ans=S+T*T;
   int curS=S,curT=T;
   REP(i,min((int)x.size(),(int)y.size())){
      curS=curS-x[i]+y[i];
      curT++;
      ans=max(ans,curS+curT*curT);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
int inf=1e9+7;
vector<vector<int> > v;
vector<ll> dp;
ll dfs(int node,int par){
	if(dp[node]!=-1){
		return dp[node];
	}else{
		ll ans=0;
		for(int i=0;i<v[node].size();i++){
			if(v[node][i]!=par){
				ans=max(ans,1+dfs(v[node][i],par));
			}
		}
		dp[node]=ans;
		return ans;
	}
}
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	v.resize(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		v[x-1].push_back(y-1);
	}
	dp.resize(n,-1);
	for(int i=0;i<n;i++){
		if(dp[i]==-1){
			dp[i]=dfs(i,i);
		}
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<ln;
}

Measured memory_bytes: 8576
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

import math
def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = int(input())
    a = 0  #トータルの戦闘回数
    b = 0  #何回めの操作か
    while s > 0:
        s = float(s / 2)
        a += pow(2, b)
        b += 1
        if s < 1:
            break
    print(a)
    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 7492
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s.size()%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  else{
    vector<int> vec(26, 0);
    for(int i=0; i<s.size(); i++){
      int j = s[i] - 'a';
      vec[j]++;
    }
    for(int i=0; i<26; i++){
      if(vec[i]%2 == 1){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	string y,m,d,s;
	cin>>s;
	y=s.substr(0,4);
	m=s.substr(5,2);
	d=s.substr(8,2);
	string ans;
	if(y>"2019") ans="TBD";
	else if (y=="2019" and m>"04") ans="TBD";
	else if (y=="2019" and m=="04" and d>"30") ans="TBD"; 
	else ans="Heisei";
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
int n,m,a[MN],b[MN];
void update(int l,int r){l=max(l,1);r=min(r,n);b[l]++;b[r+1]--;}
int main(){
	scanf("%d%d",&n,&m);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	while(m--){
		for(reg int i=1;i<=n;i++)update(i-a[i],i+a[i]);
		for(reg int i=1;i<=n;i++)b[i]+=b[i-1];
		for(reg int i=1;i<=n;i++)a[i]=b[i],b[i]=0;
		reg int flg=1;
		for(reg int i=1;i<=n;i++)if(a[i]!=n)flg=0;
		if(flg)break;
	}
	for(reg int i=1;i<=n;i++)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  A.push_back(A[0] + K);
  int l = 0;
  rep(i, N)
  {
    l = max(l, A[i + 1] - A[i]);
  }
  int ans = K - l;
  cout << ans << endl;
}

Measured memory_bytes: 1792