akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#include<random>
#pragma warning(disable:4996)
using namespace std;




#define _GLIBCXX_DEBUG

using namespace std;

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


//const int INF = 2147483647;
//const long long int L_INF = 9223372036854775807;

typedef int Weight;

const Weight INF = 1e9;
const Weight ZERO =0;
struct Edge {
	int src, dst;
	Weight weight;
	int id;
	Edge(int src_, int dst_, Weight weight_, const int id_) :
		src(src_), dst(dst_), weight(weight_), id(id_) { }
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
	Edge() :src(0), dst(0), weight(0) {

	}
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])

//流量0の逆辺も張らないと正しく求まらないので注意
Weight maximumFlow(const Graph &ag, int s, int t) {

	Graph g(ag);
	for (int i = 0; i < ag.size(); ++i) {
		for (int j = 0; j < ag[i].size(); ++j) {
			int d = ag[i][j].dst;
			int s = ag[i][j].src;

			bool ok = false;
			for (int k = 0; k < ag[d].size(); ++k) {
				if (ag[d][k].src == s) {
					ok = true;
					break;
				}
			}
			if (!ok) {
				g[d].push_back(Edge(d, s, ZERO));
			}
		}
	}
	int n = g.size();
	Matrix flow(n, Array(n,ZERO)), capacity(n, Array(n,ZERO));
	REP(u, n) FOR(e, g[u]) capacity[e->src][e->dst] =capacity[e->src][e->dst]+ e->weight;


	Weight total = ZERO;
	while (1) {
		queue<int> Q; Q.push(s);
		vector<int> prev(n, -1); prev[s] = s;
		while (!Q.empty() && prev[t] < 0) {
			int u = Q.front(); Q.pop();
			FOR(e, g[u]) if (prev[e->dst] < 0 && RESIDUE(u, e->dst) > ZERO) {
				prev[e->dst] = u;
				Q.push(e->dst);
			}
		}
		if (prev[t] < 0)break; // prev[x] == -1 <=> t-side
		Weight inc = INF;
		for (int j = t; prev[j] != j; j = prev[j]){
			auto v(RESIDUE(prev[j], j));
			if (inc > v) {
				inc = v;
			}
		}
		for (int j = t; prev[j] != j; j = prev[j])
			flow[prev[j]][j] =flow[prev[j]][j]+inc, flow[j][prev[j]] =flow[j][prev[j]]- inc;;
		total += inc;
	}

	return total;
}
int main() {
	int H,W;cin>>H>>W;
	vector<vector<int>>edges(H+W+2);
	vector<string>sts;
	for (int i = 0; i < H; ++i) {
		string st;cin>>st;
		sts.emplace_back(st);
		
	}
	int ans=0;
	Graph g(H+W+2);
	
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			char ch = sts[i][j];
			vector<int>v;
			
			if (ch == 'o') {
				g[i].push_back(Edge(i,H+j,1));
				g[H+j].push_back(Edge(H+j,i,1));
				
			}
			else if (ch == 'S') {
				g[H+W].push_back(Edge(H+W,i,10000));
				g[H+W].push_back(Edge(H+W,H+j,10000));
			}
			else if (ch == 'T') {
				g[i].push_back(Edge(i,H+W+1,10099));
				g[H+j].push_back(Edge(H+j,H+W+1,10099));
			}
		}
	}
	ans=maximumFlow(g,H+W,H+W+1);
	if(ans>1000)ans=-1;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1664
import sys
import math
from collections import Counter
import heapq
for _ in range(1):
    n=int(input())
    s=list(input())
    ptr=0
    while(ptr<n and s[ptr]=="R"):ptr+=1
    if ptr==n:
        print(0)
        exit(0)
    k=ptr
    ptr=n-1
    while(ptr>=0 and s[ptr]=="W"):
        ptr-=1
    if ptr==-1:
        print(0)
        exit(0)
    l=ptr
    ans=0
    while(k<l):
        if s[k]=="W" and s[l]=="R":
            s[k],s[l]=s[l],s[k]
            k+=1
            l-=1
            ans+=1

        elif s[k]=="R":
            k+=1
        elif s[l]=="W":
            l-=1
    print(ans)
    
        


