akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=1e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back();
#define se second
#define fi first
#define debug(x) cerr<<x<<endl
#define test(t) int t;cin>>t;while(t--)
#define fordebug(x) cerr<<x<<" "

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference

int main(){
    ll ans =0 ;
    int n;
    cin>>n;
    vi a(n+1);
    forn(i,1,n+1){
        cin>>a[i];
    }
    vl dp(n+1,0),fac(n+1,0);
    fac[0]=1;
    fac[1]=1;
    dp[1] = 1;
    forn(i,1,n){
        fac[i]=(i*fac[i-1])%MOD;
        dp[i] = (dp[i-1]*i + fac[i-1])%MOD;
        ans += ((((a[i+1]-a[i])*dp[i])%MOD)*mod_inv(fac[i],MOD))%MOD;
        ans%=MOD;
    }
    cout<<(ans*fac[n-1])%MOD;
    return 0;
}

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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

// 
LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

// Union Find木
template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

template<class T> vector<T> cumulativeSum(const vector<T>& ordered)
{
  vector<T> res;
  T sum = 0;
  for(auto elem : ordered)
  {
    res.push_back(sum += elem);
  }
  return std::move(res);
}

vector<LL> divisor(LL n)
{
  vector<LL> res;
  for(LL i = 1; i*i <= n; i++)
  {
    if(n % i == 0)
    {
      res.push_back(i);
      if(i * i != n) res.push_back(n/i);
    }
  }
  sort(begin(res), end(res));
  return res;
}

LL gcd(const vector<LL>& n)
{
  LL allGCD = __gcd(n[0], n[0]);
  for(LL i = 1; i < n.size(); i++)
  {
    allGCD = __gcd(allGCD, n[i]);
  }
  return allGCD;
}

// --------------------------------------

LL n;
vector<LL> a;

void input()
{
  cin >> n;
  a.resize(n);

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

void solve()
{
  vector<LL> l(n);
  vector<LL> r(n);
  for(int i = 0; i < n-1; i++)
  {
    l[i+1] = __gcd(l[i], a[i]);
  }
  for(int i = n-1; 0 < i; i--)
  {
    r[i-1] = __gcd(r[i], a[i]);
  }

  LL maxGCD = 0;
  for(int i = 0; i < n; i++)
  {
    maxGCD = max(maxGCD, __gcd(l[i], r[i]));
  }

  cout << maxGCD;
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 2560
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s=scanner.next();
		int tmp1=0;
		for(int i=0;i<s.length();i++){
			char c=s.charAt(i);
			if(i%2==0&&c=='0'){
				tmp1++;
			}
			if(i%2==1&&c=='1'){
				tmp1++;
			}
		}
		int tmp2=0;
		for(int i=0;i<s.length();i++){
			char c=s.charAt(i);
			if(i%2==0&&c=='1'){
				tmp2++;
			}
			if(i%2==1&&c=='0'){
				tmp2++;
			}
		}
		System.out.println(Math.min(tmp1, tmp2));
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21716
/*
 * NO2.c
 *
 *  Created on: 2017/04/07
 *      Author: CuSO4
 */


#include <stdio.h>
#include <math.h>
int main(){
	long N;
	long A,B,F;
	scanf("%ld",&N);

	for(A=(int)sqrt(N)+1;A>>0;A--){
		F = 0;
		if(N%A==0){
			B=N/A;
			while(B>=1){
				B = B / 10;
				F = F + 1;
			}
			break;
		}
	}
	printf("%d",F);
	return 0;
}


Measured memory_bytes: 128
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 1; i < n; i++)
    {
        ll x;
        cin >> x;
        a[x - 1]++;
    }
    for (ll e : a)
        cout << e << '\n';
}

Measured memory_bytes: 4768
N = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
s = 0

for i in 0..N-1
    a[i] = a[i] - b[i]
    if a[i]>0
        s += a[i]
    end 
end
print s

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define fr(i,n) for(ll i=0;i<n;i++)
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
using namespace std;
int main()
{
	int r;
	cin>>r;
	double pi = 3.14159;
	double c=2*pi*r;
	cout << fixed << setprecision(2) << c <<endl; 
}

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

