akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        Scanner sc = new Scanner(is);
        /* read */
        int n = sc.nextInt();

        Map<Integer, Set<Integer>> lists = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            Set<Integer> list = new HashSet<>();

            for (int j = 0; j < n; j++) {
                if (s.charAt(j) == '1') {
                    // matrix[i][j] = true;
                    list.add(j);
                }
            }
            lists.put(i, list);
        }

        int max = -1;
        for (int i = 0; i < n; i++) {
            max = Math.max(depth(i, lists, n), max);
        }

        os.println(max);
    }

    private static class Node {
        int node;
        Set<Integer> parents = new HashSet<>();
    }

    private static int depth(int start, Map<Integer, Set<Integer>> lists, int N) {
        HashMap<Integer, HashSet<Integer>> tempLists = new HashMap<>();
        for (int j = 0 ; j < N ; j++) {
            tempLists.put(j, new HashSet<>(lists.get(j)));
        }
        Set<Integer> visited = new HashSet<>();
        Set<Node> curr = new HashSet<>();
        Node s = new Node();
        s.node = start;
        curr.add(s);

        int count = 0;
        while (visited.size() < tempLists.size()) {
            count++;
            Map<Integer, Node> next = new HashMap<>();
            for (Node n : curr) {
                Set<Integer> nexts = tempLists.get(n.node);
                for (int nx : nexts) {
                    if (n.parents.contains(nx)) {
                        // parent. ignore
                        continue;
                    }
                    if (visited.contains(nx)) {
                        // visiting again
                        return -1;
                    }
                    Node node;
                    if (next.containsKey(nx)) {
                        node = next.get(nx);
                    } else {
                        node = new Node();
                        node.node = nx;
                        next.put(nx, node);
                    }
                    node.parents.add(n.node);
                }
                visited.add(n.node);
            }
            for (Node n : curr) {
                for(Integer child : next.keySet()) {
//                    tempLists.get(child).remove(n.node);
                }
            }
            curr = new HashSet<>(next.values());
        }
        return count;
    }
}

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

int main(){
    int h,a;
    cin >> h >> a;
    int cnt=0;
    while(h){
        h = h-a;
        if(h < 0) h= 0;
        cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

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

int main(void) {
	int k = 0;
	int sum = 0;
	scanf("%d", &k);
	for (int i = 1;i <= k;i++) {
		for (int j = 1;j <= k;j++) {
			int A = gcd(i, j);
			for (int l = 1;l <= k;l++) {
				sum += gcd(A, l);
			}
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
int K[3][8] = {
	{1,1,1,1,-1,-1,-1,-1},
	{1,1,-1,-1,1,1,-1,-1},
	{1,-1,1,-1,1,-1,1,-1}
};
int main() {
	ll x, y, z;
	ll A[8][1000];
	ll max = -100000000000;
	int N, M;
	cin >> N >> M;

	for (int i = 0; i < N; i++)
	{
		cin >> x >> y >> z;
		for (int j = 0; j < 8; j++)
		{
			A[j][i] = K[0][j] * x + K[1][j] * y + K[2][j] * z;
		}
	}

	for (int i = 0; i < 8; i++)
	{
		sort(A[i], A[i] + N, greater<ll>());
	}

	for (int i = 0; i < 8; i++)
	{
		ll tmp = 0;
		for (int j = 0; j < M; j++)
		{
			tmp += A[i][j];
		}
		if (tmp > max) {
			max = tmp;
		}
	}

	cout << max << endl;

	return 0;
}

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

int main() {
	// your code goes here
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
				cout<<"OK";
				return 0;
		}
	
	}
	cout<<"NG";
	return 0;
}

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

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

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

import qualified Data.ByteString.Char8 as B

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

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

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

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

main = do
	[ k, x ] <- readInts
	putStrLn $ if k * 500 < x
		then "No"
		else "Yes"

Measured memory_bytes: 380
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
int n;
struct db{
    int a,b;
}e[100001];
bool comp1(db x,db y)
{
    return x.b<y.b;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>e[i].b;
        e[i].a=i;
    }
    sort(e+1,e+n+1,comp1);
    for(int i=1;i<=n;i++)printf("%d ",e[i].a);
    return 0;
}


Measured memory_bytes: 1536
if __name__ == '__main__':

	S = input()

	s_len = len(S) - 1
	sum = 0
	for i in range(2**s_len):
		A = S[0]
		for j in range(s_len):
			if ((i >> j) & 1):
				A += "+" + S[j+1]
			else:
				A += S[j+1]
		sum += eval(A)

	print(sum)

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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int  n; cin >> n;
    int a[n], pre[n]={}; for(int &i : a) cin >> i;
    for(int  i= 0; i < n; i++) {
        if(i) pre[i] = pre[i-1];
        pre[i] += a[i];
    }    

    int ans = 1e9;
    for(int i = 0; i < n; i++) {
        int res=0;
        res += pre[n-1] - pre[i];
        res -= pre[i];
        ans = min(ans, abs(res)); 
    }
    cout << ans;
}

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

typedef long  long ll;
#define FF first
#define SS second
#define INF 2000000000


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

    int n;
    cin >> n;

    float x = 2.0 * 3.14159265358979323 * n;
    cout << x << "\n";

}



