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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;
typedef long long  ll;

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

const double EPS = 1e-9;
const double pi = acos(-1.0);

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


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

    char g[n][m];
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < m ; ++j)cin >> g[i][j];
    }

    bool f[n][m];
    memset(f , 0 , sizeof f);
    for(int i = 0 ; i < n ; ++i){
        bool ok = true;
        for(int j =  0 ; j< m ; ++j){
            ok &= g[i][j] == '.';
        }

        if(ok){
            for(int j =  0 ; j< m ; ++j){
//                cout << i << ' ' << j << endl;
                f[i][j] = true;
            }
        }
    }
//    watch(1);

    for(int i = 0 ; i < m ; ++i){
        bool ok = true;
        for(int j = 0 ; j< n ; ++j){
            ok &= g[j][i] == '.';
        }

        if(ok){
            for(int j =  0 ; j< n ; ++j){
//                cout << i << ' ' << j << endl;
                f[j][i] = true;
            }
        }
    }

    for(int i = 0 ; i < n ; ++i){
        bool ok = false;
        for(int j = 0 ; j < m ; ++j){
//            cout << i << ' ' << j << endl;
//            cout << f[i][j] << endl;
            if(!f[i][j])cout << g[i][j] , ok = true;
        }
        if(ok)cout << endl;
    }
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())

    edges = [[] for _ in range(n)]

    for _ in range(m):
        a,b = map(int,input().split())
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    q = deque([0])

    ans = [-1]*n
    ans[0] = 0
    count = 1

    while q:
        l = q.popleft()
        for i in edges[l]:
            if ans[i] == -1:
                ans[i] = l
                count += 1
                q.append(i)
        if count == n:
            break

    if count == n:
        print('Yes')
        for i in ans[1:]:
            print(i+1)
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 92244
#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
long long a[200005],ans;
int main()
{
	long long n;
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(long long i=2;i<=n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i]-a[i-1];
			a[i]=a[i-1];
		}
	}
	printf("%lld",abs(ans));
	return 0;
}

Measured memory_bytes: 5372
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;

int max(int,int);
int main(void){
	const int inf = 1001001001;
	int v,e,r;
	int i,j,k;
	pair<int,int> l[100000];
	pair<int,pair<int,int> > P[500000];
	bool boo[100000];
	int a[100000],b[100000];
	pair<int,int> Q;
	//??\???
	scanf("%d%d%d",&v,&e,&r);
	for(i=0;i<e;i++){
		scanf("%d%d%d",&P[i].first,&P[i].second.first,&P[i].second.second);
	}
	sort(P,P+e);
	for(i=0;i<v;i++){
		a[i] = inf;
		b[i] = inf;
	}
	for(i=0;i<e;i++){
		P[i].second.second=P[i].second.second*(-1);
	}
//printf("P=(");
//for(i=0;i<e;i++){
//	printf("%d,",P[i].first);
//}
//printf(")\n");
	a[P[0].first]=0;
	b[P[e-1].first]=e-1;
	for(i=0;i<e-1;i++){
		if(P[i+1].first>P[i].first){
			a[P[i+1].first]=i+1;
			b[P[i].first]=i;
		}
	}
	for(i=0;i<v;i++){
		if(a[i]==inf){
			a[i]=1;
			b[i]=0;
		}
	}
//for(i=0;i<v;i++){
//	printf("a[%d]=%d,b[%d]=%d\n",i,a[i],i,b[i]);
//}
	for(i=0;i<v;i++){
		l[i].first=inf*(-1);
		l[i].second=i;
	}
	l[r].first=0;	//?????¢????????????
	
	priority_queue<pair<int,int> > q;//????¢????????????\???
	for(i=0;i<v;i++){
		q.push(l[i]);
		boo[i]=true;
	}
	while(!q.empty()){
		Q=q.top();
//printf("Q=(%d,%d)\n",Q.first,Q.second);
		q.pop();
		if(boo[Q.second]==true){
			boo[Q.second]=false;
			for(i=a[Q.second];i<=b[Q.second];i++){
//printf("done\n");
				int t=P[i].second.first;
				int d=P[i].second.second;
				l[t].first=max(l[t].first,Q.first+d);
//printf("i=%d,l[%d]=(%d,%d)\n",i,t,l[t].first,l[t].second);
				q.push(l[t]);				
			}
		
		}
	}
	for(i=0;i<v;i++){
		int k=l[i].first*(-1);
		if(k!=inf){
			printf("%d\n",k);
		} else {
			printf("INF\n");
		}
	}
	return 0;
}	

