akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
	VI pm;
	vector<bool> is_pm( 100000, true );
	is_pm[ 0 ] = is_pm[ 1 ] = false;
	for ( int i = 2; i * i < 100000; i += 2 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j < 100000; j += i ) {
				is_pm[ j ] = false;
				if ( i == 2 ) {
					j += i;
				}
			}
			if ( i == 2 ) {
				--i;
			}
		}
	}
	for ( int i = 2; i < 100000; i += 2 ) {
		if ( is_pm[ i ] ) {
			pm.push_back( i );
			if ( i == 2 ) {
				i--;
			}
		}
	}
	int m, a, b;
	while ( ~scanf( "%d %d %d", &m, &a, &b ) && m && a && b ) {
		int ans_a = 0, ans_b = 0;
		for ( int i = 0; i < pm.size(); i++ ) {
			if ( sq( pm[ i ] ) > m ) {
				break;
			}
			for ( int j = i; j < pm.size(); j++ ) {
				if ( pm[ i ] * pm[ j ] > m || ( double ) a / b > ( double ) pm[ i ] / pm[ j ] ) {
					break;
				}
				if ( pm[ i ] * pm[ j ] > ans_a * ans_b ) {
					ans_a = pm[ i ];
					ans_b = pm[ j ];
				}
			}
		}
		printf( "%d %d\n", ans_a, ans_b );
	}
	return 0;
}

Measured memory_bytes: 1320
while line = gets
  nums = line.split(" ").map(&:to_i)
  remains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - nums

  draw_decision = nums[0] + nums[1] + remains[3]

  puts draw_decision <= 20 ? "YES" : "NO"
end

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


using namespace std;
using ll = long long;

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






int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    
    ll m,n;
    cin >> n >> m;
    ll k[n];
    ll h[n];

    rep(i,n)
    {
        cin >> h[i];
        k[i]=i;
    }
    
    rep(i,m)
    {
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
       if(h[a]>h[b])
       {
           k[b]=k[a];
       }else if(h[a] <h[b]) 
       {k[a]=k[b];}else{
           k[a]=-1;
           k[b]=-1;
       }

    }
    ll ans=0;
    rep(i,n)
    {
        if(k[i]==i) 
        {ans++;
        
        }
    }
    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 5208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int a[7]={1,3,5,7,8,10,12};
  int b[4]={4,6,9,11};
  int xx=0,yy=0;
  int x,y;
  cin>>x>>y;
  for(int i=0;i<7;i++){
    if(a[i]==x)xx=1;
    if(a[i]==y)yy=1;
  }
  for(int i=0;i<4;i++){
    if(b[i]==x)xx=2;
    if(b[i]==y)yy=2;
  }
  if(xx==yy)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys,time
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def solve():
    start = time.time()

    N = inp()
    AA = [inpl() for _ in range(N)]
    itrs = [0]*N
    ans = cnt = 0

    while True:
        next = set()
        for x,itr in enumerate(itrs):
            if itr < N-1:
                t = AA[x][itr] - 1
                if AA[t][itrs[t]]-1 == x:
                    next.add(x)

        for n in next:
            itrs[n] += 1
            if itrs[n] == N-1:
                cnt += 1

        if len(next) == 0:
            for x in itrs:
                if x != N-1:
                    return -1
            return ans

        now = time.time() - start
        if now > 1.6:
            return N*(N-1)//2

        ans += 1

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 55256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

using llint = long long int;

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
llint t;
vector<string> d;
llint now = 0;
void dfs(int n,string s="",char maxc='0',bool f=false){
    if(s.size()==n){
        now++;
      //  cout << now << endl;
        d.push_back(s);
        //cout << s << endl;
        if(now==t){
           
        }
    }else{
        if(f==false){
            
            dfs(n,s+'0','0');
            for (auto c = '1'; c <= '9';c++){
           
                dfs(n,s+c,c,true);
            }
        }else{
            for (auto c = max('0',(char)(maxc-1)); c <= min('9',(char)(maxc+1));c++){
           
                dfs(n,s+c,c,true);
            }
        }
    }
}


