akhauriyash/Code-Regression huggingface dataset:
a,b,c = map(int,input().split())
flag = 1
cnt = 0

if a == b == c and a % 2 == 0:
  print("-1")
else:
  while flag:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
      a,b,c = a/2 + b/2, b/2 + c/2, c/2 + a/2
      cnt += 1
    else:
      flag = 0
  print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m = n+1, cnt = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    if (m > p) {
      m = p;
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
n = int(input())
l ,r = 1, 1
for i in range(n):
    t, a = list(map(int, input().split()))

    k = max(l//t + 1 if l%t else l//t, r//a + 1 if r%a else r//a)
    l = t*k
    r = a*k
print(l+r)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int a;

int main(){
	cin >> a;
	if(a < 1200) cout << "ABC" << endl;
	else if(a < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
s = input()
q = int(input())
op = [input().split() for _ in range(q)]


flag = True
ans = deque(s)

for i in op:
    if i[0] == "1":
        flag = not flag
    else:
        if i[1] == "1":
            if flag:
                ans.appendleft(i[2])
            else:
                ans.append(i[2])
        else:
            if flag:
                ans.append(i[2])
            else:
                ans.appendleft(i[2])

if flag:
    while(ans):
        t = ans.popleft()
        print(t, end='')
else:
    while(ans):
        t = ans.pop()
        print(t, end='')


Measured memory_bytes: 121816
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int height[n];
    for (int i = 0; i < n; i++) cin >> height[i];

    for (int i = n - 2; i >= 0; i--) if (height[i] > height[i + 1]) --height[i];

    // for (int i = 0; i < n; i++) cout << height[i] << " ";
    // cout << endl;

    for (int i = 1; i < n; i++) {
        if (height[i] < height[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	while(cin>>a>>b)
	{
		cout<< (a-1)*(b-1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
module Main where

    import Debug.Trace

    solve :: Int -> Int -> Int -> Int
    solve a b n = iter a where
        iter x
            | x > b = 0
            | mod n x == 0 = 1 + iter (x+1)
            | otherwise = iter (x+1)

    readLine:: IO [Int]
    readLine = fmap (map read . words) getLine
    
    main :: IO() 
    main = do
        [a, b, n]    <- readLine
        let ans = solve a b n
        print ans
    


Measured memory_bytes: 4096
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;
int main(){
  int n;
  cin >> n;
  unordered_set<int> us;
  multiset<int> ms;
  for(int i = 0; i < n; ++i){
    int a;
    cin >> a;
    us.insert(a);
    ms.insert(a);
  }
  long long ans = 0;
  for(const auto& x: us){
    int cnt = ms.count(x);
    ans += (x <= cnt ? cnt - x : cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 8740
fignum = {"I"=>1, "V"=>5, "X"=>10, "L"=>50, "C"=>100, "D"=>500, "M"=>1000}
while gets
  sum = 0
  r = $_.chomp.split("")
  fb = r.shift
  r.each do |f|
    if fb[-1] != f
      sum+=fignum[fb[0]]*fb.size if fignum[fb[0]]>fignum[f]
      sum-=fignum[fb[0]]*fb.size if fignum[fb[0]]<fignum[f]
      fb = f
    else
      fb << f
    end
  end
  sum+=fignum[fb[0]]*fb.size
  p sum
end

Measured memory_bytes: 8560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	char buf[21];
	for(int n;scanf("%d ",&n),n;){
		vs lines(n);
		rep(i,n){
			gets(buf);
			lines[i]=buf;
		}
		
		vs tags(n);
		vi marks(n),isre(n);
		rep(i,n){
			int j=lines[i].size()-1;
			if(lines[i][j]=='v'){
				isre[i]=1;
				j--;
			}
			int k=j;
			while(k>=0 && isdigit(lines[i][k]))
				k--;
			k++;
			if(k<=j)
				marks[i]=atoi(lines[i].c_str()+k);
			tags[i]=lines[i].substr(0,k);
		}
		
		map<string,int> q;
		vi prev(n,-1);
		for(int i=n;i--;){
			if(marks[i]>0){
				int& cur=q[tags[i]];
				if(marks[i]>1)
					prev[i]=cur;
				cur=i;
			}
		}
		rep(i,n)
			if(isre[i])
				prev[i]=i+1;
		
		vvi paths;
		vi flgs(n);
		rep(i,n){
			if(flgs[i])
				continue;
			vi path;
			for(int j=i;j!=-1;j=prev[j]){
				path.push_back(j);
				flgs[j]=1;
			}
			reverse(allof(path));
			paths.push_back(path);
		}
		
		sort(allof(paths));
		
		vi perm(n);
		int k=0;
		rep(i,paths.size()) rep(j,paths[i].size())
			perm[k++]=paths[i][j];
		
		rep(i,n)
			printf("%d\n",perm[i]+1);
	}
	
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x, K;
    cin >> x >> K;
    x=x%K;
    ll min=x;
    if(min>x){
        min=x;
    }
    x=abs(x-K);
    if(min>x){
        min=x;
    }
    x=abs(x-K);
    if(min>x){
        min=x;
    }
    cout << min << endl;
}


Measured memory_bytes: 3632
#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;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n*a<=b) cout<<a*n<<endl;
	else cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
const int INF = 1e9;
//int m[3000];

ll memo[200005];

ll comb(ll x) {
	return x * (x - 1) / 2;
}

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n);
	rep(i, n) {
		ll buf;
		cin >> buf;
		buf--;
		a[i] = buf;
		b[buf]++;
	}
	
	ll sum(0);
	rep(i, n) {
		sum += comb(b[i]);
	}
	//cout << sum;
	rep(i, n) {
		ll ans = sum;
		ans -= comb(b[a[i]]);
		ans += comb(b[a[i]] - 1);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  string s;
  cin >> s;

  ll k;
  cin >> k;

  int index = 0;
  FORm(it, s) {
    if (*it != '1') {
      cout << *it << endl;
      return 0;
    }
    index++;
    if (index >= k) {
      break;
    }
  }

  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=2019;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

int main(){
  ll l,r;
  cin >> l >> r;
  if(l+2018<=r){
    cout << 0 << endl;
    return 0;
  }
  l%=MOD;
  r%=MOD;
  ll ans = 2018;
  ll num;
    for(ll i=l;i<=r-1;i++){
      for(ll j=i+1;j<=r;j++){
        num=i*j;
        num%=MOD;
        if(ans>num)ans=num;
      }
    }

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


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    set<int> ans;
    ans.insert(a);
    ans.insert(b);
    ans.insert(c);
    cout << ans.size() << 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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a == b && b ==c) {
            System.out.println("No");
        } else if(a != b && b != c && a != c) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
string s;
int main()
{
	int minn=1000,maxn=-2;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
			if(i<minn)
				minn=i;
		if(s[i]=='F')
			if(i>maxn)
				maxn=i;
	}
	if(minn<maxn)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 
 
 
const int N=2e5+100;
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;
vector<ll>edge[200000];
int visted[100][100][999];
vector<pair<ll,ll>>vv;
map<string,ll>mp;
int main()
{
  ll a,b,c,d;cin>>a>>b>>c>>d;ll cc=0;
  while(a>0&&c>0){
      if(cc%2==0){
          c-=b;
      }else{
          a-=d;
      }cc++;
  }if(a>0){
      cout<<"Yes";
  }else{cout<<"No";}
  /*
  for(int i=0;i<n;i++){cin>>a[i]>>b[i];}
  dp[0][a[0]]=b[0];
   for(int i=1;i<n;i++){
      for(int s=0;s<t-1;s++){
          dp[i][t+b[i]]=max( dp[i][t+a[i]], dp[i-1][t]+b[i]);
      }
       
   }*/
   
}

Measured memory_bytes: 8320
S = input()

left_counter = 0
right_counter = 0
before = 0
answer = 0

for i,s in enumerate(S):
    if s == "<":
        left_counter += 1
        if i == len(S)-1:
            answer += ((1+left_counter)*left_counter)/2
            break
    else:
        right_counter += 1
        if i == len(S)-1:
            answer += ((1+max(left_counter, right_counter))*max(left_counter, right_counter))/2
            answer += (min(left_counter, right_counter)*(min(left_counter, right_counter)-1))/2
            break
        elif S[i+1] == "<":
            answer += ((1+max(left_counter, right_counter))*max(left_counter, right_counter))/2
            answer += (min(left_counter, right_counter)*(min(left_counter, right_counter)-1))/2
            left_counter = 0
            right_counter = 0
print(int(answer))

Measured memory_bytes: 4116
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int[][string] m;
    string s;
    while ((s = readln.chomp) != null) {
        auto ss = s.split;
        auto name = ss[0];
        auto page = ss[1].to!int;

        m[name] ~= page;
    }

    foreach (k; m.keys.sort) {
        writeln(k);
        // auto v = m[k].sort.map!(to!string).array.join(" ");
        auto v = m[k].sort.to!(string[]).join(" ");
        writeln(v);
    }

}

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

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

Measured memory_bytes: 256
fun main(args: Array<String>) {
    while (true) {
        val x = readLine()!!.split(" ")
        val a = x[0].toInt()
        val op = x[1]
        val b = x[2].toInt()
        if (op == "?") break
        when (op) {
            "+" -> println(a + b)
            "-" -> println(a - b)
            "*" -> println(a * b)
            "/" -> println(a / b)
        }
    }
}


Measured memory_bytes: 31996
#include<cmath>
#include<queue>
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef pair<int,int> pii;

const double INF=1e77,EPS=1e-9;

struct Point{
	int x,y;
	Point operator-(const Point &p)const{ return (Point){x-p.x,y-p.y}; }
};

struct Edge{
	int j,v;
	double cost;
	bool warp;
};

struct Floor{
	int n;
	vector<Edge> adj[20];
};

int  dot (const Point &p,const Point &q){ return p.x*q.x+p.y*q.y; }
int cross(const Point &p,const Point &q){ return p.x*q.y-p.y*q.x; }

double norm2(const Point &p){ return dot(p,p); }

double dist(const Point &p,const Point &q){ return sqrt(norm2(p-q)); }

bool identify(int i,int j,const Floor *F,const Point P[50][20],int *sigma){
	if(F[i].n!=F[j].n) return false;

	int n=F[i].n;
	rep(a,n) rep(b,n) if(a!=b) {
		bool ok=true;
		rep(u,n){
			int v;
			for(v=0;v<n;v++){
				Point vec_i[2]={P[i][0]-P[i][u],P[i][1]-P[i][u]};
				Point vec_j[2]={P[j][a]-P[j][v],P[j][b]-P[j][v]};
				if(norm2(vec_i[0])==norm2(vec_j[0])
				&& norm2(vec_i[1])==norm2(vec_j[1])
				&&  dot (vec_i[0],vec_i[1])== dot (vec_j[0],vec_j[1])
				&& cross(vec_i[0],vec_i[1])==cross(vec_j[0],vec_j[1]))
					break;
			}
			if(v<n) sigma[u]=v;
			else    ok=false;
		}
		if(!ok) continue;

		bool adj_i[20][20]={},adj_j[20][20]={};
		rep(u,n) rep(k,F[i].adj[u].size()) {
			Edge e=F[i].adj[u][k];
			if(!e.warp) adj_i[u][e.v]=true;
		}
		rep(u,n) rep(k,F[j].adj[u].size()) {
			Edge e=F[j].adj[u][k];
			if(!e.warp) adj_j[u][e.v]=true;
		}

		rep(u,n) rep(v,n) if(adj_i[u][v]!=adj_j[sigma[u]][sigma[v]]) ok=false;
		if(!ok) continue;

		return true;
	}

	return false;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		Floor F[50];
		Point P[50][20];
		rep(i,n){
			scanf("%d",&F[i].n);
			rep(k,F[i].n) scanf("%d%d",&P[i][k].x,&P[i][k].y);
			int b; scanf("%d",&b);
			rep(k,b){
				int u,v; scanf("%d%d",&u,&v); u--; v--;
				F[i].adj[u].push_back((Edge){i,v,dist(P[i][u],P[i][v])});
				F[i].adj[v].push_back((Edge){i,u,dist(P[i][u],P[i][v])});
			}
			int c; scanf("%d",&c);
			rep(k,c){
				int u,j,v; scanf("%d%d%d",&u,&j,&v); u--; j--; v--;
				F[i].adj[u].push_back((Edge){j,v,0,true});
			}
		}
		int si,su,gi,gu; scanf("%d%d%d%d",&si,&su,&gi,&gu); si--; su--; gi--; gu--;

		rep(j,n) rep(i,j) {
			int sigma[20];
			if(identify(i,j,F,P,sigma)){
				rep(u,F[i].n){
					int v=sigma[u];
					F[i].adj[u].push_back((Edge){j,v,0,true});
					F[j].adj[v].push_back((Edge){i,u,0,true});
				}
			}
		}

		double d[50][20],ans=-1;
		rep(i,n) rep(u,20) d[i][u]=INF;
		d[si][su]=0;

		priority_queue< pair<double,pii> > pq;
		pq.push(make_pair(0,make_pair(si,su)));
		while(!pq.empty()){
			pair<double,pii> a=pq.top(); pq.pop();
			int i=a.second.first,u=a.second.second;
			if(d[i][u]+EPS<-a.first) continue;

			if(i==gi && u==gu){
				ans=d[gi][gu];
				break;
			}

			rep(k,F[i].adj[u].size()){
				Edge e=F[i].adj[u][k];
				double nextd=d[i][u]+e.cost;
				if(nextd+EPS<d[e.j][e.v]){
					d[e.j][e.v]=nextd;
					pq.push(make_pair(-nextd,make_pair(e.j,e.v)));
				}
			}
		}

		printf("%f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,m,k;
int a[N],b[N];
LL s[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m>>k;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=m;i++)cin>>b[i],s[i]=s[i-1]+b[i];
  int ans=0;
  for(int i=0;i<=n;i++){
    k-=a[i];
    if(k<0)break;
    int x=upper_bound(s+1,s+1+m,k)-s-1;
    ans=max(ans,i+x);
  }
  cout<<ans<<'\n';
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, W;
  IN(H,W);
  vvll dp(H, vll(W, 0));
  dp[0][0] = 1;

  vvb A(H, vb(W, true));

  REP(i,H){
    string str;
    IN(str);
    REP(j,W){
      if(str[j]=='#') A[i][j]=false;
    }
  }

  REP(i,H) REP(j,W){
    if(!A[i][j]) continue;
    if(i) dp[i][j] += dp[i-1][j];
    if(j) dp[i][j] += dp[i][j-1];
    dp[i][j] %= MOD;
  }

  OUT(dp[H-1][W-1]%MOD);

  return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll solve(int a[],int n,int s,int fl,ll dp[51][2501][2])
{
  ll cnt=0;
  if(s==0&&fl==1)
    cnt++;
  if(n==0)
    return cnt;
  if(dp[n][s][fl]!=-1)
    return dp[n][s][fl];
  ll x = solve(a,n-1,s+a[n],1,dp);
  ll y = solve(a,n-1,s,0,dp);
  dp[n][s][fl] = cnt+x+y;
  return dp[n][s][fl];
}
int main()
{
    flash;
    //sieve();
    int T=1,n,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n>>k;
        int a[n+1];
        ll dp[51][2501][2];
        FOR(i,0,51)FOR(j,0,2501)  dp[i][j][0]=dp[i][j][1]=-1;
        FOR(i,1,n+1){
          cin>>a[i];
          a[i] -= k;
        }
        ll cnt = solve(a,n,0,0,dp);
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 5660
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = map(int, input().split())
    
    base = (M*1900) + ((N-M)*100)
    tmp = 1/(2**M)
    tmp = 1/tmp
    
    print(int(base*tmp))
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
 
};
signed main(){
    int n,m;cin>>n>>m;
    vector<int> a(m);
    vector<int> b(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    vector<int> res(m+1,0);res[m]=n*(n-1)/2;
    vector<int> par(n,1);
    UnionFind tree(n);
    for(int i=m-1;i>=0;i--){
        res[i]=res[i+1];
        if(tree.same(a[i],b[i])){
            continue;
        }
        else{
            int ra=tree.root(a[i]);
            int rb=tree.root(b[i]);
            res[i]-=par[ra]*par[rb];
            par[rb]+=par[ra];
            par[ra]=0;
            tree.unite(a[i],b[i]);
        }
    }
    rep1(i,m){
        cout<<res[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double dist(int[],int[],int,int);
int main(void)
{
  int *arr[2];
  int i,n;
  scanf("%d",&n);
  arr[0]=(int*)malloc(sizeof(int)*n);
  arr[1]=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) scanf("%d",&arr[0][i]);
  for(i=0;i<n;i++) scanf("%d",&arr[1][i]);
  printf("%f\n",dist(arr[0],arr[1],n,1));
  printf("%f\n",dist(arr[0],arr[1],n,2));
  printf("%f\n",dist(arr[0],arr[1],n,3));
  printf("%f\n",dist(arr[0],arr[1],n,-1));
  return 0;
}
double dist(int x[],int y[],int n,int p)
{
  int i;
  double d=0;
  double temp;
  if(p==-1)
    {
      for(i=0;i<n;i++)
        {
          temp=fabs(x[i]-y[i]);
          if(temp>d) d=temp;
        }
    }
  else
    {
      for(i=0;i<n;i++)
        {
          d+=pow(fabs(x[i]-y[i]),p);
        }
      d=pow(d,1.0/p);
    }
  return d;
}


Measured memory_bytes: 2084
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>

#define _USE_MATH_DEFINES

#include<math.h>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	double r;
	scanf("%lf", &r);
	printf("%.5lf %.5lf\n", M_PI*r*r, 2 * M_PI*r);
	return 0;
}

Measured memory_bytes: 2692
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		StringBuilder sb = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int x = x2 - x1;
		int y = y2 - y1;

		System.out.println((x2 - y) + " " + (y2 + x) + " " + (x1 - y) + " " + (y1 + x));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int inf=1e9+7;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	for(int i=0;i<2;i++)
	{
		int t;
		cin>>t;
		if(!(t%2))
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  string s;cin>>s;
  int n=s.length();
  int ma=0;
  int cnt=0;
  rep(i,n){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')cnt++;
    else cnt=0;
    chmax(ma,cnt);
  }
  cout<<ma<<endl;
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	string p(s.size(), 'x');
	cout << p << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,d,e,f,g,h,w;
 
ll x[800005],y[800005],z[900005];
char s[500005];

int main(){
    cin>>n>>k;
	if(n%k)p(1);
	if(!(n%k))p(0);

	return 0;


}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI mar;
VI avb;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,x;
  cin>>n>>x;
  mar.resize(2*n-1);
  if(x==1 || x==2*n-1){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<"\n";
  if(n==2){
    cout<<"1\n2\n3\n";
    return 0;
  }
  avb.resize(2*n,1);
  avb[x]=avb[x-1]=avb[x+1]=0;
  if(x<=n){
    mar[n-1]=x;
    mar[n-2]=x-1;
    mar[n-3]=x+1;
    mar[n]=x+2;
    avb[x+2]=0;
  }
  else{
    mar[n-1]=x;
    mar[n-2]=x+1;
    mar[n-3]=x-1;
    mar[n]=x-2;
    avb[x-2]=0;
  }
  in nxt=1;
  forv(i,mar){
    if(mar[i])
      continue;
    while(!avb[nxt])
      ++nxt;
    mar[i]=nxt++;
  }
  forv(i,mar)
    cout<<mar[i]<<"\n";
  return 0;
}


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

long long n, ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(long long i=1; i*i<=n; ++i){
		if(n % i != 0) continue;
		long long j = n / i;
		if(j < i - 1) ans += i - 1;
		if(j != i && i < j - 1) ans += j - 1;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(Math.abs(a - b) <= W) {
			System.out.print(0);
		}
		else {
			System.out.print(Math.abs(a - b) - W);
		}
	}

}


Measured memory_bytes: 23380
n=int(input())
count=0
dic={}
ppp=""
for i in range(n):
  s=list(input())
  s.sort()
  s=ppp.join(s)
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
kouho=0
for j in range(len(dic)):
  kk=dic.popitem()
  c=kk[1]
  kouho+=(c*(c-1))//2
print(kouho)
  
  

Measured memory_bytes: 17932
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int n = reader.ni();
		int[][] dis = new int[n][2];
		for (int i=0; i<n; i++) {
			dis[i][0] = reader.ni();
			dis[i][1] = reader.ni();
		}

		int[] arr = new int[n];
		for (int i=0; i<n; i++)arr[i] = i;

		int u = 0;

		double res = 0.0;
		do {
			u++;
			for (int i=0;i<n-1;i++) {
				int a = arr[i], b = arr[i+1];
				long dx = dis[b][0] - dis[a][0];
				long dy = dis[b][1] - dis[a][1];
				double t = Math.sqrt(dx*dx + dy*dy);
				// res +=  (((t * (n-1) ) * (n-1)) / fact);
				res += t;
				// System.out.print(array[i]);
			}
			// System.out.println();
		} while (nextPermutation(arr));

		// long fact = 1;
		// for (long i=2; i<=n; i++) {
		// 	fact *= i;
		// }
		//
		// double total_dist = 0.0;
		// double res = 0.0;
		// for (int i=0; i<n; i++) {
		// 	for (int j=i+1; j<n; j++) {
		// 		long dx = dis[j][0] - dis[i][0];
		// 		long dy = dis[j][1] - dis[i][1];
		// 		// System.out.println(dx + " " + dy);
		// 		double t = Math.sqrt(dx*dx + dy*dy);
		// 		// res +=  (((t * (n-1) ) * (n-1)) / fact);
		// 		res += t;
		// 		// System.out.println(t);
		// 	}
		// }

		res /= u;
		// total_dist *= 2;
		// System.out.println("total = " + total_dist);

		// long fact = 1;
		// for (long i=2; i<=n; i++) {
		// 	fact *= i;
		// }

		// double res = 0.0;

		System.out.println(res);

		return;
	}

	public static boolean nextPermutation(int[] array) {
		if (array.length<=1) return false;
		int i = array.length-2;
		for(;i>=0&&array[i]>array[i+1];i--);
		if(i==-1)return false;
		int k =i+1;
		for(;k<array.length&&array[k]>array[i];k++);
		swap(array,i,k-1);
		Arrays.sort(array,i+1,array.length);
		return true;
	}

	public static void swap(int[] array, int i, int j) {
		int t = array[i];
		array[i] = array[j];
		array[j] =t;

	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 22484
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n = int(readline())

cnt = [0]*(n+1)

for i in range(1,n+1):
    for j in range(i,n+1,i):
        cnt[j] += 1
ans = 0
for i in range(1,n+1):
    ans += i*cnt[i]
print(ans)


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

bool isP(const string& S) {
    int n = S.size();
    for_(i,0,n/2) if (S[i] != S[n-i-1]) return false;
    return true;
}

int main() {
    string S;
    cin >> S;
    int n = S.size();
    if (isP(S) and isP(S.substr(0,n/2)) and isP(S.substr(n/2+1,n/2))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int X;
    cin >> X;
    int glad, num_bg, num_sg;
    num_bg = X / 500;
    num_sg = (X % 500) / 5;
    glad = num_bg * 1000 + num_sg * 5;
    cout << glad << endl;
    return 0;
}


Measured memory_bytes: 256
def kezl(xlist):
    lenx=len(xlist)
    news=[]
    for i in range(lenx-1):
        news.append(abs(xlist[i+1]-xlist[i]))
    return news

flist=[]

import math
n=int(input())
alist=input()
blist=[]
swit=0
for i in range(n-1):
    now=abs(int(alist[i+1])-int(alist[i]))
    if now==1:
        swit=1
    blist.append(now)
#print(blist)
if swit==1:
    for i in range(n-1):
        if blist[i]==2:
            blist[i]=0
    #print(blist)
    dekai=100
    while len(blist)>1:
        clist=[]
        dekai=math.floor(math.log(len(blist),2))
        katamari=2**dekai
        kosu=len(blist)-katamari+1
        nanko=0
        for i in range(katamari):
            if blist[i]==1:
                nanko+=1
        clist.append(nanko%2)
        for i in range(kosu-1):
            nanko+=blist[katamari+i]-blist[i]
            clist.append(nanko%2)
        blist=clist
        #print(blist)
    print(blist[0])
else:
    for i in range(n-1):
        if blist[i]==2:
            blist[i]=1
    #print(blist)
    dekai=100
    while len(blist)>1:
        clist=[]
        dekai=math.floor(math.log(len(blist),2))
        katamari=2**dekai
        kosu=len(blist)-katamari+1
        nanko=0
        for i in range(katamari):
            if blist[i]==1:
                nanko+=1
        clist.append(nanko%2)
        for i in range(kosu-1):
            nanko+=blist[katamari+i]-blist[i]
            clist.append(nanko%2)
        blist=clist
        #print(blist)
    print(blist[0]*2)

Measured memory_bytes: 116432
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n],b[n],c[n],ans=0;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][3];
    dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
    	for(int j=0;j<3;j++)
    	{
    		if(j==0)
    		{
    			dp[i][j]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    		}
    		if(j==1)
    		{
    			dp[i][j]=b[i]+max(dp[i-1][0],dp[i-1][2]);
    		}
    		if(j==2)
    		{
    			dp[i][j]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    		}
    	}
    }
    for(int i=0;i<3;i++)
    {
    	ans=max(ans,dp[n-1][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6000
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

using namespace std;

int main(){
    ll n;
    ll tmp=1;

    cin >> n;

    ll i=sqrt(n);
    for(;i>=1;i--){
        if(n%i==0){
            tmp=n/i;
            break;
        }
    }
    cout << tmp+i-2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,n,flag=0,s,i,sum=0;
    scanf("%d%d",&h,&n);
    for(i=0;i<n;i++){
        scanf("%d",&s);
        sum+=s;
        if(h<=sum){
            flag=1;
        }
    }
    if(flag==1)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)1e5+5;
pair<LL, LL> store[MAX];
LL dpl[MAX];
LL dpr[MAX];
int main(void){
	int n; LL c; scanf("%d %lld", &n, &c);
	rep1(i, 1, n+1) scanf("%lld %lld", &store[i].F, &store[i].S);
	LL cur = 0, x = 0;
	rep1(i, 1, n+1){
		cur += x - store[i].F + store[i].S;
		dpl[i] = max(dpl[i-1], cur);
		x = store[i].F;
	}
	cur = 0; x = c;
	per1(i, n, 1){
		cur += store[i].F - x + store[i].S;
		dpr[i] = max(dpr[i+1], cur);
		x = store[i].F;
	}
	LL ans = 0;
	rep1(i, 1, n+1) ans = max(ans, dpl[i]);
	rep1(i, 1, n+1) ans = max(ans, dpr[i]);
	per1(i, n, 1) ans = max(ans, dpr[i] + dpl[i-1] - (c - store[i].F));
	rep1(i, 1, n+1) ans = max(ans, dpl[i] + dpr[i+1] - store[i].F);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, k;
    cin >> k >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
    	cin >> v[i];
    int mn = INF;
    for(int i = 0; i < n; i++)
    {
    	int prev = (i - 1 + n) % n;
    	mn = min((v[prev] - v[i] + k) % k, mn);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 1792
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int fact[int(2e5+1)];
int inv[int(2e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA  
   int n;cin>>n;
   int arr[n];
   for(int i=0;i<n;++i)cin>>arr[i];
   int sum=accumulate(arr,arr+n,0);
   int val=sum/n;
  
    int ans1=0;
    for(int x:arr)ans1+=((x-val)*(x-val));
    ++val;
    int ans2=0;
    for(int x:arr)ans2+=((x-val)*(x-val));
      cout<<min(ans1,ans2)<<endl;
  


}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <math.h>
using namespace std;

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

 if(1 <= A && 9 >= A && 1 <= B && 9 >= B){
     cout << A*B << endl;
 }else{
     cout << "-1" << endl;
 }
 return 0;
}

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

const double pi=acos(-1.0);

int main(){
   double a,b,h,m;
   scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
   h=h*60+m;
   double angh=360*h/720;
   double angm=360*m/60;
   if(angh<angm){
    swap(angh,angm);
   }
   double diff;
   if(angh-angm>180){
    diff=360-(angh-angm);
   }else diff=angh-angm;
   printf("%.30lf",sqrt(a*a+b*b-2*a*b*cos(diff/180*pi)));
    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

vector<vector<ll>> a(100001);//隣接リスト(添え字は始点、値は終点)
vector<ll>t(100001);//訪問したかどうか
vector<ll>ret1;
vector<ll>ret2;
void dfs1(ll k, ll f){
  t[k]=1;
  ret1.push_back(k+1);
  for(ll i=0;i<a[k].size();i++){
    if(t[a[k][i]]==0){
      dfs1(a[k][i],k); 
      return;
    }
  }
}
void dfs2(ll k, ll f){
  t[k]=1;
  ret2.push_back(k+1);
  for(ll i=0;i<a[k].size();i++){
    if(t[a[k][i]]==0){
      dfs2(a[k][i],k); 
      return;
    }
  }
}


int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  for(i=0;i<m;i++){
    ll p,q;
    cin>>p>>q;
    a[p-1].push_back(q-1);
    a[q-1].push_back(p-1);
  }
  dfs1(0,-1);
  dfs2(0,-1);
  cout<<ret1.size()+ret2.size()-1<<endl;
  reverse(ALL(ret2));
  for(i=0;i<ret2.size()-1;i++)cout<<ret2[i]<<" ";
  for(i=0;i<ret1.size();i++)cout<<ret1[i]<<" ";
  cout<<endl;


  return 0;
}

Measured memory_bytes: 10868