Measured memory_bytes: 71536
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 10000
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;
const ll mod=1e9+7;
unordered_map<ll,int>mp;
int main()
{
   FAST;
   bool flag=1;
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
      ll tmp;
      cin>>tmp;
      mp[tmp]++;
   }
   int m;
   cin>>m;
   for(int i=0;i<m;i++){
      ll tmp;
      cin>>tmp;
      if(mp[tmp]>=1)mp[tmp]--;
      else{
         flag=0;
         break;
      }
   }
   if(flag)
   cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 8520
'''
問題：
    高橋君と青木君がモンスターを闘わせます。

    高橋君のモンスターは体力が A で攻撃力が B です。
    青木君のモンスターは体力が C で攻撃力が D です。

    高橋君→青木君→高橋君→青木君→... の順に攻撃を行います。
    攻撃とは、相手のモンスターの体力の値を自分のモンスターの攻撃力のぶんだけ減らすことをいいます。
    このことをどちらかのモンスターの体力が 0 以下になるまで続けたとき、
    先に自分のモンスターの体力が 0 以下になった方の負け、そうでない方の勝ちです。

    高橋君が勝つなら Yes、負けるなら No を出力してください。
'''

'''
制約：
    1 ≦ A, B, C, D ≦ 100
    入力は全て整数である
'''
class Monster:
    def __init__(self, hp, power):
        self.hp = hp
        self.power = power

    def fight(self, power)  -> int:
        self.hp -= power
        return self.hp

    def is_loser(self)   -> bool:
        return self.hp <= 0

# 標準入力から A, B, C, D を取得する
a, b, c, d = map(int, input().split())

takahashi_monster = Monster(a, b)   # 高橋モンスター
aoki_monster = Monster(c, d)    # 青木モンスター
result = "ret"

while True:
    aoki_monster.fight(b)   # 高橋の攻撃
    if aoki_monster.is_loser():
        result = "Yes"
        break
    else:
        pass

    takahashi_monster.fight(d)  # 青木の攻撃
    if takahashi_monster.is_loser():
        result = "No"
        break
    else:
        pass

