akhauriyash/Code-Regression huggingface dataset:
r, c = map(int, input().split())
a = [[0 for i in range(c + 1)] for j in range(r + 1)]

for i in range(r):
    sumC = 0
    ar = input().split()
    for j in range(c):
        a[i][j] = int(ar[j])
        sumC += int(ar[j])
    a[i][c] = sumC

for k in range(c + 1):
    for m in range(r):
        a[r][k] += a[m][k]


for i in a:
    print(*i)


Measured memory_bytes: 6248
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
#define ld long double
#define ull unsigned long long
#define db double
#define ll long long
const db eps=1e-7;
//const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (ll i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e5+7;

int t,n,m,k,fl=0;
int main() {
    string a;
    cin>>a;
    if(a[1]=='R') puts("ABC");
    else puts("ARC");
    
    return 0;
}

Measured memory_bytes: 3036
N = int(input())

list = [int(x) for x in range(1,N+1)]

index_3 = [int(x) for x in range(3, N+1, 3)]
index_5 = [int(x) for x in range(5, N+1, 5)]

for i in index_3:
    list[i-1] = 0
for i in index_5:
    list[i-1] = 0

print(sum(list))

Measured memory_bytes: 141784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=105,MOD=1000000007;
int qmi(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)ans=1ll*ans*x%MOD;
	return ans;
}

int n,a[MAXN],f[MAXN][MAXN],g[MAXN][MAXN];
void solve(int l,int r,int x)
{
	int y=1<<30,las=l-1,w=0;
	for(int i=l;i<=r;++i)chkmin(y,a[i]);
	for(int i=l;i<=r;++i)if(a[i]==y)++w;
	if(w==r-l+1)
	{
		f[l][r]=(1ll*qmi(2,y-x)+qmi(2,r-l+1)-2+MOD)%MOD;
		g[l][r]=qmi(2,y-x);
		return;
	}
	f[l][r]=qmi(2,w);
	g[l][r]=1;
	for(int i=l;i<=r+1;++i)
		if(i>r || a[i]==y)
		{
			if(i-las>=2)
			{
				solve(las+1,i-1,y);
				g[l][r]=1ll*g[l][r]*g[las+1][i-1]%MOD;
				f[l][r]=1ll*f[l][r]*(g[las+1][i-1]+f[las+1][i-1])%MOD;
			}
			las=i;
		}
	f[l][r]=(f[l][r]+1ll*g[l][r]*(qmi(2,y-x)-2+MOD))%MOD;
	g[l][r]=1ll*g[l][r]*qmi(2,y-x)%MOD;
//cerr<<l<<" "<<r<<":"<<f[l][r]<<" "<<g[l][r]<<endl;
}

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n);
	for(int i=1;i<=n;++i)readint(a[i]);
	solve(1,n,0);
	printf("%d\n",f[1][n]);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

    int cards = sc.nextInt();
    int gates = sc.nextInt();

    Integer[] start = new Integer[gates];
    Integer[] end = new Integer[gates];
    for (Integer i = 0; i < gates; i++) {
      start[i] = sc.nextInt();
      end[i] = sc.nextInt();
    }

    Arrays.sort(start, Collections.reverseOrder());
    Arrays.sort(end);

    Integer result = end[0] - start[0] + 1;

    if(result < 0) {
      result = 0;
    }

    System.out.println(result);
  }
}


Measured memory_bytes: 95100
import java.util.Scanner;

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();
		}
		int ct = 0;
		for (int i = 0; i < N; i++) {
			int minj = i;
			for (int j = i; j < N; j++) {
				if (A[j] < A[minj]) {
					minj = j;
				}
			}
			if (i != minj) {
				int k = A[i];
				A[i] = A[minj];
				A[minj] = k;
				ct++;
			}
		}
		for (int i = 0; i < N; i++) {
			System.out.print(A[i]);
			if (i < N - 1) {
				System.out.print(" ");
			}
		}
		System.out.println();
		System.out.println(ct);
	}
}



Measured memory_bytes: 26288
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int P[N];
  rep(i,0,N-1) cin >> P[i];

  int left = N, ans = 0;
  rep(i,0,N-1) {
    left = min(left, P[i]);
    if (P[i] <= left) ans++;
  }

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


Measured memory_bytes: 1024
fun main(args : Array<String>) {
    val (N, Y) = readLine()!!.split(" ").map { it.toInt() }
    (0..N).forEach { a->
        (0..N).forEach { b ->
            val c = N - (a + b)
            if (c >= 0 && a + b + c == N && 10000 * a + 5000 * b + 1000 * c ==  Y) {
                println(a.toString() + " " + b.toString() + " " + c.toString())
                return
            }
        }
    }
    println("-1 -1 -1")
}