int main(){
    /*input*/
    int n;  cin >> n; 
    vector<int>h(n);
    rep(i, n)cin >> h[i];
    /*calculation*/
    int length = 1;
    int ans = 0;
    for(int i = 0; i < n-1; i++){
	if(h[i] >= h[i+1]){
	    length++;
	    if(i == n-2)ans = max(ans, length-1);
	}else{
	    ans = max(ans, length-1);
	    length=1;
	}
    }
    /*output*/
    cout << ans << endl;
}



Measured memory_bytes: 640
def solution(s,t):
    minv = float("inf")
    for i in range(len(s) - len(t) + 1):
        v = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                v += 1
        minv = min(minv, v)
    return minv

s = input()
t = input()
print(solution(s, t))


Measured memory_bytes: 9044
h, w = map(int, input().split())
S = []
for _ in range(h):
    s = str(input())
    S.append(s)

# leftの個数カウントを行う
Left_count = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    s = S[i]
    count = 0
    for j in range(w):
        if s[j] == '#':
            count = 0
            continue
        else:
            count += 1
            Left_count[i][j] = count

# Rightの個数カウントを行う
Right_count = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    s = S[i][::-1]
    count = 0
    for j in range(w):
        if s[j] == '#':
            count = 0
            continue
        else:
            count += 1
            Right_count[i][j] = count
for i in range(h):
    Right_count[i] = Right_count[i][::-1]