print(result)


Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int n = 2, tmp = 1, node;
  while(N > tmp){
    tmp += n;
    n++;
  }
  if(tmp == N){
    node = n;
  }else{
    cout << "No" << endl;
    return 0;
  }
  vector<vector<int> > ans(node, vector<int>(node, 0));
  int eNum= 1; // 最終的にNになる
  for(int i = 0; i < node-1; i++){
    for(int j = i+1; j < node; j++){
      ans[i][j] = eNum;
      ans[j][i] = eNum;
      eNum++;
    }
  }
  cout << "Yes" << endl;
  cout << node << endl;
  REP(i, node){
    cout << node - 1 << " ";
    REP(j, node){
      if(ans[i][j] != 0){
        cout << ans[i][j] << " ";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n;int a[2][100];
int main(){
	cin >> n;
	int ans = 0;
	REP(i,2) {
		REP(j,n) {
			cin >> a[i][j];
		}
	}
	REP(i,n) {
		int sum = 0;
		REP(j,i + 1) {
			sum += a[0][j] ;
		}

		sum += a[1][i];

		FOR(j,i + 1,n) {
			sum += a[1][j];
		}
		ans = max(sum,ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  cin>>S;
  ll N=S.size();
  S="0"+S;
  
  // 桁DP[i][j]=i番目まで見た時の最小値、j=0ならばピッタリ
  ll DP[N+1][2];
  DP[0][0]=0;
  DP[0][1]=1;
  
  RREP(i,N){
    DP[i][0]=min(DP[i-1][0]+S[i]-'0',DP[i-1][1]+10-(S[i]-'0'));
    DP[i][1]=min(DP[i-1][0]+S[i]-'0'+1,DP[i-1][1]+9-(S[i]-'0'));
  }
  
  co(DP[N][0]);
  return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  string s, ans;
  cin >> s;

  int n = in();
  for (int i = 0; i < s.size(); i += n) ans += s[i];
  cout << ans << endl;
}


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

using namespace std;
#define ll long long int

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

  ll ans = 1;
  for ( int i = 0; i < n; ++i ) {
    if ( i == 0) ans *= k;
    else ans *= ( k - 1 );
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i=0; i<s.size(); i++) {
		cnt += (s[i] != t[i]);
	}
	cout << cnt;
}


Measured memory_bytes: 3916
#include<cstdio>
 
int main(){
  int n, a, ans = 32, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a);
    for(j = 0; !(a&1); j++, a >>= 1);
    ans = (ans < j ? ans : j);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);
  printf("%d %d %d\n", x, y, z);
  return 0;
}

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

int main(){
  int n;
  int ac=0,wa=0,tle=0,re=0;
  cin >> n;
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s == "AC"){
      ac++;
    }else if(s == "WA"){
      wa++;
    }else if(s == "TLE"){
      tle++;
    }else{
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define N 100
#define inf 20000000
#define NIL -1
#define WHITE 1
#define BLACK 0

int n,w[N][N];

int prim(void){
  int i,sum=0,mincost,u,v,d[N],pi[N],color[N];
  for(u=0 ; u<n ; u++){
    d[u] = inf;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = inf;
    for(i=0 ; i<n ; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == inf) break;

    color[u] = BLACK;
    
    for(v=0 ; v<n ; v++){
      if (color[v] != BLACK && w[u][v] < d[v] && w[u][v]!=NIL){
      pi[v] = u;
      d[v] = w[u][v];
      }
    }
  }
  for(i=0 ; i<n ; i++){
        sum+=d[i];
    }
    return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);
  
  for(i=0 ;i<n ; i++){
    for(j=0 ;j<n ; j++){
      scanf("%d",&w[i][j]);
      if(w[i][j]==-1) w[i][j]=inf;
      }
  }
  printf("%d\n",prim());
     
  return 0;
}
 



Measured memory_bytes: 2104
from decimal import Decimal
def waru(N,num):
  cnt = 0
  while N%num==0:
    N //= num
    cnt += 1
  return cnt
def solve():
  N = int(input())
  num = [[0]*101 for _ in range(101)]
  lis = [0]*N
  for i in range(N):
    a = input()
    b = a.split(".")
    if len(b)==1:
        a = int(a)*(10**9)
    else:
        a = int(b[0] + b[1] + (9-len(b[1]))*"0")
    two,five = waru(a,2)-9,waru(a,5)-9
    two -= 50
    five -= 50
    num[two][five] += 1
    lis[i] = [two,five]
  cum2 = [[0]*101 for _ in range(101)]
  for i in range(99,-1,-1):
    for j in range(99,-1,-1):
      cum2[i][j] = cum2[i+1][j]+cum2[i][j+1]-cum2[i+1][j+1]+num[i][j]
  ans = 0
  for i in range(N):
    two,five = lis[i]
    two2,five2 = -(two+50)-50,-(five+50)-50
    ans += cum2[two2][five2]
    if two+50>=0 and five+50>=0:
      ans -= 1
  return ans//2
print(solve())

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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0,rep,cnt,sad;
char c;
string s,s2;
vector <ll> V;

int main()
{
    cin >> s >> s2;
    for (int i=0;i<s.size();i++){
        if (s[i]!=s2[i]) sol++;
    }
    cout << sol;
}



Measured memory_bytes: 3868
a, b, c, d = [int(i) for i in input()]
for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            ans = a
            if op1 == '+':
                ans += b
            else:
                ans -= b
            if op2 == '+':
                ans += c
            else:
                ans -= c
            if op3 == '+':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + '=7')
                exit()

Measured memory_bytes: 3064
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


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

    int a,b,c; cin >> a >> b >> c;
    swap(a,b); swap(a,c);
    cout << a << " " << b << " " << c << endl;
}

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