Measured memory_bytes: 3792
import sys
c=[[int(i) for i in l.split()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

ll dp[100005][13];

int main() {
  string s, t;
  cin >> s;
  int n = s.size();
  
  dp[0][0] = 1;
  rep(i, n) {
    int c;
    if (s[i] == '?') c= -1;
    else c = s[i] - '0';

    rep(j, 10) {
      if (c != -1 and c != j) continue;
      rep(ki, 13) {
        dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
      }
    }
    rep(j, 13) dp[i+1][j] %= MOD;
  }

  ll res = dp[n][5];
  cout << res << endl;
}
  

Measured memory_bytes: 10624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		int[] num = new int[c.length];
		for(int n = 0; n < c.length;n++) {
			num[n] = c[n] - '0';
		}
		if((num[0]+num[1]+num[2]+num[3])==7) {
			System.out.println(num[0] + "+"+ num[1]+"+"+num[2]+"+"+num[3]+"=7");
		}
		else if((num[0]+num[1]+num[2]-num[3])==7) {
			System.out.println(num[0] + "+"+ num[1]+"+"+num[2]+"-"+num[3]+"=7");
		}
		else if((num[0]+num[1]-num[2]+num[3])==7) {
			System.out.println(num[0] + "+"+ num[1]+"-"+num[2]+"+"+num[3]+"=7");
		}
		else if((num[0]+num[1]-num[2]-num[3])==7) {
			System.out.println(num[0] + "+"+ num[1]+"-"+num[2]+"-"+num[3]+"=7");
		}
		else if((num[0]-num[1]+num[2]+num[3])==7) {
			System.out.println(num[0] + "-"+ num[1]+"+"+num[2]+"+"+num[3]+"=7");
		}
		else if((num[0]-num[1]+num[2]-num[3])==7) {
			System.out.println(num[0] + "-"+ num[1]+"+"+num[2]+"-"+num[3]+"=7");
		}
		else if((num[0]-num[1]-num[2]+num[3])==7) {
			System.out.println(num[0] + "-"+ num[1]+"-"+num[2]+"+"+num[3]+"=7");
		}
		else if((num[0]-num[1]-num[2]-num[3])==7) {
			System.out.println(num[0] + "-"+ num[1]+"-"+num[2]+"-"+num[3]+"=7");
		}
	}
}


Measured memory_bytes: 39456
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n;
  cin >> n;
  vector< vector<int> > g(n, vector<int>(n));
  int u, k;
  for(int i=0; i<n; i++){
    cin >> u >> k;
    int v;
    for(int j=0; j<k; j++){
      cin >> v;
      g[u-1][v-1] = 1;
    }
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if( j != n-1 ) cout << g[i][j] << " ";
      else cout << g[i][j] << endl;
    }
  }

  return 0;
}

// EOF

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	ll first, last;
	for (int i = k; i <= n + 1; ++i) {
		first = ll(i - 1) * ll(i) / ll(2);
		last = (ll(n) + ll(n + 1 - i))*ll(i) / ll(2);
		ans += last - first + 1;
		ans %= ll(MOD);
	}
	cout << ans << endl;
	return 0;
}

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

int calcGCD(int, int);

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> A(N);
	for (auto& e: A) scanf("%d", &e);
	int minus{}, zero{};
	for (auto& e: A)
		if (e < 0)
			minus++;
		else if (e == 0)
			zero++;

	long long sum{};
	for (auto& e: A) sum += std::abs(e);
	if (zero == 0 && minus % 2 == 1)
	{
		int min{1 << 30};
		for (auto& e: A) min = std::min(min, std::abs(e));
		sum -= 2 * min;
	}
	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 640
import std.stdio, std.string, std.conv;

