akhauriyash/Code-Regression huggingface dataset:
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var ans = s

    var lCnt = 0
    var rCnt = 0

    s.forEach { c ->
        if (c == '(') lCnt++
        if (c == ')') rCnt++

        if (rCnt > lCnt) {
            lCnt++
            ans = "($ans"
        }
    }

    repeat(lCnt-rCnt) {
        ans = "$ans)"
    }

    println(ans)
}

Measured memory_bytes: 34488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
ll gcd(ll a,ll b){
  if(b==0)return a;
  return gcd(b,a%b);
}
vi sosuu(ll n){ //n以下の素数列挙
  vector<bool> b(n-1,true);
  for(ll i=2;i<=sqrt(n);i++){
    if(!b[i-2])continue;
    for(ll j=2;i*j<=n;j++){
      b[i*j-2]=false;
    }
  }
  vi v;
  rep(i,n-1){
    if(b[i])v.push_back(i+2);
  }
  return v;
}
vector<P> bunkai(ll n){
  vector<P> v;
  vi x=sosuu(sqrt(n)+1);
  for(ll i:x){
    if(n%i!=0)continue;
    ll k=0;
    while(n%i==0){
      k++;
      n/=i;
    }
    v.emplace_back(i,k);
  }
  if(n!=1)v.emplace_back(n,1);
  return v;
}
int main(){
  ll a,b;cin>>a>>b;
  ll n=gcd(a,b);
  vector<P> v=bunkai(n);
  cout<<v.size()+1<<endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, a[200005], fw[200005], ans;
void upd(ll p, ll v){
	for (ll i= p; i <= n; i+= (i&(-i)))fw[i] += v;
}
ll qry(ll p){
	ll res = 0;
	for (ll i= p; i > 0; i-=(i&(-i)))res+=fw[i];
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i= 1; i <= n; i++)cin >> a[i];
	//check if there is anything before you that is smaller than you, 
	//if have, then don't count, else count
	for (ll i = 1; i <= n; i++){
		//PURQ
		ll check = qry(a[i]-1)-qry(0);
		if (check == 0)ans++;
		upd(a[i], 1);
	}
	cout << ans;
}


Measured memory_bytes: 3328
N = int(input())
A = [int(a) for a in input().split()]

A.append(0)
A.insert(0, 0)
L = []
for i in range(N+1):
    L.append(abs(A[i]-A[i+1]))
    
L_a = []
for i in range(N):
    L_a.append(abs(A[i]-A[i+2]))
    
l = 0
for i in range(N+1):
    l += abs(A[i]-A[i+1])
    
for i in range(N):
    print(l-L[i]-L[i+1]+L_a[i])

Measured memory_bytes: 16420
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, D = map(int, input().strip().split())
x = list()
y = list()
for _ in range(N):
    tmp_x, tmp_y = map(int, input().strip().split())
    x.append(tmp_x)
    y.append(tmp_y)
 
res = 0
for i in range(N):
    if x[i] ** 2 + y[i] ** 2 <= D ** 2:
        res += 1

print(res)



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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector <int> a(3); cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(),a.end()); cout << a[2]*10+(a[1]+a[0]) << "\n";
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
        Ok(_) => match input.trim_end().parse::<i32>() {
            Ok(x) => println!("{}", if x >= 30 { "Yes" } else { "No" }),
            Err(_) => eprintln!("not a number")
        }
        Err(_) => eprintln!("can't read anything")
    }
}


