akhauriyash/Code-Regression huggingface dataset:
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int x,y;
  cin>>x>>y;
  if(x>=y) cout<<10;
  else cout<<0;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rrep(i, a, b) for(int i=b-1; i>=a; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define rREP(i, n) for(int i=n-1; i>=0; i--)
#define MAX 200
typedef long long ll;
using namespace std;

int sumDigit(int n){
  int sum = 0;
  for(char c:to_string(n)){
    sum += (c - '0');
  }
  return sum;
}

int main(void){
  int n;  cin >> n;
  int sd = sumDigit(n);
  if(n%sd == 0)  cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]

from itertools import accumulate
from bisect import bisect_left, bisect_right

ts = list(accumulate(A)) + [0]

r = 0

def calc(st, ed):
    t0 = ts[ed-1] - ts[st-1]
    i1 = bisect_left(ts, (ts[ed-1] + ts[st-1]) / 2, st + 1, ed - 1)
    t11 = ts[i1-1] - ts[st-1]
    t12 = t0 - t11
    t21 = ts[i1] - ts[st-1]
    t22 = t0 - t21
    #print("*", st, ed, t0, i1, t11, t12, t21, t22)
    if abs(t22-t21) > abs(t12-t11):
        return t11, t12
    else:
        return t21, t22

result = 999999999999999999999999
for i in range(2, N-1):
    r1, r2 = calc(0, i)
    r3, r4 = calc(i, N)
    #print(r1, r2, r3, r4)
    r = max(r1, r2, r3, r4) - min(r1, r2, r3, r4)
    result = min(result, r)

print(result)


Measured memory_bytes: 24664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    REP(i, s.size()){
        if (s[i]!=t[i]) {
            ans++;
        }
    }
    COUT(ans);
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

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

		else if(s[i]=='b'){
			if(abnt<a+b&&bnt<b){
				cout<<"Yes"<<endl;
				abnt++;bnt++;
			}
			else cout<<"No"<<endl;
		}

		else {
			cout<<"No"<<endl;
		}
	}
}

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

int check(int j,int k, int a, int b){
    int ans = 0;
    if ((k + j) % 2 == 0)
        ans = 1;
    return (ans);
}

