akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    vector<int> a(1000000);
    int n;
    cin >> n;
    for(int x=1; x<=100; x++){
        for(int y=1; y<=100; y++){
            for(int z=1; z<=100; z++){
                a[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 7024
A, B = map(int, input().split())
a = set([])
b = set([])
n = 1
while n**2 <= max(A, B):
  if A%n == 0 and n**2 <= A:
    a.add(n)
    a.add(A//n)
  if B%n == 0 and n**2 <= B:
    b.add(n)
    b.add(B//n)
  n += 1
ab = a & b
ab.discard(1)
ab = list(ab)
answer = 0
for i, n in enumerate(ab):
  prime = True
  for j, m in enumerate(ab):
    if i != j and n%m == 0:
      prime = False
      break
  if prime:
    answer += 1
print(answer+1)


Measured memory_bytes: 73244
while True:
    try:
        N = int(input())
        count = 0
        for a in range(10):
            for b in range( 10):
                for c in range(10):
                    for d in range(10):
                        if a + b + c + d == N:
                            count += 1
        print(count)
    except EOFError:
        break



Measured memory_bytes: 5588
package main

import "fmt"

var table [][]string

type Pos struct {
	y, x int
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	table = make([][]string, h)
	for i := 0; i < h; i++ {
		table[i] = make([]string, w)
		var m string
		fmt.Scan(&m)
		for j := 0; j < w; j++ {
			table[i][j] = string([]rune(m)[j])
		}
	}
	if table[0][0] == "." || table[h-1][w-1] == "." {
		fmt.Println("Impossible")
		return
	}
	queue := []Pos{}
	queue = append(queue, Pos{y: 0, x: 0})
	for len(queue) > 0 {
		var cur Pos
		cur, queue = queue[len(queue)-1], queue[:len(queue)-1]
		if cur.y == h-1 && cur.x == w-1 {
			table[cur.y][cur.x] = "."
			break
		}
		steps := []int{0, 1, 0}
		for i := 0; i < 2; i++ {
			next_y, next_x := cur.y+steps[i], cur.x+steps[i+1]
			if 0 <= next_y && next_y < h && 0 <= next_x && next_x < w {
				if table[next_y][next_x] == "#" {
					next_Pos := Pos{next_y, next_x}
					queue = append(queue, next_Pos)
					table[cur.y][cur.x] = "."
				}
			}
		}
	}
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if table[y][x] == "#" {
				fmt.Println("Impossible")
				return
			}
		}
	}
	fmt.Println("Possible")

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define up(i, a, b) for (int i = a, _b = b; i <= _b; i++)
#define down(i, a, b) for (int i = a, _b = b; i >= _b; i--)
#define SZ(a) (int)a.size()
#define long long long
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define debug(X) cerr << #X << " = " << X << endl
#define debug2(X, Y) cerr << #X << " = " << X << " , " << #Y << " = " << Y << endl
#define show(X, a, b) { cerr << #X << " = "; up(_, a, b) cerr << X[_] << " "; cerr << endl; }
#define gc getchar
#define pc putchar
using namespace std;
template <class T>
inline void read(T &x) {
        int c = gc();
        x = 0;
        int neg = 0;
        for (; ((c<48 || c>57) && c != '-'); c = gc());
        if(c=='-') {neg=1; c=gc();}
        for(; c>47 && c<58; c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
        if(neg) x=-x;
}
template <class T>
inline void writeln(T x) {

        char buffor[21];
        int i=0;
        int neg=0; if (x<0) {neg=1; x= -x;}
        do {
                buffor[i++]=(x%10)+'0';
                x/=10;
        } while(x);
        i--;
        if (neg) pc('-');
        while(i>=0) pc(buffor[i--]);
        pc('\n');
}
const int N = 1e5 + 10;
int n;
long C, v[N], x[N], suf[N], pre[N];
void input() {
        cin >> n >> C;
        up(i, 1, n) cin >> x[i] >> v[i];
}


void solve() {
        x[n + 1] = C;
        long sumv = 0;
        down(i, n, 1) {
          sumv += v[i];
          suf[i] = sumv - (C - x[i]);
        }
        down(i, n - 1, 1) suf[i] = max(suf[i], suf[i + 1]);
        
        long res = 0; sumv = 0;
        up(i, 1, n) {
          sumv += v[i]; pre[i] = sumv - x[i];
          res = max(res, sumv - x[i]);
          res = max(res, sumv - 2 * x[i] + suf[i + 1]);
        }

        up(i, 2, n) pre[i] = max(pre[i - 1], pre[i]);
        sumv = 0;
        down(i, n, 1) {
          sumv += v[i];
          res = max(res, sumv - (C - x[i]) );
          res= max(res, sumv - 2 * (C - x[i]) + pre[i - 1]);
        }
        cout << res;
}
int main() {
  #ifdef I_Love_Pork
        clock_t sttime = clock ();
  #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

  #ifdef I_Love_Pork
  #define TASK "tmp"
        freopen(TASK ".inp","r",stdin);
        freopen(TASK ".out","w",stdout);
  #endif
        input();
        solve();



  #ifdef I_Love_Pork
        clock_t entime = clock ();
        cerr << "\nExecution time: " << double (entime - sttime) / CLOCKS_PER_SEC << "s";
  #endif

}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	ll a, b, x;
	
	cin >> a >> b >> x;
	if(a == 0)
		cout << b / x + 1;
	else
		cout << b / x - (a - 1) / x;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  if(n%2==1){
  ll m = n * (n-1) / 2;
  stack<pair<ll,ll>> ans;
  FOR(i,1,n){
      FOR(j,i+1, n+1){
          if(j== n-i)continue;
          ans.push(mp(i,j));
      }
  }
  cout << ans.size() << endl;
  while(ans.size()){
      auto tmp = ans.top();
      ans.pop();
      cout << tmp.first << " " << tmp.second << endl;
  }
  }else{
  stack<pair<ll,ll>> ans;
      FOR(i,1,n){
          FOR(j,i+1,n+1){
              if(i + j == n+1)continue;
              ans.push(mp(i,j));
          }
      }
cout << ans.size() << endl;
  while(ans.size()){
      auto tmp = ans.top();
      ans.pop();
      cout << tmp.first << " " << tmp.second << endl;
  }
  }

}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String string;
		int map[][] = new int[51][51], max = 0;
		while((string = reader.readLine()) != null){
			int array[] = app.splitter(string);
			max = max > array.length ? max : array.length;
			for(int i = 0; i < array.length; i++)
				map[max - i - 1][max - array.length + i] = array[i];
		}
		int res[][] = new int[max + 1][max + 1];
		res[0][0] = map[0][0];
		for(int i = 0; i < max; i++){
			for(int j = 0; j < max; j++){
				if(res[i][j] > 0){
					res[i][j + 1] = Math.max(res[i][j + 1], res[i][j] + map[i][j + 1]);
					res[i + 1][j] = Math.max(res[i + 1][j], res[i][j] + map[i + 1][j]);
				}else{
					res[i][j + 1] = res[i][j] + map[i][j + 1];
					res[i + 1][j] = res[i][j] + map[i + 1][j];
				}
			}
		}
		System.out.println(res[max - 1][max - 1]);
		reader.close();
	}
	
	public int[] splitter(String string){
		String str[] = string.split(",");
		int array[] = new int[str.length];
		for(int i = 0; i < str.length; i++)
			array[i] = Integer.valueOf(str[i]);
		return array;
	}
	
}

Measured memory_bytes: 25064
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi 3.1415926535
# define eps 1e-4
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

LL a[N], b[N], sum[N], cheng[N];

int main ()
{
    int n, m;
    LL ans=0, tmp=0, pp=0;
    scanf("%d%d",&n,&m);
    FOR(i,1,n) scanf("%lld",a+i);
    FOR(i,1,m) scanf("%lld",b+i);
    FOR(i,2,m) sum[i-1]=b[i]-b[1], pp=(sum[i-1]+pp)%MOD;
    FO(i,1,n) cheng[i]=(LL)i*(n-i), tmp=(tmp+cheng[i]*(a[i+1]-a[i])%MOD)%MOD;
    FO(i,1,m) {
        ans=(ans+tmp*pp%MOD)%MOD;
        pp=(pp-(b[i+1]-b[i])*(m-i)%MOD)%MOD;
    }
    ans=(ans+MOD)%MOD;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
# -*- coding:utf-8 -*-

def solve():
    S = input()
    ans = 0
    if "RRR" in S:
        print(3)
    elif "RR" in S:
        print(2)
    elif "R" in S:
        print(1)
    else:
        print(0)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N;
int a[100100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> a[i];
    int now = 0;
    rep(i, N+10) {
        now = a[now]-1;
        if (now==1) {
            cout << i+1 << endl;
            exit(0);
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll n, k;
    cin >> n >> k;

    ll res = 0;
    while(n){
        n /= k;
        ++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
class Edge{
public:
//int s;
int t;
long long len;
};
class Node{
    public:
    int num;//node番号
    long long dist;//startからの距離
    vector<Edge> edge;//自分から生えている辺
    bool comp;//dijkstra中で到達しているかどうか
    void in_edge(int in_t,int in_len){
        Edge in;in.t=in_t;in.len=in_len;
        edge.push_back(in);
    }  
};
bool operator >(const Node& a,const Node &r){
        return a.dist > r.dist;
    }
void dijkstra(vector<Node> &node,int s,int n){
    //n個のノードでできたグラフのsからtまでの最短距離を計算する
    //この時各要素のdistの値はsからの最短距離となる
    for(int i=0;i<n;i++){
        //初期化
        node[i].dist=inf;
        node[i].num=i;
        node[i].comp=true;
    }
    node[s].dist=0;
    priority_queue<Node,vector<Node>,greater<Node>> que;
    que.push(node[s]);
    while(!que.empty()){
        Node buf;
        buf=que.top();//
        que.pop();
        int k=buf.num;
        if(node[k].comp){
            node[k].comp=false;
            int edge_num=buf.edge.size();
            for(int i=0;i<edge_num;i++){
                int buf_t=node[k].edge[i].t;
                int buf_len=node[k].edge[i].len;
                if(node[buf_t].dist>node[k].dist+buf_len){
                node[buf_t].dist=node[k].dist+buf_len;
                que.push(node[buf_t]);
                }
            }
        }
    }
}
signed main(){
  int k;cin>>k;
  vector<Node> node(k+1);
  rep1(i,k-1){
      node[i].in_edge(i*10%k,0);
      node[i].in_edge((i+1)%k,1);
  }
  dijkstra(node,1,k);
  cout<<node[0].dist+1<<"\n";
  return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		205

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

//
int main(){
	int N;cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];

	vector<int> L(N+2),R(N+2);
	L[0]=R[N+1]=0;
	REPS(i,1,N+1){
		L[i]=gcd(L[i-1],A[i-1]);
		R[N-i+1] = gcd(A[N-i],R[N-i+2]);
	}

	//cout<<L[1];REPS(i,2,N+1)cout << " " << L[i];cout << endl;
	//cout<<R[1];REPS(i,2,N+1)cout << " " << R[i];cout << endl;

	ll ans = 0;
	REP(i,N){
		//cout << L[i] << " " << R[i+2] << " " << gcd(L[i],R[i+2]) << endl;
		ans = max(ans,gcd(L[i],R[i+2]));
	}

	cout << ans << endl;

	return 0;
}




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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N;
    int ans = 0;
    cin >> N;

    int value[N];
    rep(i, N) {
        cin >> value[i];
    }
    rep(i, N) {
        int tmp;
        cin >> tmp;
        if (value[i] - tmp > 0) {
            ans += value[i] - tmp;
        } 
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double l;
  cin >> l;
  l /= 3;
  cout << fixed << setprecision(6);
  cout << l * l * l << '\n';
  return 0;
}


Measured memory_bytes: 256
# D
N = int(input())

al = [chr(ord('a') + i) for i in range(26)]

ans = ['a']
for i in range(N-1):
    tmp = []
    for s in ans:
        stop = ord(max(s)) + 1
        for i in range(ord('a'), stop+1):
            tmp.append(s + chr(i))
    ans = tmp
for s in ans:
    print(s)

Measured memory_bytes: 12980
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 100000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 3e5+5;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846

int vis[MAXN];
std::vector<int> v;

signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n, i, k;
    cin>>n>>k;
    int a[n+1];
    for(i=1;i<=n;i++){
    	cin>>a[i];
    }
    i=1;
    while(!vis[i]){
    	v.pb(i);
    	vis[i]=1;
    	i=a[i];
    }
    int x = find(all(v), i)-v.begin();
    int r = v.size()-x;
    if(k<x){
    	cout<<v[k]<<endl;
    	return 0;
    }
    cout<<v[x+(k-x)%r]<<endl;
}

Measured memory_bytes: 8444
#include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	int n;
	std::cin >> n;
	double**result = new double*[n];
	for(int i = 0; i < n; i++)
	{
		result[i] = new double[3];
		double x1, y1, x2, y2, x3, y3;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double dx12 = x1 - x2, dx23 = x2 - x3, dx31 = x3 - x1, dy12 = y1 - y2, dy23 = y2 - y3, dy31 = y3 - y1;
		result[i][0] = (x1 * x1 * dy23 + x2 * x2 * dy31 + x3 * x3 * dy12 - dy12 * dy23 * dy31) / (x1 * dy23 + x2 * dy31 + x3 * dy12) / 2;
		result[i][1] = (y1 * y1 * dx23 + y2 * y2 * dx31 + y3 * y3 * dx12 - dx12 * dx23 * dx31) / (y1 * dx23 + y2 * dx31 + y3 * dx12) / 2;
		double dx = result[i][0] - x1, dy = result[i][1] - y1;
		result[i][2] = sqrt(dx * dx + dy * dy);
	}
	std::cout << std::fixed << std::setprecision(3);
	for(int i = 0; i < n; i++)
	{
		std::cout << result[i][0] << ' ' << result[i][1] << ' ' << result[i][2] << std::endl;
		delete[]result[i];
	}
	delete[]result;
	return 0;
}


Measured memory_bytes: 3268
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

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

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());
    int z = Integer.parseInt(sc.next());
    pw.println(z + " " + x + " " + y);
  }
}


Measured memory_bytes: 24404
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    int N, W;
    cin >> N >> W;
    vector<vector<ll>> dp(N + 10, vector<ll>(pow(10, 6) + 10, INF));
    vector<ll> w(N), v(N);
    ll v_max = 0;
    rep(i, N) {
        cin >> w[i] >> v[i];
        v_max += v[i];
    }

    // i個まで選んだ時価格がjになる重さの最小値

    dp[0][0] = 0;
    rep(i, N + 1) {
        rep(j, v_max + 5) {
            if (j >= v[i])
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    rep(i, N + 1) {
        rep(j, v_max + 1) {
            if (dp[i][j] <= W) {
                ans = max(ans, (ll)j);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 867840
D, G = map(int, input().split())
p = []
c = []
for i in range(D):
    x, y = map(int, input().split())
    p.append(x)
    c.append(y)
iters = 2 ** D
ans = 1<<30
for i in range(iters):
    score = 0
    nums = 0
    for b in range(D):
        if ((1 << b) & i) != 0:
            score += c[b] + p[b] * 100 * (b+1)
            nums += p[b]
    need = G - score
    if need <= 0:
        ans = min(ans, nums)
        continue
    for b in range(D):
        if (1 << b) & i == 0:
            kai = (need+(100*(b+1)-1)) // (100*(b+1))
            if kai <= p[b]:
                ans = min(ans, kai+nums)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
typedef priority_queue<int, vector<int>, greater<int> > GQint;
typedef priority_queue<int> PQint;
typedef priority_queue<PA, vector<PA>, greater<PA> > GQpair;
typedef priority_queue<PA> PQpair;
typedef	set<int> Sint;
typedef	set<PA> SPA;
typedef map<int, int> MAP;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 5000000002
#define MOD 100000
#define MAXN 102
#define MAXM 1002
#define MAXK 100002

ll a, b, c, x, y, mi = INF, sa;

int main()
{
    cin >> a >> b >> c >> x >> y;
    sa = abs(x - y);
    mi = mi < (a * x + b * y) ? mi : (a * x + b * y);
    if(x > y){
        mi = mi < (y * 2 * c + a * sa) ? mi : (y * 2 * c + a * sa);
        mi = mi < (x * 2 * c) ? mi : (x * 2 * c);
    }
    else if(x < y){
        mi = mi < (x * 2 * c + b * sa) ? mi : (x* 2 * c + b * sa);
        mi = mi < (y * 2 * c) ? mi : (y * 2 * c);
    }
    else{
        mi = mi < (y * 2 * c) ? mi : (y * 2 * c);
        mi = mi < (x * 2 * c) ? mi : (x * 2 * c);
    }
    cout << mi << endl;

    return 0;
}
/*













*/


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

int calc(int y,int m,int d)
{
  int count=0;

  for(int y_t=1;;y_t++){//年
    if(y_t%3==0){
      for(int m_t=1;m_t<=10;m_t++){//月
	for(int d_t=1;d_t<=20;d_t++){//日
	  count++;
	  if(y_t==y && m_t == m && d_t ==d)return count;
	  //printf("%d %d %d\n",y_t,m_t,d_t);
	}
      }
    }else{
      for(int m_t=1;m_t<=10;m_t++){
	if(m_t%2==1){
	  for(int d_t=1;d_t<=20;d_t++){
	    count++;
	    if(y_t == y && m_t ==m && d_t ==d)return count;

	  }
	}else{
	  for(int d_t=1;d_t<=19;d_t++){
	    count++;
	    if(y_t == y && m_t ==m && d_t ==d)return count;
	    //printf("%d %d %d\n",y_t,m_t,d_t);	  
	  }
	}
      }
    }
  }

  //return count;
}
  


int main(void)
{
  
  int n;

  int y,m,d;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> y >> m >> d;
    printf("%d\n",calc(1000,1,1)-calc(y,m,d));

  }
}

Measured memory_bytes: 1148
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

lists = [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]
K = int(input())
K -= 1
print(lists[K])

Measured memory_bytes: 65388
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
  
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = [(1 + int(x)) / 2 for x in input().split()]
a_idx, l, r = 0, 0, 0
for i in range(1, n - k + 1):
    l += p[i - 1]
    r += p[i + k - 1]
    if r > l:
        a_idx, l, r = i, 0, 0
print(sum(p[a_idx:a_idx + k]))


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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


	ll n; cin>>n;

	ll ans =1000000000000000;
	for( ll i =1; i<=sqrt(n); i++){
		if(n % i ==0){
			ans = min(ans, i-1+(n/i)-1);
		}
	}

	writeln(ans);


}




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

int main()
{
	int X[3][3], sum;
	cin >> X[0][0] >> X[0][1] >> X[1][1];
	sum = X[1][1] * 3;

	X[0][2] = sum - X[0][0] - X[0][1];
	X[2][0] = sum - X[1][1] - X[0][2];
	X[2][2] = sum - X[1][1] - X[0][0];
	X[1][0] = sum - X[0][0] - X[2][0];
	X[2][1] = sum - X[2][0] - X[2][2];
	X[1][2] = sum - X[0][2] - X[2][2];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 2; j++) {
			cout << X[i][j] << ' ';
		}
		cout << X[i][2] << endl;
	}
	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
    if (N == M)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int X = sc.nextInt();
		final int Y = sc.nextInt();
		sc.close();
		if (Y % 2 == 1) {
			System.out.println("No");
			return;
		}
		int a = Y/2 - X;
		int b = 2*X - Y/2;
		if(a>=0 && b>=0){
			System.out.println("Yes");
		}else if(a < 0 || b < 0){
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}



int main() {
	ll n;
	cin>>n;
	vector <ll> a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	vector < vector <ll> > dp(n,vector <ll> (n,0));
	for(ll i=n-1;i>=0;i--){
		for(ll j=i;j<n;j++){
			if(i==j)
				dp[i][j]=a[i];
			else{
				dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
			}
		}
	}
	cout<<dp[0][n-1]<<"\n";
}


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

int main() {
	long long ls[100];
	ls[0] = 2;ls[1] = 1;
	int n; cin>>n;
	for(int i=2;i<n+1;++i){
		ls[i] = ls[i-1] + ls[i-2];
	}
	cout << ls[n] << endl;
	return 0;
}

Measured memory_bytes: 256
# = int(input())
N, M = map(int, input().split())
H = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
AB = [list(map(int, input().split())) for i in range(M)]
count = []

for i in range(M):
    if H[AB[i][0]-1]==H[AB[i][1]-1]:
        count.append(AB[i][1])
        count.append(AB[i][0])
    elif H[AB[i][0]-1]<H[AB[i][1]-1]:
        count.append(AB[i][0])
    else:
        count.append(AB[i][1])

loser = list(set(count))

print(N-len(loser))


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


int ans = 0;
int N, M;

void dfs(vector<int> sinro, vector<vector<int>> edge, vector<bool> reached, int node) {
    bool has_next = false;
    reached[node] = true;

    rep(i, edge[node].size()) {
        int next_node = edge[node][i];

        // next_nodeにまだ到達していなければ
        if (!reached[next_node]) {
            dfs(sinro, edge, reached, next_node);
            has_next = true;
        } else {
            continue;
        }
    }

    // next nodeがなかった場合、
    if (!has_next) {
        bool all_reached = true;

        //全てのnodeを探索
        rep (i, N) {
            all_reached = all_reached && reached[i];
        }

        // 全てのnodeを通過していた場合
        if (all_reached) {
            ans += 1;
        }
    }
}

int main() {
    cin >> N >> M;
    vector<vector<int>> edge(N);
    vector<bool> reached(N, false);
    rep(i, M){
        int ai, bi;
        cin >> ai >> bi;
        edge[ai-1].push_back(bi-1);
        edge[bi-1].push_back(ai-1);
    }

    int node = 0;
    vector<int> sinro;

    sinro.push_back(node);
    dfs(sinro, edge, reached, node);
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    double input;

    while (cin >> input) {
        int n = 1;
        while (true) {
            if (10 * n - 10 > input * input / 9.8)
                break;
            n++;
        }

        cout << n << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    }
}



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

int main() {
  int n;
  cin >> n;
  char s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  
  map<char, int> m{ {'P', 0}, {'W', 0}, {'G', 0}, {'Y', 0} };  
  for (char i : s) m[i] += 1;
  
  if (0 < m['P'] && 0 < m['W'] && 0 < m['G'] && 0 < m['Y']) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}
  

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
cin.tie(0);              \
cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
	cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

#define watch(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	string in;
	cin >> in;
	if(in=="ABC") cout << "ARC";
	else cout << "ABC";
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



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

using namespace std;

int main()
{
  int n;
  map<int, int> m;
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (m.find(x) != m.end()) m[x]++;
    else m[x] = 1;
  }
  
  vector<int> v, s;
  for (auto it = m.begin(); it != m.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());
  s.resize(v.size());
  for (int i = 0; i < s.size(); i++) {
    s[i] = v[i];
    if (i) s[i] += s[i - 1];
  }
  
  for (int i = 1; i <= n; i++) {
    int l = 0, r = n / i;
    while (l != r) {
      int m = (l + r + 1) / 2;
      int pos = upper_bound(v.begin(), v.end(), m) - v.begin();
      int sum = (pos ? s[pos - 1] : 0) + m * ((int)v.size() - pos);
      if (sum >= i * m) l = m;
      else r = m - 1;
    }
    printf("%d\n", l);
  }
  
  return 0;
}

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  int ans = X + N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans += (D-1)/A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int a,b;
    cin>>a>>b;
    int ans=-1;
    for(double i=1;i<=100000;i++){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            ans=i;
            break;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int rate,goal,pfm;
  char str[8];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&rate);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&goal);
  
  /*(rate+pfm)/2 == goal
    pfm == 2goal - rate*/
  
  pfm = 2*goal - rate;
  
  printf("%d",pfm);
  return 0;
}
  

Measured memory_bytes: 128
# coding: UTF-8
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    class SegmentTree:
        def __init__(self,n,ide_ele,segfunc):
            self.ide_ele=ide_ele
            self.segfunc=segfunc
            self.num=2**(n-1).bit_length()
            self.dat=[ide_ele]*2*self.num
        
        def init(self,iter):
            for i in range(n):
                self.dat[i+self.num]=iter[i]
            for i in range(self.num-1,0,-1):
                self.dat[i]=self.segfunc(self.dat[i*2],self.dat[i*2+1])
        
        def update(self,k,x):
            k+=self.num
            self.dat[k]=x
            while k:
                k//=2
                self.dat[k]=self.segfunc(self.dat[k*2],self.dat[k*2+1])
        
        def query(self,p,q):
            if q<=p:
                return self.ide_ele
            p+=self.num
            q+=self.num-1
            res=self.ide_ele
            while q-p>1:
                if p&1==1:
                    res=self.segfunc(res,self.dat[p])
                if q&1==0:
                    res=self.segfunc(res,self.dat[q])
                    q-=1
                p=(p+1)//2
                q=q//2
            if p==q:
                res=self.segfunc(res,self.dat[p])
            else:
                res=self.segfunc(self.segfunc(res,self.dat[p]),self.dat[q])
            return res
    
    N=int(input())
    S=list(input())
    Q=int(input())
    seg=[SegmentTree(N,0,lambda x,y:x+y) for _ in range(26)]
    
    S2=[0]*N
    
    for i in range(N):
        S2[i]=ord(S[i])-ord('a')
    
    for i,x in enumerate(S2):
        p=seg[x].query(i,i+1)
        seg[x].update(i,p+1)
    
    for _ in range(Q):
        a,b,c=input().split()
        if a=='1':
            b=int(b)-1
            c=ord(c)-ord('a')
            p=seg[c].query(b,b+1)
            seg[c].update(b,p+1)
            q=seg[S2[b]].query(b,b+1)
            seg[S2[b]].update(b,q-1)
            S2[b]=c
        else:
            b=int(b)-1
            c=int(c)-1
            ans=0
            for i in range(26):
                ans+=bool(seg[i].query(b,c+1))
            print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 285776
#include<stdio.h>
#include<math.h>
int main () {
    int num[6], i;
    for(i = 0; i < 6; ++i) scanf("%d", &num[i]);
    for(i = 0; i < 4; ++i){
        for(int j = i + 1; j < 5; ++j){
            if(num[j] - num[i] > num[5]){
                puts(":(");
                return 0;
            }
        }
    }
    puts("Yay!");
    return 0;
}

Measured memory_bytes: 128
S = input()

CHARS = [chr(ord("a") + i) for i in range(26)]

xs = dict((c, -1) for c in CHARS)
ms = dict((c, -1) for c in CHARS)

for i, c in enumerate(S):
    p = xs[c]
    ms[c] = max(i - p - 1, ms[c])
    xs[c] = i

for c in CHARS:
    ms[c] = max(len(S) - xs[c] - 1, ms[c])

result = min(ms.values())

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<P> to[100005];
ll dist[100005];

void dfs(int v, int p=-1) {
    ll d = dist[v];
    for (auto e: to[v]) {
        if (e.first==p) continue;
        dist[e.first] = d + e.second;
        dfs(e.first, v);
    }
}

int main(){
    int n;
    cin >> n;
    rep(i, n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        to[a].emplace_back(b, c);
        to[b].emplace_back(a, c);
    }
    int q, k;
    cin >> q >> k;
    k--;
    dfs(k);
    rep(qi, q) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        ll ans = dist[x] + dist[y];
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

#define ll unsigned long long

const int mod  = 1e9 + 7;
const ll INF = 1e14;

void solve(){

    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();

    int ans = m;

    for(int i = 0; i <= n - m; ++i){
        int ch = 0;
        for(int j = 0; j < m; ++j)
            ch += (s[i+j] == t[j] ? 0 : 1);
        //cout << ch << endl;
        ans = min(ans, ch);
    }

    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



Measured memory_bytes: 3632
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    s = input()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 67320
#include <stdio.h>

int adj[100][100];

int main(){
  int n;
  scanf("%d",&n);
  int i,j;
  int u,k,v;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
   
    for(j=0;j<k;j++){
      scanf("%d",&v);
      adj[u][v]=1;
      }
    
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j==n) printf("%d\n",adj[i][j]);
      else printf("%d ",adj[i][j]);
    }
  }
  return 0;
}



Measured memory_bytes: 2052
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int height = b-a;
        int ans = 0;
        for(int i = 1; i<=height; i++) {
            ans += i;
        }
        ans -= b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int H,N;
  cin>>H>>N;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  vector<vector<int64_t>>dp(N+1,vector<int64_t>(H+1,INF));
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=H;j++){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][min(j+A[i],H)],dp[i+1][j]+B[i]);
    }
  }
  cout<<dp[N][H]<<endl;
  return 0;
}

