akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();

        char c[][];
        c = new char[H][W];

        for (int i = 0; i < H; i++) {
            String line = sc.next();
            for (int j = 0; j < W; j++) {
                c[i][j] = line.charAt(j);
            }
        }
        sc.close();

        int ans = 0;
        for (byte is = 0; is < 1 << H; is++) {
            for (byte js = 0; js < 1 << W; js++) {

                int cnt = 0;
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        if ((is >> i & 1) == 1) {
                            continue;
                        }
                        if ((js >> j & 1) == 1) {
                            continue;
                        }
                        if (c[i][j] == '#') {
                            cnt++;
                        }
                    }
                }
                if (cnt == K) {
                    ans++;
                }

            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35640
nums = gets.chomp.split('').map(&:to_i)

ans = 0
['+','-'].repeated_permutation(3) do |bits|
    ans = nums[0]
    1.upto(3) do |i|
        if bits[i -1] == '+'
            ans += nums[i]
        else
            ans -= nums[i]
        end
    end
    if ans == 7
        puts("#{nums[0]}#{bits[0]}#{nums[1]}#{bits[1]}#{nums[2]}#{bits[2]}#{nums[3]}=7")
        break
    end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, m;
    cin >> n >> m;
    vector<pii> ans;
    if (n % 2) {
        for (int l = 1, r = n - 1; l < r; l++, r--)
            ans.emplace_back(l, r);
    }
    else {
        bool flag = false;
        for (int l = 1, r = n - 1; l < r; l++, r--) {
            if (!flag && r - l <= n / 2) {
                r--;
                flag = true;
            }
            ans.emplace_back(l, r);
        }
    }
    for (int i = 0; i < m; i++)
        cout << ans[i].first << ' ' << ans[i].second << '\n';
}


Measured memory_bytes: 4136
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
int n;
vector<long long>an(300030);
long long ans = 0;
void solve(){
    for(long long i = 0; i < 61; i++){
        long long c0 = 0;//0のcount
        long long c1 = 0;//1のcount
        for(int j = 0; j < n; j++){
            if(((long long)(1ll) << (i)) & an.at(j)){//jのi桁目が立っている時
            c1++;
            }
            else{
            c0++;
            }
        }
        unsigned long long tmp = (1ll << (i));
        tmp %= mod;
        unsigned long long tmp2;
        tmp2 = c0 * c1;
        tmp2 %= mod;
        ans += (tmp2 * tmp);
        ans %= mod;
        cerr << "2^" << i << ":" <<  ans << endl;
    }
    ans += mod;
    ans %= mod;
    cout << ans << endl;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> an.at(i);
    }
    solve();
    return 0;
}



Measured memory_bytes: 2560
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<int> so;
bool ok[110];
int num[110];
lint dp[110][110];
int main()
{
	memset(ok,false,sizeof(ok));
	memset(num,0,sizeof(num));
	REP(i,2,105){
		if(ok[i]) continue;so.pb(i);
		for(int j=i*2;j<105;j+=i) ok[j]=true;
	}
	int n,m=so.size();cin>>n;
	REP(i,2,n+1){
		rep(j,m){
			int x=i;
			while(x%so[j]==0){
				num[j]++;x/=so[j];
			}
		}
	}
	memset(dp,0,sizeof(dp));dp[0][1]=1;
	rep(i,m) REP(j,1,76) rep(k,num[i]+1){
		if(j*(k+1)<76) dp[i+1][j*(k+1)]+=dp[i][j];
	}
	cout<<dp[m][75]<<endl;
}


Measured memory_bytes: 1016
from itertools import *
n,m = map(int,input().split())
path = [set() for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    path[a-1].add(b-1)
    path[b-1].add(a-1)
ans = 0

for r in permutations(list(range(1,n))):
    p = 0
    flag = True
    for i in r:
        if not i in path[p]:
            flag = False
        p = i
    if flag:
        ans += 1
print(ans)


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

int main() {
    int N;
    cin >> N;
    set<int> color;
    int f_count = 0;

    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        if(a < 400) color.insert(1);
        else if(a < 800) color.insert(2);
        else if(a < 1200) color.insert(3);
        else if(a < 1600) color.insert(4);
        else if(a < 2000) color.insert(5);
        else if(a < 2400) color.insert(6);
        else if(a < 2800) color.insert(7);
        else if(a < 3200) color.insert(8);
        else if(a >= 3200) f_count++;
    }

    int min_color = max(int(color.size()), 1);
    int x = f_count + color.size();
    int max_color = x;
    cout << min_color << " " << max_color;
}

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

