akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void test(){
//    for(int i = 0; i <= 6; i++){
//        ll p;
//        if(i == 0) p = 1;
//        else{
//            p = 2;
//            int t = i;
//            while(--t){
//                p *= p;
//            }
//        }
//        p+=1;
//
//        cout << p << endl;
//
//        ll ans = 1;
//        for(ll i = 0; i < p-2;i++){
//            ans = (ans*10 + 1)%p;
//        }
//    }
    ll p = 4294967311;
    ll ans = 1;
    for(ll i = 0; i < p-2;i++){
        ans = (ans*10 + 1)%p;
    }
    cout << ans << endl;
}
bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}
void test2(){
    ll p = 4294967297;
    while(!IsPrime(p)){
        p++;
    }
    cout << p << endl;
}
template<class Type>
Type solve(Type res = Type()){
    int n; cin >> n;
    if(n == 0) return 1;
    if(n == 1) return 2;
    if(n == 2) return 1;
    return 0;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //test();
    //solve<ll>();
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



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

const int N = 50;

int n, k;
long long ans = -1;
int xx[N + 10], yy[N + 10];
pair <int, int> a[N*N + 10];

int main()
{
	//freopen("F:\\rush.txt", "r", stdin);
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	int nn = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			a[++nn] = make_pair(xx[i], yy[j]);
	for (int i = 1; i <= nn; i++)
	{
		for (int j = i+1; j <= nn; j++)
		{
			int x1 = min(a[i].first, a[j].first);
			int x2 = max(a[i].first, a[j].first);
			int y1 = min(a[i].second, a[j].second);
			int y2 = max(a[i].second, a[j].second);
			int num = 0;
			for (int kk = 1; kk <= n; kk++)
				if (x1 <= xx[kk] && xx[kk] <= x2 && y1 <= yy[kk] && yy[kk] <= y2)
					num++;
			if (num >= k)
			{
				long long s = 1LL * (x2 - x1)*(y2 - y1);
				if (ans == -1)
					ans = s;
				else
					ans = min(ans, s);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int n,i,ans=1;
    cin>>n;
    vector <int> s(n,0);
    for(i=0;i<n;i++) cin>>s[i];
    sort(s.begin(),s.end());
    int cnt=s[0];
    for(i=1;i<n;i++)
    {
        if(cnt!=s[i]) 
        {
            cnt=s[i];
            ans++;
        }
    }
    cout<<ans;
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
import java.util.Scanner

object Main extends App {
  def readALine(c:Int, ac:List[Int]):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
    if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val ls = readALine(N, Nil)


  def reverse(ls:List[Int], ac:List[Int]): List[Int] = {
    if (ls.isEmpty) ac else reverse(ls.tail, ls.head::ac)
  }
  
  println(reverse(ls, Nil).mkString(" "))

}


Measured memory_bytes: 45060
while 1:
    H,W=map(int,input().split())
    if H==W==0:break
    maze=[]
    root=[]
    x=0
    y=0
    for i in range(H):
        maze.append(list(input()))
    while 1:
        if maze[y][x]==">":
            x+=1
        elif maze[y][x]=="<":
            x-=1
        elif maze[y][x]=="^":
            y-=1
        elif maze[y][x]=="v":
            y+=1
        else:
            print(x,y)
            break
        if x+y*W in root:
            print("LOOP")
            break
        root.append(x+y*W)


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

int main(){
	int n;
	while( cin >> n , n ){
		int num = 0;
		int ans = 0;
		for(int i=1 ; i <= n/2 ; i++ ){
			num = i;
			int j = i;
			while( num < n ){
				num += ++j;
				if( num == n )
					ans++; 
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

struct edge {
	int to, cost;
};

int N, M, A, B, C, P;
vector<edge>v[2500];
ll dist[2500], res;

int main() {
	cin >> N >> M >> P;
	for (int i = 0; i < M; ++i) {
		cin >> A >> B >> C;
		v[A - 1].push_back({ B - 1,C });
	}
	for (int i = 1; i < N; ++i) {
		dist[i] = -0xE869120E869120;
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			for (edge e : v[j]) {
				dist[e.to] = max(dist[e.to], dist[j] + e.cost - P);
			}
		}
	}
	res = dist[N - 1];
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			for (edge e : v[j]) {
				dist[e.to] = max(dist[e.to], dist[j] + e.cost - P);
			}
		}
	}
	if (res < dist[N - 1]) {
		cout << -1 << endl;
	}
	else {
		cout << max(0ll, res) << endl;
	}
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		long a = stdIn.nextLong();
		long b = stdIn.nextLong();
		long c = stdIn.nextLong();
		
		long k = stdIn.nextLong();
		
		if(Math.abs(a-b)>1e18) {
			System.out.println("Unfair");
		}else if(k%2==1) {	
		System.out.println(b-a);
		}else {
			System.out.println(a-b);
		}
/*		for(int i = 0; i < k; i++) {
			long atmp = a;
			long btmp = b;
			a = b+c;
			b = atmp + c;
			c = atmp + btmp;
		}
		if(a-b>1e18) {
			System.out.println("Unfair");
		}else {	
		System.out.println(a-b);
		}
		*/
	}

}


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

typedef long long ll;
const int N=200100;
ll a[N],b[N];
int n,K;

ll solve(int l,int r){
	if(l==r)return 0;
	int mid=(l+r)/2;
	ll ret=solve(l,mid)+solve(mid+1,r);
	for(int i=l,j=mid+1,cnt=l;i<=mid||j<=r;)
		if(j>r||(i<=mid&&a[i]<=a[j])){ret+=r-j+1;b[cnt++]=a[i++];}
		else b[cnt++]=a[j++];
	for(int i=l;i<=r;++i)a[i]=b[i];
	return ret;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>K;
	for(int i=1;i<=n;++i){int x;cin>>x;a[i]=a[i-1]+x-K;}
	cout<<solve(0,n)<<'\n';
	return 0;
}


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

int main() {
   ll n;
  cin>>n;
  vector<ll>v;
  ll ans=LONG_MAX;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(i==n/i)
      {
             v.push_back(i);
      }
      else
      {
        v.push_back(i);
        v.push_back(n/i);
      }
    }
  }
  /*for(int i=0;i<v.size();i++)
  {
    cout<<v[i]<<" ";
  }
  cout<<endl<<endl;
  */
  for(int i=0;i<v.size();i++)
  {
    ll temp=n/v[i]+(v[i]-2);
    //cout<<"Temp "<<temp<<endl;
    if(ans>temp)
    {
      ans=temp;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
struct Node;
vector<Node> V;
lint N, X, M;
lint ans = 0;
lint sum = 0;
lint cnt = 0;
struct Node {
  lint idx;
  int nbr;
  bool vst = false;
  int dfs() {
    if(N == 0 || vst) return idx;
    vst = true;
    ans += idx;
    N--;
    return V[nbr].dfs();
  };
  void dfs2() {
    if(vst) return;
    vst = true;
    sum += idx;
    cnt++;
    V[nbr].dfs2();
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> X >> M;
  REP(i, M) V.emplace_back();
  REP(i, M) V[i].idx = i;
  REP(i, M) V[i].nbr = (lint)i*i%M;
  int idx = V[X].dfs();
  if(N != 0) {
    REP(i, M) V[i].vst = false;
    V[idx].dfs2();
    ans += N / cnt * sum;
    N %= cnt;
    REP(i, M) V[i].vst = false;
    V[idx].dfs();
  }
  cout << ans << endl;
}

Measured memory_bytes: 5320
#include<stdio.h>

int main(void)
{
    int a,b,c,d,x,y;

    scanf("%d%d%d%d",&a,&b,&c,&d);
    if (a>b)
    x=b;
    else
    x=a;

    if(c>d)
    y=d;
    else
    y=c;

    printf("%d\n",x+y);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

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

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int lower_bound(int *arr, int size, int key) {
    int low = -1;
    int high = size;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        if(arr[mid] >= key) {
            high = mid;
        } else {
            low = mid;
        }
    }
    return high;
}

int main(void) {
    int num, selects;
    get_int2(&num, &selects);

    static int arr[NUM_MAX];
    fget_array(arr, num);

    int ans = 0;
    int k, i;
    for(k = 1; k <= min(num, selects); k++) {
        int max_remove = min(k, selects-k);
        int items[NUM_MAX] = {0};
        int left, right;
        for(left = 0; left <= k; left++) {
            int res = 0;
            right = num-(k-left);
            int idx = 0;
            for(i = 0; i < left; i++) {
                items[idx++] = arr[i];
            }
            for(i = right; i < num; i++) {
                items[idx++] = arr[i];
            }
            qsort(items, k, sizeof(int), asc);
#ifdef DEBUG
            printf("k :%d  : ", k);
            for(i = 0; i < k; i++) {
                printf(" %d", items[i]);
            }
            putchar('\n');
#endif
            int start = lower_bound(items, k, 0);
            start = min(start, max_remove);
            for(i = start; i < k; i++) {
                res += items[i];
            }
#ifdef DEBUG
            printf("[k: %d] [%d %d] -> %d\n", k, left, right, res);
#endif
            ans = max(res, ans);
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  if (N<1 || N>100 || K<1 || K>100){
    return 0;
  }
  vector<int> position(N);
  for(int i=0; i<N; ++i){
    int x;
    cin >> x;
    if(x <= 0 || x >= K){
      return 0;
    }
    position.at(i) = x;
  }
  int distance = 0;
  for(int i=0; i<N; ++i){
    if (position.at(i) < (K - position.at(i))){
      distance += position.at(i);
    }
    else{
      distance += K - position.at(i);
    }
  }
  distance *= 2;
  cout << distance << endl;
  return 0;
}


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

int main()
{
    int n;
    vector<int> p;
    int temp;
    int c=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        p.push_back(temp);
    }
    for(int i=1;i<n-1;i++)
    {
        if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1]))
        {
            c++;
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include <ext/numeric>
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))
#define     pii       pair<int,int>
#define     N         100005
using namespace std;

bool cmp(const pair<string,int> &a, const pair<string,int> &b)
{
        if(a.first==b.first)
            return (a.second > b.second);
        else return (a.first<b.first);

}

int main(){
    __;

#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif

    string s;
    int n,a;
    vector< pair<string,int> >v;
    map <int,int>mp;


    cin>>n;

     for(int i=0;i<n;i++)
     {
         cin >> s >> a;
         v.emplace_back(s,a);
         mp[a]=i+1;
     }

    sort(v.begin(),v.end(),cmp);

    for(int i=0;i<n;i++)
    {
        cout<< mp[v[i].second] <<endl;

    }

   return 0;
}


Measured memory_bytes: 384
//-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  set<int> SI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if ((A > D&&B > C) || (A < D&&B < C))
	{
		COUT(0);
	}
	else 
	{
		COUT(min(B, D) - max(A, C));
	}

	#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vector<vi> c(10, vi(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    vector<vi> a(h, vi(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    vector<vi> dp(10, vi(10, INF));
    rep(i, 10) rep(j, 10) dp[i][j] = c[i][j];
    rep1(k, 10) rep(i, 10) rep(j, 10) dp[i][j] = min(dp[i][j], dp[i][k-1]+dp[k-1][j]);
    int ans = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] == -1) continue;
        ans += dp[a[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
s = input()
ans = 0
ACGT = {"A", "C", "G", "T"}
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        if set(s[i:j]) <= ACGT:
            ans = max(ans, len(s[i:j]))
print(ans)

Measured memory_bytes: 8932
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,a,b) for (int i = a; i < (b); i++)
#define sz(t) int(t.size())
using namespace std;
typedef long long ll;


vector<string> s;

map<string,ll> m;

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

    REP(i, 0, n) {
        char tmp_str[11];
        REP(j, 0, 10) {
            char c;
            cin >> c;
            tmp_str[j] = c;
        }
        sort(tmp_str, tmp_str + 10);
        string tmp = string(tmp_str);
        s.push_back(tmp);
    }

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

    REP(i, 0, n) {
        if (!m[s[i]]) {
            m[s[i]] = 1;
        }
        else {
            m[s[i]]++;
        }
    }

    ll ans = 0;
    for (auto u: m) {
        if (u.second < 2)
            continue;

        ans += (u.second * (u.second - 1)) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12020
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
ll x[100001],y[100001];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lld",&x[i]);
		x[i]+=1000000007LL;
	}
	ll sumx=0,allx=0;
	for(int i=0;i<n;i++){
		sumx+=(ll)x[i]*i-allx;
		allx+=x[i];
		sumx%=MOD;
		allx%=MOD;
	}
	for(int i=0;i<m;i++){
		scanf("%lld",&y[i]);
		y[i]+=1000000007LL;
	}
	ll sumy=0,ally=0;
	for(int i=0;i<m;i++){
		sumy+=(ll)y[i]*i-ally;
		ally+=y[i];
		sumy%=MOD;
		ally%=MOD;
	}
	printf("%lld\n",sumx*sumy%MOD);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 201;

vector<int> G[MAX_N];

ll inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll comb(int a,int b)
{
	if(a<b){
		return 0;
	}
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

ll add(ll x,ll y)
{
    return (x + y)%MOD;
}

ll sub(ll x,ll y)
{
    return (x+MOD-y)%MOD;
}

ll mul(ll x,ll y)
{
    return x*y%MOD;
}

ll memo[MAX_N][MAX_N][MAX_N];
bool par[MAX_N];

vl mul(vl& a,vl& b)
{
    vl res(len(a)+len(b)-1,0);
    rep(i,len(a)){
        rep(j,len(b)){
            srep(k,min(i,j),i+j+1){
                res[k] = add(res[k],mul(mul(a[i],b[j]),memo[i][j][k]));
            }
        }
    }
    return res;
}

vl dp(int u,int p)
{
    vl res = {1};
    for(int v : G[u]){
        if(v != p){
            vl hoge = dp(v,u);
            res = mul(res,hoge);
        }
    }
    res.resize(len(res)+1);
    rrep(i,len(res)-1){
        res[i+1] = res[i];
    }
    res[0] = 0;
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a].pb(b);
        par[b] = true;
    }
    make();
    rep(i,n+1){
        memo[0][i][i] = memo[i][0][i] = 1;
    }
    srep(i,1,n+1){
        srep(j,1,n+1-i){
            srep(k,min(i,j),i+j+1){
                memo[i][j][k] = add(add(memo[i][j][k],memo[i-1][j][k-1]),add(memo[i][j-1][k-1],memo[i-1][j-1][k-1]));
            }
        }
    }
    int r = -1;;
    rep(i,n){
        if(!par[i]){
            r = i;
            break;
        }
    }
    vl ans = dp(r,-1);
    cout << accumulate(all(ans),0LL) % MOD << "\n";
    return 0;
}



Measured memory_bytes: 35700
"use strict";

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v);
  const a = input[0];
  const b = input[1];

  let i = a;
  let ans = 0;
  while (i <= b) {
    if (
      Math.floor(i / 10000) === i % 10 &&
      Math.floor(i / 1000) % 10 === Math.floor(i / 10) % 10
    )
      ans++;

    i++;
  }
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11596
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

vi d;
void dijkstra(v(vp) &G,int V,int s) {
// G[f][i] = P(t,c) means that from `f` to `t` 's cost is `c` 
  d = vi(V,INF);
  priority_queue<P,vp, greater<P>> que;
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()) {
    P p = que.top();
    que.pop();
    int tar = p.second;
    if(d[tar] < p.first) continue;
    rep(i,sz(G[tar])) {
      P e = G[tar][i];
      if(d[e.first] > d[tar] + e.second) {
        d[e.first] = d[tar] + e.second;
        que.push(P(d[e.first],e.first));
      }
    }
  }
}
  
int main() {
  int N,s,t;
  cin >> N >> s >> t;
  s--;
  t--;
  v(vp) G(N);
  rep(i,N-1) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(P(b,1));
    G[b].push_back(P(a,1));
  }
  dijkstra(G,N,s);
  vi ta = d;
  dijkstra(G,N,t);
  vi ao = d;
  int ans = 0;
  rep(i,N) {
    if(ta[i] < ao[i]) {
      ans = max(ans,ao[i]-1);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7604
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (1<<18);

int n, a, b;

int utnij(int x, int id) {
  int res = 0;
  for (int i = 0; i < id; ++i)
    if (x&(1<<i))
      res += (1<<i);
  for (int i = id+1; i < 18; ++i)
    if (x&(1<<i))
      res += (1<<(i-1));
  return res;
}

int dodaj(int x, int id, int co) {
  int res = 0;
  for (int i = 0; i < id; ++i)
    if (x&(1<<i))
      res += (1<<i);
  if (co == 1)
    res += (1<<id);
  for (int i = id; i < 18; ++i)
    if (x&(1<<i))
      res += (1<<(i+1));
  return res;
}

VI jeb(int n, int a, int b) {
  VI res;
  //cout<<n<<",,"<<a<<",,"<<b<<"\n";
  if (n == 2) {
    res.PB(a);
    res.PB(b);
    return res;
  }
  for (int i = 17; i >= 0; --i) {
    if ((a&(1<<i) && !(b&(1<<i)))) {
      int x = utnij(a, i);
      int y = utnij(b, i);
      int co = 0;
      for (; ; ++co) {
        if (__builtin_popcount(x)%2 != __builtin_popcount(co)%2 && co != x && co != y)
          break;
      }
      auto res1 = jeb(n/2, x, co);
      auto res2 = jeb(n/2, co, y);
      for (int j = 0; j < res1.size(); ++j)
        res1[j] = dodaj(res1[j], i, 1);
      for (int j = 0; j < res2.size(); ++j)
        res2[j] = dodaj(res2[j], i, 0);
      res = res1;
      for (int x: res2)
        res.PB(x);
      return res;
    }
    else if (!(a&(1<<i)) && (b&(1<<i))) {
      //cout<<"ucinam z a i b bit "<<i<<"\n";
      int x = utnij(a, i);
      int y = utnij(b, i);
      int co = 0;
      for (; ; ++co) {
        if (__builtin_popcount(x)%2 != __builtin_popcount(co)%2 && co != x && co != y)
          break;
      }
      //cout<<"zos "<<x<<","<<y<<" i szuk = "<<co<<"\n";
      auto res1 = jeb(n/2, x, co);
      auto res2 = jeb(n/2, co, y);
      for (int j = 0; j < res1.size(); ++j)
        res1[j] = dodaj(res1[j], i, 0);
      for (int j = 0; j < res2.size(); ++j)
        res2[j] = dodaj(res2[j], i, 1);
      res = res1;
      for (int x: res2)
        res.PB(x);
      return res;
    }
  }
}

int main() {
  init_ios();
  cin >> n >> a >> b;
  n = (1<<n);
  if (__builtin_popcount(a)%2 == __builtin_popcount(b)%2) {
    cout<<"NO\n";
    return 0;
  }
  cout<<"YES\n";
  auto res = jeb(n, a, b);
  for (int x: res)
    cout<<x<<" ";
  cout<<"\n";
}

Measured memory_bytes: 1632
import numpy as np

N = int(input())
As = list(map(int, input().split()))
Q = int(input())
BCs = [list(map(int, input().split())) for _ in range(Q)]

#rint(BCs)

ansArray = np.zeros(10**5 + 1, dtype = int)
indexArray = np.array(range(10**5+1))

for A in As:
    ansArray[A] += 1

#print(ansArray)
#print(indexArray)
ans = np.dot(ansArray, indexArray)

for BC in BCs:

    ans = ans + (BC[1] - BC[0]) * ansArray[BC[0]]
    print(ans)
    ansArray[BC[1]] += ansArray[BC[0]]
    ansArray[BC[0]] = 0


Measured memory_bytes: 54540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define lgt length()
#define sz size()
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(v) sort(v.begin(), v.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define SP(n) cout << setprecision(n) << fixed

int pow(int a, int b){
    int ans=1;
    REP(i, b){
        ans *= a;
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    int c=0;
    for(int i=0; i < 7; i++) if(N > pow(2, i)) c = i;
    cout << N - (N % pow(2, c)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

int n;
string str[10];
int sub[10][10];
int num[10];

void solve(){
	rep(i,10) num[i] = i;
	rep(i,10) rep(j,10) sub[i][j] = 0;
	rep(i,10) str[i].clear();
	rep(i,n) cin >> str[i];
	while(true){
		bool end = true;
		rep(i,n) for(int j = i+1; j < n; j++){
			if(str[i].size() > str[j].size()){
				swap(str[i],str[j]);
				end = false;
			}
		}
		if(end) break;
	}
	while(true){
		bool end = true;
		rep(i,n){
			for(int j = i+1; j < n; j++){
				rep(k,str[j].size()){
					bool ok = true;
					if(k+str[i].size() > str[j].size()) break;
					rep(l,str[i].size()){
						if(str[j][k+l] != str[i][l]){
							ok = false;
							break;
						}
					}
					if(ok){
						for(int l = i+1; l < n; l++) str[l-1] = str[l];
						n--;
						end = false;
						break;
					}
				}
				if(!end) break;
			}
			if(!end) break;
		}
		if(end) break;
	}
	rep(i,n) rep(j,n){
		if(i == j) continue;
		for(int k = 1; k <= min(str[i].size(),str[j].size()); k++){
			bool ok = true;
			rep(l,k){
				if(str[i][str[i].size()-k+l] != str[j][l]){
					ok = false;
					break;
				}
			}
			if(ok) sub[i][j] = max(sub[i][j],k);
		}
	}
	string ans;
	rep(i,1000) ans.push_back('x');
	do{
		string tmp;
		for(int i = 1; i < n; i++){
			for(int j = 0; j < str[num[i-1]].size()-sub[num[i-1]][num[i]]; j++) tmp.push_back(str[num[i-1]][j]);
		}
		tmp += str[num[n-1]];
		if(ans.size() > tmp.size() || (ans.size() == tmp.size() && ans > tmp)){
			ans = tmp;
		}
	} while(next_permutation(num, num+n));
	cout << ans << endl;
}

int main(){
	while(true){
		cin >> n;
		if(n == 0) break;
		solve();
	}
}

Measured memory_bytes: 1216
#include <cstdio>
#include <algorithm>
#include <cstring>
#define maxn 200010
using namespace std;
struct node{
	char s[12];
}q[maxn];
char pre[12];
int cmp(node a,node b){
	return strcmp(a.s,b.s)<0;
}
int main(){
	int n,i,cnt=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%s",q[i].s);
	sort(q+1,q+1+n,cmp);
	strcpy(pre,q[1].s);
	for(i=2;i<=n;i++)
		if(strcmp(q[i].s,pre)!=0)strcpy(pre,q[i].s),cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 5576
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
syo = n//k 
total = 0
for i in range(k):
  te = ''
  score = 0
  for j in range(i, n, k):
    if score == 0 or t[j] != te:
      if t[j] == 'r':
        score = p
        total += p
        te = 'r'
      elif t[j] == 's':
        score = r
        total += r
        te = 's'
      else:
        score = s
        total += s
        te = 'p'
    else:
      score = 0
      
  
print(total)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN (101010)
#define LL long long
using namespace std;
int n; 
struct Node{
	LL p,v;
	bool operator < (const Node &a)const{
		return p<a.p;
	}
	void Read(){
		scanf("%lld %lld",&p,&v);
	}
}T[MAXN];
LL C,A1[MAXN],A2[MAXN],B1[MAXN],B2[MAXN],p[MAXN],v[MAXN];
LL Max(LL a,LL b){
	if (a>b) return a;
	return b;
}
int main(){
	scanf("%d %lld",&n,&C);
	int i;
	LL ans=0;
	for (i=1;i<=n;i++) 
		T[i].Read();
	sort(T+1,T+n+1);
	for (i=1;i<=n;i++) p[i]=T[i].p,v[i]=T[i].v;
	p[n+1]=C;
	for (i=1;i<=n;i++){
		A1[i]=A1[i-1]+v[i]-(p[i]-p[i-1]);
		ans=Max(A1[i],ans);
		B1[i]=A1[i]-p[i];
		if (i>1) B1[i]=Max(B1[i],B1[i-1]);
	}
	for (i=n;i>=1;i--){
		A2[i]=A2[i+1]+v[i]-(p[i+1]-p[i]);
		ans=Max(ans,A2[i]);
		B2[i]=A2[i]-(C-p[i]);
		if (i<n) B2[i]=Max(B2[i],B2[i+1]);
	}
	for (i=1;i<n;i++) ans=Max(ans,A1[i]+B2[i+1]);
	for (i=2;i<=n;i++) ans=Max(ans,A2[i]+B1[i-1]);
	cout<<ans;
	
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

int a[30];
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int b; cin >> b;
		for (int i = 0; i < b; i++) {
			int c; cin >> c; c--;
			a[c]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (a[i] == n)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <string>

using namespace std;


int main(){
	string a;
	cin >> a;
	int len = a.size();
	int hl = len / 2;
	
	for(int i=0;i<len;i++){
		if(a[i] == 'p'){
			hl -= 1;
		}
	}
	
	printf("%d\n",hl);	
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, ans=0;
  cin >> n;
  vector<int> d(n);
  rep(i, n)cin >> d.at(i);
  for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++)ans += d.at(i)*d.at(j);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
  int main(){
     int h1[3],m1[3],s1[3];
      int h2[3],m2[3],s2[3];
       int h[3],m[3],s[3];
       int i;
         for(i=0;i<3;i++){
            scanf("%d%d%d%d%d%d",&h1[i],&m1[i],&s1[i],&h2[i],&m2[i],&s2[i]);
              }
          for(i=0;i<3;i++){
             int x[3];
             int y[3];
             y[i]=h2[i]*3600+m2[i]*60+s2[i];
             x[i]=h1[i]*3600+m1[i]*60+s1[i];
             int z[3];
             z[i]=y[i]-x[i];
             h[i]=z[i]/3600;
             z[i] -= h[i]*3600;
              m[i] = z[i]/60;
              z[i] -= m[i]*60;
              s[i] = z[i];
               printf("%d %d %d\n",h[i],m[i],s[i]);
}
return 0;
}

Measured memory_bytes: 600
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().toInt
  val words = (0 until n).map(_ => StdIn.readLine())
  val r = words.sliding(2).foldLeft((Map.empty[String, Int], true)) { (acc, lst) =>
    if (acc._2 &&
      lst(0).last == lst(1).head &&
      !acc._1.contains(lst(0)) &&
      !acc._1.contains(lst(1))) {
      (acc._1 + (lst(0) -> 1), true)
    } else {
      (Map.empty[String, Int], false)
    }
  }
  println(if (r._2) "Yes" else "No")

}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n, d;
  cin >> n >> d;
  int A[n][d];
  rep(i, n) rep(j, d) cin >> A[i][j];
  int ans = 0;
  rep(i, n) REP(j, i+1, n) {
    int s = 0;
    rep(k, d) s += (A[i][k] - A[j][k]) * (A[i][k] - A[j][k]);
    int x = 0;
    while(x*x <= s) {
      if (x*x == s) {
        ans++;
        break;
      }
      x++;
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,Count=0;
    cin>>n;
    for(int a=1; a<=9; ++a)
    {
        for(int b=1; b<=9; ++b)
        {
            if(a*b==n)
            {
                Count++;
            }
        }
    }
    if(Count==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}


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

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


Measured memory_bytes: 3536
S = input()
Q = int(input())
mae = ''
ushiro = ''
rotate = False
for _ in range(Q):
  query = input()
  if query[0] == '1':
    rotate = not rotate
  else:
    if query[2] == '1':
      if rotate:
        ushiro = ushiro + query[4]
      else:
        mae = query[4] + mae
    else:
      if rotate:
        mae = query[4] + mae
      else:
        ushiro = ushiro + query[4]
print(mae + S + ushiro if not rotate else (mae + S + ushiro)[::-1])

Measured memory_bytes: 4532
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = 0;
		a += scanner.nextInt();
		a += scanner.nextInt();
		String s =(scanner.nextInt() <= a) ? "Yes" : "No" ;
		
		System.out.println(s);
	}
 
}

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

int main() {
	// your code goes here
	int A=0,B=0;
	for(int i=0;i<4;i++){
		int temp;
		cin >> temp;
		A+=temp;
	}
	for(int i=0;i<4;i++){
		int temp;
		cin >> temp;
		B+=temp;
	}
	if(A<B)
		cout << B << endl;
	else
		cout << A << endl;
	return 0;
}

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

// const int SIZE=300;
const int SIZE=300;
const int FSIZE=SIZE*2+2;

vector<vector<int>> transpose(vector<vector<int>> x){
    int m=x.size(),n=x[0].size();
    vector<vector<int>> res(n,vector<int>(m));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            res[j][i]=x[i][j];
        }
    }
    return res;
}

void debug(vector<vector<int>> mat){
    for(auto &row:mat){
        for(auto e:row){
            cerr<<e;
        }
        cerr<<endl;
    }
}
int main(){
    vector<vector<int>> f(FSIZE,vector<int>(FSIZE));
    {
        int h,w;
        cin>>h>>w;
        vector<string> s(h);
        for(int i=0;i<h;i++) cin>>s[i];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]=='#'){
                    int x=i+j;
                    int y=i-j+SIZE;
                    assert(0<=x && x<FSIZE && 0<=y && y<FSIZE);
                    f[x][y]=true;
                }
            }
        }
    }
    // debug(f);
    vector<vector<int>> sum(FSIZE+1,vector<int>(FSIZE+1,0));
    for(int i=0;i<FSIZE;i++){
        for(int j=0;j<FSIZE;j++){
            sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j]+f[i][j];
        }
    }
    
    auto rect=[&](int x0,int y0,int x1,int y1){
        return sum[x1][y1]-sum[x0][y1]-sum[x1][y0]+sum[x0][y0];
    };
    auto calc=[&](){
        int res=0;
        for(int i=0;i<FSIZE;i++){
            vector<int> pos;
            for(int j=0;j<FSIZE;j++) if(f[i][j]) pos.push_back(j);
            for(int p=0;p<pos.size();p++){
                for(int q=0;q<p;q++){
                    int py=pos[p],qy=pos[q];
                    int d=py-qy;
                    if(i-d>=0) res+=rect(i-d,qy+1,i-d+1,py);
                    if(i+d<FSIZE) res+=rect(i+d,qy+1,i+d+1,py);
                }
            }
        }
        return res;
    };
    auto calc2=[&](){
        int res=0;
        for(int i=0;i<FSIZE;i++){
            vector<int> pos;
            for(int j=0;j<FSIZE;j++) if(f[i][j]) pos.push_back(j);
            for(int p=0;p<pos.size();p++){
                for(int q=0;q<p;q++){
                    int py=pos[p],qy=pos[q];
                    int d=py-qy;
                    if(i-d>=0) res+=f[i-d][qy];
                    if(i-d>=0) res+=f[i-d][py];
                    if(i+d<FSIZE) res+=f[i+d][qy];
                    if(i+d<FSIZE) res+=f[i+d][py];
                }
            }
        }
        return res;
    };
    int res=0;
    res+=calc();
    // res+=calc2();
    f=transpose(f);
    sum=transpose(sum);
    res+=calc();
    res+=calc2();

    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 COM(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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    ll N,M; cin >> N >> M;
    ll out=0;
    if(2*N<M){
        out = N;
        ll tmp=M-2*N;
        out = out + tmp/4;
    }else{
        out = M/2;
    }
    
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 256
x,y=map(int,input().split())
if abs(x)==abs(y):
    print(1)
elif x>0 and y>0:
    if x<=y:
        print(y-x)
    else:
        print(x-y+2)
elif x>0 and y<0:
    print(abs(x+y)+1)
elif x<0 and y>0:
    print(abs(x+y)+1)
elif x<0 and y<0:
    if x<=y:
        print(abs(y-x))
    else:
        print(abs(x-y)+2)
elif x==0:
    if y>=0:
        print(y)
    else:
        print(abs(y)+1)
elif y==0:
    if x<=0:
        print(abs(x))
    else:
        print(abs(x)+1)

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int c[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  int sumx[3] = { 0, 0, 0 };
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      sumx[i] += c[i][j];
    }
  }
  int sumy[3] = { 0, 0, 0 };
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < 3; i++) {
      sumy[j] += c[i][j];
    }
  }
  dumpv(sumx, 3);
  dumpv(sumy, 3);
  int a12 = sumx[0] - sumx[1];
  int a23 = sumx[1] - sumx[2];
  int a31 = sumx[2] - sumx[0];
  int b12 = sumy[0] - sumy[1];
  int b23 = sumy[1] - sumy[2];
  int b31 = sumy[2] - sumy[0];
  if (a12 % 3 || a23 % 3 || a31 % 3 || b12 % 3 || b23 % 3 || b31 % 3) {
    cout << "No" << endl;
    return;
  }
  dump(a12, a23, a31, b12, b23, b31);
  if (a23 + a12 == -a31 && b23 + b12 == -b31)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
#define N 100
int main(){
    int n,a[N],i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=n-1;i>0;i--)
        cout<<a[i]<<" ";
    cout<<a[0];
    cout<<endl;
    

}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    ll A, B;
    cin >> A >> B;

    if (A+B >= 10) {
        cout << "error" << endl;
    } else {
        cout << A+B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int k;
	cin >> k;
	V<int> a(k);
	rep(i, k)cin >> a[k - 1 - i];

	ll mx = 2, mn = 2;
	bool ok = true;
	
	rep(i, k) {
		ll u = mx / a[i] * a[i];
		ll d = ((mn - 1) / a[i] + 1) * a[i];
		if (u < d) { ok = false;break; }
		mx = u + a[i] - 1;
		mn = d;
	}

	if (ok)cout << mn << " " << mx << endl;
	else cout << -1 << endl;

}

Measured memory_bytes: 640
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		long n = long.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
		var b = Console.ReadLine().Split().Select(y => long.Parse(y)).ToArray();
		long counter = 0;
		
		for(long i=n;i>0;i--){
			if(a[i]>=b[i-1]){
				counter += b[i-1];
				a[i] -= b[i-1];
			}else{
				counter += a[i];
				b[i-1] -= a[i];
				if(a[i-1]>=b[i-1]){
					counter += b[i-1];
					a[i-1] -= b[i-1];
				}else{
					counter += a[i-1];
					b[i-1] -= a[i-1];
					a[i-1] = 0;
				}
			}
		}
		
		Console.WriteLine(counter);
		
	}
}

Measured memory_bytes: 41944
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */
#define sq(x) (x) * (x)

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n = in();
  ll ans = INF;
  vi a(n); REP(i, n) cin >> a[i];

  REPS(i, -100, 201) {
    ll cost = 0;
    REP(j, n) {
      cost += sq(a[j] - i);
    }
    ans = min(ans, cost);
  }
  print(ans);

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=1e4+5;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int r;cin>>r;
    double pi=3.1415926;
    cout<<setprecision(4)<<fixed<<2*pi*r;
}


Measured memory_bytes: 3804