akhauriyash/Code-Regression huggingface dataset:
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll mod = (ll)1e9 + 7;
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
set<int> s;
int vis[111];
int main()
{
    fast;
     char c;
     set<char> s;
     for(int i=0;i<4;i++)
     {
         cin>>c;
         s.insert(c);
     }
     if(s.sz==2)
        pr(1);
     else
        pr(0);
}




Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


def dfs(curr):
    visit[curr] = 1
    for x in graph[curr]:
        if visit[x] == 0:
            dfs(x)


ans = 0
for i in range(m):
    temp = ab[:i] + ab[i + 1:]
    graph = [[] for _ in range(n + 1)]
    for a, b in temp:
        graph[a].append(b)
        graph[b].append(a)

    visit = [0] * (n + 1)
    dfs(1)

    if sum(visit[1:]) != n:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int x,h;
double ans;

int main(){
	while(true){
		scanf("%d%d", &x, &h);
		if(x == 0 && h == 0) break;
		ans = (double)(x*x)+sqrt((double)(h*h)+(double)(x*x/4.0))*(double)x*2.0;
		printf("%.9f\n", ans);
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N,C,K;
int T[100000];

int main(){
    cin>>N>>C>>K;
    rep(i,N) cin>>T[i];
    sort(T,T+N);

    bool first=true;
    int s;
    int ans=0;
    int cnt=0;
    rep(i,N){
        if(first){
            cnt++;
            s=T[i]+K;
            first=false;
            continue;
        }
        if(cnt<C && T[i]<=s){
            cnt++;
        }else{
            cnt=0;
            ans++;
            first=true;
            i--;
        }
    }
    if(cnt) ans++;

    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String S=scan.next();
		String T=scan.next();
		int A=scan.nextInt();
		int B=scan.nextInt();
		String U=scan.next();
		if(S.equalsIgnoreCase(U))
		{
			A--;
		}
		else {
			B--;
	
		}
		System.out.println(A);
		System.out.println(B);
	}

}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}



