akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
typedef long long i64;
#define Templ(T) template <typename T>
inline int read() {
    reg int ans = 0, f = 1;
    reg char c = getchar();
    while (!isdigit(c)) f ^= (c == '-'), c = getchar();
    for (; isdigit(c); c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48);
    return f ? ans : -ans;
}
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
} // namespace my_std
using namespace my_std;

#define N 100010
#define pb push_back
int n, m, a[N], b[N], c[N];
int oud[N], f[N], s[N], r[N];
//out degree, father, size, ring
vector<int> q[4];
i64 ans;
inline int find(int x){ return x == f[x] ? x : (f[x] = find(f[x])); }
//0类：自环自成连通块
//1类：环自成连通块
//2/3类：其他连通块（中的自环/其他边）

int main() {
    n = read(), m = read();
    FOR(i, 1, n) f[i] = i, r[i] = 1;
    FOR(i, 1, m){
        a[i] = read(), b[i] =read(), c[i] = read();
        ++oud[a[i]], ans += a[i] != b[i];
        f[find(a[i])] = find(b[i]);
    }
    FOR(i, 1, n){
        ++s[find(i)];
        if(oud[i] != 1) r[find(i)] = 0;
    }

    reg i64 cnt(0);
    FOR(i, 1, n){
        cnt += find(i) == i && s[i] > 1 && r[i];
    }
    if(!cnt) return printf("%lld\n", ans), 0;
    ans += cnt;
    //无环
    FOR(i, 1, m){
        if(c[i] == 1) continue;
        Rint u = (find(a[i]));
        if(r[u]){
            if(s[u] == 1) q[0].pb(c[i] - 2);
            else if(s[u] > 1) q[1].pb(c[i] - 1);
        }
        else{
            q[a[i] == b[i] ? 2 : 3].pb(c[i] - 1);
        }
    }
    reg i64 sum(0);
    FOR(o, 0, 3) for(Rint i: q[o]) sum += i;
    if(sum < cnt) return puts("-1"), 0;
    //可用次数不够
    if(q[2].empty() && q[3].empty()) return puts("-1"), 0;
    //没有能开始贡献的
    FOR(o, 0, 3) sort(q[o].begin(), q[o].end());
    if(q[3].size()) cnt -= q[3].back(), q[3].pop_back();
    else ++ans, cnt -= q[2].back(), q[2].pop_back();
    //开始贡献
    for(Rint i: q[1]) cnt -= i;
    for(Rint i: q[3]) cnt -= i;
    if(cnt <= 0) return printf("%lld\n", ans), 0;
    //无需额外次数
    reg i64 res(1145141919810364364ll);
    sum = 0;
    Rint p(0);
    for(Rint i: q[2]) sum += i;
    ROF(i, q[0].size(), 0){
        if(i < (int)q[0].size()) sum += q[0][i];
        while(p < (int)q[2].size() && sum - q[2][p] >= cnt)
            sum -= q[2][p++];
        if(sum >= cnt){
            chkmin(res, 2ll * ((int)q[0].size() - i) +
                ((int)q[2].size() - p));
        }
    }
    //2 Pointers求剩余两种各取几个
    printf("%lld\n", ans + res);
    return 0;
}

Measured memory_bytes: 6972
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
#define endl "\n"
using namespace std;
void solve(){
	int n;cin>>n;
    int ar[n];
    ll sum = 0;
    unmap mp;
    for(int i=0;i<n;i++){
        cin>>ar[i];
        sum += ar[i];
        mp[ar[i]]++;
    } 
    int q;cin>>q;
    while(q--){
        int a,b;cin>>a>>b;
        if(!mp[a]){
            cout<<sum<<endl;
            continue;
        }
        int x = mp[a];
        sum -= 1ll*x*a;
        sum += 1ll*x*b;
        mp[a] = 0;
        mp[b] += x;
        cout<<sum<<endl;
    }
}

int main(){
	fastio;
	solve();
	return 0;
}