int max(int a,int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
	
		
		
			
	
	

Measured memory_bytes: 11812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60



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

	char c; cin >> c;
	if (c == 'A') cout << 'T' << endl;
	else if (c == 'T') cout << 'A' << endl;
	else if (c == 'C') cout << 'G' << endl;
	else if (c == 'G') cout << 'C' << endl;



	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
#print(n)
avg=sum(a)/n
b=[abs(int(j)-avg) for j in a]
#print(min(b))
#print(b)
print(b.index(min(b)))
#c=b.index(min(b))
#print(a[b])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(a + b - n, 0) << endl;
  return 0;
}

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

int main() {
  long long int n,k,s=0;
  cin >> n >> k;
  long long int a[n];
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a, a+n);
  for (int i=0;i<n-k;i++) {
    s+=a[i];
  }
  cout << s;
}
    

Measured memory_bytes: 1792
n, k = map(int, input().split())
p = 10**9 + 7

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append(-inv[p % i] * (p // i) % p)
    factinv.append(factinv[-1] * inv[-1] % p)

def cmb(n, r, p):
    if n < r:
        return 0
    else:
        r = min(r, n - r)
        return((fact[n] * factinv[r] * factinv[n - r]) % p)

res = []
for i in range(n):
    res.append((cmb(n, i, p) * cmb(n - 1, i, p)) % p)

if n > k:
    print(sum(res[:k + 1]) % p)
else:
    print(sum(res) % p)


Measured memory_bytes: 36500
#include<stdio.h>
#include<math.h>
 
int main(void){
    double a,b, angle;
    double c;
    double rad;
    double s, l, height;
     
    scanf("%lf", &a);
    scanf("%lf", &b);
    scanf("%lf", &angle);
     
    rad = (angle / 180) * M_PI;
     
    c = sqrt(a*a + b*b - 2*a*b * cos(rad));
     
    height = b * sin(rad);
     
    s = (a * height) / 2;
     
    l = a + b + c;
     
    printf("%lf\n", s);
    printf("%lf\n", l);
    printf("%lf\n", height);
     
    return 0;
}


Measured memory_bytes: 2048
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;


void Main()
{
   int N;
  string S;
  cin >> N >> S;
  int temp = 0;
  int tempmax = 0;
 
  rep(i,N){
     if(S[i]=='I'){
     temp++;
     tempmax=max(temp,tempmax);  
     }
    if(S[i]=='D'){
     temp--;
     }
  }
  cout << tempmax << endl;
return;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N;cin >> N;
vector<vector<ll>> A(N, vector<ll>(26, 0));
vector<ll> Ans(26);

rep(i, 0, N){

string S;cin >> S;

    rep(j, 0, S.size()){

    ll I = S[j] - 2*'0' - 1;A[i][I]++;

    }

}

Ans = A[0];

rep(i, 1, N){

    rep(j, 0, 26)Ans[j] = min(Ans[j], A[i][j]);

}

vector<char> ANS;

rep(i, 0, 26){
char c = i + 2*'0' + 1;
    rep(j, 0, Ans[i]){
    ANS.push_back(c);
    }
}

sort(ALL(ANS));

for(auto a : ANS)cout << a;
}


Measured memory_bytes: 3636
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
string s[100000];
const char march[] = "MARCH";
ll n[5];

void init()
{
}

void solve()
{
    ll ans = 0;
    REP(i, N){
        REP(j, 5){
            if(s[i][0] == march[j]){
                n[j]++;
                break;
            }
        }
    }
    REP(i, 5){
        FOR(j, i+1, 5){
            FOR(k, j+1, 5){
                ans += n[i] * n[j] * n[k];
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> s[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
    string s;
    int q;
    cin >> s >> q;
    vector<char> front,back;
    int now = 1;
    rep(i,q) {
        int t;
        cin >> t;
        if(t == 1) {
            now = -now;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1) {
                if(now == 1) front.push_back(c);
                else back.push_back(c);
            } else {
                if(now == 1) back.push_back(c);
                else front.push_back(c);
            }
        }
    }
    if(now == 1) {
        for(int i = front.size()-1; i >= 0; i--) {
            cout << front[i];
        }
        cout << s;
        rep(i,back.size()) {
            cout << back[i];
        }
        cout << endl;
    } else {
        for(int i = back.size()-1; i >= 0; i--) {
            cout << back[i];
        }
        reverse(all(s));
        cout << s;
        rep(i,front.size()) {
            cout << front[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
const int MAX_N = 2010;
const int INF = 1e18;
int d[MAX_N][MAX_N];
vector<int> G[MAX_N];
int n, k, s;

int calc(int x1, int y1, int z1, int x2, int y2, int z2){
    int x = min(x1, x2) + s - max(x1, x2);
    int y = min(y1, y2) + s - max(y1, y2);
    int z = min(z1, z2) + s - max(z1, z2);
    // cout << " " << x << ' ' << y << ' ' << z << endl;
    if(x <= 0 || y <= 0 || z <= 0) return 0;
    // if(x == 0) x = s;
    // if(y == 0) y = s;
    // if(z == 0) z = s;
    int res = 2 * (x * y + y * z + z * x);
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> k >> s;
        if(n + k + s == 0) break;
        vector<int> x(n), y(n), z(n);
        rep(i, 0, n){
            cin >> x[i] >> y[i] >> z[i];
        }
        if(n == 1 || k == 1){
            cout << 6 * s * s << endl;
            continue;
        }
        rep(i, 0, n) rep(j, 0, n) d[i][j] = 0;  
        rep(i, 0, n) G[i].clear();
        rep(i, 0, n){
            rep(j, i + 1, n){
                d[i][j] = calc(x[i], y[i], z[i], x[j], y[j], z[j]);
                    // cout << i << ' ' << j << ' ' << d[i][j] << endl;
                d[j][i] = d[i][j];
                if(d[i][j] > 0){
                    G[i].push_back(j);
                    G[j].push_back(i);
                }
            }
        }
        int ans = INF;
        rep(i, 0, n){
            rep(j, 0, G[i].size()){
                int tmp = 0;
                int now = G[i][j], nxt, pre = i;
                // cout << i << ' ' << tmp << endl;
                rep(l, 0, k - 1){
                    if(now == i){
                        tmp = INF; break;
                    }
                    tmp += d[pre][now];
                    // cout << now << ' ' << d[pre][now] << " " << tmp << endl;                    
                    if(G[now].size() == 1){
                        if(l == k - 2){
                            now = pre = -1;
                        }else{
                            tmp = INF;
                        }
                        break;
                    }else{
                        rep(p, 0, G[now].size()){
                            if(G[now][p] != pre) nxt = G[now][p];
                        }
                        pre = now;
                        now = nxt;
                    }
                }
                // cout << endl;
                if(tmp != INF){
                    if(now == i) tmp += d[pre][now];
                    // cout << now << " " << pre << " " << d[pre][now] << " " << tmp << endl;
                    tmp = 6 * s * s * k - tmp;
                    ans = min(ans, tmp);
                    // cout << " " << tmp << endl;
                }
            }
        }
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 15056
#include <stdio.h>
#include <stdlib.h>
long long MAX(long long a,long long b){
    return a>b?a:b;
}
int main() {
    int N,W;
    scanf("%d%d",&N,&W);
    long long w[N],v[N];
    for(int i=0;i<N;i++){
        scanf("%lld%lld",&w[i],&v[i]);
    }
    long long dp[N+2][W+2];
    for(int i=0;i<=N+1;i++){
        dp[i][0]=0;
        for(int j=1;j<=W+1;j++){
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<N;i++){
        for(long long j=0;j<=W;j++){
            dp[i+1][j]=dp[i][j];
            if(j>=w[i]){
                dp[i+1][j]=MAX(dp[i][j-w[i]]+v[i],dp[i+1][j]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    long long ans=0;
    for(int i=1;i<=W;i++){
        if(ans<dp[N][i]){
            ans=dp[N][i];
            //printf("update @%d\n",i);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 79872
#include <iostream>
#define NIL -1
struct Node {
    int parent, left, right;
};

void preorder(Node* nodeArray, int root)
{
    if (root == NIL) {
	return;
    }
    std::cout << " " << root;
    preorder(nodeArray, nodeArray[root].left);
    preorder(nodeArray, nodeArray[root].right);
}

void inorder(Node* nodeArray, int root)
{
    if (root == NIL) {
	return;
    }
    inorder(nodeArray, nodeArray[root].left);
    std::cout << " " << root;
    inorder(nodeArray, nodeArray[root].right);
}

void postorder(Node* nodeArray, int root)
{
    if (root == NIL) {
	return;
    }
    postorder(nodeArray, nodeArray[root].left);
    postorder(nodeArray, nodeArray[root].right);
    std::cout << " " << root;
}
int main()
{
    int n = 0;
    std::cin >> n;
    Node* nodeArray = (Node*)malloc(n * sizeof(Node));
    for (int i = 0; i < n; i++) {
	nodeArray[i].parent = NIL;
	nodeArray[i].left = NIL;
	nodeArray[i].right = NIL;
    }
    for (int i = 0; i < n; i++) {
	int index, left, right;
	std::cin >> index;
	std::cin >> left;
	std::cin >> right;
	nodeArray[index].left = left;
	nodeArray[index].right = right;
	nodeArray[left].parent = index;
	nodeArray[right].parent = index;
    }
    //??????????????¢?´¢
    int root;
    for (int i = 0; i < n; i++) {
	if (nodeArray[i].parent == NIL) {
	    root = i;
	    break;
	}
    }
    std::cout << "Preorder" << std::endl;
    preorder(nodeArray, root);
    std::cout << std::endl;
    std::cout << "Inorder" << std::endl;
    inorder(nodeArray, root);
    std::cout << std::endl;
    std::cout << "Postorder" << std::endl;
    postorder(nodeArray, root);
    std::cout << std::endl;
}

Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	unsigned int a, b, k;
	cin >> a >> b >> k;
	for (unsigned int i = a; i <= b; ++i) {
		if (i < a + k || i > b - k) {
			cout << i << endl;
		}
	}
	return 0;
}

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



#define MAX 100002

int n;

char buf[MAX];
#define MOD 1000000007

map<int, int> mp;

string s;
#define MOD 1000000007

int main() {
	cin >> n;
	scanf("%s", buf);
	s = buf;
	for (int i = 0; i < s.size(); i++) {
		mp[s[i]]++;
	}
	long long int ans = 1;
	for (auto it : mp) {
		ans *= (1LL+it.second);
		ans %= MOD;
	}
	ans += MOD - 1;
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
	int  A, B;
	
	cin >> A >> B;
	
	if(A == 1) A = 14;
        if(B == 1) B = 14;

	if(A == B) cout << "Draw" << endl;
	else if(A < B) cout << "Bob" << endl;
	else cout << "Alice" << endl;
	
	return 0;
}

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

int n,ans=1;
int t[MAX];
int L[MAX],R[MAX];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&t[i]);
  L[0]=1;
  for(int i=1;i<n;i++){
    L[i]=(t[i]==t[i-1]?1:L[i-1]+1);
    ans=max(ans,L[i]);
  }
  L[n]=L[n-1];
  R[n-1]=1;
  for(int i=n-2;i>=0;i--){
    R[i]=(t[i]==t[i+1]?1:R[i+1]+1);
    ans=max(ans,R[i]);
  }
  R[n]=0;
  
  for(int i=1;i<n;i++){
    if(t[i]==t[i-1]){
      int target=i+R[i];    
      ans=max(ans,L[i-1]+R[i]+R[target]);
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2364
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
int N;
ll a[100001];
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
    	cin>>a[i];
    }
    ll ans=0;
    ll ans2=0;
    ll R=a[0];
    if(a[0]<=0){
    	ans=1-a[0];
    	R=1;
    }

    for(int i=1;i<N;i++){
    	if(R<0){
    		R+=a[i];
    		if(R<=0){
    			ans+=1-R;
    			R=1;
    		}
    	}else{
    		R+=a[i];
    		if(R>=0){
    			ans+=R+1;
    			R=-1;
    		}

    	}
    }
    R=a[0];
    if(a[0]>=0){
    	ans2=a[0]+1;
    	R=-1;
    }

    for(int i=1;i<N;i++){
    	if(R<0){
    		R+=a[i];
    		if(R<=0){
    			ans2+=1-R;
    			R=1;
    		}
    	}else{
    		R+=a[i];
    		if(R>=0){
    			ans2+=R+1;
    			R=-1;
    		}

    	}
    }

    ll ans3=min(ans,ans2);

    cout<<ans3<<endl;
    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N,K;
  cin >> N >> K;
  vector <int> x(N);
  for(int i=0;i<N;i++)
    cin >> x[i];

  int min_cost = 1000000000;
  for(int i=0;i+K-1<N;i++)
    {
      //      cout << i << " " << i+K-1 << endl;
      //      cout << x[i] << " " << x[i+K-1] << endl;
      min_cost = min(min_cost, abs(x[i])+abs(x[i]-x[i+K-1]));
      min_cost = min(min_cost, abs(x[i+K-1])+abs(x[i]-x[i+K-1]));
    }
  
  cout << min_cost << endl;
}


Measured memory_bytes: 640
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut range: Vec<_> = (0..n)
		.map(|_| {
			let x: i64 = s.next().unwrap().parse().unwrap();
			let l: i64 = s.next().unwrap().parse().unwrap();
			(x - l, x + l)
		})
		.collect();
	range.sort_by_key(|r| r.1);
	let (ans, _) = range.into_iter().fold((0, std::i64::MIN), |s, r| if r.0 >= s.1 { (s.0 + 1, r.1) } else { s });
	println!("{}", ans);
}


Measured memory_bytes: 8444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s,t,u;

	cin >> s >> t;
	u = "Yes";
	for(i=0;i<s.size();i++) {
		if (s[i]!=t[i]) u = "No"; 
	}

	cout << u << endl;
	return 0;
}


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

inline int readInt(){
  int ret = 0;
  char c;
  while((c=getchar()) && isdigit(c)){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

void outint(int a){
  if (a == 0)return;
  outint(a/10);
  putchar('0' + a%10);
}

main(){
  int n,s;
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();
    int r[101]={0};
    //for(int i=0;i<n;i++){
    for(int i=n;i;i--){
      int tmp;tmp=readInt();r[tmp]++;
    }
    int ans = 0;
    for(int i=100;i;i--){
      if (r[i] && i+i > s)ans += r[i]*(r[i]-1)/2;
      if (!r[i])continue;
      for(int j=100;j > i;j--){
	if (i+j <= s)break;
	ans += r[i]*r[j];
      }
    }
    if (ans == 0)putchar('0');
    else outint(ans);
    puts("");
    //cout << ans << endl;
  }
}

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

int main() {
	int k, s; cin >> k >> s;
	int cnt = 0;
	for (int i = 0; i < k + 1; ++i) {
	for (int j = 0; j < k + 1; ++j) {
		if ( k >= s - i - j &&  s - i - j >= 0) ++cnt;
	}	
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

const ll MAX_N = 200000;
ll mat[26][MAX_N];

int main(){
	string A;
	cin >> A;
	ll i, j;
	for (i = 0; i < 26; i++){
		char s = 'a' + i;
		ll n = 0;
		for (j = 0; j < A.length(); j++){
			if (A[j] == s){
				n++;
			}
			mat[i][j] = n;
		}
	}
	ll ans = 1;
	for (j = 1; j < A.length(); j++){
		char s = A[j];
		ll lls = s - 'a';
		ans += j - mat[lls][j - 1];
	}
	cout << ans << endl;
	return 0;
}

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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long[] xs) {
    long sum = xs.map!abs.sum;
    auto n = xs.count!(e => e < 0);
    if (n % 2 == 0) return sum;
    auto m = xs.map!abs.reduce!min;
    return sum - m * 2;
}

void main() {
    readint;
    auto xs = reads!long;
    writeln(calc(xs));
}


Measured memory_bytes: 4436
from collections import defaultdict

def calc_cost(data_iwakan, color_dic, ind):
    cost = 0
    for ele in color_dic.keys():
        if ind == ele:
            continue
        cost += color_dic[ele] * data_iwakan[ele - 1][ind - 1]
    return cost



def main():
    masu_num, color_num = map(int, input().split())
    data_iwakan = [list(map(int, input().split())) for i in range(color_num)]
    data_masu = [list(map(int, input().split())) for i in range(masu_num)]

    color_dic = [defaultdict(int) for i in range(3)]

    for i in range(masu_num):
        for j in range(masu_num):
            color_dic[(i + j + 2) % 3][data_masu[i][j]] += 1

    ans = 10 ** 12

    for i in range(color_num):
        for j in range(color_num):
            for k in range(color_num):
                if i == j:
                    continue
                if i == k:
                    continue
                if j == k:
                    continue
                kari_ans = 0
                kari_ans += calc_cost(data_iwakan, color_dic[0], i)
                kari_ans += calc_cost(data_iwakan, color_dic[1], j)
                kari_ans += calc_cost(data_iwakan, color_dic[2], k)

                if ans > kari_ans:
                    ans = kari_ans

    print(ans)





if __name__ == '__main__':
    main()

Measured memory_bytes: 50396
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

h,w,m = ip()
y = [0]*h
x = [0]*w
dt = {}
for i in range(m):
    a,b = ip()
    y[a-1] += 1
    x[b-1] += 1
    dt[(a-1,b-1)] = 1
ans = 0
mx = max(x)
my = max(y)
xx = [i for i in range(w) if x[i] == mx]
yy = [i for i in range(h) if y[i] == my]
#print(x,y,xx,yy)
for i in xx:
    for j in yy:
        if dt.get((j,i),0):
            ans = max(ans,x[i]+y[j]-1)
        else:
            ans = max(ans,x[i]+y[j])
        if ans == mx+my:
            break
print(ans)

Measured memory_bytes: 166716
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
 
using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum;
int main(){
	string s;
	cin>>s;
	for(int i=0; i<3; i++) if(s[i]=='1') ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        X = N - (R * r) - (G *g)
        if X < 0:
            continue
        if X % B == 0:
            ans += 1

print(ans)


Measured memory_bytes: 42676
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<int> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
ll  n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (a == b &&b == c) {
		cout << -1 << endl;
		return 0;
	}
	while (1) {
		ans++;
		int na = b / 2 + c / 2;
		int nb = a / 2 + c / 2;
		int nc = a / 2 + b / 2;
		a = na; b = nb; c = nc;
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val ymd = sc.nextLine().split("/").map(_.toInt)

    if (Ordering.Iterable[Int].lteq(ymd, Array(2019, 4, 30)))
      println("Heisei")
    else
      println("TBD")
  }

}

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

using namespace std;

int cnt(int n) {

  int sum = 0;
  while (n % 2 == 0) {
    sum++;
    n /= 2;
  }
  return sum;
}

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

  int maxcnt = -1;
  int maxv = -1;

  for (int i = 1; i <= N; i++) {
    int a = cnt(i);
    if(maxcnt < a) {
      maxcnt = a;
      maxv = i;
    }
  }

  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0501
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        map<char, char> mp;
        while (N--) {
            char a, b;
            cin >> a >> b;
            mp[a] = b;
        }
        int M;
        cin >> M;
        string s;
        REP(i, M) {
            string t;
            cin >> t;
            s += t;
        }
        for (auto &x : s) {
            if (mp.count(x) > 0) {
                x = mp[x];
            }
        }
        cout << s << endl;
    }

    return 0;
}



Measured memory_bytes: 3168
r, c = map(int, input().split())
a    = []

for i in range(r):
    a.append(list(map(int, input().split())))
    a[i].append(sum(a[i]))

for i in range(r):
    print(" ".join(list(map(str, a[i]))))

csum = []
for j in range(c + 1):
    su = 0
    for i in range(r):
        su += a[i][j]
    csum.append(su)

print(" ".join(list(map(str, csum))))


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

int main()
{
    int n; cin >> n;
    
    if(n<10){
        cout << n << endl;
    }else if(n<100){
        cout << 9 << endl;
    }else if(n<1000){
        cout << n-90 << endl;
    }else if(n<10000){
        cout << 909 << endl;
    }else if(n<100000){
        cout << n-9090 << endl;
    }
    else{
        cout << 90909;
    }
}


Measured memory_bytes: 256
def prime_factor(n)
  prime = []
  2.upto(n) do |i|
    break unless i <= n / i
    while (n % i).zero?
      prime << i
      n /= i
    end
  end
  prime << n unless n == 1
  prime
end

h=Hash.new{|h,k|h[k]=0}
prime_factor(gets.to_i).each do |i| h[i]+=1 end
ans=0
h.each do |_,v|
  1.upto(v) do |i|
    v-=i
    break if v<0
    ans+=1
  end
end
p ans


Measured memory_bytes: 14356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		//入力したそのままの数
		String s=sc.next();
		
		//逆にした文字列
		StringBuffer str=new StringBuffer(s);
        String s2=str.reverse().toString();
		
		int count=0;
		int roopcount = 0;
		
		if(s.length()%2==0) {
			roopcount =s.length()/2;
		}else {
			roopcount=(s.length()-1)/2;
		}
		
		for(int i=0;i<roopcount;i++) {
			String a = s.substring(i,i+1);
			String b = s2.substring(i,i+1);
						
			if(!a.equals(b)){
				count+=1;
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


const ll N = 1e9+7;
const ll M = 1e6+5;
ll dp[M], invdp[M], inv[M];

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

}

void expo(){
    dp[0] = 1;
    invdp[0] = 1;
    inv[0] = 1;
    rep(i,M){
        dp[i+1] = dp[i] * (i + 1) % N;
        inv[i+1] = N - inv[N%(i+1)] * (N/(i+1)) % N;
        invdp[i+1] = modinv(dp[i+1], N);
    }
}


ll comb(ll x, ll y){
    ll ans;
    if(y > 0) ans = dp[x] * (invdp[y] * invdp[x-y] %N) % N;
    else ans = 1;
    // cout << dp[x] << " " << invdp[y] << " " << invdp[x-y] << " " << ans << endl;
    return ans;
}

int main(){
    ll X,Y;  cin >> X >> Y;
    ll x = 2*Y-X, y = 2*X-Y;
    bool ok = true;
    if(x%3 || y%3 || x < 0 || y < 0)ok = false;
    else{
        x /= 3;
        y /= 3;
    }
    expo();
    cout << (ok ? comb(x+y, y) : 0) << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll l,r,d;
  cin >> l >> r >> d;
  cout << r/d - (l-1)/d << endl;
}


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

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

//???????????????????????????TNode*???????????????(vector??????????????¢?????????????????????)
class TTable
{
private:
	vector<TNode*> FNodes;
	void Create(int Id)
	{
		if(FNodes[Id] == NULL){
			TNode* Node;
			Node = new TNode;
			*Node = {Id, NULL, NULL, NULL};
			FNodes[Id] = Node;
		}
	}
public:
	//TNode*?????????&?????????????????????????????????
	//????????????????????§delete????????????????????????????????????????????????????????¨?????????????????????????????????????????????
	//???????????????????????????Id??¨TNode*???????????????????????¨??§????????????????????????????????¨????????????????????????????????????
	TNode* operator[](int n)
	{
		Create(n);
		return FNodes[n];
	}
	TNode* operator[](int n)const
	{
		return FNodes[n];
	}
	TTable(int n)
	{
		//????´??????°???????????????
		FNodes.resize(n, NULL);
	}
	~TTable()
	{
		int n = FNodes.size();
		for(int i = 0; i < n; i++){
			delete FNodes[i];
		}
	}
	int size()const
	{
		return FNodes.size();
	}
};

enum TNodeType {Root, InternalNode, Leaf};

void CreateLeftRelation(TNode* ParentNode, TNode* LChildNode)
{
	ParentNode->LChild = LChildNode;
	LChildNode->Parent = ParentNode;
}

void CreateRightRelation(TNode* ParentNode, TNode* RChildNode)
{
	ParentNode->RChild = RChildNode;
	RChildNode->Parent = ParentNode;
}

void Input(TTable& Table)
{
	for(int i = 0; i < Table.size(); i++){
		int Id;
		cin >> Id;
		TNode* Node = Table[Id];
		int left;
		cin >> left;
		if(left != -1){
			CreateLeftRelation(Node, Table[left]);
		}
		int right;
		cin >> right;
		if(right != -1){
			CreateRightRelation(Node, Table[right]);
		}
	}
}

void PreorderOutput(const TNode* Node)
{
	cout << ' ' << Node->Id;
	if(Node->LChild){
		PreorderOutput(Node->LChild);
	}
	if(Node->RChild){
		PreorderOutput(Node->RChild);
	}
}

void InorderOutput(const TNode* Node)
{
	if(Node->LChild){
		InorderOutput(Node->LChild);
	}
	cout << ' ' << Node->Id;
	if(Node->RChild){
		InorderOutput(Node->RChild);
	}
}

void PostorderOutput(const TNode* Node)
{
	if(Node->LChild){
		PostorderOutput(Node->LChild);
	}
	if(Node->RChild){
		PostorderOutput(Node->RChild);
	}
	cout << ' ' << Node->Id;
}

void ChangeToRootNode(TNode* &Node)
{
	while(Node->Parent){
		Node = Node->Parent;
	}
}

void Output(const TTable& Table)
{
	TNode* Node = Table[0];
	ChangeToRootNode(Node);
	TNode* RootNode = Node;
	cout << "Preorder"  << endl;
	PreorderOutput(RootNode);
	cout << endl;
	cout << "Inorder"   << endl;
	InorderOutput(RootNode);
	cout << endl;
	cout << "Postorder" << endl;
	PostorderOutput(RootNode);
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	TTable Table(n);
	Input(Table);
	Output(Table);
    return 0;
}

Measured memory_bytes: 3112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static int[][] C;

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

        C = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                C[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve() ? "Yes" : "No");
    }

    static boolean solve() {
        for (int a0 = 0; a0 <= 100; a0++) {
            if( isOk(a0) ) {
                return true;
            }
        }
        return false;
    }

    static boolean isOk(int a0) {
        int[] b = new int[3];
        for (int i = 0; i < 3; i++) {
            b[i] = C[0][i] - a0;
        }
        int[] a = new int[3];
        a[0] = a0;
        a[1] = C[1][0] - b[0];
        a[2] = C[2][0] - b[0];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if( a[i] + b[j] != C[i][j] ) return false;
            }
        }
        return true;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const LL  INF  = 1<<30;
const int mod  = 1e9+7;

int n,m;
struct node{
    int l,r;
}s[maxn];

bool cmp(node a ,node b){
    if(a.l==b.l)return  a.r<b.r;
    else return a.l<b.l;
}
void solve(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&s[i].l,&s[i].r);
    }
    sort(s+1,s+1+m,cmp);
    int l = s[1].l ,r = s[1].r;
    int cnt = 1;
    for(int i=2;i<=m;i++){
        if(s[i].l>=r){
            cnt++;
            l = s[i].l;
            r = s[i].r;
        }else{
            l = s[i].l;
            r = min(r,s[i].r);
        }
    }
    printf("%d\n",cnt);

    return;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int cas = 1,t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}


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

const int DIM = 1e5 + 5;

int v[DIM], oki[DIM];

int main(void) {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++i)
        cin >> v[i];
    
    int nr = 0;
    for (int i = 1; !oki[i]; ++nr, i = v[i]) {
        if (i == 2) {
            cout << nr; return 0; }
        else
            oki[i] = true;
    }
    
    cout << -1;
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N=int(input().rstrip())
count=0

def resolve():
    global count
    dfs("")
    print(count)

def dfs(s):
    global count
    

    s3=str(s)+str(3) if s!="" else str(3)
    s5=str(s)+str(5) if s!="" else str(5)
    s7=str(s)+str(7) if s!="" else str(7)

    if s3.find("3")!=-1 and s3.find("5")!=-1 and s3.find("7")!=-1 and int(s3)<=N:
        count+=1
    if int(s3)>N:
        return
    dfs(s3)

    if s5.find("3")!=-1 and s5.find("5")!=-1 and s5.find("7")!=-1 and int(s5)<=N:
        count+=1
    if int(s5)>N:
        return
    dfs(s5)

    if s7.find("3")!=-1 and s7.find("5")!=-1 and s7.find("7")!=-1 and int(s7)<=N:
        count+=1
    if int(s7)>N:
        return
    dfs(s7)


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """575"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3600"""
        output = """13"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """999999999"""
        output = """26484"""
        self.assertIO(input, output)

if __name__ == "__main__":
#    unittest.main()
    resolve()

Measured memory_bytes: 5700
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	double R=read()*2;
	printf("%.12lf",R*acos(-1));

	return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	ll n;
	for(ll i=0;i<5;i++)
	{
		cin>>n;
		if(n==0)
		{
			cout<<i+1;
			return;
		}
	}
	
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int par[100005];
int lank[100005];

void init(int n){
    for(int i=0; i<n; i++){
        par[i]=i;
        lank[i]=0;
    }
}
int find(int x){
    if(par[x]==x){
        return x;
    }else {
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(lank[x]<lank[y]){
        par[x]=y;
    }else {
        par[y]=x;
        if(lank[x]==lank[y])lank[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}
signed main() {
    int n,m;cin>>n>>m;
    int a[114514];
    rep(i,0,n){
        cin>>a[i];
        a[i]--;
    }
    init(n);
    rep(i,0,m){
        int a,b;cin>>a>>b;
        a--;b--;
        unite(a,b);
    }
    int ans=0;
    rep(i,0,n){
        if(same(i,a[i]))ans++;
    }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
A = list(input())
k = False
p = False
if A[0] == 'A' and A[1].islower() == True and  A[-1].islower() == True:
  A.pop(0)
  A=str(A)
  for a in A:
    if a == 'C':
      p =True
  A = A.replace('C', '', 1)
  k = A.islower()
if k and p:
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    if(s[s.length()-1] == 's'){
        cout << s+"es" << "\n";
    }else{
        cout << s+"s" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc082_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<int> c(N);
  rep(i, N) {
    int t;
    cin >> t;
    t--;
    c[i] = t;
  }

  ll ans = 0;
  rep(i, N-1) {
    if (c[i] == i) {
      swap(c[i], c[i + 1]);
      ans++;
    }
  }
  if (c[N-1] == N-1) {
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3708