akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 20;
vector<pair<ll, ll>> possible[N][N];
int cat[N];
int main(){
	cat[0] = cat[1] = 1;
	int n;
	cin >> n;
	vector<int> A(n);
	for(int & x : A){
		cin >> x;
	}
	if(n == 2){ cout << A[0] + A[1] << endl; return 0;}
	for(int i = 0; i + 1 < n; i++){
		possible[i][i + 1] = {{0, 0}};
	}

	ll ans = 1LL << 60;
	for(int i = 1; i + 2 <= n; i++){
		for(int j = 0; j < i; j++) cat[i] += cat[j] * cat[i - 1 - j];
		for(int j = 0; j + i + 1 < n; j++){
			int r = j + i + 1;
			if(i != n - 2) possible[j][r].reserve(cat[i]);
			for(int k = j + 1; k < r; k++){
				for(auto X : possible[j][k]) for(auto Y : possible[k][r]){
					ll p = A[k] + X.second + Y.first;
					pair<ll, ll> T = {X.first + p, Y.second + p};
					if(i == n - 2){
						ans = min(ans, T.first + T.second);
					} else{
						possible[j][r].push_back(T);
					}
				}
			}
		}
	}
	cout << ans + A[0] + A[n - 1] << endl;
}

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

int main()
{
        int size;
        cin >> size;
        vector<int> x(size);
//      cout << "input: "; 
        for (int i=0; i<size; ++i){
                cin >> x[i];
//              cout << x[i] << " ";
        }
//      cout << endl;
        // maximum increment 
        int maximum_increment = x[1] - x[0];
        if (size == 2) {
                cout << maximum_increment << endl;
                return 0;
        }
        int min = x[0];
        int max = x[0];
        for (int i=1; i<size; ++i) {
                if (x[i] < min) {
                        min = x[i];
                        max = min;
                        continue;
                }
                if (x[i] > max) {
                        max = x[i];
                }
                if (max - min > maximum_increment) {
                        maximum_increment = max - min;
                }
        }   
        cout << maximum_increment << endl;
        return 0;
}



Measured memory_bytes: 3592
import std.stdio, std.string, std.conv;