Measured memory_bytes: 40300
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[allow(dead_code)]
fn f(n: usize, v: &Vec<(usize, usize)>) {
    let mut dist = vec![vec![0; n]; n];
    let mut is_empty = vec![vec![false; n]; n];

    for y in 0..n {
        for x in 0..n {
            dist[y][x] = min(min(x, y), min(n - x - 1, n - y - 1));
            is_empty[y][x] = dist[y][x] == 0;
        }
    }

    let mut q: VecDeque<(usize, usize, usize)> = VecDeque::new();
    let mut ans = 0;
    for p in v {
        let (x, y) = *p;
        is_empty[y][x] = true;
        let new_dist = min(
            min(dist[y - 1][x], dist[y + 1][x]),
            min(dist[y][x - 1], dist[y][x + 1]),
        );
        ans += new_dist;
        q.push_back((x, y, new_dist)); // (x,y)の外周からの距離を更新する。隣のマスの外周からの距離はnew_distだ。

        while let Some((x, y, new_dist)) = q.pop_front() {
            let d = new_dist + if is_empty[y][x] { 0 } else { 1 };

            if dist[y][x] > d {
                dist[y][x] = d;
                q.push_back((x + 1, y, d));
                q.push_back((x - 1, y, d));
                q.push_back((x, y + 1, d));
                q.push_back((x, y - 1, d));
            }
        }
    }

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

//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        p:[usize;n*n],
    }

    // 外周に1マス分の空きスペースを増やす
    let n2 = n + 2;
    let mut v: Vec<(usize, usize)> = Vec::with_capacity(n * n);

    for i in 0..n * n {
        let pp = p[i] - 1;
        let x = pp % n;
        let y = pp / n;
        v.push((x + 1, y + 1));
    }

    f(n2, &v);
}


Measured memory_bytes: 11748
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  int m=0;
  sort(a,a+n);
  m=a[n-1]-a[0];
  
  cout << m << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,ddx,ddy;
ll x[100005],y[100005];
char s[300004];


int main(){
	cin>>a>>b;
	c = max({a+b,a-b,a*b});
	p(c);
	return 0;
}

Measured memory_bytes: 5500
N=int(input())
List=[list(map(int,input().split())) for i in range(N)]
A,B,C=zip(*List)
dp=[[0]*3 for i in range(N)]
dp[0][0]=A[0]
dp[0][1]=B[0]
dp[0][2]=C[0]
for i in range(1,N):
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i]
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+B[i]
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+C[i]
print(max(dp[-1]))

Measured memory_bytes: 49896
#warning orz_night
#include <bits/stdc++.h>
#define MAXN 110
using namespace std;

int a, b;
char ans[MAXN][MAXN];