void main()
{
    loop:
    do
    {
        bool[8][8] map;

        foreach(y; 0..8) foreach(x, c; readln.chomp)
        {
            map[y][x] = c == '1';
        }

        foreach(y; 0 .. 7) foreach(x; 0 .. 7)
        {
            if(map[y][x] && map[y + 1][x] && map[y][x + 1] && map[y + 1][x + 1])
            {
                "A".writeln;
                continue loop;
            }
        }

        foreach(y; 0 .. 5) foreach(x; 0 .. 8)
        {
            if(map[y][x] && map[y + 1][x] && map[y + 2][x] && map[y + 3][x])
            {
                "B".writeln;
                continue loop;
            }
        }

        foreach(y; 0 .. 8) foreach(x; 0 .. 5)
        {
            if(map[y][x] && map[y][x + 1] && map[y][x + 2] && map[y][x + 3])
            {
                "C".writeln;
                continue loop;
            }
        }

        foreach(y; 0 .. 6) foreach(x; 0 .. 7)
        {
            if(map[y][x + 1] && map[y + 1][x] && map[y + 1][x + 1] && map[y + 2][x])
            {
                "D".writeln;
                continue loop;
            }
        }

        foreach(y; 0 .. 7) foreach(x; 0 .. 6)
        {
            if(map[y][x] && map[y][x + 1] && map[y + 1][x + 1] && map[y + 1][x + 2])
            {
                "E".writeln;
                continue loop;
            }
        }

        foreach(y; 0 .. 6) foreach(x; 0 .. 7)
        {
            if(map[y][x] && map[y + 1][x] && map[y + 1][x + 1] && map[y + 2][x + 1])
            {
                "F".writeln;
                continue loop;
            }
        }

        foreach(y; 0 .. 7) foreach(x; 0 .. 6)
        {
            if(map[y + 1][x] && map[y + 1][x + 1] && map[y][x + 1] && map[y][x + 2])
            {
                "G".writeln;
                continue loop;
            }
        }
    } while (readln !is null);
}

Measured memory_bytes: 1020
#include<iostream>

int main()
{
	int x;//x:?????¨?????°???
	int y = 1;//y:3????????????

	std::cin>>x;//??\???

	//3???????¨????
	for (int i = 0; i < 3; i++){
		y = y * x;
	}

	std::cout<<y<<std::endl;//??????
	return 0;
}

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

int main(){
  int h, w;
  while(true){
    cin >> h >> w;
    if(h==0 || w==0)
      break;

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++)
	cout << "#";
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include   <bits/stdc++.h>
#include   <stdio.h>
#include   <stdlib.h>
#define    mp make_pair
#define    ii   int
#define    ll  long long
#define    ld  long double
#define    pii  pair<ii,ii>
#define    pll  pair<ll,ll>
#define    vcii   vector<ii>
#define    vcll   vector<ll>
#define    vcd     vector<double>
#define    pb push_back
#define    vcs    vector<string>
#define    vpii   vector<pii>
#define    vpll   vector<pll>
#define    scll(x)  scanf("%lld",&x)
#define    pfll(x) printf("%lld\n",x)
#define    scd(x) scanf("%llf",&x)
#define    pfd(x) prinf("%0.5llf\n",x)
#define    pie acos(-1)

using namespace std;



int main()
{

   ll  t,n,a,b,d,i,j,c,s,m,test,q,area,area2,x,y,k;
   cin>>a>>b;
   if(b>=a)
   {
   	cout<<"unsafe\n";
   }
   else
   {
   	cout<<"safe\n";
   }
    return 0;
}





Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long n = sc.nextLong();

		lin: {
			for (int i = 0; i < 150; i++) {
				long a = (long) Math.pow(i, 5);
				if (a > n) {
					for (int j = 0; j < 150; j++) {
						long ans = a - (long) Math.pow(j, 5);
						if (ans == n) {
							System.out.println(i + " " + j);
							break lin;
						}
					}
				} else {
					for (int j = 0; j > -150; j--) {
						long ans = a - (long) Math.pow(j, 5);
						if (ans == n) {
							System.out.println(i + " " + j);
							break lin;
						}
					}
				}
			}
		}
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 36668
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);

  for (int i = 0; i < n; ++i) {
    cin >> x.at(i);
  }

  int res = INT_MAX;
  for (int i = 0; i < n - k + 1; ++i) {
    int tmpL = abs(x.at(i)) + abs(x.at(i + k - 1) - x.at(i));
    int tmpR = abs(x.at(i + k - 1)) + abs(x.at(i + k - 1) - x.at(i));
    int tmp = min(tmpL, tmpR);
    res = min(res, tmp);
  }
  cout << res << endl;
}