int main() {
    /* Input */
    long long A;
    long long b1, b2;
    char ch;
    cin >> A >> b1 >> ch >> b2;
    
    /* Main Logic */
    long long B = b1 * 100 + b2;
    long long ans = (A * B) / 100;

    /* Output */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long A, long long B, long long C, long long K)
{
  LL ans = 0;
  ans += min(A, K);
  K -= A;
  if (K >= 0)
  {
    K -= B;
  }
  if (K >= 0)
  {
    ans -= K;
  }
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long K;
  scanf("%lld", &K);
  solve(A, B, C, K);
  return 0;
}


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

int main(){
    int a, b;
    
    cin>> a >> b;
    
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;

    return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define IREP(i,j,n) for(int (i)=(j);(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int n, m;
vector<int> adj[10];

bool connected(int i, int j) {
    int f = false;
    REP(k,adj[i].size()) {
        if (adj[i][k] == j) f = true;
    }
    return f;
}

int main() {
    cin >> n >> m;
    int a, b;
    REP(i,m) {
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    int cnt = 0;
    vector<int> v;
    REP(i,n) {
        v.push_back(i);
    }
    
    do {
        int c = true;
        REP(i,v.size()-1) {
            if (!connected(v[i], v[i+1])) {
                c = false;
            }
        }
        if (v[0] == 0 && c) cnt++;
    } while (next_permutation(v.begin(), v.end()));
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    higher_peeks = [0] * N

    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] > H[B-1]:
            higher_peeks[B-1] += 1
        elif H[A-1] < H[B-1]:
            higher_peeks[A-1] += 1
        else:
            higher_peeks[A-1] += 1
            higher_peeks[B-1] += 1

    ans = 0
    for i in higher_peeks:
        if i == 0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 20032
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, k;
    cin >> n >> k;
    int gcd = 0;
    const int INF = 1e9 + 7;
    int mn = INF, mx = -1;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        gcd = __gcd(gcd, x);
        mn = min(mn, x); mx = max(mx, x);
    }   
    if (k % gcd == 0 && mn <= k && k <= mx) {
        cout << "POSSIBLE\n";
    }   
    else {
        cout << "IMPOSSIBLE\n";
    }   
}   

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

  
  
    int main(){
      long x;
      cin >>x;
      
      while(1){
        bool f = true;
      for(int i=2;i*i<x;i++){
        
        if(x%i == 0){
          x++;
          f = false;
          break;
          
        }
        
      }
      if(f)break;
      }
      cout << x;
    }
      


    


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int coins = 0;
		for (int i = 0; i < 2; i++) {
			if (a > b) {
				coins += a;
				a--;
			} else {
				coins += b;
				b--;
			}
		}
		System.out.println(coins);
	}
}


Measured memory_bytes: 23892
k = int(input())
n = 7
c = 1
if(k%2 == 0):
  print(-1)
else:
  while(True):
    if(n%k == 0):
      break
    if(c > k):
      c = -1
      break
    r = n%k
    n = 10*r+7
    c += 1
  print(c)

Measured memory_bytes: 9168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main() {
	int t, i, j, k;
	int a, b, c ,d,F=0;
	string A,D,E;
	char B,C;
	cin >> A;

	a = A.size();

	a -= 2;
	cout << A[0]<< a << A[a+1]  << endl;
	return 0;
}

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