int main(void){
    for (int i = 0; i < 1000; i++){
        int a, b;
            cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        for (int j = 0; j < a; j++){
            for (int k = 0; k < b; k++){
                if (check(j, k, a, b))
                    cout << "#";
                else
                    cout << ".";
                if (k == b - 1)
                    cout << endl;
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3076
using System;
using System.Linq;
namespace AGC012A
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(a);
            long ans = 0;
            for (int i = 2; i <= 2 * n; i += 2)
                ans += a[3 * n - i];
            Console.WriteLine(ans);
        }
    }
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e5 + 10;
int n, k, A[maxn], tmp[maxn];

void solve() {
  cin >> n >> k;
  rep(i, 1, n) A[i] = read();
  rep(T, 1, k) {
    memset(tmp, 0, (n + 1) << 2);
    rep(i, 1, n) {
      int l = i - A[i], r = i + A[i];
      chkmax(l, 1), chkmin(r, n);
      tmp[l]++, tmp[r + 1]--;
    }
    bool flg = 1;
    rep(i, 1, n) {
      tmp[i] += tmp[i - 1];
      A[i] = tmp[i];
      flg &= A[i] == n;
    }
    if (flg) break;
  }
  rep(i, 1, n) printf("%d ", A[i]);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}


Measured memory_bytes: 5268
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll N;
vvl days;
vvl dp;

ll rec (ll day, ll last_act){

    if(day >= N) return 0;
    if(last_act != -1 && dp[day][last_act] != 0){ return dp[day][last_act];}

    ll max_happy = 0;
    FOR(i, 0, 3){
        if(last_act == i) {continue;}
        max_happy = max(max_happy, rec(day+1, i)+days[day][i]);
    }

    if(last_act != -1 ) { dp[day][last_act] = max_happy;}
    return max_happy;
}

int main() {

    cin >> N;
    vl activity(3);
    days.assign(N, activity);
    dp.assign(N, activity);
    FOR(i, 0, N){
        FOR(j, 0, 3){
            cin >> days[i][j];
        }
    }
    
    cout << rec(0, -1) << endl;

    return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;
 
const ll INF=(1ll<<31)-1;
int a[100001];
int b[1005];
int main(){
    int n,q;
    cin>>n>>q;
    int sqn=sqrt(n);
    int bn=(n+sqn-1)/sqn;
    rep(i,n) a[i]=INF;
    rep(i,bn) b[i]=INF;
    int com;
    rep(i,q){
        cin>>com;
        if(com==0){
            int s,t,x;
            //[s,t)
            cin>>s>>t>>x;
            ++t;
            rep(j,bn+1){
                int l=j*sqn,r=(j+1)*sqn;
                if(r<=s||t<=l) continue;
                if(s<=l&&r<=t) b[j]=x;
                else{
                    FOR(k,l,r){
                        if(k>=max(s,l)&&k<min(t,r)) a[k]=x;
                        else if(b[j]!=INF) a[k]=b[j];
                    }
                    b[j]=INF;
                }
            }
        }
        if(com==1){
            int k;
            cin>>k;
            int cur=k/sqn;
            if(b[cur]!=INF){
                FOR(j,cur*sqn,(cur+1)*sqn){
                    a[j]=b[cur];
                }
                b[cur]=INF;
            }
            cout<<a[k]<<endl;
        }
    }
    return 0;
}


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

int main(){
    int t;cin >> t;
    
    rep(test,t){
        int n; cin >> n;
        vector<ll> a(n);
        rep(i,n)cin >> a[i];
        string s; cin >> s;
        
        set<ll, greater<ll>> dp;//遷移は基底が増えるだけ
        per(i,n){
            for(ll b: dp)a[i] = min(a[i], a[i]^b);
            //minを取れば掃き出しが可能
            if(s[i]=='0'){
                dp.insert(a[i]);
                //0は何個あってもいい
                //基底の大小はともかく
            }else if(a[i]!=0){
                //1のターンで新しい基底を取れたなら終了
                dp.clear();
                break;
            }
        }
        if(dp.empty())
            cout << 1 << endl;
        else
            cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int i,j,k,n,m,x,y,z,a[100000],b[100000]={0};
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=1;i<n;i++)
	{
		if(i==1)
		{
			x=a[i]-a[i-1];
			if(x<0)
			x=x*(-1);
			b[i]=x;
		}
		else
		{
			x=a[i]-a[i-1];
			y=a[i]-a[i-2];
			if(x<0)
			x=x*(-1);
			if(y<0)
			y=y*(-1);
			x=x+b[i-1];
			y=y+b[i-2];
			b[i]=min(x,y);
		}
	}
	cout<<b[n-1];
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
	while (true) {
	  
	  int n = sc.nextInt();
	  if (n == 0) {
		break;
	  }
	  int min = 1001, max = 0, sum = 0;
	  for (int i = 0; i < n; i++) {
		int s = sc.nextInt();
		if (min > s) {
		  min = s;
		}
		if (max < s) {
		  max = s;
		}
		sum += s;
	  }
	  System.out.println((sum - max - min) / (n - 2));
	}
  }
}



Measured memory_bytes: 28828
n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)])

t = 0

for ab_i in ab:
    if m == 0:
        break
    for i in range(ab_i[1]):
        if m == 0:
            break
        m -= 1
        t += ab_i[0]

print(t)


Measured memory_bytes: 28656
import sys
import itertools


def check(i,array):
    now=0
    while True:
        flag=0
        if(now==len(i)-1):
            return 1
        for x in array:
            if(i[now]==x[0] and i[now+1]==x[1] or \
                i[now]==x[1] and i[now+1]==x[0]):

                flag=1
                now+=1
                break

        if(flag==0):
            return 0


def main():
    N, M = map(int,input().split())

    array=[]
    sum=0

    for _ in range(0, M):
        array.append(list(map(int,input().split())))


    for i in itertools.permutations(range(1,N+1),N):
        if(i[0]==1):
            sum += check(i,array)
    print(sum)