Measured memory_bytes: 2096
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num =new int[3];
		for(int i = 0; i < 3; i++) {
			num[i] = sc.nextInt();
		}
		
		int count = 0;
		while(num[0]!=num[1]||num[1]!=num[2] || num[0] != num[2]) {
			Arrays.sort(num);
			if(num[0] != num[2] && num[1] != num[2]) {
				num[0]++;
				num[1]++;
				count++;
			}
			if(num[0] != num[2]&&num[1] == num[2]) {
				num[0]+=2;
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35856
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
s = [list(input()) for i in range(n)]
ss = []
for i in range(n):
    if s[i].count('.') == m:
        continue
    ss.append(s[i])
sss = [[]for _ in range(len(ss))]
for i in range(m):
    ok = False
    ln = len(ss)
    for j in range(ln):
        if ss[j][i] == '#':
            ok = True
    if ok:
        for j in range(ln):
            sss[j].append(ss[j][i])

for i in sss:
    print(''.join(i))


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  cout << C << " " << A << " " << B << endl;
}

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

int main()
{
	char b;

	cin >> b;
	if (b == 'A')
	{
		cout << "T" << endl;
	}
	else if (b == 'T')
	{
		cout << "A" << endl;
	}
	else if (b == 'C')
	{
		cout << "G" << endl;
	}
	else
	{
		cout << "C" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=300+10,mod=1e9+7;
inline void add(int &x,int y){
	x+=y;
	if(x>=mod) x-=mod;
}
vector<int> G[maxn],ve[maxn];
int dp[maxn][maxn][maxn];
int sz[maxn];
int main(){
	int n=read(),m=read();
	REP(i,1,m){
		int x=read(),y=read(),z=read();
		G[y].push_back(x),ve[y].push_back(z);
		++sz[y];
	}
	dp[0][0][0]=1;
	REP(i,0,n) REP(j,0,max(i-1,0)) REP(k,j,jend) if(dp[i][j][k]){
		REP(u,0,sz[i]-1)
			if(ve[i][u]!=(j>=G[i][u])+(k>=G[i][u])+1){
				dp[i][j][k]=0;
				break;
			}
		if(!dp[i][j][k]) continue;
		add(dp[i+1][j][k],dp[i][j][k]);
		add(dp[i+1][j][i],dp[i][j][k]);
		add(dp[i+1][k][i],dp[i][j][k]);
	}
	int ans=0;
	REP(i,0,n-1) REP(j,i,n-1) add(ans,dp[n][i][j]);
	printf("%d\n",ans);
	return 0;
}


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

#define PREC 1e-12

int main() {
    int x, y, x0, y0, x1, y1, x2, y2, x3, y3;
    int q;
    double v1x, v1y, v2x, v2y, cosa;
    int judge;

    scanf("%d", &q);
    
    while (q--) {
        scanf("%d %d %d %d %d %d %d %d",
              &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        v1x = x1 - x0;
        v1y = y1 - y0;
        v2x = x3 - x2;
        v2y = y3 - y2;
        cosa = (v1x*v2x + v1y*v2y) /
            (sqrt(v1x*v1x+v1y*v1y) * sqrt(v2x*v2x+v2y*v2y));

        if (fabs(cosa) < PREC) {
            judge = 1;
        }
        else if (fabs(fabs(cosa) - 1.0) < PREC) {
            judge = 2;
        }
        else {
            judge = 0;
        }
        printf("%d\n", judge);
    }
}

Measured memory_bytes: 600
n=int(input())
a = list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(n-i-1):
        j+=i+1
        d=a[i]-a[j]
        if(d<0):
            d=-d
        ans=max(ans,d)

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <queue>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)
#define pb push_back

using namespace std;

const int N = 100010;

int n, A[N];

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &A[i]);
	sort(A + 1, A + n + 1, greater<int>());
	int a = 0, b = 0;
	For(i, 1, n){
		if(b) break;
		if(A[i] == A[i + 1]){
			if(!a) a = A[i];
			else b = A[i];
			++i;
		}
	}
	cout << 1LL * a * b << endl;
	return 0;
}

Measured memory_bytes: 640
fun main(args : Array<String>) {
    val S = readLine()!!
    val trg = 753
    val lastIndex = S.length - 1

    val min = (0..lastIndex - 2).map {
        val from = it
        val to = it + 3
        Math.abs(Integer.parseInt(S.subSequence(from, to).toString()) - trg)
    }.min()

    println(min)
}

Measured memory_bytes: 31888
program sample
	implicit none
    integer :: a
    
    read(*,*) a
    
    if(a<1200) then
    	write(*,*) 'ABC'
    else if(a>=2800) then
    	write(*,*) 'AGC'
    else
    	write(*,*) 'ARC'
    end if
    stop
end program sample




Measured memory_bytes: 2784
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=2e5+4;
const int mod=1e9+7;
void solve(){
    int k; cin>>k;
    string temp="ACL";
    string ans="";
    for(int i=0;i<k;i++){
        ans+=temp;
    }
    cout<<ans<<endl;
}   
int32_t main(){
    // ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tt; 
    tt=1;
    // cin>>tt;
    for(int t=1;t<=tt;t++){
        solve();
    }
} 

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;
int main(){
    string S;
    cin >> S;
    for(int i = 0;i < (1<<3);i++){
        string siki;int ans = S[0] - '0';
        for(int j = 0;j < 3;j++){
            siki += S[j];
            if(i & (1<<j)){siki += '+';ans += S[j+1] - '0';}
            else {siki += '-';ans -= S[j+1] -'0';}
        }
        siki += S[3];
        if(ans == 7){cout << siki + "=7";return 0;}
    }
}

Measured memory_bytes: 256
"use strict"
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {
    const rows = input.split("\n")
    const H = rows[0].split(" ")[0] - 0
    const W = rows[0].split(" ")[1] - 0

    const map = []
    const dp = []
    for (let r  = 0; r < H; r++) {
        map[r] = []
        dp[r] = []
        for (let c = 0; c <  W; c++) {
            map[r][c] = rows[r + 1][c]
            dp[r][c] = Infinity
        }
    }

    dp[0][0] = map[0][0] === '.' ? 0 : 1
    for (let r = 0; r < H; r++ ) {
        for (let c = 0; c < W; c++) {
            if (c + 1 < W) {
                if (map[r][c] === map[r][c + 1]) {
                    dp[r][c + 1] = Math.min(dp[r][c + 1], dp[r][c])
                } else {
                    dp[r][c + 1] = Math.min(dp[r][c + 1], dp[r][c] + 1)
                }
            }
            if (r + 1 < H) {
                if (map[r][c] === map[r + 1][c]) {
                    dp[r + 1][c] = Math.min(dp[r + 1][c], dp[r][c])
                } else {
                    dp[r + 1][c] = Math.min(dp[r + 1][c], dp[r][c] + 1)
                }
            }
        }
    }

    if (map[H - 1][W - 1] === '#') {
        dp[H - 1][W - 1]++
    }
    console.log(Math.ceil(dp[H - 1][W - 1] / 2))
})(input)


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