void replaceAll(string &str, string from, string to) {
  int pos = str.find(from);
  if (pos == -1) return;

  str.replace(pos, from.size(), to);
  replaceAll(str, from, to);
}

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

  replaceAll(s, "eraser", "");
  replaceAll(s, "erase", "");
  replaceAll(s, "dreamer", "");
  replaceAll(s, "dream", "");

  if (s.empty()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int q;
    cin>>q;
    ll b=0;
    multiset<int> leq,gt;
    ll left_sum=0;
    ll right_sum=0;
    while(q--){
        int op;
        cin>>op;
        if(op==1){
            int a,bi;
            cin>>a>>bi;
            b+=bi;
            if(!gt.empty()&&a>(*begin(gt))){
                gt.insert(a);
                right_sum+=a;
            }else{
                leq.insert(a);
                left_sum+=a;
            }

            while(gt.size()>leq.size()){
                int x=*begin(gt);
                gt.erase(begin(gt));
                right_sum-=x;
                left_sum+=x;
                leq.insert(x);
            }

            while(leq.size()-1>gt.size()){
                int x=*prev(end(leq));
                leq.erase(prev(end(leq)));
                left_sum-=x;
                right_sum+=x;
                gt.insert(x);
            }
        }else{
            int x=*prev(end(leq));
            ll cost=b+1ll*x*leq.size()-left_sum+right_sum-1ll*x*gt.size();
            cout<<x<<" "<<cost<<endl;
        }
    }

}

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

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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;

  if(k > a + b){
    a = 0;
    b = 0;
  }
  else if(k > a){
    b = b - (k - a);
    a = 0;
  }
  else{
    a -= k;
  }

  cout << a << " " << b << endl;

  return 0;
}


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


struct S{
	string name;
	int point;
	bool operator<(const S& a)const{return point>a.point;}
}s[10];