main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <set>
#include <time.h>
#include <deque>
#include <algorithm>
#define ll long long
#define MAXN 100000
using namespace std;


bool done[MAXN+2];

vector<int> edges[MAXN+2];
deque<int> verts;
set<int> verts_covered;
void dfs(int u, bool fb) {
    done[u]=true;
    verts_covered.insert(u);

    for(int j=0;j<edges[u].size();j++) {
        int v=edges[u][j];
        if (done[v])
            continue;
        if (fb)
            verts.push_back(v);
        else
            verts.push_front(v);
        dfs(v,fb);
        break;
    }
}

bool AllCovered(int u) {
    for(int j=0;j<edges[u].size();j++) {
        int v=edges[u][j];
        if (verts_covered.find(v) == verts_covered.end())
            return false;
    }
    return true;
}

int main() {
    int N,M;
    cin>>N>>M;
    for(int i=1;i<=N;i++)
        done[i]=false;
    for(int i=1;i<=M;i++) {
        int u,v;
        cin>>u>>v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    int st=1;
    int mind=N+100;
    for(int u=1;u<=N;u++) {
        if (edges[u].size() < mind)
        {
            mind = edges[u].size();
            st=u;
        }
    }
    
    
    verts.push_back(st);
    
    
    
    while(1) {
        if (AllCovered(verts.front()) && AllCovered(verts.back()))
            break;
        int st = verts.front();
        if (!AllCovered(st)) {
            dfs(st,0);
        }
        int en = verts.back();
        if (!AllCovered(en)) {
            dfs(en,1);
        }
        
    }
    
    dfs(st,true);
    
    cout << verts.size() << endl;
    for(int i=0;i<verts.size();i++)
        printf("%d ",verts[i]);
    printf("\n");
    
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int dp[N],n,m,ans;
vector<int>v[N];
bool isroot[N];
int dfs(int now)
{
	if(dp[now])return dp[now];
	else {
		for(int i=0;i<v[now].size();i++)
		{
			dp[now]=max(dp[now],dfs(v[now][i])+1);
		}
		return dp[now];
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)isroot[i]=true;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
		isroot[b]=false;
	}
	for(int i=0;i<n;i++)
		if(isroot[i])
			ans=max(ans,dfs(i));
	cout<<ans<<endl;
	return 0;
}

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

const int maxn=5e5+10;

int n,k,p[maxn],q[maxn],deg[maxn];
int tote,FIR[maxn],TO[maxn<<1],NEXT[maxn<<1];
priority_queue<int> pq;

namespace SegTree{
	int mn[maxn<<2];
#define lc (nd<<1)
#define rc (nd<<1|1)
#define mid ((s+t)>>1)

	void init()
	{
		memset(mn,0x3f3f3f3f,sizeof(mn));
	}

	void update(int nd,int s,int t,int id,int val)
	{
		if (s==t) {mn[nd]=val; return;}
		if (id<=mid) update(lc,s,mid,id,val);
		else update(rc,mid+1,t,id,val);
		mn[nd]=min(mn[lc],mn[rc]);
	}

	int query(int nd,int s,int t,int l,int r)
	{
		if (l<=s&&t<=r) return mn[nd];
		int Ans=0x7fffffff;
		if (l<=mid) Ans=min(Ans,query(lc,s,mid,l,r));
		if (r> mid) Ans=min(Ans,query(rc,mid+1,t,l,r));
		return Ans;
	}
}

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
	deg[v]++;
}

