akhauriyash/Code-Regression huggingface dataset:
from operator import sub,mul
def cross(a,b):
    return a[0]*b[1] - a[1]*b[0]

def func(a,b):#
    return [map(sub,aa,bb) for aa,bb in zip(a,b)]

def check(a):
    return all(map(lambda x:x<0,a)) or all(map(lambda x:x>0,a))

for _ in xrange(input()):
    line = map(int,raw_input().split())
    tmp = zip(line[:6:2],line[1:6:2])
    v = func(tmp[1:]+[tmp[0]],tmp)
    m = func([line[6:8]]*3,tmp)
    f = func([line[8:]]*3,tmp) 
    if check(map(cross,m,v)) != check(map(cross,f,v)):
        print "OK"
    else:
        print "NG"

Measured memory_bytes: 4396
#include <iostream>
#include <stdio.h>
using namespace std;

int gcd(int m, int n){
  if (m>n) return gcd(n,m);
  if (m==0) return n;
  return gcd(n-m, m);
}

long long int lcm(long int n, long int m){
  return n*m/gcd(n,m);
}

int main(void){
  int a[3], m[3], pos[3], t[3];

  while (1){
    for (int i=0; i<3; i++){
      scanf("%d%d", &a[i], &m[i]);
      pos[i] = 1;
      t[i] = 1;
    }
    if (a[0]==0) break;
    for (int i=0; i<3; i++){
      while (pos[i]*a[i] % m[i] != 1) {
	//cout << a[i] << m[i] << endl;
	pos[i] = pos[i]*a[i] % m[i];
	t[i]++;
      }
      //      cout << t[i] << endl;
    }
    cout << lcm(lcm(t[0], t[1]), t[2]) << endl;
  }

  return 0;
}
      

Measured memory_bytes: 3132
#include <stdio.h>

int main()
{
	char isi;
	scanf("%c", &isi);
	
	if(isi>='A' && isi<='Z'){
		printf("A\n");
	}
	else if(isi>='a' && isi<='z'){
		printf("a\n");
	}

	return 0;
}

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

using namespace std;
using ll = long long;

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

  const ll mod = 1e9 + 7;

  ll s;
  cin >> s;

  // vector<ll> dp(s + 1);
  // dp[0] = 1;
  // for (int i = 3; i <= s; i++) {
  //   for (int j = 3; j <= i; j++) {
  //     dp[i] += dp[i - j];
  //     dp[i] %= mod;
  //   }
  // }
  // cout << dp[s] << endl;

  const ll inf = 1e18;
  vector<ll> ans(s + 1, -inf);
  ans[0] = 1;

  function<ll(ll)> f = [&](ll n) {
    if (ans[n] != -inf) {
      return ans[n];
    }
    if (n < 3)
      return ans[n] = 0ll;
    ll ret = 0;
    for (ll i = 3; i <= n; i++) {
      ret += f(n - i);
      ret %= mod;
    }
    return ans[n] = ret;
  };
  f(s);
  cout << ans[s] << endl;

  return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int d[2005][2005];
int ans[2005];
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	memset(ans, 0, sizeof(ans));
	int n, x, y;
	cin >> n >> x >> y;
	for (int i = 1; i <= n;i++) {
		d[i][i] = 0;
	}
	for (int i = 1; i <= x;i++) {
		for (int j = i + 1; j <= x;j++) {
			d[i][j] = j - i;
			ans[d[i][j]]++;
		}
		for (int j = y; j <= n;j++) {
			d[i][j] = j - i - (y - x)+1;
			ans[d[i][j]]++;
		}
		for (int j = x + 1; j < y;j++) {
			d[i][j] = min(j - i, y - j + d[i][y]);
			ans[d[i][j]]++;
		}
	}
	for (int i = y; i <= n;i++) {
		for (int j = i + 1; j <= n;j++) {
			d[i][j] = j - i;
			ans[d[i][j]]++;
		}
	}
	for (int i = x + 1; i < y;i++) {
		for (int j = i + 1; j <= n;j++) {
			if (j<=y) {
				d[i][j] = min(j - i, y - x + 1 + i - j);
			}
			else {
				d[i][j] = d[i][y] + d[y][j];
			}
			//d[i][j] = min(j - i, j - x + d[x][j]);
			ans[d[i][j]]++;
		}
	}
	for (int i = 1; i <= n - 1;i++) {
		cout << ans[i] << " ";
	}
	cout << "\n";
	return 0;
}


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

using namespace std;
const int N = 100;

int n, sum(0);
int a[N], ans = 0;

