akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 20;
//const int mod = 998244353;

using mint = modint998244353;

mint p[N], s[N];
pair <int, int> l[K][N], r[K][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    vector <int> x(n + 2);
    for (int i = 1; i <= n; i++) cin >> x[i];
    x[0] = -2e9;
    x[n + 1] = 2e9;
    for (int i = 1; i <= n; i++){
        int v = (int)(lower_bound(x.begin(), x.end(), k + x[i]) - x.begin());
        r[0][i] = {v, -v};
        v = (int)(upper_bound(x.begin(), x.end(), -k + x[i]) - x.begin());
        l[0][i] = {v - 1, v - 1};
    }
    r[0][n + 1] = {n + 1, 0};
    for (int i = 1; i < K; i++){
        for (int j = 1; j <= n + 1; j++){
            auto y = r[i - 1][j];
            r[i][j].F = r[i - 1][y.F].F;
            r[i][j].S = r[i - 1][y.F].S + y.S;
            y = l[i - 1][j];
            l[i][j].F = l[i - 1][y.F].F;
            l[i][j].S = l[i - 1][y.F].S + y.S;
        }
    }
    int q;
    cin >> q;
    while(q--){
        int ls, rs;
        cin >> ls >> rs;
        int ans = rs - ls;
        int v = ls;
        int z = 1;
        for (int i = K - 1; i >= 0; i--){
            if (x[r[i][v].F] <= x[rs]){
                z += (1 << i);
                ans += r[i][v].S;
                v = r[i][v].F;
            }
        }
        v = rs;
        int f = 1;
        for (int i = K - 1; i >= 0; i--){
            if (x[l[i][v].F] >=  x[ls]){
                f += (1 << i);
                ans += l[i][v].S;
                v = l[i][v].F;
            }
        }
        ans += z;
        cout << ans << endl;
    }
}


Measured memory_bytes: 153484
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    K, X = map(int, readline().split())
    print(*list(range(X - K + 1, X + K)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; cin >> N;
    vector<ll> divs;
    for(ll i=1; i*i<=N; i++) {
        if(N % i == 0) {
            divs.emplace_back(i);
            if(N/i != i) divs.emplace_back(N/i);
        }
    }

    ll ans = LONGINF;
    for(auto d : divs) {
        ll x = d, y = N/d;
        chmin(ans, (x-1) + (y-1));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
#include<math.h>
#include<queue>
using namespace std;
#define MAX 300000
#define INF 3000
typedef long long ll;
typedef pair<int,int> P;

int c[6]={500,100,50,10,5,1};



int main(){
  int a,b,t;
  cin>>a>>b>>t;
  cout<<(t/a)*b<<endl;
}


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

using namespace std;

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

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

    int can[n];
    for(int i = 0; i < n; i++) can[i] = 1;

    int a, b;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        if(h[a] >= h[b]) {
            can[b] = 0;
        }
        if(h[a] <= h[b]) {
            can[a] = 0;
        }
    }

    int counter = 0;
    for(int i = 0; i < n; i++) {
        if(can[i] == 1) counter++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 4416
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    static ContestScanner in;static Writer out;static StringBuilder sb=new StringBuilder();
    public static void main(String[] args)
    {try{in=new ContestScanner();out=new Writer();Main solve=new Main();solve.solve();
        in.close();out.flush();out.close();}catch(IOException e){e.printStackTrace();}}
    void solve() throws NumberFormatException, IOException{
        int n = in.nextInt();
        int m = in.nextInt();
        int[] card = new int[n + 1];
        for (int i = 0; i < m; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt();
            card[l]++;
            card[r]--;
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            card[i + 1] += card[i];
            if (card[i] == m) count++;
        }
        System.out.println(count);
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 41256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        // int[] q = new int[N];
        PriorityQueue<Integer> q = new PriorityQueue<Integer>(Comparator.reverseOrder());
        for(int i=0;i<N;i++){
            // q[i]=sc.nextInt();
            q.add(sc.nextInt());
        }
        for(int i=0;i<M;i++){
            int num = q.poll();
            num/=2;
            q.add(num);
        }
        long ans = 0;
        for(int i=0;i<N;i++){
            int num = q.poll();
            ans+=num;
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 63088
#include<stdio.h>
int main(void){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0){
        break;
    }
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	    if(j%2==1){
	      if(i%2==1){
	          printf("#");
	      }else{
	          printf(".");
	      }
	    }else{
            if(i%2==1){
                printf(".");
            }else{
                printf("#");
            }
	        }
	    }
        printf("\n");
        }
    printf("\n");
	}
  return 0;
}


Measured memory_bytes: 2044
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;



int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,ans=0;
        cin>>n;
        for(ll i=1;i<=n;i++)
        {
            ll maxMultipleOf_i_lessThanN=floor((n*1.0)/(i*1.0));///[we have to find :(1 * i)+(2 * i)+(3 * i)+.....+(maxMultipleOf_i_lessThanN * i)]///
                                                                ///                  =(1 + 2 + 3 +....+ maxMultipleOf_i_lessThanN) * i [formula: n*(n+1)/2]

            ll tmp= ((maxMultipleOf_i_lessThanN*(maxMultipleOf_i_lessThanN+1)*i)/2);
            ans+=tmp;
        }
        cout<<ans<<endl;

    }
    return 0;
}