int main()
{
#ifdef h10
	freopen("permutation.in","r",stdin);
	freopen("permutation.out","w",stdout);
#endif
	int i,x;
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++)
		scanf("%d",&p[i]),q[p[i]]=i;
	SegTree::init();
	for (i=n;i>=1;i--)
	{
		x=SegTree::query(1,1,n,q[i]-k+1,q[i]);
		if (x<=n) addedge(q[x],q[i]);
		x=SegTree::query(1,1,n,q[i],q[i]+k-1);
		if (x<=n) addedge(q[x],q[i]);
		SegTree::update(1,1,n,q[i],i);
	}
	for (i=1;i<=n;i++)
		if (!deg[i]) pq.push(i);
	for (i=n;i>=1;i--)
	{
		int u=p[i]=pq.top(); pq.pop();
		for (int p=FIR[u];p;p=NEXT[p])
			if (!(--deg[TO[p]])) pq.push(TO[p]);
	}
	for (i=1;i<=n;i++) q[p[i]]=i;
	for (i=1;i<=n;i++) printf("%d\n",q[i]);
}


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

using namespace std;

#define vi vector<int>
#define pb push_back
#define lli long long int
#define INF 1000000001

void solve() {
	char s;
	cin >> s;
	if (s >= 65 && s <= 90)cout << "A" << endl;
	else cout << "a" << endl;

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

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--) {
	solve();

	// }



	return 0;

}

Measured memory_bytes: 3608
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb1=new StringBuilder();
		StringBuilder sb2=new StringBuilder();
		String b=" ",n="\n";
        String[] rc=br.readLine().split(b);
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[][] h=new int[r+1][c+1];
        
        for(int i=0;i<r;i++){
        	String[] row=br.readLine().split(b);
        	int j=0;
        	for(String num:row){
        		h[i][j]=Integer.parseInt(num);
        		h[i][c]+=h[i][j];
        		h[r][j]+=h[i][j];
        		sb1.append(h[i][j]+b);
        		if(i==r-1){
        			h[r][c]+=h[r][j];
        			sb2.append(h[r][j]+b);
        		}
        		j++;
        	}
        	sb1.append(h[i][c]+n);
        }
        sb1.append(sb2).append(h[r][c]);
        System.out.println(sb1);
	}
}

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