int main(){
  int A,P;
  cin >> A >> P;
  int frag = A*3+P;
  int pie = frag/2;

  cout << pie;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))

    ans = 0
    tmp = 1
    for aa in a:
        if aa == tmp:
            tmp += 1
        else:
            ans += 1

    if ans == N:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    for(int i =0; i < s.size(); i++){
        if(s.at(i) != t.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

using ll = long long;
using namespace std;

int main() {
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

array = [a,b,c,d,e]

m = min(array)
if n <= m: print(5)
else: 
	if n%m == 0:
		print(4 + (n//m))
	else:
		print(4 + (((n//m)+1)*m)//m)
		

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define N (int)(1e5+7)
#define inf (int)(1e9+7)
#define INF (long long) (1e18+7)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int M = (int)(2e6 + 239);

int d[13];

bool f(int n){
    while(n>0){
        if(d[n%10])return false;
        n/=10;
    }
    return true;
}

void solve(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<=10;i++)d[i]=0;
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        d[x]=1;
    }
    for(int i=n;i<=10*n+3;i++){
        if(f(i)){
            cout<<i<<'\n';
            break;
        }
    }
    return;
}
int main(){
    fastio;
    solve();
    return 0;
}

Measured memory_bytes: 3632
import math
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        if 0 > p:
            p = -p
            q = -q
        elif p == 0:
            q = abs(q)
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
if N != 1:
    print(N-max(s_dict.values()))
else:
    print(1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  ll m = 0;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(m);
  map<ll,ll> ac;
  map<ll,ll> bc;
  for(int i = 0;i < n;i++)cin >> a[i],ac[a[i]]++;
  for(int i = 0;i < m;i++)cin >> b[i],bc[b[i]]++;
  if((ll)ac.size() != n || (ll)bc.size() != m){
    cout << 0 << endl;
    return 0;
  }
  vector<ll> awa(n*m);
  vector<ll> bwa(n*m);
  for(int i = n*m - 1;i >= 0;i--){
    if(ac[i + 1] == 1)awa[i] = 1;
    if(i != n*m - 1)awa[i] += awa[i + 1];
  }
  for(int i = n*m - 1;i >= 0;i--){
    if(bc[i + 1] == 1)bwa[i] = 1;
    if(i != n*m - 1)bwa[i] += bwa[i + 1];
  }
  ll res = 1;
  ll mod = pow(10,9) + 7;
  for(int i = n*m - 1;i >= 0;i--){
    if(ac[i + 1] == 1 && bc[i + 1] == 0)res *= max((ll)0,bwa[i + 1]);
    if(ac[i + 1] == 0 && bc[i + 1] == 1)res *= max((ll)0,awa[i + 1]);
    if(ac[i + 1] == 0 && bc[i + 1] == 0)res *= max((ll)0,awa[i + 1] * bwa[i + 1] - (n*m - i - 1));
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 143816
##ARC61-C
#再帰関数
s = list(input())
#桁数を扱うのは文字列として扱ってlenを取るのがベター
n = len(s)

def dfs(i,f):
    if i == n -1:
        return sum(list(map(int, f.split("+"))))#+がきたら分割する
    return dfs(i+1,f + s[i+1]) + dfs(i+1,f + "+" + s[i+1])

#イメージとしては1文字目を計算して、2文字目を追加する時、+を追加するかしないかを分けて考えるイメージ
print(dfs(0,s[0]))
        

Measured memory_bytes: 3060
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll len, sum = 0;
        cin>>len;
        vector<ll> arr(len);
        for(auto &i:arr) cin>>i;
        sum = accumulate(arr.begin(),arr.end(),0);
        ll now_sum = 0; ll ans = sum;
        for(auto i=0; i<len; i++){
            now_sum += arr[i];
            ans = min(ans,abs(now_sum - (sum - now_sum)));
        }
        cout<<ans;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

int n,pos;
int sumv[55];

struct node
{
	string title;
	int time;
}song[55];

int main()
{
	string s;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>song[i].title>>song[i].time;
		if (i==1)  sumv[i]=song[i].time;
		else sumv[i]=sumv[i-1]+song[i].time;
	} 
	cin>>s;
	for (int i=1;i<=n;i++)
	{
		if (song[i].title==s)
		{
			pos=i;
			break;
		}
	}
	cout<<sumv[n]-sumv[pos]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a==b && b==c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1000000000;
const int MOD = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };



int main()
{

	ll i,j,k,l,m,flag,cc,sum,N,M;
	flag = 0;
	sum = 0;
	cin >> N;
	vector<ll>A(N);
	vector<ll>B(N);
	vector<ll>C(N);
	vector<pair<ll, ll>>D(N);
	REP(i, 0, N) {
		cin >> A[i] >> B[i];
		C[i] = A[i] + B[i];
		D[i].first = C[i];
		D[i].second = i;
	}
	sort(D.begin(), D.end());
	cc = 0;
	ll ansA;
	ll ansB;
	ll ans;
	ansA = 0;
	ansB = 0;
	for (i = N - 1; i >= 0; i--) {
		cc++;
		if (cc % 2 == 1) {
			ansA += A[D[i].second];
		}
		else {
			ansB += B[D[i].second];
		}
	}
	output(ansA - ansB);
	
	return 0;
}





Measured memory_bytes: 4224
//Problem:
//Date:
//Skill:
//Bug:
/////////////////////////////////////////Definations/////////////////////////////////////////////////
//循环控制
#define CLR(a) memset((a),0,sizeof(a))
#define F(i,a,b) for(int i=a;i<=int(b);++i)
#define F2(i,a,b) for(int i=a;i>=int(b);--i)
#define RE(i,n)  for(int i=0;i<int(n);i++)
#define RE2(i,n) for(int i=1;i<=int(n);i++)
//输入输出
#define PII pair<int,int>
#define PB push_back
#define ENDL '\n'
#define x first
#define y second
typedef long long ll;
using namespace std;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
////////////////////////////////////////Options//////////////////////////////////////////////////////
#define stdcpph
#define CPP_IO

#ifdef stdcpph
#include<bits/stdc++.h>
#else
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#ifdef CPP_IO
#include<iostream>
#include<iomanip>
#include<string>
#else
#include<stdio.h>
#endif
#endif
////////////////////////////////////////Basic Functions//////////////////////////////////////////////
template<typename INint>
inline void IN(INint &x)
{
	x = 0; int f = 1; char c; cin.get(c);
	while (c<'0' || c>'9') { if (c == '-')f = -1; cin.get(c); }
	while (c >= '0'&&c <= '9') { x = x * 10 + c - '0'; cin.get(c); }
	x *= f;
}
template<typename INint>
inline void OUT(INint x)
{
	if (x > 9)OUT(x / 10); cout.put(x % 10 + '0');
}
////////////////////////////////////////Added Functions//////////////////////////////////////////////
const int maxn = int(2e5+10);
char a[maxn];
int BlaL[maxn], WhiR[maxn];

////////////////////////////////////////////Code/////////////////////////////////////////////////////
int main()
{
	//freopen("C:\\Users\\VULCAN\\Desktop\\data.in", "r", stdin);
	int T(1), times(0);
#ifdef CPP_IO// CPP_IO
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//cin >> T;
#else
	//IN(T);
#endif 
	/////////////////////////////////////////////////////////////////////////////////////////////////
	while (++times, T--)
	{
		ll a, b, c; cin >> a >> b >> c;
		if (a > b)swap(a, b);
		cout << (c<b&&c>a ? "Yes" : "No") << ENDL;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m;
    cin >> n >> m;
    int sum = 0;
    while(m--){
        int x;
        cin >> x;
        sum += x;
    }
    if(sum>n){
        cout << -1 << endl;
    }else{
        cout << n-sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
# coding:utf-8
from fractions import gcd

def calc_lcm(a, b):
    return (a * b) // gcd(a, b)

N = int(input())
A = [int(n) for n in input().split(' ')]
div_n = 10 ** 9 + 7
min_a = min(A)
lcm = A[0]

for a in A:
    lcm = calc_lcm(lcm, a)

if min_a == lcm:
    print((1*N) % div_n)
else:
    stack = 0
    for a in A:
        stack += lcm // a
    print(stack % div_n)


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

class UF{
  vi p,r;

public:
  UF(int n):p(n,-1),r(n,0){ }

  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }

  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }

  bool same(int x,int y){return find(x)==find(y);}
};

int memo[1001][1001][2];

int rec(int odd, int even, int edges){
  if(memo[odd][even][edges]>=0)return memo[odd][even][edges];
  if(odd + even == 2)return edges;

  int res = 1;
  if(edges)res *= rec(odd, even, 1-edges);
  if(odd && even)res *= rec(odd, even-1, 1-edges);
  if(odd >= 2)res *= rec(odd-2, even+1, edges);
  if(even >= 2)res *= rec(odd, even-1, 1-edges);

  return memo[odd][even][edges] = 1-res;
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int n;
  cin >> n;
  UF uf(n);

  string s[1010];
  int num = 0;
  rep(i,n){
    cin >> s[i];
    rep(j,i)if(s[i][j] == 'Y')uf.unite(i,j), num--;
  }

  vi card(n,0);
  rep(i,n)card[uf.find(i)]++;
  
  int odd = 0, even = 0;
  rep(i,n){
    if(card[i]){
      if(card[i] & 1)odd++;
      else even++;
      num += card[i]*(card[i]-1)/2;
    }
  }

  memset(memo,-1,sizeof(memo));
  if(rec(odd, even, num&1))cout << "Taro" << endl;
  else cout << "Hanako" << endl;
}

Measured memory_bytes: 10228
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long i,j,l,a,r=0,dr,iu,k;
    char s[16];
    scanf("%s",s);
    l=strlen(s);
    a=llpow(2,l-1);
    for(i=0;i<a;i++){
        dr=0;iu=1;k=1;
        for(j=l-1;j>=0;j--){
            dr+=((s[j]-'0')*k);
            //printf("<%lld %lld %lld>",i,iu,i&iu);
            k*=10;
            if((i&iu) != 0){k=1;}
            //printf("[%lld]",k);
            iu*=2;
        }
        r+=dr;
        //printf("%lld\n",dr);
    }
    printf("%lld\n",r);
    return 0;
}

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

int main() {
	int N, T;
	cin >> N >> T;
	vector<int> t(N);
	for (int i = 0; i < N; i++) cin >> t[i];
	long long X = 0;
	for (int i = 0; i < N-1; i++) {
		X += min(T, t[i+1]-t[i]);
	}
	cout << X+T << endl;
}


Measured memory_bytes: 1024
import Control.Applicative

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- getInts
  print $ solve ns

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: [Int] -> Int
solve xs = foldl1 (\acc b -> (b `div` (gcd acc b))* acc) xs

Measured memory_bytes: 3680
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[]pre = new int[N];
        int ans = 0;

        for (int i = 0; i < N; i++) {
			pre[i] = sc.nextInt();
		}
        sc.close();
        Arrays.sort(pre);
        
        for (int i = 0; i < N; i++) {
			if(i != N-1) {
				ans += pre[i];
			}else {
				ans += pre[i]/2;
			}
			
		}
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&c<=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
int x,y;
while(scanf("%d%d",&x,&y)!=EOF)
{
    if(x%3==0)
    printf("Possible\n");
    else
	if(y%3==0)
	printf("Possible\n");
	else
	if((x+y)%3==0)
    printf("Possible\n");
     else 
	printf("Impossible\n");
	

}


return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
int kaijo(int n) {
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		ans *= i;
		ans %= mod;
	}
	return ans;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b % 2)return modpow(a, b - 1)*a%mod;
	return modpow(a, b / 2)*modpow(a, b / 2) % mod;
}
int n, a[111111], b[111111], ans, k;
signed main() {
	cin >> n;
	k = kaijo(n);
	rep(i, n)cin >> a[i];
	for (int i = 1; i <= n; i++) {
		b[i] = modpow(i, mod - 2);
		b[i] *= k;
		b[i] %= mod;
		b[i] += b[i - 1];
		b[i] %= mod;
	}
	rep(i, n) {
		ans += a[i] * b[n - i] + a[i] * b[i + 1] - a[i] * b[1];
		ans %= mod;
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] dish = new int[5];
		for(int i = 0; i < 5; i++){
			int d = sc.nextInt();
			dish[i] = d;
		}
		int minid = 0;
		int min = 10;
		for(int i = 0; i < 5; i++){
			if(dish[i]%10 != 0){	
				if(dish[i]%10 < min){
					min = dish[i]%10;
					minid = i;
				}
			}	
		}
		int sum = 0;
		for(int i = 0; i < 5; i++){
			if(i == minid){
				sum += dish[i];
			}else{
				sum += ((dish[i] + 9)/10*10);
			}
		}
		System.out.println(sum);
	}
}

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

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

const long long INF = 1LL << 60;

int main(void){
	cout.precision(15);
	double n;cin >> n;
	n = n/3.0;
	cout <<  n*n*n << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <time.h>
#include <cassert>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    clock_t start = clock();

    ll N, K;
    cin >> N >> K;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    Rep (j, K) {
        vec cnt(N+1, 0);
        Rep (i, N) {
            cnt[max<ll>(0, i-A[i])]++;
            cnt[min<ll>(N, i+A[i]+1)]--;
        }
        ll tmp = 0;
        Rep (i, N) {
            A[i] = tmp + cnt[i];
            tmp += cnt[i];
        }

        bool flag = true;
        Rep (i, N) {
            if (A[i] < N) {
                flag = false;
            }
        }

        if (flag) break;

        assert((clock()-start)/CLOCKS_PER_SEC < 3);
    }

    printvec(A);
}

Measured memory_bytes: 6424
use io::*;
use std::cmp::{max, min};

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: f64 = sc.next();
    let m: f64 = sc.next();
    let d: f64 = sc.next();

    let ans = (n - d) * (if d == 0.0 { 1.0 } else { 2.0 }) / (n * n) * (m - 1.0);

    println!("{:.12}", ans);
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        N: usize, W: usize,
        wv: [(usize, i64); N]
    }

    let mut vals = vec![Vec::new(); 4];
    let w0 = wv[0].0;
    for &(w, v) in &wv {
        vals[w - w0].push(v);
    }
    for v in &mut vals {
        v.sort();
        v.reverse();
    }

    let ans = rec(3, N, w0, W, &vals);
    println!("{}", ans);
}

fn rec(cur: usize, rest: usize, base: usize, lim: usize, vals: &[Vec<i64>]) -> i64 {
    if cur == 0 {
        let num = min(rest, lim / base);
        return vals[0].iter().take(num).sum();
    }

    let num_lim = min(rest, lim / (base + cur));
    let mut res = 0;
    for num in 0..=num_lim {
        let res1: i64 = vals[cur].iter().take(num).sum();
        res = max(res, res1 + rec(cur - 1, rest - num, base, lim - num * (base + cur), vals));
    }
    res
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

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

    vector<ll> s(n + 1);
    s[0] = 0;
    rep(i, 0, n)
        s[i + 1] = s[i] + a[i];

    sort(s.begin(), s.end());
    ll ans = 0;
    for (int i = 0; i < s.size();)
    {
        ll now = s[i];
        ll cnt = 0;
        for (i; i < s.size() and s[i] == now; i++)
            ++cnt;
        ans += cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


class UnionFind():
    def __init__(self, n):
        """
        Parameters
        ----------
        n:int
            the number of node
        """
        self.par = [-1] * n  # -self.par[i] means the tree size

    def find(self, x):
        """
        Parameters
        ----------
        x:int
            target node

        Return
        ----------
        res:int
            root node
        """
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.par[x] > self.par[y]:  # lesser has many nodes
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        '''
        Parameters
        ----------
        x:int
            target node

        Return
        ----------
        x:int
            size of  group  to which belongs
        '''
        return - self.par[self.find(x)]


n, m = inpl()
uf1 = UnionFind(n)
for _ in range(m):
    a, b = inpl()
    uf1.union(a - 1, b - 1)
for i in range(n):
    uf1.find(i)  # 一周findすることによって接続漏れをなくす。
dp = [1] * n
for i in uf1.par:
    if i >= 0:
        dp[i] += 1
print(max(dp))


Measured memory_bytes: 76368
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
l = [0]*(max(A)+1)
l[1]=1
for a in A:
  if a==1:
    continue
  x=0
  while a%2==0:
    a//=2
    x+=1

  l[2]=max(l[2],x)
  
  f = 3
  while f**2<=a:
    x = 0
    while a%f==0:
      a//=f
      x+=1
    l[f]=max(l[f],x)
    f+=2
    
  if a!=1:
    l[a]=max(l[a],1)
    
b = 1
for i,x in enumerate(l):
  b*=pow(i,x,mod)
  b%=mod
  
ans = 0
for a in A:
  ans+=(b*pow(a,mod-2,mod))%mod
  ans%=mod
  
print(ans%mod)

Measured memory_bytes: 53228
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int A[51],B[51];
bool F[51];
vector<int> G[51];


void dfs(int s){
	F[s]=true;
	REP(i,G[s].size()){
		int e=G[s][i];
		if(F[e]==false){
			dfs(e);
		}
	}
}

signed main(){
	cin>>N>>M;
	REP(i,M){
		cin>>A[i]>>B[i];
		A[i]--,B[i]--;
	}
	int ans=0;
	REP(i,M){
		REP(j,51){
			G[j].clear();
			F[j]=false;
		}
		REP(j,M){
			if(i==j)continue;
			G[A[j]].push_back(B[j]);
			G[B[j]].push_back(A[j]);
		}
		dfs(0);
		bool flag=true;
		REP(j,N){
			if(F[j]==false)flag=false;
		}
		if(flag==false){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
struct bian{
	int next,point;
}b[210000];
int n,m,p[110000],len,pd[110000],num[2],flag=0,w[110000];
void add(int k1,int k2){
	b[++len]=(bian){p[k1],k2}; p[k1]=len;
}
void ade(int k1,int k2){
	add(k1,k2); add(k2,k1);
}
void dfs(int k1,int k2){
	num[k2]++; pd[k1]=1; w[k1]=k2;
	for (int i=p[k1];i;i=b[i].next){
		int j=b[i].point;
		if (pd[j]==0){
			dfs(j,k2^1);
		} else if (w[j]==w[k1]) flag=1;
	}
}
int main(){
	scanf("%d%d",&n,&m); long long ans=0;
	for (int i=1;i<=m;i++){
		int k1,k2; scanf("%d%d",&k1,&k2); ade(k1,k2);
	}
	for (int i=1;i<=n;i++)
		if (pd[i]==0){
			flag=0;num[0]=num[1]=0; dfs(i,0);
			//cout<<num[0]<<" "<<num[1]<<endl;
			if (flag){
				num[0]+=num[1]; ans+=1ll*(num[0])*(num[0]-1)/2;
			} else ans+=1ll*num[0]*num[1];
		}
	cout<<ans-m<<endl;
}

Measured memory_bytes: 3584
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var v = cin.ReadIntArray(N);
            double[] doubleV = new double[N];
            for (int i = 0; i < N; i++)
            {
                doubleV[i] = (double)v[i];
            }

            Array.Sort(doubleV);

            double[] guzai = new double[N];

            guzai[0] = doubleV[0];
            // guzai[1] = makeGuzai(guzai[0], doubleV[1]);
            // guzai[2] = makeGuzai(guzai[1], doubleV[2]);

            for (int i = 1; i < N; i++)
            {
                guzai[i] = makeGuzai(guzai[i - 1], doubleV[i]);
            }

            Console.WriteLine(guzai[N - 1]);

        }

        public double makeGuzai (double a, double b)
        {
            return (a + b) / 2.0;
        }

    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
using ping = pair<ll, ll>;

int main() { 
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    for (int i = 1;; i++){
        if(i%2==1){
          C -= B;
          if(C<=0){
              cout << "Yes" << endl;
              return 0;
          }
        }
        else{
            A-=D;
            if(A<=0){
                cout << "No" << endl;
                return 0;
            }
        }
    } return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

ll e;

int main()
{
    while (cin >> e)
    {
        if (e == 0)
            return 0;

        ll ans = infll;
        for (ll z = 0; z * z * z <= e; z++)
        {
            for (ll y = 0; y * y <= e; y++)
            {
                if (e - y * y - z * z * z < 0)
                    break;
                ll x = e - y * y - z * z * z;
                ans = min(ans, x + y + z);
            }
        }
        cout << ans << "\n";
    }
}


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

int main(){
  string A,B;
  cin >> A >> B;

  vector<int>x(2);
  cin >> x.at(0) >> x.at(1);

  string color;
  cin >> color;

  if(color == A){ 
    cout << x.at(0) -1 << " " << x.at(1) << endl;
  } else { 
    cout << x.at(0) << " " << x.at(1) -1 << endl;
  }

}

Measured memory_bytes: 256
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    v = N

    ans = ''

    while v > 0:
        d, m = divmod(v, 26)
        if m == 0:
            d -= 1
            m = 26
        ans = chr(m + 96) + ans
        v = d

    return ans


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include<stdio.h>
int main(){
  int n,p[300][2],r,l,u,d,s,t,a,b,i;
  int X[]={-1,0,1,0};
  int Y[]={0,-1,0,1};
  while(scanf("%d",&n),n){
    r=l=u=d=p[0][0]=p[0][1]=0;
    for(i=1;i<n;i++){
      scanf("%d %d",&a,&b);
      p[i][0]=p[a][0]+X[b];
      p[i][1]=p[a][1]+Y[b];
      if(p[i][0]<l)l=p[i][0];
      if(p[i][0]>r)r=p[i][0];
      if(p[i][1]>u)u=p[i][1];
      if(p[i][1]<d)d=p[i][1];
    }
    printf("%d %d\n",r-l+1,u-d+1);
  }
  return 0;
}
 

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
int t[110],v[110];
int vl[40010],vr[40010];
double dp[40010][210];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  REP(i,N) cin >> t[i], t[i] *= 2;
  REP(i,N) cin >> v[i], v[i] *= 2;
  int c = 0;
  vl[c] = 0;
  REP(i,N) {
    vr[c++] = v[i];
    REP(j,t[i]-1) {
      vl[c] = vr[c] = v[i];
      c++;
    }
    vl[c] = v[i];
  }
  vr[c] = 0;

  fill_n((double*)dp,40010*110,-INF);
  dp[0][0] = 0;
  REP(i,c) REP(j,210) if (dp[i][j] != -INF) {
    if (j <= vl[i+1] && j <= vr[i+1]) CHMAX(dp[i+1][j],dp[i][j]+j);
    if (j+1 <= vl[i+1] && j+1 <= vr[i+1]) CHMAX(dp[i+1][j+1],dp[i][j]+j+0.5);
    if (0 <= j-1 && j-1 <= vl[i+1] && j-1 <= vr[i+1]) CHMAX(dp[i+1][j-1],dp[i][j]+j-0.5);
  }
  cout << dp[c][0]/4 << endl;

  return 0;
}

Measured memory_bytes: 66560
using System;
using System.Collections.Generic;
using System.Linq;

/*

  Points/Vectors - Projection
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A

  ?????????????°???±????±?????????????
  ??¨???: Vec2f ??? float ??§?¨????????????¨???????????????

 */

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    // a, b ????????´??????????????????p ????????????????°???±?????????????±???????
    static void Calc(Vec2f p, Vec2f a, Vec2f b) {
        var ab = b - a;
        var ap = p - a;

        var d = ab.Normalized().Dot(ap);
        var m = a + ab.Normalized() * d;

        var pm = m - p;
        var px = 2 * pm;
        var x = p + px;
        Console.WriteLine("{0:f8} {1:f8}", x.X, x.Y);
    }

    static void Main() {
        var xs = ReadInts();
        var p1 = new Vec2f(xs[0], xs[1]);
        var p2 = new Vec2f(xs[2], xs[3]);

        int q = ReadInt();
        for (int i = 0; i < q; i++) {
            var xy = ReadInts();
            var p = new Vec2f(xy[0], xy[1]);
            Calc(p, p1, p2);
        }
    }
}

struct Vec2f {
    public double X { get; private set; }
    public double Y { get; private set; }

    public Vec2f(double x, double y) : this() {
        X = x;
        Y = y;
    }

    public override string ToString() {
        return string.Format("({0}, {1})", X, Y);
    }

    public static Vec2f operator+(Vec2f a, Vec2f b) {
        return new Vec2f(a.X + b.X, a.Y + b.Y);
    }

    public static Vec2f operator-(Vec2f a, Vec2f b) {
        return new Vec2f(a.X - b.X, a.Y - b.Y);
    }

    public static Vec2f operator*(Vec2f a, double t) {
        return new Vec2f(a.X * t, a.Y * t);
    }

    public static Vec2f operator*(double t, Vec2f a) {
        return new Vec2f(a.X * t, a.Y * t);
    }

    // a???b = |a||b|cos??
    public double Dot(Vec2f other) {
        return X * other.X + Y * other.Y;
    }

    public double Cross(Vec2f other) {
        return X * other.Y - Y * other.X;
    }

    public Vec2f Normalized() {
        var m = Magnitude();
        if (m != 0 && m != 1) {
            return new Vec2f(X / m, Y / m);
        }
        return this;
    }

    public double Magnitude() {
        return Math.Sqrt(X * X + Y * Y);
    }

    public double SqrMagnitude() {
        return X * X + Y * Y;
    }

    public static double Distance(Vec2f a, Vec2f b) {
        return (a - b).Magnitude();
    }
}

Measured memory_bytes: 9748
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  
  string s; cin>>s;
  int ans = 0;
  int len = 0;
  for (auto c : s) {
    if (c == 'A' or c == 'C' or c == 'G' or c == 'T') {
      len++;
      ans = max(ans, len);
    }
    else
      len = 0;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

using namespace std;


long long int factriolf(long long int n)
{
    long long int f,i;
    f = 1;
    for (i = 1; i<=n;i++)
    {
      f = f *i;
    }
    return f;
}

int main ()
{
    long long int n;
    scanf("%lld",&n);

long long int r = factriolf(n);

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

return 0;
}

Measured memory_bytes: 1024
import math
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [[]]
s = 1
for i in a:
  while i >= 2*s:
    s *= 2
    b.append([])
  b[-1].append(i-s)
while m > 0 and b != []:
  size = len(b[-1])
  for i in range(min(m,size)):
    if len(b) > 1:
      b[-2].append(b[-1].pop()//2)
    else:
      b[-1].pop()
  if len(b) > 1:
    b[-2].sort()
  if size <= m:
    b.pop()
  m -= size
ans = 0
for i in range(len(b)):
  ans += len(b[i])*(2**i)
  for j in b[i]:
    ans += j
print(ans)

Measured memory_bytes: 65764
#include <stdio.h>
int gcd(int a, int b){
    int tmp;
    if(a<b){
        tmp=b;
        b=a;
        a=tmp;
    }
    
    while(1) {
        a=a%b;
        tmp=b;
        b=a;
        a=tmp;
        if(b==0) break;
    }
    return a;
}

int main(void){
    int a,b;
    while(scanf("%d %d", &a, &b)!=EOF){
        
        int lcm=a/gcd(a,b)*b;
        
        printf("%d %d\n", gcd(a,b), lcm);
    }
    
}


Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    ll i;
    cin >> N;
    ll A[N];
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    ll ans=0;
    for(i=0;i<N;i++){
       if(A[A[i]-1]==i+1)ans++;
    }
    cout << ans/2;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i, n+1){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }

    int tmp;
    long long int cnt = 0;
    rep(i, n){
        if(a[i]<=b[i]){
            tmp = a[i];
            cnt += tmp;
            b[i] -= tmp;
            a[i] = 0;

            if(a[i+1] <= b[i]){
                tmp = a[i+1];
                cnt += tmp;
                b[i] -= tmp;
                a[i+1] = 0;
            }else{
                tmp = b[i];
                cnt += tmp;
                b[i] = 0;
                a[i+1] -= tmp;
            }
        }else{
            tmp = b[i];
            cnt += tmp;
            b[i] = 0;
            a[i] -= tmp;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024