Measured memory_bytes: 81604
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main extends Thread implements Runnable {
	public static void main(String[] args) {
 
		Main main = new Main();
		main.run();
	}
		public void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
 
                if(A<=8){
                    if(B<=8){
                        		System.out.println("Yay!");
                                        return ;
                   }
                }
                System.out.println(":(");
		
	}
}

Measured memory_bytes: 21844
def island(f,x,y,m):
    rf = f[:][:]
    rf[y][x] = m
    for i in [-1,1]:
        if 0 <= x+i <= 11 and rf[y][x+i] == 1:
            rf = island(rf,x+i,y,m)
        if 0 <= y+i <= 11 and rf[y+i][x] == 1:
            rf = island(rf,x,y+i,m)
    return rf

while True:
    f = []; m = 2
    for i in range(12):
        f.append(map(int, list(raw_input())))
    for y in range(12):
        for x in range(12):
            if f[y][x] == 1:
                f = island(f,x,y,m)
                m += 1
    ans = []
    for i in range(12):
        for j in range(12):
            ans.append(f[i][j])
    ans = list(set(ans))
    print len(ans) - 1*ans.count(0)
    try:raw_input()
    except: break

Measured memory_bytes: 4340
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[n-1] - a[0]);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <math.h> 
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
      {
        if (num % i == 0)
	  {
            // 素数ではない
            return false;
	  }
      }

    // 素数である
    return true;
}