int main() {
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++)
		cin >> h[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
					dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a==25)
    {
        cout<<"Christmas\n";
    }
    else if(a==24)
    {
        cout<<"Christmas Eve\n";
    }
    else if(a==23)
    {
        cout<<"Christmas Eve Eve\n";
    }
    else if(a==22)
    {
        cout<<"Christmas Eve Eve Eve\n";
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(void){
    double r;
    cin >> r;
    
    double P, S;
    P = 2 * M_PI * r;
    S = pow(r,2) * M_PI;
    
    printf("%.6lf %.6lf\n", S, P);
}

Measured memory_bytes: 1240
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)cin >> a[i];
  int count = 0;
  for(int i = 1; i < n; i++){
    if(a[i]==a[i-1]){
      a[i]=-1;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 384
#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;

/*
<url:https://abc055.contest.atcoder.jp/tasks/arc069_a?lang=en>
問題文============================================================
 すぬけくんはパズルが好きです。
 
 今日は S と c の形をしたピースを使ったパズルで遊んでいます。
c 型のピースを 2 つ組み合わせて S 型のピースを 1 つ作ることができます。
 
 すぬけくんは S 型のピースを 1 つ、c 型のピースを 2 つ組み合わせて
 Scc という組を可能な限り多く作ることにしました。
 
 すぬけくんが N 個の S 型のピースと M 個の c 型のピースを持っているとき、
 Scc という組を最大でいくつ作ることが可能か求めなさい。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    cout << min(N,M/2) + (M - 2*min(N,M/2))/4 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DBG(a) if(DBGDO) cout<<#a<<':'<<a<<endl;
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()
#define pow(a,b) (pow(a,b)+0.5)

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<string> vs;typedef vector<vector<string>> vvs;

#define unmp unordered_map

#define PRIME ((lli)(1e9+7ll))
#define PRIME2 (998244353ll)
const lli TEN_18 = 1e18;
const lli TEN_9 = 1e9;
const lli TEN_5 = 1e5;

inline void debugORfast(int a=1,int b=1){
    if(a){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
        #endif
    }
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}}

template<typename T>
void print(const T &v, int begin=-1, int end=-1, int w=2)
{
	if(begin<=end){
		if(begin==-1) fl(i,0,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) fl(i,begin,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else fl(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;}
	else{
		if(begin==-1) flr(i,v.SZ-1,-1) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) flr(i,begin,-1) cout<<setw(w)<<v[i]<<' ';
		else flr(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;
	}
}

void pans(char v){
	switch(v){
		case 'y' : cout<<"yes"<<endl; break;
		case 'n' : cout<<"no"<<endl; break;
		case 'Y' : cout<<"Yes"<<endl; break;
		case 'N' : cout<<"No"<<endl; break;
		case 'B' : cout<<"YES"<<endl; break;
		case 'S' : cout<<"NO"<<endl; break;
	}
}

int DBGDO=0;

lli brute(){
	return 0;
}

lli solve(){
    return 0;
}

const long double PI = acosl(-1.0);

int main()
{
	debugORfast(0,1);
	//w(ttt)
	{
		int x,n; cin>>x>>n;
		inp(n,p,int);
		sort(btoe(p));
		int minv = 100000;
		f(i,x,x+n+1){
			int posn = lower_bound(btoe(p),i)-p.begin();
			if(posn==n or p[posn]!=i){
				minv = i;
				break;
			}
		}
		fr(i,x,-2){
			int posn = lower_bound(btoe(p),i)-p.begin();
			if(posn==n or p[posn]!=i){
				if(abs(x-i)<abs(minv-x)){
					minv = i;
					break;
				}
				else if(abs(x-i)==abs(minv-x)){
					minv = i;
					break;
				}
			}
		}
		cout<<minv<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int i = 0;
    for(i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    for (i = n-1; i >= 0; i -= 2) {
      System.out.print(a[i] + " ");
    }
    if(i == -2) {
      for (i = 1; i < n; i += 2) {
        System.out.print(a[i] + " ");
      }
    }else if(i == -1) {
      for (i = 0; i < n; i += 2) {
        System.out.print(a[i] + " ");
      }
    }
    System.out.println();
  }
}

Measured memory_bytes: 92072
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Text.Parsec
import Text.Parsec.String

main :: IO ()
main = do
  solve <$> getc (map words) >>= mapM_ print

solve :: [[String]] -> [BTree]
solve = map f
  where
    f :: [String] -> BTree
    f [c, t1, t2]
      | c == "i" = isect l r
      | otherwise = unn l r
      where
        l = either (const Leaf) id $ parse expr "" t1
        r = either (const Leaf) id $ parse expr "" t2
        
getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

expr :: Parser BTree
expr = do
  char '('
  l <- expr <|> return Leaf
  char ','
  r <- expr <|> return Leaf
  char ')'
  return $ Node l r

data BTree = Leaf | Node BTree BTree

instance Show BTree where
  show Leaf = ""
  show (Node l r) = "(" ++ show l ++ ","++ show r  ++ ")"

isect :: BTree -> BTree -> BTree
isect Leaf _ = Leaf
isect _ Leaf = Leaf
isect (Node l1 r1) (Node l2 r2) = Node (isect l1 l2) (isect r1 r2)

unn :: BTree -> BTree -> BTree
unn Leaf r = r
unn l Leaf = l
unn (Node l1 r1) (Node l2 r2) = Node (unn l1 l2) (unn r1 r2)

Measured memory_bytes: 4284
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	ll d;
	cin >> n >> d;
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		ll x, y;
		cin >> x >> y;
		
		if( x * x + y * y <= d * d ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func main() {
	n := readFloat64()
	v := math.Floor(math.Sqrt(n))
	fmt.Println(int(v * v))
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
bool prime(int n);
int main()
{
    int n,i,count;
    while(cin>>n)
    {
        count=0;
        for(i=2;i<=n;i++)
        {
            if(prime(i)&&prime(n-i+1))
            {
                 count++;
            }
        }
        cout<<count<<endl;
    }
    return 0;
}




bool prime(int n)
{
    int i,k=sqrt(n);
    if(n==1)
    {
        return 0;
    }
    for(i=2;i<=k;i++)
    {
        if(n%i==0)
        {
            return 0;break;
        }
    }
    if(i==(k+1))
    {
        return 1;
    }
}

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

int main(){
	string s;
  map<string, int> score;
  int n;
	cin >> n;
	rep(i,n){
		cin >> s;
		score[s] = 100;
	}
  cout << score.size() << endl;
}

Measured memory_bytes: 19224
#coding:utf-8
import numpy as np
N = int(input())
ls = []
for n in range(N):
  a,b= map(int,input().split())
  ls.append([a,b])
ls = np.array(ls)
idx = np.argsort(ls[:,1])
ls = ls[idx]
sm = 0
for a,b in ls:
  sm += a
  if sm > b:
    print("No")
    exit()
print ("Yes")



Measured memory_bytes: 46916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct Node{
    double a;
    ll x;
    ll flag;
    bool b; //trueはs,t,falseはd
};
bool comp(Node x,Node y){
    return x.a<y.a;
}

int main(){
    ll n,q;cin>>n>>q;
    double s[n+1],t[n+1];
    ll x[n+1];
    double d[q];
    vector<Node> time;
    Node node;
    rep(i,1,n){
        cin>>s[i]>>t[i]>>x[i];
        node.a=s[i]-(double)x[i]-0.5;
        node.flag=i;
        node.x=(ll)x[i];
        node.b=true;
        time.pb(node);
        node.a=t[i]-(double)x[i]-0.5;
        time.pb(node);
    }
    rep(i,0,q-1){
        cin>>d[i];
        node.a=d[i];
        node.b=false;
        node.flag=i;
        node.x=d[i];
        time.pb(node);
    }
    sort(time.begin(),time.end(),comp);
    priority_queue<l_l,vector<l_l>,greater<l_l>> p;
    bool bol[n+1];rep(i,0,n)bol[i]=false;
    rep(i,0,time.size()-1){
        if(time[i].b==true){
            if(!bol[time[i].flag]){
                p.push(make_pair(time[i].x,time[i].flag));
                bol[time[i].flag]=true;
            }else{
                bol[time[i].flag]=false;
            }
        }else{
            while(true){
                if(p.empty()){
                    cout<<-1<<endl;
                    break;
                }
                if(bol[p.top().second]==false){
                    p.pop();
                    continue;
                }else{
                    cout<<p.top().first<<endl;
                    break;
                }
            }
        }
    }
    
    
    
    
    return 0;
}




Measured memory_bytes: 41060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  int ma,mi;
  ma=max(a,max(b,max(c,max(d,e))));
  mi=min(a,min(b,min(c,min(d,e))));

  if(ma-mi>k) cout<<":(";
  else cout<<"Yay!";
  cout<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	char c[52];
	REP(i, 26) {
		c[i] = 'a' + i;
		c[i + 26] = 'A' + i;
	}
	int n;
	while (cin>>n,n) {
		vi num(n);
		REP(i, n)
			cin >> num[i];
		string s;
		cin >> s;
		REP(i,s.length()){
			if ('a' <= s[i] && s[i] <= 'z')
				cout << c[(s[i]-'a' + 52 - num[i%num.size()]) % 52];
			else
				cout << c[(s[i]-'A' + 52+26 - num[i%num.size()]) % 52];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3084
while 1:
    a,op,b=input().split()
    if op == '+':
        r = int(a)+int(b)
    elif op == '-':
        r = int(a)-int(b)
    elif op == '*':
        r = int(a)*int(b)
    elif op == '/':
        r = int(a)//int(b)
    elif op == '?':
        break;
    print(r)

Measured memory_bytes: 7628
import java.util.*;

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

    int n = scan.nextInt(), m = scan.nextInt();

    if(n==0||m==0||((long)n*(long)m<0L)) {
      System.out.println("Zero");
      return;
    }

    if(n>0) {
      System.out.println("Positive");
      return;
    }

    if(m<0) {
      if((m-n)%2==0) System.out.println("Negative");
      else System.out.println("Positive");
      return;
    }
  }
}


Measured memory_bytes: 9936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
const int num = 100005;
typedef long long ll;
ll a[num],dp[num];
int main()
{
	int n,k;
	cin >> n >> k;
	rep(i,1,n+1)
		cin >> a[i],dp[i] = INT_MAX;
	dp[1] = 0;
	rep(i,2,n+1)
	{
		rep(j,max(i-k,1),i)
			dp[i]= min(dp[i],dp[j]+abs(a[j]-a[i]));
		
	}
	cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int r = inp.nextInt();
        System.out.println((double)r * 3.141592653589257 * 2.0);
    }
}


Measured memory_bytes: 35844
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
int main(){
    CIN(N);CIN(M);
    V v1,v2;
    REP(a,M){
        CIN(b);CIN(c);
        v1.push_back(b);
        v2.push_back(c);
    }
    REP(a,N){
        int b = a+1;
        COUT(count(ALL(v1),b)+count(ALL(v2),b));
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int key = sc.nextInt();
            int val = sc.nextInt();
            if(val <= t) {
                map.put(key, val);
                ans = Math.min(ans, key);
            }
        }
        if(map.size() == 0) {
            System.out.println("TLE");
        } else {
            System.out.println(ans);
        }
    }
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    ll res = (ll)a*c;
    res = max(res, (ll)a*d);
    res = max(res, (ll)b*c);
    res = max(res, (ll)b*d);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {

	var K int64;
    K = nextInt();
    var X int64;
    X = nextInt();
	solve(K, X);

}

func solve(K int64, X int64){
	for i:= 0;i<int(K)*2-1 ;i++{
		if i>0 {Print(" ")}
		Print(int(X) - int(K)+1 + i)
	}
	Println("")
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int64 {
	a, err := strconv.ParseInt(next(),10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 2816
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,M,X = LI()
# c=[]
# a=[]
# for i in range(n):
#     ca = LI()
#     c.append(ca[0])
#     a.append(ca[1:])
# print(c)
# print(a)

_ca = [LI() for _ in range(N)]
ca = np.array(_ca, np.int64)
# print(ca)
# ca = ca.reshape(n,-1)
C = ca[:,0]
A = ca[:,1:]
# print(c)
# print(a)

result = 10**7
# ビット全探索
for i in range(1 << N):
    t = [0] * M
    c = 0
    for j in range(N):
        # i を j回右にシフトして1との論理積を取り、1であればアイテムを購入しているとみなす
        # 購入していない場合
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    # 全てX以上であれば更新
    if all(x >= X for x in t):
            result = min(result, c)

if result == 10**7:
    print(-1)
else:
    print(result)

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll y = 1'000'000'000'000'000'000LL;
    ll x = 1;
    bool f = 1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            puts("0");
            return 0;
        }
        ll z = y/x;
        if (A[i] <= z) {
            x *= A[i];
        }
        else {
            f = 0;
        }
    }
    if (f) {
        cout << x << endl;
    }
    else {
        puts("-1");
    }
}

Measured memory_bytes: 3976
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 1)cout << "Odd" << endl;
	else cout << "Even" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}





int main(){

  
  cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
  cin >> s;
  int n=s.length();
  ll ary[n+1];
  ary[n]=0;
  int ans[2019];
  rep(i,2019) ans[i]=0;
  string tmps="";
  ans[0]++;
  rep(i,n)
  {
    tmps=s[n-1-i]+tmps;
    ary[n-i-1]=ary[n-i]+(s[n-1-i]-'0')*mod_pow(10,i,2019);
    ary[n-1-i]%=2019;
    ans[ary[n-1-i]]++;
  }
  ll rec=0;
  rep(i,2019) rec+=(ans[i]*(ans[i]-1))/2;
  cout << rec <<endl;

    
}




Measured memory_bytes: 5768
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int l = sc.nextInt(); // 使用しない

		String[] s = new String[n];
		for (int i = 0; i < s.length; i++) {
			s[i] = sc.next();
		}
		sc.close();

//		int imin;
//		for (int i = 0; i < s.length - 1; i++) {
//			imin = i;
//			for (int j = i + 1; j < s.length; j++) {
//				if (s[imin].compareTo(s[j]) > 0) {
//					imin = j;
//				}
//			}
//			if (imin != i) {
//				exchange(s, imin, i);
//			}
//		}

		Arrays.sort(s);

		String sum = "";
		for (String str : s) {
			sum += str;
		}

		System.out.println(sum);
	}

//	public static void exchange(String[] s, int a, int b) {
//		String str = s[a];
//		s[a] = s[b];
//		s[b] = str;
//	}

}


Measured memory_bytes: 26744
#include<bits/stdc++.h>
using namespace std;
void gce(int a, int b, int&x, int &y) {
	if (!b) {x = 1; y = 0; return;}
	gce(b, a%b, x, y);
	int t = x; x = y; y = t-a/b*x;
}
int main(){
    int T;
    scanf("%d",&T);
    while (T--){
        int n,m;
        scanf("%d%d",&n,&m);
        int g=__gcd(n,m);
        if (g<=50000){
            int a,b;
            gce(n,m,a,b);
            if (a<=0) printf("3\n0 0\n%d% d\n%d %d\n",n,m,b,-a);
            else printf("3\n0 0\n%d% d\n%d %d\n",n,m,-b,a);
        }
        else {
            printf("4\n0 0\n%d %d\n%d %d\n%d %d\n",n,m-1,n/g,m/g,n-1,m);
        }
    }
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int a[200010];
int ans[200010];

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        ans[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5156
from copy import copy

S = input()
Slist = []
par = []
rap = []

for s in S:
    Slist.append(s)

if len(Slist)==3:
    if Slist==list(reversed(Slist)):
        print("Yes")
    else:
        print("No")
else:
    par = copy(Slist)
    rap = copy(Slist)
    rap = list(reversed(rap))

    if par==rap:
        rap = []
        par = copy(Slist)
        par = par[:(len(par)-1)//2]
        rap = copy(par)
        rap = list(reversed(rap))

        if par==rap:
            rap = []
            par = copy(Slist)
            par = par[(len(par)+3)//2-1:]
            rap = copy(par)
            rap = list(reversed(rap))

            if par==rap:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

void no(){
	cout<<"No"<<endl;
	exit(0);
}
void yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

//KUPC2017J
//AOJDSL1A
//without rank
struct unionfind{
	vi p,s;
	int c;
	unionfind(int n):p(n,-1),s(n,1),c(n){}
	int find(int a){
		return p[a]==-1?a:(p[a]=find(p[a]));
	}
	//set b to a child of a
	bool unite(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b)return false;
		p[b]=a;
		s[a]+=s[b];
		c--;
		return true;
	}
	bool same(int a,int b){
		return find(a)==find(b);
	}
	int sz(int a){
		return s[find(a)];
	}
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

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

	if ( q == 0 ) {
	  abort();
	}
	if ( m > ((n * (n - 1)) / 2) ) {
	  abort();
	}

	vc<pi> dup;
	unionfind uf(n);
	rep(_,q){
		int u,v,f;cin>>u>>v>>f;
		if(f==0)
			uf.unite(u,v);
		else
			dup.eb(u,v);
	}

	if(m==n-1){
		if(dup.size())no();
		yes();
	}

	for(auto e:dup)
		if(uf.same(e.a,e.b))no();

	if(m<=n-uf.c+uf.c*(uf.c-1)/2)yes();
	else no();
}


Measured memory_bytes: 3956
q = int(input())
k = 10**5+1
x = [0]*k
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    for i in range(2, n+1):
        if prime[i]:
            for j in range(i*2, n+1, i):
                prime[j] = False
    return prime

p = sieve(k+1)
c = 0
for i in range(3, k):
    if p[i] and p[(i+1)//2]:
        c += 1
    x[i] = c

for _ in range(q):
    l, r = map(int, input().split())
    print(x[r] - x[l-1])

Measured memory_bytes: 52056
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   int n,k;
   cin>>n>>k;
   string s;
   cin>>s;
   int res=0;
   for(int i=0;i<n-1;i++){
       if(s[i]==s[i+1])res++;
   }
   cout<<min(n-1,res+2*k)<<"\n";
}

Measured memory_bytes: 512