int main(){
    cin>>t;
    for (auto x = '0'; x <= '4';x++){
        string t;
        t += x;
        dfs(10, t,x,x=='0'?false:true);

    }
    vector<string> k(d);
    
    sort(k.begin(), k.end());
    string result=k[t];
    REP(i,k[t].size()-1ll){
     //   cout << result << endl;
        if(k[t][i]=='0'){
            result = k[t].substr(i + 1);
        }else{
            break;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 8436
a, b, c=map(int,input().split())
A,B,C = a,b,c
ans = 0
if(a%2 or b%2 or c%2):
  print(0)
  exit(0)
while(a%2==0 and b%2==0 and c%2==0):
  if(A==B==C):
    ans = -1
    break
  A,B,C = a,b,c
  a = B//2 + C//2
  b = A//2 + C//2
  c = A//2 + B//2
  ans += 1
print(ans)
  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,ans;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a>>b;
	ans=(a-1)*(b-1);
	printf("%d\n",ans); 
	return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size();
    char x;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        x = s[n - 1];
        s.pop_back();
        s = x + s;
        if (s == t)
        {
            count++;
        }
    }

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

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int par[100000]; //parent
int rnk[100000]; //depth

//init with n elements
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
//find a root of the tree
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//merge the sets contains x,y
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rnk[x] < rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

//the set contains x and y or not
bool same(int x, int y) {
	return find(x) == find(y);
}
int main()
{
    int n,m;
    cin>>n>>m;
    init(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        unite(a,b);
    }
    int q;
    cin>>q;
    vector<string>ans(q);
    rep(i,q){
        int a,b;
        cin>>a>>b;
        if(same(a,b))ans[i]="yes";
        else ans[i]="no";
    }
    rep(i,q)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4080
#include <stdio.h>

int main()
{
  int number[100];
  int N, K;
  int tmp;
  int sum = 0;

  scanf("%d %d", &N, &K);
  for(int p = 0; p < N; ++p){
    scanf("%d", &number[p]);
  }

  for (int i = 0; i < N; ++i){
    for (int j = i+1; j < N; ++j){
      if (number[i] < number[j]){
        tmp =  number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }
  for (int i = 0; i < K; ++i){
    sum += number[i];
  }
  printf("%d", sum);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;

const long long TIME_LIMIT=10000;

ll scorecalc(vector<vector<ll>> a, vector<ll> los, ll d, vector<ll> an)
{
    ll ans = 0;
    
    vector<ll> last(los.size(), 0);
    for (int i = 0; i < an.size(); i++)
    {
        ll loss = 0;
        for (int j = 0; j < 26; j++)
        {
            if (j == an[i] - 1)
                continue;

            loss += los[j] * (i+1LL - last[j]);
        }
        ans += a[i][an[i] - 1] - loss;
        last[an[i] - 1] = i + 1LL;
    }

    return ans;
}

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

    ll d;
    cin >> d;
    vector<ll> c(26);
    rep(i, 26)
    {
        cin >> c[i];
    }
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i, d)
    {
        rep(j, 26)
            cin >> s[i][j];
    }

    vector<ll> ans(d);

    vector<ll> last(26, 0);

    for (ll i = 0; i < d; i++)
    {
        ll lost = 0;
        for (int j = 0; j < 26; j++)
        {
            lost += c[j] * (i + 1 - last[j]);
        }
        ll man = s[i][0] - lost + c[0] * (i + 1 - last[0]);
        ll manu = 1;
        for (int j = 0; j < 26; j++)
        {
            if (man <= s[i][j] - lost + c[j] * (i + 1 - last[j]))
            {
                man = s[i][j] - lost + c[j] * (i + 1 - last[j]);
                manu = j + 1LL;
                last[j] = i + 1;
            }
        }
        ans[i] = manu;
    }
    ll score = scorecalc(s, c, d, ans);
    ll times = 0;
    while (times < 30000)
    {
        ll tmpD = (ll)rand() % d;
        ll tmpN = ans[tmpD];
        ans[tmpD] = (ll)rand() % 26 + 1;

        if (score >= scorecalc(s, c, d, ans))
            ans[tmpD] = tmpN;
        else
            score = scorecalc(s, c, d, ans);

        times++;
    }

    rep(i, d)
    {
        cout << ans[i] << endl;
    }

	return 0;

}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

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

    int N, K;
    cin >> N >> K;
    vector<int>H(N);
    cin >> H;
    SORT(H);

    vector<int> dis(N);
    dis[0] = 0;
    REP(i, N - 1) {
        dis[i + 1] = dis[i] + H[i + 1] - H[i];
    }

    int ans = INF;
    REP(i, N - K + 1) {
        ans = min(ans, dis[i + K - 1] - dis[i]);
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int x,y;cin >> x >> y;
    bool ok = false;
    for(int i=0;i<=x;++i){
        int j = x - i;
        if(2*i + 4*j == y){
            ok = true;
            break;
        }
    }
    cout << (ok? "Yes\n" : "No\n");
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
int X;
int C[12], A[12][12];

signed main(){
    cin >> N >> M >> X;
    rep(i, N){
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    int ans = INT_MAX;
    rep(i, (1<<N)){
        int tmp[12] ={};
        int c = 0;
        rep(j, N){
            if((i>>j)&1){
                c += C[j];
                rep(k, M){
                    tmp[k] += A[j][k];
                }
            }
        }
        bool flg = true;
        rep(j, M){
            if(tmp[j] < X) flg = false;
        }
        if(flg) ans = min(ans, c);
    }
    if(ans == INT_MAX) cout << -1 << endl;
    else cout << ans << endl;
}

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

using ll = long long;

int main(){
    ll x, k, d;
    scanf("%lld%lld%lld", &x, &k, &d);
    if (x + __int128(k) * d <= 0){
        printf("%lld\n", std::abs(x + k * d));
        return 0;
    }
    if (x - __int128(k) * d >= 0){
        printf("%lld\n", std::abs(x - k * d));
        return 0;
    }
    if (k == 1){
        printf("%lld\n", std::min(std::abs(x + d), std::abs(x - d)));
        return 0;
    }
    if (k & 1){
        x += d;
    }
    x = x % (2 * d);
    x += x < 0 ? 2 * d : 0;
    printf("%lld\n", std::min(x, std::abs(x - 2 * d)));
    return 0;
}

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

#define ll long long

int main()
{
	int n;
	cin>>n;
	int a[n],b[n+1];
	memset(b,0,sizeof(b));
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
		b[a[i]]++;

	}
	for(int i=0;i<n;i++)
	{
		cout<<b[i+1]<<endl;
	}
}



Measured memory_bytes: 5196
#include<cstdio>
#include<cstring>

int main(){
    char s[201], t[101], p[101];

    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);

    if ( strstr(s, p) == NULL ) printf("No\n");
    else printf("Yes\n");

    return 0;
}

Measured memory_bytes: 2756
from sys import stdin
def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
 
n = I()
s = list(S())

r = s.count('R')
g = s.count('G')
b = s.count('B')
 
ans = r*g*b
for i in range(n-1):
    for j in range(1,n):
        if i-j<0 or n<=i+j:
            break
        else:
            if s[i-j]!=s[i] and s[i]!=s[i+j] and s[i-j]!=s[i+j]:
                ans-=1
 
print(ans)

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

int main(){
    int H, W; cin >> H >> W;

    vector<vector<char>> S(H+2,vector<char>(W+2,'#'));

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            char c; cin >> c;
            S.at(i+1).at(j+1) = c;
        }
    }

    int ans = 0;
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(S.at(i).at(j) == '#'){
                continue;
            }

            queue<pair<int,int>> bfs;
            vector<vector<int>> dist(H+2,vector<int>(W+2,-1));
            int ans_ij = 0;
            dist.at(i).at(j) = 0;
            pair<int,int> start = make_pair(i,j);
            
            bfs.push(start);

            while(!bfs.empty()){
                pair<int,int> now = bfs.front();
                bfs.pop();

                int now_x = now.first; int now_y = now.second;
                
                ans_ij = max(ans_ij,dist.at(now_x).at(now_y));

                if( S.at(now_x).at(now_y-1) != '#' && dist.at(now_x).at(now_y-1) == -1){
                    bfs.push(make_pair(now_x,now_y-1));
                    dist.at(now_x).at(now_y-1) = dist.at(now_x).at(now_y) +1;
                }
                if( S.at(now_x).at(now_y+1) != '#' && dist.at(now_x).at(now_y+1) == -1){
                    bfs.push(make_pair(now_x,now_y+1));
                    dist.at(now_x).at(now_y+1) = dist.at(now_x).at(now_y) +1;
                }
                if( S.at(now_x-1).at(now_y) != '#' && dist.at(now_x-1).at(now_y) == -1){
                    bfs.push(make_pair(now_x-1,now_y));
                    dist.at(now_x-1).at(now_y) = dist.at(now_x).at(now_y) +1;
                }
                if( S.at(now_x+1).at(now_y) != '#' && dist.at(now_x+1).at(now_y) == -1){
                    bfs.push(make_pair(now_x+1,now_y));
                    dist.at(now_x+1).at(now_y) = dist.at(now_x).at(now_y) +1;
                }

            }
            ans = max(ans,ans_ij);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   int h,n;
   cin >> h >> n;
   int sum =0;
   rep(i,n)
   {
      int foo;
      cin >> foo;
      sum +=foo;
   }
   if(sum<h)
   {
      cout<<"No"<<endl;
   }
   else
   {
      cout<<"Yes"<<endl;
   }
   
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {

            int n, a, b, p1, p2,  x;

            var word = Console.ReadLine().Split(' ');

			n = int.Parse(word[0]);
			a = int.Parse(word[1]);
			b = int.Parse(word[2]);

			if (a * n < b)
				x = a * n;
			else
				x = b;



			Console.WriteLine(x);

            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
 
	public static void main(String[] args) {
		new Main();	
	}
 
	public Main() {
		new A().doIt();
	}
	class A{
		class Data{
			int num,time;
			public Data(int num,int time) {
				this.num = num;
				this.time = time;
			}
		}
		void sort(Data data[],int n){
			for(int i = 1;i < n;i++){
				for(int j = i;j > 0;j--){
					if(data[j].time < data[j-1].time){
						Data temp = data[j];
						data[j] = data[j-1];
						data[j-1] = temp;
					}
				}
			}
		}
		void doIt(){
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				Data data[] = new Data[n];
				for(int i = 0;i < n;i++){
					int num = sc.nextInt();
					int time = (sc.nextInt()*60) + sc.nextInt();
					time = time + (sc.nextInt()*60) + sc.nextInt();
					time = time + (sc.nextInt()*60) + sc.nextInt();
					time = time + (sc.nextInt()*60) + sc.nextInt();
					data[i] = new Data(num,time);
				}
				sort(data,n);
				System.out.printf("%d\n%d\n%d\n",data[0].num,data[1].num,data[n-2].num);
			}
		}
	}
}

Measured memory_bytes: 69284
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			if(j * (n - i) + i * (m - j) == k){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   if(s[0] != s[1])
      cout << "Yes" << endl;
   else if (s[1] != s[2]) cout << "Yes" << endl;
   else if (s[0] != s[2])
      cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int maxi = *max_element(a.begin(), a.end());
  if(sum - maxi > maxi){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

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

int main(){
    int n;cin>>n;
    ll ans=0;
    rep(i,n-1){
        ans+=n/(i+1);
        if(n%(i+1)==0)ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);
  
int N;
  cin>>N;
  int sum=0;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    sum+=b-a+1;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int int_fast64_t
using namespace std;
const int MX = 1e5 + 100;
int sz[MX], dst[MX];
pii v[MX];
vector<int> G[MX];
main () {
    int n; cin >> n;
    for(int i = 1; i <= n; i ++) cin >> v[i].F, v[i].S = i;
    sort(v + 1, v + 1 + n);
    unordered_map<int, int> mp;
    for(int i = 1; i <= n; i ++) mp[v[i].F] = v[i].S, sz[i] = 1;
    for(int i = n; i > 1; i --) {
        int ptr = v[i].F - (n - sz[v[i].S]) + sz[v[i].S];
        if(ptr >= v[i].F or !mp[ptr]) return cout << -1, 0;
        int pp = mp[ptr];
        G[pp].push_back(v[i].S);
        sz[pp] += sz[v[i].S];
        dst[pp] += dst[v[i].S] + sz[v[i].S];
    }
    if(dst[v[1].S] != v[1].F) return cout << -1, 0; 
    for(int i = 1; i <= n; i ++) {
        for(auto it: G[i]) cout << i << ' ' << it << endl;
    }
}

Measured memory_bytes: 14116
#include <iostream>

using namespace std;


struct CARD {char suit,  value;};

void babble(int n, CARD *pcard)
{
	for(int i=0;i<n;i++){
		for(int j=n-1;i<j;j--){
			if(pcard[j].value<pcard[j-1].value) swap(pcard[j],pcard[j-1]);
		}
	}
}

void selectsort(int n, CARD *pcard)
{
	int min;
	int minv;
	for(int i=0;i<n;i++){
		min=i;
		for(int j=i; j<n;j++){
			if(pcard[j].value<pcard[min].value) min=j;
		}
		swap(pcard[min],pcard[i]);
	}
}

void stable(CARD *in, CARD *out, int n)
{
	int flag=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int a=0;a<n;a++){
				for(int b=a+1;b<n;b++){
					if((in[i].value==in[j].value)&&(in[i].suit==out[b].suit)&&(in[j].suit==out[a].suit)&&(in[i].value==out[b].value)&&(in[j].value==out[a].value)){ 
						flag=1;
						break;
					}
				}
			}
		}
	}
	if(flag==1){ cout <<"Not stable"<<endl;}
	else cout <<"Stable"<<endl;
}

int main()
{

	CARD c1[100],c2[100];

	int n;
	int buff[200];
	cin>>n;
	for(int i=0;i<n;i++) cin>>c1[i].suit>>c1[i].value;
	for(int i=0;i<n;i++) c2[i]=c1[i];

	babble(n, c1);
	for(int j=0;j<n-1;j++) cout << c1[j].suit<<c1[j].value<<" ";
	cout << c1[n-1].suit<<c1[n-1].value<<endl;

	stable(c2,c1,n);
	for(int i=0;i<n;i++) c1[i]=c2[i];
	selectsort(n,c2);
	for(int j=0;j<n-1;j++) cout << c2[j].suit<<c2[j].value<<" ";
	cout << c2[n-1].suit<<c2[n-1].value<<endl;
	stable(c1,c2,n);


	return 0;
}



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

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	vector<int>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr.begin(),arr.end());
	int ans=0;
	for(int i=0;i<k;i++){
		ans+=arr[i];
	}
	cout<<ans;
	return 0;
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    string c;
    int d;
    c = to_string(min(a,b));
    d = max(a,b);
    string ans = "";
    rep(i,d) ans += c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

bool insertable(string S, string T, int n) {
    for (int i = 0; i < T.size(); i++) {
        if (T[i] != S[n + i] && S[n + i] != '?')return false;
    }
    return true;
}

int main() {
    string S, T;
    cin >> S >> T;
    string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

    bool ok = false;
    if (S.size() >= T.size()){
        for (int i = 0; i <= S.size() - T.size(); i++) {
            if (insertable(S, T, i)) {
                ok = true;
                string c = "";
                for (int j = 0; j < i; j++)c += ((S[j] == '?') ? 'a' : S[j]);
                c += T;
                for (int j = c.size(); j < S.size(); j++)c += ((S[j] == '?') ? 'a' : S[j]);
                ans = min(ans, c);
            }
        }
    }

    cout << ((ok) ? ans : "UNRESTORABLE") << endl;

    return 0;
}

Measured memory_bytes: 256
import os,io
import heapq
INF=10**9
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline  
n,m=map(int,input().split())
edges=[]
d=[]
for i in range(n+1):
  d.append([])
  for j in range(n+1):
    d[-1].append(INF)
  d[i][i]==0
for i in range(m):
  a,b,c=list(map(int,input().split()))
  edges.append([a,b,c])
  d[a][b]=c
  d[b][a]=c
for k in range(1,n+1):
  for i in range(1,n+1):
    for j in range(1,n+1):
      if (d[i][j]>d[i][k]+d[k][j]):
        d[i][j]=d[i][k]+d[k][j]
ans=0
for i in range(m):
  a=edges[i][0]
  b=edges[i][1]
  c=edges[i][2]
  if d[a][b]<c:
    ans+=1
print(ans)

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

int main() {
	char k;
    cin>>k;
    if(k=='A')
    cout<<'T'; 
    if(k=='T')
    cout<<'A';
    if(k=='G')
    cout<<'C';
    if(k=='C')
    cout<<'G';
	return 0;
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};
int a[maxn];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    if(n==1)
    {
        cout<<0;
        return 0;
    }
    if(n&1)
    {
        int d=a[n/2+1];
        if(a[n/2]==d)
        {
            cout<<0;
            return 0;
        }
        else
        {
            cout<<d-a[n/2];
            return 0;
        }
    }
    else
    {
        int d=a[n/2+1];
        if(a[n/2]==d)
        {
            cout<<0;
            return 0;
        }
        else
        {
            cout<<d-a[n/2];
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll N, T, c, t;

int main(){
	cin >> N >> T;
	
	ll ans = 1001;
	for(ll i = 1; i <= N; i++){
		cin >> c >> t;
		if(t <= T){ans = min(c, ans);}
	}
	
	if(ans <= 1000){cout << ans << endl;}
	else{cout << "TLE" << endl;}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int n, x;
	cin >> n >> x;
	int p[100005], dif[100005];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	p[n] = x;
	sort(p, p + n + 1);
	int mini = 1000000000, num;
	for (int i = 0; i < n; i++) {
		dif[i] = p[i + 1] - p[i];
		mini = min(mini, dif[i]);
		if (mini == dif[i])num = i;
	}
	while (1) {
		for (int i = 0; i < n; i++) {
			if (i == num)continue;
			dif[i] %= mini;
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (dif[i] == 0) {
				count++;
				continue;
			}
			mini = min(mini, dif[i]);
			if (mini == dif[i])num = i;
		}
		if (count == n - 1)break;
	}
	cout << mini << endl;
	return 0;
}


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

const int N = 1010;
int n, m, a, b;
vector<int> g[N], ans(N + 1);

vector<int> minCircle(int s) {
    int d[N] = {0}, f[N] = {0};
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
        int p = q.front();q.pop();
        for(int c : g[p]) {
            if(!d[c]) {
                f[c] = p;
                d[c] = 1;
                q.push(c);
            }
        }
        if(d[s]) break;
    }
    int p = f[s];
    vector<int> ret;
    ret.push_back(s);
    while(p && p != s) {
        ret.push_back(p);
        p = f[p];
    }
    return ret;
}

int main() {
    cin >> n >> m;
    while(m--) {
        cin >> a >> b;
        g[a].push_back(b);
    }
    for(int i = 1; i <= n; i++) {
        vector<int> t = minCircle(i);
        if(t.size() > 1 && t.size() < ans.size()) ans = t;
    }
    if(ans.size() == N + 1) cout << -1;
    else {
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int, input().split()))

"""
ans = 1
flag = 0
for i in li:
  if i == 0:
    flag = 1
    break
  ans *= i

if flag == 1:
  print(0)
elif ans > 10**18:
  print(-1)
else:
  print(ans)
"""
ans = 1
flag = 0
li.sort()
if li[0] == 0:
  print(0)
else:
  for i in li[::-1]:
    ans *= i
    if ans > 10**18:
      flag = 1
      break

  if flag == 0:
    print(ans)
  elif flag == 1:
    print(-1)

Measured memory_bytes: 21696
#include<iostream>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
int dd[4] = {1,-1,4,-4};

int num;
map<string, int> d;
string str = "01234567";

queue<string> que;
void bfs()
{	
	int pos;
	while(que.size())
	{
		string s = que.front();que.pop();
		for(int i=0;i<8;i++)
			if(s[i] == '0')
				{pos = i;break;}
		for(int i = 0;i <4;i++)
		{
			
			string s2 =s;
			swap(s2[pos],s2[pos+dd[i]]);
			map<string, int>::iterator it = d.find(s2);
			if(pos+dd[i]<8 && pos+dd[i]>=0 && !(pos==3 && dd[i] == 1) && !(pos == 4 && dd[i] == -1) && it == d.end())
			{
				que.push(s2);
				d[s2] = d[s]+1; 
			}
		}
	}	
}
void solve()
{
	
     str.erase(remove(str.begin(), str.end(), ' '), str.end());
	 //cout << str<<endl;
	 //if(str=="01234567")
	 cout<<d[str]<<endl;
}
int main()
{
	
	que.push(str);
	d[str] = 0;
	bfs();
	while(getline(cin,str))
		solve();		
}

Measured memory_bytes: 5372
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<int>g[100005];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        if(a > m)continue;
        g[m-a].push_back(b);
    }
    priority_queue<int>pq;
    ll ans = 0;
    for(int i = m - 1; i >= 0; i--){
        for(auto x : g[i])pq.push(x);
        if(pq.size()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

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

int main() {
  //int a;
  //int a,b;
  int a,b,c;
  	//cin>>a;
  	//cin>>a>>b;
  	cin>>a>>b>>c;
  //string s;
  	//cin>>s;
  cout<<c/a*b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{
    int a,b;
    cin>>a>>b;
    string x="",y="";
    vector<string> v;
        int w=a;
        while(w--)
            x+=to_string(b);
    
         w=b;
        while(w--)
            y+=to_string(a);
        v.push_back(x);
        v.push_back(y);
        sort(v.begin(),v.end());
        cout<<v[0]<<endl;
    
    
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

vector<vector<int>> g(55);

void solve(int u,int a,int b,vector<bool>& memo){
  memo[u]=1;
  rep(i,g[u].size()){
    int v=g[u][i];
    if((u==a&&v==b)||(u==b&&v==a)) continue;
    if(!(memo[v])) solve(v,a,b,memo);
  }
}

int main(){
  int n,m; cin>>n>>m;
  vector<P> p(m);
  rep(i,m){
    int a,b; cin>>a>>b;
    a--; b--;
    p[i]=mp(a,b);
    g[a].pb(b); g[b].pb(a);
  }
  int s=p[0].fs;
  int sum=0;
  rep(i,m){
    vector<bool> memo(n,0);
    solve(s,p[i].fs,p[i].sc,memo);
    bool f=1;
    rep(i,n){
      if(!memo[i]) f=0;
    }
    if(!f) sum++;
  }
  cout<<sum<<endl;

  return 0;
}


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

int main()
{
	long long n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	if (a > b) swap(a, b);
	if ((a & 1) == (b & 1)) printf("%lld\n", (b - a + 1) / 2);
	else printf("%lld\n", min(a + (b - a) / 2, n - b + 1 + (b - a) / 2));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main() {
	ll money = 100000;
	cin >> n;
	REP(i,n){
		money *= 1.05;
		if (money % 1000 != 0) {
			money -= money % 1000;
			money += 1000;
		}
	}
	cout << money << endl;
}

Measured memory_bytes: 3076
#!/usr/bin/env ruby
k, s = STDIN.readline.strip.split(' ').map(&:to_i)
# puts "k:#{k}, s:#{s}"
sum = 0
(0..k).each do |a|
  rest_a = s - a
  # puts "s:#{s}, a:#{a}, rest_a:#{rest_a}"
  (0..k).each do |b|
    rest_b = rest_a - b
    # puts "a: #{a}, b: #{b}, rest:#{rest_b}, k:#{k}"
    next if rest_b < 0 or rest_b > k
    # puts "#{rest}"
    c = rest_b
    sum += 1
    # puts "abc: #{a}, #{b}, #{c}"
  end
end
puts sum


Measured memory_bytes: 1788
#include<iostream>
#include<string>

using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> c >> b;
  if ((a >= b && b >= c) || (a <= b && b <= c)) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int a, b, c; cin >> a >> b >> c;

  cout << (a + b == c || b + c == a || c + a == b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
As = list(map(int, input().split()))

next = 1
bricks = As

for i in range(n):
    if As[i] != next:
        bricks[i] = 0
    else:
        next += 1

ans = Counter(bricks)[0]

if n == ans:
    print(-1)
else:
    print(ans)



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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}



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

int main(){
    long N;
    cin >> N;
    vector<long> A(N, 0);
    for(long i=0; i <N; i++){
        cin >> A.at(i);
    }
    vector<long> num(N + 1, 0);
    for (long i = 0; i < N; i++)
    {
        num[A[i]] += 1;   
    }
    long sum = 0;
    for(long i = 1; i <= N; i++){
        if(num[i] > 0) sum += num[i] * (num[i] - 1) / 2;
    } 
    for(long i = 0; i < N; i++){
        long ans = sum - num[A[i]] + 1;
        cout << ans <<endl;
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	if(a <= x && x <= a+b){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int s, w;
cin >> s >> w;
cout << (w >= s ? "unsafe" : "safe");
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 累積和が等しくなる2点を選ぶ組み合わせを考えれば良い。

int main(){
    Init();
    ll n; cin >> n;
    vi a(n), sum(n+1, 0);
    ll ans = 0;
    rep(i, n){
        cin >> a[i];
        sum[i+1] += a[i] + sum[i];
    }
    map<ll, ll> cnt;
    rep(i, n+1) cnt[sum[i]]++;
    for(auto &num: cnt) if(num.second >= 2) ans +=(num.second*(num.second-1)/2);
    cout << ans << endl;
}

Measured memory_bytes: 18692
'use strict'
 
function Main(input) {
  let nums = input.split('\n')[1].split(' ').map(n => parseInt(n, 10));

  let count = 0;
  while(nums.every(num => num % 2 === 0)) {
    count ++;
    nums = nums.map(n => n / 2);
  }

  console.log(count);
}
 
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> ps[5];
    vector<bool> b(55556, true);
    for (int p = 2; p < b.size(); p++) {
        if (b[p]) {
            ps[p%5].push_back(p);
            if (ps[p%5].size() == n) {
                for (int a : ps[p%5]) cout << a << ' ';
                cout << endl;
                return 0;
            }
            for (int q = 2*p; q < b.size(); q+=p) b[q] = false;
        }
    }
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string date;
    cin >> date;
    int month = stoi(date.substr(5, 2));
    cout << (month > 4 ? "TBD" : "Heisei") << endl;
    return 0;
}


Measured memory_bytes: 256