akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    vector<int> L(N);
    for(int i = 0; i < N; i++)
    {
        cin >> L[i];
    }

    vector<int> D(N+1);
    int cnt;
    D[0] = 0;
    for (cnt = 1; cnt < N+1; cnt++)
    {
        D[cnt] = D[cnt-1] + L[cnt-1];
        
        if(D[cnt] > X)
            break;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  set<int> as;
  F0R(i, N) {
    int a;
    cin >> a;
    as.insert(a);
  }

  cout << (as.size() == N ? "YES" : "NO");
}
#endif


Measured memory_bytes: 9600
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    for i in range(n, 1000):
        b = True
        s = str(i)
        t = ""
        for j in range(len(s)):
            if t == "":
                t = s[j]
            else:
                if t != s[j]:
                    b = False
                    break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N, W;
  cin >> N >> W;
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  for (int i = 0; i < N; i++) {
    int w, v;
    cin >> w >> v;
    for (int j = 0; j <= W; j++) {
      if (j >= w)
        dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j]);
      else
        dp[i + 1][j] = dp[i][j];
    }
  }
  cout << dp[N][W] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 80256
s = input()

if s[0] == 'A' and s[2:-1].count('C') == 1:
    for i in s:
        if i.islower() == True:
            continue
        elif i == 'A' or i == 'C':
            continue
        else:
            print('WA')
            exit()
else:
    print('WA')
    exit()

print('AC')

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

const int MAX = 100001;

typedef pair<int,int> P;

class UnionFind{
  P par[MAX];
  int rank[MAX];

public:
  UnionFind(int n = MAX){
    clear(n);
  }

  void clear(int n = MAX){
    for(int i=0;i<n;i++){
      par[i] = P(i,0);
      rank[i] = 0;
    }
  }

  P find(int x){
    if(par[x].first == x) return par[x];
    else {
      P res = find(par[x].first);
      return par[x] = P(res.first, res.second + par[x].second);
    }
  }

  void unite(int x, int y, int cost){
    P px = find(x);
    P py = find(y);
    if(px.first == py.first) return;
    if(rank[px.first] < rank[py.first]) {
      par[px.first] = P(py.first, py.second - px.second - cost);
    }
    else{
      par[py.first] = P(px.first, px.second - py.second + cost);
      if(rank[px.first] == rank[py.first]) rank[px.first]++;
    }
  }

  bool same(int x, int y){ return find(x).first == find(y).first;}
  int calc(int x, int y) { return par[y].second - par[x].second;}
};


int n,m;
UnionFind uf;

int main(){
  while(cin >> n >> m && (n|m)){
    uf.clear();
    for(int i=0;i<m;i++){
      char c;
      int x,y,z;
      cin >> c >> x >> y;

      if(c == '!'){
        cin >> z;
        uf.unite(x, y, z);

      } else {
        if(uf.same(x, y)) cout << uf.calc(x, y) << endl;
        else cout << "UNKNOWN" << endl;        
        /*
        cout << endl;
        for(int i=1;i<=n;i++){
          cout << i << ": " << uf.par[i].first << ' ' << uf.par[i].second << endl;
        }
        */
      }
    }
  }
}

Measured memory_bytes: 2336
#include <iostream>

using namespace std;

int main(void){
    long long int x;
    long long int y;
    cin >> x >>y;

    for(long long int i=0; i<=x; i++){
        long long int tartle = (x-i);
        long long int tmpans = y;
        if(y == 2*i && i==x){
            cout << "Yes" << endl;
            return 0;
        }else{
            if(y < 2*i){
                cout << "No" << endl;
                return 0;
            }else{
                tmpans -= 2*i;
                if(tmpans == tartle*4){
                    cout << "Yes" << endl;
                    return 0;                
                    }
            }
        }
    }
                    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const double pi = 3.141592653589793238;
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    double space = a * b - x;
    double ans = 0;
    if (space > x) {
        double h = x * 2 / b;
        ans = atan2(b, h) * 180 / pi;
    }
    else {
        double h = space * 2 / a;
        ans = atan2(h, a) * 180 / pi;
    }
    printf("%.10f\n", ans);
    return 0;
}


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