Measured memory_bytes: 640
# coding: utf-8
x, k, d = map(int,input().split())
x=abs(x)
t=x-k*d
if t>=0:
    ans=t
else:
    l=x//d#一番近いところまでの回数
    p=x%d#一番近いところ
    if (k-l)%2==0:
        ans=p
    else:
        ans=min(abs(p+d), abs(p-d))
print(ans)

Measured memory_bytes: 9164
#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;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<P>r(n), b(n);
	rep(i, n)cin >> r[i].first >> r[i].second;
	rep(i, n)cin >> b[i].first >> b[i].second;
	sort(ALL(b));
	int ans = 0;
	rep(i, n) {
		int tmp = -1;
		int idx = -1;
		rep(j, r.size()) {
			if (r[j].first < b[i].first&&r[j].second < b[i].second) {
				if (r[j].second > tmp) {
					tmp = r[j].second; idx = j;
				}
			}
		}
		if (idx >= 0) {
			ans++; r.erase(r.begin() + idx);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int n,p[11];scanf("%d",&n);for(int i=1;i<=n;++i) scanf("%d",&p[i]);
	sort(p+1,p+1+n);int ans=0;
	for(int i=1;i<n;++i) ans+=p[i];ans+=p[n]/2;printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        ll n;
                        cin>>n;
                        vector<vector<ll>> vec;
                        vll temp(n);
                        rep(i,0,n)
                                temp[i]=i+1;
                        do{
                                vec.pb(temp);
                        }
                        while(next_permutation(all(temp)));
                        vll fst(n),snd(n);
                        rep(i,0,n)
                                cin>>fst[i];
                        rep(i,0,n)
                                cin>>snd[i];
                        ll ans=0;
                        rep(i,0,vec.size()){
                                if(vec[i]==fst){
                                        ans=i;
                                        break;
                                }
                        }
                        rep(i,0,vec.size()){
                                if(vec[i]==snd){
                                        ans-=i;
                                        if(ans<0)
                                                ans*=-1;        
                                        cout<<ans;
                                        break;
                                }
                        }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                // cout<<"Case "<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 4408
n = int(input())
for i in range(0, n):
    nums = list(map(int, input().split()))
    max_num = max(nums)
    nums.remove(max_num)
    if max_num**2 == nums[0]**2 + nums[1]**2:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
//2015.6.16 「Convenient Location」
#include<iostream>
using namespace std;

const int INF = 1000000;

int main(){

	while(true){

		int n;		//道の数
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(i==j){
					T[i][j]=0;
				}
				else{
					T[i][j]=INF;
				}
			}
		}

		int m = 0;		//町の数	

		for(int i=0;i<n;i++){
			int a,b,c;
			cin >> a >> b >> c;
	
			T[a][b]=T[b][a]=c;

			//町の数を調べる
			if(a+1>m){		//aが大きい数の町の時		
				m=a+1;
			}
			if(b+1>m){		//bが大きい数の町の時	
				m=b+1;
			}
		}
	
		//ワーシャル-フロイト法
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j]=T[i][k]+T[k][j];
					}
				}
			}
		}

	
		int machi=0;
		int time=INF;
		int time2=0;

		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
	
				if(i!=j){
					time2+=T[i][j];
				}
			}


			if(time>time2){
				time=time2;
				machi=i;
			}
			time2=0;
			

		}
		
		cout << machi << ' ' << time << '\n'; 
	
	}
			

		return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void){
  int H,W,N;
  scanf("%d%d%d",&H,&W,&N);

  int a,counter = 0;
  int data[H*W];
  int ans[H][W];
  for(int i = 0;i < N;i++){
    scanf("%d",&a);
    int num = a;
    while(num > 0){
      data[counter+num-1] = i+1;
      num--;
    }
    counter += a;
  }

  counter = 0;
  for(int i = 0;i < H;i++){
    if(i%2 == 0){
      for(int j = 0;j < W;j++){
        ans[i][j] = data[counter];
        counter++;
      }
    }else{
      for(int j = W-1;j >= 0;j--){
        ans[i][j] = data[counter];
        counter++;
      }
    }
  }

  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      printf("%d",ans[i][j]);
      if(j != W-1) printf(" ");
    }
    printf("\n");
  }


  return 0;
}

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

typedef pair<double, int> P;

int n;

