akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <string.h>
#include<algorithm>
#include <numeric>      // std::accumulate
#include <iomanip>      // std::setprecision


using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define v           vector <int>
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define EPS			 1e-9
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;

bool cmp(const pair<int, int>& a, const pair<int, int>& b)
{
    return (a.second < b.second);
}

int gcd(int a, int b) 
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
long long power(ll n, ll k) 
{
    if (k == 0) return 1;
    ll sq = (power(n, k / 2));
    sq = (sq * sq);
    if (k % 2 == 1)
        sq = (sq * n);
    return sq;
}
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
string to_binary(int x) 
{
    string s;
    while (x > 0) 
    {
        s += (x % 2 ? '1' : '0');
        x /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
bool isPerfect(ll x)
{
    if (x < 1) 
        return false;
    ll root(round(sqrt(x)));
    return x == root * root;
}
void solve()
{
    int n;
    cin >> n;
    
    v a(n + 1);

    lp(i, 1, n+1)
    {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i+=2)
    {
        if (a[i] % 2 == 1)
            ans += 1;
    }

    cout << ans << "\n";
}

int main()
{
    IOS;    
    
    int tt;
    tt = 1;
    // cin >> tt;
    while (tt--)
    {
        solve();
    }
    
}
       

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll sum = 1000000000000001;
    ll n;
    cin >> n;
    ll c = 26, d=26;
    ll count = 1;
    while (n>c){
        count++;
        d *= 26;
        c += d;
    }
    ll b = 26;
    string res = "";
    rep(i,count){
        if(n%26==0){
            res.push_back(26 + 'a' - 1);
            n -= (26);
            n /= 26;
        }else{
            res.push_back(n%26 + 'a' - 1);
            n -= (n%26);
            n /= 26;
        }
    }
    string sres = "";
    rep(i,res.size()){
        sres.push_back(res.at(res.size()-i-1));
    }
    cout << sres << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int L,cnt;
int st[61],to[61],cost[61];
int main(){
	ios::sync_with_stdio(false);
	cin>>L;reg int pos=0;
	for(reg int i=20;i&&(!pos);i--)if(L&(1<<i))pos=i;
	for(reg int i=1;i<pos;i++){
		st[++cnt]=i;to[cnt]=i+1;cost[cnt]=0;
		st[++cnt]=i;to[cnt]=i+1;cost[cnt]=1<<(i-1);
	}
	st[++cnt]=pos;to[cnt]=20;cost[cnt]=0;
	st[++cnt]=pos;to[cnt]=20;cost[cnt]=1<<(pos-1);
	reg int l=1<<pos;
	while(l<L){
		pos=0;for(reg int i=20;i&&(!pos);i--)if((1<<i)&(L-l))pos=i;
		st[++cnt]=pos+1;to[cnt]=20;cost[cnt]=l;l|=1<<pos;
	}
	cout<<20<<' '<<cnt<<endl;
	for(reg int i=1;i<=cnt;i++)
		cout<<st[i]<<' '<<to[i]<<' '<<cost[i]<<endl;
	return 0;
}

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

signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    
    vector<int> sum(N+1);
    for(int i=0;i<N;i++){
        sum[i+1]=sum[i]+a[i];
    }
    
    int ans=1e9;
    for(int i=1;i<N;i++){
        ans=min(ans,abs(sum[N]-sum[i]*2));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  int a = 1;
  bool b = true;
  for (int i = 0; i < N; i++){
    a = A.at(a - 1);
    if (a == 2) {
      cout << i + 1 << endl;
      b = false;
      break;
    }
  }
  if (b) cout << -1 << endl;
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{	
        ll a, b, c; cin >> a >> b >> c;
        for (int i = 1; i < 10001; ++i)
        {
                if ((i * a) % b == c) 
                {
                        cout << "YES";
                        return;
                }
        }
        cout << "NO";
}

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t l;
typedef vector<l> q;
#define r(i,n)for(i=0;i<n;i++)
void c(l &a,l b){if(a>b)a=b;}
main(){l n,s,k,v,i,j,b;cin>>n;q x(n),y(n),p(n),a(n+1,1LL<<60);vector<q>X(n),Y(n);r(i,n)cin>>x[i]>>y[i]>>p[i];r(i,n){X[i]=q(1<<n,abs(x[i])),Y[i]=q(1<<n,abs(y[i]));r(b,1<<n)r(j,n)if(b&1<<j)c(X[i][b],abs(x[i]-x[j])),c(Y[i][b],abs(y[i]-y[j]));}r(b,1<<n){s=b;do{k=__builtin_popcountl(b),v=0;r(i,n)v+=p[i]*min(X[i][s],Y[i][b&~s]);c(a[k],v),s=(s-1)&b;}while(s!=b);}r(i,n+1)cout<<a[i]<<" ";}

Measured memory_bytes: 11084
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,g,b,k;
    cin>>r>>g>>b;
    cin>>k;
    for(int i=0;i<k;i++){
        if(g<=r){
            g*=2;
            continue;
        }
        if(b<=g){
            b*=2;
            continue;
        }
    }
    if(g>r && b>g)
        cout<<"Yes\n";
    else
        cout<<"No\n";

}


Measured memory_bytes: 3636
// abc.96.c   Grid Repainting

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

int main( void ) {

    //縦横の入力幅の設定
    int h, w;
    cin >> h >> w;

    //ボードの設定、上下左右に+1
    char board[ h + 2 ][ w + 2 ];

    //入力
    for( int i = 1; i <= h; i++ ) {
        for( int j = 1; j <= w; j++ ) {
            cin >> board[ i ][ j ];
        }
    }

    //判断処理
    for( int i = 1; i <= h; i++ ) {
        for( int j = 1; j <= w; j++ ) {
            //もし中心が＃　＆＆　上下左右が'.'の場合
            if( board[ i ][ j ] == '#' ) {
                if( board[ i - 1 ][ j ] == '#' || board[ i ][ j - 1 ] == '#' ||
                    board[ i ][ j + 1 ] == '#' || board[ i + 1 ][ j ] == '#' ) {
                    continue;
                } else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
cout << "Yes" << endl;

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

void Main(){
  long n,wm;
  cin >> n >> wm;
  vl w(n),v(n);
  rep(i,n) cin >> w[i] >> v[i];
  vl dp(wm+1,0);
  rep(i,n){
    for(int j=wm;j>=0;j--){
      if(j - w[i] < 0) dp[j] = dp[j];
      else dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    }
  }
  cout << dp[wm] << endl;
}

int main(){
  Main();
  return 0;
  long n,wm;
  cin >> n >> wm;
  vl w(n),v(n);
  rep(i,n) cin >> w[i] >> v[i];
  vvl dp(n+1, vl(wm+1,0));
  rep(i,n){
    rep(j,wm+1){
      if(j - w[i] < 0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
    }
  }
  cout << dp[n][wm] << endl;
}



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

/* 整数numが素数か判定する関数 */
int Jdg_Prime(int num){
    int sqrt_num=0;
    int k;
    if(0 == num % 2){
        if(2 == num) return 1;
        else{
//            printf("%dは偶数\n", num);
//            printf("%dは合成数\n", num);        
            return 0;
        }
    }else{
        sqrt_num = (int)(floor(sqrt(num)));
//        printf("%dのルート未満の整数は%d\n", num, sqrt_num);
        for(k=3; k<=sqrt_num; k+=2){
//            printf("%d÷%dの余りは%d\n", num, k, num%k);
            if(0 == num % k){
//                printf("%dは合成数\n", num);
                return 0;
                break;
            }
        }
        return 1;
    }
}

int main(void){
    /** 初期化 **/
    int i, j, n=0;
    int flag=0;
    int *num_int;
    int n_prime = 0;
    
    /** 入力部 **/
    do{
//        puts("入力する整数の数を入力してください");
        scanf("%d", &n);
    }while(n<1 || n>10000);
    num_int = (int *)malloc(sizeof(int)*n);
    do{
//        puts("n個の整数を1個1行ずつ入力してください");
        for(i=0; i<n; i++){
            scanf("%d", &num_int[i]);
//            printf("%d\n", num_int[i]);
            if(num_int[i]<2 || num_int[i]>100000000){
                flag = 1;
                break;
            }
        }
    }while(0!=flag);

    /** 処理部 **/
    for(j=0; j<n; j++){
        n_prime += Jdg_Prime(num_int[j]);
    }

    /** 出力部 **/
//    printf("入力された整数の中に%d個素数アリ\n", n_prime);
    printf("%d\n", n_prime);

    free(num_int);
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll x[100004];
ll y[100004];
ll z[100004];
vl ad[100004];
ll vis[100004];

void dfs(ll v)
{
	ll i;
	vis[v] = 1;
	fr(i,0,ad[v].size())
	{
		if(vis[ad[v][i]] == 0)
			dfs(ad[v][i]);
	}
}

int main()
{
	FAST;
	ll n, m, i, j;
	cin >> n >> m;
	fr(i,0,m)
	{
		cin >> x[i] >> y[i] >> z[i];
		ad[x[i]].pb(y[i]);
		ad[y[i]].pb(x[i]);
	}
	ll ans = n;
	fr(i,1,n+1)
	{
		if(vis[i] == 1)
			ans--;
		else
			dfs(i);
	}
	cout << ans;
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define lli long long int
#define in int
#define el endl
#define oo cout
#define ii cin
#define pb push_back
#define bg begin()
#define en end()
#define p1 first
#define p2 second
#define FOR(i,a,b,c) for (int i = (a); i < (b); i=i+(c))
#define ROF(i,a,b,c) for (int i = (a); i > (b); i=i-(c))
using namespace std;

//vector< pair<lli,lli> >ccr;
//vector< pair<lli,lli> >jjr;
//vector<string>r;
//int ar[100008],br[100008];

int main()
{


int n,aa,bb,cc,i,j;
ii>>n;
vector<lli>v,u;
FOR(i,0,n+1,1){
ii>>cc;
v.pb(cc);
//ar[i]=cc;
}
FOR(i,0,n,1){
ii>>cc;
u.pb(cc);
//br[i]=cc;
}
lli ss=0;

FOR(i,0,n,1){

    if(v[i]>u[i]){
    ss+=u[i];
    u[i]=0;
    }
    else{
        ss+=v[i];
        u[i]-=v[i];
    }

if(u[i]>0){
        if((v[i+1])>u[i]){
        ss+=u[i];
        v[i+1]-=u[i];
        }
        else{
            ss+=v[i+1];
            v[i+1]=0;
}
}
}
oo<<ss<<el;
return 0;
}



Measured memory_bytes: 5560
#include<stdio.h>

int main(){
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
   if(a==b && a!=c){
      printf("Yes");
   }else if(a==c && a!=b){
      printf("Yes");
   }else if(b==c && a!=b){
      printf("Yes");
   }else{
      printf("No");
   }
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    long double n, m, d; cin >> n >> m >> d;
    if(m == 1){cout << 0;}
    else{
    if(d>0){
    cout << setprecision(10) << 2*(n-d)*(m-1)/(n*n);
    }
    else{
    cout << setprecision(10) << (n-d)*(m-1)/(n*n);
    }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll exp(ll a, ll b) {
    ll ret = 1;
    while(1) {
        if (b==0) break;
        if (b%2==1) ret = ret * a % mod;
        a = a * a % mod;
        b>>=1;
    }   
    return ret; 
}

ll inv(ll a) {
    return exp(a, mod-2);
}

ll factorial(ll a, ll b) {
    ll ret = 1;
    while(1) {
        if (b==0) break;
        ret = ret * a % mod;
        --a;
        --b;
    }
    return ret;
}

ll choose(ll a, ll b) {
    if (a < b) swap(a, b);
    ll ret = 1;
    ret = factorial(a, b) * inv(factorial(b, b)) % mod;
    return ret;
}

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll ans = 1;
    ll num = 1;
    vector<int> c(26);
    rep(i, n) ++c[s[i]-'a'];
    //for (auto p: c) {
    //    cout << p << endl;
    //}
    rep(i, 26) {
        ans = ans * (c[i] + 1) % mod;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int n,m;
int c[30];
int T[30][50010];
int min(int a,int b){
    return a<b?a:b;
}
void solve(){
    for(int i=1;i<=m;i++)
        for(int j=0;j<=n;j++)
        {
            if(i==1)
                T[i][j]=j;
            else if(i!=1&&c[i-1]<j)
                T[i][j]=min(T[i-1][j],T[i][j-c[i-1]]+1);
            else if(i!=1&&c[i-1]>j)
                T[i][j]=T[i-1][j];
            else if(i!=1&&c[i-1]==j)
                T[i][j]=1;
        }
    cout<<T[m][n]<<endl;

}
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>c[i];
    }
    solve();
    return 0;
}



Measured memory_bytes: 7036
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve(){
    int N;
    ll C;
    cin >> N >> C;
    vector<pair<ll, ll>> sushi(N);
    for (int i=0; i<N; i++) {
        cin >> sushi.at(i).first >> sushi.at(i).second;
    }
    vector<ll> forw(N+1), rev(N+1), disForw(N+1), disRev(N+1);
    for (int i=1; i<N+1; i++) {
        forw.at(i) = sushi.at(i-1).second;
        rev.at(i) = sushi.at(N-i).second;
        disForw.at(i) = sushi.at(i-1).first;
        disRev.at(i) = C - sushi.at(N-i).first;
    }
    for (int i=1; i<N+1; i++) {
        forw.at(i) += forw.at(i-1);
        rev.at(i) += rev.at(i-1);
    }
    for (int i=1; i<N+1; i++) {
        forw.at(i) -= disForw.at(i);
        rev.at(i) -= disRev.at(i);
    }
    for (int i=1; i<N+1; i++) {
        if (chmax(forw.at(i), forw.at(i-1))) disForw.at(i) = disForw.at(i-1);
        if (chmax(rev.at(i), rev.at(i-1))) disRev.at(i) = disRev.at(i-1);
    }
    ll ans = -LINF;
    for (int i=0; i<N+1; i++) {
        chmax(ans, forw.at(i) + rev.at(N-i) - min(disForw.at(i), disRev.at(N-i)));
    }

    cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4992
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    string n;
    cin >> n;
    bool ans = false;
    for(int i = 0 ; i < n.size() ; i++){
        if(n[i] == '9'){
            ans = true;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
/* FALTU HI LIKH ... BUT KHALI NI BAITHNA */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

/* if not able to handle the ques.. see up */
int32_t main() {
	fast
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
		string s, t;
		cin >> s >> t;
		int n = s.length(), m = t.length();
		vector<vector<int>> dp(n + 1, vector<int>(m + 1));

		for (int si = n; si >= 0; si--) {
			for (int ti = m; ti >= 0; ti--) {
				if (si == n or ti == m)
					dp[si][ti] = 0;
				else if (s[si] == t[ti])
					dp[si][ti] = 1 + dp[si + 1][ti + 1];
				else
					dp[si][ti] = max(dp[si + 1][ti], dp[si][ti + 1]);
			}
		}

		string ans = "";
		int si = 0, ti = 0;
		while (si != n and ti != m) {
			if (s[si] == t[ti]) {
				ans += s[si];
				si++, ti++;
			} else {
				dp[si + 1][ti] > dp[si][ti + 1] ? si++ : ti++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 70784
package main

import "fmt"

func main() {
	arr := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&arr[i])
	}
	min := arr[0] % 10
	p := 0
	for i := 1; i < 5; i++ {
		tmp := arr[i] % 10
		if min > tmp && tmp > 0 {
			min = tmp
			p = i
		}
	}
	var total int
	for i := 0; i < 5; i++ {
		if i != p {
			tmp := arr[i] / 10
			total += tmp * 10
			if arr[i]%10 != 0 {
				total += 10
			}
		}
	}
	total += arr[p]
	fmt.Println(total)
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        string ab = "Christmas";
        for (int a = 0; a < 25 - input ; a++)
        {
            ab += " Eve";
        }
        Console.WriteLine(ab);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11220
import sys
from collections import defaultdict as dd
from collections import deque as dq
input = sys.stdin.readline
N, K = map(int, input().split())
e = dd(list)
for _ in range(N - 1):
  a, b = map(int, input().split())
  e[a].append(b)
  e[b].append(a)
d = [[N for _ in range(N + 1)] for _ in range(N + 1)]
for s in range(1, N + 1):
  Q = dq([s])
  d[s][s] = 0
  while len(Q):
    p = Q.popleft()
    for q in e[p]:
      if d[s][q] > d[s][p] + 1:
        d[s][q] = d[s][p] + 1
        Q.append(q)
vis = set()
table = [[0] * (N + 1) for _ in range(N + 1)]
lntable = [0] * (N + 1)
for i in range(1, N + 1):
  for j in range(1, N + 1):
    if d[i][j] > K:
      table[i][j] = 1
      lntable[i] += 1
while True:
  t = 0
  for i in range(1, N + 1):
    if i in vis: continue
    if lntable[i] > lntable[t]: t = i
  if t == 0: break
  for i in range(1, N + 1):
    if table[i][t] == 1:
      table[i][t] = 0
      lntable[i] -= 1
  vis.add(t)
print(len(vis))

Measured memory_bytes: 113244
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

struct dat {
	int l,r;
	bool operator<(const dat &A) const {
		return r-l<A.r-A.l;
	}
} p[N];

int n,m,c[N],cnt[N];

void modify(int p,int v) {
	++p;
	while(p<=m+1) c[p]+=v,p+=p&-p;
}

int query(int p) {
	int ret=0;++p;
	while(p) ret+=c[p],p-=p&-p;
	return ret;
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) p[i]={gi(),gi()},++cnt[p[i].r-p[i].l+1];
	sort(p+1,p+n+1);
	for(int i=m;i;i--) cnt[i]+=cnt[i+1];
	for(int i=1,j=1;i<=m;i++) {
		while(j<=n&&p[j].r-p[j].l+1<i) modify(p[j].l,1),modify(p[j].r+1,-1),++j;
		int sum=0;
		for(int k=0;k<=m;k+=i) sum+=query(k);
		cout<<sum+cnt[i]<<'\n';
	}
	return 0;
}


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

int main() {
  long long int N, P;
  cin >> N >> P;
  set<pair<long long int, long long int>> S;
  for (long long int i = 2; i * i <= P; i++) {
    if (P % i == 0) {
      long long int k = 0;
      while (P % i == 0) {
        P /= i;
        k++;
      }
      pair<long long int, long long int> p = make_pair(i, k);
      S.insert(p);
    }
  }
  pair<long long int, long long int> p = make_pair(P, (long long int)1);
  S.insert(p);
  long long int ans = 1;
  for (auto p : S) {
    for (long long int i = 0; i < p.second / N; i++) ans *= p.first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unrolong long-loops")
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#define F first
#define S second
using namespace std;
unordered_map<int,int> mp;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(mp[a]>0){
            cout<<"NO";
            return 0;
        }
        mp[a]++;
    }
    cout<<"YES";
    return 0;
}
/*
 1 - u
 2 - d
 3 - r
 4 - l
 
 
 9
 0 1 0 2
 1
 0 2 0 3 2
 0 3 0 4 3
 0 4 1 0 4
 1 0 1 1 5
 1 1 1 2 6
 1 2 1 3 7
 1 3 1 4 8
 1 4 2 0 9
 */


Measured memory_bytes: 8520
#include <stdio.h>
#include <algorithm>
using namespace std;

#define MAX 1<<30
#define REP(i,N) for(int i = 0; i < (N); i++)

int count_b(int num){
    int ret = 0;
    while(num > 0){
        int mod = num % 2;
        num = (num-mod)/2;
        ret += mod;
    }
    return ret;
}
 
int main()
{
    int f[100], p[100][11], n, fi;
    long sale, res = -MAX;// least
    scanf("%d", &n);
    fill_n(f, n, 0);
    REP(i, n){
        REP(j, 10){
            scanf("%d", &fi);
            if(fi) f[i] += (1 << j);
        }
    }
    REP(i, n){
        REP(j, 11)
            scanf("%d", &(p[i][j]));
    }
 
    for(int mask = 1; mask < (1 << 10); mask++){
        sale = 0;
        REP(i, n){
            sale += p[i][count_b(f[i] & mask)];
        }
        res = max(res, sale);
    }
 
    printf("%ld\n", res);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;

int main(){
  int h[101][1001];


  int n,m,a;
  while(cin>>n>>m>>a){
    if(n==0&&m==0&&a==0)
      return 0;
    memset(h,0,sizeof(h));
    for(int i = 0;i<m;i++){
      int height,p,q;
      cin>>height>>p>>q;
      h[p][height] = q;
      h[q][height] = p;
    }
    
    int ans = a;
    for(int i = 1000;i>=0;i--){
      if(h[ans][i] != 0){
	ans = h[ans][i];
      }
    }
    cout<<ans<<endl;
  }
  


  return 0;
}

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

void Main()
{
  ll N, Y;
  cin >> N >> Y;
  ll senMai = Y / 1000;
  for (int i = 0; i <= senMai / 10; i++) {
    for (int g = 0; g <= senMai / 5; g++) {
      if ((Y - 5000*g - 10000*i)%1000 != 0 || Y - 5000*g - 10000*i < 0) continue;
      int s = (Y - 5000*g - 10000*i)/1000;
      if (s+g+i == N) {cout << i << " " << g << " " << s << endl; return;}
    }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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;}
};


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    ll X, Y;
    cin >> X >> Y;

    ll x, y;
    if(2 * Y - X < 0 || (2 * Y - X) % 3 != 0 ) {
        cout << 0 << endl;
        return 0;
    }

    x = (2 * Y - X) / 3;
    y =  Y - 2 * x;
    if(y < 0) {
        cout << 0 << endl;
        return 0;
    }

    combination comb = combination(x + y);
    mint ans = comb.operator()(x + y, x);
    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 13796
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

int main()
{
	int n;
	string s;

	cin >> n;
	cin >> s;

	for(int i = 0; i < n; i++)
	{
		if(s[i] == s[i+1])
		{
			s[i] = '\0';
		}
	}

	int ans = 0;
	rep(i, s.size())
	{
		if(s[i] != '\0')
		{
			ans++;
		}
	}

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

Measured memory_bytes: 512
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    listc = []
    for i in range(1,201):
        lista = []
        for j in range(1,201):
            if i%j == 0:
                lista.append(j)
        if len(lista) >= 8 and lista[-1] %2 != 0:
            listc.append(lista[-1])
    #print(listc)#デバッグ用
    for i in range(len(listc)):
        if n < listc[0]:
            return 0
        elif n >= listc[-(i+1)]:
            return len(listc)-i

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int h[100010];
    rep(i, N) cin >> h[i];
    dp[1] = abs(h[1] - h[0]);
    REP(i, 2, N - 1) {
        int jump1 = abs(h[i] - h[i - 1]) + dp[i - 1];
        int jump2 = abs(h[i] - h[i - 2]) + dp[i - 2];
        dp[i] = min(jump1, jump2);
    }
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 200004
#define M 51
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}


int main()
{
    int n;
    while(cin>>n)
    {
        int x,tot;
        FOR(i,1,n)
        {
            cin>>x;
            tot+=x;
        }
        if(tot%2 == 0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
fn main () {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    match n.trim() {
        "1" => a(),
        "2" => b(),
        _ => panic!(),
    }
}

fn a () {
    println!("Hello World");
}

fn b () {
    let mut a = String::new();
    let mut b = String::new();
    std::io::stdin().read_line(&mut a).unwrap();
    std::io::stdin().read_line(&mut b).unwrap();
    println!("{}", a.trim().parse::<usize>().unwrap() + b.trim().parse::<usize>().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    vector<string> V = {"Sunny", "Cloudy", "Rainy"};
    string S; cin >> S;
    for(int i=0; i<3; i++){
        if(S==V[i]) cout << V[(i+1)%3] << endl;
    }
    
    return 0;
}


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

int main() {
	// freopen("input.txt", "r", stdin);

	int N, K;
	scanf("%d %d", &N, &K);
	double res = 0.0;
	for(int i = 1; i <= N; i++){
		int now = i;
		double prob = 1.0 / N;
		while(now < K){
			prob /= 2.0;
			now <<= 1;
		}
		res += prob;
	}
	printf("%.9f\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const ll MOD = 1e9+7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

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

 //使い方
 int main() {
     int m;
     cin >> m;
     cout << 48 - m << endl;
     return 0;
 }

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

using namespace std;
using ll = long long;

int main(){
    int H,W,K;cin >> H >> W >> K;
    vector<string> vec;
    for(int i = 0;i < H;i++){
        string s;cin >> s;
        vec.push_back(s);
    }
    int cnt = 1;
    vector<vector<int>> ins(H, vector<int>(W, -1));
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(vec[i][j] == '#'){
                ins[i][j] = cnt;
                cnt++;
            }
        }
    }
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W-1;j++){
            if(ins[i][j] != -1 && ins[i][j + 1] == -1){
                ins[i][j+1] = ins[i][j];
            }
        }
        for(int j = W-1;j >= 1;j--){
            if(ins[i][j] != -1 && ins[i][j - 1] == -1){
                ins[i][j - 1] = ins[i][j];
            }
        }
    }
    for(int i = 0;i < H-1;i++){
        for(int j = 0;j < W;j++){
            if(ins[i][j] != -1 && ins[i+1][j] == -1)ins[i+1][j] = ins[i][j];
        }
    }
    for(int i = H-1;i >= 1;i--){
        for(int j = 0;j < W;j++){
            if(ins[i][j] != -1 && ins[i-1][j] == -1)ins[i-1][j] = ins[i][j];
        }
    }
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cout<<ins[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
    }
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(const Point &p, const double r): p(p), r(r) {}
};

pair<Point, Point> get_ipoints(const Circle &c, const Line &l) {
    double a=imag(l.first)-imag(l.second);
    double b=real(l.second)-real(l.first);
    double k=-b*imag(l.first)-a*real(l.first);

    double d=a*real(c.p)+b*imag(c.p)+k;
    double r=c.r;

    double R=a*a+b*b;
    double D=sqrt(R*r*r-d*d);
    Point p1=c.p+polar(1/sqrt(R), atan2(b, a))*Point(-d, D);
    Point p2=c.p+polar(1/sqrt(R), atan2(b, a))*Point(-d, -D);

    if (p2 < p1)
        swap(p1, p2);

    return make_pair(p1, p2);
}

int main() {
    double x, y, r;
    scanf("%lf %lf %lf", &x, &y, &r);
    Circle c(Point(x, y), r);

    size_t q;
    scanf("%zu", &q);

    for (size_t i=0; i<q; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        Point p1(x, y);

        scanf("%lf %lf", &x, &y);
        Point p2(x, y);

        Line l(p1, p2);
        pair<Point, Point> ps=get_ipoints(c, l);
        printf("%.9f %.9f ", real(ps.first), imag(ps.first));
        printf("%.9f %.9f\n", real(ps.second), imag(ps.second));
    }

    return 0;
}

Measured memory_bytes: 3144
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())
A = sorted(A)
for i in range(N):
    if A[i - 1] == A[i]:
        print "NO"
        exit()
print "YES"

Measured memory_bytes: 58904
#include<cstdio>

using namespace std;

int main(){
	int N, i, j, k;
	char S[100000][10];

	scanf("%d", &N);
	long int March[5] = { 0 };
	for (i = 0; i < N; i++){
		scanf("%s", S[i]);
		if (S[i][0] == 'M'){
			March[0]++;
		}
		else if (S[i][0] == 'A'){
			March[1]++;
		}
		else if (S[i][0] == 'R'){
			March[2]++;
		}
		else if (S[i][0] == 'C'){
			March[3]++;
		}
		else if (S[i][0] == 'H'){
			March[4]++;
		}
	}

	long int ans = 0;
	for (i = 0; i < 3; i++){
		for (j = i + 1; j < 4; j++){
			for (k = j + 1; k < 5; k++){
				ans = ans + March[i] * March[j] * March[k];
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
import sys
from collections import Counter
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A_ex = [(i, a) for i, a in enumerate(A)]

    # i < jを仮定する
    counter = Counter()
    cnt = 0
    for i, a in A_ex[::-1]:
        cnt += counter[i+A[i]]
        counter[i-A[i]] += 1
    print(cnt)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62440
N, K = map(int, input().split())
A = list(map(int, input().split()))

index = 1
route = [index]
node = {index}

for i in range(1, K + 1):
    index = A[index - 1]
    if index in node:
        pre = route.index(index)
        loop = len(route)
        route_idx = (K - pre) % (loop - pre) + pre
        print(route[route_idx])
        break
    else:
        route.append(index)
        node.add(index)
else:
    print(index)

Measured memory_bytes: 32188
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int gcd(int x, int y){
     return (x % y)? gcd(y, x % y): y; 
    }
int main () {
    ll N ;
    cin >> N ;
    ll a , b ;
    cin >> a  ;

    for(ll i = 0 ; i < N - 1; i++){
        
    cin >> b;
    a = gcd(a, b);
  
    }
    cout << a << endl;
    return 0 ;
}

 


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<algorithm>
typedef long long int ll;
using namespace std;
ll n;
ll a[300000];
ll sum=0,xo=0,ans=0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sum=a[0];
    xo=a[0];
    int l=0;
    int r=1;

    for(int l=0;l<n;l++){
        //rを伸ばせるか判定
        
        while(r<n&&(sum+a[r])==(sum^a[r])){
            sum+=a[r];
            xo=sum;
            //cout<<r<<" "<<sum<<endl;
            r++;
        }
        //cout<<l<<" "<<r<<endl;
        ans+=(r-l);
        sum=sum-a[l];
        xo=xo^a[l];
    }
cout<<ans<<endl;

}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    ans = 0
    for i in range(N):
        ans += max(A[i], -A[i])
    print(ans)
    exit()
    
minus_count = 0
for i in range(N):
    if A[i] < 0:
        minus_count += 1
        
if minus_count % 2 == 0:
    ans = 0
    for i in range(N):
        ans += max(A[i], -A[i])
    print(ans)
else:
    for i in range(N):
        if A[i] < 0:
            A[i] = -A[i]
    min_A = min(A)
    print(sum(A) - 2*min_A)

Measured memory_bytes: 20004
#include <iostream>
#include <list>
#include <vector>

bool check_mask(std::list<uint64_t> &xs, size_t k, uint64_t mask) {
    size_t count = 0;
    for (uint64_t x : xs) {
        if ((x & mask) == mask) {
            count++;
        }
    }
    if (count < k) {
        return false;
    } else {
        xs.remove_if([=](uint64_t x) { return (x & mask) != mask; });
        return true;
    }
}

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<uint64_t> sums;
    sums.push_back(0);
    uint64_t accum = 0;

    //std::list<uint64_t> l;
    for (int i = 0; i < n; i++) {
        uint64_t x;
        std::cin >> x;
        accum += x;
        sums.push_back(accum);
    }

    std::list<uint64_t> bs;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            bs.push_back(sums.at(j) - sums.at(i)); 
        }
    }
    bs.sort([](uint64_t x, uint64_t y) { return y < x; } );
    uint64_t ans = 0;
    for (uint64_t bit = 0x8000000000000000; bit != 0; bit >>= 1) {
        if (check_mask(bs, k, bit)) {
            ans |= bit;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 17920
#ifndef _WIN32
#include<iostream>
#endif
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

using namespace std;

struct P {
	int id;
	int x, y;

	bool operator < (P &a) const {
		if (id != a.id) {
			return id < a.id;
		}
		return x*y < a.x * a.y;
	}
};

int N, W, D;
P C[10010];
vector<int> X;

int main() {
	while (true) {
		cin >> N >> W >> D;
		if (!N && !W && !D) break;
		C[0].id = 0;
		C[0].x = W;
		C[0].y = D;

		for (int i = 0; i < N; ++i) {
			int w, h;
			int p, s;

			int p1[2], p2[2];

			cin >> p >> s;
			--p;

			w = C[p].x;
			h = C[p].y;

			s = s % (2 * w + 2 * h);

			if (s < w) {
				p1[0] = s; p1[1] = h;
				p2[0] = w - s; p2[1] = h;
			}
			else if (w < s && s < w + h){
				p1[0] = w; p1[1] = s - w;
				p2[0] = w; p2[1] = h - (s - w);
			}
			else if (w + h < s && s < w + w + h) {
				p1[0] = w - (s - (w + h)); p1[1] = h;
				p2[0] = s - (w + h); p2[1] = h;
			}
			else{
				p1[0] = w; p1[1] = h - (s - (w + w + h));
				p2[0] = w; p2[1] = s - (w + w + h);
			}
			if (p1[0] * p1[1] > p2[0] * p2[1]){
				p1[0] ^= p2[0] ^= p1[0] ^= p2[0];
				p1[1] ^= p2[1] ^= p1[1] ^= p2[1];
			}
			C[p].id = i + 1;
			C[p].x = p1[0];
			C[p].y = p1[1];
			C[i + 1].id = i + 1;
			C[i + 1].x = p2[0];
			C[i + 1].y = p2[1];


			sort(C, C + (i + 1));
		}

		X.clear();
		for (int i = 0; i <= N; ++i) {
			X.push_back(C[i].x * C[i].y);
		}
		sort(X.begin(), X.end());

		cout << X[0];
		for (int i = 1; i <= N; ++i) {
			cout << " " << X[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3068
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int n;
    scan(n);
    int d, x;
    scan(d, x);
    foreach (i ; 0 .. n) {
        int ai;
        scan(ai);
        x += (d + ai - 1) / ai;
    }

    writeln(x);
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
	int m,f,r;
	int sum;
	char str;

	while (1) {
		str = '\0';
		scanf("%d %d %d",&m,&f,&r);
		if ((m==-1)&&(f==-1)&&(r==-1)) {
			return 0;
		}
		if ((m == -1)||(f == -1)) {
			str = 'F';
		}
		else {
			sum = m + f;
			if (sum >= 80) {
				str = 'A';
			}
			else {
				if (sum >= 65) {
					str = 'B';
				}
				else {
					if ((sum >= 50)||(r>=50)) {
						str = 'C';
					}
					else {
						if (sum >= 30) {
							str = 'D';
						}
						else {
							str = 'F';
						}
					}
				}
			}
		}
		printf("%c\n",str);
	}
	return 0;
}

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

int main(){
  char S[200];
  scanf("%s",S);
  int lenS = strlen(S);
  for(int i = 2;i < lenS;i+=2){
      int lens = (lenS-i)/2;
      if(strncmp(S,S+lens,lens)==0){
        printf("%d\n",lens*2);
        return 0;
      }
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include <climits>
using namespace std;
int n, l;
vector<string> v;
int main() {
    cin >> n >> l;
    for(int i=0; i<n; ++i){
        string str; cin >> str;
        v.push_back(str);
    }
    sort(v.begin(), v.end());
    string str;
    for(int i=0; i<n; ++i){
        str += v[i];
    }
    cout << str << endl;
        
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int a, b, c;

	while( cin >> a >>b ){
		c = a + b;
		int k=0;
		while (c > 0){
			k++;
			c /=10;	
		}
		if(k==0) k=1;
		cout << k << endl;
	}
		return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define MAX 100
#define INFTYtw 10000
#define WHITEtw 0
#define GRAYtw 1
#define BLACKtw 2

int n,Mtw[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTYtw;
    p[i]=-1;
    color[i]=WHITEtw;
  }

  d[0]=0;

  while(1){
    minv=INFTYtw;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACKtw){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACKtw;
    for(v=0;v<n;v++){
      if(color[v]!=BLACKtw&&Mtw[u][v]!=INFTYtw){
	if(d[v]>Mtw[u][v]){
	  d[v]=Mtw[u][v];
	  p[v]=u;
	  color[v]=GRAYtw;
	}
      }
    }
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=Mtw[i][p[i]];
  }

  return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      int e;
      scanf("%d",&e);
      if(e==-1)Mtw[i][j]=INFTYtw;
      else Mtw[i][j]=e;
    }
  }

  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
  cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int count = 0;
  for(int i =0; i < N-1;i++){
  if(A.at(i) ==A.at(i+1)){
  count +=1;
  }
  }
  if(count == 0){
    cout << "YES";  
  }else{
    cout << "NO";  
  }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string tmp;
    cin >> tmp;
    int ans = 1000000;
    rep(i, tmp.size()-2) {
        string str = "";
        str += tmp[i];
        str += tmp[i+1];
        str += tmp[i+2];
        int num = stoi(str);
        ans = min(ans, abs(753-num));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256