Measured memory_bytes: 7516
while True:
  n,m=map(int,input().split())
  if n==0 and m==0:
    break
  P=[]
  for i in range(1,n+1):
    P.append(i)
  a=m-1
  for i in range(n-1):
    #print(P.pop(a))
    P.pop(a)
    a+=m
    while True:
      if a<=int(len(P)):
        break
      a=a-int(len(P))
      
    a=a-1
  print(P[0])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define endl "\n"
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define pi pair<int,int>
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	long double arr[n];
	f(i,n)cin>>arr[i];
	long double dp[n+10][n+1];
	for(int i=0;i<=(n+2);i++)
	{
		if(i>(n/2))
			dp[i][n]=1;
		else
			dp[i][n]=0;
	}
	for(int x=n;x>=0;x--)
	{
		for(int i=n-1;i>=0;i--)
			dp[x][i]=arr[i]*dp[x+1][i+1]+(1-arr[i])*dp[x][i+1];
	}
	cout<<fixed << setprecision(12)<< dp[0][0]<<endl;
	return 0;
}

Measured memory_bytes: 141184
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 0;
		char[] alp = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
				't', 'u', 'v', 'w', 'x', 'y', 'z' };
		for (int i = 1; i < n; i++) {
			String x = s.substring(0, i);
			String y = s.substring(i, n);
			int cout = 0;
			for (int j = 0; j < 26; j++) {
				if (y.contains(String.valueOf(alp[j])) && x.contains(String.valueOf(alp[j])))
					cout++;
			}
			ans = Math.max(ans, cout);
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;
#define MAX 100005
typedef long long ll;
int mapp[30];
int main()
{
    char s[30];
    scanf("%s",s);
    memset(mapp,0,sizeof(mapp));
    int flag=1;
    for(int i=0;i<strlen(s);i++)
    {
        if(mapp[s[i]-'a']==0)
            mapp[s[i]-'a']++;
        else
            flag=0;
    }
    if(flag)
        printf("yes\n");
    else
        printf("no\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
       string s;
       cin>>s;
       ll sum=0;
       for(char c:s){
           sum+=(c-'0');
       }
       if(sum%9==0){
           cout<<"Yes";
       }else{
           cout<<"No";
       }

      return 0;
   }



Measured memory_bytes: 3740
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  double x1, y1, x2, y2;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

  printf("%lf\n", sqrt(pow(x2-x1, 2)+pow(y2-y1, 2)));
  return 0;
}


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

int N, M, C;

int main() {
  cin >> N >> M >> C;
  int B[M];
  for (int i = 0; i < M; ++i) cin >> B[i];
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int sum = 0;
    for (int j = 0; j < M; ++j) {
      int A; cin >> A;
      sum += A * B[j];
    }
    sum += C;
    if (sum > 0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,c;
    cin>>n>>c;
    vvll d(c,vll(c));
    vvll v(n,vll(n));
    vector<map<ll,ll>> A(3);
    rep(i,c)rep(j,c){
        cin>>d[i][j];
    }
    rep(i,n)rep(j,n){
        cin>>v[i][j];
        v[i][j]--;
        A[(i+j)%3][v[i][j]]++;
    }
    ll ans=LLINF;
    rep(i,c){
        rep(j,c){
            if(i==j)continue;
            rep(k,c){
                if(i==k||j==k)continue;
                ll sum=0;
                irep(m,A[0]){
                    sum+=d[ m->first ][i]*m->second;
                }
                irep(m,A[1]){
                    sum+=d[ m->first ][j]*m->second;
                }
                irep(m,A[2]){
                    sum+=d[ m->first ][k]*m->second;
                }
                chmin(ans,sum);
            }
        }
    }
    fin(ans);

}



Measured memory_bytes: 2176
h, w, k = map(int,input().split())
c = [list(input()) for i in range(h)]
ans = 0
for p_h in range(2**h):
    for p_w in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if(p_h>>i)&1==0 and (p_w>>j)&1==0:
                    if c[i][j]=='#':
                        black += 1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

int main() {
    int N;

    cin >> N;

    cout << ceil((float)N/2);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv vector<vector<int> >
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


ll kaijou(ll x){
  ll sum=1;
  for(int i=1;i<=x;++i){
    sum*=i;
  }

return sum;
}
int main(){
ll n;cin>>n;
vll a(5);
rep(i,n){
  string s;cin>>s;
  char sin=s[0];
  if(sin=='M')a.at(0)++;
  else if(sin=='A')a.at(1)++;
  else if(sin=='R')a.at(2)++;
  else if(sin=='C')a.at(3)++;
  else if (sin=='H')a.at(4)++;
}
ll x=0;
ll y=0;
rep(i,5){
  if(a.at(i)!=0)x++;
  if(a.at(i)>1)y++;
}

if(x<3){
  cout<<0<<endl;
  return 0;
}
ll ans=0;
rep(i,3){
  for(int j=i+1;j<4;j++){
    for(int k=j+1;k<5;k++){
        if(a.at(i)==0||a.at(j)==0||a.at(k)==0)continue;
        ans+=a.at(i)*a.at(j)*a.at(k);

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

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n,m;

long long gc[110][110];
long long gt[110][110];

void warshallfloyd()
{
	for (int k = 0; k < m; k++)
	{
		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < m; j++)
			{
				gc[i][j] = min(gc[i][j], gc[i][k] + gc[k][j]);
				gt[i][j] = min(gt[i][j], gt[i][k] + gt[k][j]);
			}
		}
	}
}

int main(void)
{
	while (cin >> n >> m, n || m)
	{

		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < m; j++)
			{
				gc[i][j] = 9999999;
				gt[i][j] = 9999999;
			}
		}

		for (int i = 0; i < n; i++)
		{
			int a, b, c, t;

			cin >> a >> b >> c >> t;

			a--; b--;

			gc[a][b] = gc[b][a] = c;
			gt[a][b] = gt[b][a] = t;
		}

		warshallfloyd();

		int k;

		cin >> k;

		for (int i = 0; i < k;i++)
		{
			int p, q, r;

			cin >> p >> q >> r;

			p--; q--;

			if (r == 0)
			{
				cout << gc[p][q] << endl;
			}
			else
			{
				cout << gt[p][q] << endl;
			}
		}
	}

	

	return 0;
}


Measured memory_bytes: 3168
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		ll n;
		cin>>n;
		ll x=n%10;
		if(x==0 || x==1 || x==6||x==8)
			cout<<"pon";
		else if(x==3)
			cout<<"bon";
		else
			cout<<"hon";
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/


Measured memory_bytes: 3608
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

int a[5010];
bitset<5010> dp;
bitset<5010> tmp;

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int n, k;
	scanf("%d%d", &n, &k);
	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	int l = -1;
	int r = -1;
	FOR(i, 0, n) {
		if (a[i] < k) {
			if (l == -1) {
				l = i;
			}
			r = i;
		}
	}
	if (l == -1) {
		cout << 0 << endl;
		return 0;
	}
	int res = 0;
	while (l <= r) {
		int i = (l + r) / 2;
		dp.reset();
		dp[0] = 1;
		bool ok = false;
		FOR(j, 0, n) {
			if (j == i) {
				continue;
			}
			if (a[j] > k) {
				continue;
			}
			dp |= (dp << a[j]);
		}
		for (int j = k - a[i]; j < k; ++j) {
			if (dp[j]) {
				ok = true;
				break;
			}
		}
		if (!ok) {
			res = i + 1;
			l = i + 1;
		}
		else {
			r = i - 1;
		}
	}
	cout << res << endl;

#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7
import sys
from collections import Counter
from math import gcd
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
ans = 0
c = Counter()
zero = 0
for _ in range(n):
	a, b = map(int, input().split())
	if a == b == 0:
		zero += 1
		continue
	if a < 0:
		a, b = -a, -b
	if a == 0:
		a, b = 0, 1
	if b == 0:
		a, b = 1, 0
	g = gcd(a, b)
	c[(a//g, b//g)] += 1

ans = 1
for k, v in c.items():
	#print(k, v)
	if k[1] <= 0:
		x, y = -k[1], k[0]
		if c[(x, y)] > 0:
			continue
	else:
		x, y = k[1], -k[0]
	res = 0
	res += pow(2, v, MOD) - 1
	res += pow(2, c[(x, y)], MOD) - 1
	res += 1
	ans *= res
	ans %= MOD

ans += zero
ans -= 1
ans %= MOD
print(ans)

Measured memory_bytes: 46708
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<int,ll>;
vector<P> v[100001];
ll N,a,b,c,Q,K,x,y,d[100001];
int main(){
    cin>>N;
    for(int i{};i<N-1;++i){
        cin>>a>>b>>c;
        v[a].emplace_back(b,c);
        v[b].emplace_back(a,c);
    }
    cin>>Q>>K;
    fill_n(d,100001,numeric_limits<ll>::max()/3);
    d[K]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.emplace(K,0);
    while(q.size()){
        a=q.top().first,c=q.top().second;
        q.pop();
        if(d[a]<c)continue;
        for(auto& x:v[a]){
            b=x.first,c=x.second;
            if(d[b]>d[a]+c){
                d[b]=d[a]+c;
                q.emplace(b,d[b]);
            }
        }
    }
    for(int i{};i<Q;++i){
        cin>>x>>y;
        cout<<d[x]+d[y]<<endl;
    }
}


Measured memory_bytes: 11264
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int hourS = int.Parse(Console.ReadLine());

        int h = hourS / 3600;
        int m = hourS % 3600 / 60;
        int s = hourS % 60;

        Console.WriteLine(h + ":" + m + ":" + s);
    }
}

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

int c_2(int x){
  if(x<2){
    return 0;
  }else{
    return x*(x-1)/2;
  }
}
  
int main(){
  int n, m;
  cin >> n >> m;
  cout << c_2(n)+c_2(m) << endl;
}
  

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    sx, sy, tx, ty = MI()

    ans = ''
    # path1
    ans += 'U' * abs(ty - sy) + 'R' * abs(tx - sx)

    # path2
    ans += 'D' * abs(ty - sy) + 'L' * abs(tx - sx)

    # path3
    ans += 'L' + 'U' * (abs(ty - sy) + 1) + 'R' * (abs(tx - sx) + 1) + 'D'

    # path4
    ans += 'R' + 'D' * (abs(ty - sy) + 1) + 'L' * (abs(tx - sx) + 1) + 'U'

    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9232
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<fixed<<setprecision(20);
	double A,B,P,Q,R;cin>>A>>B>>P>>Q>>R;
	cout<<B+(B*P-(B-A)*Q)/(Q+R)<<endl;
	return 0;
}
//1000
//100
//10
//1


Measured memory_bytes: 3288
from itertools import permutations
from scipy.sparse import csgraph, csr_matrix
N, M, R = map(int, input().split())
r = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
a, b, c = zip(*edges)
graph = csgraph.dijkstra(csr_matrix((c, (a, b)), shape=(N + 1, N + 1)),
                         directed=False)
ans = 10 ** 18
for p in permutations(r):
    ans = min(ans, sum(int(graph[i][j]) for i, j in zip(p, p[1:])))
print(ans)

Measured memory_bytes: 32820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n;cin>>n;
    fore(i,1,n){
        bool flg=i%3==0;
        ll t=i;
        while(t>0)flg|=t%10==3,t/=10;
        if(flg)cout<<" "<<i;
    }
    cout<<endl;
}

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



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

int main()
{
    string str[9];
    int am[9];
    int pm[9];

    for (int i = 0; i < 9; i++){
        cin >> str[i];
        cin >> am[i];
        cin >> pm[i];
    }

    for (int i = 0; i < 9; i++){
        cout << str[i] << " " << am[i] + pm[i] << " " << (pm[i] * 300) + (am[i] * 200) << endl;
    }
    return (0);
}



Measured memory_bytes: 3012
using System;

namespace Range
{
    class Range
    {
        static void Main()
        {
            string input = Console.ReadLine();
            string[] sample = input.Split(' ');
            int[] a = new int[sample.Length];
            for(int i = 0; i < sample.Length; i++)
            {
                a[i] = int.Parse(sample[i]);
            }
            if (a[0] < a[1] && a[1] < a[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 15944
s=input()
t=input()
n,m=len(s),len(t)
dp=[[0]*(m+1) for i in range(n+1)]
dp[0][0]=1

for i in range(n+1):
    for j in range(m+1):
        dp[i][j]=max(dp[i][j-1],dp[i-1][j])
        if i*j!=0 and s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j])

ans=""
i,j=n,m
while 0<i and 0<j:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans+=s[i-1]
        i-=1
        j-=1

print(ans[::-1])





Measured memory_bytes: 113500
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a < b+c) {
        System.out.println(c-a+b);
        } else {
        	System.out.println(0);
        }
        
        
        sc.close();
    }
}


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

typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll pt = 0 , px =0 , py =0;
    bool ans = true;
    cout<<boolalpha;
    for(int i=0;i<n;i++)
    {
        ll ct , cx , cy;
        cin>>ct>>cx>>cy;
        if( (ct-pt) < (abs(cx-px)+abs(py-cy))  )
        {
            ans = false;
        } else
        {
            if( (ct-pt)%2 != (abs(cx-px)+abs(py-cy))%2 )
                ans = false;
        }
                px = cx;
        py = cy;
        pt = ct;
    }
    if( ans)
        cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3608
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let n:usize = read();
    let mut a:Vec<i32> = (0..n).map(|_| read()).collect();

    println!("{}", a.iter_mut().map(|x| {
            let mut cnt:i32 = 0;
            while *x%2==0 {
                cnt += 1;
                *x /= 2;
            }
            cnt
        }
    ).sum::<i32>());

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> A(3);
  REP(i, 3) cin >> A[i];
  int ans = 1000000;
  do {
    int sum = 0;
    sum = abs(A[1] - A[0]) + abs(A[2] - A[1]);
    ans = min(ans, sum);
  } while(next_permutation(A.begin(), A.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n,i,x;
    
    i = 1;
    
    cin >> n;

    do{
        x = i;
    
        if ( x % 3 == 0 ){
            cout << " " << i;
        }else{
            do{
                if ( x % 10 == 3 ){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }while(x);
        }
    
    }while(++i <= n);
    
    cout << endl;

}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(ll i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

ll f(ll b, ll n) {
  if(n < b) return n;
  else return f(b, n/b) + n%b;
}

int main () {
  ll n, s; cin >> n >> s;

  if(n == s) {
    cout << n+1 << endl;
  } else {
    FOR(b, 2, (ll)(sqrt(n) + eps) + 1) {
      if(f(b, n) == s) {
        cout << b << endl;
        return 0;
      }
    }

    RFOR(p, (ll)(sqrt(n) + eps) + 1, 1) {
      ll b = (n-s)/p + 1;
      if(b >= 2 && f(b, n) == s) {
        cout << (n-s)/p+1 << endl;
        return 0;
      }
    }

    cout << -1 << endl;
    
  }
  
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A & 1:
            A -= 1
        B += A // 2
        A //= 2
    else:
        if B & 1:
            B -= 1
        A += B // 2
        B //= 2
    # print(i, A, B)
print(A, B)


Measured memory_bytes: 9104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>
using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    ll ans;
    int A[K];
    REP(i,K) cin >> A[i];
    sort(A,A+K);
    ans = abs(A[0]-A[K-1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n) {
		par = vector<int>(n, -1);
	}
	int root(int x) {
		if (par[x] < 0) return x;
		else return root(par[x]);
	}
	int size(int x) {
		return -par[root(x)];
	}
	bool unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return false;
		if (size(rx) < size(ry)) swap(rx, ry);
		par[rx] += par[ry];
		par[ry] = rx;
		return true;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int count() {
		int res = 0;
		rep(i, par.size()) {
			if (par[i] < 0) res++;
		}
		return res;
	}
};
int main() { // 問題文はしっかり読め!!!
	int n, m;
	cin >> n >> m;
	UnionFind G(n);
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--, c %= 2;
		G.unite(a, b);
	}
	cout << G.count() << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define P pair<int, int>
#define mk_p make_pair
const int N = 1e5 + 11;
set<int> s[N];
map<P, int> mp;
int n, fa[N];
P dl[N];
int read(){
    int x = 0, fl = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0')fl = (ch == '-' ? -1 : fl), ch = getchar();
    while(ch >= '0' && ch <= '9')x = 10 * x + ch - 48, ch = getchar();
    return x * fl;
}
int find(int x){
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}
int main(){

    n = read();
    int u, v;
    int hd = 0, tl = 0;
    for(int i = 1;i <= 2 * n - 2; i++){
        u = read(); v = read();
        s[u].insert(v); s[v].insert(u);
        mp[mk_p(u, v)]++; mp[mk_p(v, u)]++;
        if(mp[mk_p(u, v)] == 2)dl[++tl] = mk_p(u, v);
    }
    for(int i = 1;i <= n; i++)fa[i] = i;
    while(hd < tl){
        P now = dl[++hd];
        int u = now.first, v = now.second;
        u = find(u); v = find(v);
        if(u == v)continue;
        if(s[u].size() < s[v].size())swap(u, v);
        fa[v] = u;
        set<int>::iterator it;
        s[u].erase(v); s[v].erase(u);
        for(it = s[v].begin();it != s[v].end(); it++){
            int to = *it;
            mp[mk_p(v, to)] = mp[mk_p(to, v)] = 0;
            s[to].erase(v); s[to].insert(u); s[u].insert(to);
            mp[mk_p(to, u)]++; mp[mk_p(u, to)]++;
            if(mp[mk_p(to, u)] == 2)dl[++tl] = mk_p(to, u);
        }
    }
    int fl = 0;
    for(int i = 1;i <= n; i++)fl += fa[i] == i;
    puts(fl == 1 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 62592
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s,t;cin>>s>>t;
  rep(i,0,s.size())if(s[i]!=t[i])res++;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3744
from math import gcd

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

L = [0] * n
L[0] = A[0]
for i, a in enumerate(A):
  L[i] = gcd(L[max(0, i - 1)], a)
  
R = [0] * n 
R[0] = A[-1]
for i, a in enumerate(A[::-1]):
  R[i] = gcd(R[max(0, i - 1)], a)

ans = 0
for i in range(n):
  if i == 0:
    ans = max(ans, R[n - 2])
  elif i == n - 1:
    ans = max(ans, L[n - 2])
  else:
    ans = max(ans, gcd(L[i - 1], R[n - i - 2]))
    
print(ans)

Measured memory_bytes: 21808
n=int(input())
b=list(map(int,input().split()))
a=[0]+b+[0]
s=0
for i in range(1,n+2):
    s+=abs(a[i]-a[i-1])
for i in range(n):
    print(s+abs(a[i+2]-a[i])-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1]))




Measured memory_bytes: 14048
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int[] H = new int[N];

		for(int i=0;i<N;i++) {
			H[i]=sc.nextInt();
		}

		int now = 0;
		int max = 0;

		for(int i=1;i<N;i++) {
			if(H[i-1]>=H[i]) {
				now++;
			}else {
				max=Math.max(max, now);
				now=0;
			}
		}
		max = Math.max(max, now);

		out.println(max);
	}
}


Measured memory_bytes: 52588
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
//文字列Sの中から文字列Tと一致する位置を返す
vector<int> RollingHash(const string &s, const string &t)
{
    using ull = unsigned long long;
    int s_len = s.size(), t_len = t.size();
    if(s_len < t_len) return vector<int>();
    ull ss = 1;
    for(int i = 0; i < t_len; i++) ss *= MOD;
    ull s_hash = 0, t_hash = 0;
    for(int i = 0; i < t_len; i++) s_hash = s_hash * MOD + s[i];
    for(int i = 0; i < t_len; i++) t_hash = t_hash * MOD + t[i];
    vector<int> res;
    for(int i = 0; i + t_len <= s_len; i++)
    {
        if(s_hash == t_hash) res.push_back(i);
        if(i + t_len < s_len) s_hash = s_hash * MOD + s[i + t_len] - s[i] * ss;
    }
    return res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    vector<int> ans = RollingHash(s, t);
    for(int &x : ans) cout << x << endl;
    return 0;
}




Measured memory_bytes: 8864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 1000 * 1000 + 10;

int d[MAXN] = {};

int solve(int n)
{
    if(n == 1) return 0;
    if(d[n] != 0) return d[n];

    if(n % 2)
        d[n]= 1 + solve( n * 3 + 1);
    
    else d[n] = 1 + solve(n / 2);

    return d[n];
}

int main()
{
    int n;
    while(cin >> n && n) 
    {
        cout << solve(n) << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int x,y;cin>>x>>y;
    if(y%2!=0){
        cout <<"No"<<endl;
        return 0;
    }
    int mini=x*2;
    int maxi=x*4;
    if(y<=maxi && y>=mini){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }

}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

int n, m;
vector<int> graph[500000];
vector<pair<int, int> > cd;

int marked[500000];
int deg[500000];

void dfs(int v, int p)
{
    marked[v] = 1;
    for (auto u : graph[v])
    {
        if (u == p) continue;
        if (marked[u] == 2) continue;
        if (marked[u])
        {
            cd.push_back({v, u});
            deg[v]++;
        }
        else
        {
            dfs(u, v);
            if (deg[u] % 2 == 1)
            {
                cd.push_back({u, v});
                deg[u]++;
            }
            else
            {
                cd.push_back({v, u});
                deg[v]++;
            }
        }
    }
    marked[v] = 2;
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int v, u;
        cin >> v >> u;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    if (m % 2 != 0)
    {
        cout << -1;
        return 0;
    }
    dfs(1, -1);
    for (auto e : cd)
    {
        cout << e.first << " " << e.second << "\n";
    }
}


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

int main() {
    ll N,K;
    cin >> N >>K;
    ll R,S,P;
    cin >> R >>S>>P;
    string T;
    cin >> T;
    ll ans =0;
    for(ll i=0;i<N;i++){
        ll next = i+K;
        if(next<N && T[i] == T[next]){
            T[next] ='w';
        }
        if(T[i] =='r'){
            ans += P;
        }
        if(T[i] =='s'){
            ans += R;
        }
        if(T[i] =='p'){
            ans += S;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
using namespace std;
int n, i, ii, nr, ok, sol;
char s[105], c[105];
int main(){
    cin>> s + 1;
    n = strlen(s + 1);
    sol = n;
    for(ii = 'a'; ii <= 'z'; ii++){
        ok = 1;
        for(i = 1; i <= n; i++){
            c[i] = s[i];
            if(c[i] != ii){
                ok = 0;
            }
        }
        nr = 0;
        while(ok == 0){
            nr++;
            ok = 1;
            for(i = 1; i <= n - nr; i++){
                if(c[i] == ii || c[i + 1] == ii){
                    c[i] = ii;
                }
                else{
                    ok = 0;
                }
            }
        }
        sol = min(sol, nr);
    }
    cout<< sol;
}


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

int main()
{
    long  n, k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){cin >> a[i];}
    long long ans = 0;
    long num1 = 0;
    long num2 = 0;
    for(int j=0;j<n-1;j++){
        for(int m=j+1;m<n;m++){
            if(a[j]>a[m]){
                ans += (k*(k+1)/2)%1000000007;
                if(ans>=1000000007) ans -= 1000000007;

            }
            else if(a[j]<a[m]){
                ans += (k*(k-1)/2)%1000000007;
                if(ans>=1000000007) ans -= 1000000007;
            }
        }
    }

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




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


int main(){
  int N;
  cin >> N;
  vector<int> a(N),b(N);
  rep(i,N) cin >> a[i];
  rep(i,N) b[i] = a[i];
  sort(a.begin(),a.end());
  vector<int> res;
  rep(i,N) {
    if( b[i] < a[N/2] ) res.push_back(a[N/2]);
    else res.push_back(a[N/2-1]);
  }
  for(auto e : res) cout << e << endl;
  return 0;
}

Measured memory_bytes: 4724
'use strict'

function main(s) {

  s = s.split('\n').slice(0, -1).map(n => Number(n));

  const n = s[0];
  const k = s[1];

  let num = 1;

  for (let i = 0; i < n; i++) {
    if (num <= k) {
      num *= 2;
    } else {
      num += k;
    }
  }

  console.log(num);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
X = int(input())
a = 0
b = 0
c = 0
d = 0
if X >= 500:
	a = X%500
	b = X-X%500
	if a >=5:
		c = a%5
		d = a-a%5
else:
	if X >= 5:
		c = X%5
		d = X-X%5
print(2*b+d)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

template <typename T> inline string toString(const T &a){ostringstream oss; oss<<a; return oss.str();};

int main(){
    string s; cin>>s;
    int n=s.size();

    ll ans=0;
    int tail=n-1;
    for(int i=n-1; i>=0; i--){
        if(s[i]=='B'){
            ans+=tail-i;
            tail--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
ll power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int x;
	cin>>x;
	if(360%x==0)
		cout<<360/x<<endl;
	else{
		int k=__gcd(x,360);
		cout<<360/k<<endl;
	}
		
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--)
		solve();
}


Measured memory_bytes: 3640