akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;
char s[100010], t[100010];
int e[100010], f[100010];
int main()
{
    int i,j,k,m,n,T;
    int a,b,c,d;
    scanf("%s%s%d",s+1,t+1,&T);
    for(i=1; s[i]; ++i)
        e[i] = e[i-1]+s[i]-'A'+1;
    for(i=1; t[i]; ++i)
        f[i] = f[i-1]+t[i]-'A'+1;
    while(T--)
    {
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if((e[b]-e[a-1])%3 == (f[d]-f[c-1])%3)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar('\n')
#define enter putchar(' ')
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0){putchar('-');x = -x;}
	if(x >= 10) out(x / 10);
	putchar('0' + x % 10);
}
int N;
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	read(N);
	int ans = 0x7fffffff;
	for(int i = 1 ; i < N ; ++i) {
		int A = i,B =  N - i;
		int tmp = 0;
		while(A) {tmp += A % 10;A /= 10;}
		while(B) {tmp += B % 10;B /= 10;}
		ans = min(ans,tmp);
	}
	out(ans);enter;
}


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

using namespace std;

const int MAXN = 302;

int n;
double dp[MAXN][MAXN][MAXN];

int main() {
  int cnt[4] = {0};
  cin >> n;
  for(int i=1; i<=n; ++i) {
    int x;
    cin >> x;
    ++cnt[x];
  }

  for (int c=0; c<=n; ++c) {
    for (int b=0; b<=n; ++b) {
      for (int a=0; a<=n; ++a) {
        if(!a && !b && !c || a+b+c > n)
          continue;
        int total = a + b + c;
        dp[a][b][c] = (double)(n - total)/total;
        if (a) dp[a][b][c] += a*((dp[a-1][b][c]+1)/total);
        if (b) dp[a][b][c] += b*((dp[a+1][b-1][c]+1)/total);
        if (c) dp[a][b][c] += c*((dp[a][b+1][c-1]+1)/total);
      }
    }
  }
  cout.precision(10);
  cout << dp[cnt[1]][cnt[2]][cnt[3]] << '\n';
  return 0;
}


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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    cout << a[2] - a[0] << endl;
    return 0;
}



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

int lower_bound(int *a, int n, int x)
{
    int lf = 0, rg = n - 1;

    while (lf != rg){
        int mid = (lf + rg) / 2;
        if (a[mid] >= x) rg = mid;
        else lf = mid + 1;
    }

    return (lf);
}

int main(void)
{
    int i, n;
    int *dp;
    int a;

    scanf("%d", &n);
    dp = (int *)malloc(sizeof(int) * (n + 1));

    for (i = 0; i <= n; i++) dp[i] = 1001001001;

    for (i = 0; i < n; i++){
        scanf("%d", &a);
        dp[lower_bound(dp, n + 1, a)] = a;
    }

    printf("%d\n", lower_bound(dp, n + 1, 1001001001));

    return (0);
}

Measured memory_bytes: 992
#include<stdio.h>

int numS,S[100000];

int bsearch(int T);

int main(void)
{
  int i;
  int numT,T;
  int count=0;

  scanf("%d",&numS);
  
  for(i=0;i<numS;i++)
    {
      scanf("%d",&S[i]);
    }

  scanf("%d",&numT);
  
  for(i=0;i<numT;i++)
    {
      scanf("%d",&T);
    
      if(bsearch(T)==1)
	{
	  count++;
	}
    }
  
  printf("%d\n",count);

  return 0;
}