void dijkstra(int s, int g, vector<vector<pair<int, double>>> &G){
    vector<double> dist(n, 1e9);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(0, s);

    vector<int> prev(n, -1);

    while(que.size()){
        double ccost;
        int cv;
        tie(ccost, cv) = que.top();
        que.pop();

        if(dist[cv] < ccost) continue;

        for(auto x : G[cv]){
            int nv;
            double ncost;
            tie(nv, ncost) = x;

            if(dist[cv] + ncost < dist[nv]){
                dist[nv] = dist[cv] + ncost;
                prev[nv] = cv;
                que.emplace(dist[nv], nv);
            }
        }
    }

    if(dist[g] == 1e9){
        cout << "NA" << endl;
    }
    else{
        vector<int> ans;
        for(int i=g; i!=-1; i=prev[i]){
            ans.emplace_back(i);
        }
        reverse(ans.begin(), ans.end());

        for(int i=0; i<ans.size(); i++){
            cout << ans[i] + 1 << " \n"[i == ans.size() - 1]; 
        }
    }
}

int main(){
    while(1){
        cin>>n;
        if(n == 0) return 0;
        vector<int> b(n), x(n), y(n);
        for(int i=0; i<n; i++){
            cin>>b[i]>>x[i]>>y[i];
            b[i]--;
        }

        vector<vector<pair<int, double>>> G(n);
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                double cdist = sqrt(abs(x[i] - x[j]) * abs(x[i] - x[j]) + abs(y[i] - y[j]) * abs(y[i] - y[j]));
                if(50 < cdist) continue;
                G[b[i]].emplace_back(b[j], cdist);
                G[b[j]].emplace_back(b[i], cdist);
            }
        }

        int m; cin>>m;
        while(m--){
            int s, g; cin>>s>>g;
            s--, g--;
            dijkstra(s, g, G);
        }
    }
}


Measured memory_bytes: 2996
from collections import defaultdict

n = int(input())
s = input()

ans = 0
for i in range(n):
    dic = defaultdict(int)
    for j in range(i):
        for k in range(i, n):
            if s[j] == s[k]:
                dic[s[j]] += 1
                break
    ans = max(ans, len(dic))
    
print(ans)

Measured memory_bytes: 3316
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input()) - 1])

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

int solve(int n,int r){
  vector<int> l;
  for(int i=0;i<n;i++){
    l.push_back(i+1);
  }
  l = vector<int>(l.rbegin(),l.rend());
  for(int i=0;i<r;i++){
    int p,c;
    cin>>p>>c;
    vector<int> l1,l2;
    for(int j=0;j<l.size();j++){
      if(j<p-1){
        l1.push_back(l[j]);
      }else if(j<p+c-1){
        l2.push_back(l[j]);
      }else{
        l1.push_back(l[j]);
      }
    }
    for(int j=0;j<l1.size();j++){
      l2.push_back(l1[j]);
    }
    l = l2;
    //for(auto i:l)cout<<i<<" ";cout<<endl;
  }
  return l[0];
}


int main(){
  int n,r;
  while(cin>>n>>r,n!=0&&r!=0){
    cout<<solve(n,r)<<endl;
  }

}

Measured memory_bytes: 1220
#include <stdio.h>

int main() {
  int m, n, c;
  scanf("%d %d %d", &n, &m, &c);
  int cnt = 0;

  int b[25];
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }

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

  for (int i = 0; i < n; i++) {
    int sum = 0;
    // scanf("%d", &b[i]);

    for (int j = 0; j < m; j++) {
      sum += a[i][j] * b[j];
      // scanf("%d", &a[i][j]);
    }

    sum += c;
    if (sum > 0) {
      cnt++;
    }
  }
  printf("%d\n", cnt);

  return 0;
}

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

int main()
{
	int R, C;
	cin >> R >> C;
	vector<string> in(R);
	for(string& i: in) cin >> i;
	
	for(int i = 0; i < R; i++) {
		for(int k = 0; k < 2; k++) { // repeat every row two times
			cout << in[i];
			puts("");
		}
	}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[10000],c,d;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  c=a;
  for(int i=0;i<a/2;i++){
    d=b[i];
    b[i]=b[a-i-1];
    b[a-i-1]=d;
  }
  for(int i=0;i<c;i++){
    cout<<b[i];
    if(i<c-1){
      cout<<" ";
    }
  }
  cout<<"\n";
  return(0);
}



Measured memory_bytes: 3088
#include <iostream>

using namespace std;

void print(int *p, int n)
{
    cout << p[0];
    for (int i = 1; i < n; i++) cout << " " << p[i];
    cout << endl;
}