# Upの個数カウントを行う
Up_count = [[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    count = 0
    for i in range(h):
        if S[i][j] == '#':
            count = 0
            continue
        else:
            count += 1
            Up_count[i][j] = count

# Downの個数カウントを行う
Down_count = [[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    count = 0
    for i in range(h-1,-1,-1):
        if S[i][j] == '#':
            count = 0
            continue
        else:
            count += 1
            Down_count[i][j] = count

ans = 0
for i in range(h):
    for j in range(w):
        tot_ij = Left_count[i][j] + Right_count[i][j] + Down_count[i][j] + Up_count[i][j] -3
        ans = max(tot_ij, ans)
print(ans)

Measured memory_bytes: 184452
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

int div_up(int a, int b) { return (a + b - 1) / b; }

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

  vector<int> x(3);
  rep(i, 3) {
    IN(x[i]);
  }

  sort(all(x));

  if (x[0] == x[1] && x[1] == x[2]) {
    OUTL(0); return 0;
  }

  i64 res = 0;
  while (x[1] != x[2]) {
    res++; x[0]++; x[1]++;
  }

  if (x[2] % 2 == x[0] % 2) {
    i64 diff = x[2] - x[0];
    res += (diff / 2);
  }

  else {
    i64 diff = x[2] - x[0];
    res += div_up(diff, 2);
    res++;
  }

  OUTL(res);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 1000000007
#define mod 1000000007
#include <iostream>
const lli infl=0x3f3f3f3f3f3f3f3fLL;

int main()
{  ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
  // test(t)
   {
       //lli a,b,c,d;
       float a,b;
       string s;

       cin>>a;
       b=float((2*22*a)/7);
       cout<<float(b);

     cout<<endl;
   }


return 0;
}


Measured memory_bytes: 3840
import heapq


def main():
    _ = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    q = []
    heapq.heapify(q)
    ans = A[0]
    tmp_score = min(A[0], A[1])
    heapq.heappush(q, (-tmp_score, A[0], A[1]))
    heapq.heappush(q, (-tmp_score, A[1], A[0]))

    for a in A[2:]:
        g = heapq.heappop(q)
        ans += -g[0]
        tmp_score1 = min(a, g[1])
        tmp_push1 = (-tmp_score1, a, g[1])

        tmp_score2 = min(a, g[2])
        tmp_push2 = (-tmp_score2, a, g[2])

        heapq.heappush(q, tmp_push1)
        heapq.heappush(q, tmp_push2)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 134504
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j,k;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(a==0 && b==0)
        {
            break;
        }
        for(i=0; i<a; i++)
        {
            for(j=0; j<b; j++)
            {
                if(i%2==0)
                {
                    if(j%2==0)
                    {
                        cout<<"#";
                    }
                    else
                    {
                        cout<<".";
                    }
                }

                else if(i%2==1)
                {
                    if(j%2==0)
                    {
                        cout<<".";
                    }
                    else
                    {
                        cout<<"#";
                    }
                }

            }
            cout<<endl;
        }
            cout<<endl;
        }
    }



Measured memory_bytes: 3172
// 1_union_findlib_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

vector<int> parent;
vector<int> node_rank;


int root(int x){
    if(parent[x] == x) return x;
    else return parent[x] = root(parent[x]);
}

void link(int x, int y){
    if(node_rank[x] > node_rank[y]){
        parent[y] = x;
    }else{
        parent[x] = y;
        if(node_rank[x] == node_rank[y]){
            node_rank[y]++;
        }
    }
}

void unite(int x, int y){
    link(root(x), root(y));
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;// number of nodes
    int q;// number of query
    cin >> n >> q;

    parent.resize(n);
    node_rank.resize(n);
    rep(i, n){
        parent[i] = i;
        node_rank[i] = 1;
    }

    rep(i, q){
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0){
            unite(x, y);
        }else{
            cout << same(x, y) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] pic = new int[h][w];
		for(int i = 0; i < h; i++) {
			String s = sc.next();
			for(int j = 0; j < w; j++) {
				if(s.charAt(j) == '.') {
					pic[i][j] = 0;
				} else {
					pic[i][j] = 1;
				}
			}
		}
		boolean flag = true;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if((!((i + 1 < h && pic[i + 1][j] == 1)
						|| (i - 1 >= 0 && pic[i - 1][j] == 1)
						|| (j + 1 < w && pic[i][j + 1] == 1)
						|| (j - 1 >= 0 && pic[i][j - 1] == 1)))
						&& pic[i][j] == 1) {
					flag = false;
					break;
				}
			}
		}
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


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

using namespace std;

int n;
vector<int> card,card1;

void riffleshuffle(){
	int j=0,k=n;
	for(int i=0;i<2*n;i++){
		if(i%2==0)
		card1.push_back(card[j++]);
		else
		card1.push_back(card[k++]);
	}
	card = card1;
	card1.erase(card1.begin(),card1.end());
}

void cut(int k){
	for(int i=k;i<2*n;i++){
		card1.push_back(card[i]);
	}
	for(int i=0;i<k;i++){
		card1.push_back(card[i]);
	}
	card = card1;
	card1.erase(card1.begin(),card1.end());
}

int main(){
	int m,k;
	scanf("%d",&n);
	for(int i=0;i<2*n;i++){
		card.push_back(i+1);
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		scanf("%d",&k);
		if(k==0)
		riffleshuffle();
		else
		cut(k);
	}
	for(int i=0;i<2*n;i++){
		printf("%d\n",card[i]);
	}
}

Measured memory_bytes: 3240
from math import sqrt
from itertools import combinations
n = int(input())
a = int(sqrt(2*n))
if n-a*(a+1)//2: print("No")
else:
	print("Yes")
	print(a+1)
	x,y,m = [[str(a)] for i in range(a+1)],[i for i in range(a+1)],1
	for i,j in combinations(y,2):
		x[i].append(str(m))
		x[j].append(str(m))
		m+=1
	for i in x: print(" ".join(i)) 

Measured memory_bytes: 17140
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(c>=a&&c<=b)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
fun <T> List<T>.upperBound(element: T): Int where T : Comparable<T> {
    return this
        .binarySearch { if (it > element) 1 else -1 }
        .let { -(it + 1) }
}

fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val table = Array(26) { mutableListOf<Int>() }
    for ((i, c) in s.repeat(2).withIndex()) {
        table[c - 'a'].add(i + 1)
    }

    var cur = 0L
    for (c in t) {
        val i = c - 'a'
        if (table[i].isEmpty()) {
            cur = -1
            break
        }

        val p1 = (cur % s.length).toInt()
        val p2 = table[i].upperBound(p1)
        cur += table[i][p2] - p1
    }
    println(cur)
}


