akhauriyash/Code-Regression huggingface dataset:
/*input
5
-998244353 0 0 0 0 0 
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int n;
ll a[maxn];
vector<int> p;
bool isp[maxn];
ll cnt[maxn];
vector<int> ans;

void check(ll pp){
	if(pp>n){
		for(int i=0;i<=n;i++) if(a[i]%pp) return;
		ans.pb(pp);
		return;
	}
}

int main()
{
	IOS;
	for(int i=2;i<40000;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<40000;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
	cin>>n;
	REP(i,n+1) cin>>a[n-i];
	for(int pp:p){
		if(pp>n) break;
		if(a[0]%pp) continue;
		REP(i,pp-1) cnt[i]=0;
		for(int i=1;i<=n;i++){
			cnt[i%(pp-1)]+=a[i];
		}
		// cout<<pp<<'\n';
		// REP(i,pp-1) cout<<cnt[i]<<" \n"[i==pp-2];
		bool f=1;
		REP(i,pp-1) if(cnt[i]%pp){
			f=0;
			break;
		}
		if(f) ans.pb(pp);
	}
	ll cur=abs(a[n]);
	for(int pp:p){
		if(cur<=1) break;
		if(cur%pp) continue;
		check(pp);
		while(cur%pp==0) cur/=pp;
	}
	if(cur!=1) check(cur);
	sort(ALL(ans));
	for(int i:ans) cout<<i<<'\n';
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    int r;
    cin >> r;
    cout<<r*r<<endl;
    return 0;
    
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<int> ret;
  for (int i = 1; i <= n; i++) {
    double x = (double)i * 1.08;
    if ((int)floor(x) == n) ret.push_back(i);
  }
  if ((int)ret.size() == 0) {
    cout << ":(" << endl;
    return 0;
  }
  cout << ret[0] << endl;
}


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

int main(){
	while(1){
		long n, m;
		string s;
		scanf(" %ld", &n);
		if(n==0) break;
		scanf(" %ld", &m);
		cin >> s;
		
		long a=0;
		long ans=0;
		long lim=m-2*n-1;
		while(a<m){
			long ct=0;
			if(s[a]=='I'){
				while(a<m && s[a+1]=='O' && s[a+2]=='I'){
					a+=2;
					ct++;
				}
				ct = ct-n+1;
				if(ct>0)ans+=ct;
			}
			++a;
			//printf("%ld\n", a);
		}
		
		printf("%ld\n", ans);
	}	
}

Measured memory_bytes: 2128
//2018.9.22 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    int n,m;
    int q[N];
    bool p[N];
    int sum;
    inline void MAIN(){
        n=read(),m=read();
        p[1]=1;
        for(res i=1;i<=m;i++){
            res x=read(),y=read();
            if(p[x]){
                if(!q[x])p[x]=0;
                p[y]=1;
            }
            q[x]--,q[y]++;
        }
        for(res i=1;i<=n;i++)if(p[i])sum++;
        printf("%d\n",sum);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 768
def run(N, A):
    r = 0
    A_sum = 0
    A_xor = 0
    A_and = 0
    r = -1
    cnt = 0
    for l in range(N):
        while (A_sum - A_xor == 2*A_and) and r < N-1:
            r += 1
            A_sum += A[r]
            A_xor ^= A[r]
            A_and &= A[r]
        if A_sum - A_xor == 2*A_and:
            cnt += r - l + 1
        else:
            cnt += r - l
        '''
        元に戻す
        xor:
        0 0 => 0
        0 1 => 1
        1 0 => 1
        1 1 => 0
        '''
        A_sum -= A[l]
        A_xor ^= A[l]
        A_and = 2*(A_sum - A_xor)
    return cnt


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 24840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll calc(ll n, ll m)
{
    ll l = n > m ? n : m;
    ll s = n <= m ? n : m;
    ll mod = l % s;

    if (mod == 0)
    {
        return s;
    }
    else
    {
        return calc(s, mod);
    }
}

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

    ll min = a[0];
    for (int i = 1; i < n; i++)
    {
        min = calc(min, a[i]);
        if (min == 1)
        {
            break;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 1024
ans = 0
 
def dfs(i, cur, sum_v):
    global ans, S
    if i == len(S)-1:
        ans += sum_v
        return 
    dfs(i+1, int(S[i+1]), sum_v+int(S[i+1]))
    dfs(i+1, cur*10+int(S[i+1]), sum_v+cur*9+int(S[i+1]))
 
S = input()
dfs(0, int(S[0]), int(S[0]))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-9;
const ll MOD = 1000000007LL;
int main() {
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        int ss=0;
        for(int j=i;j<s.length();j++){
            if(s[j]=='A'||s[j]=='T'||s[j]=='G'||s[j]=='C'){
                ss++;
            }else{
                break;
            }
        }
        ans=max(ans,ss);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char A[100], B[100], C[100];
int main () {
    scanf ("%s%s%s", A, B, C);
    int alen, blen, clen;
    alen = strlen (A);
    blen = strlen (B);
    clen = strlen (C);
    if (A[alen-1] == B[0] && B[blen-1] == C[0]) {
        printf ("YES\n");
    }
    else printf ("NO\n");
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit=100010;
int x[limit];
int t[limit],add[limit];

int main(void){
	int n,m;
	cin >> n >> m;
	
	rep(i,n){
		int in;
		cin >> in;
		x[in]++;
	}

	rep(i,limit){
		t[i%m]+=x[i];
		add[i%m]+=x[i]/2*2;
	}

	int ans=0;
	
	//rep(i,m) cout << t[i] << " ";
	//cout << endl;

	rep(i,m){
		int j=(m-i)%m;

		if(i<j){
			int com=min(t[i],t[j]);
			ans+=com;
			t[i]-=com,t[j]-=com;
			ans+=min(t[i],add[i])/2;
			ans+=min(t[j],add[j])/2;
		}

		if(i==j){
			ans+=t[i]/2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,sum=0,ans1=0,ans2=0;
  cin >> N;
  int a[N];
  FOR(i,0,N){
    cin >> a[i];
    sum += a[i];
  }
  int avg1 = sum/N,avg2 = sum/N+1;
  FOR(i,0,N){
    ans1 += (a[i]-avg1)*(a[i]-avg1);
    ans2 += (a[i]-avg2)*(a[i]-avg2);
  }
  cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

long long process(long long x1, long long y1, long long x2, long long y2)
{
	long long d = 1;
	for (int i = 0; i < 30; i++) d *= 3;

	if (y1 > y2)
	{
		swap(x1, x2);
		swap(y1, y2);
	}

	long long result = abs(x1 - x2) + abs(y1 - y2);
	while (d > 1)
	{
		d /= 3;

		long long x1_idx = x1 / d;
		long long x2_idx = x2 / d;
		long long y1_idx = y1 / d;
		long long y2_idx = y2 / d;
		if (x1_idx != x2_idx) break;

		if (x1_idx % 3 == 1 && abs(y1_idx - y2_idx) > 1)
		{
			long long top = x1_idx * d - 1;
			long long bottom = x1_idx * d + d;
			long long loss = min(x1, x2) - top;
			loss = min(loss, bottom - max(x1, x2));
			result += loss * 2;
			break;
		}
	}

	return result;
}

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

	int Q;
	cin >> Q;

	while (Q--)
	{
		long long x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		x1--;
		y1--;
		x2--;
		y2--;

		long long result1 = process(x1, y1, x2, y2);
		long long result2 = process(y1, x1, y2, x2);

		cout << max(result1, result2) << "\n";
	}

	return 0;
}

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

int main() {
	int n, k;
	cin>>n>>k;
	int ppl[n+1] = {0};
	while(k--){
		int d;
		cin>>d;
		while(d--){
			int s;
			cin>>s;
			ppl[s]++;
		}
	}int ans = 0;
	for(int i = 1; i <= n; i++){
		if(ppl[i] == 0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3676
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b = I()
c = max(a+b,a-b)
print(max(c,a*b))


Measured memory_bytes: 10476
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    int[] si = new int[N];
    for (int i = 0; i < N; i++) {
      si[i] = s[i] == 'o' ? 0 : 1;
    }

    for (int[] t : new int[][] {{0, 0}, {0, 1}, {1, 0}, {1, 1}}) {
      int[] a = test(t, si, N);
      if (a != null) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
          sb.append(a[i] == 0 ? 'S' : 'W');
        }
        System.out.println(sb.toString());
        return;
      }
    }
    System.out.println(-1);
  }

  private static int[] test(int[] t, int[] s, int N) {
    int[] a = new int[N];
    a[0] = t[0];
    a[1] = t[1];
    for (int i = 1; i < N - 1; i++) a[i + 1] = a[i - 1] ^ (a[i] ^ s[i]);
    if ((a[N - 2] ^ (a[N - 1] ^ s[N - 1])) != a[0]
        || (a[N - 1] ^ (a[0] ^ s[0])) != a[1]) return null;
    return a;
  }
}


Measured memory_bytes: 26648
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int sumTotal = 0;

    for(int i = 0; i <= n; i++)
    {
        // 各桁の和、べき指数
        int tmp = i, digitSum = 0, exponent = 4;
        while(exponent >= 0)
        {
            // 注目している桁の数字
            int digitNum = tmp / pow(10, exponent);
            digitSum += digitNum;

            tmp -= digitNum * pow(10, exponent);
            exponent--;
        }

        if(a <= digitSum && digitSum <= b)
        {
            sumTotal += i;
        }
    }

    cout << sumTotal << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    int cnt=0;
    for (int i = 0; i < s.size(); i++)
    {
        cnt+=s[i]-'0';
    }
    if(cnt%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3708
#include <stdio.h>

int main() {
    int a, b;
    char op;
    while (scanf("%d %c %d", &a, &op, &b) == 3) {
        if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op == '*') {
            printf("%d\n", a * b);
        } else if (op == '/') {
            printf("%d\n", a / b);
        }
    }
    return 0;
}

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

int main() {
    int K;
    cin >> K;
    int64_t ans = 0;
    rep(i, K) rep(j, K) rep(k, K) {
        ans += __gcd(__gcd(i, j), k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a, b;
    cin >> a >> b;

    int ret = a - 1;
    if(b >= a) ret++;
    cout << ret << endl;

    return 0;
}



Measured memory_bytes: 256
// A - Station and Bus

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string ans;

	if (S[0] == S[1] && S[1] == S[2]) ans = "No";
	else ans = "Yes";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, m;
    double h[105][105], dp[105][105] = {0};
    rep(i,105){
        dp[0][i] = 1.0;
    }
    while(cin >> n >> m, n||m){
        double ans = 0;
        rep(i,105){
            rep(j,105){
                dp[i][j] = 0;
            }
        }
        rep(i,105){
            dp[1][i] = 1;
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                cin >> h[i][j];
            }
        }
        for(int i = 2; i <= m; i++){
            for(int j = 1; j <= n; j++){
                for(int k = 1; k <= n; k++){
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] * h[k][j]);
                }
            }
        }
        for(int i = 1; i <= n; i++){
            ans = max(dp[m][i], ans);
        }
        printf("%.2f\n", ans);
    }


    return 0;
}

Measured memory_bytes: 1420
import Data.List
import Control.Monad

cograph::Int->[(Int,Int)]
cograph n = case mod n 2 == 0 of
            True -> [(i,(n+1-i))|i<-[1..div n 2]]
            False-> [(i,n-i)|i<-[1..div n 2]]

eater::[(Int,Int)]->[(Int,Int)]->[(Int,Int)]
eater rest []       = rest
eater (x:xs) (y:ys) = if x == y then eater xs ys
                                else x:(eater xs (y:ys))

solver::Int->[(Int,Int)]
solver n = eater [(i,j)|i<-[1..n],j<-[1..n],i<j] (sort (cograph n))

main::IO()
main=do
  n<-return.read=<<getLine
  let sl = solver n
  print (length sl)
  forM_ sl (\(x,y)->putStr (show x ++ " " ++ show y ++ "\n"))

Measured memory_bytes: 1404
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
using namespace std;
#define SZ(a) (int)(a).size()
typedef long long ll;

int main() {
	cin.sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	deque<bool> a(n);
	for (auto i = 0; i < n; i++) {
		a[i] = s[i] == 'B';
	}
	bool flip = false;
	if (k > 2*n) {
		k = 2*n+(k & 1);
	}
	for (auto i = 0; i < k; i++) {
		if (a[0] == flip) {
			a[0] = !a[0];
		}
		else {
			a.pop_front();
			a.push_back(!flip);
			flip = !flip;
		}
	}
	for (auto& x: a) {
		printf("%c", x != flip ? 'B' : 'A');
	}
	puts("");
	return 0;
}


Measured memory_bytes: 920
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    long long int n,a[200001],i,max=0,max2=0,b=0;
    scanf("%lld", &n);
    for(i=0; i<n; i++)
    {
        scanf("%lld", &a[i]);
        if(a[i]>max)
        {
            max=a[i];
        }
    }
    for(i=0; i<n; i++)
    {
        if(a[i]==max)
        {
            b++;
        }
    }
    for(i=0; i<n; i++)
    {
        if(a[i]>max2 && a[i]<max)
        {
            max2=a[i];
        }
    }
    if(b==1)
    {
        for(i=0; i<n; i++)
        {
            if(a[i]==max)
            {
                printf("%lld\n", max2);
            }
            else
            {
                printf("%lld\n", max);
            }
        }
    }
    else
    {
        for(i=0; i<n; i++)
        {
            printf("%lld\n", max);
        }
    }
    return 0;
}


Measured memory_bytes: 3072
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
        M: usize,
        ABs: [(Usize1, Usize1); M],
    }

    // つながっているグループをUnionFindで表現
    let mut uf: UnionFind<usize> = UnionFind::new(N);

    for &(a, b) in ABs.iter() {
        uf.union(a, b);
    }

    let mut parents: HashSet<usize> = HashSet::new();
    for i in 0..N {
        let root = uf.find(i);
        parents.insert(root);
    }

    let ans = parents.len() - 1;
    println!("{}", ans);
}


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

#define N 1000

int main(void)
{
	char s[N][N],a[N];
	int n,l,i,j;
	scanf("%d%d",&n,&l);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(strcmp(s[j-1],s[j])>0){
				strcpy(a,s[j-1]);
				strcpy(s[j-1],s[j]);
				strcpy(s[j],a);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N=200005;
LL A[MAX_N],dp1[MAX_N],dp2[MAX_N]; 
LL ans,D;
int n;
int main()
{
	cin>>n>>D;
	ans+=(n-1)*D;
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
		ans+=A[i];
	}
	dp1[0]=A[0];
	dp2[n-1]=A[n-1];
	for(int i=1;i<n;i++)dp1[i]=min(dp1[i-1]+D,A[i]);
	for(int i=n-2;i>=0;i--)dp2[i]=min(dp2[i+1]+D,A[i]);
	for(int i=1;i<n-1;i++)ans+=min(dp1[i],dp2[i]);
	if(n==1)ans=0;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#define N 500000
int count;

struct node
{
  int key;
  int pare;
  int left;
  int right;
};

void insert(struct node bi[],int z)
{
  int x,y;
  int num=0;

  y=-1;
  x=bi[0].key;
//  printf("while start\n");
  while(1)
  {
    if(x==-1) break;
    y = num;
    if(z<x)
    {
      num = bi[num].left;
      if(num!=-1) x = bi[num].key;
      else
      {
        x=-1;
      }
    }
    else
    {
      num = bi[num].right;
      if(num!=-1) x = bi[num].key;
      else
      {
        x=-1;
      }
    }
  }
//  printf("while end\n");
  bi[count].pare=y;
  bi[count].key=z;

  if(y==-1)
  {
    bi[0].key=z;
  }
  else if(z<bi[y].key)
  {
    bi[y].left = count;
  }
  else
  {
    bi[y].right = count;
  }

  count++;
}

void pre(struct node bi[],int now)
{
  printf(" %d",bi[now].key);
  if(bi[now].left!=-1)  pre(bi,bi[now].left);
  if(bi[now].right!=-1)  pre(bi,bi[now].right);
}

void in(struct node bi[],int now)
{
  if(bi[now].left!=-1) in(bi,bi[now].left);
  printf(" %d",bi[now].key);
  if(bi[now].right!=-1) in(bi,bi[now].right);
}


void print(struct node bi[])
{
  in(bi,0);
  printf("\n");
  pre(bi,0);
  printf("\n");
}
/*
void find(int key,struct node bi[])
{
  int i=0;
  while(1)
  {
    if(bi[i].pare==-1) break;
    if(bi[i].key==key)
    {
      printf("yes\n");
      return;
    }
    i = bi[i].pare;
  }
  while(1)
  {
    if(bi[i].key<key)
    {
      i=bi[i].right;
      if(bi[i].key==-1)
      {
        printf("no\n");
        return;
      }
    }
    else
    {
      i=bi[i].left;
      if(bi[i].key==-1)
      {
        printf("no\n");
        return;
      }
    }
    if(bi[i].key==key)
    {
      printf("yes\n");
      return;
    }
  }
}
*/
int main(void)
{
  int n,i;
  int num;
  char comm[10];
  struct node bi[N];
  count=0;

  for(i=0;i<N;i++)
  {
    bi[i].key = -1;
    bi[i].pare = -1;
    bi[i].left = -1;
    bi[i].right = -1;
  }
//  printf("set ok\n");

  scanf("%d",&n);

  for(i=0;i<n;i++)
  {
//    printf("comm:");
    scanf("%s",comm);
//    printf("comm:%s\n",comm);
    if(strcmp(comm,"insert")==0)
    {
//      printf("scan:");
      scanf("%d",&num);
      insert(bi,num);
    }
/*    else if(strcmp(comm,"find")==0)
    {
      scanf("%d",&num);
      find(num,bi);
    }*/
    else
    {
//      printf("print\n");
      print(bi);
    }
  }
  return 0;
}