int main(){
    char a[3],b[3];
    cin>>a>>b;
    int k=0;
    for(int i=0; i<3; i++){
        if(a[i]==b[2-i]){
            k++;
        }
    }
    if(k==3){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
ll dp[100010], v[100010], n, k;
ll f(int pos){
    if(pos >= n) return 2e9;
    if(pos == n - 1) return 0;
    ll &ans = dp[pos];
    if(ans != -1) return ans;
    ans = 2e9;
    for(int i = 1; i <= k; i++)
        ans = min(ans, f(pos + i) + abs(v[pos + i] - v[pos]));
    return ans;
}
int main(){
    fast;
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    cout << f(0) << "\n";
	return 0;
}


Measured memory_bytes: 11424
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define ui unsigned int
#define pb push_back
#define ul unsigned long
#define show(x) ; //cerr << #x << ':' << x << endl;

using namespace std;
long dp[100000];
long mincost(vector<long> &v, long i, long j, long k)
{
    ll ret = 0;
    show(i);
    show(j);
    if (j + 1 < v.size())
    {
        // show(j);
        // show(j + 1);
        // show(j + 2);
        if (dp[j] == -1)
        {
            long mine=mincost(v, j, j + 1,k);
            for (long l=2;l<=k && (j+l)<v.size();l++)
                mine = min(mine,mincost(v, j, j + l,k));
            dp[j]=mine;
        }
        ret += dp[j];
    }
    // else if (j + 1 < v.size())
    // {
    //     // show(j);
    //     // show(j + 1);
    //     if (dp[j] == -1)
    //     {
    //         dp[j] = mincost(v, j, j + 1);
    //     }
    //     ret += dp[j];
    // }
    show(ret);
    show(v[j]);
    show(v[i]);
    ret += abs(v[j] - v[i]);
    show(ret);
    return ret;
}

int main(int argc, const char **argv)
{
    cin.tie(0);
    cout.tie(0);
    long n, k;
    cin >> n >> k;
    vector<long> v;
    memset(dp, -1, sizeof(dp));
    for (ull i = 0; i < n; i++)
    {
        ull t;
        cin >> t;
        v.push_back(t);
    }
    cout << mincost(v, 0, 0, k);
}

Measured memory_bytes: 8180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        int big, small;
        if (a[0] == a[1]) {
            System.out.println(a[0]);
            return;
        } else if (a[0] > a[1]) {
            big = a[0];
            small = a[1];
        } else {
            big = a[1];
            small = a[0];
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                System.out.println(small);
                return;
            } else {
                big = small;
                small = x;
            }
        }
    }
}

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

int main(){
    int a,b;
    char c;
    
    
    for(int i =0;i<20000;i++){
        cin >> a >>c >> b;
        if(c=='?') break;
        if(c=='+') cout << a+b << endl;
        if(c=='-') cout << a-b << endl;
        if(c=='*') cout << a*b << endl;
        if(c=='/') cout << a/b << endl;
        
    }



}


Measured memory_bytes: 3080
n = gets.to_i
a = [0] + gets.split(" ").map(&:to_i)
INF = Float::INFINITY
yen = 1000
(1..(n-1)).each do |i|
  if a[i] < a[i+1]
    stock = yen / a[i]
    yen += (a[i+1] - a[i]) * stock
  end
end
puts yen

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