int main(void)
{
    int A[100];
    int N;
    int i, j, v;
    cin >> N;
    for (i = 0; i < N; i++) cin >> A[i];
    print(A, N);
    for (i = 1; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print(A, N);
    }
    return 0;
}


Measured memory_bytes: 3076
using System;

class MainClass : MyUtil
{
	public static void Main (string[] args)
	{
		while (true) {
			int[] ins = ReadIntMap();
			int n = ins[0], k = ins[1], s = ins[2];
			if (n + k + s == 0)
				break;
			Console.WriteLine(DFS(n, k, s));
		}
	}

	public static int DFS(int n, int k, int s){
		if (k == 0) {
			if (s == 0) {
				return 1;
			} else {
				return 0;
			}
		}
		if (n == 0 || s < 0)
			return 0;

		return DFS(n-1, k, s) + DFS(n-1, k-1, s-n);
	}
}

class MyUtil : MyIO
{
}

class MyIO
{
	public static String ReadLine ()
	{
		return Console.ReadLine ();
	}

	public static int[] ReadIntMap ()
	{
		string[] strs = Console.ReadLine ().Split (' ');
		int[] ret = new int[strs.Length];
		for (int i = 0; i < strs.Length; i++) {

			ret [i] = int.Parse (strs [i]);
		}
		return ret;
	}
}

Measured memory_bytes: 5620
/*	M
	   [0]   [1]   [2]   [3]   [4]   [5]
 [0]    0     0     0     0     0     0    
N[1]  INF   500   300   150   150   150   
 [2]  INF   INF  1250   675   675   675
 [3]  INF   INF   INF  1475  1275  1125
*/
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int N,M;
int n[1010],m[1010];
long long dp[1010][1010],INF=1000000000000LL;
int main(void){
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>n[i];
	}
	for(int i=0;i<M;i++){
		cin>>m[i];
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			dp[i][j]=INF;
		}
	}
	for(int i=0;i<=M;i++){
		dp[0][i]=0;
	}
	for(int i=0;i<N;i++){
		for(int j=1;j<=M;j++){
			dp[i+1][j]=min(dp[i][j-1]+n[i]*m[j-1],min(dp[i+1][j-1],dp[i+1][j]));
		}
	}
	/*for(int i=0;i<=N;i++){
		for(int j=0;j<M;j++){
			cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j];
		}
		cout<<endl;
	}*/
	cout<<dp[N][M]<<endl;
	return 0;
}


Measured memory_bytes: 9512
n=int(input())
x=list(map(int,input().split()))
x2=sorted(x)
bunsi=0
for i in range(n):
    bunsi+=x2[i]
ave=bunsi/n
ave=round(ave)
ans=0
for i in range(n):
    ans+=(x2[i]-ave)**2
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main() {
    int c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    int a[3], b[3];
    for (int i = 0; i < 3; i++)
    {
        b[i] = c[0][i];
    }
    for (int i = 0; i < 3; i++)
    {
        a[i] = c[i][0] - b[0];
    }

    bool ok = true;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if(a[i] + b[j] != c[i][j]) ok = false;
        }
    }

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

Measured memory_bytes: 256
def gcd(a: int, b: int) -> int:
    if a < b:
        a, b = b, a
    return a if b == 0 else gcd(b, a % b)


def lcm(a: int, b: int) -> int:
    return a * b // gcd(a, b)


def multiple_clocks(N: int, T: list) -> int:
    ans = 1
    for t in T:
        ans = lcm(ans, t)
    return ans


if __name__ == "__main__":
    N = int(input())
    T = [int(input()) for _ in range(N)]
    ans = multiple_clocks(N, T)
    print(ans)


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  char b;
  cin >> b;
  if(b == 'A'){
    cout << 'T' <<endl;
  }
  if(b == 'T'){
    cout << 'A' <<endl;
  }
  if(b == 'G'){
    cout << 'C' <<endl;
  }
  if(b == 'C'){
    cout << 'G' <<endl;
  }
}

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

int main() {
    int H, N; cin >> H >> N;
    int A = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        A += a;
    }
    if (H > A) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
def hantei(l):
    if l >= 1.1:
        return 'A'
    elif 0.6 <= l < 1.1:
        return 'B'
    elif 0.2 <= l < 0.6:
        return 'C'
    elif l  < 0.2 :
        return 'D'

ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
    try:
        l,r = map(float,raw_input().split())
        ls.append((l,r))
    except EOFError:
        break
        