int bsearch(int T)
{
  int L=0,R=numS-1,M;

  while(L<=R)
    {
      M=(L+R)/2;
    
      if(T>S[M])
	{
	  L=M+1;
	}
      else if(T<S[M])
	{
	  R=M-1;
	}
      else
	{
	  return 1;
	}
    }   
  return 0;
}




Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=55;
int dp[N][N*N],n,m,s,c[N],d[N],ans[N];
struct zh
{
	int x,y,z;
	bool operator<(const zh k)const
	{
		return z>k.z;
	}
	zh(){}
	zh(int _x,int _y,int _z):x(_x),y(_y),z(_z){}
};
vector<zh>e[N];
priority_queue<zh>pq;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>s;
	if(s>2500) s=2500;
	for(int i=1;i<=n;i++)
	{
		ans[i]=1e18;
		for(int j=0;j<=2500;j++)
			dp[i][j]=1e18;
	}
	for(int i=1;i<=m;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(c>2500) c=2500;
		e[a].push_back(zh(b,c,d));
		e[b].push_back(zh(a,c,d));
	}
	for(int i=1;i<=n;i++)
		cin>>c[i]>>d[i];
	dp[1][s]=0;
	pq.push(zh(1,s,0));
	while(!pq.empty())
	{
		auto k=pq.top();
		pq.pop();
		int x=k.x,y=k.y,z=k.z;
		if(dp[x][y]!=z)
			continue;
		ans[x]=min(ans[x],dp[x][y]);
		if(y+c[x]<=2500)
		{
			if(dp[x][y+c[x]]>dp[x][y]+d[x])
			{
				dp[x][y+c[x]]=dp[x][y]+d[x];
				pq.push(zh(x,y+c[x],dp[x][y+c[x]]));
			}
		}
		for(auto i:e[x])
		{
			int v=i.x,p=i.y,q=i.z;
			if(y>=p)
			{
				if(dp[v][y-p]>dp[x][y]+q)
				{
					dp[v][y-p]=dp[x][y]+q;
					pq.push(zh(v,y-p,dp[v][y-p]));	
				}
			}
		}
	}
	for(int i=2;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 7440
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define mod 998244353LL
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define sq(x) ((x)*(x))

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

#define EPS 1e-7

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef pair<i64, i64> pii;

#define maxn 1000005

i64 gcd(i64 a, i64 b)
{
    if( b==0 ) return a ;
    return gcd( b  , a%b ) ;
}

i64 mulSum[maxn] ;
i64 cnt[maxn] , total[maxn] ;

i64 bigMod( i64 a, i64 n, i64 m )
{
    if( n==0 ) return 1 ;
    i64 r = bigMod( a , n/2 , m ) ;
    r = (1LL*r*r)%m ;
    if( (n&1) ) r = (1LL*r*a)%m ;
    return r ;
}

i64 Inv(i64 a)
{
    return bigMod(a,mod-2,mod) ;
}

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

    for(int i=1 ; i<=n ;i++)
    {
        int a ;
        scanf("%d",&a) ;
        cnt[a]++ ;
    }

    int N = 1000000 ;

    for(int i=1 ; i<=N ; i++)
    {
        for(int j=i ; j<=N ; j+=i) mulSum[i] += (cnt[j]*j) ;
        mulSum[i] %= mod ;
    }

    i64 ans = 0LL ;

    for(i64 i=N ; i>=1 ; i--)
    {
        total[i] = (mulSum[i]*mulSum[i])%mod ;
        for(int j=i+i ; j<=N ;j+=i) total[i] = (total[i]-total[j])%mod ;
        ans = ( ans + total[i]*Inv(i) )%mod ;

        ans = ( ans - i*cnt[i] )%mod ;
    }

    ans = (ans*Inv(2))%mod ;

    ans = (ans%mod + mod)%mod ;

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

    return 0 ;
}


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

#define ll long long

int main()
{
    ll i, n, x, ans;

    cin >> n;

    ll a[n], count[n+1];

    memset(count, 0, sizeof(count));
    for(i=0; i<n; i+=1)
    {
        cin >> a[i];
        count[a[i]]+=1;
    }

    ans=0;
    for(i=1; i<=n; i+=1)
        if(count[i]>=2)
            ans+=(count[i]*(count[i]-1))/2;

    for(i=0; i<n; i+=1)
    {
        x=a[i];
        if(count[x]>1)
            cout << ans-(count[x]-1) << endl;
        else
            cout << ans << endl;
    }
}

Measured memory_bytes: 5760
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for(int i = 1; i<=N; i++){
      //N = 8
      //0 1 2 3 4 5 6 7
      //1 2 3 4 5 6 7 8
      String s = sc.next();
      if(s.equals("Y")){
        System.out.println("Four");
        System.exit(0);
      }
    }
    System.out.println("Three");
  }
}


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