int main() {
    scanf("%d%d", &a, &b); --a; --b;
    for (register int i = 1; i <= 50; ++i)
        for (register int j = 1; j <= 100; ++j)
            ans[i][j] = '.';
    for (register int i = 51; i <= 100; ++i)
        for (register int j = 1; j <= 100; ++j)
            ans[i][j] = '#';
    //fprintf(stderr, "init complated %d %d\n", a, b);
    for (register int i = 1; b; i += 2)
        for (register int j = 1; b && j <= 100; j += 2) {
            ans[i][j] = '#'; --b;
        }
    for (register int i = 52; a; i += 2)
        for (register int j = 2; a && j <= 100; j += 2) {
            ans[i][j] = '.'; --a;
        }
    puts("100 100");
    for (register int i = 1; i <= 100; ++i) {
        for (register int j = 1; j <= 100; ++j)
            putchar(ans[i][j]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

int main() {fio;
	ll n;
	cin >> n;
	ll r = sqrtl(n);
	while(r * r < n) r++;
	if(n % 2 == r % 2) {
		cout << "0 0 ";
		ll lef = r * r - n;
		cout << r << ' ' << 2 << ' ' << lef / 2 << ' ' << r << endl;
		return 0;
	}
	if(r != (ll)1e9) {
		ll lef = (r * r - 1) - n;
		cout << "0 0 ";
		cout << r - 1 << ' ' << 2 << ' ' << lef / 2 << ' ' << r + 1 << endl;
	} else {
		ll lef = r * r - n;
		if(lef <= r) {
			ll l2 = n - (r * (r - 1));
			cout << 0 << ' ' << 1 << ' ' << r << ' ' << 0 << ' ' << l2 << ' ' << r << endl;
			assert(abs(r * (r - 1) + l2) == n);
		} else {
			ll l2 = n - (r * (r - 2));
			cout << 0 << ' ' << 2 << ' ' << r << ' ' << 1 << ' ' << l2 << ' ' << r << endl;
			assert(r <= 1e9 && l2 <= 1e9);
			assert(abs(r * (r - 2) + l2) == n);
		}
	}
    return 0;
}

Measured memory_bytes: 256
// バケット法による解
#include <iostream>
using namespace std;

int main() {
    int N,M;
    cin >> N >> M;
    int b[110];
    for(int i = 0; i< M*2;++i)  cin >> b[i];
    int app[110] = {0};
    for(int i = 0; i< M*2;++i){
      app[b[i]]++;
    }
    for(int i = 1;i<=N;++i){
      cout << app[i] << endl;
    }
}


Measured memory_bytes: 3572
A=0
n=str(input())
if len(n)>=6:
    A=A+1
B=n.count('0')+n.count('1')+n.count('2')+n.count('3')+n.count('4')+n.count('5')+n.count('6')+n.count('7')+n.count('8')+n.count('9')
if B>0:
    A=A+1
C=n.count('a')+n.count('b')+n.count('c')+n.count('d')+n.count('e')+n.count('f')+n.count('g')+n.count('h')+n.count('i')+n.count('j')+n.count('k')+n.count('l')+n.count('m')+n.count('n')+n.count('o')+n.count('p')+n.count('q')+n.count('r')+n.count('s')+n.count('t')+n.count('u')+n.count('v')+n.count('w')++n.count('x')+n.count('y')+n.count('z')
if C>0:
    A=A+1
D=n.count('A')+n.count('B')+n.count('C')+n.count('D')+n.count('E')+n.count('F')+n.count('G')+n.count('H')+n.count('I')+n.count('J')+n.count('K')+n.count('L')+n.count('M')+n.count('N')+n.count('O')+n.count('P')+n.count('Q')+n.count('R')+n.count('S')+n.count('T')+n.count('U')+n.count('V')+n.count('W')++n.count('X')+n.count('Y')+n.count('Z')
if D>0:
    A=A+1
if A==4:
    print('VALID')
else:
    print('INVALID')


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

def solve():
    N = int(input())
    B = list(map(int, input().split()))
    res = []
    while B:
        for i in range(len(B)-1,-1,-1):
            if B[i] == i+1:
                res.append(B[i])
                del B[i]
                break
        else:
            if B:
                res = '-1'
                break
    else:
        res = '\n'.join(map(str, res[::-1]))
    return str(res)
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dp[100007][2];
int n,m;
int arr[107];
int f(int k,int i)
{
	if(k<0)
		return i;
	
	if(dp[k][i]!=-1)
		return dp[k][i];
		
	int a=f(k-arr[0],!i);
	if(i==0)
		for(int j=1;j<n;j++)
			a=min(a,f(k-arr[j],!i));
	else
		for(int j=1;j<n;j++)
			a=max(a,f(k-arr[j],!i));
	//cout<<k<<" "<<i<<" "<<a<<"\n";
	return dp[k][i]=a;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	int k,i;
	cin>>n>>k;
	cin>>arr[0];
	m=arr[0];
	for(i=1;i<n;i++){
		cin>>arr[i];m=min(m,arr[i]);}
	if(!f(k,0))
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}

Measured memory_bytes: 7296
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int N = Integer.parseInt(s[0]);
    int M = Integer.parseInt(s[1]);
    int C = Integer.parseInt(s[2]);
    
    String[] t = sc.nextLine().split(" ");
    int[] B = new int[M];
    for(int i = 0; i < M; i++){
      B[i] = Integer.parseInt(t[i]);
    }
    
    int count = 0;
    for(int i = 0; i < N; i++){
      String[] u = sc.nextLine().split(" ");
      int sum = 0;
      for(int j = 0; j < M; j++){
        sum += Integer.parseInt(u[j]) * B[j];
      }
      
      if(sum + C > 0){
        count++;
      }
    }
    System.out.println(count);
  }
}

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

int main(){
  int A, B, C, r;
  cin >> A >> B >> C;
  r = A-B;
  if(r>0){
    C = C-r;
    if(C<0){
      C=0;
    }
  }
  cout << C << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
using namespace std;
#define N 1005
#define pii pair<int,int>
#define mp make_pair
const int INF=1<<29;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};

int H,W,ans;
char s[N][N];
int d[N][N];
queue<pii> q;
bool inRange(int x,int y)
{
	return x>=0 && y>=0 &&x<H && y<W;
}

int main()
{
	
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;i++)
		scanf("%s",&s[i]);
	for(int i=0;i<H;i++)
	for(int j=0;j<W;j++)
		if(s[i][j]=='.') d[i][j]=INF;
		else q.push(mp(i,j));
	
	while(!q.empty())
	{
		pii p=q.front();
		q.pop();
		for(int i=0;i<4;i++)
		{
			int nx=p.first+dx[i];
			int ny=p.second+dy[i];
			if(d[nx][ny]!=INF) continue;
			if(!inRange(nx,ny)) continue;
			d[nx][ny]=d[p.first][p.second]+1;
			ans=max(ans,d[nx][ny]);
			q.push(mp(nx,ny));
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 11280
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a*b > c){
        cout << c;
    }
    else
    {
        cout << a*b;
    }
    
    cout << endl;    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    ll x;
    cin >> n >> x;
    VL a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0;
    REP(i,n-1){
        if (a[i] + a[i+1] > x){
            int p = a[i] + a[i+1] - x;
            ans += p;
            if (p > a[i+1]) a[i+1] = 0;
            else a[i+1] -= p;
        }
    }

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

Measured memory_bytes: 1024
C=[list(map(int, input().split())) for _ in range(3)]
is_Yes=0
a=[0]*3
for i in range(3):
    a[i]=C[i][1]-C[i][0]
if a[0]==a[1]==a[2]:
    for i in range(3):
        a[i]=C[i][1]-C[i][2]
    if a[0]==a[1]==a[2]:
        for i in range(3):
            a[i]=C[1][i]-C[0][i]
        if a[0]==a[1]==a[2]:
            for i in range(3):
                a[i]=C[i][2]-C[i][1]
            if a[0]==a[1]==a[2]:
                print("Yes")
                is_Yes=1
if is_Yes==0:
    print("No")


Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 998244353;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int sum = 0;
    rep(i, n){
        sum += a[i];
    }

    auto dp1 = initVec2<int>(n + 1, sum + 1);
    dp1[0][0] = 1;
    rep(i, n){
        rep(j, sum){
            dp1[i+1][j] += dp1[i][j];
            dp1[i+1][j] %= MOD;;
            if(j + a[i] > sum){
                continue;
            }
            dp1[i+1][j+a[i]] += dp1[i][j];
            dp1[i+1][j+a[i]] %= MOD;
        }
    }

    auto dp2 = initVec2<int>(n + 1, sum + 1);
    dp2[0][0] = 1;
    rep(i, n){
        rep(j, sum){
            dp2[i+1][j] += dp2[i][j] * 2 % MOD;
            dp2[i+1][j] %= MOD;;
            if(j + a[i] > sum){
                continue;
            }
            dp2[i+1][j+a[i]] += dp2[i][j];
            dp2[i+1][j+a[i]] %= MOD;
        }
    }

    int ans = 1;
    rep(i, n){
        ans *= 3;
        ans %= MOD;
    }

    int x = 0;
    for(int i = (sum + 1) / 2; i <= sum; i++){
        x += dp2[n][i];
        x %= MOD;
    }
    if(sum % 2 == 0){
        x = (x + MOD - dp1[n][sum/2]) % MOD;
    }
    x *= 3;
    x %= MOD;

    cout << (ans + MOD - x) % MOD << endl;

    return 0;
}


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

using namespace std;

void solve()
{
	vector<int> Vec(3);
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		for(int j = 0; j < 3; ++j)
		{
			cin >> Vec[j];
		}
		sort(Vec.begin(), Vec.end());
		if(Vec[0] * Vec[0] + Vec[1] * Vec[1] == Vec[2] * Vec[2])
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string> 
#include <string.h>
#include <set>
#include <stdlib.h>
using namespace std; 
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if ((a!=b) and (a!=c)) {
	  cout<<a;
	  return 0;
	  }
	if ((b!=a) and (b!=c)) {
	  cout<<b;
	  return 0;
	  }
	if ((c!=a) and (c!=b)) {
	  cout<<c;
	  return 0;
	  }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main (){
  string a[105];
  int n,l;
  cin>>n>>l;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    cout<<a[i];
  }
  cout<<"\n";
  return(0);
}

  

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

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

    int ans = (n - 1) * (m - 1);

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


Measured memory_bytes: 3620
def hour(s):
    return s // 3600

def minute(s):
    return s // 60


s = input("")
s = int(s)
h = hour(s)
m = minute(s - h * 3600)
s = s - (h * 3600 + m * 60)

print("{}:{}:{}".format(h, m, s))


Measured memory_bytes: 5596
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> c[i][j];
    }
  }

  int HW = H + W;
  int ans = 0;
  rep(b, bit(HW)) {
    auto cc = c;
    rep(k, HW) {
      if ((b >> k) & 1) {
        if (k < H) {
          int i = k;
          rep(j, W) {
            cc[i][j] = '*';
          }
        } else {
          int j = k - H;
          rep(i, H) {
            cc[i][j] = '*';
          }
        }
      }
    }

    int cnt = 0;
    rep(i, H) {
      rep(j, W) {
        cnt += cc[i][j] == '#';
      }
    }
    ans += cnt == K;
  }
  cout << ans << endl;
}

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

