akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint c(N),s(N),f(N);
    REP(i,N-1) cin>>c[i]>>s[i]>>f[i];

    for(int i=0;i<N;i++){
        int time=0,idx=i;
        while(idx!=N-1){
            time=max(time,s[idx]);
            time=(time+f[idx]-1)/f[idx]*f[idx];
            time+=c[idx++];
        }
        cout<<time<<endl;
    }

}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    int maxn=0,maxi=0;
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]>maxn)
        {
            maxn=arr[i];
            maxi=i;
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(i==maxi)
         continue;
         sum+=arr[i];
    }
    if(sum>maxn)
     cout<<"Yes\n";
     else
      cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <functional>
#include <cmath>
#include <utility>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int



// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}
 
int ans =0; int mn = 1000000001; int d,g,h; 
int p[10],c[10],s[10],sum[10];
using namespace std;

int main() {
   cin >> d >> g; 
   h = g;
  for(int i=0;i<d;i++){
    cin >> p[i] >> c[i];
    s[i] = p[i]*100*(i+1);
    sum[i] = s[i] + c[i];
  }
  
  

  foreach_permutation(d, [](int *indexes) {
    ans = 0;
    g = h;
    for(int j=0;j<d;j++){
      if(g <= sum[indexes[j]] && g > s[indexes[j]]){
        ans += p[indexes[j]];
        break;
      }
      if(g<= s[indexes[j]]){
        ans += (g+100*(indexes[j]+1)-1)/(100*(indexes[j]+1));
        break;
      }
      if(g > sum[indexes[j]]){
        ans += p[indexes[j]];
        g -= sum[indexes[j]];
      }
    }
    mn = min(mn,ans);
  });
  cout << mn;
    
 
 return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> s(n);
    rep(i,n){
        int a;
        cin >> a;
        s[i] = make_pair(a,i+1);
    }
    sort(s.begin(), s.end());
    rep(i,n) cout << s[i].second << ' ';
}

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

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

    if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ||
        (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ||
        (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]))  cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll x = N/(A + B);
  ll ans = 0;
  ans += x*A;
  ll amari = N - x*(A + B);
  if(amari >= A) ans += A;
  else ans += amari;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = np.zeros(N+1)

for i in range(N):
  B[A[i]]+=1
#print(B)

all_c = 0
for i in range(1,N+1):
  all_c += int(B[i]*(B[i]-1)/2)			# 同一の整数を持つボールの組合せ数
for i in range(N):
  if B[A[i]] != 0:
    print(int(all_c-(B[A[i]]-1)))


