akhauriyash/Code-Regression huggingface dataset:
import sys


from inspect import currentframe


def pri(*args):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    # print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))


def solve(m, n_min, n_max, P):
    ans = n_min
    pri(P)
    gap = P[n_min - 1] - P[n_min]
    pri(gap)

    for i in range(n_min - 1, n_max):
        if gap <= P[i] - P[i+1]:
            gap = P[i] - P[i+1]
            ans = i + 1
            pri(ans)
            pri(gap)
    print(ans)

    return


if __name__ == '__main__':
    while True:
        m_input, n_min_input, n_max_input = map(int, input().split())
        if m_input == n_min_input == n_max_input == 0:
            break
        P_imput = [int(input()) for _ in range(m_input)]

        solve(m_input, n_min_input, n_max_input, P_imput)




Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l,r,d,count=0;
  cin >> l >> r >> d;
  while (r>=l) {
    if(r%d == 0)
    {
      count++;
    }
    r--;
  }
  cout << count << endl;
  return 0;
}


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


def f(N, S, st):
    R = [0]*(N)

    Q = set([st])
    R[st] = 1
    idx = 1
    cnt = 0

    while(len(Q) > 0):
        Q2 = set()
        cnt += 1
        idx += 1
        
        for i in Q:
            for j, s in enumerate(S[i]):
                if s == '1':
                    if R[j] == idx - 1:
                        return -1
                    elif R[j] == 0:
                        R[j] = idx
                        Q2.add(j)
                    
        Q = Q2
        
    return cnt
        


def g(N, S):
    m = 0

    for i in range(N):
        k = f(N, S, i)
        if k == -1:
            return -1

        m = max(m, k)

    return m



def main():
    N = int(input())
    S = list(input() for _ in range(N))

    print(g(N, S))





if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
S=set(list(input()))
l=['a','b','c','d','e','f','g','h','i','j',\
   'k','l','m','n','o','p','q','r','s','t',\
   'u','v','w','x','y','z']

if len(S)==26:
    print('None')
else:
    for i in range(26):
        if l[i] not in S:
            print(l[i])
            break

Measured memory_bytes: 3956
n = int(input())
A, B, C = [], [], []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append([a + b, i])
C = sorted(C, reverse=True)

suma, sumb = 0, 0
for i in range(n):
    if i % 2:
        sumb += B[C[i][1]]
    else:
        suma += A[C[i][1]]
print(suma - sumb)

Measured memory_bytes: 30272
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int dp[100005][2];
vi Tree[100005];

int compute(int n, bool c, int p){
    if(dp[n][c] != -1)  return dp[n][c];

    int ans = 0, w1 = 1;
    for(int child : Tree[n]){
        if(child != p)
            w1 = (w1 * compute(child, 0, n))%mod;
    }
    ans += w1;
    if(!c){
        int w2 = 1;
        for(int child : Tree[n]){
            if(child != p)
                w2 = (w2 * compute(child, 1, n))%mod;
        }
        ans = (ans + w2)%mod;
    }

    return dp[n][c] = ans;
}