///---hints:----///
/*
For a positive integer j, we define g(j) as the sum of multiples of j that does not exceed N.
Find sum[g(j);j=1...N],This g(X) is a sum of an arithmetic progression,and can be calculated faster than f(X).
Specifically, let Y=floor(N/X)(the maximum integer that does not exceed N/X), then g(X)=X+2X+...+YX=(1+2+...+Y)X=Y(Y+ 1)X/2,
so by using this formula, the problem can be solved in a total of O(N) time.
*/



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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    ll n,A,B;cin>>n>>A>>B;
    string s;
    cin>>s;
    ll a,b;
    a=0;
    b=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='a'){
            if(a+b<A+B){
                a++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(s[i]=='b'){
            if(a+b<A+B && b<B){
                b++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 896
def merge(A, left, mid, right):
  global counter
  n1, n2 = mid - left, right - mid
  L, R = list(A[left:left+n1]+[float("inf")]), list(A[mid:mid+n2]+[float("inf")])
  i = j = 0
  for k in range(left, right):
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1
  counter += right - left
def mergeSort(A, left, right):
  if left+1 < right:
    mid = (left + right)//2;
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

N = int(input())
A = [int(i) for i in input().split()]
counter = 0
mergeSort(A, 0, len(A))
print(*A)
print(counter)

Measured memory_bytes: 63736
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

//	for priority queue
//	priority_queue<ipair, vector<ipair>, greater<ipair>>
using ipair = pair<int, pair<int, int>>;
bool operator>(const ipair a, const ipair b) { return a.first > b.first; };
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };

int main()
{
	ll n;
	cin >> n;
	if (n == 1)
	{
		printf("0");
		return 0;
	}

	ll nm = 100000000;
	vector<bool> prime(nm + 1, true);
	ll r = 0;
	
	for (ll i = 2; i <= nm && n > 1; i++)
	{
		if (!prime[i])
			continue;
		for (ll j = i; j <= nm; j += i)
			prime[j] = false;
		if (n % i != 0)
			continue;
		ll k = i;
		while (n % k == 0)
		{
			n /= k;
			k *= i;
			r++;
		}
		while (n % i == 0)
			n /= i;
	}

	if (n > 1)
		r++;

	printf("%lld", r);
	return 0;
}


Measured memory_bytes: 15048
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
p(6484)
a(0,1,3)
a(2,3,3,1)
for x in 0,1:
	a(x,3,x)
	for t in r(30):a(v:=x+4,v,v);a(v,3,6),exec('a(6,6,6);'*(29-t));a(6,x,T:=x*60+35+t,1);a(v,T,v)
for t in r(60):a(2,2,2);[(a(34+t-s,95+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9156
using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
			string input;
			int maxValue = 0;
			Dictionary<int, int> inputValues = new Dictionary<int, int>(200);
			for(int i=0;i < 100 && (input = Console.ReadLine()) != "A";++i){
				int inputValue = int.Parse(input);
				if(!inputValues.ContainsKey(inputValue)){
					inputValues.Add(inputValue, 0);
				}
				maxValue = ++inputValues[inputValue] > maxValue ? inputValues[inputValue] : maxValue;
			}
			inputValues.Where(i => i.Value == maxValue).OrderBy(i => i.Key).Select(i => i.Key).ToList().ForEach(n => Console.WriteLine(n));
        }
    }
}

Measured memory_bytes: 6524
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){

    unsigned long long int n;
    cin>>n;
    
    unsigned long long int te=(unsigned long long int)sqrt(n);
    
    cout<<te*te<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    B = []
    g = [[0]*(2*n) for _ in range(2*n)]
    for _ in range(n):
        a,b  = map(int,input().split())
        g[b][a] = 1
    for _ in range(n):
        c,d = map(int,input().split())
        B.append((c,d))
    B.sort()
    ans = 0
    for i,j in B:
        f = 0
        for y in range(j,-1,-1):
            for x in range(i,-1,-1):
                if g[y][x]:
                    ans += 1
                    f = 1
                    g[y][x] = 0
                    break
            if f:
                break
    print(ans)

main()

Measured memory_bytes: 9408
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

struct Circle{
	double x,y,r;
	bool operator < (const Circle &)const;
};

bool Circle::operator < (const Circle &a)const{
	return (x*x+y*y)<(a.x*a.x+a.y*a.y);
}

double dist(const Circle &a,const Circle &b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))-a.r-b.r;
}

const int MAX_N=100000;

int N;
Circle c[MAX_N];

vector<double> out;

int main(){
	do{
		scanf("%d",&N);
		if (N){
			for (int i=0;i<N;i++){
				scanf("%lf %lf %lf",&c[i].r,&c[i].x,&c[i].y);
			}
			sort(c,c+N);
			double ans=1e50;
			for (int i=0;i<N;i++){
				for (int j=i+1;j<min(N,i+4001);j++){
					ans=min(ans,dist(c[i],c[j]));
				}
			}
			out.push_back(ans);
		}
	}while(N);
	for (int i=0;i<out.size();i++){
		printf("%.12f\n",out[i]);
	}
	return 0;
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (max({a, b, c}) == 7 && min({a, b, c}) == 5 && a + b + c == 17) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
def examA():
    n, m = LI()
    ans = (n-1)*(m-1)
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define LL               long long int
#define PB               push_back
using namespace std;
LL M= 1000000000+7;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;cin>>n;
    LL a[n];
    LL dp[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
        if (i==0) dp[i]=a[i];
        else {
            dp[i]=dp[i-1]+a[i];
            dp[i]%=M;
        }
    }
    LL ans=0;
    for (int i=1;i<n;i++){
        ans+=dp[i-1]*a[i];
        ans%=M;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 6740
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int ans=0;
    rep(i,n)ans+=s[i]!=t[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <string.h>
 
int main(void){
  char day[3];
  scanf("%s",day);
  if(strcmp("SUN",day)==0)
    printf("%d",7);
  if(strcmp("MON",day)==0)
    printf("%d",6);
  if(strcmp("TUE",day)==0)
    printf("%d",5);
  if(strcmp("WED",day)==0)
    printf("%d",4);
  if(strcmp("THU",day)==0)
    printf("%d",3);
  if(strcmp("FRI",day)==0)
    printf("%d",2);
  if(strcmp("SAT",day)==0)
    printf("%d",1);
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  pair<double,int> ans={0,0};
  for(int a=0;a*A*100<=F;a++){
    for(int b=0;a*A*100+b*B*100<=F;b++){
      for(int c=0;a*A*100+b*B*100+c*C<=F;c++){
        for(int d=0;a*A*100+b*B*100+c*C+d*D<=F;d++){
          if((a*A+b*B)*E<c*C+d*D)continue;
          int f=a*A*100+b*B*100+c*C+d*D;
          if((c*C+d*D)*ans.first>=ans.second*f){
            ans.first=f;
            ans.second=c*C+d*D;
          }
        }
      }
    }
  }
  cout<<ans.first<<" "<<ans.second<<endl;
  return 0;
}


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

int n,m,q,a[N][N],b[N][N],c[N][N];
char s[N][N];

int query(int a[][N],int tx,int ty,int dx,int dy){
	return a[dx][dy]-a[tx-1][dy]-a[dx][ty-1]+a[tx-1][ty-1];
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();m=read();q=read();
	for (int i=1;i<=n;i++) scanf(" %s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='1'),
			b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(s[i][j]=='1'&&s[i-1][j]=='1'),
			c[i][j]=c[i-1][j]+c[i][j-1]-c[i-1][j-1]+(s[i][j]=='1'&&s[i][j-1]=='1');
	for (int i=1;i<=q;i++){
		int tx=read(),ty=read(),dx=read(),dy=read();
		printf("%d\n",query(a,tx,ty,dx,dy)-query(b,tx+1,ty,dx,dy)-query(c,tx,ty+1,dx,dy));
	}
	return 0;
}

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

int main() {
    int n, m, c, cnt = 0;
    cin >> n >> m >> c;
    vector<vector<int> > a(n, vector<int>(m));
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    rep(i, n) rep(j, m) cin >> a[i][j];

    rep(i, n) {
        int sum = 0;
        rep(j, m) {
            sum += a[i][j] * b[j];
        }
        if(sum + c > 0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  string s;
  cin >> s;
  int c = count(all(s), 'A');
  int c2 = count(all(s), 'B');
  if(c && c2) cout<< "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s;
  cin >> s;
  vector<int> a(3, 0);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') {
      a[0]++;
    } else if (s[i] == 'b') {
      a[1]++;
    } else {
      a[2]++;
    }
  }
  sort(a.rbegin(), a.rend());
  if (s.size() == 1) {
    cout << "YES" << endl;
    return 0;
  }

  for (int i = 0; i < s.size(); i++) {
    if (i % 3 == 0) {
      a[0]--;
    } else if (i % 3 == 1) {
      a[1]--;
    } else {
      a[2]--;
    }
    int judge = *min_element(a.begin(), a.end());
    if (judge < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> S(N+1, 0);
  for(int i=0; i<M; i++){
    int l,r;
    cin >> l >> r;
    S[l-1]++;
    S[r]--;
  }
  for(int i=0; i<N; i++){
    S[i+1] += S[i];
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(S[i] == M){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>
#include <iomanip>
//#include <string.h>

using namespace std;

int main()
{
    int n,a[100],i,ass=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]!=i)
            ass++;
    }
    if(ass>2)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

//////////////////////////////////////////////////////////////////////
bool check(string s) {
	int n = s.size();
	rep(n / 2) {
		if (s[i] != s[n - 1 - i]) return false;
	}
	return true;
}
int main(void) {
	string s; cin >> s;
	string t;
	vi a;
	int n = s.size();
	int q = 0;
	rep(n) {
		if (s[i] == 'x') q++;
		else {
			a.pb(q);
			q = 0;
			t.pb(s[i]);
		}
	}
	a.pb(q);
	if (!check(t)) {
		cout << -1 << endl;
		return 0;
	}
	
	int k = a.size();
	ll ans = 0;
	rep(k / 2) {
		ans += abs(a[i] - a[k - 1 - i]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 1656
/*
    author: Salam_35
    Created at :

*/

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

/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

string ans(ll value)
{
	const int a = (int)'a';
    value = value - 1;
    string returnValue;
    while (value > -1)
    {
        int remainder = value % 26;
        returnValue+=(char)(a + remainder);
        value = value / 26  - 1;
    }
    reverse(ALL(returnValue));
    return returnValue;
}

int main()
{
    ll n;
    cin >>n;
    cout<<ans(n)<<endl;
    
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


Measured memory_bytes: 3628
n=int(input())
s=input()
al=list("abcdefghijklmnopqrstuvwxyz")
count=0
ans=0
for i in range(1,n):
  left=set(s[:i])
  right=set(s[i:])
  for j in al:
    if j in left and j in right:
      count+=1
  if ans<=count:
    ans=count
  count=0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	int l[100005], r[100005];
	for(int i=0;i<m;i++){
		cin >> l[i] >> r[i];
	}
	int lans = l[0];
	int rans = r[0];
	for(int i=0;i<m;i++){
		lans = max(lans, l[i]);
		rans = min(rans, r[i]);
	}
	cout << max(0, rans-lans+1) << endl;
	return 0;
}

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

int main(){
	char n[20];
	int k;
	
	for(int i=0;i<20;i++){
		n[i]=0;
	}
	k=0;
	while(cin >> n[k]){
		if(k%2==0){
			if(n[k]=='A'){
				k++;
			}
			else{
				n[k]=0;
			}
		}
		if(k%2==1){
			if(n[k]=='Z'){
				k++;
			}
			else{
				n[k]=0;
			}
		}
	}
	if(n[k-1]=='A'){
		n[k-1]=0;
		k--;
	}
	if(k==0){
		cout <<"-1\n";
		return 0;
	}
	cout << n <<"\n";
return 0;
}

Measured memory_bytes: 1104
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, i, j;
    vector <pair<int, int>> v;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; i++) {
        for (j = i + 1; j <= n; j++) {
            if (i + j == n + 1 - n % 2) continue;
            v.push_back(make_pair(i, j));
        }
    }
    
    printf("%d\n", v.size());
    for (i = 0; i < v.size(); i++) printf("%d %d\n", v[i].first, v[i].second);
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x;
    rep(i, n){ int tmp; cin >> tmp; x.push_back(tmp);}

    ll ans = MOD;
    rep(i, n-k+1){
        ll tans = 0;
        ll l = x[i];
        ll r = x[i+k-1];

        ll hugo = (ll)l * (ll)r;
        if (hugo < 0){
            tans = min(abs(l)*2+abs(r), abs(r)*2+abs(l));
        } else {
            tans = max(abs(l),abs(r));
        }
        ans = min(ans, tans);
    }
    cout << ans << endl;
}



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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
const ll INF=1000000;
const ll MOD=1000000007;

int main(){
  int N,K,X,Y;cin>>N>>K>>X>>Y;
  cout<<min(K,N)*X+max(0,N-K)*Y<<endl;
}


Measured memory_bytes: 256
/* 2020/04/09 Atcoder Beginner Contest 145 C - Average Length */

#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++) vec[i] = i + 1;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];

    long double d = 0.0;
    int cnt = 0;
    do {
        for(int i = 0; i < n - 1; i++){
        double distx, disty;
        distx = x[vec[i + 1] - 1] - x[vec[i] - 1];
        disty = y[vec[i + 1] - 1] - y[vec[i] - 1];
        d += sqrt(pow(distx, 2) + pow(disty, 2));
        }
        cnt++;
    } while(next_permutation(vec.begin(), vec.end()));

    cout << fixed << setprecision(10) << d / cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    long long n;
    cin >> n;
    string result = "";
    int tmp = 0;
    while (n > 0) {
        n -= 1;
        tmp = n % 26;
        result += char('a' + tmp);
        n = n / 26;
    }
    reverse(result.begin(), result.end());
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3132
class UnionFind:
  def __init__(self, N):
    self.par=[i for i in range(N)]
    self.rank=[0 for _ in range(N)]
    self.size=[1 for _ in range(N)]
    
  def unite(self, x, y):
    x=self.getroot(x)
    y=self.getroot(y)
    if x!=y:
      if self.rank[x]<self.rank[y]:
        x, y=y, x
      if self.rank[x]==self.rank[y]:
        self.rank[x]+=1
      self.par[y]=x
      self.size[x]+=self.size[y]
      
  def united(self, x, y):
    return self.getroot(x)==self.getroot(y)
      
  def getroot(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x]=self.getroot(self.par[x])
      return self.par[x]

  def getsize(self, x):
    return self.size[self.getroot(x)]
  
from collections import defaultdict

N, K, L=map(int, input().split())
UF1=UnionFind(N+1)
UF2=UnionFind(N+1)
for _ in range(K):
  p, q=map(int, input().split())
  UF1.unite(p, q)
  
for _ in range(L):
  r, s=map(int, input().split())
  UF2.unite(r, s)
  
nums=defaultdict(int)
for i in range(1, N+1):
  nums[str(UF1.getroot(i))+'_'+str(UF2.getroot(i))]+=1
  
for i in range(1, N+1):
  print(nums[str(UF1.getroot(i))+'_'+str(UF2.getroot(i))])

Measured memory_bytes: 56504
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int V = sc.nextInt(); //頂点
		int edge = sc.nextInt(); //辺

		int[] masterNodeList = new int[V];
		ArrayDeque<Integer> noticeQueue = new ArrayDeque<Integer>();
		List<Integer>[] edgeList = new ArrayList[V + 1]; //各nodeが持つedgeを集約する

		for (int i = 0; i < edgeList.length; i++) {
			edgeList[i] = new ArrayList<Integer>();
		}

		//辺をノードごとに集約
		for (int i = 0; i < edge; i++) {
			int edge_a = sc.nextInt();
			int edge_b = sc.nextInt();
			edgeList[edge_a].add(edge_b);
			edgeList[edge_b].add(edge_a);
		}

		for (int i = 1; i < edgeList.length; i++) {
			List<Integer> list = edgeList[i];
			System.out.println(list.size());
		}

	}
}



Measured memory_bytes: 35972
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;

int main(){
    LL a,b,c;
    cin >> a >> b >> c;
    int count=0;
    while(1){
        if(count==100){
            count=-1;
            break;
        }
        if(a%2==1||b%2==1||c%2==1){
            break;
        }
        LL x,y,z;
        x=a,y=b,z=c;
        a=(y+z)/2;
        b=(x+z)/2;
        c=(x+y)/2;
        count++;
    }
    cout << count << endl;
    return 0;
}


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

#define NMAX 100005
using namespace std;

int dp[NMAX], dg[NMAX];
vector<int>G[NMAX];

void DFS(int nod){
    for(auto it: G[nod]){
        if(dp[it] == 0)
            DFS(it);
        dp[nod] = max(dp[nod], dp[it] + 1);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;

    for(int i = 1; i <= m; ++i){
        int x, y;
        cin >> x >> y;

        G[x].emplace_back(y);
        dg[y]++;
    }

    for(int i = 1; i <= n; ++i)
        if(dg[i] == 0)
            DFS(i);

    int maxx = 0;
    for(int i = 1; i <= n; ++i)
        maxx = max(maxx, dp[i]);
    cout << maxx << '\n';
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  if(n%2==0){
    rep(i,0,min(m,n/4)){
      cout<<i+1<<" "<<n-i<<endl;
    }
    rep(i,0,m-n/4){
      cout<<n/4+1+i<<" "<<n-n/4-1-i<<endl;
    }
  }
  else{
    rep(i,0,m){
      cout<<i+1<<" "<<n-i<<endl;
    }
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("1"); return;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

inline int bsr(ll x) { return 63^__builtin_clzll(x);}
struct BB {
  const int n = 60;
  vl d;
  BB(): d(n) {}
  void add(ll x) {
    x = tomin(x);
    if (!x) return;
    int p = bsr(x);
    rep(i,n) if (d[i]>>p&1) d[i] ^= x;
    d[p] = x;
  };
  ll& operator[] (int i) { return d[i];}
  inline ll tomin(ll x) {
    drep(i,n) if (x>>i&1) x ^= d[i];
    return x;
  }
  inline ll tomax(ll x) {
    drep(i,n) if (~x>>i&1) x ^= d[i];
    return x;
  }
};


void solve() {
  int n;
  scanf("%d",&n);
  vl a(n);
  cin>>a;
  string s;
  cin>>s;
  BB b;
  drep(i,n) {
    if (s[i] == '0') {
      b.add(a[i]);
    } else {
      if (b.tomin(a[i])) dame;
    }
  }
  cout<<0<<endl;
}

int main() {
  int ts;
  scanf("%d",&ts);
  rep(ti,ts) solve();
  return 0;
}






















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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#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()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {
	int n;
	cin >> n;
	cout << fixed << setprecision(8);
	cout << (double)n*2*M_PI << endl;
}


Measured memory_bytes: 3808
N,A,B=map(int,input().split(' '))
S=input()
n = 0
b = 0
for i in S:
    if (i=='a' and n < A+B) or(i=='b' and n<A+B and b<B):
        print('Yes')
        if i=='b':
            b += 1
        n += 1
    else:
        print('No')

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 200002

int n;
int a[MAXN];
int b[MAXN];

inline int gcd(int a, int b) {
	if (!a || !b) return a + b;
	return __gcd(a, b);
}

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	if (n == 1) {
		puts(a[0] > 1 ? "First" : "Second");
		return 0;
	}

	int turn = 0;
	while(1) {
		ll s = 0;
		for (int i = 0; i < n; ++i) {
			s += a[i];
			b[i] = a[i];
			if (i) b[i] = gcd(b[i - 1], a[i]);
		}
		if ((s - n) & 1) {
			puts(!turn ? "First" : "Second");
			return 0;
		}
		int made = 0;
		int cur = 0;
		for (int i = n - 1; i >= 0; --i) {
			int t = cur;
			if (i) t = gcd(t, b[i - 1]);
			t = gcd(t, a[i] - 1);
			if (a[i] > 1 && t > 1) {
				for (int i = 0; i < n; ++i)
					a[i] /= t;
				made = 1;
				break;
			}
			cur = gcd(cur, a[i]);
		}
		if (!made) {
			puts(turn ? "First" : "Second");
			return 0;
		}
		turn ^= 1;
	}

	return 0;
}


Measured memory_bytes: 1152
<?php
define("MOD", 10**9+7);

list($x, $y) = ints();
$diff = abs($x-$y);
$st = ($x + $y) - $diff * 3;
if($st < 0 || ($x+$y) % 3 != 0){
  echo 0;exit;
}
$a = $st/6;
$b = $st/6+$diff;
echo nCm($a+$b, $a);

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}
//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}

Measured memory_bytes: 98808
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
 string str;
 cin >> str;
 int i = atoi(str.c_str());
 int h = 0;
 int m = 0;
 int s = 0;
if(i != 0){
  h = i / 3600;
  m = i % 3600 / 60;
  s = i % 3600 % 60;
}
 cout << h << ":" << m << ":" << s << endl;
}


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

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i]-0x40 + n > 26)s[i] = s[i] + n - 26;
    else s[i] = s[i] + n;
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
#define MAX 100000

int A[MAX],n;
int part(int p,int r)
{
    int x,i,j;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++)
    {
        if(A[j]<=x)
        {
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

int main()
{
    int i,q;
    cin>>n;

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

    q=part(0,n-1);

    for(i=0;i<n;i++)
    {
        if(i) cout<<" ";
        if(i==q)cout<<"[";
        cout<<A[i];
        if(i==q)cout<<"]";
    }
    cout<<endl;
    /*int x,y;
    x=2;
    y=3;
    swap(x,y);
    cout<<x<<" "<<y<<endl;*/
    return 0;

}

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

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto c = lread!char();
    writeln((c + 1).to!char);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

const int MAX_N = 1 << 17;
const int INF = 1 << 30;

template <class T>
struct MinSegTree2 {
	int n;
	T segMin[2 * MAX_N - 1], segAdd[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) segMin[i] = 0;
	}

	void add(int a, int b, T x) { add(a, b, x, 0, 0, n); }

	void add(int a, int b, T x, int k, int l, int r) {
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) {
			segAdd[k] += x;
			return;
		}
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1], segMin[k * 2 + 2] + segMin[k * 2 + 2]);
	}

	T query(int a, int b) { return query(a, b, 0, 0, n); }

	T query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return INF;
		if(a <= l && r <= b) return segMin[k] + segAdd[k];
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr) + segAdd[k];
	}
};

MinSegTree2<int> st;

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

	int n, q;
	cin >> n >> q;

	st.init(n);
	while(q--) {
		int a;
		cin >> a;
		if(a == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			st.add(s - 1, t, x);
		}
		else {
			int i;
			cin >> i;
			cout << st.query(i - 1, i) << endl;
		}
	}
}

Measured memory_bytes: 4984
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

h,w,k=map(int,input().split())
C = [input() for i in range(h)]
for biti in range(2**h):
  for bitj in range(2**w):
    count = 0
    for i in range(h):
      for j in range(w):
        if C[i][j] == "." or (biti >> i &1) or (bitj >> j & 1):count += 1
    if h*w-count == k:
      ans += 1
    # print(count)
print(ans)
        


Measured memory_bytes: 74528
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[100];
	int ans,sum,i,j,k;
	cin >> n;
	for(i = 0; i < n; i++)	cin >> box[i];
	for(i = 100; i >= 1; i--){
		sum = 0;
		for(j = 0; j < n; j++){
			if(i <= box[j])	sum++;
		}
		if(i <= sum){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}
	


Measured memory_bytes: 3128