Measured memory_bytes: 46508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
//#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  string S; cin >> S;
  int Q; cin >> Q;
  
  bool k = true;
  string B, E;
  rep(i, Q) {
    int T; cin >> T;
    if(T == 1) {
      k = !k;
    }
    if(T == 2) {
      int F; cin >> F;
      char C; cin >> C;
      if(F == 1) {
        if(k) B += C;
        else E += C;
      } else {
        if(k) E += C;
        else B += C;
      }
    }
  }
  
  reverse(all(B));
  string ans = B+S+E;
  if(k) cout << ans << endl;
  else {
    reverse(all(ans));
    cout << ans << endl;
  }
  

}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  ll N;
  std::cin >> N;

  std::cout << (N - 1) * N / 2 << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
string s;
int ans=1<<30; 
int main()
{
    cin>>s;
    for(int i=1;i<s.length();i++) 
        if(s[i]!=s[i-1]) 
            ans=min(ans,max(i,int(s.length())-i)); 
    cout<<min(ans,int(s.length()))<<endl; 
    return 0;
}

Measured memory_bytes: 512
import math
f_inf = float("inf")
num = int(input())
s = input().rstrip().split(' ')
t = input().rstrip().split(' ')
d1 = 0
d2 = 0
d3 = 0
dinf = 0
for i in range(num):
  d1 = d1 + abs(int(s[i]) - int(t[i]))
  d2 = d2 + (int(s[i]) - int(t[i])) ** 2
  d3 = d3 + (abs(int(s[i]) - int(t[i]))) ** 3
  if abs(int(s[i]) - int(t[i])) > dinf:
    dinf = abs(int(s[i]) - int(t[i]))

d2 = math.sqrt(d2)
d3 = d3 ** (1/3)
print(d1)
print(d2)
print(d3)
print(dinf)


Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

vector<int> tolological_sort(vector<vector<edge>>& g) {
    int n = g.size();
    vector<int> res;
    vector<int> indeg(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (int)g[i].size(); j++) {
            indeg[g[i][j].to]++;
        }
    }
    stack<int> s;
    for (int i = 0; i < n; i++) {
        if (indeg[i] == 0) s.push(i);
    }
    while (!s.empty()) {
        int now = s.top();
        s.pop();
        res.push_back(now);
        for (int i = 0; i < (int)g[now].size(); i++) {
            indeg[g[now][i].to]--;
            if (indeg[g[now][i].to] == 0) s.push(g[now][i].to);
        }
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> g(n), indeg(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(edge(b));
        indeg[b].push_back(edge(a));
    }
    vector<int> topo = tolological_sort(g);
    // topo_order[i]:頂点iがトポロジカルソートの何番目に現れるか
    vector<int> topo_order(n);
    for (int i = 0; i < n; i++) {
        topo_order[topo[i]] = i;
    }
    //初期値用にオーダー-1の頂点nを追加しておく
    topo_order.push_back(-1);
    vector<int> ans(n, n);
    //オーダーが一番若いやつが根
    //最後の処理の都合で-1
    ans[topo[0]] = -1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < indeg[i].size(); j++) {
            if (topo_order[indeg[i][j].to] > topo_order[ans[i]]) {
                ans[i] = indeg[i][j].to;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
}

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

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

    int ans = 0;
    int ansnum = 1;
    for (int i = 1; i <= N; i++) {
        int num = i;
        int res = 0;
        while (num % 2 == 0) {
            num /= 2;
            res++;
        }
        if (res > ans) {
            ansnum = i;
        }
        ans = max(res, ans);
    }

    cout << ansnum << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	var S string

	fmt.Scan(&N)
	fmt.Scan(&S)

	cnt :=0

	for i:=0 ; i< N-2;i++{

		if S[i:i+1]=="A"{

			if  S[i+1:i+2]=="B"{

				if S[i+2:i+3]=="C" {

					cnt++					
				}
			}
		}
	}

	fmt.Println(cnt)


}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int X = scanner.nextInt();
        int T = scanner.nextInt();
        for(int i = 1; i < 100000; i++) {
            if(N <= X * i) {
                System.out.println(T*i);
                return;
            }
        }
    }
}