long init_sum(unordered_map<int, int> &d_max, int k, priority_queue<int> &ds, stack<int> &remove_candidate) {
    long res = 0;
    priority_queue<int> type;
    for (auto x : d_max) {
        type.push(x.second);
    }
    int i = k;
    while (!type.empty() && k > 0) {
        k--;
        int top = type.top();
        res += top; type.pop();
        remove_candidate.push(top);
    }
    while (k > 0) {
        k--;
        res += ds.top(); ds.pop();
    }
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    priority_queue<int> ds;
    unordered_map<int, int> d_max;
    for (int i = 0; i < n; i++) {
        int t, d;
        cin >> t >> d;
        if (d_max.find(t) == d_max.end()) {
            d_max[t] = d;
        } else {
            if (d_max[t] < d) {
                ds.push(d_max[t]);
                d_max[t] = d;
            } else {
                ds.push(d);
            }
        }
    }

    long types = min((long) d_max.size(), (long) k);
    stack<int> remove_candidate;
    long d_sum = init_sum(d_max, k, ds, remove_candidate);
    long ans = d_sum + types * types;

    while (types > 0) {
        if (ds.empty() || ds.top() <= remove_candidate.top())
            break;

        types--;
        d_sum += (long) ds.top() - remove_candidate.top();
        ds.pop();
        remove_candidate.pop();
        ans = max(ans, d_sum + types * types);
    }

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


Measured memory_bytes: 5284
#include <bits/stdc++.h>
#define INF 1000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

typedef unsigned long long ull;
const ull B = 1000000007;
//=============rolling_hash============================
ull rolling_hash(vector<ll> a) {
    ll al = a.size();
    ull t = 1;
    ull ah = 0;
    for (ll i = 0; i < al; ++i) {
      ah = ah * B + a.at(i);
      t *= B;
    }
    return ah;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> a(N), b(N);
  for (ll i = 0; i < N; ++i) {
    cin >> a.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    cin >> b.at(i);
  }
  vector<ll> ax(N), bx(N);
  for (ll i = 0; i < N; ++i) {
    ax.at(i) = a.at(i) ^ a.at((i + 1) % N);
    bx.at(i) = b.at(i) ^ b.at((i + 1) % N);
  }
  ull ah = rolling_hash(ax);
  ull bh = rolling_hash(bx);
  ull t = 1;
  for (ll i = 0; i < a.size(); ++i) {
    t *= B;
  }
  vector<pll> ans;
  for (ll i = 0; i < N; ++i) {
    // cout << ah << ' ' << bh << "\n";
    if (ah == bh) {
      ans.push_back({i, a.at(i) ^ b.at(0)});
    }
    ah = ah * B + ax.at(i) - ax.at(i) * t;
  }
  for (ll i = 0; i < ans.size(); ++i) {
    cout << ans.at(i).first << ' ' << ans.at(i).second << "\n";
  }
}


Measured memory_bytes: 15680
#include <stdio.h>
long int n,ans = -20000000,mem;
long int num[200][200] = {0};
int main()
{
    scanf("%ld",&n);
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            scanf("%ld",&num[i][j]);
        }
    }
    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            num[i][j] = num[i - 1][j] + num[i][j];
        }
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 2; j <= n; j++)
        {
            num[i][j] = num[i][j - 1] + num[i][j];
        }
    }
    for(int i = 0; i <= n - 1; i++)
    {
        for(int j = i + 1; j <= n; j++)
        {
            for(int k = 0; k <= n - 1; k++)
            {
                for(int l = k + 1; l <= n; l++)
                {
                    mem = num[i][k] - num[i][l] - num[j][k] + num[j][l];
                    if(ans < mem)ans = mem;
                    //printf("%d %d %d %d [%ld]\n",i,j,k,l,mem);
                }
            }
        }
    }
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 1192
n = int(input())
x = list(map(int,input().split()))
a = min(x)
b = max(x) + 1
ans = 10 ** 8
for p in range(a,b):
    m = 0
    for i in range(n):
        m += (x[i] - p) ** 2
    ans = min(ans,m)
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  string s;cin >> s;
  if(s[s.size()-1] == 's') cout << s << "es\n";
  else cout << s << "s\n";
}

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