void
solver(char *S, char *T)
{
    printf("%s%s\n", T, S);
}

int
main(int argc, char *argv[])
{
    char S[101], T[101];

    scanf("%s%s", S, T);
    solver(S, T);
    return 0;
}

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

int main(void){
  int a, b;
  cin >> a >> b;
  bool ok = true;
  if(a > 9) ok = false;
  if(b > 9) ok = false;
  if(ok) cout << a*b << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3604
program b171
 
implicit none
integer :: n, k, z, m, i, j
integer, allocatable :: p(:)
 
read *, n, k
 
allocate(p(1:n))
 
read *, p(:)
 
do j = 1, n-1
 do i = 1, n-1
  if(p(i) > p(i+1)) then
   m = p(i)
   p(i) = p(i+1)
   p(i+1) = m
  end if
 end do
end do

z = 0
 
do i = 1, k
 z = z + p(i)
end do
 
print *, z
 
end program b171

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'a') {
			a++;
		}
		else if (S[i] == 'b') {
			b++;
		}
		else if (S[i] == 'c') {
			c++;
		}
	}

	if ((a == 1) && (b == 1)) {
		if (c == 1) {
			cout << "Yes" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;

public class Class1
{
    public static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int W = int.Parse(input[0]);
        int H = int.Parse(input[1]);
        int N = int.Parse(input[2]);

        int Llimit = 0;
        int Rlimit = W;
        int Ulimit = H;
        int Dlimit = 0;

        for(int i = 0;i < N;i++)
        {
            string[] in1 = Console.ReadLine().Split(' ');
            int x = int.Parse(in1[0]);
            int y = int.Parse(in1[1]);
            int a = int.Parse(in1[2]);

            switch (a)
            {
                case 2:
                    if (x < Rlimit) Rlimit = x;
                    break;
                case 1:
                    if (x > Llimit) Llimit = x;
                    break;
                case 3:
                    if (y > Dlimit) Dlimit = y;
                    break;
                case 4:
                    if (y < Ulimit) Ulimit = y;
                    break;
                default:
                    Console.WriteLine("Error");
                    break;
            }

                    //Console.WriteLine(Rlimit + " " + Llimit + " " + Dlimit + " " + Ulimit);
        }

        if (Llimit >= Rlimit) Console.WriteLine(0);
        else if (Dlimit >= Ulimit) Console.WriteLine(0);
        else Console.WriteLine((Rlimit - Llimit) * (Ulimit - Dlimit));
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int k;
cin>>k;
long long int total=0;
for(long long int i=1;i<=10000000;i++){
	total=(total*10+7)%k;
	if(total==0){
		cout<<i<<endl;
		return 0;
	}
}
cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
	int a,b,i;
	
	for(i=0;i<4;i++){
		scanf("%d %d",&a,&b);
		if(a==1){
			b=b*6000;
		}
		if(a==2){
			b=b*4000;
		}
		if(a==3){
			b=b*3000;
		}
		if(a==4){
			b=b*2000;
		}
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int N;
int H[100010];
int dp[100010];

int main() {
  cin >> N;
  rep(i, 0, N) cin >> H[i];
  rep(i, 0, N) dp[i] = inf;
  dp[0] = 0;
  rep(i, 0, N) {
    chmin(dp[i+1], dp[i] + abs(H[i] - H[i+1]));
    chmin(dp[i+2], dp[i] + abs(H[i] - H[i+2]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
s = input()
N = len(s)
if s[0]=="0" or s[-1]=="1":
    print(-1)
    exit()
Ans = []
q = [0]
for i in range(1, N//2):
    c, cr = s[i], s[-2-i]
    if c!=cr:
        print(-1)
        exit()
    else:
        if c=="1":
            for u in q:
                Ans.append([u, i])
            q = [i]
        else:
            q.append(i)
i = N//2
if N%2==1:
    for u in q:
        Ans.append([u, i])
    for ans in Ans:
        print(ans[0]+1, ans[1]+1)
        print(N-ans[0], N-ans[1])
else:
    if len(q)==1:
        print(i, i+1)
        for ans in Ans:
            print(ans[0] + 1, ans[1] + 1)
            print(N - ans[0], N - ans[1])
    else:
        v = q.pop()
        for u in q:
            print(v+1, u+1)
            print(v+1, N-u)
        print(i, i+1)
        for ans in Ans:
            print(ans[0] + 1, ans[1] + 1)
            print(N - ans[0], N - ans[1])


Measured memory_bytes: 11616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  long double bunbo = 0;
  int n; cin >> n;
  rep(i,n){
    long double in; cin >> in;
    in = 1.0 / in;
    bunbo += in;
  }
  cout << fixed << setprecision(10) << 1.0/bunbo << endl;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a,b) memset(a, b, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 200010;

int a[maxn];
int dp[maxn];

int main(){
        _ios;

        int n; cin >> n;
        for(int i = 0; i<n; i++){
            cin >> a[i];
        }
        for(int i= 0; i<=n; i++){
            dp[i] = mod;
        }
        dp[0]=0;
        for(int i = 0; i<n; i++){
            if(i+1<n) dp[i+1] = min(dp[i+1], dp[i]+abs(a[i]-a[i+1]));
            if(i+2<n) dp[i+2] = min(dp[i+2], dp[i]+abs(a[i]-a[i+2]));
        }
        cout<<dp[n-1]<<endl;

return 0;
}


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

int main(){
  int a,b,c,d ;
  cin >> a >> b >> c >> d ;
  if(-1*d<=a-b&&a-b<=d&&-1*d<=b-c&&b-c<=d) cout << "Yes" << endl ;
  else if(-1*d<=a-c&&a-c<=d) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[])
{
	//input
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++){
		cin >> x[i];
	}


	//calc
	int min_sum = INT_MAX;
	for (int j = 1; j <= 100; j++){
		int sum = 0;
		for (int i = 0; i < n; i++){
			sum += (j - x[i]) * (j - x[i]);
		}
		
		if (sum < min_sum){
			min_sum = sum;
		}
	}

	//ans
	int ans = min_sum;
	cout << ans << endl;


	return 0;
}


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

struct P
{
    int x, y;

    bool operator<(const P &a)const{
              return y>a.y;
    }

};


//vector<P> v[100100];
vector<int> v;
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[111111];
int l[111111];
//int z1[1000100],z2[1000100];
int j[1];
int e[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=1000000007,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1];
//stack<int> s;

//set<long long> s;
queue<int> q;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<long long,int> p;
//list<int> l;

//string r;
//char r[1100222],r1[1101000];
//deque<int> de;
//srand((int)time(NULL));


bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    n=0;
    m=0;
    c=0;
    d=0;

    int n1,m1,c1,d1;
    n1=m1=c1=d1=0;
    for(int t=1;t<=a;t+=2)
    {
        l[o[t]]++;
        if(l[o[t]]>=m)
        {
            c=n;
            d=m;
            n=o[t];
            m=l[o[t]];
        }
        else if(l[o[t]]>=d)
        {
            d=l[o[t]];
            c=o[t];
        }
    }
    memset(l,0,sizeof(l));


    for(int t=2;t<=a;t+=2)
    {
        l[o[t]]++;
        if(l[o[t]]>=m1)
        {
            c1=n1;
            d1=m1;
            n1=o[t];
            m1=l[o[t]];
        }
        else if(l[o[t]]>=d1)
        {
            d1=l[o[t]];
            c1=o[t];
        }
    }

    if(n1==n)
    {
        int x=max(m1,m);
        if(n1!=c)
        x=max(x,m1+d);
        if(n!=c1)
            x=max(x,m+d1);
        if(c1!=c)
            x=max(x,d1+d);
        printf("%d",a-x);
    }
    else
    printf("%d",a-m1-m);
}


Measured memory_bytes: 1024
import copy


N = int(input())
*T, = map(int, input().split())

M = int(input())

A = []
for _ in range(M):
    P,X = map(int, input().split())
    A.append([P,X])


for i in range(M):
    sum = 0
    P,X = A[i][0],A[i][1]
    P = P-1
    for j in range(N):
        if P!=j:
            sum = sum + T[j]
        else:
            sum = sum + X
    print(sum)


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  vector<vector<int>> G(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b), G.at(b).push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (auto g : G.at(i)) if (H.at(g) >= H.at(i)) goto NG;
    ans++;
    NG:;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 8648
import sys

def solve(n, lst_a):
    a=lst_a[0]
    b=lst_a[0]
    [0]
    for i in lst_a:
        if a <i:
            a=i
        elif b>i:
            b=i
    return a-b

def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    n = int(line1)
    line2 = sys.stdin.readline().rstrip()
    lst_a = [int(s) for s in line2.split(' ')]
    return (n, lst_a)

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

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int d=sc.nextInt(); 
    int t=sc.nextInt(); 
    int s=sc.nextInt(); 
    if((s*t)<d){
     System.out.print("No"); 
    }else{
       System.out.print("Yes"); 
    }
  }
}

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

int n;
ll a[200];
ll Max=INT_MIN;
bool b[105];

void dfs(int p,ll c){
	if(p==n+1){
		Max=max(Max,c);
		return;
	}
	ll cnt=0;
	for(int i=p;i<=n;i++){
		if(!b[i]&&a[i]>0)cnt+=a[i];
	}
	if(c+cnt<Max)return;
	if(b[p]==1)dfs(p+1,c);
	else{
		map<int,bool>d;
		for(int j=p;j<=n;j+=p){
			d[j]=b[j];
			b[j]=1;
		}
		dfs(p+1,c);
		for(int j=p;j<=n;j+=p){
			b[j]=d[j];
		}
		dfs(p+1,c+a[p]);
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dfs(1,0);
	cout<<Max<<endl;
}

Measured memory_bytes: 384
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

const ll MAX_V = 205;
struct edge {long long to, cap, rev; };  // 行き先、容量、逆辺

vector<edge> G[MAX_V];  // 隣接リスト
bool used[MAX_V];  // すでに訪問済みかのフラグ

// fromからtoへの容量capの辺をグラフに追加する
void add_edge(long long from, long long to, long long cap) {
    G[from].push_back((edge){to, cap, (ll)G[to].size()});
    G[to].push_back((edge){from, 0, (ll)(G[from].size()-1)});
}

// DFSで増加パスを探索
long long dfs(long long v, long long t, long long f) {
    if (v == t) return f;
    used[v] = true;
    for (int i=0; i<G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            long long d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流を求める
long long max_flow(long long s, long long t) {
    long long flow = 0;
    for (;;) {
        REP(i, MAX_V) used[i] = false;
        long long f = dfs(s, t, HIGHINF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    ll sx, sy, tx, ty;
    REP(i, h) {
        REP(j, w) {
            char a; cin >> a;
            if (a == 'S') {
                add_edge(0, i + 1, HIGHINF);
                add_edge(0, j + h + 1, HIGHINF);
                sx = i, sy = j;
            } else if (a == 'T') {
                add_edge(i + 1, MAX_V - 1, HIGHINF);
                add_edge(j + h + 1, MAX_V - 1, HIGHINF);
                tx = i, ty = j;
            } else if (a == 'o') {
                add_edge(i + 1, j + h + 1, 1);
                add_edge(j + h + 1, i + 1, 1);
            }
        }
    }

    if (sx == tx || sy == ty) {
        cout << -1 << '\n';
        return 0;
    }
    ll ans = max_flow(0, MAX_V - 1);
    cout << (ans == HIGHINF ? -1 : ans) << '\n';
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  bool ok = true;
  rep(i,S.size()){
    if(i%2==0){
      if(S[i] == 'L') ok = false;
    }else{
      if(S[i] == 'R') ok = false;
    }
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = infll;
        for (ll i = 0; i < w - 2; i++)
        {
            ll s1 = i * h;
            ll s2 = ((w - i) / 2) * h;
            ll s3 = ((w - i + 2 - 1) / 2) * h;
            chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
        for (ll i = 0; i < h - 2; i++)
        {
            ll s1 = i * w;
            ll s2 = ((h - i) / 2) * w;
            ll s3 = ((h - i + 2 - 1) / 2) * w;
            chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
        for (ll i = 1; i < w; i++)
        {
            ll s1 = i * h;
            ll s2 = (w - i) * (h / 2);
            ll s3 = (w - i) * ((h + 2 - 1) / 2);
            chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
        for (ll i = 1; i < h; i++)
        {
            ll s1 = i * w;
            ll s2 = (h - i) * (w / 2);
            ll s3 = (h - i) * ((w + 2 - 1) / 2);
            chmin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3644
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m,c = inpl()
b = inpl()
a = [0] * n
res = 0
for i in range(n):
    a[i] = inpl()
for i in range(n):
    tmp = c
    for j in range(m):
        tmp += a[i][j] * b[j]
    if tmp > 0:
        res += 1
print(res)


Measured memory_bytes: 38764
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
typedef pair<int,int> P;
vector<P> link[100000];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n-1;i++){
		int u,v,w;
		cin >> u >> v >> w;
		u--,v--;
		link[u].push_back(P(v,w));
		link[v].push_back(P(u,w));
	}

	int color[n];
	int dist[n];
	for(int i=1;i<n;i++) color[i]=-1;
	color[0]=0;
	dist[0]=0;
	stack<int> s;
	s.push(0);
	while(!s.empty()){
		int p=s.top();s.pop();
		for(P v:link[p]){
			if(color[v.first]>=0) continue;
			dist[v.first]=dist[p]+v.second;
			if(dist[v.first]%2) color[v.first]=1;
			else color[v.first]=0;
			s.push(v.first);
		}
	}
	for(int i=0;i<n;i++) cout << color[i] << endl;
	return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <map>
#include <string>
#include <set>
using namespace std;
class Dice {
public:
  int c[6];
  bool operator <(const Dice &d) const {
    for(int i = 0; i < 6; i++) {
      if(c[i] != d.c[i]) return c[i] < d.c[i];
    }
    return false;
  }

  void sort() {
    for(int i = 0; i < 6; i++) {
      if(c[i] == 0) {
	switch(i) {
	case 0: break;
	case 1: rotateY(-1); break;
	case 2: rotateX(-1); break;
	case 3: rotateX(1); break;
	case 4: rotateY(1); break;
	case 5: rotateX(2); break;
	}
	break;
      }
    }
    int minc = 9999;
    int pos;
    for(int i = 1; i <= 4; i++) {
      if(c[i] < minc) {
	minc = c[i];
	pos = i;
      }
    }
    switch(pos) {
    case 1: break;
    case 2: rotateZ(-1); break;
    case 3: rotateZ(1); break;
    case 4: rotateZ(2); break;
    }
  }

  void rotateX(int dx) {
    int d = 1;
    if(dx < 0) {
      d *= -1;
      dx *= -1;
    }
    for(int i = 0; i < dx; i++) {
      int tmp;
      if(d > 0) {
	tmp = c[0];
	c[0] = c[3];
	c[3] = c[5];
	c[5] = c[2];
	c[2] = tmp;
      } else {
	tmp = c[0];
	c[0] = c[2];
	c[2] = c[5];
	c[5] = c[3];
	c[3] = tmp;
      }
    }
  }
  void rotateY(int dy) {
    int d = 1;
    if(dy < 0) {
      d *= -1;
      dy *= -1;
    }
    for(int i = 0; i < dy; i++) {
      int tmp;
      if(d > 0) {
	tmp = c[0];
	c[0] = c[4];
	c[4] = c[5];
	c[5] = c[1];
	c[1] = tmp;
      } else {
	tmp = c[0];
	c[0] = c[1];
	c[1] = c[5];
	c[5] = c[4];
	c[4] = tmp;
      }
    }
  }
  void rotateZ(int dz) {
    int d = 1;
    if(dz < 0) {
      d *= -1;
      dz *= -1;
    }
    for(int i = 0; i < dz; i++) {
      int tmp;
      if(d > 0) {
	tmp = c[1];
	c[1] = c[3];
	c[3] = c[4];
	c[4] = c[2];
	c[2] = tmp;
      } else {
	tmp = c[1];
	c[1] = c[2];
	c[2] = c[4];
	c[4] = c[3];
	c[3] = tmp;
      }
    }
  }
};



int main() {
  map<string, int> color;
  color["Red"] = 0;
  color["Yellow"] = 1;
  color["Blue"] = 2;
  color["Magenta"] = 3;
  color["Green"] = 4;
  color["Cyan"] = 5;

  while(1) {
    int n;
    set<Dice> s;
    Dice dice;
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 6; j++) {
	string str;
	cin >> str;
	dice.c[j] = color[str];
      }
      dice.sort();
      s.insert(dice);
    }
    cout << n - s.size() << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  ll n, b, r, ball_count, ans = 0;
  cin >> n >> b >> r;
  ball_count = b + r;
  ans = n / ball_count * b +
        (n - n / ball_count * ball_count < b ? n - n / ball_count * ball_count : b);
  cout << ans << endl;
}

signed main() {
  solve();

  return 0;
}

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

#define MOD 1000000007
using namespace std;

double n, m,x,y;
string s;

int main() {
	cin >> n >> m>>x>>y;
	cout << setprecision(20)<<(n * m) / 2.0 << endl;
	if (x * 2 == n && y * 2 == m)cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
MOD = 1000000007  # type: int

# 逆元comb
def comb(n, k):
    k = min(n-k,k)
    ans = 1
    for i in range(1, k + 1):
        ans *= (n + 1 - i) * pow(i,MOD-2,MOD)
        ans %= MOD
    return ans

def solve(X: int, Y: int):
    if (X+Y)%3 != 0 or Y*2-X < 0 or X*2-Y < 0:
        print(0)
        return

    # (1,2)の移動をa回, (2,1)の移動をb回するとするをそれぞれ何回か決まる
    a = (Y*2-X)//3
    b = (X*2-Y)//3
    print(comb(a+b,a))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();
        final int d = sc.nextInt();
        final int[][] x = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] = sc.nextInt();
            }
        }

        int ans = 0;

        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (i == j) continue;
                double sum = 0;
                for (int k = 0; k < d; k++) {
                    sum += Math.pow(x[i][k] - x[j][k], 2);
                }
                if (Math.sqrt(sum) == Math.floor(Math.sqrt(sum))) {
                    ans++;
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import math
a,b,x = map(int,input().split())
if a**2*b/2 <= x:
	atant = 2*(b/a-x/a**3)
	print(math.degrees(math.atan(atant)))
else:
	atant = a*b**2/(2*x)
	print(math.degrees(math.atan(atant)))

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	TLong n;
	TLong tb[90] = {0};
	tb[0] = 2;	tb[1] = 1;
	for (int i = 2; i <= 86; ++i)	tb[i] = tb[i - 1] + tb[i - 2];
	scanf("%lld",&n);
	printf("%lld\n", tb[n]);
	return 0;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll A[202020];
ll K;
ll i, j, k;
ll B[202020];

int main(){
    scanf("%lld", &N);
    rep(i,0,N){
        scanf("%lld", &A[i]);
        K ^= A[i];
    }
    rep(i,0,N){
        printf("%lld ", A[i] ^ K);
    }
    
    return 0;
}

Measured memory_bytes: 5404
S = input()

flag = True
for i, s in enumerate(S):
    if i % 2 == 0:
        if s in ["R", "U", "D"]:
            continue
        else:
            flag = False
    else:
        if s in ["L", "U", "D"]:
            continue
        else:
            flag = False


if flag:
    print("Yes")
else:
    print("No")


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


int main(){
  vector<string> s(3);
  for(int i=0;i<3;++i){
    cin >> s[i];
  }
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
  return 0;
}


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

   
using namespace std; 

int main(){
	int c[100005]={0},d[100005]={0};
	int n,i,j;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){
		cin >> a[i];
		if(a[i]==0){
			c[a[i]]++;
			c[a[i]+1]++;
		}else{
			c[a[i]]++;
			c[a[i]+1]++;
			c[a[i]-1]++;
		}
	}
	
	
	int t=0;
	

	for(i=0;i<100000;i++){
	
		if(c[t]<c[i]){
			t=i;
			
		}
		
	}

	
	
	printf("%d ",c[t]);
}

Measured memory_bytes: 1024
/*
#include <bits/stdc++.h>
//*/
//*
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
//*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
    const long long INF = LLONG_MAX / 10;
#else
    const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;



signed main()
{
    string S;
    
    cin >> S;
    if (S.substr(0, 4) == "YAKI") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const int INF = 1e9;
	int N;
	cin >> N;
	vector<int> a(N), b(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	for (int i = 0; i < N; ++i) { cin >> b[i]; }

	int ans = INF;
	for (int i = 0; i < (1<<N); ++i) {
		vector<pair<int, int>> odd, even;
		for (int j = 0; j < N; ++j) {
			if ((i>>j) & 1) {
				if (j % 2 == 0) { even.emplace_back(a[j], j); }
				else { odd.emplace_back(a[j], j); }
			} else {
				if (j % 2 == 0) { odd.emplace_back(b[j], j); }
				else { even.emplace_back(b[j], j); }
			}
		}
		if (even.size() < odd.size() || even.size() > odd.size() + 1) {
			continue;
		}

		sort(even.begin(), even.end());
		sort(odd.begin(), odd.end());
		vector<pair<int, int>> x(N);
		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (i % 2 == 0) { x[i] = even[i / 2]; }
			else { x[i] = odd[i / 2]; }

			if (i > 0 && x[i].first < x[i - 1].first) { ok = false; }
		}
		if (!ok) { continue; }

		int tmp = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (x[i].second > x[j].second) { ++tmp; }
			}
		}
		ans = min(ans, tmp);
	}
	cout << (ans < INF ? ans : -1) << endl;

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    vector<int> A(5);
    for(int i = 0; i < 5; i++){
        cin >> A[i];
    }
    int k;
    cin >> k;
    sort(all(A));
    if(A[4]-A[0] <= k) puts("Yay!");
    else puts(":(");
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

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

struct P {
  int keta;
  int num;
};

int main(int argc, char** argv) {
  int N, M;
  std::cin >> N >> M;
  std::vector<P> c(M);
  rep(i,M) std::cin >> c[i].keta >> c[i].num;
  std::vector<char> Number(N, 'a');

  bool is_error = false;
  rep(i, M) {
    if (Number[c[i].keta - 1] == 'a') {
      Number[c[i].keta - 1] = c[i].num + '0';
    } else if (Number[c[i].keta - 1] != c[i].num+'0') {
      is_error = true;
      break;
    }
  }
  if (is_error == true) {
    std::cout << "-1\n";
  } else if (N == 1) {
    if (Number[0] != 'a') {
      std::cout << Number[0];
    } else {
      std::cout << "0\n";
    }
  } else if (Number[0] == '0') {
    std::cout << "-1\n";
  } else {
    rep(i, N) {
      if (Number[i] == 'a' && i == 0) std::cout << '1';
      else if (Number[i] == 'a') std::cout << '0';
      else std::cout << Number[i];
    }
  }
}


Measured memory_bytes: 384
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
const ll M=1000000007;
int n,m;
vector<int>G[211111];

int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	rep(i,G[0].size()){
		rep(j,G[G[0][i]].size()){
			if(G[G[0][i]][j]==n-1){
			cout<<"POSSIBLE"<<endl;
			return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt=0;
    for (int i=0;i<N;++i){
        string S; cin >> S;
        cnt+=(S=="A"?1:-1);
        if (cnt<0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << (cnt?"NO":"YES") << endl;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
vector<int> arr;
vector<long long> vaal;
long long functFrog(int n){
    if(vaal[n]!=-1) return vaal[n];
    if(n==0) return LONG_MAX;
    if(n==1){
        vaal[n] = abs(arr[n]-arr[n-1]);
        return vaal[n];
    } 
    if(n==2){
        vaal[n] =abs(arr[n]-arr[n-2]);
        return vaal[n];
    }
    if(n>2){
        vaal[n] =min(abs(functFrog(n-1)+abs(arr[n]-arr[n-1])),abs(functFrog(n-2)+abs(arr[n]-arr[n-2])));
        return vaal[n];
    }
}


int main(){
    int n;
    cin >> n;
    arr = vector<int>(n);
    vaal = vector<long long>(n,-1);
    for(int i=0;i<n;i++) cin >> arr[i];
    long long value = functFrog(n-1);
    cout << value << "\n";
    return 0;
}

Measured memory_bytes: 3712
import std.stdio;
import std.algorithm;
import std.math;

void main(){
	int n, h, m, longHand, shortHand, angle;
	readf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		readf("%d:%d\n", &h, &m);
		longHand = h*60 + m;
		shortHand = 2*6*m;
		angle = abs(longHand - shortHand);
		angle = min(2*360 - angle, angle);
		if (angle >= 0 && angle < 2*30) writeln("alert");
		else if (angle >= 2*90 && angle <= 2*180) writeln("safe");
		else writeln("warning");
	}
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pb push_back
#define all(a) a.begin(),a.end()
#define i64 long long int
const double pi = 2*acos(0) ;
const int maxn = (i64)2e5+5;

int main()
{
    int n,i,j;
    cin>>n;
    int arr[n];
    for(i = 0 ; i<n ; i++)
    {
        cin>>arr[i];
    }
    int mx = -1;
    for(i = 0 ; i<n ; i++)
    {
        int cnt = 0;
        for(j = i ; j<n-1 ; j++)
        {
            if(arr[j]>=arr[j+1]) cnt++;
            else break;
        }
        mx = max(cnt,mx);
        i=j;
    }
    cout<<mx;

return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    ll X;
    cin >> X;
    for(ll i=1;i<=2e3;i++){
        for(ll j=-2e3;j<=2e3;j++){
            if(i*i*i*i*i - j*j*j*j*j == X){
                cout << i << " " << j << endl;
                return;
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>

int main(void){
    int N;
    scanf("%d",&N);
    int x[8] = {};
    int y[8] = {};
    for(int i=0;i<N;i++){
        scanf("%d %d",&x[i],&y[i]);
    }
    double l[100]= {};
    int k=0;
    double sum = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            l[k] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            sum += l[k];
            k++;
        }
    }
    printf("%lf",2*sum/(N));
    return 0;
}

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

int main(){
  int n,tmp;

  while(1){
    cin >> n;
    if(!n)break;

    vector<int> a,b;
    for(int i=0;i<n;i++){
      cin >> tmp;
      a.push_back(tmp);
    }
    sort(a.begin(),a.end());

    for(int i=0;i<n;i++){
      cin >> tmp;
      b.push_back(tmp);
    }
    sort(b.begin(),b.end());

    while(a.size() || b.size()){
      bool f = false;
      while(a.size() && !a[0])a.erase(a.begin());
      while(b.size() && !b[0])b.erase(b.begin());
      if(a[(int)a.size()-1] == (int)b.size()){
	for(int i=0;i<(int)b.size();i++)b[i]--;
	a.erase(a.end()-1);
	f = true;
      }else if(b[(int)b.size()-1] == (int)a.size()){
	for(int i=0;i<(int)a.size();i++)a[i]--;
	b.erase(b.end()-1);
	f = true;
      }
      if(!f)break;
    }
 
    if(a.empty() && b.empty())cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1016
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, k, T, x, y, cnt;
ll vv[55];

int main(void)
{
	cin>>k; n=50; T=k/n; ll i;
	x=T+2*n-k%n; y=x-n-1;
	for(i=1 ; i<=k%n ; i++) vv[i]=x;
	for(i=k%n+1 ; i<=n ; i++) vv[i]=y;
	cout<<n<<"\n";
	for(i=1 ; i<=n ; i++) cout<<vv[i]<<" ";
	return 0;
}


// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int dp[55][55][2510];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	int ans = INF;
	int  a = 0, b = 0, c = 0;
	rep(i, 2) {
		rep(j, w - 1) {
			a = (j + 1)*h;
			b = (h / 2)*(w - j - 1);
			c = ((h + 1) / 2)*(w - j - 1);
			chmin(ans, max({ a,b,c }) - min({ a,b,c }));
		}
		swap(h, w);
	}
	chmin(ans, min((w + 2) / 3 * h - (w / 3)*h, (h + 2) / 3 * w - (h / 3)*w));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256