int main(){
	int n;
	if(!(cin>>n&&n))return 0;
	while(1){
		for(int i=0;i<n;i++){
			cin>>s[i].name;
			int a,b,c;
			cin>>a>>b>>c;
			s[i].point=a*3+c;
		}
		stable_sort(s,s+n);
		for(int i=0;i<n;i++){
			cout<<s[i].name<<','<<s[i].point<<endl;
		}
		if(cin>>n&&n)cout<<endl;
		else break;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

void solve() {
	int n; cin >> n;
	vector<int> a(n),b(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		if (a[i] > b[i]) {
			cout << -1 << endl; return;
		}
	}
	ll ans = 0;
	rep(aa, 100) {
		rep(i, n) {
			int l = b[(i - 1 + n) % n];
			int r = b[(i + 1) % n];
			if (b[i] > (l + r)) {
				int re = b[i] % (l + r);
				if (re < a[i]) {
					if ((b[i] - a[i]) % (l + r) == 0) {
						ans += (b[i] - a[i]) / (l + r);
						b[i] = a[i];
					}
					else {
						cout << -1 << endl; return;
					}
				}
				else {
					ans += b[i] / (l + r);
					b[i] = re;
				}
			}
		}
		per(i, n) {
			int l = b[(i - 1 + n) % n];
			int r = b[(i + 1) % n];
			if (b[i] > (l + r)) {
				int re = b[i] % (l + r);
				if (re < a[i]) {
					if ((b[i] - a[i]) % (l + r) == 0) {
						ans += (b[i] - a[i]) / (l + r);
						b[i] = a[i];
					}
					else {
						cout << -1 << endl; return;
					}
				}
				else {
					ans += b[i] / (l + r);
					b[i] = re;
				}
			}
		}
	}
	rep(i, n) {
		if (a[i] != b[i]) {
			cout << -1 << endl; return;
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 1792
def print_inner(w)
  (1..w).map { |i|
    if i == 1 || i == w
      '#'
    else
      '.'
    end
  }
  .join
end

def print_frame(h, w)
  (1..h).each do |i|
    if i == 1 || i == h
      puts "#{'#' * w}"
    else
      puts print_inner(w)
    end
  end
  puts ""
end

loop do
  h, w = gets.split.map(&:to_i)
  break if h == 0 && w == 0

  print_frame(h, w)
end



Measured memory_bytes: 6912
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,rs=0,rsp,mj[1000];
string s[3],kari;

int main(){
    cin>>n;
    for(int i=0;i<3;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        for(int j=int('a');j<=int('z');j++){
            mj[j]=0;
        }
        for(int j=0;j<3;j++){
            
            mj[int(s[j][i])]=(mj[int(s[j][i])]+1);
        }
        for(int j=int('a');j<=int('z');j++){
            if(j==int('a'))rsp=mj[j];
            else rsp=max(rsp,mj[j]);
        }
        rs+=rsp;
        
    }
    cout<<n*3-rs<<endl;
    
    
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
       
int main(){
int a , b , c;
cin >> a >> b >> c;
       
     if( a <= b && b <= c ) cout << a << " " << b << " " << c << endl;
else if( b <= a && a <= c ) cout << b << " " << a << " " << c << endl;
else if( a <= c && c <= b ) cout << a << " " << c << " " << b << endl;
else if( b <= c && c <= a ) cout << b << " " << c << " " << a << endl;
else if( c <= a && a <= b ) cout << c << " " << a << " " << b << endl;
else                        cout << c << " " << b << " " << a << endl;
       
return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
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;}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a+b-n, 0) << endl;    
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1, 0);

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

    long ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int left = min(A[i], B[i]);
        ans += left;
        A[i] -= left;
        B[i] -= left;
        int right = min(A[i + 1], B[i]);
        ans += right;
        A[i+1] -= right;
        B[i] -= right;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,m,T;
vector<pii> g[125252];
pair<int,pii> es[252521];
bool reachable[125252];

int data[125252];
int lastmerged[125252];
ll score[125252];
int root(int x){
  return data[x]<0?x:data[x]=root(data[x]);
}
void unite(int a,int b,int t){
  a=root(a);
  b=root(b);
  if(a!=b){
    if(data[a]>data[b])swap(a,b);
    if(score[a]>=0){
      int spent = lastmerged[a] - t;
      score[a] += (ll)spent * (-data[a]);
    }
    if(score[b]>=0){
      int spent = lastmerged[b] - t;
      score[b] += (ll)spent * (-data[b]);
    }
    data[a] += data[b];
    data[b] = a;
    CHMAX(score[a], score[b]);
    lastmerged[a] = t;
  }
}

int main(){
  scanf("%d%d%d",&n,&m,&T);
  REP(i,m){
    int a,b,t;
    scanf("%d%d%d",&a,&b,&t);
    --a;--b;
    g[a].push_back(pii(b,t));
    g[b].push_back(pii(a,t));
    es[i] = make_pair(t,pii(a,b));
  }
  reachable[0] = true;
  queue<pii> Q;
  Q.push(pii(0,0));
  while(!Q.empty()){
    pii P = Q.front(); Q.pop();
    int pos = P.first;
    int t = P.second;
    for(pii R : g[pos]){
      int to = R.first;
      int lost = R.second;
      if(lost<=t)continue;
      if(reachable[to])continue;
      reachable[to] = true;
      Q.push(pii(to,t+1));
    }
  }

  REP(i,n)data[i]=-1;
  REP(i,n){
    lastmerged[i] = T;
    if(reachable[i]){
      score[i] = 0;
    }else{
      score[i] = -2521830;
    }
  }
  sort(es,es+m);
  FORR(i,0,m){
    int a = es[i].second.first;
    int b = es[i].second.second;
    unite(a,b,es[i].first);
  }
  ll ans = score[root(0)] + (ll)n * lastmerged[root(0)];
  printf("%lld\n",ans);
  return 0;
}

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

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

  string ans;
  vector<string> v;
  for(int i = 0; i < s.size(); ++i) {
    string st;
    for(int j = 0; j < 6 && i + j < s.size(); ++j) {
      st += s[i+j];
      v.push_back(st);
    }
  }

  sort(v.begin(), v.end());
  unique(v.begin(), v.end());

  cout << v[k-1] << endl;
  return 0;
}


Measured memory_bytes: 1916
import sys

n, m, *ab = map(int, sys.stdin.read().split())
graph = [set() for _  in range(n)]
for a, b in zip(*[iter(ab)] * 2):
    a -= 1; b -= 1
    graph[a].add(b); graph[b].add(a)

def main():
    stack = [i for i in range(n) if len(graph[i]) == 1]
    bridges = 0
    while stack:
        x = stack.pop()
        if not graph[x]: continue
        y = graph[x].pop()
        graph[y].remove(x)
        bridges += 1
        if len(graph[y]) == 1:
            stack.append(y)
    print(bridges)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define mod 1000000007
#define mx 200001
//#define y 20
using namespace std;
typedef long long int ll;
# define f(i, n) for(int i = 0;i < n; ++i)
typedef long long int ll;

void input()
{
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}
int main()
{
    input();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

vector<ll>dv;
void divisor(ll n) {
	dv.clear();
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			if (i == n / i) {
				dv.push_back(i);
			}
			else {
				dv.push_back(i);
				dv.push_back(n / i);
			}
		}
	}
}

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n+1);
	rep(i, 0, n)cin >> a[i+1];

	vector<ll>ans(n+1);
	vector<ll>sum(n+1);
	for (ll i = n; i >= 1; i--) {
		ans[i] = ((sum[i]%2) == a[i]) ? 0 : 1;
		divisor(i);
		fore(x, dv) {
			sum[x] += ans[i];
		}
	}

	vector<int>b;
	rep(i, 1, n+1)if (ans[i])b.pb(i);
	puts(b.size());
	rep(i, 0, b.size()) {
		cout << b[i] << " ";
	}
	if (b.size())puts("");


	return 0;
}