#define int long long
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
int gcd( int m, int n )
{
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    // ユークリッドの方法
    while( m != n )
    {
        if ( m > n ) m = m - n;
        else         n = n - m;
    }
    return m;
}//gcd

//*********************************************************
// 最小公倍数（Least Common Multiple）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
int lcm( int m, int n )
{
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

signed main(){
    int n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;

    int l=lcm(n,m);
    unordered_map<int,char> ans;
    for (int i = 0; i < n; ++i) {
        ans[i*l/n]=s[i];
    }
    for (int i = 0; i < m; ++i) {
        if (ans[i * l / m] == 0)continue;
        if (ans[i * l / m] == t[i])continue;
        cout<<-1<<endl;
        return 0;
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
  struct node{
    int p,y;}x[100005];
  bool cmp(node a,node b)
  {
  if(a.p==b.p) return a.y<b.y;
  return a.p<b.p;
  }
  int a[100005],b[100005];
  map<pair<int , int >,int >m1;
  int main()
  {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++)
  {
  scanf("%d%d",&a[i],&b[i]);
  x[i].p=a[i];
  x[i].y=b[i]; 
  }
  sort(x+1,x+m+1,cmp);
 int t=0,tt=1;
 for(int i=1;i<=m;i++)
 {
    if(x[i].p==t){
     m1[make_pair(x[i].p,x[i].y)]=tt;
  tt++;
  }
  else{
  m1[make_pair(x[i].p,x[i].y)]=1;
  tt=2;
  t=x[i].p;
}
}
for(int i=1;i<=m;i++)
{ 
printf("%06d%06d\n",a[i],m1[make_pair(a[i],b[i])]);
}
return 0;
}

Measured memory_bytes: 9344
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextLineInt() []int {
	arr := strings.Split(nextLine(), " ")
	var ret []int
	for _, v := range arr {
		x, _ := strconv.Atoi(v)
		ret = append(ret, x)
	}
	return ret
}

func main() {
	cin := nextLineInt()
	F := cin[0]
	fmt.Println((F-30)/2)
}



Measured memory_bytes: 1092
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n;
    cin>>n;
	int a[n];
	int x=0;
	rep(i,0,n){
		cin>>a[i];
		x=x^a[i];
	}
	rep(i,0,n){
		cout<<(x^a[i])<<" ";
	}
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

using namespace std;

int n, k;
double p;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
    	int ans = i;
    	double ap = (double)1 / n;
    	while (ans < k) {
    		ap *= (double) 0.5;
    		ans *= 2;
    	}
    	//ap *= (double)1 / 2;
    	p += ap;
    }
    cout << setiosflags(ios::fixed);
    cout << setprecision(12) << p;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<29)//INF