Measured memory_bytes: 35564
#![allow(non_snake_case)]

use std::cmp;
use std::iter::FromIterator;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

#[allow(dead_code)]
const INF: i64 = 1_010_000_000_000_000_000;

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let S = sc.chars();
    let T = sc.chars();
    let N = S.len() as i64;
    let M = T.len() as i64;

    // (i文字,j文字) まででのLCSの最大長
    let mut dp = vec![vec![0; (M+1) as usize]; (N+1) as usize];

    // どちらか一方が0文字ならLCSは空
    for i in 0..N+1 {
        dp[i as usize][0] = 0;
    }
    for j in 0..M+1 {
        dp[0][j as usize] = 0;
    }

    for i in 1..N+1 {
        let s = S[(i-1) as usize];
        for j in 1..M+1 {
            let t = T[(j-1) as usize];

            dp[i as usize][j as usize] = if s == t {
                1 + dp[(i-1) as usize][(j-1) as usize]
            }
            else {
                cmp::max(
                    dp[(i-1) as usize][j as usize],
                    dp[i as usize][(j-1) as usize]
                )
            };
        }
    }

    let mut ans = vec![];
    let (mut i, mut j) = (N, M);
    loop {
        if dp[i as usize][j as usize] == 0 { break; }

        let s = S[(i-1) as usize];
        let t = T[(j-1) as usize];
        if s == t {
            ans.push(s);
            i -= 1;
            j -= 1;
        }
        else {
            if dp[(i-1) as usize][j as usize] == dp[i as usize][j as usize] {
                i -= 1;
            }
            else {
                j -= 1;
            }
        }
    }
    ans.reverse();

    println!("{}", String::from_iter(ans));
}


Measured memory_bytes: 41212
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int red_count = 0;
    for (char c : s) {
        if (c == 'R') {
            ++red_count;
        }
    }

    int blue_count = N - red_count;
    if (red_count > blue_count) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# ABC-138-D
# 参考 https://atcoder.jp/contests/abc138/submissions/7003989

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a, b in AB:
    #例えば、graph[2]には頂点2に繋がる全ての頂点が記録される。
    #グラフ2の親が1, 子が2,3の場合は、graph[2]=[1,2,3] ※この時点で親か子かは記録されない。
    graph[a].append(b)
    graph[b].append(a)

#(頂点の数+1)個分の要素を含む配列を作る。
value  =[0] * (N+1)
#「頂点p以下の部分木にxを加算する」という指示に応じて頂点pにx点加算する。pの子に対する加算は後の処理で行う。
for p,x in PX:
    value[p] += x
    
#各pの子に対する加算を行う。
#(加算対象となる頂点、親)という形でキューを持つ。最初の１発目は頂点0を親に持つ頂点1に加算を行う。という形で実行。
#2発目以降でgraphに記載された頂点の中から子に当たる頂点を見つけて、valueに加算をおこなっていく。
queue = [(1,0)]
while queue:#queue=[]になったら終了。
    x, parent = queue.pop()
    value[x] += value[parent]
    #頂点xに繋がる全ての頂点をループで確認していき、parentでなければqueueに入れていく。
    for y in graph[x]:
        if y == parent:
            continue
        #次はparentが現在加算をおこなってる頂点xという形で進んでいく。
        queue.append((y, x))

answer = " ".join(map(str, value[1:]))
print(answer)

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

int main(){
  int N , K ;
  cin >> N >> K ;
  string S ;
  cin >> S ;
  char s = S.at(K-1);
  s +=32 ;
  S.at(K-1) = s;
  
  cout << S << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
	Scanner in = new Scanner(System.in);

	int h = in.nextInt();
	int w = in.nextInt();
	String s;

	while (!(h ==0 && w == 0)){
		StringBuffer sb = new StringBuffer(w);
		for (int i = 0; i < w; i++) {
                        sb.append("#");
                }
		for (int i = 0; i < h; i++) {
			System.out.println(sb.toString());
		}
		h = in.nextInt();
		w = in.nextInt();
                System.out.println();
	}	
    }   
}