void main() {
    auto input = getStdin!(string[])();
    foreach (line; input) {
    	auto num = line.split(" ").to!(int[]).sort;
    	if (num[0] == 0 && num[1] == 0) break;
    	writefln("%d %d", num[0], num[1]);
    }
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2928
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    P = list(map(float, input().split()))

    dp = [0.0]*(N//2+2)
    dp[0] = 1.0
    for i in range(N):
        dp_ = [0.0]*(N+1)
        dp_[N//2+1]=dp[N//2+1]
        for j in range(min(i+1,N//2+1),-1,-1):
            dp_[j]+=dp[j-1]*P[i]
            dp_[j-1]+=dp[j-1]*(1-P[i])
        dp=dp_.copy()
    print(dp[N//2+1])

if __name__ == '__main__':
    main()

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> ans(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		ans[a]++;
		ans[b]++;
	}
	rep(i,n){
		cout << ans[i] << endl;
	}
}

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

int m,n;
int i,j,mark[8][8][8][8][8][8][8],q[100000][10],p[7];

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

int check(int a[]){
	int k;
	for(k=0;k<8;k++){if(a[k]!=k)return 0;}
	return 1;
}

void look(int a[],int dir){
	int k;
	for(k=0;k<10;k++)q[j][k]=a[k];
	if(dir==0){swap(&q[j][q[j][8]],&q[j][q[j][8]-1]);q[j][8]--;}
	if(dir==1){swap(&q[j][q[j][8]],&q[j][q[j][8]+1]);q[j][8]++;}
	if(dir==2){swap(&q[j][q[j][8]],&q[j][q[j][8]-4]);q[j][8]-=4;}
	if(dir==3){swap(&q[j][q[j][8]],&q[j][q[j][8]+4]);q[j][8]+=4;}
	q[j][9]++;
	if(mark[q[j][0]][q[j][1]][q[j][2]][q[j][3]][q[j][4]][q[j][5]][q[j][6]]==0){
		mark[q[j][0]][q[j][1]][q[j][2]][q[j][3]][q[j][4]][q[j][5]][q[j][6]]=q[j][9];
		j++;
	}
}

void inspect(int a[]){
	if(a[8]%4>0)look(a,0);
	if(a[8]%4<3)look(a,1);
	if(a[8]>3)look(a,2);
	if(a[8]<4)look(a,3);
}


int main(){
	mark[0][1][2][3][4][5][6]=1;
	for(i=0;i<8;i++)q[0][i]=i;
	q[0][8]=0;q[0][9]=1;
	i=0;j=1;
	while(i<j){inspect(q[i]);i++;}

	while(scanf("%d %d %d %d %d %d %d %*d",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6])!=EOF){
		printf("%d\n",mark[p[0]][p[1]][p[2]][p[3]][p[4]][p[5]][p[6]]-1);
	}
	return 0;
}

Measured memory_bytes: 10104
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long
int arr[60];
int n, p;

int main() {
	ll n, maxi1 = 0, maxi2 = 0;
	cin >> n;
	map<ll, ll> mp;
	for (int i = 0; i < n; i++) {
		ll in;
		cin >> in;
		mp[in]++;
		if (mp[in] >= 2 && in > maxi1) {
			maxi2 = maxi1;
			maxi1 = in;
		}
		if (mp[in] >= 2 && in < maxi1 && in > maxi2) {
			maxi2 = max(maxi2, in);

		}
	}
	ll ans[2] = {0};
	int i = 0;
	ll finalans = 0;
	map<ll, ll>::iterator s = mp.end();
	s--;
	map<ll, ll>::iterator e = mp.begin();
	e--;
	for (map<ll, ll>::iterator it = s; it != e; it--) {
		if (it->second >= 4){
			finalans = max (finalans , (it->first) * (it->first));
		}
		if (it->second >= 2)
			ans[i++] = it->first;
		if (i == 2)
			break;
	}
	cout << max (finalans , ans[0] * ans[1]) << endl;
}


Measured memory_bytes: 9740
# B - Exchange
A,B,K = map(int,input().split())
for i in range(K):
    if i%2==0:
        A = A-A%2
        A,B = A//2,B+A//2
    else:
        B = B-B%2
        A,B = A+B//2,B//2
print(A,B)

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

int main(){
  int N,Y;
  cin >>N>>Y;
  Y = Y/1000;
  int t=Y-N;
  int x=-1,y=-1,z=-1;
  for(int i=0;9*i<=t;i++){
    if((t-9*i)%4 == 0){
      x = i;
      y = (t-9*i)/4;
      z = N-x-y;
      if(z<0){
        x=-1;
        y=-1;
        z=-1;
        continue;
      }
      else break;
    }
  }
  cout <<x<<" "<<y<<" "<<z<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int main()
{
      int n,t;
      while(cin>>n>>t)
      {
          int x,y;
          int ans = -1;
          int now = -1;
          int cost = -1;
          for(int i = 0; i < n; ++i)
          {
              cin>>x>>y;
              if(y <= t)
              {
                  if(now == -1)
                    {
                        ans = i + 1;
                        now = y;
                        cost = x;
                    }
                    else
                    {
                        cost = min(cost, x);
                    }
              }
          }

          if(ans == -1)
            cout<<"TLE"<<endl;
          else
            cout<<cost<<endl;
      }
}












Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0,0)
s = 0
for i in range(len(a)-1):
    s += abs(a[i]-a[i+1])
for h in range(1,n+1):
    t = abs(a[h+1]-a[h-1])-abs(a[h]-a[h-1])-abs(a[h+1]-a[h])
    print(s+t)

Measured memory_bytes: 20488
#include<stdio.h>

int main(void){
    int n,m,i,k;
    int a[100][100];
    int b[100];
    int c[100]={0};
    scanf("%d %d",&n,&m);
    
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            scanf("%d",&a[i][k]);
        }
    }
    
    for(k=0;k<m;k++){
        scanf("%d",&b[k]);
    }
    
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            c[i]+=a[i][k]*b[k];
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    return 0;
}

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

int main() {
  int k;
  string s, ans;
  cin >> k >> s;
  if (s.length() <= k){
    ans = s;
  }
  else{
    ans = s.substr(0, k) + "...";
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

int main()
{
	lint a=ty(),b=ty(),c=ty();
	printf("%lld\n",b+min(c,a+b+1));

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,W,w;
vi d[100010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>W;
	w=W/2;
	vi ans;
	rep2(i,1,min(w+2,N-W+2)){
		ans.pb(i+W-1);
	}
	rep2(i,w+1,W){
		for(int j=i;j<=N;j+=i){
			d[j].pb(i);
		}
	}
	int res=ans[sz(ans)-1];
	rep2(i,w+2,N-W+2){
		int in=i+W-1,out=i-1;
		int hi=min(i-1,W-1);
		rep(j,sz(d[in]))if(d[in][j]<=hi)res++;
		rep(j,sz(d[out]))if(d[out][j]<=hi)res--;
		if(out<W)res++;
		ans.pb(res);
	}
	rep(i,sz(ans))cout<<ans[i]<<(i==sz(ans)-1?"\n":" ");
}

Measured memory_bytes: 5616
A, B, K = map(int, input().split())
if (B - A + 1) <= 2 * K:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)


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

int main(){
  int N;
  cin >> N;
  string ans="No";
  for(int i=1; i<10; i++){
    for(int j=1; j<10; j++){
      if(N==i*j) ans="Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------



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

int main()
{
    Phuong_;
    int n;
    cin >> n;
    int minn=n+1;
    int dem=0;
    while (n--)
    {
        int u;
        cin >> u;
        minn=min(minn,u);
        if (u==minn) dem++;
    }
    cout << dem;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;
ll vis[100005]={0};
vector<ll>adj[100005];


//-----------------//
  #define amin main
//-----------------//

void dfs(ll u)
{

	vis[u] = 1;
	for(auto v : adj[u])
	{
		if(vis[v]==0)
			dfs(v);
	}
}


int amin()
{
	 	// freopen("input.txt", "r", stdin);
   //   	freopen("output.txt", "w", stdout);
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		ll t,i,j;
		
		ll n,m;
		cin>>n>>m;
		for(i=0;i<m;i++)
		{
			ll a,b;
			cin>>a>>b;
			a--;
			b--;
			adj[a].pb(b);
			adj[b].pb(a);
		}
		ll cnt= 0;
		for(i=0;i<n;i++)
		{
			if(vis[i]==0)
			{
				dfs(i);
				cnt++;
			}
		}
		cout<<cnt-1<<endl;

	
	
	


	
	return 0;
}

Measured memory_bytes: 11124
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=505;
char s[N];
int a[N][N],cnt[N],ct[N];
int main(){
   // freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,j,n,ff=0;
    scanf("%d",&n);
    for (i=1;i<=n;i++){
        scanf("%s",s+1);
        for (j=1;j<=n;j++) if (s[j]=='.') a[i][j]=0; else a[i][j]=1,ff=1;
    }
    if (!ff) {puts("-1");return 0;}
    for (i=1;i<=n;i++)
     for (j=1;j<=n;j++)
      cnt[j]+=a[i][j],ct[i]+=a[i][j];
    int tot=n,ans=n+1;
    for (i=1;i<=n;i++) if (cnt[i]==n) tot--;
    for (i=1;i<=n;i++) if (cnt[i]) ans=min(ans,n-ct[i]); else ans=min(ans,n-ct[i]+1);
    ans+=tot;
    cout<<ans<<endl;
    
  //  system("pause");
    return 0;
}


Measured memory_bytes: 1280
{-
BubbleSort(A)
1 for i = 0 to A.length-1
2     for j = A.length-1 downto i+1
3         if A[j] < A[j-1]
4             swap A[j] and A[j-1]
-}

main = do
    s1 <- getLine
    let n = read s1 :: Int
    s2 <- getLine
    let a = map (\x -> read x :: Int) $ words s2
    let (swapTimes, sorted) = bubbleSort a
    putStrLn $ unwords $ map show sorted
    putStrLn $ show swapTimes

bubbleSort :: [Int] -> (Int, [Int])
bubbleSort a = bubbleSorti (0,a) 0

bubbleSorti :: (Int,[Int]) -> Int -> (Int,[Int])
bubbleSorti (swapTimes, a) i
  | i > (length a-1) = (swapTimes, a)
  | otherwise        = bubbleSorti (bubbleSortj (swapTimes, a) i (length a - 1)) (i+1)

bubbleSortj :: (Int,[Int]) -> Int -> Int -> (Int,[Int])
bubbleSortj (swapTimes, a) i j
  | j < (i+1)       = (swapTimes, a)
  | a!!j < a!!(j-1) = bubbleSortj (swapTimes+1, swap a j (j-1)) i (j-1)
  | otherwise       = bubbleSortj (swapTimes, a) i (j-1)

swap :: [a] -> Int -> Int -> [a]
swap a i j = (take i1 a) ++ [a!!i2] ++ (take (i2-i1-1) $ drop (i1+1) a) ++ [a!!i1] ++ (drop (i2+1) a)
  where (i1, i2) = (min i j, max i j)


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

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;
    std::vector<int> vec;

    for (int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        vec.push_back(a);
    }

    std::vector<int> count;
    for (int i = 0; i < N; i++) {
        int c = 0;
        while(vec[i] % 2 == 0) {
            vec[i] /= 2;
            c++;
        }
        count.push_back(c);
    }

    int min = 1000000000;
    for (int i = 0; i < N; i++) {
        if (count[i] < min) {
            min = count[i];
        }
    }

    std::cout << min;

    return 0;
}

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

using namespace std;

class RollingHash {
 private:
  const uint64_t mod = (1ULL << 61) - 1;
  std::vector<uint64_t> hashes, pows;

  inline uint64_t add(uint64_t a, uint64_t b) const {
    a += b;
    if (a >= mod) a -= mod;
    return a;
  }

  inline uint64_t sub(uint64_t a, uint64_t b) const {
    if (a < b) a += mod;
    a -= b;
    return a;
  }

  inline uint64_t mul(uint64_t a, uint64_t b) const {
    uint64_t ah = a >> 31, al = a & ((1ULL << 31) - 1), bh = b >> 31,
             bl = b & ((1ULL << 31) - 1), m = ah * bl + al * bh,
             v = (ah * bh << 1) + (m >> 30) + ((m & ((1ULL << 30) - 1)) << 31) +
                 al * bl;
    v = (v & ((1ULL << 61) - 1)) + (v >> 61);
    return v;
  }

 public:
  template <typename T>
  RollingHash(const T &S, uint64_t base = 10007)
      : hashes(S.size() + 1, 0), pows(S.size() + 1, 0) {
    pows[0] = 1;
    for (size_t i = 0; i < S.size(); i++) {
      pows[i + 1] = mul(pows[i], base);
      hashes[i + 1] = add(mul(hashes[i], base), S[i]);
    }
  }

  // S[r, l)
  uint64_t slice(int l, int r) const {
    return sub(hashes[r], mul(hashes[l], pows[r - l]));
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  vector<int> C(N), D(N);
  for (int i = 0; i < N; i++) {
    C[i] = A[i] ^ A[(i + 1) % N];
    D[i] = B[i] ^ B[(i + 1) % N];
  }
  for (int i = 0; i < N; i++) {
    C.emplace_back(C[i]);
  }
  RollingHash rhc(C), rhd(D);
  for (int i = 0; i < N; i++) {
    if (rhc.slice(i, i + N) == rhd.slice(0, N)) {
      cout << i << ' ' << (A[i] ^ B[0]) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 16752
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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





int main(){
  int N, T;
  while(cin >> N >> T){
    vector<int> A(N), B(N);
    REP(i,N) cin >> A[i] >> B[i];

    vector<vector<int>> dp(N+1, vector<int>(T+1));
    vector<vector<pair<int,int>>> restore(N+1, vector<pair<int,int>>(T, make_pair(-1,-1)));

    REP(i,N){
      REP(j,T){
        if(chmax(dp[i+1][j], dp[i][j])) restore[i+1][j] = restore[i][j];
        if(j+A[i]<T){
          if(chmax(dp[i+1][j+A[i]], dp[i][j]+B[i])){
            restore[i+1][j+A[i]] = make_pair(i, j);
          }
        }
      }
    }
    
    //dp[N][T];
    
    vector<int> used;
    
    auto cur = restore[N][T-1];
    while(cur != make_pair(-1,-1)){
      //dump(cur);

      used.push_back(cur.fst);

      cur = restore[cur.fst][cur.snd];
    }
    

    {
      int t = 0;
      for(auto i : used){
        t += B[i];
      }
      dump(t);

      
    }

    dump(accumulate(ALL(B), 0));

    dump(used);

    dump(dp[N][T-1]);

    int ans = dp[N][T-1];


    int t = 0;

    REP(i,N){
      if(count(ALL(used), i) == 0){
        chmax(t, B[i]);
      }
    }

    
    ans += t;

    cout << ans << endl;
    
  }


  return 0;
}


Measured memory_bytes: 106112
N,X = map(int,input().split())
if X in (1,2*N-1):
    print('No')
    exit()

print('Yes')
if N == 2:
    for i in range(3): print(i+1)
    exit()

ans = [None] * (2*N-1)
if X == 2:
    ans[N-2:N+2] = [3,2,1,4]
    n = 5
    for i in range(2*N-1):
        if ans[i] is not None: continue
        ans[i] = n
        n += 1
else:
    ans[N-2:N+2] = [X-1,X,X+1,X-2]
    n = X+2
    for i in range(2*N-1):
        if ans[i] is not None: continue
        ans[i] = (n-1)%(2*N-1) + 1
        n += 1
for a in ans:
    print(a)

Measured memory_bytes: 12500
import java.util.Scanner;
import java.util.HashSet;

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

        int n = sc.nextInt();
        int i;

        for(i=0; i<n; i++)
        {
            String type = sc.next();

            if(type.equals("insert"))
            {
                String input = sc.next();
                hs.add(input);
            }
            else if(type.equals("find"))
            {
                String input = sc.next();
                if(hs.contains(input)) System.out.println("yes");
                else System.out.println("no");
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 259504
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[105][105];
signed main() {
    for(int i = 0; i < 105; i++) {
        for(int j = 0; j < 105; j++) {
            if(i != j) {
                cnt[i][j] = INF;
            }
        }
    }
    int N,M;
    cin >> N >> M;
    vector<int>a(M),b(M),c(M);
    for(int i = 0; i < M; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        cnt[a[i]][b[i]] = min(cnt[a[i]][b[i]],c[i]);
        cnt[b[i]][a[i]] = min(cnt[b[i]][a[i]],c[i]);
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                cnt[j][k] = min(cnt[j][k],cnt[i][j]+cnt[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                if(cnt[j][a[i]]+cnt[b[i]][k]+c[i] == cnt[j][k]) {
                    ans++;
                    goto END;
                }
            }
        }
    END:;
    }
    cout << M-ans << endl;
}


Measured memory_bytes: 3732
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline

H, W = map(int, readline().split())
S = [list(input()) for i in range(H)]


def bfs(grid, start):
    distance = [[0] * W for _ in range(H)]
    queue = deque([start])
    visited = [[False] * W for _ in range(H)]
    visited[start[0]][start[1]] = True
    while queue:
        x, y = queue.popleft()

        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            new_y, new_x = y + j, x + i
            if 0 <= new_y < W and 0 <= new_x < H:
                if grid[new_x][new_y] == '.' and not visited[new_x][new_y]:
                    distance[new_x][new_y] = distance[x][y] + 1
                    visited[new_x][new_y] = True
                    queue.append((new_x, new_y))
    return distance


answer = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue

        cnt = 0
        for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            new_y, new_x = dy + j, dx + i
            if 0 <= new_y < W and 0 <= new_x < H:
                if S[new_x][new_y] == '.':
                    cnt += 1

        if cnt > 2:
            continue

        tmp = max(map(max, bfs(S, (i, j))))
        if tmp > answer:
            answer = tmp

print(answer)


Measured memory_bytes: 3316
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int main(){
fcin;
string s;
int y = 0;
    cin >> s;
    for(auto x: s){
        y += (x-'0');
    }
    if(y%9==0) cout << "Yes\n";
    else cout << "No\n";

}

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

typedef long long ll;

int N;
ll a[(int)2e5];

int main() {
    ll ans = 1e18;
    ll sum = 0;
    cin >> N;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }

    // ll sum = accumulate(a, a + N, 0);
    ll x = 0;
    for (int i = 0; i <= N - 2; i++) {
        x += a[i];
        ll y = sum - x;
        // printf("x: %lld y: %lld abs: %lld\n", x, y, abs(x - y));
        ans = min(ans, abs(x - y));
        // ans = min(ans, abs(sum - 2 * x));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String row1 = scan.next();
		String row2 = scan.next();

		if(row1.charAt(0) != row2.charAt(2)){
			System.out.println("NO");
			return;
		}

		if(row1.charAt(1) != row2.charAt(1)){
			System.out.println("NO");
			return;
		}

		if(row1.charAt(2) != row2.charAt(0)){
			System.out.println("NO");
			return;
		}

		System.out.println("YES");

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int cnt = 0, wa;
   string n;
   cin >> n;

   n = '0' + n;

   for (int i = n.size() - 1; i >= 0; --i)
   {
      wa = n[i] - '0';

      if (wa < 5)
      {
         cnt += wa;
      }
      else
      {
         if (wa == 5 && n[i - 1] < '5')
         {
            cnt += wa;
         }
         else
         {
            cnt += 10 - wa;
            ++n[i - 1];
         }
      }
   }

   cout << cnt << '\n';
}

Measured memory_bytes: 2332
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int H,W;
	while (1)
	{
		cin>>H>>W;
		if(H==0 && W==0)
			break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import math
def f(a,b):
  return math.sqrt((a*a)+(b*b))

n,k=map(int,input().split())
c=0
for i in range(n):
  a,b=map(int,input().split())
  res=f(a,b)
  #print(res)
  if res<=k:
    c+=1
print(c)


Measured memory_bytes: 9188
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, K;
    cin >> N >> K;
    if (K == 1) cout << 0 << endl;
    else cout << N-K << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static long Solve(string N, int K)
    {
        int L = N.Length;
        var dp1 = new long[L + 1][];
        var dp2 = new long[L + 1][];
        dp1[0] = new long[K + 1];
        dp2[0] = new long[K + 1];
        dp1[0][0] = 1;
        dp2[0][0] = 1;
        for (int i = 1; i <= L; ++i)
        {
            int n = int.Parse(N.Substring(L - i, 1));
            dp1[i] = new long[K + 1];
            dp2[i] = new long[K + 1];
            Func<int, long> pr1 = j => (j < 0) ? 0 : dp1[i - 1][j];
            Func<int, long> pr2 = j => (j < 0) ? 0 : dp2[i - 1][j];
            for (int j = 0; j <= K; ++j)
            {
                dp1[i][j] = pr1(j - 1) * 9 + pr1(j);
                if (n > 0)
                {
                    dp2[i][j] = pr1(j - 1) * (n - 1) + pr1(j) + pr2(j - 1);
                }
                else
                {
                    dp2[i][j] = pr2(j);
                }
            }
        }
        return dp2[L][K];
    }

    static void Main(string[] args)
    {
        string N = Console.ReadLine();
        int K = int.Parse(Console.ReadLine());
        Console.WriteLine(Solve(N, K));
    }
}


Measured memory_bytes: 11220
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		City[] cities = new City[n];
		for (int i = 0; i < n; i++) {
		    cities[i] = new City(i, sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(cities, new Comparator<City>() {
		    public int compare(City c1, City c2) {
		        if (c1.pref == c2.pref) {
		            return c1.year - c2.year;
		        } else {
		            return c1.pref - c2.pref;
		        }
		    }
		});
		int prev = 0;
		int num = 1;
		for (City c : cities) {
		    if (prev != c.pref) {
		        num = 1;
		        prev = c.pref;
		    } else {
		        num++;
		    }
		    c.num = num;
		}
		Arrays.sort(cities, new Comparator<City>() {
		    public int compare(City c1, City c2) {
		        return c1.idx - c2.idx;
		    }
		});
		StringBuilder sb = new StringBuilder();
		for (City c : cities) {
		    sb.append(c).append("\n");
		}
		System.out.print(sb);
	}
	
	static class City {
	    int idx;
	    int pref;
	    int year;
	    int num;
	    public City (int idx, int pref, int year) {
	        this.idx = idx;
	        this.pref = pref;
	        this.year = year;
	    }
	    
	    public String toString() {
	        return String.format("%06d", pref) + String.format("%06d", num);
	    }
	}
}


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

using namespace std;

int main(void) {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> color;
    for(int i=1; i<=N; i++) {
        int a;
        cin >> a;
        while(a--) {
            color.emplace_back(i);
        }
    }

    vector< vector<int> > grid(H, vector<int>(W));
    for(int i=0; i<H; i++) {
        if(i%2) {
            for(int j=0; j<W; j++) {
                grid[i][j] = color.back();
                color.pop_back();
            }
        } else {
            for(int j=W-1; j>=0; j--) {
                grid[i][j] = color.back();
                color.pop_back();
            }
        }
    }

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cout << grid[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){

int N;
cin >> N;

if(N < 10){}
else if(N < 100){
  N = N % 10;
}
else{
  N = N % 100;
  N = N % 10;
}

if(N == 3){
  cout << "bon" << endl;
}
else if(N == 0 || N == 1 || N == 6 || N == 8){
  cout << "pon" << endl;
}
else{
  cout << "hon" << endl;
}

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long li;
typedef int in;
typedef double dub;
#define fst first
#define scnd second
#define pub push_back
#define pob pop_back
#define mkp make_pair
#define lb lower_bound
#define ub upper_bound
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n,a[100005],i,mov,ans;
    while(cin>>n)
    {
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        mov=0,ans=0;
        for(i=0;i<n-1;i++)
        {
            if(a[i]>=a[i+1])
            {
                mov++;
            }
            else
            mov=0;
            if(mov>ans)
            {
                ans=mov;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int count = 0;
  rep(i,6)
  {
    if(S[i]=='1')
    {
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int point[50][2];
	int goal[50][2];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>point[i][0]>>point[i][1];
	}
	for(int i=0;i<m;i++){
		cin>>goal[i][0]>>goal[i][1];
	}
	for(int i=0;i<n;i++){
		int ans=-1;
		long long int min=99999999999999999;
		for(int j=0;j<m;j++){
			long long int ans_t=abs(goal[j][0]-point[i][0])+abs(goal[j][1]-point[i][1]);
			if(min > ans_t){
				ans=j;
				min=ans_t;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static long[] ans=new long[100001];
     public static void main (String[] args) throws java.lang.Exception {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
    	int t=1;//sc.nextInt();
        while (t-- > 0){
            int l=sc.nextInt();
             pw.println((l*l)+(l)+(l*l*l));
        }
        pw.close();
}
}

  

Measured memory_bytes: 33596
from numpy import sort

N,M,X = map(int,input().split())
C = [0] * N
A = [None] * N
for i in range(N):
  c,*a = map(int,input().split())
  C[i] = c
  A[i] = a

INF = 10 ** 9
ans = INF
import itertools
for i in range(1,N + 1):
  for comb in itertools.combinations(range(N),i):
    cost = 0
    skills = [0] * M
    for c in comb:
      cost += C[c]
      for j in range(M):
        skills[j] += A[c][j]
    if cost >= ans:
      continue
    for s in skills:
      if s < X:
        break
    else:
      ans = cost

if ans == INF:
  print(-1)
else:
  print(ans)        


Measured memory_bytes: 27180
#include <iostream>
#include <list>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;

class vec2d {
	public:
		double x,y;
		vec2d(double _x,double _y) {
			x = _x;y = _y;
		}
		vec2d() {
			x = 0;y = 0;
		}
		vec2d transform(double rotate,double magnify) {
			vec2d ret;
			ret.x = ((x*cos(rotate))-(y*sin(rotate)))*magnify;
			ret.y = ((x*sin(rotate))+(y*cos(rotate)))*magnify;
			return ret;
		}
		vec2d operator-(const vec2d e) const{
			return vec2d(x - e.x,y - e.y);
		}
		vec2d operator+(const vec2d e) const{
			return vec2d(x + e.x,y + e.y);
		}
};

list<vec2d> pt;

void koch(int depth,list<vec2d>::iterator p1,list<vec2d>::iterator p2) {
	if(depth == 0) return;
	vec2d dif = (*p2) - (*p1);
	pt.insert(p2,(*p1) + dif.transform(0,((double)1)/((double)3)));
	pt.insert(p2,(*p1) + dif.transform(0,((double)1)/((double)3)) + dif.transform(M_PI / ((double)3),((double)1)/((double)3)));
	pt.insert(p2,(*p1) + dif.transform(0,((double)2)/((double)3)));
	auto pp = p1;
	auto pn = p1;
	pn++;
	for(int i = 0;i < 4;i++) {
		koch(depth-1,pp,pn);
		if(i != 3) {
			pp = pn;
			pn++;
		}
	}
}

int main() {
	int n;
	cin >> n;
	pt.insert(pt.end(),vec2d(0.0,0.0));
	pt.insert(pt.end(),vec2d(100.0,0.0));
	auto pn = pt.begin();
	pn++;
	koch(n,pt.begin(),pn);
	cout << fixed << setprecision(20);
	//cout << "2500 1000 " << pt.size() << endl;
	for(auto e:pt) {
		cout << e.x << " " << e.y << endl;
	}
}



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

int main() {
	int v[4] = {0, 3, 5, 7};
	string s;
	cin >> s;
	int len = s.size();
	int dp[len+1][2][2][2][2][2];
	fill((int *)dp, (int *)dp + sizeof(dp)/sizeof(int), 0);
	dp[0][0][0][0][0][0] = 1;
	for (int i = 0; i < len; i++) {
		const int D = s[i] - '0';
		for (int smaller = 0; smaller <= 1; ++smaller) {
			for (int nonzero = 0; nonzero <= 1; nonzero++) {
				for (int f3 = 0; f3 <= 1; f3++) {
					for (int f5 = 0; f5 <= 1; f5++) {
						for (int f7 = 0; f7 <= 1; f7++) {
							int x_max = smaller ? 9 : D;
							for (int x : v) {
								if (nonzero && x == 0) continue; 
								if (x > x_max) continue;
								dp[i+1][smaller || x<D][nonzero || x != 0][f3||x==3][f5||x==5][f7||x==7] += dp[i][smaller][nonzero][f3][f5][f7];
							}
						}
					}
				}
			}
		}
	}
	int ans = dp[len][0][1][1][1][1] + dp[len][1][1][1][1][1];
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N, sumA=0, sumB=0, Min;
    cin >> N;
    for (int A=1; A<N; A++){
     		int B=N-A;
      		int a=A, b=B;
            sumA=0, sumB=0;
            while (true){
              		sumA += a%10;
                    a = (a-a%10)/10;
                    if (a==0) break;
            }
            while (true){
              		sumB += b%10;
                    b = (b-b%10)/10;
              		if (b==0) break;
            }
            if ((Min>sumA+sumB)||A==1){
              		Min = sumA+sumB;
            }
    }
    cout << Min << endl;
              		
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &v[i]);
	}
	int cnt = 0;
	for(; ; cnt ^= 1){
		int cnt_odd = 0, ind_odd = 0;
		REP(i, 0, n){
			if (v[i] & 1){
				cnt_odd++;
				ind_odd = i;
			}
		}
		if (cnt_odd > 1 || v[ind_odd] == 1){
			break;
		}
		if (n % 2 == 0){
			break;
		}
		v[ind_odd]--;
		int g = 0;
		REP(i, 0, n){
			g = gcd(g, v[i]);
		}
		REP(i, 0, n){
			v[i] /= g;
		}
	}
	
	REP(i, 0, n){
		if (v[i] % 2 == 0){
			cnt ^= 1;
		}
	}
	
	if (cnt){
		printf("First\n");
	} else {
		printf("Second\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3100
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if n == 1:
        print(1)
        exit()

    # Only when there is no bit duplication in a group,
    # it always meets the condition.
    # l <= true_l < true_r < r
    ans = n
    l = 0
    now = a[0]
    for r in range(1, n):
        if now & a[r] == 0:
            now = now ^ a[r]
            continue

        now = now ^ a[r]
        for new_l in range(r-1, l-1, -1):
            if a[new_l] & a[r] != 0:
                break
        # else:
            # print('Error')
            # exit()
        new_l += 1

        for i in range(l, new_l):
            now = now ^ a[i]

        ans += (r-l) * (r-l-1) // 2 - (r-new_l) * (r-new_l-1) // 2

        l = new_l

    r += 1
    ans += (r-l) * (r-l-1) // 2

    print(ans)

main()

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

int main() {
  int N,M;
  cin >> N >> M;
  
  // APG4b-N
  vector<int> c(N);
  for (int i = 0; i < M; i++) {
    int a,b; // city number
    cin >> a >> b;
    c.at(a-1)++;
    c.at(b-1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << c.at(i) << endl;
  }

}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */


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

	int N, A, B; cin >> N >> A >> B;
	LL ans = min(N*A,B);
	
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function permutation(a,n)
	ans = Array{Int,1}[copy(a)]
	c = ones(Int,n)
	i = 1
	while i<=n
		if c[i]<i
			if i%2==1
				tmp = a[1]
				a[1] = a[i]
				a[i] = tmp
			else
				tmp = a[c[i]]
				a[c[i]] = a[i]
				a[i] = tmp
			end
			c[i] += 1
			i = 1
			push!(ans,copy(a))
		else
			c[i] = 1
			i += 1
		end
	end
	ans
end

function main()
    n,m,rn = readline() |> split |> parseMap
    r = readline() |> split |> parseMap
    d = 10^18*ones(Int,n,n)
    for i in 1:n
        d[i,i] = 0
    end
    for i in 1:m
        a,b,c = readline() |> split |> parseMap
        d[a,b] = c
        d[b,a] = c
    end
    for i in 1:n
        for k in 1:n
            for j in 1:n
                d[i,j] = min(d[i,j],d[i,k]+d[k,j])
            end
        end
    end
    for k in 1:n
        for j in 1:n
            for i in 1:n
                d[i,j] = min(d[i,j],d[i,k]+d[k,j])
            end
        end
    end
    for j in 1:n
        for i in 1:n
            for k in 1:n
                d[i,j] = min(d[i,j],d[i,k]+d[k,j])
            end
        end
    end
    prm = permutation(r,rn)
    minim = 10^18
    for i in 1:length(prm)
        x = 0
        for j in 2:rn
            x += d[prm[i][j-1],prm[i][j]]
        end
        minim = min(minim,x)
    end
    println(minim)
end
main()

Measured memory_bytes: 189052