for i,j in ls:
    ldic[hantei(i)] += 1
    rdic[hantei(j)] += 1
    
for L,R in zip(sorted(ldic),sorted(rdic)):
    print ldic[L],rdic[R] 

Measured memory_bytes: 4264
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = [(i, j) for (i, j) in zip(LI(), range(n))]
    a.sort(reverse=True)
    dp = [[0] * (n + 1) for i in range(n + 1)]
    for i in range(n):
        dp[i + 1][0] = dp[i][0] + a[i][0] * abs(a[i][1] - i)
        dp[0][i + 1] = dp[0][i] + a[i][0] * abs(a[i][1] - (n - (i + 1)))
        for l in range(1, i + 1):
            r = i - l + 1
            dp[l][r] = max(dp[l - 1][r] + a[i][0] * abs(a[i][1] - (l - 1)),
                            dp[l][r - 1] + a[i][0] * abs(a[i][1] - (n - r)))
    ans = 0
    for r in range(n + 1):
        l = n - r
        ans = max(ans, dp[l][r])
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 116328
#include<iostream>
#include<algorithm>
using Int = long long;
const Int INF = 1 << 30;

int main() {

	Int A, B, C, X, Y;
	std::cin >> A >> B >> C >> X >> Y;

	Int ans = INF;
	Int c_limit = std::max(X, Y)*2;

	for (Int i = 0; i <= c_limit; i++) {
		Int a = std::max(0LL,X - i/2);//aを買う枚数
		Int b = std::max(0LL,Y - i/2);//bを買う枚数
		//if (b <= 0)b = 0;
		Int sum = a * A + b * B + i * C;
		if (sum <= ans)ans = sum;
	}

	std::cout << ans << std::endl;

}

Measured memory_bytes: 256
N, K = map(int, input().split())
Ai = list(map(int, input().split()))
 
D = 40
Bi = []
for a in Ai:
    b = bin(a)[2:]
    b = ("0" * (D - len(b))) + b
    Bi.append(b)
 
result = ""
for i in range(D):
    count = 0 # 1の個数
    for i, b in enumerate(Bi):
        if b[0] == '1':
            count += 1
        Bi[i] = b[1:]
    if count >= N / 2:
        result += "0"
    else:
        result += "1"
    #count = count // 2
x = 0
for i in range(D):
    if result[0] == '1':
        a = pow(2, D - i - 1)
        if x + a <= K:
            x += a
    result = result[1:]
 
ans = 0
for a in Ai:
    ans += (a ^ x)
print(ans)

Measured memory_bytes: 17948
A, B, K = (int(i) for i in input().split())

ans_list=[]

maximum=max(A,B)

for num in range(1, maximum+1, 1):
    if((A%num == 0)and (B%num == 0)):
        ans_list.append(num)

print(ans_list[::-1][K-1])

Measured memory_bytes: 3060
#!/usr/bin/env python3
# GRL_4_B: Path/Cycle - Topological Sort

from collections import namedtuple


DirectedEdge = namedtuple('DirectedEdge', ('src', 'dest'))


def revert(edge):
    return edge._replace(src=edge.dest, dest=edge.src)


class Digraph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, edge):
        self._edges[edge.src].append(edge)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e

    def reversed(self):
        g = self.__class__(self.v)
        for e in self.edges():
            g.add(revert(e))

        return g


def sorted_topological(graph):
    return reversed(list(reverse_post(graph.reversed())))


def reverse_post(graph):
    def visit(v):
        if not visited[v]:
            visited[v] = True
            return True
        else:
            return False

    def leave(v):
        if not left[v]:
            left[v] = True
            vs.append(v)
        return False

    visited = [False] * graph.v
    left = [False] * graph.v
    vs = []

    for i in range(graph.v):
        if not visited[i]:
            stack = [(i, leave)]
            stack.extend((e.dest, visit) for e in graph.adj(i))
            while stack:
                v, f = stack.pop()
                if f(v):
                    stack.append((v, leave))
                    for e in graph.adj(v):
                        stack.append((e.dest, visit))
    return reversed(vs)


def run():
    v, e = [int(i) for i in input().split()]
    g = Digraph(v)

    for _ in range(e):
        s, t = [int(i) for i in input().split()]
        g.add(DirectedEdge(s, t))

    for v in sorted_topological(g):
        print(v)


if __name__ == '__main__':
    run()



Measured memory_bytes: 18000
#include<stdio.h>