Measured memory_bytes: 8416
import sys
import itertools

n = int(input())
# = map(int, input().split())
l = sorted(list(map(int, input().split())))
if n < 3 or len(set(l)) < 3:
    print(0)
    sys.exit()
c = list(itertools.combinations(l, 3))
ans = 0
for i in range(len(c)):
    if len(set(c[i])) < 3:
        continue
    if c[i][0] + c[i][1] <= c[i][2]:
        continue
    ans += 1
print(ans)


Measured memory_bytes: 20532
#include<stdio.h>

int main(){
  int i,j,k,a[100],n,count=0,flag = 1;

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

  i = 0;
  while(flag){
    flag = 0;
    for(j = n - 1;j >= i + 1;j--){
      if(a[j] < a[j-1]){
	k = a[j];
	a[j] = a[j-1];
	a[j-1] = k;
	flag = 1;
	if(j < i + 1)break;
	count++;
      }
    }
    i++;
  }

  for(i = 0;;i++){
    printf("%d",a[i]);
    if(i >= n - 1)break;
    printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}

Measured memory_bytes: 604
using System;

namespace SortingThreeNumbers
{
	class MainClass
	{
		public static void Main (string[] args)
		{

			//??\??????
			string[] input = Console.ReadLine().Split(' ');

			//????????????
			Array.Sort(input);
			//?°???????????????????
			Console.WriteLine (input[0]+" "+input[1]+" "+input[2]);
		}
	}
}

Measured memory_bytes: 6380
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
gets;
a,b=$<.map{|s|s.split.map &:to_i}.transpose.map{|a|a.map.with_index.sort.each_cons(2).map{|(x,i),(y,j)|[y-x,i,j]}};
p=*0..a.size;s=0;
f=->a{a==p[a]?a: p[a]=f[p[a]]}
(a+b).sort_by{|a|a[0]}.map{|c,a,b|(s+=c;p[p[b]]=p[a])if f[a]!=f[b]}
p s

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

int h,n;

int main(){
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		h-=x;
		if(h <= 0){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

using namespace std;
#define sd(x) scanf("%d",&x);
#define sdl(x) scanf("%lld",&x);
#define pr(x) printf("%d\n",x);
#define prl(x) printf("%lld\n",x);


   long long int gcd(long long int a,long long int b)
{
    if (b<a)return gcd(b,a);
    else if (b%a==0)return a;
    else return gcd(b%a,a);
 
}

long long fast_exp(long long a,long long n,long long mod1)
    {

    if (n==0)return 1;
    else if (n==1)return a;
    if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
    else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
bool is_square(long long  a)
{
    long long int b=sqrt(a);
    if (b*b==a)return true;
    else return false;
}


void solve()
{
   int n,k;
   cin >> n >> k;
   unordered_map<int,int>arr;
   for (int c=0;c<k;c++)
        {
            int d;
            cin >> d;
            for (int c1=0;c1<d;c1++)
                {
                    int a;
                    cin >> a;
                    arr[a]=1;
                }
        }
    int total=0;
    for (int c=1;c<=n;c++)
        if (arr[c]==0)
            total++;
    
    cout << total << endl;
    
    
}



int main ()
{
      
     int t;
     //cin >> t;
     t=1;
     for (int tt=1;tt<=t;tt++)
     {
         solve();

     }

    return 0;
     
     
     
     
 }


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#define endl '\n'
using namespace std;
string s, t;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    cin >> t;
    int flag = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (t[i] != s[i])
        {
            flag = 1;
            break;
        }
    }
    if (flag)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <string.h>
 
int main()
{
    char str[1001],cmd[10],c,s[1001];
    int i,j,q,a,b;
     
    scanf("%s",&str);
    scanf("%d",&q);
     
    for(i=0;i<q;i++){
        scanf("%s",&cmd);
        if(strcmp(cmd,"print") == 0){
            scanf("%d %d",&a,&b);
            for(j=a;j<=b;j++){
                printf("%c",str[j]);
            }
                        printf("\n");
        }else if(strcmp(cmd,"reverse") == 0){
            scanf("%d %d",&a,&b);
            while(a<b){
                c = str[a];
                str[a] = str[b];
                str[b] = c;
                a++;
                b--;
            }
        }else if(strcmp(cmd,"replace") == 0){
            scanf("%d %d %s",&a,&b,&s);
            for(j=0;j<b-a+1;j++){
                str[j+a] = s[j];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2104
use proconio::{input, marker::Chars};
use std::collections::HashMap;

fn main() {
    input! {
        a: Chars,
    }

    let len = a.len() as u64;

    let mut map = HashMap::new();

    for c in a {
        *map.entry(c).or_insert(0) += 1;
    }

    let mut count = 0_u64;

    for (_, val) in map {
        count += (len - val) * val;
    }
    count /= 2;
    count += 1;

    println!("{}", count);
}


Measured memory_bytes: 3016
N=int(input())
A=[]
M1=[0]
M2=[0]

max_val = 0
for i in range(N):
    input_val = int(input())
    if (max_val < input_val):
        max_val = input_val
    A.append(input_val)
    if (i < N -1):
        M1.append(max_val)

max_val = 0
for i in range(N-1):
    input_val = A[N-1-i]
    if (max_val < input_val):
        max_val = input_val
    M2.append(max_val)

if (N<=2):
    print(A[1])
    print(A[0])
else:
    for i in range(N):
        print(max(M1[i], M2[N-1-i]))


Measured memory_bytes: 15672
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int> s(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	// a > 0
	// b > 0
	// c = a - b: b = a - c > 0
	// a + kc = n - 1

	long long ans = 0;
	int c = 1;
	while (c < n) {

		long long sum = 0;
		int k = 0;
		set<int> s_pos;

		// printf("c %d\n", c);
		while (1) {
			int kc = k * c;
			int a = n - 1 - kc;
			if (a <= c) {
				break;
			}
			if (kc == a || s_pos.count(kc) > 0 || s_pos.count(a) > 0) {
				break;
			}
			s_pos.insert(kc);
			s_pos.insert(a);

			// printf("  %d %d\n", kc, a);
			sum += s[kc];
			sum += s[a];
			ans = max(ans, sum);
			k++;
		}
		c++;
	}

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


Measured memory_bytes: 7424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  string s;
  cin>>s;
  int a=s[0]-'0';
  int b=s[1]-'0';
  int c=s[2]-'0';
  int d=s[3]-'0';
  rep(i,2)rep(j,2)rep(k,2){
    int sum=a;
    string ans="";
    ans+=s[0];
    if(i)sum+=b,ans+="+";
    else sum-=b,ans+="-";
    ans+=s[1];
    if(j)sum+=c,ans+="+";
    else sum-=c,ans+="-";
    ans+=s[2];
    if(k)sum+=d,ans+="+";
    else sum-=d,ans+="-";
    ans+=s[3];
    if(sum==7){
      cout<<ans<<"=7"<<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
import sys
c = False
for s in sys.stdin.readlines():
    n = s.strip().zfill(5)
    if c: print
    c = True
    for i in xrange(2):
        print "".join(["*" if int(n[j])-5*i in range(5) else " " for j in xrange(5)])
    print "="*5
    for i in xrange(5):
        print "".join([" " if (int(n[j])%5)==i else "*" for j in xrange(5)])

Measured memory_bytes: 4228
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    N = iRaw()
    As = isRaw()
    Ais = [(a,i) for i,a in enumerate(As)]
    Ais.sort(reverse=True)
    dp = [[0]*(N+1) for n in range(N+1)]
    for sidx,ai in enumerate(Ais):
        a,i = ai
        sxy = sidx+1
        dp[0][sxy] = dp[0][sxy-1]+ a*(i-sidx)
        dp[sxy][0] = dp[sxy-1][0]+ a*(N-1-sidx -i)
        for x in range(1,sxy):
            c1 = dp[x-1][sxy-x]+ a*(N-x-i)
            c2 = dp[x][sxy-x-1]+ a*(i-(sidx-x))
            dp[x][sidx+1-x] = max(c1,c2)
    return max([dp[n][N-n] for n in range(N+1)])

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 100676
// Date: 2020-04-19

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int fa[N], son[N];
int main() {
    FIO;
    int n; cin >> n;
    rep(i, 2, n) {
        cin >> fa[i];
        son[fa[i]]++;
    }
    rep(i, 1, n) cout << son[i] << '\n';

    return 0;
}

Measured memory_bytes: 5180
#include <iostream>
#include <iomanip>
#include <math.h>
#include <float.h>
using namespace std;

#ifndef M_PI
#define M_PI (4.0*atan(1.0))
#endif

int main() {
	// your code goes here
	int H,W;
	while(1){
		std::cin>>H>>W;
//		std::cout<<H<<" "<<W<<std::endl;
		if(H==0 && W==0) break;
		for(int i=0; i<H; i++){
			if(i==0 || i==H-1){
				for(int j=0; j<W; j++) {
					std::cout<<"#";
				}
			} else {
				std::cout<<"#";
				for(int j=1; j<W-1; j++) {
					std::cout<<".";
				}
				std::cout<<"#";
			}
			
			std::cout<<std::endl;
		}
		std::cout<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int a, b; cin>>a>>b;
    if(10 <= a || 10 <= b){
        cout << -1 << endl;
    }
    else{
        cout << a * b << endl;
    }

    return 0;
}

Measured memory_bytes: 896
using System;

namespace ManyHelloWorld
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			while (true){
				int[] data = getInputdata(" ");
				if (data[0] == 0 && data[1] == 0)
					break;

				Console.WriteLine ((data[0] > data[1])?"{1} {0}": "{0} {1}", data[0], data[1]);
			}
		}
		public static int[] getInputdata (string token)
		{
			string[] data = Console.ReadLine ().Split (token.ToCharArray ());
			int[] idata = new int[data.Length];

			for (int i = 0; i < data.Length; i++) {
				idata [i] = int.Parse (data [i]);
			}
			return idata;
		}


	}
}

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

int N, X;
const int MAX_N = 100;
int L[MAX_N];

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) cin >> L[i];

    int ans = 0;
    int D = 0;
    int i = 0;
    while (D <= X) {
        D = D + L[i];
        i++;
        ans++;
    }

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	long long int n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	if (a > b) swap(a, b);
	if ((b - a) % 2 == 0){
		printf("%lld\n", (b - a) / 2);
	}else{
		printf("%lld\n", (b - a - 1) / 2 + min(a, n - b + 1));
	}
}

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

using namespace std;

struct nod {long long val, p;} v[100002];

long long sum1[100002], m1[100002];
long long sum2[100002], m2[100002];
int n;
long long S, c, sol, nr;

int main()
{
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> v[i].p >> v[i].val;
  }
  for (int i = 1; i <= n; i++) {
    S += v[i].val;
    sum1[i] = (S - v[i].p);
    m1[i] = max(m1[i - 1], sum1[i]);
    sol = max(sol, sum1[i]);
  }
  S = 0;
  for (int i = n; i >= 1; i--) {
    S += v[i].val;
    sum2[i] = S - (c - v[i].p);
    m2[i] = max(m2[i + 1], sum2[i]);
    sol = max(sol, sum2[i]);
  }
  for (int i = 1; i <= n; i++) {
    nr = sum1[i] - v[i].p + m2[i + 1];
    sol = max(sol, nr);
  }
  for (int i = n; i >= 1; i--) {
    nr = sum2[i] - (c - v[i].p) + m1[i - 1];
    sol = max(sol, nr);
  }
  cout << sol;
  return 0;
}


Measured memory_bytes: 4992
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXV = 10010;
int V, E;
vector<int> G[MAXV];
vector<int> rG[MAXV];
vector<int> vs;
bool used[MAXV];
int cmp[MAXV];

void add_edge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        if (!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (int i = 0; i < rG[v].size(); i++) {
        if (!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}

int scc() {
    for (int i = 0; i < MAXV; i++) used[i] = false;
    vs.clear();
    for (int v = 0; v < V; v++) {
        if (!used[v]) dfs(v);
    }
    for (int i = 0; i < MAXV; i++) used[i] = false;
    int k = 0;
    for (int i = vs.size()-1; i >= 0; i--) {
        if (!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
}

int main(void) {
    cin >> V >> E;
    while (E--) {
        int s, t;
        cin >> s >> t;
        add_edge(s, t);
    }
    scc();
    int q;
    cin >> q;
    while (q--) {
        int s, t;
        cin >> s >> t;
        if (cmp[s] == cmp[t]) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 2780
N, M = map(int, input().split())
ls = []
dp = [float('inf')]*(1<<N)
for i in range(M):
  a, b = map(int, input().split())
  c = ['0']*N
  inf = [int(i)-1 for i in input().split()]
  for i in range(b):
    x = inf[i]
    c[x] = '1'
  m = ''.join(c)
  m = int(m,2)
  ls += [(a,m)]
  dp[m] = a
dp[0] = 0
for i in range(M):
  for j in range(1<<N):
    a,m = ls[i]
    dp[m|j] = min(dp[m|j], a+dp[j])
ans = dp[-1] if dp[-1]!=float('inf') else -1
print(ans)

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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述
    string yohou, real;
    int ans=0;

    cin >> yohou >> real;

    REP(i,3){
        if(yohou[i] == real[i]) ans++;
    }

    cout << ans << endl;

return 0;
}

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

int main(){
  int n, m;
  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    int res = 0, tmp;
    vector<int> points, points2;
    for(int i = 0;i < n;i++){
      scanf("%d", &tmp);
      points.push_back(tmp);
    }
    vector<int>::iterator it1,it2;
    for(it1 = points.begin();it1 != points.end();it1++){
      points2.push_back(*it1);
      for(it2 = points.begin();it2 != points.end();it2++){
	if(*it1 + *it2 <= m)points2.push_back(*it1 + *it2);
      }
    }
    sort(points2.begin(),points2.end());
    for(it1 = points2.begin();it1 != points2.end();it1++){
      it2 = upper_bound(points2.begin(), points2.end(), m - *it1);
      if(it2 == points2.begin())continue;
      it2--;
      res = max(res, *it1 + *it2);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;
   bool a=false;
   for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
    if(i*j==N){
    a=true;
    break;
    }
    }
   }
   if(a==true){
    cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
   
}

Measured memory_bytes: 256
#include <stdio.h>

char input[3][3] = {};

void disp(){
  int i,j;
  for(i = 0; i < 3; i++){
    for(j = 0; j < 3; j++){
      printf("%c ", input[i][j]);
  }
    printf("\n");
  }

}

int hoge(){
  int i;
  int j;
  int count = 0;
  for(i = 0; i < 3; i++){//よこ
    for(j = 0; j < 3; j++){
      if(input[i][j] == 'o'){
        count++;
      }else if(input[i][j] == 'x'){
        count--;
      }
    }
    if(count == 3){
      printf("o\n");
      return 0;
    }
    if(count == -3){
      printf("x\n");
      return 0;
    }
    count = 0;
  }

  for(i = 0; i < 3; i++){//たて
    for(j = 0; j < 3; j++){
      if(input[j][i] == 'o'){
        count++;
      }else if(input[j][i] == 'x'){
        count--;
      }
    }
    if(count == 3){
      printf("o\n");
      return 0;
    }
    if(count == -3){
      printf("x\n");
      return 0;
    }
    count = 0;
  }

  //ななめ
  if(input[0][0] == 'o'){
    if(input[1][1] == 'o'){
      if(input[2][2] == 'o'){
        printf("o\n");
        return 0;
      }
    }
  }
  //  disp();
  if(input[0][0] == 'x'){
    if(input[1][1] == 'x'){
      if(input[2][2] == 'x'){
        printf("x\n");
        return 0;
      }
    }
  }
  if(input[0][2] == 'o'){
    if(input[1][1] == 'o'){
      if(input[2][0] == 'o'){
        printf("o\n");
        return 0;
      }
    }
  }
  if(input[0][2] == 'x'){
    if(input[1][1] == 'x'){
      if(input[2][0] == 'x'){
        printf("x\n");
        return 0;
      }
    }
  }

  printf("d\n");

}

int main (){

  int i,j;
  char str[100];

  while(scanf("%s", str) != EOF){

   for(i = 0; i < 3; i++){
    for(j = 0; j < 3; j++){
      //      scanf("%c", &input[i][j]);
      input[i][j] = str[i*3+j];
    }
   }

    hoge();
  /*
  for(i = 0; i < 3; i++){
    for(j = 0; j < 3; j++){
      printf("%c ", input[i][j]);
    }
    printf("\n");
  }
  */

  }
  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
int main(void){
    double r, s, are, circ;
    
    scanf("%lf" ,&r);
    
    
    s = 3.141592653589;
    are = r * r * s;
    circ = 2 * r * s;
    
    printf("%.6f %.6f\n", are, circ);
    return 0;
}


Measured memory_bytes: 2080
function f(d) {
	return d * d;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var d;
while (d = +lines.shift()) {
	var sum = 0;
	var n = 600 / d;
	for (var i = 1; i < n; i++) {
		sum += d * f(i * d);
	}
	console.log(sum);
}

Measured memory_bytes: 8484