Measured memory_bytes: 6140
A, B, C, X = [int(input()) for i in range(4)]
res = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + c * 50 == X:
                res += 1
print(res)

Measured memory_bytes: 3060
/*input
6 2 4
33189 87907 277349742
71616 46764 575306520
8801 53151 327161251
58589 4337 796697686
66854 17565 289910583
50598 35195 478112689
13919 88414 103962455
7953 69657 699253752
44255 98144 468443709
2332 42580 752437097
39752 19060 845062869
60126 74101 382963164
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 100005

int X, Y, Z;
vector<pair<int, int> > a;
int base = 0;
int sumx[N], sumy[N];

bool cmp(pair<int, int> x, pair<int, int> y) {
	return x.fi - x.se > y.fi - y.se;
}

ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> X >> Y >> Z;
	for (int i = 1; i <= X + Y + Z; i++) {
		int x, y, z; cin >> x >> y >> z;
		base += z;
		a.push_back(mp(x - z, y - z));
	}
	sort(a.begin(), a.end(), cmp);
	priority_queue<int, vector<int>, greater<int> > pq;
	int cursum = 0;
	for (int i = 1; i <= a.size(); i++) {
		int val = a[i - 1].fi;
		while (pq.size() >= X && pq.top() < val) {
			cursum -= pq.top();
			pq.pop();
		}
		if (pq.size() < X) pq.push(val), cursum += val;
		sumx[i] = cursum;
	}
	while (!pq.empty()) pq.pop(); cursum = 0;
	for (int i = a.size(); i >= 1; i--) {
		int val = a[i - 1].se;
		while (pq.size() >= Y && pq.top() < val) {
			cursum -= pq.top();
			pq.pop();
		}
		if (pq.size() < Y) pq.push(val), cursum += val;
		sumy[i] = cursum;
	}
	int ans = -1e18;
	for (int i = X; i <= X + Y + Z; i++) {
		if (X + Y + Z - i < Y) break;
		ans = max(ans, sumx[i] + sumy[i + 1]);
	}
	cout << base + ans << endl;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
const int maxn = 4e5 + 5;
int dist[maxn] , n , m;
vector<pii> E[maxn];
vector<pii> C[1000005];
int f[maxn];
int getf (int x){ return x == f[x] ? x : f[x] = getf(f[x]);}
void mer (int a , int b)
{
    int fa = getf(a) , fb = getf(b);
    if (fa == fb) return ;
    f[fb] = fa;
    return ;
}
struct Node
{
    ll num;
    ll dis;
    Node (int n = 0, ll d = 1e17){
        num = n;
        dis = d;
    }
    bool operator < (const Node & a) const {
        return dis > a.dis;
    }
};
int book[maxn];
priority_queue<Node>Q;
void Dijstra(int s){
    while(Q.size()) Q.pop();
    for (int i = 1 ; i <= n ; i++)
        book[i] = 0 , dist[i] = -1;
    dist[s] = 0;
    Q.push(Node(s , 0));
    while(Q.size())
    {
        Node temp = Q.top() ; Q.pop();
        int num = temp.num;
        if (book[num]) continue;
    //    cout << "现在在" << num << "点，它的答案是" << dist[num] << endl;
        book[num] = 1;
        for (auto e : E[num]){
            int v = e.first , w = e.second;
            if (dist[v] == -1 || dist[v] > dist[num] + w){
                dist[v] = dist[num] + w;
                Q.push({v , dist[v]});
            }
        }
    }
    return ;
}
int vis[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    int o = n;
    for (int i = 1 ; i <= m ; i++){
        int x , y , z;cin >> x >> y >> z;
        C[z].pb (mp(x , y));
    }
    vector<int> node;
    int up = 1e6;
    for (int i = 1 ; i <= up ; i++){
        if (C[i].size() == 0) continue;
        node.clear();
        for (auto e : C[i]) node.push_back(e.first) , node.push_back(e.second);
        sort(node.begin() , node.end());
        node.erase(unique(node.begin(),node.end()),node.end());
        for (auto g : node) f[g] = g;
        for (auto e : C[i]) mer(e.first , e.second);
        for (auto g : node){
            int ff = getf(g);
            if (!vis[ff]) vis[ff] = ++n;
            E[g].pb(mp(vis[ff] , 1));
            E[vis[ff]].pb(mp(g , 0));
        }
        for (auto g : node) vis[getf(g)] = 0;
    }
    Dijstra(1);
    cout << dist[o] << endl;
    return 0;
}

Measured memory_bytes: 58796
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int N;
vector<int> A;

void input(void){
	cin >> N;
	A.resize(1 << N);
	for (auto& ai : A)
		cin >> ai;
}

using tiiii = tuple<int, int, int, int>;

tiiii merge(tiiii a, tiiii b){
	using pii = pair<int, int>;
	set<pii> st;
	st.insert({get<0>(a), get<1>(a)});
	st.insert({get<2>(a), get<3>(a)});
	st.insert({get<0>(b), get<1>(b)});
	st.insert({get<2>(b), get<3>(b)});
	vector<pii> res;
	for (auto p : st)
		res.push_back(p);
	reverse(res.begin(), res.end());
	return make_tuple(res[0].first, res[0].second, res[1].first, res[1].second);
}

int sum(tiiii t){
	return get<0>(t) + get<2>(t);
}

vector<int> solve(void){
	vector<vector<tiiii>> dp(1 << N, vector<tiiii>(N + 1));
	// 初期化
	for (int i = 0; i < (1 << N); ++i)
		dp[i][0] = make_tuple(A[i], i, 0, -1);
	// 遷移
	for (int j = 0; j < N; ++j){
		for (int i = 0; i < (1 << N); ++i){
			if (i & (1 << j))
				dp[i][j + 1] = merge(dp[i & ~(1 << j)][j], dp[i][j]);
			else dp[i][j + 1] = dp[i][j];
		}
	}
	vector<int> res(1 << N);
	res[0] = sum(dp[0][N]);
	for (int i = 1; i < (1 << N); ++i)
		res[i] = max(res[i - 1], sum(dp[i][N]));
	return res;
}

int main(void){
	input();
	vector<int> res = solve();
	for (int i = 1; i < (1 << N); ++i)
		cout << res[i] << endl;
	return 0;
}

Measured memory_bytes: 93292
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long ;
using ld=long double;
 
 
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<10;i++){
        int x=c*a-b;
        cout<<x<<endl;
        c=x;
    }
    
    return 0;
}

Measured memory_bytes: 256