#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, x, y, mx, mn = inf, r, d;
pii a[252525];

signed main() {
	cin >> n;
	rep(i,n) {
		// x<=yにしとく
		cin >> x >> y;
		if (x>y) swap(x,y);
		// デカイ方(y)だけのmin/max
		chmin(mn,y), chmax(mx,y);
		a[i] = {x,y};
	}
	sort(a, a+n);
	// するとmxがRmax/Bmax, mnがRmin/Bminそれぞれどちらかになるから決め打ちできる とりあえずmnは赤で塗ることにして、
	// 1) mxは青で塗る場合
	// 残りはxを赤、yを青で塗るのが最善
	r = (mx-mn) * (a[n-1].fi-a[0].fi);
	// 2) mxも赤で塗る場合
	// 残りはどう塗っても赤のmin/maxが変わらないから青のmax-minを最小化することだけ考えればいい
	d = mx-a[0].fi, mn = inf, mx = 0;
	rep(i,n) {
		if (a[i].fi>=mn) break;
		chmin(mn, a[i].se), chmax(mx, a[i].se);
		chmin(r, d * (max(a[n-1].fi, mx) - min(mn, a[i+1].fi)));
	}
	cout << r << ln;
}

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

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Measured memory_bytes: 24840
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

vector<unsigned long long> v, sump;
int n;
unsigned  long long ans = 0;

void solve(unsigned long long x, int phase){
    if(phase < 0){
        return;
    }
    if (x == 0){
        return;
    }
    x -= 1;
    if (x == 0){
        return;
    }
    if(x >= v[phase]){
        ans += sump[phase];
        x -= v[phase];
    }else{
        phase -= 1;
        solve(x, phase);
        return;
    }
    if(x >= 1){

        ans += 1;
        x -= 1;
    }else{
        return;
    }
    if(x >= v[phase]){

        ans += sump[phase];
        x -= v[phase];
    }else{
        phase -= 1;
        solve(x, phase);
        return ;
    }
    if(x >= 1){
        x -= 1;
    }else{
        return;
    }
}
int main() {
    
    unsigned long long x;
    cin >> n >> x;
    for (int i = 0; i <= 50; i++) {
        if (i == 0) {
            v.push_back(1);
            sump.push_back(1);
        } else {
            v.push_back(2 * v[i - 1] + 3);
            sump.push_back(2 * sump[i - 1] + 1);
        }
    }
    solve(x, n - 1);
    cout << ans << endl;


}

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

int stre(int n) {
	int total = 0;
	for (int i = 0; i < arr.size(); i++) {
		total += (n - arr[i]) * (n - arr[i]);
	}
	return total;
}
int main()
{
	int n; cin >> n; int sum = 0;
	for (int i = 0; i < n;i++) {
		int a; cin >> a; sum += a; arr.push_back(a);
	}
	cout<<min(stre(sum / n) ,stre((sum / n) + 1));
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int r,c;


  while(1) {
  scanf("%d %d",&r,&c);
  if(r == 0 && c== 0) break;

  if(r%2 == 1&&c %2 == 1)printf("no\n");
  else printf("yes\n");

 
  }

  return 0;

}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;
const int LEN = 2e5 + 10;
int A[LEN], P[LEN], vis[LEN];

int main() {
    int N;
    LL K;
    scanf("%d%lld", &N, &K);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }
    vector<int> v;
    int pos = 1;
    while (!vis[pos]) {
        vis[pos] = true;
        v.push_back(pos);
        pos = A[pos];
    }
    int repeat = pos;
    int len = v.size();
    pos = 0;
    while (pos <= N) {
        if (v[pos] != repeat) {
            pos += 1;
        } else {
            break;
        }
    }
    LL priod = len - pos, sub = pos;
    for (int i = 0; i < priod; i++) {
        P[i] = v[pos++];
    }
    if (K < sub) {
        cout << v[K] << endl;
    } else {
        cout << P[(K - sub) % priod] << endl;
    }
    return 0;
}


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