int main(void)
{
	cin >> n;
	for (int i=1;i<=n;++i)
	    cin >> a[i];
	for (int i=n-1,sum=a[n];i;--i)
		ans += a[i] * sum, sum += a[i];
	cout << ans << endl;
	return 0; 
}

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

int main()
{
  int N,K,ans=1;
  cin >> N >> K;
  rep(i,N)
  {
    if(ans < K)
      ans *= 2;
    else
      ans += K;
  }
    cout << ans << endl;
}
    

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

const ll large_P = 1e9 + 7;


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


// base を底としたときの、i桁目を、v.at(i) に入れる。
void ll_to_vector(ll base, ll n, vector<int>& v){
  ll tempo = n;
  ll n_digit = v.size();

  for(ll i = 0; i < n_digit; i++){
    v.at(i) = tempo/pow(base, n_digit - 1 - i);
    tempo -= v.at(i) * pow(base, n_digit - 1 - i);
  }
}



int main(){
  string S; cin >> S;
  int N = S.size();
  
  vector<int> v(N);
  rep(i, N) v.at(i) = char_to_int(S.at(i));
  
  vector<int> plus(N-1, 0); //0か1で、1の場合、プラスを入れる。
  
  ll res = 0;
  ll temp = 0;
  ll digit_count = 0;
  
  for(int i = 0; i < pow(2, N-1); i++){
    ll_to_vector(2, i, plus);
    //rep(j, N-1) cout << plus.at(j);
    //cout << endl;
    
    temp = 0; digit_count = 0; int j = N-1;  // リセット   
    while(j >= 0){
      temp += v.at(j)*pow(10, digit_count);
      if(j>0){
        if(plus.at(j-1) == 1) digit_count = 0;
        else digit_count += 1;
      }
      j--;
      if(j<0) break;
    }
    //cout << temp << endl;
    res += temp;
  }
  
  cout << res;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

    public static void main(String[] args) {
        var sc = new java.util.Scanner(System.in);
        var k = sc.nextLong();
        long res = 0;
        Deque<Long> deque = new ArrayDeque<>();
        deque.addAll(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L));
        for (int i = 0; i < k; i++) {
            res = deque.pollFirst();
            if (res % 10 == 0) {
                deque.addLast(res * 10 + res % 10);
                deque.addLast(res * 10 + res % 10 + 1);
            } else if (res % 10 == 9) {
                deque.addLast(res * 10 + res % 10 - 1);
                deque.addLast(res * 10 + res % 10);
            } else {
                deque.addLast(res * 10 + res % 10 - 1);
                deque.addLast(res * 10 + res % 10);
                deque.addLast(res * 10 + res % 10 + 1);
            }
        }
        System.out.println(res);
    }

}


Measured memory_bytes: 45964
#include "bits/stdc++.h"
#define all(v) v.begin(),v.end()
#define SZ(x) (int)x.size()
#define endl "\n"
#define thunder ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(15);
using namespace std;
typedef long long int ll;
#ifdef ONLINE_JUDGE
#define debug(...)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
void debug_out() { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
vector<pair<int,int>>vp;
map<pair<int,int>,ll>mp;
ll dp(int weight,int index)
{
    if(weight<0||index<0)return 0;
    if(mp[{weight,index}])return mp[{weight,index}];
    ll ans1=0;
    if(vp[index].first<=weight)
    {
        ans1+=(max(ll(vp[index].second)+dp(weight-vp[index].first,index-1),dp(weight,index-1)));
    }
    else
        ans1=dp(weight,index-1);
    mp[{weight,index}]=ans1;
    return ans1;


}
int main()
{
    thunder
    auto start = chrono::high_resolution_clock::now();
    int n,w;cin>>n>>w;
    vp.assign(n,{0,0});
    for(int i=0;i<n;++i)
    {
        cin>>vp[i].first>>vp[i].second;
    }

   cout<<dp(w,n-1);
   





   auto end = chrono::high_resolution_clock::now(); 
   double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
   time_taken *= 1e-9;
   debug(time_taken);
}

Measured memory_bytes: 9488
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1e9
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int a,b; cin >> a >> b;
    int x = max(a,b);
    if(a == b){
        cout << 2*a << endl;
        return 0;
    } else cout << 2*x - 1 << endl;
}

Measured memory_bytes: 256
from itertools import permutations, combinations,combinations_with_replacement,product
s=input()
al=sorted(list(product(['','+'],repeat=len(s)-1)))
ans=0
for i in al:
    word=''
    for s1,i1 in zip(s[:-1],i):
        word+=s1+i1
    word+=s[-1]
    ans+=eval(word)