#define F first
#define S second
#define VS vector<string>
#define VI vector<int>
#define REPI(i,s,n) for(int i=s;i<n;i++)//sからn未満の間iを回す
#define REPJ(j,s,n) for(int j=s;j<n;j++)//sからn未満の間iを回す
#define RREPI(i,s,n) for(int i=s;i>=n;i--)//sからn以下の間iを回す
#define RREPJ(j,s,n) for(int j=s;j>=n;j--)//sからn以下の間jを回す
#define ALL(a) a.begin(),a.end()//ソートとかに使える sort(ALL(vec))のように
#define SET(a,c) memset(a,c,sizeof(a));//aをc（0or1）で初期化する
#define DEBUGONE(x) cout<<#x<<" : "<<x<<endl;//デバックで一つの変数を表示
#define DEBUGTWO(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;//デバックで二つの変数を表示
#define DEBUGTHREE(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl;//デバックで三つの変数を表示
#define OUTONE(x) cout<<x<<endl;//一つの変数を表示
#define OUTTWO(x,y) cout<<x<<" "<<y<<endl;//二つの変数を表示
#define OUTTHREE(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;//三つの変数を表示
typedef long long int64;
typedef pair<string,int> Psi;
typedef pair<int,int> Pii;
main(){
  int n,m;
  VI a,b,c;
  int go,to,co;
  cin>>n>>m>>go;
  go--;
  int64 rui[150000]={0};
  REPI(i,0,m-1){
    cin>>to;
    to--;
    int front=min(go,to);
    int back=max(go,to);
    rui[front]+=1;
    rui[back]-=1;
    go=to;
  }
  REPI(i,0,n-1){
    cin>>go>>to>>co;
    a.push_back(go);
    b.push_back(to);
    c.push_back(co);
  }
  int64 ans=0;
  REPI(i,1,n+1){
    rui[i]=rui[i-1]+rui[i];
  }
  REPI(i,0,n){
    ans+=min(rui[i]*a[i],rui[i]*b[i]+c[i]);
  }
  OUTONE(ans);
}

Measured memory_bytes: 3628
def main(K, X):
    num_list = [x for x in range(-1000000,1000001,1)]
    if 100 >= K >= 1 and 100 >= X >= 0:
        range_k = [j for j in range(X-K+1, X+K,1)]
    for j in range(len(range_k)):
        print(range_k[j], end=' ')

if __name__ == '__main__':
    s = list(map(int, input().split()))
    main(s[0], s[1])