Measured memory_bytes: 34156
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/
int main(){
   int n , y;
   cin >> n >> y;
   bool flg = false;
   REP(i, n+1){
       REP(j, n+1){
           if(10000*i+5000*j+1000*(n-i-j)==y&&n-i-j>=0){
               cout << i << ' ' << j << ' ' << n-i-j << endl;
               flg = true;
               break;
           }
       }
    if(flg==true) break;
   }
   if(flg==false) cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 141 A - Weather Prediction
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/19
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string s;

void solve() {

    const static vector<string> WEATHERS = { "Sunny", "Cloudy", "Rainy", "Sunny"};

    for (auto itr=WEATHERS.begin();itr!=WEATHERS.end();++itr) {
        if (s == *itr) {
            cout << *++itr << "\n";
            return;
        }
    }

}

int main() {

    cin >> s;

    solve();

}

Measured memory_bytes: 2864
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll n, x = 0;
  cin >> n;
  vector<ll> v(n);
  rep(i, 0, n) {
    cin >> v[i];
    x ^= v[i];
  }
  rep(i, 0, n) cout << (v[i] ^ x) << " ";
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[11];
    buf[10] = '\n';
    int i = 9;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
  if(g==0)return 1;

  if(g%2==1)return (num*power((num*num),g/2));
  return power((num*num),g/2);
}
int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int a,b,c;
  cin>>a>>b>>c;
  for(int i=min(a,b);i>0;i--)
  {
    if(a%i==0 && b%i==0)
    {
      c--;
    }
    if(c==0)
    {
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
	string a;
	cin >> a;
	if(a == "SUN"){
	  cout << 7;
	}
	else if(a == "MON"){
	  cout << 6;
	}
	else if(a == "TUE"){
	  cout << 5;
	}
	else if(a == "WED"){
	  cout << 4;
	}
	else if(a == "THU"){
	  cout << 3;
	}
	else if(a == "FRI"){
	  cout << 2;
	}
	else{
	  cout << 1;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		//
		// 0, 1, 2
		// 3, 4, 5
		// 6, 7, 8
		//
		List<Integer> A = new ArrayList<Integer>();
        for (int i=0; i<9; i++) {
            A.add(sc.nextInt());
       }

		int N = sc.nextInt();
        for (int i=0; i<N; i++) {
       		// 登場したら0に変える
        	int index = A.indexOf(sc.nextInt());
        	if(index != -1){
            	A.set(index, 0);
        	}
        }
        
        // 判定
        boolean isBingo = false;
        if(A.get(0)==0 && A.get(1)==0 && A.get(2)==0){
        	isBingo = true;
        }else if(A.get(3)==0 && A.get(4)==0 && A.get(5)==0){
        	isBingo = true;
        }else if(A.get(6)==0 && A.get(7)==0 && A.get(8)==0){
        	isBingo = true;
        }else if(A.get(0)==0 && A.get(3)==0 && A.get(6)==0){
        	isBingo = true;
        }else if(A.get(1)==0 && A.get(4)==0 && A.get(7)==0){
        	isBingo = true;
        }else if(A.get(2)==0 && A.get(5)==0 && A.get(8)==0){
        	isBingo = true;
        }else if(A.get(0)==0 && A.get(4)==0 && A.get(8)==0){
        	isBingo = true;
        }else if(A.get(2)==0 && A.get(4)==0 && A.get(6)==0){
        	isBingo = true;
        }

        if(isBingo){
    		System.out.println("Yes");
        }else{
    		System.out.println("No");
        }
		sc.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
string s;
long mod=1e9+7,dp[1<<17][13];
main()
{
	dp[0][0]=1;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		for(int j=0;j<13;j++)
		{
			if(s[i]=='?')
			{
				for(int k=0;k<10;k++)
				{
					(dp[i+1][(j*10+k)%13]+=dp[i][j])%=mod;
				}
			}
			else
			{
				(dp[i+1][(j*10+s[i]-'0')%13]+=dp[i][j])%=mod;
			}
		}
	}
	cout<<dp[s.size()][5]<<endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> h(n + 1); h[n] = 1001001001;
  for (int i = 0; i < n; i++) cin >> h[i];
  int prev = 0;
  int res = 0;
  int cnt = 0;
  for (int i = 0; i < n + 1; i++) {
    if (h[i] > prev) {
      res = max(res, cnt);
      cnt = 0;
    } else {
      cnt++;
    }
    prev = h[i];
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
int p[101010];

int main() {
  cin >> N;
  rep(i, 0, N) { cin >> p[i]; }
  int ans = 0;
  rep(i, 0, N - 1) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      ++ans;
    }
  }
  if (p[N - 1] == N) {
    ++ans;
  }
  cout << ans;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W;
    vector<vector<ll>> c(10, vector<ll>(10));
    cin >> H >> W;
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    ll ans = 0;
    rep(h, H) {
        rep(w, W) {
            ll temp;
            cin >> temp;
            if(temp != -1) ans += c[temp][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
n = int(input()) 
a = list(map(int,input().split())) 
a = sorted(a)
mod = 10**9+7
if n%2==0:
    k = 0
else:
    k = 1
if k==0:
    for i in range(1,n,2):
        if a[i]!=i or a[i-1]!=i:
            print(0)
            exit()
    else:
        print(2**(n//2)%mod)
else:
    if a[0]!=0:
        print(0)
        exit()
    else:
        for i in range(2,n,2):
            if a[i-1]!=i or a[i]!=i:
                print(0)
                exit()
        else:
            print(2**(n//2)%mod)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  bool dis = true;
  
  for(int i = 0; i < n - 1; i++){
    if(a.at(i) == a.at(i + 1)) dis = false;
  }
  
  if(dis) cout << "YES" <<endl;
  else cout << "NO" << endl;
}

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

using namespace std;

const long long INF = 1000000000000000000;
const long long THRESHOLD = 10000000000;

void Main() {
    long long V, E;
    cin >> V >> E;
    vector<vector<long long>> D(V, vector<long long>(V, INF));
    for (long long i = 0; i < E; ++i) {
        long long s, t, d;
        cin >> s >> t >> d;
        D[s][t] = d;
    }
    for (long long i = 0; i < V; ++i) {
        D[i][i] = 0;
    }

    for (long long k = 0; k < V; ++k) {
        for (long long i = 0; i < V; ++i) {
            for (long long j = 0; j < V; ++j) {
                long long via = D[i][k] + D[k][j];
                if (THRESHOLD < via) {
                    via = INF;
                }
                else {
                    D[i][j] = min(D[i][j], via);
                }
            }
        }
    }

    for (long long i = 0; i < V; ++i) {
        if (D[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return;
        }
    }

    for (long long i = 0; i < V; ++i) {
        for (long long j = 0; j < V; ++j) {
            if (j > 0) {
                cout << " ";
            }
            if (D[i][j] < INF) {
                cout << D[i][j];
            }
            else {
                cout << "INF";
            }
        }
        cout << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 3232
dic_words = {}
for i in range(0, int(input())):
    word = input()
    if word in dic_words.keys():
        dic_words[word] += 1
    else:
        dic_words[word] = 1

for i in range(0, int(input())):
    word = input()
    if word in dic_words.keys():
        dic_words[word] -= 1
    else:
        dic_words[word] = -1

if (max(dic_words.values()) >= 0):
    print(max(dic_words.values()))
else:
    print(0)

Measured memory_bytes: 3064
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next

  val ans = s.foldLeft(("", false)){
    (acc, value) =>
      if (acc._2 || acc._1 == value.toString)
        (value.toString, true)
      else
        (value.toString, false)}

  if (ans._2) println("Bad") else println("Good")
}

Measured memory_bytes: 25424
N, Q = map(int, input().split())
S = input()
cnt = [0] * N

for i in range(1, N):
    cnt[i] = cnt[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(cnt[r-1] - cnt[l-1])

print('\n'.join(list(map(str, ans))))

Measured memory_bytes: 18004
#pragma region Template
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}
#pragma endregion Template

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

    int N, K, S;
    scan(N, K, S);

    vector<int> ans(N);
    int cnt = 0;
    rep(i, N) {
        if (cnt < K) {
            ans[i] = S;
            cnt++;
        } else {
            if (S < (int)1e5)
                ans[i] = (int)1e5;
            else {
                ans[i] = 1;
            }
        }
    }
    print(ans);

    return 0;
}

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

xlist=[]
sum=0
for i in range(n):
    xlist.append(input().split())
    if xlist[i][1] == "BTC":
        sum = sum + float(xlist[i][0])*380000
    else:
        sum = sum + float(xlist[i][0])

print(sum)


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

int main()
{
    int cnt,c,i;
    cin>>s;
    cnt=c=0;
    for(i=0; i<s.size(); i++)
    {
        if(s[i]=='+')c++;
        else cnt++;
    }
    cout<<c-cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import GHC.Exts

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray array i f =  writeArray array i =<< f <$> readArray array i

main = do
	n <- readInt
	as <- readInts
	let
		f = map fst . filter snd . zip as . cycle
		evens = f [ True, False ]
		odds  = f [ False, True ]
	print $ minimum' ( n `div` 2 ) $ do
		( a, c1 ) <- take 2 $ majors evens
		( b, c2 ) <- take 2 $ majors odds
		guard $ a /= b
		return $ n - c1 - c2

majors as = runST $ do
	counts <- newArray ( 0, maximum as + 1 ) 0 :: ST s ( STUArray s Int Int )
	forM_ as $ \a -> do
		modifyArray counts a succ
	reverse . sortWith snd . filter ( ( 0 < ) . snd ) <$> getAssocs counts

minimum' a [] = a
minimum' _ as = minimum as


Measured memory_bytes: 29052
N,M = map(int,input().split())
lr = []
for i in range(M):
    lr.append(list(map(int, input().split())))

l = []
for i in range(M):
    l.append(lr[i][0])

r = []
for i in range(M):
    r.append(lr[i][1])

print(max(0, min(r)-max(l)+1))

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

int main() {

    int n;

    cin >> n;

    set<int> s;

    while(n--){
        int a;
        cin >> a;
        set<int>::iterator itr = s.find(a);
        if(itr == s.end()){
            s.insert(a);
        }
        else{
            s.erase(itr);
        }
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <climits>
using namespace std;

char s[200002];
int dp[1 << 26];

int main(){
  scanf("%s", s + 1); int L = strlen(s + 1);

  int M = 1 << 26;

  for(int i = 0; i < M; i++) dp[i] = INT_MAX;

  dp[0] = 0; int v = 0;

  for(int l = 1; l <= L; l++){
    v ^= 1 << (s[l] - 'a');

    for(int i = 0; i < 26; i++){
      int w = v ^ 1 << i;

      if(dp[w] != INT_MAX && dp[w] + 1 < dp[v]) dp[v] = dp[w] + 1;
    }
  }

  dp[0] = 1; printf("%d\n", dp[v]);
  return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    string ans = "";
    rep(i,n){
        if(s[i] == s[i+1]) continue;
        else ans.push_back(s[i+1]);
    }
    cout << ans.size() << endl;
}

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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  
  if (A > B) {
    cout << 0 << endl;
  } else if (N == 1) {
    if (A == B) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    cout << ((N - 1)*B + A) - ((N-1)*A + B) + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    ios::sync_with_stdio(false);
    int n,l=1,s=-1;
    cin>>n;
    for(register int i=1;i<=n;i++) cin>>a[i];
    while(l!=a[l])
    {
        s++;
        if(a[l]== 2) break;
        if(s>n){s=-1;break;}
        l=a[l];
    }
    if(s>=0) s++;
    cout<<s;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main() {
    int n, h[100000], i;
    cin >> n;
    for (i=0;i<n;i++) cin >> h[i];
    
    int counter = 0, max_c=0;
    for (i=1;i<n;i++){
        if (h[i-1] >= h[i]){
            counter++;
            if (counter > max_c)
                max_c = counter;
        }
        else{
            counter = 0;
        }
    }
    cout << max_c << endl;
}



Measured memory_bytes: 640
import math
N=int(input())
L=list(map(int,input().split()))
a=0
mod=10**9+7
s=math.factorial(N-1)
ans=[s%mod]
for i in range(2,N):
  ans.append((ans[-1]+(ans[0]*pow(i,-1,mod)))%mod)
ans2=0
for i in range(N-1):
  ans2+=((L[i+1]-L[i])*ans[i])%mod
print(ans2%mod)

Measured memory_bytes: 20368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// Scanner scan = new Scanner(System.in);
		// int n = scan.nextInt();
		for (int x = 1; x < 10; x++)
			for (int y = 1; y < 10; y++)
				System.out.println(x + "x" + y + "=" + x * y);
		System.exit(0);
	}
}

Measured memory_bytes: 24288
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define endl "\n"
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const long long INF = 8e18 + 8;
const double EPS = 1e-9;
const long long MOD = 998244353;

void solve() {
    string s; cin >> s;
    int n = sz(s);
    for (int let = 0; let < 26; let++) {
        char c = char(let + 'a');
        int l = -1;
        for (int i = 0; i < n; i++) {
            if (s[i] == c) {
                if (l == -1) l = i;
                else {
                    cout << l + 1 << " " << i + 1 << endl;
                    return;
                }
            } else {
                if (l < i - 1) l = -1;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
}

int main() {
    jonathan; 
    livingston;
    bool tests = 0;
    int t = 1;
    if (tests) cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ld a, b;
    scan(a, b);
    int ans = ceil((a + b) / 2);
    print(ans);

    return 0;
}

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 = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(){
  int n,m,x;cin>>n>>m>>x;
  vector<vector<int>>b(n, vector<int>(m));
  vector<int>p(n);
  rep(i, n){
    cin>>p[i];
    rep(j, m)cin>>b[i][j];
  }

  int price=INF;
  rep(bit, 1<<n){
    vector<int>u(m);
    int tp=0;
    rep(i, n){
      if(bit>>i & 1){
        rep(j, m)u[j]+=b[i][j];
        tp += p[i];
      }
    }
    bool f = true;
    rep(i, m)if(u[i]<x)f=false;
    if(f)price = min(price, tp);
  }

  if(price==INF)cout<<-1<<endl;
  else cout<<price<<endl;

  return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

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


Measured memory_bytes: 3668
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
ll longinf=1ll<<60;
int inf=1<<29;

 
int main(){
    ll n;
    cin>>n;
    ll a[n+1];
    rep0(i,n+1) cin>>a[i];
    ll b[n];
    rep0(i,n) cin>>b[i];
    ll ans=0;
    rep0(i,n){
        if(b[i]>a[i]){
            ans+=a[i];
            b[i]-=a[i];
            ans+=min(a[i+1],b[i]);
            a[i+1]=max(0ll,a[i+1]-b[i]);
        }
        else{
            ans+=b[i];
            b[i]=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 59;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>N>>K>>Q;
    vec a(N), ord(N), sta(N);
    rep(i,N) cin>>a[i];
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll x, ll y){
        return a[x] < a[y];
    });
    set<ll> ID = {-1};
    ID.insert(N);

    vec range(0);
    mat r_id(2010,vec(2010));
    ll range_id = -1, ans = INF, last;
    rep(i,N){ //sort順にとる
        auto ite = ID.begin();
        last = *ite;
        ++ite;
        range.push_back(*ite - last - 1);
        ++range_id;
        rep(j,N){
            if(j == *ite){
                last = *ite;
                ++ite;
                range.push_back(*ite - last - 1);
                ++range_id;
            }else{
                r_id[i][j] = range_id;
            }
        }
        ll q = Q, temp, mini;
        reps(j,i,N){
            if(range[r_id[i][ord[j]]] >= K){
                if(q == Q) mini = a[ord[j]];
                temp = a[ord[j]];
                --range[r_id[i][ord[j]]];
                --q;
            }
            if(q == 0) break;
        }
        if(q == 0) {
            //cout<<i<<' '<<temp<<' '<<mini<<endl;
            ans = min(ans, temp - mini);
        }
        ID.insert(ord[i]);
        while(i + 1 < N){
            if(a[ord[i]] != a[ord[i+1]]) break;
            ID.insert(ord[i]);
            ++i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 50556
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ini(N);
  vi v(2,0);
  rep(i,N){
    ini(x); v[x%2]++;
  }
  v[0] += v[1] / 2;
  v[1] = v[1] % 2;
  v[0] = bool(v[0]);
  out(v[0] + v[1] - 1 ? "NO" : "YES");
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 500000
#define SENTINEL 1000000000
  
int S[MAX], count = 0;
  
void merge(int *, int, int, int);
void mergeSort(int *, int, int);

void mergeSort(int *A, int left, int right)
{
  int mid;
  
  if(left + 1 < right)
    {
      mid = (left + right) / 2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }
}
void merge(int *A, int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1], i, j, k;
  
  for(i = 0; i < n1; i++) L[i] = A[left + i];
    
  for(i = 0; i < n2; i++) R[i] = A[mid + i];
    
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
    count++;
  }
}
  
 
int main()
{
  int n, i, left, right;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &S[i]);

  left = 0;
  right = n;
  
  mergeSort(S, left, right);
  
  for(i = 0; i < n; i++){
    if(i < n - 1)printf("%d ", S[i]);
    else printf("%d\n%d\n", S[i], count);
  }
  
  return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
int main ( void ) {
	int a , b;
	cin >> a;
	if ( a == 1 ) {
		cout << "Yes" << endl;
		return 0;
	}
	for ( int i = 2 ; i <= 9 ; i++ ) 
		if ( a % i == 0 ) {
			if ( a / i <= 9 && a / i >= 1 ) { 
				cout << "Yes" << endl;
				return 0;
			}
		}
	cout << "No" << endl;
	return 0;
}

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

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    
    public static void main(String[] args) {
        int n = ni();
        int m = ni();
        int[][] s = new int[m+1][];
        s[0] = new int[0];
        
        for (int i = 1; i <= m; i++) {
            int k = ni();
            s[i] = new int[k+1];
            for (int j = 1; j <= k; j++)
                s[i][j] = ni();
        }
        
        int[] p = new int[m+1];
        for (int i = 1; i <= m; i++)
            p[i] = ni();
        
        
        int count = 0;
        for (int i = 0; i < Math.pow(2, n); i++)
            if (allOn(n, m, i, s, p))
                count++;
        
        so.println(count);
    }
    
    private static boolean allOn(int n, int m, int bits, int[][] s, int[] p) {
        for (int i = 1; i <= m; i++) {
            if (!on(n, bits, s[i], p[i]))
                return false;
        }
        return true;
    }
    
    private static boolean on(int n, int bits, int[] si, int pi) {
        int switchCount = 0;
        for (int i = 1; i < si.length; i++) {
            if (bitStands(bits, si[i])) {
                switchCount++;
            }
        }
        
        return switchCount % 2 == pi;
    }
    
    public static boolean bitStands(int bits, int digit) {
        return ((bits >> (digit-1)) & 1) == 1;
    }

    static class R implements Comparable<R>{
        String s;
        int p;
        int num;
        
        public R(String s, int p, int num) {
            this.s = s;
            this.p = p;
            this.num = num;
        }
        @Override
        public int compareTo(R that) {
            if (this.s.equals(that.s)) {
                return that.p - this.p;
            }
            return (this.s).compareTo(that.s);
        }
        
        @Override
        public String toString() {
            return this.num + " " + this.s + " " + this.p;
        }
    }

    
    private static int ni() {
        return sc.nextInt();
    }

    private static long nl() {
        return sc.nextLong();
    }

    private static String ns() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0);
    }

    private static long[] nlongs(int n, int padding) {
        long[] a = new long[padding + n];
        for (int i = 0; i < n; i++)
            a[padding + i] = ni();
        return a;
    }
}


Measured memory_bytes: 23248
while True:
    H, W = map(int, input().split())

    if(H == 0 and W == 0):
        break
    else:
        for i in range(H):
            for j in range(W):
                print("#", end="")
            else:
                print("", end="\n")
        else:
            print("", end="\n")


Measured memory_bytes: 7012
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int w, n;
int a[35];

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

	for (int i = 0; i < w; i++) {
		a[i] = i;
	}

	int ai, bi;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &ai, &bi);
		ai--; bi--;
		swap(a[ai], a[bi]);
	}
	for (int i = 0; i < w; i++) {
		cout << a[i] + 1 << endl;
	}


	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	ll n;
	bool ans=true;
	cin>>n>>s;
	if(n%2==0){
		rep(i,n/2){
			ans&=(s[i]==s[i+n/2]);
		}
	}
	else ans=false;
	Yn(ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

#define SIZE 15+5

using namespace std;
 
int main(){
    std::ios_base::sync_with_stdio(false);

	int X,Y;
	int course[SIZE+1][SIZE];
	int dp[SIZE+1][SIZE];
	int ans;

	while(1){
		cin>>X>>Y;
		if(X==0&&Y==0) break;

		for(int i=0;i<Y*X;i++) cin>>course[i/X][i%X];
		for(int i=0;i<X;i++) course[Y+1][i]=0;
		for(int i=0;i<(Y+1)*(X);i++) dp[i/X][i%X]=(i/X==0&&course[i/X][i%X]==0)?1:0;

		for(int i=0;i<(Y-1)*X;i++){
			if(dp[i/X][i%X]>0){
				if(course[i/X][i%X]==0){
					if(i%X!=0){
						if(course[i/X+1][i%X-1]==0) dp[i/X+1][i%X-1]+=dp[i/X][i%X];
					}
						if(course[i/X+1][i%X]!=1) dp[i/X+1][i%X]+=dp[i/X][i%X];
						if(i%X!=X-1){
							if(course[i/X+1][i%X+1]==0) dp[i/X+1][i%X+1]+=dp[i/X][i%X];
						}
					}
					else if(course[i/X][i%X]==2){
						if(course[i/X+2][i%X]!=1) dp[i/X+2][i%X]+=dp[i/X][i%X];
					}
				}
		}
		ans=0;
		for(int i=(Y-1)*X;i<(Y+1)*X;i++){
			ans+=dp[i/X][i%X];
		}
		cout<<ans<<endl;
	}
 
 
    return 0;
}

Measured memory_bytes: 1200