int main(void){
    int N, x, n;
    scanf("%d", &N);
    
    x = (int) N/1.08;
    for(int i=0; i< 15; i++){
        n =  (int) ((x+i)*1.08);
        if( n==N){
            printf("%d\n", x+i);
            break;
        }
    }
    if(n != N) printf(":(\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int a[200][20];
int p[200][20];
int q[1<<10];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        rep(j,10)cin >> a[i][j];
    }
    rep(i,n){
        rep(j,11)cin >> p[i][j];
    }
    int ans = -inf;
    rep(bit,1<<10){
        if(bit==0){
            continue;
        }else{
            vector<int> cnt(n);
            rep(j,10){
                if((bit>>j)&1){
                    rep(k,n){
                        if(a[k][j]==1)cnt[k]++;
                    }
                }
            }
            int tmp = 0;
            rep(i,n){
                tmp += p[i][cnt[i]];
            }
            ans = max(ans,tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long



void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a && c<=b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define R(i,n) for(int i=0;i<n;i++)
using namespace std;main(){int N,M,i,j,D[999],C[1001];cin>>N>>M;R(i,N){cin>>D[i];}R(i,M){cin>>C[i];}vector<vector<int> >d(M+1,vector<int>(N+1,1<<30));d[0][0]=0;R(i,M){R(j,N+1){if(j==0){d[i+1][j]=d[i][j];}else{d[i+1][j]=min(d[i][j],d[i][j-1]+C[i]*D[j-1]);}}}printf("%d\n",d[M][N]);}

Measured memory_bytes: 5968
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int c = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            c++;
        }
    }
    if (c * 2 > n) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int bef;
int aft;
int sumbef;
int tax(int rate, int price) { return price*(100+rate)/100;}
int max(int a, int b){
  if (a<b) return b;
  else return a;
}
int main () {
  for (int i=1; cin >> bef && bef > 0; ++i) {
    cin >> aft;
    cin >> sumbef;
    int maximum = 0;
    for (int i=1; i<sumbef; ++i) {
      for (int j=i; j< sumbef; ++j){
	if (tax(bef,i) + tax(bef,j) == sumbef)
	  maximum = max(maximum, tax(aft,i)+tax(aft,j));
      }
    }
    cout << maximum << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ld = long double;

int main(){
    ld L;
    cin>>L;
    ld d = L/3;
    cout<<fixed<<setprecision(10);
    cout<<d*d*d<<'\n';
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n - 1));
  rep(i, n) {
    rep(j, n - 1) {
      int b;
      cin >> b;
      b--;
      a[i][j] = b;
    }
    reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;
  auto check = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      if (i > j) swap(i, j);
      q.push_back(P(i, j));
    }
  };
  rep(i, n) check(i);
  int day = 0;
  while(q.size()) {
    day++;
    sort(q.begin(), q.end());
    q.erase(unique(q.begin(), q.end()), q.end());
    vector<P> prevQ;
    swap(prevQ, q);
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  rep(i, n) {
    if (a[i].size() != 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;


int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main(){
 	string s;
  	cin >> s;
  	map<char,int> m;
  	for(char c:s){
     	m[c]++; 
    }
  	if(m.size()==2){
     	for(pair<int,int>p:m){
         	if(p.second!=2){
             	cout << "No" << endl;
              	return 0;
            }
        }
      	cout << "Yes" << endl;
      return 0;
    }
  	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>

#define F first
#define S second

using namespace std;

typedef pair<int,int>P;

int main(){
  int n,k,ans=0;
  int cnt[200005]={};
  
  priority_queue<int,vector<int>,greater<int> >pq;

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

  for(int i=1;i<=200000;i++){
    if(cnt[i]>0){
      pq.push(cnt[i]);
    }
  }

  while(pq.size()>k){
    ans+=pq.top();
    pq.pop();
  }

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

  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int modpow(int x,int n){
	int res=1;
	while(n>0){
		if(n&1) res=(res*x)%MOD;
		 x=(x*x)%MOD;
		 n>>=1;
	 }
	 return res;
}
signed main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	bool ok=1;

	if(n%2==1){
		if(a[0]!=0)ok=0;

		
		for(int i=1;i<n;i+=2){
			if(a[i]==i+1&&a[i+1]==i+1){
				;
			}else{
				ok=0;
			}
		}
	}else{
		for(int i=0;i<n;i+=2){
			if(a[i]==i+1&&a[i+1]==i+1){
				;
			}else{
				ok=0;
			}
		}
	}
	if(ok){
		cout<<modpow(2,n/2)<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 4032