int main(void){

  int n;
  int max_prime;
  int min_prime;

  while(cin >> n){
 
    for(int i=n-1;i>1;i--){
      if(IsPrime(i)){
	max_prime=i;
	break;
      }
    }

    for(int j=n+1;j<100000;j++){
      if(IsPrime(j)){
	min_prime=j;
	break;
      }
    }

    cout << max_prime << " " << min_prime << endl;

  }
  
  return 0;
}




Measured memory_bytes: 3108
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int w = sc.nextInt();
			int h = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();

			if((x - r < 0 || x + r > w) || (y - r < 0 || y + r > h)){
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}
	}
}

Measured memory_bytes: 26132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
    cout << "Left" << endl;
  }else if(A + B < C + D ){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

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

using namespace std;

int main(void) {
	int r,c,temp;
	cin >> r >> c;
	vector<int> sum(c+1,0);
	for (int i = 0; i < r; ++i) {
		int rsum = 0;
		for (int j = 0; j < c; ++j) {
			cin >> temp;
			sum[j] += temp;
			rsum += temp;
			cout << temp << " ";
		}
		cout << rsum <<  endl;
		sum[c] += rsum;
	}
	for (int j = 0; j < c+1; ++j) {
		cout << sum[j];
		if (j < c) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}



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

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

using namespace std;



int main(void)
{
    long long N,K,a,b,tmp,ans=0;
    map<long long ,long long> mp;
    set<long long> S;

    cin>>N>>K;

    rep(i,N){
        cin>>a>>b;
        mp[a]+=b;
        S.insert(a);
    }

    tmp=0;
    for(auto i:S){
        tmp += mp[i];
        if(K <= tmp){
            ans=i;
            break;
        }
    }

    cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 10536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

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

int main(void){
    ll N;
    cin >> N;
    ll H[100010];

    rep(i,N) cin >> H[i];

    ll mem = 0;
    ll max = 0;

    rep(i,N-1){
        if(H[i] >= H[i+1]){
            //cout << "yay" << endl;
            mem++;
        }
        else{
            if(mem>max) max = mem;
            mem = 0;
        }
        if (i == N - 2){
            if(mem>max) max = mem;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll x;
  cin>>x;
  bitset<32>b(x);
  cout<<b<<endl;
  cout<<(~b)<<endl;
  cout<<(b<<1)<<endl;
  cout<<(b>>1)<<endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 

int H,W;
char A[1010][1010];
int dist[1010][1010];
vector<P> vec;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
signed main(){
    cin>>H>>W;
    rep(i,H){
        rep(j,W){
            cin>>A[i][j];
            if(A[i][j]=='#'){
                vec.push_back(P(i,j));
            }
        }
    }

    queue<P> que;
    rep(i,vec.size()){
        dist[vec[i].first][vec[i].second]=0;
        que.push(vec[i]);
    }

    while(!que.empty()){
        P now=que.front();que.pop();
        rep(k,4){
            P next=P(now.first+dy[k],now.second+dx[k]);
            if(A[next.first][next.second]=='.'){
                A[next.first][next.second]='*';
                dist[next.first][next.second]=dist[now.first][now.second]+1;
                que.push(next);
            }
        }

    }
    int ans=0;
    rep(i,H)rep(j,W){
        ans=max(ans,dist[i][j]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 21224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<long long> A(M);
    rep(i, M) cin >> A[i];
    
    int sum = 0;
    rep(i,M){
        sum += A[i];
    }
    if (sum <= N){
    cout << N - sum << endl;
}else{
    cout << -1 << endl;
}}

Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int H, W, a, b;
  cin >> H >> W >> a >> b;

  for (int h = 0; h < H; ++ h) {
    for (int w = 0; w < W; ++w) {
      int cur = (h < b) ^ (w < a);
      cout << cur;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll unsigned long long
#define vi vector<int>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
using namespace std;
int main()
{  int n,a,b;
cin>>n>>a>>b;
  if((b-a-1)%2==0)
  cout<<"Borys";
  else cout<<"Alice";
}


Measured memory_bytes: 256