int main()
{
    int a, b, c, x;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> x;

    int result = 0;

    for (int i = 0; i <= a; i++) {
        int a_sum = 500 * i;
        if (a_sum > x) {
            break;
        }
        else if (a_sum == x) {
            result++;
        }
        else {
            for (int n = 0; n <= b; n++) {
                int b_sum = a_sum + 100 * n;
                if (b_sum > x) {
                    break;
                }
                else if (b_sum == x) {
                    result++;
                }
                else {
                    int rest = x - b_sum;
                    int num = rest / 50;
                    if (num <= c && rest == num * 50) {
                        result++;
                    }
                }

            }
        }
    }

    std::cout << result << std::endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  vll a(3);
  vin(a);
  sort(all(a));
  cout << ((a.at(0) == a.at(1) && a[1] != a[2]) || (a.at(1) == a.at(2) && a[0] != a[1]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x[n];
  int y[n];
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  vector<int> jun(n);
  iota(jun.begin(),jun.end(),0);
  double sum=0;
  int times=0;
  do{
    double r=0;
    int i=0;
    int a=0;
    int b=0;
    for(auto num: jun){
      if(i==0){
        a=x[num];
        b=y[num];
      }else{
        r=sqrt((a-x[num])*(a-x[num])+(b-y[num])*(b-y[num]));
        a=x[num];
        b=y[num];
        sum=sum+r;
      }
      i++;
    }
    times++;
  }while( next_permutation(jun.begin(), jun.end()) );
  printf("%.10f",sum/times);
}

Measured memory_bytes: 256
a=[0]*5
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
k=int(input())
c=0
for i in range(5):
  for j in range(i+1,5):
    if(abs(a[j]-a[i])>k):
      c+=1
if(c!=0):
  print(":(")
else:
  print("Yay!")


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

using namespace std;


int scores[101];
int ranks[101];

int main(){

    int n;
    cin>>n;
    for(int i=0;i<n*(n-1)/2;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        if(c>d){
            scores[a]+=3;
        }
        else if(c<d){
            scores[b]+=3;
        }
        else{
            scores[b]+=1;
            scores[a]+=1;
        }
    }
    vector<pair<int,int> > vpii;
    for(int i=1;i<=n;i++){
        vpii.push_back(make_pair(-scores[i],i));
    }
    sort(vpii.begin(),vpii.end());
    int cnt=0;
    for(int i=0;i<vpii.size();i++){
        cnt++;
        if(i!=0&&vpii[i-1].first==vpii[i].first)ranks[vpii[i].second]=ranks[vpii[i-1].second];
        else ranks[vpii[i].second]=cnt;
    }
    for(int i=1;i<=n;i++)cout<<ranks[i]<<endl;

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll dp[20][2];
signed main(){
	string s;cin>>s;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	rep(i,s.size())rep(j,2){
		if(dp[i][j]==-1)continue;
		int l;
		if(j)l=9;
		else l=s[i]-'0';
		rep(k,l+1){
			dp[i+1][j||(k<l)]=max(dp[i+1][j||(k<l)],dp[i][j]+k);
		}
	}
	cout<<max(dp[s.size()][0],dp[s.size()][1])<<endl;
}

Measured memory_bytes: 768
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll k, x;
    cin >> k >> x;
    if (k * 500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 764
N,K = [int(_n) for _n in input().split()]
h = [int(_n) for _n in input().split()]
dp = [0]*N
dp[1] = abs(h[1]-h[0])
for i in range(1,N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(max(i-K,0), i):
        dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]))
print(dp[N-1])


Measured memory_bytes: 52320
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    set<string> st;
    rep(i,n){
        string s; cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}



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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll allxor = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        allxor ^= A[i];
    }
    vector<int> odddigit;
    ll ans = 0;
    for (int i = 0; i < 62; i++) {
        if ((allxor>>i)&1) odddigit.push_back(i);
    }
    
    for (int d : odddigit) {
        ans += (1LL<<d);
        ll bitmask = ~(1LL<<d);
        for (int i = 0; i < N; i++) A[i] &= bitmask;
    }
    
    int t = 0;
    for (int i = 61; i >= 0; i--) {
        bool check = false;
        for (int j = t; j < N; j++) {
            if ((A[j]>>i)&1) {
                check = true;
                swap(A[j], A[t]);
            }
        }
        if (!check) continue;
        for (int j = t+1; j < N; j++) {
            if ((A[j]>>i)&1) A[j] ^= A[t];
        }
        t++;
    }
    
    ll evenans = 0;
    for (int i = 0; i < N; i++) {
        if (evenans < (evenans^A[i])) evenans ^= A[i];
    }
    cout << ans + (evenans<<1) << endl;
    return 0;
}


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

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

    int counter = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] == counter + 1)    counter++;
    }

    if(counter == 0)    cout << -1 << endl;
    else    cout << n-counter << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