Measured memory_bytes: 82200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	vector<int> v(3);
	rep(i,3)cin>>v[i];
	
	int sum = 0;
	rep(i,3)sum+=v[i];
	
	rep(i,3){
		if(v[i]*2==sum){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
listV = list(map(int, input().split()))
listC = list(map(int, input().split()))
listA = []
b = 0
for i in range(n):
    a=listV[i]-listC[i]
    listA.append(a)

for j in range(n):
    if listA[j]>0:
        b = b + listA[j]
print(b)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long b=0,c=0,d=1,e,f=1000000,t,g[100000];
  long long a;
  cin>>a>>b>>c>>d;
  if(d%2==1) swap(a,b);
  if(abs(a-b)>=100000000000000000ll) cout<<"Unfair";
  else cout<<a-b;
  cout<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main(){
    int n, k, m, g;
    cin >> n >> k >> g;
    m = g;
    vector<int> a(n);
    rep(i,n-1){
        int x;
        cin >> x;
        g = gcd(g,x);
        m = max(m, x);
    }
    if(k % g != 0 || k > m) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
}

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

int main() {
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n-1; i > 0; i--) {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3084
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {
  class Node(id:Int,dist:Int) { }

  def main(args:Array[String]) = {
    val n = readInt
    val b = new ArrayBuffer[String]
    for(i<-0 until n) {
      val l = readLine.trim
      var s = l(0).toString
      var j = 1
      while(j < l.length) {
        if(!s.contains(l(j+2))) {
          if(l(j+1) == '>') s = s+l(j+2) else s = l(j+2) + s
        }
        j = j+3
      }
      b += s
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 43944
<?php
	while( "-" != ($cards = trim( fgets( STDIN ) )) ) {
		$m = trim( fgets( STDIN ) );
		while( $m-- ) {
			$h = trim( fgets( STDIN ) );
			$cards = substr( $cards, $h ).substr( $cards, 0, $h );
		}
		print $cards.PHP_EOL;
	}
	return;
?>

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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    int K;
    string s;
    cin >> K;
    cin >> s;
    if(s.size() > K) {
        for(int i = 0; i < K; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    } else {
        cout << s << endl;
    }
}

Measured memory_bytes: 3624
#include<cstdio>
int main(){
	int l;
	scanf("%d",&l);
	int n;
	int m=0;
	int pow[21]={};
	pow[0]=1;
	for(int i=1;i<21;i++){
		pow[i]=pow[i-1]*2;
		if(pow[i-1]<=l&&pow[i]>l)n=i;
	}
	int s[100]={};
	int t[100]={};
	int le[100]={};
	for(int i=0;i<n-1;i++){
		s[m]=i;
		t[m]=i+1;
		m++;
	}
	for(int i=0;i<n-1;i++){
		s[m]=i;
		t[m]=i+1;
		le[m]=pow[n-2-i];
		m++;
	}
	
	int ll[n]={};
	ll[0]=l;
	for(int i=0;i<n-1;i++){
		ll[i+1]=ll[i]/2;
		ll[i]=ll[i]%2;
	}
	for(int i=0;i<n-1;i++){
		if(ll[i]==1){
			s[m]=0;
			t[m]=n-1-i;
			le[m]=l-pow[i];
			l=l-pow[i];
			m++;
		}
	}
	printf("%d %d\n",n,m);
	for(int i=0;i<m;i++){
		printf("%d %d %d\n",s[i]+1, t[i]+1, le[i]);
	}
	return 0;
}

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

int N;
vector<int> B;

int main(void) {
	cin >> N;

	B.resize(N + 1);
	int mid = (N % 2 == 0) ? N / 2 : (N + 1) / 2;
	for (int i = 1; i <= N; ++i) {
		int a;
		cin >> a;
		int idx = (i % 2 == 0) ? (mid + i / 2) : (mid - i / 2);
		B[idx] = a;
	}

	if (N % 2 == 0) {
		for (int i = N; i >= 1; --i) {
			cout << B[i];
			if (i == 1)
				cout << '\n';
			else
				cout << ' ';
		}
	}
	else {
		for (int i = 1; i <= N; ++i) {
			cout << B[i];
			if (i == N)
				cout << '\n';
			else
				cout << ' ';
		}
	}

	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 +7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n;
    cin >> n;
    vector<vector<int>> c(10, vector<int>(10));
    for (int i = 1; i <= n; i++) {
        int r = i % 10;
        int x = i;
        int l;
        while (x) {
            l = x % 10;
            x /= 10;
        }
        c[l][r]++;
    }
    long long ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(n,x) for(ll i=0;i<n;i++) cin>>x[i];


int main()
{
	double a, b, x;
	cin >> a >> b >> x;
	double ans;
	if (a * a * b <= 2 * x)
	{
		ans = atan((2 * a * a * b - 2 * x) / (a * a * a));
	}
	else
	{
		ans = atan(a * b * b / (2 * x));
	}
  
	double p = 3.1415926535;
	ans *= 180 / p;
	cout << fixed << setprecision(10) << ans << "\n";

	return 0;
}

Measured memory_bytes: 3960
import java.util.Scanner;
 
class Main{
 
    public static void main(String[] args){
 
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        scanner.close();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    }
 
}

Measured memory_bytes: 26952
$mod = 998244353

n = gets.to_i
h = Array.new(n+1, 0)
d = gets.split.map do |e|
    e = e.to_i
    h[e] += 1
    e
end

if d[0] != 0 || h[0] != 1
    puts 0
else
    ans = 1
    max = d.max
    
    1.upto(max) {|i| ans = ans * h[i-1] ** h[i] % $mod}
    puts ans
end

Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define lint long long
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
using namespace std;

int main(){
  int K;
  string S;
  cin >> K >> S;
  int len = S.size();
  if(len <= K) cout << S << endl;
  else{
    string sub = S.substr(0, K);
    cout << sub << "..." << endl;
  }
}

Measured memory_bytes: 3628
<?php
	$n = trim( fgets( STDIN ) );
	$nums = [];
	for( $i=0; $i<$n; $i++ ) {
		array_push( $nums, intval( trim( fgets( STDIN ) ) ) );
	}
	$cnt = $n;

	$cnt = array_reduce( $nums, 
			function( $carry, $item ) {
				if( 2 != $item ) {
					if( 0 != $item%2 ) {
						for( $i=3; $i*$i<=$item; $i+=2 ) {
							if( 0 == $item%$i )  {
								$carry--;
								break;
							}
						}
					} else {
						$carry--;
					}
				}
				return $carry;
				}, $cnt );
	print $cnt;
?>

Measured memory_bytes: 16472
program solve
  integer  :: n
  INTEGER(8) :: L0
  INTEGER(8) :: L1
  INTEGER(8) :: tmp
  read (*,*) n
  
  L0 = 2
  L1 = 1
  do i = 1, n-1
    tmp = L0 + L1
    L0 = L1
    L1 = tmp
  end do
  ! i0 は整数を左寄せでprintするフォーマットの意味 
  PRINT '(i0)', L1
end program solve

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


int main() 
{
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        int k = n-i-1;
        cout << a[k];
        if(i!=n-1) cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3036
/*
 * 17-1-7_ABC051_B.cpp
 *
 *  Created on: 2017/01/07
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>

using namespace std;

int K,S;
int ans;
int main(){
	cin >> K >>S;
	for(int x=0;x<=min(K,S);x++){
		for(int y=0;y<=min(K,S-x);y++){
			int z = S - (x+y);
			if(0 <= z && z <= K)
				ans++;
		}
	}
	cout << ans <<endl;
	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int abs(int a)
{
	return a<0?-a:a;
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>0&&b>0)printf("Positive");
	else if(a<0&&b>0)printf("Zero");
	else if(a==0||b==0)printf("Zero");
	else if(a<0&&b<0)
	{
		if((abs(a-b)+1)%2!=0)printf("Negative");
		else printf("Positive");
	}
	return 0;
}

Measured memory_bytes: 128
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<bitset>
#include<queue>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 5 * 100*1000 + 7;

int test;

int n;

VI g[N];

BIT czy;

int res;

int dfs(int v,int p){
    int byl = 0;
    czy[v] = 1;

    for(auto it:g[v]){
        if (!czy[it]){
            byl += dfs(it,v);
        }
    }

    int dod = (ll) g[v].size() - 2 - byl;

    dod = max(dod,(ll)0);

    res += dod;

    return min((ll)1,max(dod,byl));
}

void solve()
{
    cin >> n;

    FOR(i,1,n-1){
        int a,b;
        cin >> a >> b;

        g[a].eb(b);
        g[b].eb(a);
    }

    REP(i,n){
        if (g[i].size() > 2){
            g[i].pb(i);
            dfs(i,i);
            break;
        }
    }

    cout << max((ll)1,res);

    return;
}

int32_t main()
{
    boost

    test=1;

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

  return 0;
}


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

using namespace std;

int main() {
    int a[4];
    for (int i = 0; i < 4; ++i) cin >> a[i];
    int ans = (int) 1e9;
    for (int i = 0; i < 4; ++i) {
        for (int j = i + 1; j < 4; ++j) {
            int x = a[i] + a[j];
            int y = 0;
            for (int k = 0; k < 4; ++k) {
                if (k != i && k != j) y += a[k];
            }
            ans = min(ans, abs(x - y));
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 

int main(){
	
	int n;cin>>n;
	int ans = 1<<15;
	rep(loop,n)
	{
		int a;cin >> a;
		int cnt = 0;
		while(a%2 == 0)
		{
			cnt++;
			a /=2;
		}
		ans = min(ans,cnt);
	}
	cout << ans <<endl;
	
}

//cout << ans << endl;

Measured memory_bytes: 256
#include <limits.h>
#include <string>
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, K, a[1000];
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> a[i];
		ans += a[i];
	}
	
	ans = LLONG_MAX;
	
	for (i = -100; i <= 100; i++) {
		for (j = 0; j < N; j++) {
			k += (a[j]-i)*(a[j]-i);
		}
		ans = min(ans, k);
		k = 0;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
const int N=200006;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<n-2;i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
			cnt++;
	}
	cout<<cnt<<'\n';
}


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

using namespace std;

const int NullIndex = -1;
vector<int> heap;
int heap_size;

int get_left_index(int index) {
  int last_index = heap_size;
  int left_index = index * 2;

  if (left_index > last_index) {
    return NullIndex;
  }

  return left_index;
}

int get_right_index(int index) {
  int last_index = heap_size;
  int right_index = index * 2 + 1;

  if (right_index > last_index) {
    return NullIndex;
  }

  return right_index;
}

void max_heapify(int current_index) {
  int large_child_index;

  int left_index = get_left_index(current_index);
  int right_index = get_right_index(current_index);

  // ヒープのサイズが1ののとき
  if (left_index == NullIndex && right_index == NullIndex) {
    return;
  }

  large_child_index = left_index;
  if (right_index != NullIndex && heap[right_index] >= heap[left_index]) {
    large_child_index = right_index;
  }

  if (heap[current_index] < heap[large_child_index]) {
    int tmp = heap[current_index];
    heap[current_index] = heap[large_child_index];
    heap[large_child_index] = tmp;

    max_heapify(large_child_index);
  }
}

void build_max_heap() {
  int last_paranet_index = heap_size % 2 == 0 ? heap_size / 2 : (heap_size - 1) / 2;

  for(int i = last_paranet_index; i >= 1; i--) {
    max_heapify(i);
  }

}

int main() {

  cin >> heap_size;
  heap.resize(heap_size + 1);

  for(int i = 1; i <= heap_size; i++) {
    cin >> heap[i];
  }

  build_max_heap();

  for(int i = 1; i <= heap_size; i++) {
    cout << " " << heap[i];
  }
  cout << endl;
}



Measured memory_bytes: 4568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  if(n == 25)cout << "Christmas" << endl;
  if(n == 24)cout << "Christmas Eve" << endl;
  if(n == 23)cout << "Christmas Eve Eve" << endl;
  if(n == 22)cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, m, c;
    std::cin >> n >> m >> c;
    std::vector<int> b(m);
    for (auto &el : b) std::cin >> el;
    int p = 0;
    for (int i = 0; i < n; i++) {
        int ret = c;
        for (int i = 0; i < m; i++) {
            int a;
            std::cin >> a;
            ret += a * b[i];
        }
        if (ret > 0) p++;
    }
    std::cout << p << std::endl;

    return 0;
}


Measured memory_bytes: 256