void solve(){
    int n, x, y;  cin>>n;
    forI(i, 1, n-1){
        cin>>x>>y;
        Tree[x].pb(y);
        Tree[y].pb(x);
    }
    memset(dp, -1, sizeof dp);
    cout<<compute(1, 0, -1)<<endl;
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 17576
def main():
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    #print(A_list)
    A_list.sort()
    #print(A_list)
    ans = 1
    for a in A_list :
        ans = ans * a
        if ans == 0 :
            break
        elif ans > 10 ** 18 :
            ans = -1
            break

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21796
#include <iostream>

using namespace std;

int main() {
    char b;
    cin >> b;

    switch(b){
        case 'A':
            cout << 'T' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
    }
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int x;  cin >> x;
    cout << x+x*x+x*x*x <<endl;

    return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n = int(sys.stdin.readline())
r = list()
for i in range(n):
    r.append(int(sys.stdin.readline()))

max_diff = min(r) - max(r)
max_v = r[0]

for i in range(n-1):
    if r[i] == max_v:
        max_v = max(r[i+1:])
    diff = max_v - r[i]
    if diff > max_diff:
        max_diff = diff

print(max_diff)




Measured memory_bytes: 15088
#include <iostream>
using namespace std;
int main()
{
    int numa, numb, numc;
    int ans = 0;

    cin >> numa;
    ans ++;

    cin >> numb;
    if(numb!=numa){
        ans ++;
    }
    cin >> numc;
    if((numc!=numa)&&(numc!=numb)){
        ans ++;
    }

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

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

using namespace std;

int main(){
	string str,tar;
	cin >> str >> tar;
	bool flag=false;
	for(int i=0;i<str.length();i++){
		if(str[i]==tar[0]){
			flag=true;
			for(int j=0;j<tar.length();j++){
				int pos=(i+j)%str.length();
				if(str[pos]!=tar[j]){
					flag=false;
					break;
				}
			}
			if(flag)break;
		}
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3164
// Problem Statement
// Given is a positive integer N
// Find the number of pairs
// (A,B) of positive integers not greater than N hat satisfy the following condition:
// When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of
// A is equal to the last digit of B.

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    int health, n;
    cin >> health >> n;
    vector<pair<int, int>> vect(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vect[i].ff >> vect[i].ss;
    }
    vector<int> dp(health + 1, INT_MAX);

    dp[0] = 0;
    for (int h = 0; h <= health; h++)
    {
        for (int i = 0; i < n; i++)
        {
            int x = max(0, h - vect[i].ff);
            dp[h] = min(dp[h], (dp[x] + vect[i].ss));
        }
    }
    cout << dp[health];
}


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(void){
    int n;
    double money=0.0;
    cin>>n;
    for(int i=0;i<n;i++){
        double x;
        string s;
        cin>>x>>s;
        if(s=="JPY") money+=x;
        else money += x*380000.0;
    }
    cout << money <<endl;
}


Measured memory_bytes: 256
S = input()
a = [0 for i in range(len(S)+1)]
for i, x in enumerate(S):
    if x == '<':
        a[i+1] = max(a[i+1], a[i]+1)
for i in range(len(S)):
    if S[-i-1] == '>':
        a[-i-2] = max(a[-i-2], a[-i-1]+1)
print(sum(a)) 

Measured memory_bytes: 24132
using System;

class Program {
    static void Main(string[] args) {

        string N = Console.ReadLine();
        string[] d = Console.ReadLine().Split(' ');

        int result = 0;

        for(int a = 0; a < d.Length; a++) {
            for(int b = a+1; b < d.Length; b++) {
                result += int.Parse(d[a]) * int.Parse(d[b]);
            }
        }
        
        Console.WriteLine(result);
    }
}



Measured memory_bytes: 13140
def dfs(now,vis,G):
    if sum(vis) == len(vis):
        return 1

    ret = 0
    for nx in G[now]:
        if vis[nx] == 0:
            nvis = vis[:]
            nvis[nx] = 1
            ret += dfs(nx,nvis,G)

    return ret

def main():
    n,m = map(int,input().split())

    G = [[] for _ in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    vis = [0 for _ in range(n)]
    vis[0]=1
    return dfs(0,vis,G)

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
while 1:
    n=int(input())
    if n==0: break
    a=[0]*10
    while n:
        n-=1
        a[int(input())]+=1
    for i in range (10):
        for j in range(a[i]):
            
            print('*',end="")
        if a[i]==0:
            print('-',end="")
        print()

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
typedef unsigned long long int ull;
typedef long double ldb;
#define B 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repi(i,a,b) for(ll i=b-1;i>=a;i--)
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long int>
#define pb push_back
#define mp make_pair
#define INF 1e18
#define deci(n) fixed << setprecision(n)
#define PI 3.141592653589793238462643
#define ani ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

void pairsort(ll a[], ll b[], ll n) 
{ 
    pair<ll, ll> pairt[n]; 
  
 
    for (ll i = 0; i < n; i++)  
    { 
        pairt[i].first = a[i]; 
        pairt[i].second = b[i]; 
    } 
  
    sort(pairt, pairt + n); 
      
    for (ll i = 0; i < n; i++)  
    { 
        a[i] = pairt[i].first; 
        b[i] = pairt[i].second; 
    } 
}
 
ll extendedGcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = extendedGcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}


  ll binaryToDecimal(string n) 
{ 
    string num = n; 
    ll dec_value = 0; 
    // Initializing base value to 1, i.e 2^0 
    ll base = 1;  
    ll len = num.length(); 
    for (ll i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
    return dec_value; 
} 


ll nCr(ll n,ll k){ 
    ll C[n + 1][k + 1]; 
    ll i, j; 
    for (i=0;i<=n;i++){ 
        for(j=0;j<=min(i,k);j++){
            if(j==0||j==i) 
                C[i][j]=1;  
            else
                C[i][j]=(C[i-1][j-1]%B+C[i-1][j]%B)%B; 
        } 
    }
    return C[n][k]%B; 
} 


ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
}

ll highestPowerof2(ll n) 
{ 
   ll p = (ll)log2(n); 
    return (ll)pow(2, p);  
} 
bool isPowerOfTwo(int x)
    {   // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
        return (x && !(x & (x - 1)));
    }

void dfs(int p,vector<int> a[],int v[])
{
    if(v[p])
        return ;
    v[p]=1;
    for(int i=0;i<a[p].size();i++)
    {
        if(!v[a[p][i]])
        dfs(a[p][i],a,v);
    }
} 
ll max(ll a, ll b){
  if (a > b)
    return a;
  return b;
}
ll min(ll a, ll b){
  if (a < b)
    return a;
  return b;
}

int main()
{ 
ani;

int t=1;
 // cin>>t;
while(t--)
{
ll n,k;
    cin>>n>>k;
ll h[n];
    rep(i,0,n)
    cin>>h[i];

    ll dp[n];
    rep(i,0,n)
    dp[i]=INF;

    dp[0]=0;
    for(int i=1;i<n;i++)
        for(int j=1;j<=k;j++)
                if(i-j>=0)
                    dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

    cout<<dp[n-1];















}

return 0;
}

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

using namespace std;

int main()
{
    string s,t;
    int c=0,i;
    cin>>s;
    cin>>t;
    for(i=0;i<3;i++)
    {
       if(s[i]==t[i])
       {
          c++;
       }
       else c=c;
    }

    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
 
using namespace std;
const int N=1e7+1, mod= 998244353;
ll fact[N],ifact[N];

ll power(int a,int n){
	if(n==0) return 1;
	ll x=power(a,n/2);
	x=(x*x)%mod;
	if(n&1) return (x*a)%mod;
	return x;
}

ll comb(int n,int r){
	return  ( fact[n]*( ( ifact[r]*ifact[n-r] )%mod)  )%mod;
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	
	int n;
	cin>>n;
		
	fact[0]=1;
	for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%mod;
	ifact[n]=power(fact[n],mod-2);
	for(int i=n-1;i>=0;i--){
		ifact[i]=(ifact[i+1]*(i+1))%mod;
	}
	
	ll r1=0;
	for(int i=n/2+1;i<=n;i++){
		r1+=( comb(n,i)*power(2,n-i) )%mod;
		if(r1>=mod)r1-=mod;
	}
	
	
	cout<<( power(3,n) -r1*2 + mod*2 )%mod;
	
    yogeshk972();
}


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

const int INF = 1e9;

int main() {
  int h, w;
  cin>>h>>w;
  int m[h][w];
  queue<pair<int, int> > q;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      char c;
      cin>>c;
      if (c == '#') {
        m[i][j] = 0;
        q.push(make_pair(i, j));
      } else {
        m[i][j] = -1;
      }
    }
  }
  while (!q.empty()) {
    auto a = q.front();
    q.pop();

    int i = a.first;
    int j = a.second;
    if (i > 0 && m[i-1][j] == -1) {
      m[i-1][j] = m[i][j] + 1;
      q.push(make_pair(i-1, j));
    }
    if (i < h-1 && m[i+1][j] == -1) {
      m[i+1][j] = m[i][j] + 1;
      q.push(make_pair(i+1, j));
    }
    if (j > 0 && m[i][j-1] == -1) {
      m[i][j-1] = m[i][j] + 1;
      q.push(make_pair(i, j-1));
    }
    if (j < w-1 && m[i][j+1] == -1) {
      m[i][j+1] = m[i][j] + 1;
      q.push(make_pair(i, j+1));
    }
  }
  int ans = 0;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      ans = max(ans, m[i][j]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12304
sentence = input()

sentence_1 = sentence[0:int(((len(sentence)-1)/2))]
sentence_2 = sentence[int(((len(sentence)+3)/2)-1): ]
ans = "Yes"

def kaibun(S):
    count = 0
    for i in range(0,int(len(S)/2)):
        if S[i] == S[-i-1]:
            count += 1
    if int(count) != int(len(S)/2):
        global ans
        ans = "No"

kaibun(sentence)
kaibun(sentence_1)
kaibun(sentence_2)

print(ans)


Measured memory_bytes: 3064
function main(input) {
  const args = input.split("\n");
  const [N, K] = args[0].split(" ").map((n) => parseInt(n, 10));
  const sunukes = new Array(N).fill(false);

  for (let i = 2; i <= K * 2; i += 2) {
    args[i].split(" ").map((n) => parseInt(n, 10))
      .map((A) => { sunukes[A - 1] = true; });
  }

  console.log(sunukes.reduce((num, sunuke) => (sunuke ? num : num + 1), 0));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32096
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, W;
  cin >> N >> W;
  vector<int64_t> weight(N + 1);
  vector<int64_t> value(N + 1);
  int64_t total_value = 0;
  for (int64_t i = 1; i <= N; ++i) {
    cin >> weight[i] >> value[i];
    total_value += value[i];
  }
  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t result = 0;
  vector<vector<int64_t>> minimum_weight(N + 1, vector<int64_t>(total_value + 1, kInf));
  for (auto &a : minimum_weight) {
    a[0] = 0;
  }
  for (int64_t i = 1; i <= N; ++i) {
    for (int64_t v = 0; v <= total_value; ++v) {
      minimum_weight[i][v] = minimum_weight[i - 1][v];
      const int64_t prev_value = v - value[i];
      if (prev_value >= 0) {
        minimum_weight[i][v] = min(minimum_weight[i][v], minimum_weight[i - 1][prev_value] + weight[i]);
      }
      if (minimum_weight[i][v] <= W) {
        result = max(v, result);
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 83120
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X = int(input())
n500 = X // 500
X -= n500 * 500
n5 = X // 5
print(n500 * 1000 + n5 * 5)





Measured memory_bytes: 6988
#include<bits/stdc++.h>
using namespace std;
long long sort(int a[],int n)
{
    if(n==1)return 0;
    long long sum=0;
    int mid=n/2;
    sum+=sort(a,mid);
    sum+=sort(a+mid,n-mid);
    int *b=new int[n];
    memcpy(b,a,n*sizeof(int));
    for(int i1=0,i2=mid,i=0;i1<mid||i2<n;++i)
        if(i2==n)
            a[i]=b[i1++],sum+=i2-mid;
        else if(i1==mid)
            a[i]=b[i2++];
        else if(b[i1]<b[i2])
            a[i]=b[i1++],sum+=i2-mid;
        else
            a[i]=b[i2++];
    delete [] b;
    return sum;
}
long long inversed_pair(int a[],int n)
{
    long long ans=sort(a,n);
    for(long long i=0;i<n;++i)
    {
        long long j=i;
        while(a[j]==a[j+1])
            j++;
        ans-=(j-i+1)*(j-i)/2;
        i=j;
    }
    return ans;
}
int arr[222222];
int main()
{
    string s;
    cin>>s;
    memset(arr,-1,sizeof arr);
    int n = s.size();
    for(int i=0;i<n;++i) {
        if(s[i] == 'W')
            arr[i] = 0;
        else
            arr[i] = 1;
    }
    cout<<inversed_pair(arr,n)<<endl;
}

Measured memory_bytes: 2488
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
using VI  = vector<int>;
using PII = pair<int, int>;
using VP  = vector<PII>;
using VVP = vector<VP>;
VI color;
VVP g;
int n, cmax;
inline void DFS(int x, int w) {
    int temp(1), y, i;
    for (const PII& P : g[x]) {
        tie(y, i) = P;
        if (!color[i]) {
            color[i] = (temp += temp == w);
            DFS(y, temp++);
        }
    }
}
int x, y;
int main() {
    DAU
    cin >> n;
    g.resize(n + 1);
    for (int i = 1; i < n; ++i) {
        cin >> x >> y;
        g[x].emplace_back(y, i);
        g[y].emplace_back(x, i);
    }
    for (int i = 1; i <= n; ++i)
        cmax = max(cmax, static_cast<int>(g[i].size()));
    color.resize(n);
    DFS(1, n);
    cout << cmax << '\n';
    for (int i = 1; i < n; ++i)
        cout << color[i] << '\n';
    PLEC
}


Measured memory_bytes: 9772
N = int(input())
S = list(input())
L = 0
R = S.count('E')
ans = L + R
for i in range(0, N):
    if S[i] == 'E':
        R -= 1
        R = max(0, R)
        ans = min(ans, L+R)
    else:
        L += 1
print(ans)

Measured memory_bytes: 5796
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 300005

int X;

bool dfs(int k, int s) {
    if(k == 6) {
        return s == X;
    }
    REP(i, 0, X + 1, 100 + k) {
        if(dfs(k + 1, s + i)) {
            return true;
        }
    }
    return false;
}

int main()
{
    read(X);
    if(X >= 20000) {
        print(1);
        return 0;
    }
    if(dfs(0, 0)) {
        print(1);
    } else {
        print(0);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(cin>>n && n>0){
		vvi d(n,vi(n,0)),f(n,vi(n,0));
		rep(i,0,n) rep(j,0,n) cin>>d[i][j];
		int a=0,b=0;
		rep(i,0,n){
			a=b=0;
			rep(j,0,n){
				if(d[i][a]>d[i][j]) a=j;
				if(d[b][i]<d[j][i]) b=j;
			}
			rep(j,0,n){
				if(d[i][j]==d[i][a]) f[i][j]++;
				if(d[j][i]==d[b][i]) f[j][i]++;
			}
		}
		int ans=0;
		rep(i,0,n){
			rep(j,0,n){
				if(f[i][j]==2){
					ans=d[i][j];
				}
			}
		}
		o(ans);
	}
}

Measured memory_bytes: 1212
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	x := float64(n) / 1.08
	ans := math.Ceil(x)

	if int(ans*1.08) != n {
		fmt.Println(":(")
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 512
N, L = map(int,input().split())
A = []
for k in range(N):
    A.append(k+L)

if 0 in A:
    print(sum(A))
else:
    if abs(A[0]) < abs(A[-1]):
        print(sum(A)-A[0])
    else:
        print(sum(A)-A[-1])


Measured memory_bytes: 3060
#include<iostream>

int main(){
  int arr[3][3];
  for(int i=0; i<3; ++i)
    for(int j=0; j<3; ++j)
      std::cin>>arr[i][j];

  int n;
  std::cin>>n;
  int nrr[n];
  for(int i=0; i<n; ++i)
    std::cin>>nrr[i];

  for(int i=0; i<n; ++i){
    for(int j=0; j<3; ++j){
      for(int k=0; k<3; ++k){
        if(nrr[i] == arr[j][k])
          arr[j][k] = 0;
      }
    }
  }

  bool flag=false;
  if(arr[1][1] == 0){
    if((arr[0][0]==0 && arr[2][2]==0) || (arr[0][1]==0 && arr[2][1]==0) || (arr[2][0]==0 && arr[0][2]==0) || (arr[1][0]==0 && arr[1][2]==0)){
      flag=true;
      std::cout<<"Yes\n";
    }
  }
  else if(arr[0][0]==0){
    if((arr[1][0]==0 && arr[2][0]==0) || (arr[0][1]==0 && arr[0][2]==0)){
      flag=true;
      std::cout<<"Yes\n";
    }
  }
  else if(arr[2][2]==0){
    if((arr[2][0]==0 && arr[2][1]==0) || (arr[1][2]==0 && arr[0][2]==0)){
      flag=true;
      std::cout<<"Yes\n";
    }
  }

  if(!flag)
    std::cout<<"No\n";

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if (c % 2 == 1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << c / 2 << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    char ara[a+2][b+2];
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++) cin>>ara[i][j];

    /*for(int i=0;i<=a+2;i++) ara[i][0]=0;
    for(int j=0;j<=b+2;j++) ara[0][j]=0;
    for(int i=0;i<=b+2;i++)ara[a+2][i]=0;
    for(int i=0;i<=a+2;i++) ara[i][b+2]=0; */

    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            c=0;
            if(ara[i][j]=='#') continue;
            else
            {

                if(ara[i-1][j-1]=='#' && (i-1>=0 && j-1>=0) && (i-1<a && j-1<b)) c++;
                if(ara[i-1][j]=='#'  && (i-1>=0 && j>=0) && (i-1<a && j<b))c++;
                if(ara[i-1][j+1]=='#'  && (i-1>=0 && j+1>=0) && (i-1<a && j+1<b)) c++;
                if(ara[i][j-1]=='#' && (i>=0 && j-1>=0) && (i<a && j-1<b))c++;
                if(ara[i][j+1]=='#' && (i>=0 && j+1>=0) && (i<a && j+1<b))c++;
                if(ara[i+1][j-1]=='#'  && (i+1>=0 && j-1>=0) && (i+1<a && j-1<b))c++;
                if(ara[i+1][j]=='#' && (i+1>=0 && j>=0) && (i+1<a && j<b))c++;
                if(ara[i+1][j+1]=='#' && (i+1>=0 && j+1>=0) && (i+1<a && j+1<b))c++;
            }
            ara[i][j]=c+48;
        }
        c=0;
    }
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++) cout<<ara[i][j];
        cout<<endl;
    }


    return 0;
}



Measured memory_bytes: 256
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

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

	ll arr[n+1];
	arr[0]=0;
	ll a;
	map<ll,ll> ma;
	map<ll,ll>::iterator it;
	ma[0]=1;

	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>a;
		arr[i]=(((arr[i-1]+a)%m)+m)%m;
		it = ma.find(arr[i]);
		if(it!=ma.end())
		{
			ans+=(it->second);
			(it->second)++;
		}
		else
		{
			ma[arr[i]]=1;
		}
	}
	// for(ll i=1;i<=n;i++)
	// {
	// 	cout<<arr[i]<<" ";
	// }
	cout<<ans;

	return 0;
}

Measured memory_bytes: 4992
// A - 9x9
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
		cout << a * b << endl;
	else
		cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 16;
const int INFINI = -1e18;
int tab[MAXN][MAXN];

int meilleur[(1<<MAXN)];
int N;

vector <int> creer;

void trouverEnsembles(int in , int tot , int actu)
{
	if (in == N)
	{
		creer.push_back(actu);
		return;
	}
	trouverEnsembles(in + 1 , tot , actu);
	if (tot & (1<<in))
		trouverEnsembles(in + 1 , tot , actu | (1<<in));
}
int recursion(int ensemble)
{
	if (meilleur[ensemble] != INFINI) return meilleur[ensemble];
	if (ensemble == 0) return 0;
	meilleur[ensemble] = 0;
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = i + 1 ; j < N ; j++)
		{
			if ((ensemble & (1<<i)) && (ensemble & (1<<j)))
			{
				meilleur[ensemble] += tab[i][j];
			}
		}
	}
	creer.clear();
	trouverEnsembles(0 , ensemble , 0);
	vector <int> actu;
	for (int i = 0 ; i < creer.size() ; i++)
	{
		actu.push_back(creer[i]);
	}
	for (int i = 0 ; i < actu.size() ; i++)
	{
		meilleur[ensemble] = max(meilleur[ensemble] , recursion(actu[i]) + recursion(ensemble ^ actu[i]));
	}
	return meilleur[ensemble];


}

int32_t main()
{
	cin >> N;
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < N ; j++)
		{
			cin >> tab[i][j];
		}
	}
	for (int i = 0 ; i < (1<<N) ; i++)
	{
		meilleur[i] = INFINI;
	}
	cout<<recursion((1<<N) - 1)<<endl;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll d;
vector<vl> s;
vl c(26);
vector<set<ll>> st(26, {-1});
ll score;

void add(ll i, ll k) {  // i日目(0-index)、テストk（0-index）
  st[k].insert(i);
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score += c[k] * (i - prev) * (next - i) + s[i][k];
}

void rm(ll i, ll k) {
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score -= c[k] * (i - prev) * (next - i) + s[i][k];
  st[k].erase(i);
}

void eval(vl &t) {
  rep(i, d) {
    ll k = t[i];
    add(i, k);
  }
}

int main() {
  double limit = double(clock()) / double(CLOCKS_PER_SEC) + 1.95;
  // 入力をもらう
  cin >> d;
  rep(i, 26) cin >> c[i];
  s.resize(d, vl(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];

  //// 入力を作るデバッグ用
  // d = 365;
  // s.resize(d, vl(26));
  // rep(i, 26) c[i] = rand() % 101;
  // rep(i, d) rep(j, 26) s[i][j] = rand() % 20001;

  // 初期解をランダムに作って評価、scoreに反映
  score = -accumulate(all(c), 0LL) * d * (d + 1) / 2;
  vl t(d);
  rep(i, d) t[i] = max_element(all(s[i])) - s[i].begin();
  eval(t);

  while(double(clock()) / double(CLOCKS_PER_SEC) < limit) {
    ll xd = rand() % d;
    ll xd2 = rand() % d;
    if(xd > xd2) xd = xd2;
    ll xt = rand() % 26;
    ll xt2 = rand() % 26;
    if(c[xt] < c[xt2]) xt = xt2;
    ll old_score = score;
    ll old_test = t[xd];
    if(xt == t[xd]) xt = (xt + 1) % 26;
    rm(xd, t[xd]);
    add(xd, xt);
    if(score < old_score) {
      rm(xd, xt);
      add(xd, old_test);
    } else
      t[xd] = xt;
  }
  rep(i, d) cout << t[i] + 1 << '\n';
}

Measured memory_bytes: 3720
N = int(input())
A  =list([int(input()) for i in range(N)])
A = sorted(A, reverse=True)

count = 0
for i in range(N):
  if i==0:
    count += 1
  elif A[i] != A[i-1]:
    count += 1
  else:
    count += 0
 
print(count)

Measured memory_bytes: 3064
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

	cout << (N + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    ll h,n,p;
    cin >> h >> n;
    ll sum = 0;
    rep(i,n){
        cin >> p;
        sum += p;
    }
    if(sum < h) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#!python
# -*- coding: utf-8 -*-

ABC = list(map(int, input().split(' ')))
abc = []
c = 0
MAX = max(ABC)

for i in range(3):
    n = (MAX - ABC[i]) // 2
    c += n
    abc.append(ABC[i] + n * 2 - MAX)

abc.sort()

if abc == [0, 0, 0]:
    pass
elif abc == [-1, 0, 0]:
    c += 2
elif abc == [-1, -1, 0]:
    c += 1
print(c)


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

using namespace std;

const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

const int N = 2000006;

int fat[N], ifat[N];
int C(int n, int k) {
	if(n < k) return 0;
	return mul(mul(fat[n], ifat[k]), ifat[n-k]);
}

int solve(int n, int m) {
	if(n < 0 or m < 0) return 0;
	int ans = 0;
	for(int j = 0; j <= m; j++) {
		ans = add(ans, C(j + n + 1, j + 1));
	}
	return ans;
}

int main() {
	fat[0] = ifat[0] = 1;
	for(int i = 1; i < N; i++) {
		fat[i] = mul(i, fat[i - 1]);
		ifat[i] = fexp(fat[i]);
	}
	int r1, c1, r2, c2;
	scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
	int ans = 0;
	ans = add(ans, solve(r2, c2));
	ans = add(ans, mod - solve(r1-1, c2));
	ans = add(ans, mod - solve(r2, c1-1));
	ans = add(ans, solve(r1-1, c1-1));
	printf("%d\n", ans);
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	char a[16];
	cin >> a;
	if (strncmp(a, "YAKI", 4) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3592
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;

void main() {
    const N = readln.chomp.to!long;
    const as = readln.split.to!(long[]);
    auto ss = 0 ~ as.dup;
    foreach (i; 0..N) {
        ss[i+1] += ss[i];
    }
    long sum(long begin, long end) {
        return ss[end] - ss[begin];
    }

    auto left = new long[N];
    foreach (i; 1..N) {
        left[i] = left[i-1];
        while (abs(sum(0,left[i]) - sum(left[i], i)) > abs(sum(0,left[i]+1) - sum(left[i]+1,i))) left[i]++;
    }
    auto right = new long[N];
    foreach (i; 1..N) {
        right[i] = right[i-1];
        while (abs(sum(i,right[i]) - sum(right[i], N)) > abs(sum(i,right[i]+1) - sum(right[i]+1,N))) right[i]++;
    }
    N.iota.map!(i => [sum(0,left[i]), sum(left[i], i), sum(i, right[i]), sum(right[i], N)].pipe!(xs => xs.reduce!max - xs.reduce!min)).reduce!min.writeln;
}


Measured memory_bytes: 17416
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

typedef Segment Line;

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}

// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// 1:???????¨??????? -1:????¨??????? 2:p2-p0-p1 -2:p0-p1-p2 0:p2???p0-p1???
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1-p0;
  Vector b = p2-p0;
  if (cross(a, b) > EPS) return 1;
  if (cross(a, b) < -EPS) return -1;
  if (dot(a, b) < -EPS) return 2;
  if (a.norm() < b.norm()) return -2;

  return 0;
}

// ????§???¢?????¢???(poly???3?????\?????§0?????????)
double polygonArea(vector<Vector> &poly) {
  double ret = 0;
  int n = poly.size();
  for (int i = 0; i < n; i++) {
    ret += cross(poly[i], poly[(i+1)%n]);
    // ret += poly[i].x*poly[(i+1)%n].y-poly[(i+1)%n].x*poly[i].y;
  }
  return abs(ret*0.5);
}

int main() {
  Polygon poly;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    poly.push_back(Vector(x, y));
  }
  cout << fixed << setprecision(1) << polygonArea(poly) << endl;
}

Measured memory_bytes: 1272
# coding: utf-8
# Your code here!
N=int(input())
a1=input().split()
A = [int(i) for i in a1]
x = [0 for i in range(N)]
for i in range(N):
    for j in range(30):
        if A[i]%2 == 0:
            A[i]= A[i]/2
            x[i] = x[i]+1
print(min(x))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main()
{
	ll k;
	cin >> k;
	if(k < 10){
		cout << k << endl;
		return 0;
	}

	auto dp = vector<vector<ll>>(12, vector<ll>(10));
	for(int i = 0; i < 10; ++i){
		dp[1][i] = 1LL;
	}

	auto ans = [&dp, &k](auto ans, int d, int c)-> void {
		if(d == 0) return;
		for(int i = max(0, c - 1); i <= min(9, c + 1); ++i){
			if(k <= dp[d][i]){
				cout << i;
				ans(ans, d - 1, i);
				break;
			}else{
				k -= dp[d][i];
			}
		}
	};

	ll cnt = 9LL;
	for(int i = 2; i < 12; ++i){
		bool finish = false;
		dp[i][0] += dp[i - 1][0] + dp[i - 1][1];
		for(int j = 1; j < 10; ++j){
			dp[i][j] += dp[i - 1][j - 1] + dp[i - 1][j] + (j < 9 ? dp[i - 1][j + 1] : 0);
			if(k <= cnt + dp[i][j]){
				k -= cnt;
				cout << j;
				ans(ans, i - 1, j);
				finish = true;
				break;
			}
			cnt += dp[i][j];
		}
		if(finish) break;
	}
	return 0;
}

Measured memory_bytes: 3612
def check(board)
  flag = true
  board.map! do |line|
    if ret = erase(line)
      flag = false
      ret
    else
      line
    end
  end
  flag
end

def erase(line)
  (1..9).each do |i|
    5.downto(3).each do |j|
      if line.scan(/#{i.to_s}{#{j}}/).size == 1
        return line.gsub(/#{i.to_s}{#{j}}/, '0'*j)
      end
    end
  end
  nil
end

def sum(board)
  board.flat_map{ |l| l.split('') }.map(&:to_i).reduce(:+)
end

def fall(board)
  ret = @h.times.map{ '00000' }
  5.times do |i|
    idx = @h - 1
    (@h - 1).downto(0) do |j|
      if board[j][i] != '0'
        ret[idx][i] = board[j][i]
        idx -= 1
      end
    end
  end
  ret
end

def solve(board)
  loop do
    break if check(board)
    board = fall(board)
  end
  sum(board)
end

while (@h = gets.to_i) != 0
  board = @h.times.map{ gets.chomp.delete(' ') }
  score = sum(board)
  puts score - solve(board)
end

Measured memory_bytes: 10868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        func();
        pw.flush();
        return;
    }

    static void func() throws IOException {
        int[] input = arrayOfInt();
        int n = input[0];
        int m = input[1];

        // 1.N個の数が最大公約数Dを持つということから、
        // 　その合計値のMの約数にもDを含んでいることがわかる。
        // 2.MがDを約数としているとき、D×NがMを超えると成立しなくなるので、
        //   取りうるDの最大値はM/Nとなる
        // ex.) ・N = 3 M = 14のとき、Mの約数は 1 2 7となる
        //      ・最大公約数が7のとき、数列は全て7以上となるため、
        //      　最低値の7×3でも21となり成立しない。
        //      ・最大公約数が2のとき、数列は全て2以上となるため、
        //      　最低値の2×3は6となり、取りうる最大公約数となる。

//        // (一回目のAC解 テストケースによっては10^9ループ回ってTLEになるので想定解ではなさそう)
//        // 最大値を求める問題なので、取りうる最大値からマイナスして成立するものを探すほうが早い
//        int MAX = Math.floorDiv(m, n);
//        long ans = 1;
//        for(int i = MAX;1 < i;i--){
//            if (m%i == 0){
//                ans = i;
//                break;
//            }
//        }

        // 想定解っぽいやつ
        // Mの平方根までの約数と、その約数で割った値で全ての約数が求められるため
        // それらの値が条件に一致するかどうかをチェックして最大値を入れる
        int MAX = Math.floorDiv(m, n);
        long ans = 1;
        for (int i = 1; i*i <= m; i++) {
            if (m % i != 0) continue;
            if(i <= MAX) ans = Math.max(ans,i);
            if (m / i <= MAX) ans = Math.max(ans,m/i);
        }
        println(ans);
    }
    // 入力受け取り
    static String next() throws IOException {return br.readLine();}
    static int nextInt() throws IOException{return getInt(br.readLine());}
    static long nextLong() throws IOException{return getLong(br.readLine());}
    static String[] arrayOfString() throws IOException{return br.readLine().split(" ");}
    static int[] arrayOfInt() throws IOException{return toIntArray(arrayOfString());}
    // 変換
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {return Integer.parseInt(val);}
    static int[] toIntArray(String[] array) {return Stream.of(array.clone()).mapToInt(Integer::parseInt).toArray();}
    static String joinToString(String[] array) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < array.length;i++) sb.append(array[i]);
        return sb.toString();
    }

    // 出力
    static void println(Object val){pw.println(val);}
}

Measured memory_bytes: 28500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int N ;
  cin >> N ;
  string S ;
  cin >> S ;
  if ( N%2 == 1 ){
    cout << "No" << endl;
    return 0 ;
  }
  rep(i,N/2){
    if(S[i] != S[N/2 + i] ){
       cout << "No" << endl;
    	return 0 ;
  }
  }
  cout << "Yes" << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int a=in(),b=in();
    cout<<(a+b)%24;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K,X,Y;

    cin >> N >> K >> X >> Y;

    int sum = 0;
    if(K >= N){
        sum = X * N;
    }else if(K < N){
        sum = X * K + Y * (N -K);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import math
# 大きい数用


def modPow(a, n, p):
    if n == 1:
        return a
    if n % 2 == 1:
        return (a * (modPow(a, n // 2, p) ** 2)) % p
    else:
        return (modPow(a, n // 2, p) ** 2) % p


K, N = map(int, (input().split()))

ans_array = [0] * (N + 1)
mod = 10 ** 9 + 7

for i in range(N, 0, -1):
    c = N // i
    ans_array[i] = (ans_array[i] + modPow(c, K, mod)) % mod
    if i != 1:
        ans_array[1] = (ans_array[1] - ans_array[i] + mod) % mod
    for j in range(2, int(math.sqrt(i) + 1)):
        if i % j == 0:
            if i == j * j:
                ans_array[j] = (ans_array[j] - ans_array[i] + mod) % mod
                break
            else:
                ans_array[j] = (ans_array[j] - ans_array[i] + mod) % mod
                ans_array[i // j] = (ans_array[i // j] -
                                     ans_array[i] + mod) % mod

ans = 0
# print(ans_array)
for i, v in enumerate(ans_array):
    ans = (ans + i * v) % mod

print(ans)


Measured memory_bytes: 76380
import math

N = int(input())
X = math.floor(N/1.08)
X_list = [X-3, X-2, X-1, X, X+1, X+2, X+3]

for x in X_list:
    if(math.floor(x*1.08) == N):
        print(x)
        exit()
print(":(")


Measured memory_bytes: 2940
a,b=sorted(map(int,input().split()))
#ユークリッドの互除法
def gcd(a,b):
    if b==0:
        return a
    #余りが0になったら最後の割る数を出力=lcm
    else:
        return (gcd(b,a%b))
print(int(a*b/gcd(a,b)))

Measured memory_bytes: 2940