char s[50];
bool vis[50];
int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);
    if(n < 26){
        for(int i=1;i<=n;i++) vis[s[i]-'a'] = 1, printf("%c", s[i]);
        for(int i=0;i<26;i++){
            if(vis[i]) continue;
            printf("%c\n", i+'a');
            return 0;
        }
    }
    else{
        int mx = 0;
        vector<int> v;
        for(int i=n;i>=1;i--){
            if(s[i]-'a' < mx){
                for(int j=1;j<i;j++) printf("%c", s[j]);
                v.push_back(s[i]-'a');
                sort(v.begin(), v.end());
                for(int j=0;j<v.size();j++){
                    if(v[j] > s[i]-'a'){
                        printf("%c", v[j]+'a');
                        vis[j] = 1;
                        break;
                    }
                }
                printf("\n");
                return 0;
            }
            mx = max(mx, s[i]-'a');
            v.push_back(s[i]-'a');
        }
        printf("-1\n");
    }
}

Measured memory_bytes: 256
# coding:utf-8
from pprint import pprint

def bellman_ford(V, E, s):
    """ 始点sから残りのノードへの最短経路を求めるベルマンフォード法
    :param V: 頂点数
    :param E: (ノード1, ノード2, コスト)のタプルのリスト
    :param s: 始点とするノード
    :return : (距離リスト, 最短経路, 負の辺によるループが存在するか)a
    """
    ##### 前処理 #####
    from collections import defaultdict
    # INFの定義
    INF = 2**63 - 1
    # 最短経路情報を格納する辞書
    dist = defaultdict(lambda: INF) # 始点から始点への移動コスト
    dist[s] = 0
    # 移動経路の履歴
    pre = {}

    ##### 最短経路算出 #####
    # 高々|V|-1回の探索でいい(|V|回以上更新がある場合は負の閉路が存在)
    for i in range(V-1):
        for n1, n2, w in E:
            # 始点からi回の探索でたどり着けない頂点は考慮しない
            # 始点 -> n2 までの最短距離 > 始点 -> n1 までの最短距離 + n1 -> n2 への移動コスト
            # の場合より短い経路が発見できたと言うことなので情報を更新
            if dist[n1] != INF and dist[n2] > dist[n1] + w:
                dist[n2] = dist[n1] + w
                pre[n2] = n1

    ##### 負の閉路検出 #####

    is_cycle = False

    for n1, n2, w in E:
        # 正しい最短距離が求まったと仮定(重要)
        # 始点 -> n1 までの最短距離 + n1 -> n2 への移動コスト < 始点 -> n2 までの最短経路
        if dist[n1] + w < dist[n2]:
            is_cycle = True

    return (dist, pre, is_cycle)




n, m = map(int, input().split(' '))
# 辺の情報
e = []
for _ in range(m):
    a, b, c = map(int, input().split(' '))
    e.append((a, b, -c))


dist, pre, is_cycle = bellman_ford(n, e, 1)

'''
print()
print('##### GRAPH2 (負の閉路あり) #####')
print()
print('===== dist =====')
pprint(dist)
print()
print('===== pre =====')
pprint(pre)
print()
print('===== is_cycle =====')
print(is_cycle)
print('#################################')
print()
'''


if is_cycle:
    g = n
    for i in range(n-1):
        g = pre[g]
        if g == 1:
            break

    if g == 1 and 1 not in pre:
        print(-dist[n])
    else:
        print('inf')