Measured memory_bytes: 19216
/*---------------------------------
 *File name: B.cpp
 *Creation date: 2020-05-31 20:52
 *-------------------------------*/
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
#define loop(c, a, b) for(int c = a; c <= b; ++c)
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;

int main(){
	LL n;
	cin >> n;
	int ans = 0;
	for(int i = 2; i <= sqrt(n); ++i){
		if(n % i == 0){
			LL tmp = i;
			while(n % tmp == 0){
				ans++;
				n /= tmp;
				tmp *= i;
			}
			while(n % i == 0) n /= i;
		}
	}
	if(n != 1) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3744
/*************************************************************************
         File Name: AA.cpp
         ID: PhyCode
         PROG: 
         LANG: C++ 
         Mail: 763315163@qq.com 
         Created Time: 2016年08月28日 星期日 20时32分37秒
     ************************************************************************/
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
      int n,k,x,y;
      scanf("%d%d%d%d",&n,&k,&x,&y);
      if (k>=n)printf("%d\n",x*n);
      else
      printf("%d\n",x*k+y*(n-k));
    }

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

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> cnt(n, 0);
    for (int i = 0; i < n - 1; ++i) {
        int v;
        std::cin >> v;
        ++cnt[--v];
    }

    for (auto c : cnt) std::cout << c << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Jail solver = new Jail();
        solver.solve(1, in, out);
        out.close();
    }

    static class Jail {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextInt();
            long K = in.nextInt();
            long ans = 0;
            for (int i = 0; i < N - 1; i++) {
                ans += ans / (K - 1) + 1;
            }
            out.println(ans);
        }

    }
}




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

using namespace std;
int n;
double a[3001];
double dp[3001][2000];
double probab(int i,int t)
{
	if(dp[i][t]!=-1)
		return dp[i][t];
	if(i==n)
	{
		dp[i][t]=1;
	}
	else if(t>0)
	{
		dp[i][t]=a[i]*probab(i+1,t)+(1-a[i])*probab(i+1,t-1);
	}
	else
	{
		dp[i][t]=a[i]*probab(i+1,t);
	}
	return dp[i][t];
}

int main()
{
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < 3001; ++i)
	{
		for (int j= 0; j < 1501; ++j)
		{
			dp[i][j]=-1;
		}
	}
	printf("%.14lf\n",probab(0,n/2));
}

Measured memory_bytes: 47232
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (w, h, x, y) = {
        let line = read_vec::<f64>();
        (line[0], line[1], line[2], line[3])
    };
    let half = w * h / 2.0;
    let multi = if x == w / 2.0 && y == h / 2.0 { 1 } else { 0 };
    println!("{} {}", half, multi);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll MAX = 100000;
int cnt[2005];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
	//if (x != 1 || y != n) {
		for (int i = 1; i <= n; ++i)
			for (int j = i + 1; j <= n; ++j)
				if (i < x) {
					if (j <= x) cnt[j - i]++;
					else if (j > x&& j <= y)
						cnt[min(j - i, x - i + 1 + y - j)]++;
					else cnt[x - i + 1 + j - y]++;
				}
				else if (i >= x && i <= y) {
					if (j <= y) cnt[min(j - i, i - x + 1 + y - j)]++;
					else cnt[min(j - i, i - x + 1 + j - y)]++;
				}
				else
					cnt[j - i]++;
		for (int i = 1; i <= n - 1; ++i)
			cout << cnt[i] << endl;
	//}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int n;
int a[15];
int t[15];
int b[15], c[15];
 
void check(int x) {
	int tot = 0;
	while(x > 0) {
		b[++tot] = x % 3;
		x = x / 3;
	}
}
 