int main() {
  int N;
  cin >> N;
  vector<int> L(2*N);
  rep(i,2*N) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int answer = 0;
  rep(i,N) {
    answer += min(L.at(i*2), L.at(i*2+1));
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import sys
for e in sys.stdin:
 e=float(e)
 h=['light ','']
 a=h[e>91]+'heavy'if e>81 else h[e>75]+'middle'if e>69 else h[e>64]+'welter'if e>60 else'light'if e>57 else'feather'if e>54 else'bantam'if e>51else h[e>48]+'fly'
 print(a)


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

ll X,Y,Z,K;
vector<ll> A,B,C;
priority_queue<ll,vector<ll>,greater<ll>> R;
set<ll> F;
void Cost(int a,int b,int c){
	if(a>=X || b>=Y || c>=Z) return;
	auto res = F.insert(1000LL*1000LL*a+1000LL*b+c);
	if(!res.second) return;

	if(R.size()<K){
		R.push(A[a]+B[b]+C[c]);
	}
	else{
		ll v = R.top();
		R.pop();
		ll u = A[a]+B[b]+C[c];
		if(u<=v){
			R.push(v);
			return;
		}
		R.push(u);
	}

	Cost(a+1,b,c);
	Cost(a,b+1,c);
	Cost(a,b,c+1);
}

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

	X=in<ll>(),Y=in<ll>(),Z=in<ll>(),K=in<ll>();
	A.resize(X),B.resize(Y),C.resize(Z);
	REP(i,X) A[i]=in<ll>();
	REP(i,Y) B[i]=in<ll>();
	REP(i,Z) C[i]=in<ll>();
	sort(ALL(A),greater<ll>());
	sort(ALL(B),greater<ll>());
	sort(ALL(C),greater<ll>());

	Cost(0,0,0);
	vector<ll> res(K);
	REP(i,K){
		res[K-1-i] = R.top();
		R.pop();
	}
	for(auto& x:res){
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 217472
// 100

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N, K;
    cin >> N >> K;
    int sum = 0;
    for(int i=1;i<=N;i+=2) sum++;
    if(sum>=K) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,(input().split())))
total = 0
result = 0
MOD = pow(10,9)+7
l = []

for i in range(N):
    total += A[i]
    l.append(total)#累積和

for i,num in enumerate(l):
    temp = total-num #A[i+1]+A[i+2]+...+A[N]
    result += temp*A[i]#A[i](A[i+1]+A[i+2]+...+A[N])の総和

print(result%MOD)


Measured memory_bytes: 31416
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const ll MOD = (ll)1000000007;//10^9+7
const ll INF2 = (ll)100000000000000000;//10^18


int main() {
    int a,b,h;
    cin>>a>>b>>h;
    
    cout << (a+b)*h/2<< endl;
}


Measured memory_bytes: 256
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 int n;
 cin>>n;
 vector<int>a(n);
 int d=0;
 int64_t cnt=0;
 rep(i,n){
   cin>>a.at(i);
   if(a.at(i)<d){
     cnt+=d-a.at(i);
   }
   if(d<a.at(i)){
     d=a.at(i);
   }
 }
 cout<<cnt<<endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,a,b;
  bool hoge = true;
    cin >> k;
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
          hoge = false;
            break;
        }
      
    }
    /*if(b-a >= k-1){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }*/
  if(hoge) cout << "NG" << endl;
    return 0;
 
 
    
}

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

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> Point(N, Q - K + 1);
	for (int i = 0; i < Q; i++) {
		int A;
		cin >> A;
		Point[A - 1]--;
	}
	for (int p : Point) cout << (p <= 0 ? "Yes" : "No") << endl;
}


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