else:
    print(-dist[n])


Measured memory_bytes: 4072
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string A,B;
	cin >> A;
	cin >> B;

	if(A.size() > B.size()) cout << "GREATER" << endl;
	else if(A.size() < B.size()) cout << "LESS" << endl;

	else if(A>B) cout << "GREATER" << endl;
	else if(A < B) cout << "LESS" << endl;
	else cout << "EQUAL" << endl;


	return 0;

}


Measured memory_bytes: 256
import sys
from collections import deque
from itertools import accumulate

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def slide_min(A, K):
    res = []
    Q = deque()
    for i, a in enumerate(A):
        while Q and A[Q[-1]] > a:
            Q.pop()
        Q.append(i)
        if Q[0] == i - K:
            Q.popleft()
        res.append(Q[0])
    return res[K - 1:]

N, K = lr()
P = lr()
mi = slide_min(P, K)
ma = slide_min([-x for x in P], K)
new_pattern = [not (mi == i and ma == i+K) for i, (mi, ma) in enumerate(zip(mi, ma[1:]))]
# Trueの時は新しいパターンが登場
increase = [0] + list(accumulate(x<y for x, y in zip(P, P[1:])))
# K区間で常に上昇
stable_increase = [y-x == K-1  for x, y in zip(increase, increase[K-1:])]
answer = 1 + sum([x for x, y in zip(new_pattern, stable_increase[1:]) if not y])
if not stable_increase[0] and any(stable_increase):
    answer += 1
print(answer)


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

#define ll long long int
#define vi vector<int> 