print(ans)

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	VL l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	LL ans = INT32_MAX;
	for (int i = 1; i < 1<<n; i++) {
		LL mpa = -10; // aを作るのに使うMP
		LL sizea = 0;
		for (int x = 0; x < n; x++) {
			if (((i>>x) & 1) == 1) {
				mpa += 10;
				sizea += l[x];
			}
		}
		for (int j = 1; j < 1<<n; j++) {
			LL mpb = -10; // aを作るのに使うMP
			LL sizeb = 0;
			if ((i & j) != 0) {
				continue;
			}
			for (int y = 0; y < n; y++) {
				if (((j>>y) & 1) == 1) {
					mpb += 10;
					sizeb += l[y];
				}
			}
			for (int k = 1; k < 1<<n; k++) {
				LL mpc = -10; // aを作るのに使うMP
				LL sizec = 0;
				if ((i & k) != 0 or (j & k) != 0) {
					continue;
				}
				for (int z = 0; z < n; z++) {
					if (((k>>z) & 1) == 1) {
						mpc += 10;
						sizec += l[z];
					}
				}
				LL tmpans = mpa + mpb + mpc + abs(a - sizea) + abs(b - sizeb) + abs(c - sizec);
				ans = min(ans,tmpans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, m;
long long ans;

int main() { 

  cin >> n >> m;

  if (n == 1 && m == 1) {
    ans = 1;
    cout << ans << endl;
    return 0;
  }

  ans = max(0ll, 1ll * (n - 2) * (m - 2));

  if (n == 1) {
    ans = max(0, m - 2);
  }
  if (m == 1) {
    ans = max(0, n - 2);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> r(a), g(b), m(c);
	for(int i = 0; i < a; i++)cin >> r[i];
	for(int j = 0; j < b; j++)cin >> g[j];
	for(int i = 0; i < c; i++)cin >> m[i];
	sort(r.begin(), r.end(), greater<int>());
	sort(g.begin(), g.end(), greater<int>());
	vector<int> arr;
	for(int i = 0; i < x; i++)arr.push_back(r[i]);
	for(int i = 0; i < y; i++)arr.push_back(g[i]);
	for(int i = 0; i < c; i++)arr.push_back(m[i]);
	sort(arr.begin(), arr.end(), greater<int>());

	cout << accumulate(arr.begin(), arr.begin() + x + y, 0LL) << endl;

}

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

using namespace std;

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

  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (auto& e : s) {
    cin >> e;
  }
  sort(s.begin(), s.end());
  string ans;
  for (auto& e : s) {
    ans += e;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
//#include <math.h>
#include <set>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100;

int main(){

  int h,w,n;
  int a[maxn*maxn];
  int grid[maxn+10][maxn+10]={0};

  cin >> h>>w>>n;
  rep(i,n)cin >> a[i];

  int pos = 0;
  rep(i,h){
    if(i%2==0){
      for(int j=0;j<w;j++){
        if(a[pos]==0)pos++;
        grid[i][j]=pos+1;
        a[pos]--;
      }
    }else{
      for(int j=w-1;j>=0;j--){
        if(a[pos]==0)pos++;
        grid[i][j]=pos+1;
        a[pos]--;
      }
    }
  }

  rep(i,h){
    rep(j,w){
      if(j==w-1)cout << grid[i][j];
      else cout << grid[i][j]<<' ';
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int n, k, r, s, p;
    cin >> n >> k;
    vector<int> rsp(3);
    cin >> rsp[0] >> rsp[1] >> rsp[2];
    string t;
    cin >> t;
    vector<int> pnt(n);
    rep(i,n) {
        if (t[i] == 'r') pnt[i] = 2;
        else if (t[i] == 's') pnt[i] = 0;
        else if (t[i] == 'p') pnt[i] = 1;
    }
    int ans = 0;
    rep(i,k) {
        int now = pnt[i], cnt = 1, res = 0;
        for (int id = i+k; id < n; id += k) {
            if (pnt[id] == now) {
                cnt ++;
            }
            else {
                res += ((cnt + 1) / 2) * rsp[now];
                now = pnt[id];
                cnt = 1;
            }
        }
        res += ((cnt + 1) / 2) * rsp[now];
        ans += res;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int tmp[100005];

int main(void) {
    int N, K; cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        int tmpp = i;
        int cnt = 0;
        while (tmpp < K) {
            tmpp *= 2;
            cnt++;
        }
        tmp[i] = cnt;
    }
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        double tmpp = 1.0/N;
        for (int j = 1; j <= tmp[i]; j++) {
            tmpp /= 2.0;
        }
        ans += tmpp;
    }
    printf("%.12f\n", ans);
}   




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2025,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,cnt,a[N];
ll ans;
char ch[N];
int main(){
//	freopen("balance.in","r",stdin);
//	freopen("balance.out","w",stdout);
	scanf("%s %d",ch+1,&m);
	n=strlen(ch+1);
	int t=1;
	for (int i=2;i<=n;i++)
	if (ch[i]!=ch[i-1]){a[++cnt]=t;t=1;}
	else t++;
	a[++cnt]=t;
	if (cnt==1) ans=(ll)n*m/2;
	else if (ch[1]==ch[n]){
		ans=a[1]/2+a[cnt]/2+(ll)(a[1]+a[cnt])/2*(m-1);
		for (int i=2;i<cnt;i++) ans+=(ll)a[i]/2*m;
	}
	else for (int i=1;i<=cnt;i++) ans+=(ll)a[i]/2*m;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <utility>
typedef long long ll;

int main(void) {
  ll inf = 10e15;
  ll i, j, k, v, r, e;
  scanf("%lld%lld%lld", &v, &e, &r);
  ll dis[v];
  std::vector< std::pair<ll, ll> > vec[v];
  std::vector< std::pair<ll, ll> >::iterator it;
  for(i = 0; i < v; ++i) dis[i] = inf;
  dis[r] = 0;
  for(i = 0; i < e; ++i) {
    ll ta, tb, tc;
    std::pair<ll, ll> p;
    scanf("%lld%lld%lld", &ta, &tb, &tc);
    p = std::make_pair(tb, tc);
    vec[ta].push_back(p);
  }
  for(k = 1; k < v; ++k) {
    char flag = 0;
    for(i = 0; i < v; ++i) if(dis[i] != inf) {
      for(it = vec[i].begin(); it != vec[i].end(); ++it) {
        if(dis[(*it).first] > dis[i] + (*it).second) {
          flag = 1;
          dis[(*it).first] = dis[i] + (*it).second;
        }
      }
    }
    if(flag) {
      if(k == v - 1) {
        printf("NEGATIVE CYCLE\n");
        return 0;
      }
    } else break;
  }
  for(i = 0; i < v; ++i) {
    if(dis[i] != inf) printf("%lld\n", dis[i]);
    else printf("INF\n");
  }
  return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int n,a,b=0,ans=1;
	cin>>n>>a;
	f(i,n){
		int c;
		cin>>c;
		b+=c;
		if(b<=a)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main(){
    ll h, w, n;
    cin >> w >> h >> n;
    map<P, int> mp;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        for(ll x = a - 3; x < a; x++){
            for(ll y = b - 3; y < b; y++){
                if (0 <= x && x + 2 < w && 0 <= y && y + 2 < h) mp[{x,y}]++;
            }
        }
    }
    ll ans[10] = {};
    ans[0] = (h-2) * (w-2);
    for(auto v : mp){
        ans[v.second]++;
        ans[0]--;
    }
    rep(i, 10) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 56448
#include <stdio.h>
#include <string.h>

int main(int argc,char* argv[]){
  char str[81];
  int sum = 0;

  while(scanf("%s",str) != EOF){
    int len = strlen(str);
    int i,keta,num;

    keta = 1;
    num = 0;
    for(i = (len -1); i >= 0; i--){
      if(str[i] >= '0' && str[i] <= '9'){
	num += (str[i] - '0') * keta;
	keta*=10;
      }else if(keta != 1){
	sum += num;
	num =0;
	keta = 1;
      }
    }
    
    if(keta != 1){
	sum += num;
	num =0;
	keta = 1;
    }
  }
  
  printf("%d\n",sum);

  return 0;
  
}

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

int main(){

	int h;
  	cin >> h;
  	int w;
  	cin >> w;
  	vector<string> a(h);
  	
  	for(int i = 0; i < h ; i++){
    
      	cin >> a[i];
    
    }
  
  	vector<bool> row( h, false );
  	vector<bool> col( h, false );
  	
  	for(int i = 0; i < h ; i++){
    
    	for(int j = 0; j < w; j++){
        
        	if(a[i][j] == '#' ){
            
            	row[i] = true;
              	col[j] = true;
            
            }
        
        }
    
    }
  
  	for(int i = 0; i < h; i++){
    
    	if(row[i]){
        
        	for(int j = 0; j < w ; j++){
            
              if(col[j]){
              	cout << a[i][j];
              }
            
            }
        	cout << endl;
        
        }
    
    
    
    }
  
  




}

Measured memory_bytes: 256
int main(void){
   int a,n,i,min=1000000,max=-1000000;
    long long sum=0;
   scanf("%d",&n);
   for(i=0;i<n;i++){
       scanf("%d",&a);
       sum=sum+a;
       if(min>a)
           min=a;
       if(max<a)
           max=a;
   }
   printf("%d %d %lld\n",min,max,sum);
   return 0;
}


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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n-1);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  for(int i = 0;i < n;i++){
    cin >> b.at(i);
    ans += b.at(i);
  }
  for(int i = 0;i < n-1;i++){
    cin >> c.at(i);
  }
  for(int i = 0;i < n-1;i++){
    if(a.at(i) == a.at(i+1)-1){
      ans += c.at(a.at(i)-1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def keisan(mylst, i):
    mylst.append(i)
    result = 0
    if i % 2 == 0:
        result = i/2
    else:
        result = 3*i+1

    if result in mylst:
        return len(mylst) + 1
    else:
        return keisan(mylst, result)

mylist = list()
s = int(input())
print(keisan(list(), s))

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        int cnt=0;
        Scanner sc=new Scanner(System.in);
        String a=sc.next();        
        for(int i=0;i<a.length()/2;i++){
            if(a.charAt(i)!=a.charAt(a.length()-1-i)){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
    int k; cin >> k;
    cout << (e - a > k ? ":(" : "Yay!") << endl;
    
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];
		for(int i = 0; i < N; i++) p[i] = sc.nextInt();
		boolean check = true;
		for(int i = 1; i < N; i++) if(p[i - 1] >= p[i]) check = false;

		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				int tmp = p[i]; p[i] = p[j]; p[j] = tmp;
				boolean flg = true;
				for(int k = 1; k < N; k++) if(p[k - 1] >= p[k]) flg = false;
				check |= flg;
				tmp = p[i]; p[i] = p[j]; p[j] = tmp;
			}
		}
		System.out.println(check ? "YES" : "NO");
	}
}

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

int A[200005];
int L[200005];
int R[200005];
map<int, int> mp;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


    int n;cin>>n;
    for(int i=0;i<n;i++){
      cin>>A[i];
      L[i] = (i + A[i] + 1);
      R[i] = (i - A[i] + 1);
    }
    ll ans=0;
    for(int i=n-1;i>=0;i--){
      mp[R[i]]++;
      if(i<n-1){
        ans += mp[L[i]];
      }
    }
    cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 22972
'''
Author : Shubhanshu Jain;
'''

import math
import random;
from collections import * 
mod =1000000007
r1 = lambda : int(input());
rm = lambda : map(int,input().split());
rms = lambda : map(str,input().split());
rls = lambda : list(rm())

ls = [1,1,1,1,1,2,2,3];
dic = Counter(ls)
def def_value(): 
	return "nan"
	

    
def solve():
    n = r1();
    ls = rls();
    ans = [0]*n
    ans[0]= 0;
    ans[1] =abs(ls[0]-ls[1]);
    for i in range(2,n):
        ans[i] = min((abs(ls[i]-ls[i-1])+ans[i-1]),(abs(ls[i]-ls[i-2])+ans[i-2]));
    print(ans[n-1])

	
solve();



Measured memory_bytes: 52720
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,p=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]

#True : 負の経路が存在する
def find_negative_loop1(n,w,es):
    #負の経路の検出
    #n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [float("inf")] * n
    d[0] = 0
    infdic=defaultdict(int)
    #この始点はどこでもよい
    for i in range(n):
        for j in range(w):
            e = es[j]
            if d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                if i == n-1:
                    infdic[e[0]]=1
    return infdic

def find_negative_loop2(n,w,es,infd):
    #負の経路の検出
    #n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [float("inf")] * n
    d[0] = 0
    for i in infd.keys():
        d[i]=-float('inf')
    #この始点はどこでもよい
    for i in range(n):
        for j in range(w):
            e = es[j]
            if d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                # if i == n-1:
                #     return True
    return d


#############################
w = m
es = [[] for i in range(w)] #es[i]: [辺の始点,辺の終点,辺のコスト]
for i in range(w):
    x,y,z = abc[i]
    es[i] = [x-1,y-1,p-z]
# w = w*2
# print(es)

tmp=find_negative_loop1(n,w,es)
# print(tmp)
tmp2=find_negative_loop2(n,w,es,tmp)
# print(tmp2)
if tmp2[-1]==-float('inf'):
    print(-1)
else:
    print(-min(tmp2[-1],0))

Measured memory_bytes: 45660
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int m,d;
	while(cin >> m >> d){
		if(m == 0 && d == 0)break;
		int n = 0;
		for(int i = 1; i < m; i++){
			if(i == 2)n += 29;
			else if(i == 4 || i == 6 || i == 9 || i == 11)n += 30;
			else n += 31;
		}
		n += d;
		switch(n % 7){
			case 0:
				cout << "Wednesday" << endl;
				break;
			case 1:
				cout << "Thursday" << endl;
				break;
			case 2:
				cout << "Friday" << endl;
				break;
			case 3:
				cout << "Saturday" << endl;
				break;
			case 4:
				cout << "Sunday" << endl;
				break;
			case 5:
				cout << "Monday" << endl;
				break;
			case 6:
				cout << "Tuesday" << endl;
				break;
		}
	}
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
bool check(long long n, long long s, long long b){
    if(b<2) return false;
    long long sum = 0;
    while(n>0){
        sum+=n%b;
        n/=b;
    }
    return sum==s;
}
int main(){
    long long n, s;
    cin>>n>>s; if(n==s){cout<<n+1; return 0;}
    long long answer = 10000000000000;
    for(long long i=1; i<(long long)sqrt(n)+10000; i++){
        if(check(n, s, i)) answer = min(answer, i);
        long long a=i, b=s-i; if(b<0) continue;
        long long base = (n-b)/a;
        if(check(n, s, base)) answer = min(answer,base);
    }
    cout<<(answer!=10000000000000?answer: -1);
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N = int(input())
p = [int(x) for x in input().split()]

ans = 0

for i in range(1,N-1) :
    if p[i-1] > p[i] and p[i] > p[i+1] :
        ans += 1
    elif p[i-1] < p[i] and p[i] < p[i+1] :
        ans += 1

print(ans)


Measured memory_bytes: 3060
import sys


input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())



mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=II()

t=acinput()
a=acinput()

st = [[] for i in range(N)]
st[0]=[t[0],t[0]]
for i in range(1,N):
    if t[i-1]<t[i]:
        st[i]=[t[i],t[i]]
    else:
        st[i]=[1,st[i-1][1]]
        

sa = [[] for i in range(N)]
sa[N-1] = [a[N-1], a[N-1]]
for i in reversed(range(N-1)):
    if a[i] > a[i+1]:
        sa[i] = [a[i], a[i]]
    else:
        sa[i] = [1,sa[i+1][1]]

def diff(x):
    return x[1]-x[0]
res=1
for i in range(N):
    
    x=max(sa[i])-min(st[i])+1
    y=max(st[i])-min(sa[i])+1
    #print(x,y,np.diff(sa))
    if x<=0 or y<=0:
        res=0
        break
    res=res* min(x,y,diff(sa[i])+1,diff(st[i])+1)
    res=res%mod
    
print(res%mod)

#print(st)
#print(sa)


Measured memory_bytes: 100956
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let gs = reverse $ (\(a,c,x) -> (a,c) : x) $ f as
    let ans = foldl' h 1000 gs
    print ans

f (a:as) = foldl' g (a,a,[]) as
    where g (a,b,s) c | b <= c = (a,c,s)
                      | otherwise = (c,c, (a,b) : s)

h m (a,b) = m'
    where (k,l) = m `divMod` a
          m' = l + k * b

Measured memory_bytes: 3780
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,q = LI()
    root = [[] for _ in range(n+1)]
    quest = [0 for _ in range(n+1)]

    for _ in range(n-1):
        a,b = LI()
        root[a].append(b)
        root[b].append(a)
    
    for _ in range(q):
        p,x = LI()
        quest[p] += x

    stock = collections.deque([1])
    explored = set()

    while len(stock) != 0:
        next = stock.pop()
        explored.add(next)
        for i in root[next]:
            if i not in explored:
                stock.append(i)
                quest[i] += quest[next]
    print(*quest[1:])
main()

Measured memory_bytes: 153936
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); i++)
#define RFOR(i, a, b)  for(int i = (a); i > (b); i--)
#define rep(i, n)	   for(int i = 0; i < (n); i++)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define foritr(itr, c) for(auto itr = begin(c); itr != end(c); itr++)
#define SZ(a)		   ((ll) a.size())

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll N, string S) {
	int tmp	 = 0;
	int tmp2 = 0;
	rep(i, N) {
		if(tmp < 0 and S[i] == '(') {
			tmp2 -= tmp;
			tmp	  = 1;
		}
		else if(S[i] == '(') tmp++;
		else if(S[i] == ')') tmp--;
	}
	rep(i, tmp2) S.insert(begin(S), '(');
	tmp	 = 0;
	tmp2 = 0;
	rep(i, SZ(S)) {
		if(S[i] == ')') tmp++;
		else tmp2++;
	}
	if(tmp > tmp2) {
		rep(i, tmp - tmp2) S.insert(begin(S), '(');
	}
	else if(tmp2 > tmp) {
		rep(i, tmp2 - tmp) S.insert(end(S), ')');
	}
	cout << S;
}

int main() {
	ll	   N;
	string S;
	scanf("%lld", &N);
	cin >> S;
	solve(N, S);
	return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;

ll dfs(ll hp) {// hpのやつ1体を倒すのに必要な攻撃回数
    if (hp == 1) return 1;
    return dfs(hp/2) * 2 + 1;
}
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll H; cin >> H;
    cout << dfs(H) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    long long n,k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i = 0;i < n;i++){
          cin >> a[i];
    }
    for(int i = k;i < n;i++){
          if(a[i] > a[i - k]){
                cout << "Yes" << endl;
          }else{
                cout << "No" << endl;
          }
    }
    
}


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

int main(){
	int x;
	scanf("%d", &x);
	int l = 1, r = 1e9;
	while (r > l){
		int m = l + r >> 1;
		ll z = (ll)m * (m + 1) >> 1;
		if (z >= x)r = m;
		else l = m + 1;
	}
	printf("%d\n", l);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    rep(i,1000){
        if(i%2==0){
            c-=b;
            if(c<=0){
                cout << "Yes";
                return 0;
            }
        }
        else{
            a-=d;
            if(a<=0){
                cout << "No";
                return 0;
            }
        }
    }


    
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <memory.h>
int main(void){
	int n,m,t,p[100][101],k,l[100],i,j,ans,f;
	while(1){
		scanf("%d",&n);
		if(!n)
			break;
		memset(p,0,sizeof(p));
		f=1;
		ans=-1;
		for(i=0;i<n;i++){
			scanf("%d",&m);
			for(j=0;j<m;j++){
				scanf("%d",&t);
				p[i][t]++;
			}
		}
		scanf("%d",&k);
		for(i=0;i<k;i++)
			scanf("%d",&l[i]);
		for(i=0;i<n;i++){
			for(j=0;j<k;j++){
				if(!p[i][l[j]])
					break;
			}
			if(j==k&&f){
				ans=i+1;
				f=0;
			}
			else if(j==k&&!f)
				ans=-1;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long long ans=0;
  for(int i=1;i<n;i++){
    int x=i/2;
    ans+=a.at(x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4776
import java.util.Scanner;
import java.util.*;

public class Main {
	
	public static Boolean isNumeric(String number) {
		try {
			Double.parseDouble(number);
			return true;
		}catch(NumberFormatException e){
			return false;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] opArray = sc.nextLine().split(" ");
		Stack<Integer> st = new Stack<Integer>();
		int i = 0;
		while (i < opArray.length) {
			//System.out.println(opArray[i]);
			if(isNumeric(opArray[i])) {
				int inputInt = Integer.parseInt(opArray[i]);
				st.push(inputInt);
			}else if (opArray[i].equals("+")){
				int r1 = st.pop();
				
				int r2 = st.pop();
				
				st.push(r2 + r1);
				
			}else if (opArray[i].equals("-")) {
				int r1 = st.pop();
				
				int r2 = st.pop();
				st.push(r2 - r1);
			}else if(opArray[i].equals("*")) {
				int r1 = st.pop();
				
				int r2 = st.pop();
				st.push(r2 * r1);
			}else if(opArray[i].equals("/")) {
				int r1 = st.pop();
				
				int r2 = st.pop();
				st.push(r2 / r1);
			}
			i += 1;
		}
		

		sc.close();
		System.out.println(st.get(0));
	}
}



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

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

const int INF = 1000000007;

int main(void){
	ll n, m, d;
	cin>>n>>m>>d;
	cout<<fixed;
	cout<<setprecision(12);

	if(d == 0) {
		cout<< 1.0/n * (m - 1) <<endl;
	}
	else {
		cout<< 2.0*(n - d) / (n*n) * (m - 1) <<endl;
	}

	return 0;
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const long long MAXN=2e5 + 5;;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << 'A' << s2[0] << 'C';
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 3616
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
if N%2 == 0:
  print(int(N/2))
else:
  print(int(N/2+1))

Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    char c; cin >> c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<functional>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int ans;

int main(){
  int N;
  cin >> N;
  int miria[20];
  int m;
  for(int i=0;i<N;i++){
    cin >> miria[i];
    if(i==0){
      m = miria[0];
      ans++;
    }
    if(i>=1){
      if(miria[i]>=m){
        ans++;
        m = miria[i];
      }
    }

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


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

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2


class SingleSourceShortestPath(object):
    __slots__ = ('adj_table', 'distance', 'parent', 'visited')

    def __init__(self, in_data):
        v_num = int(in_data[0])
        vertices = map(lambda x: x.split(), in_data[1:])
        adj_table = tuple(dict() for _ in range(v_num))

        for v_info in vertices:
            source, v_adj_length, *v_adj_list = map(int, v_info)
            # assert len(v_adj_list) == v_adj_length * 2
            for target, cost in zip(v_adj_list[::2], v_adj_list[1::2]):
                adj_table[source][target] = cost

        self.adj_table = adj_table
        self.distance = [float('inf')] * v_num
        self.parent = [-1] * v_num
        self.visited = [WHITE] * v_num

    def path_heap_dijkstra(self, root):
        # path search init
        self.distance[root] = 0
        path_heap = list()
        # heapq: rank by tuple[0], at here it's d[u]
        hp.heappush(path_heap, (0, root))

        while path_heap:
            csp, current = hp.heappop(path_heap)
            self.visited[current] = BLACK

            for adj, cost in self.adj_table[current].items():
                if self.visited[adj] != BLACK:
                    # alt: d[u] + w[u,v]
                    alt_path = self.distance[current] + cost
                    if alt_path < self.distance[adj]:
                        # update path_list
                        self.distance[adj] = alt_path
                        # update heap
                        hp.heappush(path_heap, (alt_path, adj))
                        self.visited[adj] = GRAY
                        self.parent[adj] = current

        return self.distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    case = SingleSourceShortestPath(in_data=_input)
    ans = case.path_heap_dijkstra(root=0)
    for i, v in enumerate(ans):
        print(i, v)

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

using namespace std;

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

  int ret=0;
  for(int i=0;;i++)
  {
    if(i*i>N)
    {
      ret=(i-1)*(i-1);
      break;
    }
  }
  cout<< ret<< endl;

  return 0;
}


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

using namespace std;
typedef long long i64;

const int INF = 1000000000;
const int N = 100005;


int main ()
{
    i64 n, m;
    cin >> n >> m;
    if (m == 1) swap(n, m);
    if (n == 1 && m == 1) puts("1");
    else if (n == 1) printf("%lld\n", m - 2);
    else printf("%lld\n", (n - 2) * (m - 2));
    return 0;
}


Measured memory_bytes: 256
N, D = map(int, input().split())
X = []
for _ in range(N):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        s = sum((X[i][d] - X[j][d])**2 for d in range(D))
        if any(i**2 == s for i in range(1000)):
            ans += 1

print(ans)


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

const int N = 2e5+7;
struct node
{
	int a,b,c,d;
}Q[55];

int n,m,q;
int s[15],ans;

void check()
{
	int num=0;
	for(int i=0;i<q;i++)
	{
		if(s[Q[i].b]-s[Q[i].a]==Q[i].c) num+=Q[i].d;
	}
	ans = max(ans,num);
}
void dfs(int pos,int val)
{
	s[pos] = val;
	if(pos==n) 
	{
		check();
		return ;
	}
	for(int i=val;i<=m;i++)
	{
		dfs(pos+1,i);
	}
}
int main()
{
	cin >> n >> m >> q;
	for(int i=0;i<q;i++)
	{
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		Q[i] = (node){a,b,c,d};
	}
	dfs(1,1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define MAXN 100

struct Matrix {int r, c; };

int main(){
    int n; cin >> n;
    struct Matrix M[MAXN];
    for(int i=0; i<n; ++i){
        cin >> M[i].r >> M[i].c;
    }
    
    int dp[MAXN+1][MAXN];
    for(int i=0; i<n; ++i){
        dp[1][i] = 0;
    }
    for(int m=2; m<=n; ++m){
        for(int i=0; i<=n-m; ++i){
            priority_queue<int, vector<int>, greater<int> > pq;
            for(int j=1; j<m; ++j){
                //cout << "here with m= " << m << " i = " << i << " j = " << j << endl;
                int x = dp[j][i] + dp[m-j][i+j] + M[i].r*M[i+j].r*M[m+i-1].c;
                pq.push(x);
            }
            dp[m][i] = pq.top();
        }
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 1252