void main()
{
    int n = 0;
    readf("%d\n", &n);
    auto a = new Tuple!(string, int)[n];
    for (int i = 0; i < n; i++)
    {
        auto k = readln().strip.split(" ");
        a[i] = tuple(k[0], k[1].to!int);
    }
    a.sort!((x, y) => x[1] < y[1]);
    void nhuiewrwu(string l)
    {
        int old = 1;
        foreach (a ; a.filter!(x => x[0] == l))
        {
            for (int i = old; i < a[1]; i++)
                writeln(l, " ", i);
            old = a[1] + 1;
        }
            for (int i = old; i < 14; i++)
                writeln(l, " ", i);
    }
    nhuiewrwu("S");
    nhuiewrwu("H");
    nhuiewrwu("C");
    nhuiewrwu("D");
}



Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	double n;
  	double ans;
  	cin>>n;
  	ans=ceil(n/2)/n;
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(tmp);

            WriteLine(tmp[0] == tmp[1] ? tmp[0] + tmp[1] : tmp[1] + tmp[1] - 1);
        }
    }
}

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

map<string,int> M;
vector<string> vec;

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

  rep(i,n){
    string a;
    cin >> a;
    M[a]++;
  }

  int mx = 0;
  for(auto it:M) mx = max(mx,it.second);
  for(auto it:M) if(mx == it.second) cout << it.first << endl;
  
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
int a[50][26];
string s;

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        for(int j=0;j<s.size();j++){
            a[i][s[j]-'a']++;
        }
    }
    s.clear();
    int com;
    for(int i=0;i<26;i++){
        com=1e9;
        for(int j=0;j<n;j++){
            com=min(com,a[j][i]);
        }
        string ss="";
        for(int j=0;j<com;j++){
            ss.push_back(char(i+'a'));
        }
        s+=ss;
    }
    sort(s.begin(),s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace A___Rounding
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var x = int.Parse (input[0]);
            var a = int.Parse (input[1]);
            if (x < a)
            {
                Console.WriteLine (0);
            }
            else
            {
                Console.WriteLine (10);
            }
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
p = [int(i) for i in input().split()]

a = [i*20000 for i in range(1,n+1)]
b = [(n-i+1)*20000 for i in range(1, n+1)]
c = [0 for i in range(n)]

for i in range(n):
    c[i] = a[i] + b[i]

for i in range(n-1):
    if(p[i] > p[i+1]):
        b[p[i+1]-1] +=  c[p[i]-1] - c[p[i+1]-1] + 1
        c[p[i+1]-1] +=  c[p[i]-1] - c[p[i+1]-1] + 1
    else:
        a[p[i+1]-1] += c[p[i]-1] - c[p[i+1]-1] + 1
        c[p[i+1]-1] += c[p[i]-1] - c[p[i+1]-1] + 1

print(" ".join(map(str, a)))
print(" ".join(map(str, b)))

Measured memory_bytes: 7988
#include <iostream>
#define NUM 3
using namespace std ;

int main( void )
{
    int array[ NUM ] , min = 30000 ;
    for( auto &a : array )
    {
        cin >> a ;
    }

    for( int i = 0 ; i < NUM ; i++ )
    {
        for( int j = i + 1 ; j < NUM ; j++ )
        {
            int k = array[ i ] + array[ j ] ;
            if( k < min )
                min = k ;
        }
    }
    cout << min ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max(x,y) ((x)>(y)?(x):(y))
using namespace std;
char s1[10000],s2[10000];
int l,f[10000],z[10000],ans,kk,d;
bool f1,f2;
bool cmp1(const int &x,const int &y){return f[x]<f[y];}
bool cmp2(const int &x,const int &y){return f[x+l]<f[y+l];}
int main(){
	scanf("%s%s",&s1,&s2);l=strlen(s1);f1=f2=0;
	for (int i=0;i<l;i++)s1[i]-='0',f1|=s1[i];
	for (int i=0;i<l;i++)s2[i]-='0',f2|=s2[i];
	if (!f2)return cout<<(f1?-1:0)<<endl,0;
	for (int i=l;i<2*l;i++)s1[i]=s1[i-l],s2[i]=s2[i-l];
	for (int j=0;j<5;j++)
		for (int i=l-1;i>=0;i--)
			if (s2[i])f[i]=0;else f[i]=f[(i+1)%l]+1;
	for (int j=0;j<5;j++)
		for (int i=0;i<l;i++)
			if (s2[i])f[i]=0;else f[i+l]=f[(i-1+l)%l+l]+1;
	ans=1e9;z[0]=9999;for (int i=1;i<=l;i++)z[i]=i-1;sort(z+1,z+1+l,cmp1);
	for (int i=0;i<l;i++){
		if (ans<=i)break;
		d=0;kk=0;f[9999]=i;for (int j=0;j<l;j++)if (s1[j]!=s2[j+i])d++;
		for (int j=l;j>=0;j--){
			ans=min(ans,i+kk+max((f[z[j]]-i)*2,0)+d);
			if (s1[z[j]]!=s2[z[j]+i])kk=max(kk,f[z[j]+l]*2);
		}
	}sort(z+1,z+1+l,cmp2);
	for (int i=0;i<l;i++){
		if (ans<=i)break;
		d=0;kk=0;f[9999]=i;for (int j=0;j<l;j++)if (s1[j+i]!=s2[j])d++; 
		for (int j=l;j>=0;j--){
			ans=min(ans,i+kk+max((f[z[j]+l]-i)*2,0)+d);
			if (s1[z[j]]!=s2[z[j]+l-i])kk=max(kk,f[z[j]]*2);
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// 最大公約数 gcd(6, 8) -> 2
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
# 単位元とseg_funcを設定する
from fractions import gcd
class seg():
    def __init__(self,init_val):
        self.n=len(init_val)
        self.ide_ele=0 #単位元
        self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.ide_ele]*2*self.num
        for i in range(self.n):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1):
            self.seg[i]=self.seg_func(self.seg[2*i+1],self.seg[2*i+2])
    def seg_func(self,a,b):
        #return a+b #0
        #return a*b #1
        #return gcd(a,b) #0
        return max(a,b) #-1か-10**10 (十分小さいもの)
        #return min(a,b) #10**10 (十分大きいもの)
    def update(self,k,x):
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.seg_func(self.seg[k*2+1],self.seg[k*2+2])
    def query(self,p,q): #O(logN)
        if q<=p:return self.ide_ele
        p+=self.num-1
        q+=self.num-2
        self.res=self.ide_ele
        while q-p>1:
            if p&1==0:
                self.res=self.seg_func(self.res,self.seg[p])
            if q&1==1:
                self.res=self.seg_func(self.res,self.seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:self.res=self.seg_func(self.res,self.seg[p])
        else:self.res=self.seg_func(self.seg_func(self.res,self.seg[p]),self.seg[q])
        return self.res

def main():
    n=int(input())
    H=list(map(int,input().split()))
    A=list(map(int,input().split()))
    dp=[0]*(n+1) #最後の高さがjの並べ方のうち最大の美しさ
    seg_dp=seg(dp)
    for i in range(n):
        temp=seg_dp.query(1,H[i])
        seg_dp.update(H[i],temp+A[i])
    print(seg_dp.query(1,n+1))

if __name__=='__main__':
    main()

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

const int MOD = 1000000007;
const int INF = 1e9;

const int max_fac = 5 * 1e5;
long long fac[max_fac], finv[max_fac], inv[max_fac];
void ComInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_fac; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long Comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n;
  const int max_n = 1e5;
  vector<pair<int, int>> a;

  ComInit();

  cin >> n;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    a.push_back(make_pair(x, i));
  }

  sort(a.begin(), a.end());

  int ans = 0;

  int i = n-1;
  int l = 0;
  int r = i - 1;
  int mid = 0;
  int trgt = a[i].first / 2;
  while(r - l > 1){
    int mid = (l + r) / 2;
    if(a[mid].first <= trgt) l = mid;
    else r = mid;
  }
  ans = a[l].first;
  if(a[n-1].first - a[l].first * 2 > a[l+1].first * 2 - a[n-1].first) ans = a[l+1].first;

  cout << a[n-1].first << " " << ans << endl;
  return 0;
}

Measured memory_bytes: 16024
#include <bits/stdc++.h>
#define ll long long
#define P 998244353
#define B ((ll)1e18%P)
#define MAX 500005
using namespace std;

int n, m, cnt, id;
int head[MAX], vet[MAX], Next[MAX], sg[3][MAX];
ll p[MAX], f[3][MAX];

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

int dfs(int x){
    if(sg[id][x] != -1) return sg[id][x];
    sg[id][x] = 0;
    map<int, bool> mp;
    for(int i = head[x]; i; i = Next[i]){
        int v = vet[i];
        mp[dfs(v)] = true;
    }
    while(mp[sg[id][x]]) sg[id][x]++;
    return sg[id][x];
}

int main()
{
    cin >> n;
    p[0] = 1;
    for(int i = 1; i < MAX; i++){
        p[i] = p[i-1]*B%P;
    }
    memset(sg, -1, sizeof(sg));
    for(id = 0; id < 3; id++){
        memset(head, 0, sizeof(head));
        cnt = 0;
        cin >> m;
        int x, y;
        for(int i = 1; i <= m; i++){
            scanf("%d%d", &x, &y);
            if(x > y) swap(x, y);
            add(x, y);
        }
        for(int i = 1; i <= n; i++){
            if(sg[id][i] == -1) dfs(i);
        }
        for(int i = 1; i <= n; i++){
            (f[id][sg[id][i]] += p[i]) %= P;
        }
    }

    ll ans = 0;
    for(int i = 0; i < 500; i++){
        for(int j = 0; j < 500; j++){
            ans = (ans + f[0][i]*f[1][j]%P*f[2][i^j]%P)%P;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 21632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp pop_back()
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
signed main(){
  int a,b,e,f=1000000000;
  cin>>a>>b;
  vector<int> c,d;
  fo(i,a){
    cin>>e;
    if(e<0)
      c.pb(-e);
    else
      d.pb(e);
  }
  Sort(c);
  if(c.sz!=0&&d.sz!=0){
  for(int i=max<int>(0,b-c.sz-1);i<min<int>(b,d.sz);i++){
    f=min<int>(min<int>(f,d[i]*2+c[b-i-2]),d[i]+c[b-i-2]*2);
  }
  }
  if(c.sz>=b)
  f=min(f,c[b-1]);
  if(d.sz>=b)
  f=min(f,d[b-1]);
  if(c.sz==0)
    f=d[b-1];
  if(d.sz==0)
    f=c[b-1];
  cout<<f<<endl;
}


Measured memory_bytes: 1656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>
 
#define INF 100000000
#define EPS 1e-9
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> P;


#define MAX_N 101

int n, w, d;
int p[MAX_N], s[MAX_N];

PII cake[MAX_N];

int main(){

  while(true){
    cin >> n >> w >> d;
    if(n == 0 && w == 0 && d == 0)
      break;

    for(int i = 0; i < n; i++){
      cin >> p[i] >> s[i];
    }

    int M = 1;

    cake[1].first = w;
    cake[1].second = d;

    for(int num = 0; num < n; num++){
      //cout << endl << num << " " << p[num] << endl;
      M++;
      int ww = cake[p[num]].first;
      int dd = cake[p[num]].second;
      int ss = s[num];
      for(int i = p[num]+1; i < M; i++){
	cake[i-1].first = cake[i].first;
	cake[i-1].second = cake[i].second;
      }
      //cout << ww << " " << dd << endl;
      ss = ss % ((ww+dd)*2);

      if(ss - ww < 0){
	int ds = ww - ss;
	cake[M-1].first = min(ds, ss);
	cake[M-1].second = dd;
	cake[M].first = max(ds, ss);
	cake[M].second = dd;
      }
      else if(ss - ww - dd < 0){
	ss -= ww;
	int ds = dd - ss;
	cake[M-1].second = min(ds, ss);
	cake[M-1].first = ww;
	cake[M].second = max(ds, ss);
	cake[M].first = ww;
      }
      else if(ss - 2*ww - dd < 0){
	ss -= (ww + dd);
	int ds = ww - ss;
	cake[M-1].first = min(ds, ss);
	cake[M-1].second = dd;
	cake[M].first = max(ds, ss);
	cake[M].second = dd;
      }
      else if(ss - ww - dd - ww - dd < 0){
	ss -= (ww+dd+ww);
	int ds = dd - ss;
	cake[M-1].second = min(ds, ss);
	cake[M-1].first = ww;
	cake[M].second = max(ds, ss);
	cake[M].first = ww;
      }
      

    }
    
    int ans[MAX_N+1];
    for(int i = 1; i <= M; i++){
      ans[i-1] = cake[i].first * cake[i].second;
    }

    sort(ans, ans+M);

    for(int i = 0; i < M; i++){
      cout << ans[i];
      if(i < n+1 - 1)
	cout << " ";
    }

    cout << endl;

  }


  return 0;

}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int main(){
    long a,b;
    cin >> a >> b;
    long small,big;
    if(a<b){
        small = a;
        big = b;
    }else{
        small = b;
        big = a;
    }
    long ans = big;
    while(ans%small!=0){
        ans+=big;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int ab(int a, int b)
{ if(a >= b) return a-b;
  else return b-a; }
int main()
{  int n, a[100000];
  cin >> n;
  for(int i=1; i<=n; i++)
   cin >> a[i];
  int dp[n];
  dp[0]=0; dp[1]=0; dp[2]=ab(a[2], a[1]); 
  for(int i=3; i<=n; i++)
  {
     dp[i] = min(dp[i-1] + ab(a[i], a[i-1]), dp[i-2] + ab(a[i], a[i-2]));
     }
     cout << dp[n] << endl;
     }


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

int main(){
  int n, m, h[100010], a, b, ans=0;
  vector<int> v[100010];
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> h[i+1];
  for(int i=0;i<m;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for(int i=1;i<=n;i++){
    bool f=true;
    for(int j=0;j<v[i].size();j++){
      if(h[i]<=h[v[i][j]]){
        f=false;
        break;
      }
    }
    if(f)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i=0; i<N; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  map<string, ll> memo; // {s_N}に登場する文字列とその登場回数
  for (int i=0; i<N; i++) {
    if (memo.count(s[i])) memo[s[i]]++;
    else memo[s[i]] = 1LL;
  }
  ll ans = 0LL;
  for (auto p: memo) {
    auto value = p.second;
    ans += value*(value-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 18176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#define int long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0,-1 }; // x軸方向への変位
int dy[4] = { 1, 0,-1, 0 }; // y軸方向への変位





signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) {
		cout << "Yes\n";
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;




}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    alias T = Tuple!(long, long);
    auto G = new T[][](N);
    alias T2 = Tuple!(long, long, long);
    auto LRD = new T2[](M);
    foreach (i; 0 .. M)
    {
        long L, R, D;
        scan(L, R, D);
        L--, R--;
        LRD[i] = T2(L, R, D);
        G[R] ~= T(L, D);
    }
    auto pos = new long[](N);
    pos[] = -2;
    long eval(long x)
    {
        // writefln("%s %s", x, G[x]);
        if (pos[x] == -1)
            return 0;
        if (pos[x] == -2)
        {
            pos[x] = -1;
            if (G[x].length == 0)
            {
                pos[x] = 0;
                return 0;
            }
            long d;
            foreach (t; G[x])
            {
                d = max(d, t[1] + eval(t[0]));
            }
            pos[x] = d;
            return d;
        }
        else
        {
            return pos[x];
        }
    }

    foreach (i; 0 .. N)
        eval(i);

    foreach (lrd; LRD)
    {
        if (pos[lrd[1]] - pos[lrd[0]] != lrd[2])
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");

    // writeln(pos);
}


Measured memory_bytes: 31740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
ll findDivisors(ll n)
{

    // Array to store the count
    // of divisors
    vector<ll> divi(n + 1, 0);
    for (ll i = 1; i <= n; i++) {

        for (ll j = 1; j * i <= n; j++)
            divi[i * j]++;
    }
    ll  ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += (i * divi[i]);
    }
    return ans;
}

void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    ans = findDivisors(n);
    cout << ans << "\n";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}




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

int main() {
	
	    char a[3][3];
	    for(int i=0;i<3;i++) 
	    
	    {
	        for(int j=0;j<3;j++)
	        {
	            cin>>a[i][j];
	        }
	    }
	    cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
let () =
  let n,a,b = Scanf.scanf "%d %d %d " (fun a b c -> a,b,c) in

  let res = ref 0 in
  for i=1 to n do
    let cs = i |> string_of_int |> Batteries.String.to_list |> List.map (fun x -> int_of_char x - 48) in
    let sum = List.fold_left (+) 0 cs in
    if sum >= a && sum <= b then res := !res + i
  done;

  Printf.printf "%d\n" !res


Measured memory_bytes: 4864
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

int main() {
	int h, w; cin >> h >> w;
	string s[h][w];
	for (int i = 0; i < h; i++) {
		for (char j = 'A'; j < w+'A'; j++) {
			cin >> s[i][j - 'A'];
			if (s[i][j - 'A'] == "snuke") {
				cout << j << i+1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=5e5+5;
const int mod=1e9+7;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,sta[maxn],rec[maxn];
char s[maxn];
signed main(){
	//freopen("3.in","r",stdin);
	//freopen("3.out","w",stdout);
	n=read();
	rec[0]=1;
	for(int i=1;i<=n;i++)
	rec[i]=rec[i-1]*i%mod;
	scanf("%s",s+1);
	int flag=0;
	int ans=1;
	for(int i=1;i<=2*n;i++){
		if((flag&1)&&(s[i]=='W')){
			flag++;
			sta[i]=1;
		}
		else if((flag&1)&&(s[i]=='B')){
			flag--;
			sta[i]=0;
		}
		else if(((flag%2==0))&&(s[i]=='B')){
			flag++;
			sta[i]=1;
		}
		else if(((flag%2==0))&&(s[i]=='W')) {
			flag--;
			sta[i]=0;
		}
		if(flag<0)break;
	}
	if(flag<0||flag>0){
		puts("0");
		return 0;
	}
	int now=0;
	for(int i=1;i<=2*n;i++){
		if(sta[i]==0){
			ans=(ans*((i-now-1)-now+mod))%mod;
			now=(now+1)%mod;
		}
	}
	for(int i=1;i<=2*n;i++){
		
	}
	printf("%lld\n",(ans*rec[n])%mod);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

deque <char> str;

bool check_correct()
{
    int ct = 0;
    for (auto it:str)
    {
        if (it=='(')
            ct++;
        else
            ct--;
        if (ct<0)
            return false;
    }
    return true;
}

int main()
{
    int n;
    int a = 0, b = 0;
    string s;
    cin >> n >> s;
    for (auto it:s)
    {
        str.push_back(it);
        if (it == '(')
            a++;
        else
            b++;
    }
    while(a>b)
    {
        str.push_back(')');
        b++;
    }
    while(b>a)
    {
        str.push_front('(');
        a++;
    }
    while(!check_correct())
    {
        str.push_front('(');
        str.push_back(')');
    }
    for (auto it:str)
        cout<<it;
}

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

using namespace std;

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

    int i = 0;
    int a[n];
    while(i++ < n){
        cin >> a[i];
    }

    int flag = 0;
    i = 1;
    while (i++ < n-1){
        if ((a[i-1] > a[i] && a[i] > a[i+1]) || 
        (a[i-1] < a[i] && a[i] < a[i+1])){
            flag++;
        }
    }

    cout << flag << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 101;
int M[MAX][MAX];

int main()
{
    int n, m, s, v;
    cin >> n;
    for (int i = 0; i <= MAX; ++i)
    {
        for (int j = 0; j <= MAX; ++j)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        cin >> m >> s;
        while (s--)
        {
            cin >> v;
            M[m][v] = 1;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            cout << M[i][j];
            if (j != n)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>t;
    double pi=3.141592;
    double  ans=2*pi*(double)t;
    cout<<setprecision(10)<<fixed<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10864
INF = float("inf")
cnt = 0
def merge(A, left, mid, right):
    L = A[left: mid] + [INF]
    R = A[mid: right] + [INF]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += right - left
def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
n = int(input())
S = list(map(int, input().split()))
mergeSort(S, 0, n)
print(*S)
print(cnt)



Measured memory_bytes: 61652
n=int(input())
h=list(map(int,input().split()))
h.append(99999999999999999999)
temp=[0]*(n+1)
temp[0]=0
for i in range(n):
  if h[i]>=h[i+1]:
    temp[i+1]=temp[i]+1
  else:
    temp[i+1]=0
del temp[n]
print(max(temp))

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

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

bool done[110];
int main()
{
	int X, N;
	scanf("%d%d", &X, &N);
	REP(i, N)
	{
		int p;
		scanf("%d", &p);
		done[p] = 1;
	}

	int res = 0, dif = X;
	REP(i,110)
		if (!done[i] && abs(X - i) < dif)
		{
			res = i;
			dif = abs(X - i);
		}

	printf("%d\n", res);

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[101010];
ll i,j,ans;
int main(){
    scanf("%lld", &N);
    printf("%lld", N * N * 3);

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())

Tree = [[] for _ in range(N)]
for _ in range(M):
    L,R,D = map(int,input().split())
    L -= 1; R -= 1
    Tree[L].append((R,D))
    Tree[R].append((L,-D))

num = dict()
for i in range(N):
    if i not in num:
        num[i] = 0
        Q = deque(Tree[i])
        x = 0
        while Q:
            now,d = Q.popleft()
            if now in num:
                if num[now] != d:
                    print("No")
                    exit()
            else:
                num[now] = d
                for node,Di in Tree[now]:
                    Q.append((node,d+Di))
print("Yes")

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

int main()
{
	int x[2], y[2],ans[4];

	cin >> x[0] >> y[0] >> x[1] >> y[1];

	int a = x[1]-x[0],b=y[1]-y[0];

	ans[0] = x[1] - b;
	ans[1] = y[1] + a;
	ans[2] = ans[0] - a;
	ans[3] = ans[1] - b;

	for (int i = 0; i < 4; i++) {
		cout << ans[i];
		if (i != 3)cout << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
ll n, s;
ll a[3010];
ll f[3010];
ll inv2;
ll ksm(ll aa, ll b) {
	ll ret = 1;
	while (b) {
		if (b & 1) ret = (ret * aa) % MOD;
		aa = (aa * aa) % MOD;
		b >>= 1;
	}
	return ret;
}
int main() {
	cin >> n >> s;
	for (ll i = 1; i <= n; i++) cin >> a[i];
	inv2 = ksm(2, MOD - 2);
	f[0] = ksm(2, n);
	for (ll i = 1; i <= n; i++) {
		for (ll k = s; k >= a[i]; k--) {
			f[k] = (f[k] + f[k - a[i]] * inv2) % MOD;
		}
	}
	cout << f[s];
	return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	
	int n, q, a[100001];
	
	long long k;
	cin >> n >> k >> q;

	vector<long long> b(n, k);
	for (int i = 0; i < q; i++) {
		cin >> a[i];
		b[a[i]-1]++;
	}
	for (int i = 0; i < n; i++) {
		if (b[i] - q >= 1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1792
n,k=map(int,input().split())
p=list(map(int, input().split()))
for i in range(n):
	p[i]=(1+p[i])/2
cs=[]
sum=0
for i in range(n):
	sum+=p[i]
	cs.append(sum)
ans=cs[k-1]
for i in range(1,n-k+1):
	ans=max(ans,cs[i+k-1]-cs[i-1])
print('{:.8f}'.format(ans))

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

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

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

    ll h, w;
    cin >> h >> w;
    vvll a(h, vll(w)), b(h, vll(w)), c(h, vll(w));
    REP(i, h) {
        REP(j, w) {
            cin >> a[i][j];
        }
    }
    REP(i, h) {
        REP(j, w) {
            cin >> b[i][j];
            c[i][j] = abs(a[i][j] - b[i][j]);
        }
    }

    vector<vvll> dp(h, vvll(w, vll(13000)));
    dp[0][0][c[0][0]] = 1;
    REP(i, h) {
        REP(j, w) {
            ll cc = c[i][j];
            REP(v, 13000) {
                if (i && dp[i - 1][j][v]) {
                    dp[i][j][v + cc] = 1;
                    dp[i][j][abs(v - cc)] = 1;
                }
                if (j && dp[i][j - 1][v]) {
                    dp[i][j][v + cc] = 1;
                    dp[i][j][abs(v - cc)] = 1;
                }
            }
        }
    }
    ll res = 1e18;
    REP(v, 13000) {
        if (dp[h - 1][w - 1][v]) chmin(res, v);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 658944