int main() {
    int n, ans=0;
    std::cin >> n;
    std::vector<int> vec(n);
    for (auto &v : vec) std::cin >> v;
    for (int i=0; i<n; ++i) {
        bool flag = true;
        for (int j=0; j<i; ++j) {
            if (vec[j] > vec[i]) flag = false;
        }
        if (flag) ++ans;
    }
    std::cout << ans << '\n';
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int dp[55][3030];

int main() {

  for(int N, M, S; cin >> N >> M >> S && (N|M|S);) {
    rep(i, 55) rep(j, 3030)
      dp[i][j] = 0;

    dp[0][0] = 1;
    
    REP(add, 1, M + 1) {
      for(int index = N*N; index>=1; index--) {
        for(int curr=0; curr<=S-add; curr++) {
          (dp[index][curr + add] += dp[index - 1][curr]) %= 100000;
        }
      }
    }

    cout << dp[N*N][S] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
struct BinTree
{
	char data;
	BinTree *left,*right;
};
const long long mod=1e9+7;
int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> a(n+1);
	for(int i=0;i<m;i++)
	{
		int num;
		cin >> num;
		a[num]=1;
	}
	vector<int> dp(n+2);
	int mod=1000000007;
	dp[n]=1;
	for(int i=n-1;i>=0;i--)
	{
		if(a[i])
		{
			dp[i]=0;
			continue;
		}
		dp[i]=(dp[i+1]+dp[i+2])%mod;
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
#include <algorithm>
#include <map>

#define N ((int)2e5)
using namespace std;
typedef long long ll;
int main(int argc,char ** argv)
{
    int n,a[N];
    ll ans=0;
    cin>>n;
    map<int,int> mp;
    for(int i=0;i<n;++i){
        cin>>a[i];
        ++mp[a[i]];
    }
    for(auto iter:mp){
        ans+=iter.second*((ll)iter.second-1)/2;
    }
    for(int i=0;i<n;++i){
        int t=mp[a[i]];
        cout<<ans-(t-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 8320
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


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

	int c = 1, a = d[0];
	bool ok = true;
	while (a != 2)
	{
		a = d[a - 1];
		c++;
		if (c > n)
		{
			ok = false;
			break;
		}
	}
	if (ok)
		cout << c << endl;
	else 
		cout << -1 << endl;
}



Measured memory_bytes: 3688
class UnionFind():

    def __init__(self, N):
        # parent of each node
        self.parent = [n for n in range(N)]

        # number of nodes in union
        self.rank = [1] * N
        
    def find(self, u):
        if self.parent[u] == u:
            return u
        else:
            # recursive call
            return self.find(self.parent[u])
    
    def union(self, u, v):
        pu = self.find(u)
        pv = self.find(v)

        # same union
        if pu == pv: 
            return

        # let pv join into pu union 
        if self.rank[pu] < self.rank[pv]:
            pu, pv = pv, pu

        self.rank[pu] += self.rank[pv]
        self.parent[pv] = pu
 
N, M = map(int, input().split())
UF = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    UF.union(A, B)


ret = 0

for n in range(N):
    ret = max(ret, UF.rank[n])

print(ret)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 20
#define INFTY (1<<21)
class Node {
public:	int P;	vector<int> C;
	Node() {
		P = -1;
		C.clear();
	}
};
int N, G[MAX][MAX], total;
Node node[MAX]; bool visited[MAX];

void dfs(int u, int p) {
	visited[u] = true;
	node[u].P = p;
	rep(v, N){
		if (G[u][v] == INFTY || visited[v])	continue;
		node[u].C.push_back(v);
		dfs(v, u);
	}
}

void parse(int u, int cost) {
	visited[u] = true;
	if (node[u].C.size() == 0)return;
	for (int i = 0; i < node[u].C.size(); i++) {
		int v = node[u].C[i];
		if (!visited[v])parse(v, G[u][v]);
	}
	total += cost * 2;
}
int getCost() {
	rep(i, N)visited[i] = false;
	int cur = 0;	total = 0;
	while (cur != -1) {
		parse(cur, 0);
		if (node[cur].P != -1) 	total += G[cur][node[cur].P];
		cur = node[cur].P;
	}
	return total;
}
int compute() {
	int minc = INFTY;
	for (int s = 0; s < N; s++) {
		rep(i, N){
			visited[i] = false;
			node[i] = Node();
		}
		dfs(s, -1);
		minc = min(minc, getCost());
	}
	return minc;
}
int main() {
	int s, t, c;
	while( cin >> N && N ) {
		rep(i, N) rep(j, N) G[i][j] = INFTY;
		rep(i, N-1) {
			cin >> s >> t >> c;
			s--; t--;
			G[s][t] = G[t][s] = c;
		}
		cout << compute() << endl;
	}
}

Measured memory_bytes: 3100
// g++ -std=c++11 -O2 -Wall -Wl,--stack=268435456

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

typedef long long          ll;
typedef vector<int>        vi;
typedef vector<double>     vd;
typedef vector< vi >       vvi;
typedef vector< vd >       vvd;
typedef pair<int, int>     pi;
typedef vector< pi >       vpi;

#define LARGE_INT     1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = (int)(a); i < (int)(b); i++)


// string line;
// getline(cin, line);
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int  n;
    cin >> n;
    vector<vvd> dp(n+1, vvd(n+1, vd(n+1)));
    vi c(3, 0);
    REP(i, 0, n) { 
        int a;
        cin >> a; 
        c[a-1] ++;
    }
    double prob = 1.0 / n;
    // dp[i][j][k]   Expected number with i 3, j 2, k 1.
    dp[0][0][0] = 0.0;
    REP(i, 0, n+1) {  
        REP(j, 0, n+1-i) {
            REP(k, 0, n+1-i-j) {
                int m = i + j +k;
                if (m == 0)  continue;
                double ep = 1.0;
                if (i > 0)   ep += prob * i * dp[i-1][j+1][k]; 
                if (j > 0)   ep += prob * j * dp[i][j-1][k+1];
                if (k > 0)   ep += prob * k * dp[i][j][k-1];
                if (m < n) ep = ep * n / m;
                dp[i][j][k] = ep;
            }
        }
    }
    cout << setprecision(15) << dp[c[2]][c[1]][c[0]];
    return 0;
}

Measured memory_bytes: 216832
#include <iostream>
#include <atcoder/dsu>

using namespace std;

int main() {
  int N, M, A, B;
  cin >> N >> M;
  atcoder::dsu d(N);
  while(cin >> A >> B) d.merge(--A, --B);
  cout << d.groups().size() - 1 << endl;
}


Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
ll a[200006];
ll n;
int main(){
  		speed
     cin>>n;
    ll min=11;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        ll x=i;
        ll y=n/i;
        string s1=to_string(x);
        string s2 = to_string(y);
        ll z=max((ll)s1.length(),(ll)s2.length());
        if(z<min)
            min=z;
        }
    }
    cout<<min;
    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
ans=[0 for i in range(10**5+1)]

for i in range(N):
    ans[A[i]-1]+=1
    if A[i]-2>=0:
        ans[A[i]-2]+=1
    if A[i]<=N-1:
        ans[A[i]]+=1

print(max(ans))

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int AB, BC, CA;
    cin >> AB >> BC >> CA;
    double res = (double)AB*BC/2;

    cout << setprecision(20) << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long n, a, b, min_value = LLONG_MAX;
    
    cin >> n >> a >> b;
    min_value = b;
    min_value = min(min_value, n * a);
    
    cout << min_value << endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}


void init()
{
}

void solve()
{
	int N, K;
	cin >> N >> K;
	for (int i = 1; i <= N; i+=2) {
		K--;
	}
	PRINT(K <= 0);
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		String a="";
		for(int i=0; i<W+2; i++) {
			a=a+"#";
		}
		System.out.println(a);
		for(int i=0; i<H; i++) {
			a="";
			a="#"+sc.next()+"#";
			System.out.println(a);
		}
		a="";
		for(int i=0; i<W+2; i++) {
			a=a+"#";
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 22868
fn main() {
    proconio::input! {
        x: i64,
    }
    for a in -1000..1000 {
        for b in -1000..1000 {
            if (a as i64).pow(5) - (b as i64).pow(5) == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  ll v[n/2],u[n/2];
  for(ll i=0;i<n/2;i++)cin >> v[i] >> u[i];
  vec a(100001),b(100001);
  vec c,d;
  for(ll i=0;i<n/2;i++){
    a[v[i]]++;
    b[u[i]]++;
  }
  ll p=0,q=0;
  for(ll i=0;i<100001;i++){
    p=max(p,a[i]);
    q=max(q,b[i]);
  }

  for(ll i=0;i<100001;i++){
    if(p==a[i])c.push_back(i);
    if(q==b[i])d.push_back(i);
  }

  if(c.size()==1 && d.size()==1 && c[0]==d[0]){
    ll s=0,t=0;
    for(ll i=0;i<100001;i++){
      if(i!=c[0])s=max(s,a[i]);
      if(i!=d[0])t=max(t,b[i]);
    }
    ll ans=min(n-q-s,n-t-p);
    cout << ans << endl;
  }
  else{
    cout << n-p-q << endl;
  }

}

Measured memory_bytes: 6472
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
    // clang-format on

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, 0, n) {
        cin >> a[i];
    }

    auto dp = make_v(n, n, 2, -1LL);
    function<ll(int, int, int)> rec = [&](int l, int r, int turn) -> ll {
        if (dp[l][r][turn] != -1) return dp[l][r][turn];
        if (l == r) return 0;
        ll ans = 0;
        int rr = (r - 1 + 2 * n) % n;
        if (turn) {
            if (a[l] < a[rr]) {
                ans = rec(l, rr, !turn);
            } else {
                ans = rec((l + 1) % n, r, !turn);
            }
        } else {
            ans = max(ans, rec(l, rr, !turn) + a[rr]);
            ans = max(ans, rec((l + 1) % n, r, !turn) + a[l]);
        }
        return dp[l][r][turn] = ans;
    };

    ll ans = 0;
    REP(i, 0, n) {
        ans = max(ans, rec((i + 1) % n, i, 1) + a[i]);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 222264
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <cstdint>


using namespace std;

int main() {
	int64_t k,a,b;
	cin>>k>>a>>b;
	if((b-a)>2){
		if(k<=(a-1)){
			cout<<1+k<<endl;
		}else{
			k=k-(a-1);
			int64_t sum = a;
			int64_t kaisu = k/2;
			sum = sum + kaisu * (b-a);
			if(k%2==1){
				sum += 1;
			}
			cout<<sum<<endl;
		}

	}else{
		cout<<1+k<<endl;
	}
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll s,w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe";
	else cout<<"safe";
	
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
void solve(int f);

vector<int> a,b,c,d;
long long sum;
int e[11];
int n,m,q;

int main(){
	// sengen
	sum = 0;
	// nyuryoku
	cin >> n >> m >> q;
	a.assign(q,0); b.assign(q,0);
	c.assign(q,0); d.assign(q,0);
	for(int i=0;i<q;i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	// keisan
	solve(1);
	cout << sum;
	// syutsuryoku
}


void solve(int f){
	if(f == 1){
		for(int i=1;i<=m;i++){
			e[f] = i;
			solve(f+1);
		}
	}
	if(f>1 && f<10){
		for(int i=e[f-1];i<=m;i++){
			e[f] = i;
			solve(f+1);
		}
	}
	if(f==10){
		for(int i=e[f-1];i<=m;i++){
			e[f] = i;
			long long ksum = 0;
			for(int j=0;j<q;j++){
				if(e[b[j]] - e[a[j]] == c[j]){
					ksum += d[j];
				}
			}
			sum = max(sum,ksum);
		}
	}
}

Measured memory_bytes: 3644
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

char C;

signed main(){
    cin >> C;
    if('a' <= C && C <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int> edge[200010];
int num[200010];
int ans[200010];

void dfs(int from, int par, int now) {
	now+=num[from];
	ans[from]=now;
	for(int to:edge[from]){
		if(to==par) continue;
		dfs(to, from, now);
	}
}
int main() {
	int n; cin>>n;
	int q; cin>>q;
	for(int i=0;i<n-1;++i){
		int a, b; cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	while(q--){
		int p; cin >> p;
		p--;
		int x; cin >> x;
		num[p]+=x;
	}
	dfs(0, -1, 0);
	rep(i,n) {
		cout<<ans[i]<<(i==n-1?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 24064
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int solve(int **a,int **dp,int n,int x,int mask){
    if(x==n+1){
        if(mask==0){
            return 1;
        }
        else{
            return 0;
        }
    }
    if(dp[x][mask]!=-1){
        return dp[x][mask];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if( ((1<<i)&mask)!=0 && a[x][i+1]==1){
            ans=(ans+solve(a,dp,n,x+1,mask^(1<<i)))%mod;
        }
    }
    return dp[x][mask]=ans;
}
int32_t main(){
    int n;
    cin>>n;
    int **a=new int*[n+1];
    int **dp=new int*[n+1];
    for(int i=0;i<=n;i++){
        a[i]=new int[n+1];
        dp[i]=new int[(1<<(n+1))];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    int mask=(1<<n)-1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<(1<<(n+1));j++){
            dp[i][j]=-1;
        }
    }
    cout<<solve(a,dp,n,1,mask)<<endl;
    return 0;
}

Measured memory_bytes: 688512
N = int(input())
List = list(map(int, input().split()))
S2 = 0
for i in range(N):
  S2 += List[i]
S1 =0 
res = S2
for i in range(N):
  S1 += List[i]
  S2 = S2 - List[i]
  res = min(abs(S2-S1),res)
print(res)

Measured memory_bytes: 9116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int n; cin>>n;
    string s1,s2; cin>>s1>>s2;
    int i=0, j=0;
    int board[53]={};
    while(i<n){
        if(s1[i]==s2[i]){
            board[j]=1;
            i++; j++;
        }else{
            board[j]=2;
            i+=2; j++;
        }
    }
    long int ans=3*board[0];
    FOR(k,0,j){
        int k1=board[k],k2=board[k+1];
        if(k1==1 && k2==1) ans=(2*ans)%MOD;
        if(k1==1 && k2==2) ans=(2*ans)%MOD;
        if(k1==2 && k2==2) ans=(3*ans)%MOD;
    }
    cout<<ans;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(void){
	ll x; cin>>x;

	ll cnt = 0;
	cnt = (x / 11 * 2) + (x % 11 + 5)/6;

	printf("%lld\n", cnt);
	

	return 0;
}

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

int main() {
    int S;
    cin >> S ;
    int a,b;
    a=S/100;
    b=S-a*100;

    if(a>=1 && a<=12){
        a=0;
    }else{
        a=1;
    }
    if(b>=1 && b<=12){
        b=0;
    }else{
        b=1;
    }
    
    if(a==0 && b==1){
        cout << "MMYY" <<endl;

    }else if(b==0 && a==1){
        cout << "YYMM" <<endl;
    }else if(a == 0 && b == 0){
        cout << "AMBIGUOUS" <<endl;
    }else{
        cout << "NA" <<endl;
    }


    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k, s; long long answer=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++){
        for(int j=0; j<=k; j++){
            if(s-i-j>=0&&s-i-j<=k) answer++;
        }
    }
    cout<<answer;
    return 0;
}

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

using namespace std;
typedef long long ll;

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

    vector<ll> v(N + 10);
    for (int i = 1; i <= N; i++) {
        cin >> v[i];
    }

    vector<ll> dp_fl(N + 10, 0);
    vector<ll> dp_ce(N + 10, 0);
    dp_fl[1] = 0;
    dp_ce[1] = v[1];
    dp_fl[2] = dp_ce[2] = max(v[1], v[2]);
    ll sum_of_odds = v[1];
    for (int i = 3; i <= N; i++) {
        if (i % 2 == 1) sum_of_odds += v[i];
        dp_fl[i] = max(dp_ce[i - 1], dp_fl[i - 2] + v[i]);
        dp_ce[i] = (i % 2 == 1) ? sum_of_odds : dp_fl[i];
    }
    cout << dp_fl[N] << endl;


    return 0;
}


Measured memory_bytes: 7576
// O(N^2 * logN)
 
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
const int MAXN = 1004;
 
struct Seg {
  int begin, end;
 
  Seg() {}
  Seg(int begin, int end)
    : begin(begin), end(end) {}
 
  bool operator < (const Seg &s) const {
    if(begin != s.begin) return begin > s.begin;
    return end < s.end;
  }
};
 
int main() {
  int N;
  int A[MAXN], B[MAXN];
 
  while(cin >> N) {
    for(int i = 0; i < N; ++i) {
      cin >> A[i] >> B[i];
    }
 
    vector<Seg> v;
    for(int i = 0; i < N; ++i) {
      v.push_back(Seg(B[i]-A[i], B[i]));
    }
    sort(v.begin(), v.end());
    int res = 0;
    for(int i = 0; i < v.size(); ++i) {
      if(v[i].begin < 0) continue;
      ++res;
      for(int j = i+1; j < v.size(); ++j) {
        int diff = min( max(v[j].end - v[i].begin, 0),
                           v[i].end - v[i].begin );
        v[j].begin -= diff;
        v[j].end -= diff;
      }
      sort(v.begin(), v.end());
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1208
N = int(input())
A = map(int, input().split())

S = [0]

for a in A:
    S.append(S[len(S) - 1] + a)

S = sorted(S) + [None]
ret = 0
cnt = 1
for i in range(1, N + 2):
    if S[i] != S[i - 1]:
        ret += cnt * (cnt - 1) // 2
        cnt = 1
    else:
        cnt += 1

print(ret)


Measured memory_bytes: 26500
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,d;
cin>>n>>d;
int x[15][15];
for(int i = 0; i<n; i++){
    for(int j = 0; j<d; j++){
        cin>>x[i][j];
    }
}

int count = 0;
for(int i = 0; i<n; i++){
    for(int j = i+1; j<n; j++){
        int sum = 0;
        for(int k = 0; k<d; k++){
            int ans = abs(x[i][k]-x[j][k]);
            sum += ans*ans;
        }
    

int a = sqrt(sum);
    for(int k = 0; k<=a; k++){
        if(k*k==sum){
            count++;
        }
    }
        
    }
}
    cout<<count<<endl;
    return 0;
}
    
    
    
    
    


Measured memory_bytes: 256
import numpy as np
H,W=map(int, input().split())

S=[]
for h in range(H):
    s=list(input())
    S.append(s)

S=np.array(S)

d=[(1,0),(0,-1),(-1,0),(0,1)]
for h in range(H):
    for w in range(W):
        now=S[h,w]
        if now=="#":
            count=0
            for t in d:
                dx,dy=t
                nx=h+dx
                ny=w+dy
                if 0<=nx<H and 0<=ny<W:
                    if S[nx,ny]=="#":
                        count+=1
            if count==0:
                print("No")
                exit()
print("Yes")


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

int main() {
  string S;
  int cnt=0;
  cin >> S;
  for(int i=0;i<S.size()/2;i++){
    if(S.at(i)!=S.at(S.size()-i-1)){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int n,m;
int f[100][100];
int g[50][50];

void turn(void){
	int tmp[m][m];

	for(int i=0;i<m;i++) for(int j=0;j<m;j++) tmp[i][j] = g[i][j];
	for(int i=0;i<m;i++) for(int j=0;j<m;j++) g[i][j] = tmp[m-j-1][i];
}

bool equal(int x,int y){
	for(int i=y;i<y+m;i++){
		for(int j=x;j<x+m;j++){
			if(g[i-y][j-x]!=-1 && f[i][j] != g[i-y][j-x]) return false;
		}
	}
	return true;
}

int main(void){
	while(cin>>n>>m && (n||m)){
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>f[i][j];
		for(int i=0;i<m;i++) for(int j=0;j<m;j++) cin>>g[i][j];

		bool flg = true;
		int ansX = -1, ansY = -1;

		for(int i=0;flg && i<=n-m;i++){
			for(int j=0;flg && j<=n-m;j++){
				for(int k=0;flg && k<4;k++){
					if(equal(j,i)){
						flg = false;
						for(ansX=0;g[0][ansX]==-1;ansX++);
						ansX += j+1;
						ansY = i+1;
						break;
					}
					turn();
				}
			}
		}

		if(flg) cout<<"NA\n";
		else cout<<ansX<<" "<<ansY<<endl;
	}

	return 0;
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int32_t main() {
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k&1)
		cout<<b-a;
	else cout<<a-b;
}
						

Measured memory_bytes: 256