int main() {
	int a,b;
	cin >> a >>b;
   if(a<b){
    for(int i=0;i<b;i++)cout<<a;
   }
   else
   for(int i=0;i<a;i++)cout<<b;
	return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n, ma, mb;
int dp[2][401][401];

int main() {
    fastio();

    forn(k, 2) forn(i, 401) forn(j, 401) dp[k][i][j] = 1000000;
    dp[0][0][0] = 0;

    cin >> n >> ma >> mb;
    forn(k, n) {
        int a, b, c;
        cin >> a >> b >> c;
        forn(i, 401) forn(j, 401) {
            chmin(dp[(k + 1) & 1][i][j], dp[k & 1][i][j]);
            if (i + a > 400 || j + b > 400) continue;
            chmin(dp[(k + 1) & 1][i + a][j + b], dp[k & 1][i][j] + c);
        }
    }

    int ans = 1000000;
    forn1(i, 400) forn1(j, 400) {
        if (i * mb == j * ma) {
            chmin(ans, dp[n & 1][i][j]);
        }
    }

    if (ans < 1000000) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> bs(n), cs(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      if (y) {
        bs[i] |= 1LL << (x - 1);
      } else {
        cs[i] |= 1LL << (x - 1);
      }
    }
  }
  int ans = 0;
  for (int bit = 0; bit < (1LL << n); bit++) {
    int b = 0, c = 0;
    for (int i = 0; i < n; i++) {
      if (bit & (1LL << i))
        b |= bs[i];
    }
    for (int i = 0; i < n; i++) {
      if (bit & (1LL << i))
        c |= cs[i];
    }
    if (b & c) {
      continue;
    }
    if (c & bit) {
      continue;
    }
    if (b & (~bit)) {
      continue;
    }
    int count = 0;
    for (int k = 0; k < n; k++) if (bit & (1LL << k)) count++;
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int solve(int, int);

int A[2000];
int x;

int main() {
  int y,m,i;

  scanf("%d",&x);
  for(i = 0; i < x; i++) {
    scanf("%d",&A[i]);
  }

  scanf("%d",&y);
  for(i = 0; i < y; i++) {
    scanf("%d",&m);

    if((solve(0,m)) == 1) {
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}


int solve(int a, int b) {
  if(b == 0) {
    return 1;
  }
    
  if(a >= x) {
    return 0;
  }

  if(solve(a + 1, b) || solve(a + 1, b - A[a])) {
    return 1;
  }else{
    return 0;
  }
}
  



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

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

int main(){
	int a,v,b,w;cin>>a>>v>>b>>w;
	int t;cin>>t;
	int d=v-w;
	if(d<=0){
		puts("NO");return 0;
	}
	else{
		int e=abs(a-b);
		int need=(e+d-1)/d;
		if(need<=t)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int n = (int)s.size();
    rep(bit, 0, (1<<n)) {
      int sum = s[0] - '0';
      rep(i, 1, n) {
        if (bit >> i & 1) sum += s[i] - '0';
        else sum -= s[i] - '0';
      }
      if (sum == 7) {
        cout << s[0];
        rep(i, 1, n) {
          if (bit >> i & 1) cout << "+";
          else cout << "-";
          cout << s[i]; 
        }
        cout << "=7" << endl;
        return 0;
      }
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S, T;
	cin >> S >> T;
	if (S == T) {
		cout << "No" << endl;
		return 0;
	}
	sort(S);
	sort(T);
	reverse(T);
	vector<string>A(2);
	A[0] = S;
	A[1] = T;
	sort(A);
	if (A[0] == S) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef long long ll;
typedef pair<int, int> pi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    a.push_back(a[0] + k);

    int l = 0;
    rep(i, n)
    {
        l = max(a[i + 1] - a[i], l);
    }
    cout << k - l << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}





void solve()
{
 string s,t;
    cin>>s>>t;
int m=s.size(),n=t.size();
    if(m+1==n)
    {
      string c=t.substr(0,n-1);
        if(c==s)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
   
}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;

     int t=1;
    // cin>>t;
     while(t--)
    	solve();
    return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  string str;
  while(getline(cin,str)){
    reverse(str.begin(),str.end());
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 22
#define MAXM 4000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN][MAXN],dp[MAXN][MAXM];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<n);j++)
        {
            if(!dp[i][j]) continue;
            for(int k=1;k<=n;k++) 
            {
                if(j&(1<<(k-1))) continue;
                if(!a[i+1][k]) continue;
                add(dp[i+1][j|(1<<(k-1))],dp[i][j]);
            }
        }
    }
    printf("%d\n",dp[n][(1<<n)-1]);
    return 0;
}



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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N, M;
    while (cin >> N >> M, N|M) {
        vector<pii> p;
        REP(i, N) {
            int a, b;
            cin >> a >> b;
            p.push_back({b, a});
        }
        RSORT(p);
        REP(i, N) {
            if (M >= p[i].second) {
                M -= p[i].second;
                p[i].second = 0;
            } else {
                p[i].second -= M;
                M = 0;
                break;
            }
        }
        int res = 0;
        REP(i, N) {
            res += p[i].first * p[i].second;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3092
import java.util.Scanner;
class Main
{
public static void main(String[] args)
 {
 Scanner sc = new Scanner(System.in);
  int i, n, x;
  n = sc.nextInt();     
  for(i =1; i<=n; i++){
   x = i;
   if(x % 3 == 0){
    System.out.printf(" %d", i);
    continue;
   }
   do{
    if(x % 10 == 3){
    System.out.printf(" %d", i);
    break;
   }
   x /= 10;
   }while(0 < x);
}
   System.out.println();
}  
}



Measured memory_bytes: 39988
n = int(input())

def dfs(s: str) -> int:
    if int(s) > n:
        return 0

    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s+c)

    return ret

print(dfs("0"))


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

using namespace std;

int main(){
 
 int a,b , n = 0 ,k ,x,y;

    cin >> a >> b;

    for (int i = 0; n <= 1000; n++)
    {
        x = (int)n*0.08;
        y = (int) n*0.1;
        if( x == a &&  y == b){
            k = n;
            break;
        }
            
        else{
            k = -1;
        }
    }
    cout<< k<< "\n";

    
    return 0;
}


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

using namespace std;

int main(){
  
  int a[3];
  for (int i=0;i<=2;i++){
    cin>>a[i] ;
  }
 int b= *max_element(a,a+3);
  
  cout<<a[0]+a[1]+a[2]+b*9<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

vector <string> v(7);
int ans = 0;

void funcion(int pos, int n, int m, vector <bool> &rf, vector <bool> &rc, int k)
{
	if(pos == 6)
	{
		vector < vector <char>> matriz(6,vector<char>(6));
		forn(i,6)
		{
			forn(j,6)
			{
				if(rc[j]==true || rf[i]==true) matriz[i][j]='R';
				else if(i<n && j<m) matriz[i][j]=v[i][j];
				else matriz[i][j]='N';
			}
		}
		
		/*
		forn(i,6)
		{
			forn(j,6) cout << matriz[i][j] << " ";
			cout << endl;
		}
		RAYA;*/
		
		int cont = 0;
		forn(i,n)
		{
			forn(j,m)
			{
				if(matriz[i][j]=='#') cont++;
			}
		}
		
		bool a = true, b = true;
		
		forr(i,n,6) if(rf[i]==true) a=false;
		forr(i,m,6) if(rc[i]==true) b=false;
		
		if(cont == k && a==true && b==true) 
		{
			ans++;
			//forn(i,6) cout << rf[i] << " "; cout << endl;
			//forn(i,6) cout << rc[i] << " "; cout << endl; RAYA;
		}
		return;
	}
	
	funcion(pos+1, n, m, rf, rc, k);
	rf[pos]=true;
	
	funcion(pos+1, n, m, rf, rc, k);
	rc[pos]=true;
	
	funcion(pos+1, n, m, rf, rc, k);
	rf[pos]=false;
	
	funcion(pos+1, n, m, rf, rc, k);
	rc[pos]=false;
}

int main()
{
	FIN;
	
	int n, m, k;
	cin >> n >> m >> k;
	forn(i,n) cin >> v[i];
	
	vector <bool> rf(7,false);
	vector <bool> rc(7,false);
	
	funcion(0,n,m,rf,rc,k);
	cout << ans << "\n";
	
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i,N) cin >> W[i];
    int h=1e9;
    for(int i=1;i<N;i++){
        int s1=0;
        int s2=0;
        rep(j,N){
            if(j <= i) s1+=W[j];
            else s2+=W[j];
        }
        h=min(h,abs(s1-s2));
    }
    cout << h << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
 
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ab = ReadStringArray();
            var a = ab[0];
            var b = ab[1];
            var ans = a == b ? "H" : "D";
            Console.WriteLine($"{ans}");
        }
    }
 
    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

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

	int ans = 0;
	rep(i, 3)
	{
		if (s[i] == t[i])
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;
int main() {
	int N;
	cin >> N;
	vector<int>A(N+1);
	for (size_t i = 1; i <= N; i++)
	{
		cin >> A.at(i);
	}
	//とりあえずN番目の箱は決定する
	//末尾から決定する
	vector<int> b,c(N+1);
	int u;//自分以外のチェック対象者でボールが入っている箱の数
	for (int i = N; i > 0; i--)
	{
		u = 0;//初期化
		for (size_t j = 2; true; j++)//j*i<=Nとなるすべてのjに対し，いくつ入ってるかチェック
		{
			if (i * j > N) {
				if (u % 2 != A.at(i)) {//入れなきゃいけない
					b.emplace_back(i);
					c.at(i)++;
				}
				break;
			}
			else {
				u += c.at(i * j);
			}
		}
	}
	cout << b.size()<<endl;
	for (size_t i = 0; i < b.size(); i++)
	{
		cout << b.at(i)<<endl;
	}

}

Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	int N, K, S;
	cin >> N >> K >> S;
	int rem = S + 1;
	if (rem > 1000000000) rem = 1;
	for (int i = 0; i < K; ++i) cout << S << " ";
	for (int i = K; i < N; ++i) cout << rem << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader =
				new BufferedReader(new InputStreamReader(System.in));
		
		String str = reader.readLine();
		
		str = str.replaceAll("apple", "xxxxxxx");
		str = str.replaceAll("peach", "apple");
		str = str.replaceAll("xxxxxxx", "peach");
		
		System.out.println(str);
		
		reader.close();
	}
}

Measured memory_bytes: 16888
//当其中有一个数不符，往后退，直到退到末尾，输出UNSTORABLE，若相符，将剩下问好替换为？; 
#include<bits/stdc++.h>
using namespace std;
string s,t,sss="";
int i,j,r;
int main()
{
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(i=0;i<=s.size()-t.size();i++)
	{
        int k=i;
        string ss=s;
        j=0;
        while(j<t.size())
		{
            if(ss[k]=='?')
                ss[k]=t[j];
            else if(s[k]!=t[j])
                break;
            k++;
            j++;
        }
        if(j==t.size())
		{
            for(r=0;r<ss.size();r++)
			{
                if(ss[r]=='?')
                {
            		ss[r]='a';
				}

            }
            if(sss=="")
                sss=ss;
            else sss=min(sss,ss);
        }
    }
    if(sss=="")
        cout<<"UNRESTORABLE";
    else cout<<sss;
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    s.push_back(s[0]);

    string ans = "";
    const string t = "SW";
    rep(i, 2){
        rep(j, 2){
            ans.push_back(t[i]);
            ans.push_back(t[j]);

            REP(k, 2, n + 2){
                if(ans[k - 1] == 'S'){
                    if(ans[k - 2] == 'S'){
                        if(s[k - 1] == 'o'){
                            ans.push_back('S');
                        }else{
                            ans.push_back('W');
                        }
                    }else{
                        if(s[k - 1] == 'o'){
                            ans.push_back('W');
                        }else{
                            ans.push_back('S');
                        }
                    }
                }else{
                    if(ans[k - 2] == 'S'){
                        if(s[k - 1] == 'o'){
                            ans.push_back('W');
                        }else{
                            ans.push_back('S');
                        }
                    }else{
                        if(s[k - 1] == 'o'){
                            ans.push_back('S');
                        }else{
                            ans.push_back('W');
                        }
                    }
                }
            }

            if(ans[0] == ans[n] && ans[1] == ans[n + 1]){
                ans.pop_back();
                ans.pop_back();
                cout << ans << endl;
                return 0;
            }

            ans.clear();
        }
    }

    cout << -1 << endl;

    return 0;
}

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

signed main(void)
{
	int a, b;
	int ans;
	cin >> a >> b;
	if (a >= 13)
		ans = b;
	else if (a >= 6)
		ans = b / 2;
	else
		ans = 0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement as cbr
N,M,Q = list(map(int, input().split()))
X = []
for _ in range(Q):
  X.append(list(map(int, input().split())))
  
ans = -1
for p in cbr(range(1,M+1), N):
  wk = 0
  for x in X:
    a,b,c,d = x
    if p[b-1] - p[a-1] == c:
      wk += d
  ans = max(wk,ans)
  
print(ans)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll a,b;
    cin>>a>>b;
    string A,B;
    rep(i,0,a)
    {
        B+='0'+b;
    }
    rep(i,0,b)
    {
        A+='0'+a;
    }
    if(A<B)
    {
        cout<<A<<endl;
    }
    else
    {
        cout<<B<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ').Select(p => long.Parse(p)).ToArray();
        long count = 0;
        List<long> countList = new List<long>();
        long ans = 0;

        for(long i = 0; i < line.Length; i++ )
        {
            if (line.Length == 1)
            {
                goto END;
            }
            else if (i == 0)
            {

            }
            else
            {
                if(line[i-1] >= line[i])
                {
                    count = count + 1;

                    if(i == line.Length - 1)
                    {
                        countList.Add(count);
                    }
                }
                else
                {
                    countList.Add(count);
                    count = 0;
                }
            }
        }

        ans = countList.Max();
        END:
        Console.WriteLine(ans);


    }

}


Measured memory_bytes: 29404
n,m=map(int,input().split())
dp=[0]*n
indegree=[0]*n
edges=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  indegree[b-1]+=1
  edges[a-1].append(b-1)
  
starting=[]
for i in range(n):
  if(indegree[i]==0):
  	starting.append(i)
visited=set()
#print(edges)
#print(starting)
while starting:
  #print(starting)
  #print(dp)
  start=starting.pop()
  end=edges[start]
  for j in end:
    dp[j]=max(dp[j],dp[start]+1)
    indegree[j]-=1
    if(indegree[j]==0):
      starting.append(j)
print(max(dp))
  
  

Measured memory_bytes: 86708