int main()
{
	t[0] = 1;
	for(int i = 1; i <= 10; i++)
		t[i] = t[i - 1] * 3;
	while(cin>>n)
	{
		int cnt = 0;
		int tu = 0;
		for(int i = 0; i < n; i++)
			tu += t[i] * 2;
		for(int i = 1; i <= n; i++) {
			cin>>a[i];
		}
		for(int i = 0; i <= tu; i++) {
			check(i);
			for(int j = 1; j <= n; j++) {
				if(b[j] == 0) {
					c[j] = a[j] - 1;
				}
				else if(b[j] == 1) {
					c[j] = a[j];
				}
				else if(b[j] == 2) {
					c[j] = a[j] + 1;
				}
			}
			int res = 1;
			for(int j = 1; j <= n; j++)
				res = res * c[j];
			if((res & 1) == 0) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    string s1, s2;
    int a = 0, b = 0;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> s1 >> s2;
        if(s1 > s2) a += 3;
        else if(s1 < s2) b += 3;
        else{
            a += 1;
            b += 1;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3180
/*
[exawizards2019] D - Modulo Operations
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 200;
const int MAX_X = 1e5;
const ll MOD = 1e9 + 7;

int N, X;
int S[MAX_N];
ll dp[MAX_N + 1][MAX_X + 1];

ll fact(int n) {
    ll ret = 1;
    for (int i = 2; i <= n; i++) {
        (ret *= i) %= MOD;
    }

    return ret;
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x) % m;
}

ll solve() {
    sort(S, S + N, greater<int>());

    dp[0][X] = fact(N);
    for (int i = 0; i < N; i++) {
        ll inv = mod_inv(N - i, MOD);
        for (int j = 0; j <= X; j++) {
            ll p = (dp[i][j] * inv) % MOD;
            ll q = (p * (N - i - 1)) % MOD;
            (dp[i + 1][j % S[i]] += p) %= MOD;
            (dp[i + 1][j] += q) %= MOD;
        }
    }

    ll ans = 0;
    for (int j = 0; j <= X; j++) {
        (ans += j * dp[N][j]) %= MOD;
    }

    return ans;
}

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 156544
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++){
    if(ch == '\\') S1.push(i);
    else if (ch == '/' && S1.size() > 0) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while (S2.size() > 0 && S2.top().first > j){
	a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0) {ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3216
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		int[]A = new int[N];
		int max = 0;
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		int a = 0;
		for(var i=1;i<N;i++){
			if(A[i]<=A[i-1]){
				a++;
			} else {
				a = 0;
			}
			max = Math.Max(a,max);
		}
		Console.WriteLine(max);
	}
}

Measured memory_bytes: 23004
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
int n;
long long b[305][305],ans=0;

void floyd()
{
	for (int i=1;i<=n;++i)
	{
		for (int j=1;j<=n;++j)
		{
			if (i==j)
			{
				continue;
			}
			bool f=true;
			for (int k=1;k<=n;++k)
			{
				if (k==i || k==j) continue;
				if (b[i][j]>b[i][k]+b[k][j])
				{
					cout<<"-1\n";
					exit(0);
				}
				else if (b[i][j]==b[i][k]+b[k][j])
				{
					f=false;
				}
			}
			if (f)
			{
				ans+=b[i][j];
			}
		}
	}
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		for (int j=1;j<=n;++j)
		{
			cin>>b[i][j];
		}
	}
	
	floyd();
	
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 *    author:  Sarfaraz
 *    created: 19.04.2020 17:51:34
**/

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

void solve(){

     float r;
     cin >> r;
     float pi=3.14;
     float c;
     c=2*pi*r;
     cout<<fixed<<setprecision(6)<<c<<endl;

}

int main(){


    solve();

return 0;
}



Measured memory_bytes: 3780
n = int(input())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
c = [0 for i in range(n)]

dp = [[0 for i in range(3)] for j in range(n)]

for t in range(n):
    x = input().split()
    a[t] = int(x[0])
    dp[t][0] = a[t]
    b[t] = int(x[1])
    dp[t][1] = b[t]
    c[t] = int(x[2])
    dp[t][2] = c[t]

#dp = [[0 for i in range(3)] for j in range(n)]

ans = 0

if a and b and c:
    #dp[0][0] = a[0]
    #dp[0][1] = b[0]
    #dp[0][2] = c[0]
    #print(dp)

    for k in range(1,n):
        for x in range(3):
            dp[k][x] = max(dp[k-1][(x+1)%3], dp[k-1][(x+2)%3]) + dp[k][x]
    #print(dp)

    for x in range(3):
        ans = max(ans, dp[n-1][x])

print(ans)

Measured memory_bytes: 92320
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");

  return 0;
}



Measured memory_bytes: 9584
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1<<29)
using namespace std;
int n,ans,inv[100005];
const int mo=1000000007;
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int main(){
	scanf("%d",&n);
	int fac=1;
	for (int i=1;i<=n;i++)
		fac=1ll*fac*i%mo;
	for (int i=1;i<=n;i++)
		inv[i]=(inv[i-1]+power(i,mo-2))%mo;
	for (int i=1;i<=n;i++){
		int x; scanf("%d",&x);
		ans=(ans+1ll*(inv[n-i+1]+inv[i-1+1]-1)*x)%mo;
	}
	printf("%d",1ll*ans*fac%mo);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18

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

	vector<int> k(M);
	vector<vector<int>> s(M);
	int tmp;

	rep(i, M)
	{
		cin >> k[i];
		rep(j, k[i])
		{
			cin >> tmp;
			s[i].push_back(tmp - 1);
		}
	}
	vector<int> p(M);
	rep(i, M)
	{
		cin >> p[i];
	}


	// MAX: 1024 通り 1<<N
	int ans = 0;
	bool ok;

	for (int n=0; n< 1<<N; n++) {
		// switch 全通り
		ok = true;
		for (int m=0; m<M; m++) {
			// 電球全通り
			tmp = 0;
			for (int t=0; t<k[m];t++){
				tmp ^= (n >> s[m][t]) & 1;
			}
			if (tmp % 2 != p[m]){
				ok = false;
				break;
			}
		}
			if (ok) ans++;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	var sets [4][]int
	for i := 0; i < 4; i++ {
		// initiaize by 0
		sets[i] = make([]int, 13)
	}

	var mark string
	var num int

	for i := 0; i < n; i++ {
		fmt.Scan(&mark, &num)

		switch mark {
		case "S":
			sets[0][num-1] = 1
		case "H":
			sets[1][num-1] = 1
		case "C":
			sets[2][num-1] = 1
		case "D":
			sets[3][num-1] = 1
		}
	}

	for i := 0; i < 4; i++ {
		for j := 0; j < 13; j++ {
			if sets[i][j] == 0 {
				if i == 0 {
					fmt.Printf("S %d\n", j+1)
					continue
				}
				if i == 1 {
					fmt.Printf("H %d\n", j+1)
					continue
				}
				if i == 2 {
					fmt.Printf("C %d\n", j+1)
					continue
				}
				if i == 3 {
					fmt.Printf("D %d\n", j+1)
					continue
				}
			}
		}
	}
}



Measured memory_bytes: 1164
#include <iostream>
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
#define mod 1000000007
int main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    if(k==0)
    {
        cout<<1;
        return 0;
    }
    ll dp[n+1][k+1];
    ll p[n+1][k+1];
    for(int i=0;i<=n;i++)dp[i][0]=p[i][0]=1;
    for(int i=0;i<=k;i++)p[0][i]=1;
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {  
            if(j>=arr[i-1]+1)
            dp[i][j]=(p[i-1][j]-p[i-1][j-arr[i-1]-1])+mod;
            else
            dp[i][j]=(p[i-1][j]);
            dp[i][j]%=mod;
            p[i][j]=(p[i][j-1]+dp[i][j])%mod;
        }
    }
    cout<<dp[n][k]%mod;
}

Measured memory_bytes: 158080
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
#define PI 3.141592
using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int>l(n);
	int ans = 1;
	int d = 0;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	for (int i = 0; i < n; i++) {
		d += l[i];
		if (d > x) {
			break;
		}
		ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256