akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
using namespace boost::math;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    char A,B;
    cin >> A >> B;
    if(A == 'H'){
        COUT(B);
    }else{
        if(B=='D'){
            COUT("H");
        }else{
            COUT("D");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T> bool chmix(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(!(n%2)) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll inv(ll n, ll mod){
	return PowMod(n, mod-2);
}

int main(void){
	ll n;
	cin >> n;

	Vec a(n);
	rep(i, n) cin >> a[i];

	
	Vec bit(60);
	rep(i, n){
		ll b = a[i];
		rep(j, 60){
			if(b%2) bit[j]++;
			b /= 2;
		}
	}

	ll ans = 0;
	rep(i, n){
		ll b = a[i];
		rep(j, 60){
			if(b%2) ans += (n-bit[j])*((1LL << j)%MOD);
			else ans += bit[j]*((1LL << j)%MOD);
			ans %= MOD;
			b /= 2;
		}
	}
	
	co(ans*inv(2, MOD)%MOD);

	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
typedef long long ll;
using namespace std;
char a[100][100];



int main(void) {
	int h, w;
	cin >> h >> w;
	int num = 0;
	bool can = true;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0;i < h;i++) {
		num = 0;
		for (int j = 0;j < w;j++) {
			if (a[i][j] == '.')num++;
		}
		if (num == w) {
			for (int k = 0;k < w;k++)a[i][k] = ' ';
		}
	}
	for (int i = 0;i < w;i++) {
		can = true;
		for (int j = 0;j < h;j++) {
			if (a[j][i] == '#') {
				can = false;
				break;
			}
		}
		if (can) {
			for (int k = 0;k < h;k++)a[k][i] = ' ';
		}
	}
	num = 0;
	for (int i = 0;i < h;i++) {
		num = 0;
		for (int j = 0;j < w;j++) {
			if (a[i][j] != ' ')cout << a[i][j];
			else num++;
		}
		if(num!=w)cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
  
		public static int poww(int a, int b){
			return (a-b)*(a-b);
		}
  
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 2147483647;
       // int d = new int[K];
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
            }
        
		for (int i=1; i<101;i++){
			int temp = 0;
			for (int j=0; j<a.size();j++)
			{
				temp += poww(i,a.get(j));
			}
			if(temp<sum) {sum = temp;}
        }
		System.out.println(sum);
	}
}

Measured memory_bytes: 35932
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL LOG[100005];
LL pw2[100005];

void add_edge(LL u,LL v){
	cout << u << ' ' << v << endl;
}

int main(){
	LL n; cin >> n;
	LOG[0] = -1; for(LL i = 1;i <= n;i ++) LOG[i] = LOG[i >> 1] + 1;
	for(LL i = 1;i <= n;i ++) pw2[i] = (1LL << LOG[i]);
	if(n == pw2[n]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	add_edge(1,2); add_edge(2,3); add_edge(3,1 + n); add_edge(1 + n,2 + n); add_edge(2 + n,3 + n);
	for(LL i = 4;i + 1 <= n;i += 2){
		add_edge(i,1); add_edge(i + 1,1);
		add_edge(i + n,i + 1); add_edge(i + n + 1,i);
	}
	if(!(n & 1)){
		add_edge(pw2[n] + 1,n);
		add_edge(n - pw2[n],n + n);
	}
	return 0;
}
//

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    cout<<(n-2)*180<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=11;
int n;
char c[N];
long long sum,ans;
void dfs(int k,long long now)
{
	if(k>n)
	{
		sum+=now;
		ans+=sum;
		sum-=now;
		return;
	}
if(k!=1)
		dfs(k+1,now*10+c[k]-'0');
	sum+=now;
	dfs(k+1,c[k]-'0');
	sum-=now;
}
int main()
{
	scanf("%s",c+1);
	n=strlen(c+1);
	dfs(1,0);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
	long long n;
	char a[102];
	while( cin>>a>>n ){
		int i=0;
		while( a[i]=='1' )
			i++;
		if( n<=i )
			cout<<1<<endl;
		else
			cout<<a[i]<<endl;	
	}
	return 0;
	}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0; i<N; ++i) {
        cin >> A[i];
        A[i] = (A[i] - 1) % K;
    }

    vector<int> ac(N+1, 0);
    for (int i=0; i<N; ++i) {
        ac[i+1] = ac[i] + A[i];
        ac[i+1] %= K;
    }

    long long ans = 0;

    map<int, int> cnt;
    for (int i=0; i<=N; ++i) {
        ans += cnt[ac[i]];
        
        cnt[ac[i]] ++;
        if (i-K+1 >= 0) cnt[ac[i-K+1]] --;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i =0; i < (n); i++)
using namespace std;
typedef long long ll;


int main()
{
    int a, b, x;
    double l, ans, p = 3.1415926535;
    cin >> a >> b >> x;
    int n = 0;

    if (x < (double)a * a * b / 2) { //容量の半分以下の時
        l = 2.0 * x / (a * b);
        ans = atan(b/l);
    }
    else {
        x = a * a * b - x;
        l = 2.0 * x / (a * a);
        ans = atan(l/a);
    }

    cout << fixed << setprecision(10) << ans * 180 / p << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int cmpString(const void *n1, const void *n2)
{
    return strcmp((char *)n1, (char *)n2);
}

int main(void)
{

    // 投票用紙枚数の取得
    int i_inputPaperNum;
    scanf("%d", &i_inputPaperNum);

    // 投票用紙に書かれた文字列の取得
    char ca_inputString[i_inputPaperNum][11];
    for (int index = 0; index < i_inputPaperNum; index++)
    {
        scanf("%s", ca_inputString[index]);
    }

    // 文字列をソートする
    qsort(ca_inputString, i_inputPaperNum, sizeof(char [11]), cmpString);

    // 投票回数の判定
    int stringCount[200000] = {};
    int i_maxCount = 0;
    for (int index = 0; index < i_inputPaperNum; index++)
    {
        if (strcmp(ca_inputString[index], ca_inputString[index + 1]) == 0)
        {
            stringCount[index + 1] = stringCount[index] + 1;
        }
    }
    for (int index = 0; index < i_inputPaperNum; index++)
    {
        if (stringCount[index] > i_maxCount)
        {
            i_maxCount = stringCount[index];
        }
    }

    // 結果の出力
    for (int count = 0; count < i_inputPaperNum; count++)
    {
        if (i_maxCount == stringCount[count])
        {
            printf("%s\n", ca_inputString[count]);
        }
    }

    return 0;

}

Measured memory_bytes: 4884
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int s=sc.nextInt();
		int t=sc.nextInt();
		String a=sc.next();
		String b=sc.next();
		int gcdd=(int) gcd(a.length(),b.length());
		for(int i=0; i<gcdd; i++) {
			if(a.charAt(s/gcdd*i)!=b.charAt(t/gcdd*i)) {
				System.out.println(-1);
				System.exit(0);
			}
		}
		System.out.println(lcm(a.length(),b.length()));
	}
	public static long lcm(long m, long n) {
		return m / gcd(m, n)*n;
	}
	public static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}

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

    int main(){
        string s, t;
        cin>>s>>t;
        int sl=s.length(), tl=t.length();
        int n=sl-tl+1;
        int x[n] = {0};
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < tl; ++j)
            {
                if(s[i+j] == t[j]){
                    x[i]++;
                }
            }
        }
        int max=x[0];
        for (int i = 1; i < n; ++i)
        {
            if (x[i]>max)
            {
                max = x[i];
            }
        }
        cout<<tl-max;
    }


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
string S,T;
void input()
{
cin >> S;
cin >> T;
}
void solve()
{
T.pop_back();
if(S==T)
{
cout << "Yes";
}
else
{
cout << "No";
}
}
int main()
{
input();
solve();
return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		Integer[] div = new Integer[B];
		int tmpA = A;
		for (int i = 0; i <= B; i++) {
			if (div[tmpA % B] != null) {
				break;
			}
			div[tmpA % B] = 1;
			tmpA += A;
		}
		if (div[C] != null) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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

    cout << (A+B)%24 << "\n";


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,s1,s2;
    cin>>s;
    ll count=1,i;
    s1=s[0];
    for(i=1;i<s.size();i++){
        s2=s2+s[i];
        if(s1!=s2){
            count++;
            s1=s2;
            s2="";
        }
    }
    cout<<count;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define DBG(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

int main(int argc, char **argv) {
    int h1, m1, h2, m2, k;
    while (cin >> h1 >> m1 >> h2 >> m2 >> k) {
        int y = h1 * 60 + m1;
        int x = h2 * 60 + m2;
        cout << x - y - k << endl;
    }
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


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

int main()
{

   int a , b ,c;
   cin >> a >> b;
   if(a == 1 && b == 2)
    cout <<"3";
   if(a == 2 && b == 1)
    cout <<"3";
    if(a == 3 && b == 2)
    cout <<"1";
    if(a == 3 && b == 1)
    cout <<"2";
    if(a == 2 && b == 3)
    cout <<"1";
    if(a == 1 && b == 3)
    cout <<"2";

    return 0;

}

Measured memory_bytes: 256
n=int(input())
l=[input() for i in range(n)]
a=str(l.count('AC'))
b=str(l.count('WA'))
c=str(l.count('TLE'))
d=str(l.count('RE'))
print('AC x '+a)
print('WA x '+b)
print('TLE x '+c)
print('RE x '+d)

Measured memory_bytes: 79168
/*#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

template<typename T>
map<T, long long> factorize(T x) {
  map<T, long long> res;
  for (long long i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      x /= i;
      res[i] += 1;
    }
  }
  if (x != 1) res[x]++;
  return res;
}


int main() {
  int n; cin >> n;
  vector<ll> fac(n+2,0);
  for (int i = 1; i <= n; ++i) {
    for (auto pa : factorize(i)) {
      fac[pa.first] += pa.second;
    }
  }

  ll res = 0;
  if (fac[2] >= 74) res++;

  rep_r(i,n+1,2)rep_r(j,n+1,2) {
    if (i != j and fac[i] >= 2 and fac[j] >= 24) res++;
  }

  rep_r(i,n+1,2)rep_r(j,n+1,2) {
    if (i != j and fac[i] >= 4 and fac[j] >= 14) res++;
  }

  rep_r(i,n+1,2)rep_r(j,n+1,2)rep_r(k,j+1,2) {
    if (i != j and i != k and fac[i] >= 2 and fac[j] >= 4 and fac[k] >= 4) res++;
  }

  cout << res <<endl;
}
*/

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
map<T, Int> factorize(T x){
  map<T, Int> res;
  for(Int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;

  vector<Int> cnt(111,0);
  for(Int i=1;i<=n;i++){
    for(auto p:factorize(i))
      cnt[p.first]+=p.second;
  }

  Int ans=0;
  // 75 = 74 + 1
  if(cnt[2]>=74) ans++;

  // 75 = (2 + 1) * (24 + 1)
  for(Int i=2;i<111;i++)
    for(Int j=2;j<111;j++)
      if(i!=j&&cnt[i]>=2&&cnt[j]>=24) ans++;


  // 75 = (4 + 1) * (14 + 1)
  for(Int i=2;i<111;i++)
    for(Int j=2;j<111;j++)
      if(i!=j&&cnt[i]>=4&&cnt[j]>=14) ans++;

  // 75 = (2 + 1) * (4 + 1) * (4 + 1)
  for(Int i=2;i<111;i++)
    for(Int j=2;j<111;j++)
      for(Int k=2;k<j;k++)
        if(i!=j&&i!=k&&cnt[i]>=2&&cnt[j]>=4&&cnt[k]>=4) ans++;

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


Measured memory_bytes: 256
import java.util.Scanner;

//Dial Lock
public class Main{

	int n, res;
	int[] now, ans;
	
	void f(int k, int cnt){
		if(res<=cnt)return;
		if(k==n){
			res = cnt; return;
		}
		if(now[k]==ans[k])f(k+1, cnt);
		else{
			int dif = ans[k]-now[k];
			if(dif<0)dif+=10;
			for(int j=k;j<n;j++){
				now[j] = (now[j]+dif)%10;
				f(k+1, cnt+1);
			}
			for(int j=k;j<n;j++)now[j] = (now[j]+10-dif)%10;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			now = new int[n];
			ans = new int[n];
			char[] s = sc.next().toCharArray();
			for(int i=0;i<n;i++)now[i]=s[i]-'0';
			s = sc.next().toCharArray();
			for(int i=0;i<n;i++)ans[i]=s[i]-'0';
			res = n;
			f(0, 0);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <queue>
#include <cstdio>

using namespace std;
const int Max_HW(805);
const int dx[] = {+1, -1, +0, +0};
const int dy[] = {+0, +0, +1, -1};

struct node
{
	node(int _x, int _y) : x(_x), y(_y) {}
	int x, y;
};

int H, W, K, Dist[Max_HW][Max_HW];
char A[Max_HW][Max_HW];

inline bool test(int x, int y)
{
	return 1 <= x && x <= H && 1 <= y && y <= W && A[x][y] == '.';
}

inline int get(int x)
{
	return (x - 1) / K + 1;
}

int main()
{
	queue<node> Q;
	scanf("%d%d%d", &H, &W, &K);
	for (int i = 1;i <= H;++i)
	{
		scanf("%s", A[i] + 1);
		for (int j = 1;j <= W;++j)
			if (A[i][j] == 'S')
				Dist[i][j] = 1, Q.push(node(i, j));
	}
	for (int ux, uy;Q.empty() == false;)
	{
		ux = Q.front().x, uy = Q.front().y, Q.pop();
		for (int k = 0, vx, vy;k != 4;++k)
			if (test(vx = ux + dx[k], vy = uy + dy[k]) && !Dist[vx][vy])
				Dist[vx][vy] = Dist[ux][uy] + 1, Q.push(node(vx, vy));
	}
	int Ans = 0X3F3F3F3F;
	for (int x = 1;x <= H;++x)
		for (int y = 1;y <= W;++y)
		{
			if (Dist[x][y] == 0 || (--Dist[x][y]) > K)
				continue;
			if (x == 1 || x == H || y == 1 || y == W)
				Ans = min(Ans, 1);
			else
			{
				Ans = min(Ans, 1 + get(x - 1));
				Ans = min(Ans, 1 + get(H - x));
				Ans = min(Ans, 1 + get(y - 1));
				Ans = min(Ans, 1 + get(W - y));
			}
		}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  cin >> K >> N;
  vector<int> A(N);
  vector<int> length(N);

  rep(i, N)
  {
    cin >> A[i];
  }
  rep(i, N - 1)
  {
    length[i] = A[i + 1] - A[i];
  }
  length[N - 1] = (K - A[N - 1]) + A[0];
  RSORT(length);
  long long ans = 0;
  rep(i, N - 1)
  {
    ans += length[i + 1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
// D - Not Divisible
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vi A(N);
	int mx = 0;
	rep(i, N){
		cin>>A[i];
		mx = max(mx, A[i]);
	}
	vi c(mx+1, 0);
	for(int a:A){
		for(int i=a; i<=mx; i+=a) c[i]++;
	}
	int ans = 0;
	for(int a:A) if(c[a] == 1) ans++;
	cout<< ans <<endl;
}


Measured memory_bytes: 7984
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ll a, b, q;
  cin >> a >> b >> q;

  vll ss(a);
  rep(i, a) cin >> ss[i];
  vll ts(b);
  rep(i, b) cin >> ts[i];
  rep(i, q) {
    ll x;
    cin >> x;
    auto t1 = upper_bound(ts.begin(), ts.end(), x);
    auto s1 = upper_bound(ss.begin(), ss.end(), x);
    auto t2 = t1 - 1;
    auto s2 = s1 - 1;
    ll ans = INF;
    if (t1 != ts.end() && s1 != ss.end()) chmin(ans, max(*t1 - x, *s1 - x));
    if (t1 != ts.begin() && s1 != ss.begin()) chmin(ans, max(x - *t2, x - *s2));
    if (t1 != ts.end() && s1 != ss.begin()) chmin(ans, *t1 - *s2 + min(*t1 - x, x - *s2));
    if (t1 != ts.begin() && s1 != ss.end()) chmin(ans, *s1 - *t2 + min(*s1 - x, x - *t2));
      cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  int cnt = 0;
  int tmp = 1;
  while(tmp != 2){
    tmp = a[tmp-1];
    cnt++;
    if( cnt > 1e6 ) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;

  return 0;
}




//


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

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a>b){
		if(a<c)
			cout<<b<<" "<<a<<" "<<c<<endl;
		else{
			if(b<c)
				cout<<b<<" "<<c<<" "<<a<<endl;
			else
				cout<<c<<" "<<b<<" "<<a<<endl;
		}
	}
	if(b>a){
		if(b<c)
			cout<<a<<" "<<b<<" "<<c<<endl;
		else{
			if(c<a)
				cout<<c<<" "<<a<<" "<<b<<endl;
			else
				cout<<a<<" "<<c<<" "<<b<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    // ll N,S,K;
    ll a;
    cin >> a;
    cout << a*a*a;

}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[0]*n
ans[0]=1
b=[1]*n
for i in range(m):
  x,y=map(int,input().split())
  if ans[x-1]==1 and b[x-1]>1:
    ans[y-1]=1
    b[x-1]=b[x-1]-1
    b[y-1]=b[y-1]+1
  elif ans[x-1]==1 and b[x-1]==1:
    ans[x-1]=0
    ans[y-1]=1
    b[x-1]=b[x-1]-1
    b[y-1]=b[y-1]+1
  else:
    b[x-1]=b[x-1]-1
    b[y-1]=b[y-1]+1
print(sum(ans))

Measured memory_bytes: 10392
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int h=sc.nextInt(),w=sc.nextInt(),d=sc.nextInt();
		int[] index=new int[h*w+1];
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				index[sc.nextInt()]=w*i+j;
		int p[]=new int[h*w+1];
		for(int i=1;i<=h*w-d;i++)
			p[i]=Math.abs(index[i]/w-index[i+d]/w)+Math.abs(index[i]%w-index[i+d]%w);
		for(int i=h*w-d;i>=0;i--)
			p[i]+=p[i+d];
		int q = sc.nextInt();
		for(int i=0;i<q;i++)
			System.out.println(p[sc.nextInt()] - p[sc.nextInt()]);
	}
}

Measured memory_bytes: 89872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	int n;
	cin >> n;

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

	sort(a.begin(), a.end(), greater<ll>());
	ll ans = a[0];
	int p = 1;
	int cnt = 1;
	while(cnt <= n - 2){
		ans += a[p];
		cnt++;
		if(cnt % 2 == 1) p++;
	}

	cout << ans << endl;	
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

//解説参考.
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<string(d-b,'U')<<string(c-a,'R');
	cout<<string(d-b,'D')<<string(c-a,'L');
	cout<<'L'<<string(d-b+1,'U')<<string(c-a+1,'R')<<'D';
	cout<<'R'<<string(d-b+1,'D')<<string(c-a+1,'L')<<'U';
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,H=map(int,input().split())
m=0
l=[None]*N
for i in range(N):
    a,b=map(int,input().split())
    if a>m:
        m=a
    l[i]=b
l.sort(reverse=1)
a=0
for i in l:
    if i<=m:
        a+=-(-H//m)
        break
    H-=i
    a+=1
    if H<=0:
        break
else:
    a+=-(-H//m)
print(a)

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

using namespace std;

int n;
long long k;
vector<long long> a;
vector<long long> f;

bool solve(long long t)
{
    long long m=a[0];
    long long cnt=0;
    for(int i=0;i<n;i++)
    {
        long long x=a[i]-m;
        if(((a[i]*f[i]-t)%f[i])==0) x=max(x,(a[i]*f[i]-t)/f[i]);
        else x=max(x,(a[i]*f[i]-t+f[i]-1)/f[i]);
        x=max(x,0ll);
        cnt+=x;
        m=min(m,a[i]-x);
    }
    return (cnt<=k);
}

int main()
{
    cin >> n >> k;
    a.resize(n);
    f.resize(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> f[i];
    sort(a.begin(),a.end(),greater<long long>());
    sort(f.begin(),f.end());
    long long l=-1,r=1000000000000;
    while(l<r-1)
    {
        long long m=(l+r)/2;
        if(solve(m)) r=m;
        else l=m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int n;
int cnt;
void rec(int n0,int sum){
    if(sum==n) cnt++;
    else if(sum>n);
    else
    rec(n0+1,sum+(n0+1));
}
void start(){
    for(int i=1;i<=((n-1)/2);i++){
        rec(i,i);
    }
}
int main(void){
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        cnt=0;
        start();
        printf("%d\n",cnt);
    }
}



Measured memory_bytes: 2040
#include<iostream>
#include<cstring>
using namespace std;
int a, b, c, x[11], sum;
int main() {
	while (cin >> a >> b >> c) {
		memset(x, 0, sizeof(x));
		x[a] = 1;
		x[b] = 1;
		x[c] = 1; sum = 0;
		for (int i = 1; i <= 20 - (a + b); i++) {
			if (x[i] == 0) { sum++; }
		}
		if (sum > 3) { cout << "YES" << endl; }
		else { cout << "NO" << endl; }
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  for(int i=0;i<n;i++){
    cin >> data.at(i);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(i!=j) ans+=data.at(i)*data.at(j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            int a,b,c,ctr=0;
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();

            for(int i=a; i <= b; i++){
                if(c % i == 0){
                    ctr++;
                }
            }
            System.out.println(ctr);
        }
    }
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int a,b;cin>>a>>b;
	if(a<=9&&b<=9)cout<<a*b<<endl;
	else puts("-1");
}

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int MOD2 = 998244353;
const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);
#define fi first
#define se second
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )

void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << endl;
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Fry my kartoshka
 */

const int MAXN = 17;
const int INF = 2e9;
const ld PI = 3.14159265358979323846;

int a[MAXN][MAXN];
ll dp[1 << MAXN + 1];
ll add[1 << MAXN + 1];

const int REV = (1 << 31) - 1;

int main(){
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	dp[0] = 0;

	for(int i = 1; i < (1 << n) + 1; i++){
		dp[i] = -INF;
	}

	for(int mask = 0; mask < (1 << n); mask++){
		for(int i = 0; i < n; i++){
			if(mask & (1 << i)){
				for(int j = 0; j < n; j++){
					if(mask & (1 << j)){
						add[mask] += a[i][j];
					}
				}
			}
		}

		add[mask] /= 2;
	}

	ll ans = 0;
	for(int mask = 0; mask < (1 << n); mask++){
		int rem = ((1 << n) - 1) ^ mask;
		for(int sub = rem; sub > 0; sub = (sub - 1) & rem){
			dp[mask | sub] = max(dp[mask | sub], dp[mask] + add[sub]);
			ans = max(ans, dp[mask | sub]);
		}
	}
	cout << dp[(1 << n) - 1];
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int a,n,s=0;
  cin>>a;
  n=a;
  while(a!=0){
    s+=a%10;
    a/=10;
  }
  if(n%s==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
<?php
$input = file_get_contents('php://stdin');
$inarr = explode(" ", $input);

$a = $inarr[0];
$b = $inarr[1];

$min = ($b-1)/0.1;
$max = ($b+1)/0.1;

for($i=$min;$i<=$max;$i++){
  $hati = floor($i*0.08);
  $jyuu = floor($i*0.1);
  if($hati==$a and $jyuu==$b){
    echo $i;
    exit();
  }
}
echo "-1";

?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int x, r, d;
	cin >> r >> d >> x;
	for(int i = 0; i < 10; ++i){
		x = x * r - d;
		cout << x << endl;
	}
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
a.reverse()
for i in range(n-1):
    a[i]-=a[i+1]
a[n-1] = 0
a.append(k-sum(a))
ans = k-max(a)
print(ans)

Measured memory_bytes: 26444
#include <iostream>
#include <stdio.h>
#include <utility>
using namespace std;
int main(){
	double px,py;
	double tx[3],ty[3];
	bool flag;
	bool v[3];
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&tx[0],&ty[0],&tx[1],&ty[1],&tx[2],&ty[2],&px,&py) == 8){
		for(int i=0;i<3;i++){
			tx[i]=tx[i]-px;
			ty[i]=ty[i]-py;
		}
		for(int i=0;i<3;i++){
			if((tx[i%3]*ty[(i+1)%3])-(ty[i%3]*tx[(i+1)%3])<0){
				v[i]=true;
			}else{
				v[i]=false;
			}
		}
		
		if(v[0]!=v[1]){
			cout<<"NO"<<endl;
		}else if(v[1]!=v[2]){
			cout<<"NO"<<endl;
		}else {
			cout<<"YES"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
set<pii> s; int n,a[N];
void gao(int x,int now)
{	if(x<1) throw 0;
	auto tmp=*s.lower_bound(mp(x,0));
	if(tmp.first!=x) s.insert(mp(x,0)),tmp=mp(x,0);
	else
	{	s.erase(tmp);tmp.second++;
		if(tmp.second>=now) gao(x-1,now);
		else s.insert(tmp);
	}
	while(1)
	{	if(s.upper_bound(tmp)==s.end()) break;
		tmp=*s.upper_bound(tmp); s.erase(tmp);
	}
}
inline int check(int x)
{	s.clear();
	try{for(rint i=1;i<=n;i++)if(a[i]<=a[i-1])gao(a[i],x-1);throw 1;}
	catch(int x){return x;}
}
int main()
{	int tag=1; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]),tag&=(a[i]>a[i-1]);
	if(tag) return !printf("1\n");
	int l=2,r=n,ans=-1;
	while(l<=r)
	{	int mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;
#define  PI  3.14159265358979323846

int main() {
  double r;
  cin >> r;

  cout << 2 * PI * r << endl;
}

Measured memory_bytes: 3768
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_sa = []
for i in range(len(x)-1):
    x_sa.append(abs(x[i]-x[i+1]))
x_sa.sort()
ans = 0
if n >= m:
    print(0)
else:
    for i in range(m-n):
        ans += x_sa[i]
    print(ans)

Measured memory_bytes: 13968
#include<stdio.h>
int main(void)
{
	int n,m,nn[100],mm[100];
	int i,j;
	int nmin,mmin,nsum,msum;

	while(1)	{
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)	break;
		nsum=0;
		for(i=0;i<n;i++)	{
			scanf("%d",&nn[i]);
			nsum+=nn[i];
		}
		msum=0;
		for(i=0;i<m;i++)	{
			scanf("%d",&mm[i]);
			msum+=mm[i];
		}
		nmin=999;
		mmin=999;
		for(i=0;i<n;i++)	{
			for(j=0;j<m;j++)	{
				if(nsum-nn[i]+mm[j] == msum-mm[j]+nn[i])	{
					if(nmin>nn[i])	{
						nmin=nn[i];
						mmin=mm[j];
					}
				}
			}
		}
		if(nmin==999)	{
			printf("-1\n");
		}
		else {
			printf("%d %d\n",nmin,mmin);
		}
	}
	return 0;
}


Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <tuple>
#include <unordered_set>
#include <stack>

std::vector<std::vector<std::tuple<int, int>>> t_arr;
std::vector<int> length_arr;
std::unordered_set<int> found, remained;
bool dfs(int current, int parent, int length){
  length_arr[current] = length;
  found.insert(current);
  remained.erase(current);
  for(auto&& neigh: t_arr[current]){
    int nn, nlength;
    std::tie(nn, nlength) = neigh;
    if(nn == parent) continue;
    if(found.count(nn) != 0){
      if(length+nlength != length_arr[nn]) return false;
    }else{
      if(dfs(nn, current, length+nlength) == false) return false;
    }
  }
  return true;
}

int main(){
  int N,M;
  std::cin >> N >> M;

  t_arr.resize(N+1);
  for(int i = 0; i < M; i++){
    int L,R,D;
    std::cin >> L >> R >> D;
    t_arr[L].push_back(std::make_tuple(R,D));
    t_arr[R].push_back(std::make_tuple(L,-D));
  }

  bool consistent = true;
  length_arr.resize(N+1);
  for(int i = 1; i <= N; i++) remained.insert(i);
  while(remained.size() > 0){
    auto n = *(remained.begin());
    remained.erase(n);
    if(dfs(n, -1, 0) == false){
      consistent = false;
      break;
    }
  }

  if(consistent) std::cout << "Yes\n";
  else std::cout << "No\n";

  return 0;
}



Measured memory_bytes: 19004
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int a,b,c;
        cin >> a >> b >> c;
        int ans = min(b/a,c);
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
def main():
    import sys
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    MOD = 998244353
    class ModInt:
        def __init__(self, x):
            self.x = x % MOD

        def __str__(self):
            return str(self.x)

        __repr__ = __str__

        def __add__(self, other):
            return (
                ModInt(self.x + other.x) if isinstance(other, ModInt) else
                ModInt(self.x + other)
            )

        def __sub__(self, other):
            return (
                ModInt(self.x - other.x) if isinstance(other, ModInt) else
                ModInt(self.x - other)
            )

        def __mul__(self, other):
            return (
                ModInt(self.x * other.x) if isinstance(other, ModInt) else
                ModInt(self.x * other)
            )

        def __truediv__(self, other):
            return (
                ModInt(
                    self.x * pow(other.x, MOD - 2, MOD)
                ) if isinstance(other, ModInt) else
                ModInt(self.x * pow(other, MOD - 2, MOD))
            )

        def __pow__(self, other):
            return (
                ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
                ModInt(pow(self.x, other, MOD))
            )

        __radd__ = __add__

        def __rsub__(self, other):
            return (
                ModInt(other.x - self.x) if isinstance(other, ModInt) else
                ModInt(other - self.x)
            )

        __rmul__ = __mul__

        def __rtruediv__(self, other):
            return (
                ModInt(
                    other.x * pow(self.x, MOD - 2, MOD)
                ) if isinstance(other, ModInt) else
                ModInt(other * pow(self.x, MOD - 2, MOD))
            )

        def __rpow__(self, other):
            return (
                ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
                ModInt(pow(other, self.x, MOD))
            )

    n,k = ina()
    dp = [ModInt(0)]*(n+1)
    dp[1] = 1
    pair = [(0,0)]*k
    for i in range(k):
        l,r = ina()
        pair[i] = (l,r)
    for i in range(1,n):
        tmp = i
        dp[tmp]+=dp[tmp-1]
        for j in range(k):
            if(tmp+pair[j][0])<=n:
                # print(tmp,pair[j][0])
                dp[tmp+pair[j][0]]+=dp[tmp]
                # print(dp)
            if(tmp+pair[j][1])<=n-1:
                # print(tmp,pair[j][1])
                dp[tmp+pair[j][1]+1]-=dp[tmp]
                # print(dp)
    # print(dp)
    print(dp[n])
        
        
    

    
    
        


    
        


        


    




















if __name__ == "__main__":
    main()

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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0;
}

int main()
{
  string s; cin >> s;
  string t; cin >> t;

  ll slen = (int)(s.size());
  ll tlen = (int)(t.size());

  vector<vector<ll>> dp(slen+1, vector<ll>(tlen+1, 0));
  for (int i=0; i<slen; i++) {
    for (int j=0; j<tlen; j++) {
      if (s[i] == t[j]) {
        chmax(dp[i+1][j+1], dp[i][j]+1);
      }
      chmax(dp[i+1][j+1], dp[i+1][j]);
      chmax(dp[i+1][j+1], dp[i][j+1]);
    }
  }

  string ans = "";
  int i = (int)(s.size());
  int j = (int)(t.size());
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i-1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j-1]) {
      j--;
    } else {
      ans.push_back(s[i-1]);
      i--; j--;
    }
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


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

using ll = long long;

ll N, x;
ll a[111111];

int main() {
   cin >> N >> x;
   for (int i = 0; i < N; i++) cin >> a[i];

   ll ans = 0;
   for (int i = 1; i < N; i++) {
      ll sum = a[i-1] + a[i];
      if (sum > x) {
         ll diff = sum - x;
         ans += diff;
         if (diff > a[i])  {
            a[i] = 0;
         } else {
            a[i] -= diff;
         }
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 1024
n = int(input())
li = list(map(int, input().split()))
s =int(sum(li) / len(li))
p = 0
q = 0

if s < 0:
    a = s - 1
    b = s
else:
    a = s
    b = s + 1

for i in range(len(li)):
    p = p + (li[i] - a) ** 2
    q = q + (li[i] - b) ** 2

print(min(p, q))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

const int maxn = 5e5 + 5;
int n, q;
int val;
int l[maxn], pos[maxn], fe[maxn], res[maxn], z[maxn], p[maxn];
piii qu[maxn];

bool cmp(const int &x, const int &y){
    return l[x] < l[y];
}

void up(int i){
    if (i > n) return;
    fe[i]++;
    up(i + (i & (-i)));
}

int get(int i, int j){
    if (j < i) return 0;
    int tmp = j - (j & (-j));
    if (tmp < i) return get(i, j - 1) + z[j];
    return get(i, tmp) + fe[j];
}

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> q;
    for (int i = 1; i <= n; i++){
        cin >> val;
        l[i] = pos[val];
        pos[val] = i;
    }
    for (int i = 0; i < q; i++){
        cin >> qu[i].fr >> qu[i].sc;
        qu[i].th = i;
    }
    sort(qu, qu + q);
    for (int i = 1; i <= n; i++) p[i] = i;
    sort(p + 1, p + 1 + n, cmp);

    int j = 1, c0 = 0;
    for (int i = 0; i < q; i++){
        while (j <= n && l[p[j]] < qu[i].fr){

                z[p[j]]++;
                up(p[j]);
            j++;
        }
        res[qu[i].th] = get(qu[i].fr, qu[i].sc);
    }
    for (int i = 0; i < q; i++) cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 27192