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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    string s;
    cin >> s;

    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 0; i < (n-1)/2; i++) {
        if (s[i] != s[(n-1)/2-i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = (n+3)/2; i < n; i++) {
        if (s[i] != s[n-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0; 
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a!=b){
    if(b!=c){
      if(a!=c){
        cout<<"No"<<endl;
        return 0;
      }else if(a==c){
        cout<<"Yes"<<endl;
        return 0;
      }
    }else{
      cout<<"Yes"<<endl;
    }
  }else if(b!=c){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
  }
}



Measured memory_bytes: 256
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]
a=0
d=0
for i in range(26):
  b=0
  for j in range(D):
    b+=s[j][i]
  b-=((D-1)*c[i])
  if a<=b:
    d=i
for i in range(D):
  if i!=D-1:
    print(d+1)
  else:
    p=0
    q=0
    for j in range(26):
      if p<=s[D-1][j]:
        p=s[D-1][j]
        q=j
    print(j+1)

Measured memory_bytes: 9424
n,k = map(int,input().split())
lst1 = list(map(int,input().split()))

dp = [float("inf") for _ in range(n)]

dp[0] = 0

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(lst1[i]-lst1[j]))

print(dp[-1])

Measured memory_bytes: 56800
#include <stdio.h>
const int N = 305;
const int M = 305;
int main ()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == 0)
		{
			break;
		}
		for(int i = 0; i < m; i++)
		{
			printf("#");
		}
		printf("\n");
		for(int i = 0; i < n-2; i++)
		{
			printf("#");
			for(int j = 0; j < m-2; j++)
			{
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(int i = 0; i < m; i++)
		{
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	return 0;
	
}


Measured memory_bytes: 2572
#include <utility>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <ios>
#include <iomanip>
#include <sstream>
#include <climits>
#include <cmath>

using namespace std;

#ifdef USE_LOG
#define LOG(str)  cout << str << endl
#define DMP(var)  cout << #var << " = " << var << endl
#else
#define LOG(...)
#define DMP(...)
#endif

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define RFOR(v, b, e)  for (int v = (e) - 1; (b) <= v; --v)
#define REP(v, n)      FOR(v, 0, n)
#define RREP(v, n)     RFOR(v, 0, n)

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

typedef long long           ll;
typedef unsigned long long  ull;

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

	string N;
	cin >> N;

	int r = 0;
	int t = 0;
	REP (i, N.length()) {
		t += N[i] - '0';
	}

	r = t;

	FOR (i, 0, N.length() - 1) {
		t = 0;
		FOR (j, 0, i) {
			t += N[j] - '0';
		}
		t += (N[i] - '0') - 1;
		t += 9 * (N.length() - (i + 1));
		r = max(t, r);
	}

	cout << r << endl;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
#define INF (1<<29)

int dist[30][30];
int main(){
    int n, m;
    char dummy;
	cin >> n >> m;

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i == j)dist[i][j] = 0;
			else      dist[i][j] = INF;
		}
	}

	for(int i=0;i<m;i++){
		int a, b, c, d;
		cin >> a >> dummy >> b >> dummy >> c >> dummy >> d;
		dist[a-1][b-1] = c;
		dist[b-1][a-1] = d;
	}	


	for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	int x1, x2, y1, y2;
	cin >> x1 >> dummy >> x2 >> dummy >> y1 >> dummy >> y2;
	cout << (y1 - y2 - dist[x1-1][x2-1] - dist[x2-1][x1-1]) << endl;
	return 0;
}

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

int notOdd(long int a[], long int N);

int main() {
	long int *a;
	long int N;
	long int op = 0;
	scanf("%ld", &N);
	a = malloc(N * sizeof(op));
	for (int i = 0; i < N; i++) {
		scanf("%ld", &a[i]);
	}
	while (notOdd(a, N)) {
		for (int i = 0; i < N; i++) {
			a[i] = a[i]/2;
		}
		op++;
	}
	printf("%ld\n", op);
	return 0;
}

int notOdd(long int a[], long int N) {
	for (int i = 0; i < N; i++) {
		if (a[i]%2 == 1)
			return 0;
	}
	return 1;
};


Measured memory_bytes: 128
A, B = map(int, input().split())


if A == 1 or B == 1:
    if A == B:
        print('Draw')
    elif A == 1:
        print('Alice')
    elif B == 1:
        print('Bob')
else:
    if A > B:
        print('Alice')
    elif A < B:
        print('Bob')
    else:
        print('Draw')

Measured memory_bytes: 3064
#include<cstdio>

using namespace std;

int main() {
	int n, k, s;
	scanf("%d%d%d", &n, &k, &s);
	int p = 999999937;
	if (s == p) p = 2;
	int i = 0;
	for(; i < k; i++) {
		if (i == 0) printf("%d", s);
		else printf(" %d", s);
	}
	for(; i < n; i++) {
		if (i == 0) printf("%d", p);
		else printf(" %d", p);
	}
	puts("");
}




Measured memory_bytes: 1280
def main():
    INF=10**9
    n,m=map(int,input().split())
    key=[0]*m
    keycost=[0]*m

    for i in range(m):
        a,b=map(int,input().split())
        keycost[i]=a
        c=[pow(2,int(i)-1) for i in input().split()]
        key[i]=sum(c)
    
    dp=[[INF]*(m+1) for _ in range(1<<n)]
    dp[0]=[0]*(1+m)
    
    for s in range(1<<n):
        for i in range(m):
            dp[s][i+1]=min(dp[(s&key[i])^s][i]+keycost[i],dp[s][i])
    
    if dp[-1][m]==INF:
        print(-1)
    else:
        print(dp[-1][m])
 
if __name__=='__main__':
    main()

Measured memory_bytes: 76632
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,a[MAXN],val[MAXN],cnt[MAXN],Mx;char s[MAXN];
struct SegTree{
	#define ls x<<1
	#define rs x<<1|1
	int Mx[MAXN<<2];
	inline void pushup(int x){Mx[x]=max(Mx[ls],Mx[rs]);}
	void Change(int x,int l,int r,int p,int v){
		if(l==r){Mx[x]=v;return;}int mid=l+r>>1;
		if(p<=mid)Change(ls,l,mid,p,v);else Change(rs,mid+1,r,p,v);
		pushup(x);
	}int Ask(int x,int l,int r,int ql,int qr){
		if(ql<=l&&r<=qr)return Mx[x];int mid=l+r>>1;
		if(qr<=mid)return Ask(ls,l,mid,ql,qr);else if(ql>mid)return Ask(rs,mid+1,r,ql,qr);
		else return max(Ask(ls,l,mid,ql,mid),Ask(rs,mid+1,r,mid+1,qr));
	}void Build(int x,int l,int r){
		Mx[x]=1-1e9;if(l==r)return;int mid=l+r>>1;
		Build(ls,l,mid),Build(rs,mid+1,r);
	}
}Odd,Even;
inline bool chk(int mx,int Q){if(Q<0)return 0;return Q&1?Odd.Ask(1,1,n,mx,n)>=Q:Even.Ask(1,1,n,mx,n)>=Q;}
int main(){
	n=read();
	Rep(i,1,n)a[i]=read(),a[i]>Mx?Mx=a[i],val[i]=2:val[i]=1;
	Odd.Build(1,1,n);
	Red(i,n,1){
		int Mx1=Odd.Ask(1,1,n,a[i],n),Mx0=Even.Ask(1,1,n,a[i],n);
		if(val[i]==1)Odd.Change(1,1,n,a[i],Mx0+1),Even.Change(1,1,n,a[i],Mx1+1);
		else Odd.Change(1,1,n,a[i],Mx1+2),Even.Change(1,1,n,a[i],Mx0+2);
	}Red(i,n,1)cnt[i]=cnt[i+1]+val[i]-1;
	int cntX=0,cntY=0,mxX=0,mxY=0;
	Rep(i,1,n){
		Odd.Change(1,1,n,a[i],1-1e9),Even.Change(1,1,n,a[i],0);
		if(chk(mxY,cntX+cnt[i+1]-cntY+(a[i]>mxX)))s[i]='0',cntX+=a[i]>mxX,mxX=max(mxX,a[i]);
		else if(chk(max(mxX,a[i]),cntY+cnt[i+1]-cntX-(a[i]>mxX)))s[i]='0',cntX+=a[i]>mxX,mxX=max(mxX,a[i]);
		else s[i]='1',cntY+=a[i]>mxY,mxY=max(mxY,a[i]);
	}if(cntX==cntY)cout<<s+1<<'\n';else puts("-1");
	return 0;
}




Measured memory_bytes: 10192
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  
  string ans;
  int now = n;
  while(now != 0){
    if(now%(-2)==-1) {
      ans += '1';
      now = now/(-2) + 1;
    }
    else {
      ans += now%(-2) + '0';
      now /= -2;
    }
    //cout << ans << endl;
  }
  reverse(ALL(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll N,M;
  cin>>N>>M;
  if(M>N)cout<<(M-2)/(N-1)+1<<endl;
  else if(M==1)cout<<0<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
lx = list(map(int,input().split()))

lx.sort()
dx = []
s = 0

for i in range(len(lx)-1):
  dx.append(lx[i+1]-lx[i])

if n == 1:
  print(lx[m-1]-lx[0])
elif m <= n:
  print(0)
else:
  dx.sort()
  for i in range(len(dx)-n+1):
    s = s + dx[i]
  print(s)

Measured memory_bytes: 13960
n = input()
if len(n) % 2:
    ans = 0
    for i in range(1, len(n), 2):
        ans += int('9'*i)-10**(i-1)+1
    ans += int(n)-10**(len(n)-1)+1
else:
    ans = 0
    for i in range(1, len(n), 2):
        ans += int('9'*i)-10**(i-1)+1
print(ans)

Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String N = br.readLine();

			if (Integer.parseInt(N) % f(N) == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
			// System.out.println(f(N) + "," + Integer.parseInt(N));
		}
	}

	private static int f(String N) {
		char[] values = N.toCharArray();
		int count = 0;
		for (char value : values) {
			count += value - '0';
		}
		return count;
	}
}

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

using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> a(N);
    
    int a_min = INT_MAX, a_max = INT_MIN;
    rep(i, N) {
        cin >> a[i];
        chmin(a_min, a[i]);
        chmax(a_max, a[i]);
    }

    int ans = INT_MAX;
    for (int i = a_min; i <= a_max; i++) {
        int cost = 0;
        rep(j, N) {
            cost += (a[j] - i) * (a[j] - i);            
        }
        chmin(ans, cost);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~");

int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, k;
    cin >> n >> k;

    double p = 0.0;
    if ( k <= n )
        p += double(n-k+1)/double(n);

    for (int i=1; i < k && i <= n; i++) {
        int d = log(k/i)/log(2) ;
        if (i*pow(2, d) < k) d++;
        double pt = double(1.0)/ double(pow(double(2), double(d))) / double(n);
        // cout << d << " " << std::setprecision(12) << pt << endl;
        p += pt;
    }

    cout << std::setprecision(12) << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define ll long long int

int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i >= 10){
            int temp = i, sum = 0;
            while(temp > 0){
                sum += temp%10;
                temp /= 10;
            }
            if(sum >= a && sum <= b){
                ans += i;
            }
        }else{
            if(i >= a && i <= b){
                ans += i;
            }
        }
    }
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 3228
n = int(input())
d = {}
for i in range(n):
    s = input().strip()
    if s not in d: d[s] = 1
    else: d[s] += 1

t = max(d, key = lambda i : d[i])
print(*(sorted([i for i in d if d[i] == d[t]])), sep = '\n')


Measured memory_bytes: 33244
H, W, K = (int(i) for i in input().split())

if W == 1:
    print(1)

else:

    wnum = [0]*(W-1)
    for i in range(W-1):
        wsum = 0
        for j in range(2**(W-1)):
            bit = format(j, "0{}b".format(W-1))
            cc = 0
            for k in range(W-2):
                if bit[k] == "1" and bit[k + 1] == "1":
                    break
            else:
                if bit[i] == "1":
                    wnum[i] += 1
                wsum += 1

    dp = [[0]*W for i in range(H+1)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            if 1 <= j <= W-2:
                dp[i+1][j] = dp[i][j-1] * wnum[j-1] + dp[i][j+1] * wnum[j] + dp[i][j] * (wsum-wnum[j-1]-wnum[j])
            elif j == 0:
                dp[i+1][j] = dp[i][j+1] * wnum[j] + dp[i][j] * (wsum-wnum[j])
            else:
                dp[i+1][j] = dp[i][j-1] * wnum[j-1] + dp[i][j] * (wsum-wnum[j-1])
            dp[i+1][j] = dp[i+1][j] % 1000000007
    print(dp[H][K-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;


int N;
int a[100010];
int ans;
//---------------

int main(){
	cin>>N;
	REP(i,0,N) {
		cin>>a[i];
	}
	REP(i,0,N-1){
		if(a[i]==i+1){
			swap(a[i],a[i+1]);
			ans++;
		}
	}
	if(a[N-1]==N) ans++;
	p(ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
    int N, K; cin>>N>>K;
    cout << (N-K+1) << endl;
    
    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{    
  int N;
  cin >> N;
  vector<string> str_vec(N);
  for (int i = 0; i < N; i++)
  {
    cin >> str_vec[i];
  }
  sort(str_vec.begin(), str_vec.end());
  str_vec.erase(unique(str_vec.begin(), str_vec.end()), str_vec.end());
  cout << str_vec.size() << endl;

} 


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

using namespace std;

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

	vector<long> mem(N+1, 0);
	
	for(int i = 1; i < 110; i++){
		for(int j = 1; j < 110; j++){
			for(int k = 1; k < 110; k++){
				long v = i*i + j*j + k*k + i*j + j*k + k*i;
				if(v <= N) mem[v]++;
			}
		}
	}
	for(int i = 1; i <= N; i++){
		cout << mem[i] << endl;
	}
}

Measured memory_bytes: 3628
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd ** 0.5) + 1):
        if gcd % i == 0:
            cnt += 1
            while True:
                if gcd % i == 0:
                    gcd //= i
                else:
                    break
    if gcd != 1:
        cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 64364
#define _USE_MATH_DEFINES
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
  cout << std::fixed << std::setprecision(10);
  
  int a, b, x;
  double water;
  double deg;
  double y;
  
  cin >> a >> b >> x;
  
  water = (a * b * 0.5) * a;
  if(x >= water){
    y = ((double)b - ((double)x / ((double)a * (double)a))) / 0.5;
    deg = atan(y / (double)a);
    cout << (double)(deg * 180 / M_PI) << endl;
  }
  else
  {
    y = x / (0.5 * a * b);
    deg = atan((double)b / y);
    cout << (double)(deg * 180 / M_PI) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
from collections import Counter


N, M = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort()
B.sort()
A_cnt = Counter(A)
B_cnt = Counter(B)
if len(A) > 0:
    if max(A_cnt.values()) > 1:
        print(0)
        exit()
if len(B) > 0:
    if max(B_cnt.values()) > 1:
        print(0)
        exit()
if A[N - 1] != N * M or B[M - 1] != N * M:
    print(0)
    exit()

a = 0
b = 0
i = 1
C = [0] * (N * M)
while i <= N * M:
    if i == A[a] and i == B[b]:
        C[i - 1] = 1
        a += 1
        b += 1
    elif i == A[a] and i != B[b]:
        C[i - 1] = M - b
        a += 1
    elif i != A[a] and i == B[b]:
        C[i - 1] = N - a
        b += 1
    else:
        C[i - 1] = (N - a) * (M - b) - (N * M - i)
    i += 1

ans = 1
mod = 10 ** 9 + 7
for c in C:
    ans = (ans * c) % mod

print(ans)


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	vector<int> a;
	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		a.pb(t);
	}

	int f = n % 2;

	deque<int> ans;
	for(int i=0; i<n; i++){
		if(i % 2 == f){
			ans.push_back(a[i]);
		}else{
			ans.push_front(a[i]);
		}
	}

	for(int i=0; i<n; i++){
		if(i != n-1)printf("%d ", ans[i]);
		else printf("%d\n", ans[i]);
	}

	
	return 0;
}


Measured memory_bytes: 3828
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rint register int
typedef long long ll;

inline int Min(const int a,const int b){return a<b?a:b;}
inline int Max(const int a,const int b){return a>b?a:b;}

int n,c,a[10];
ll f[320][33],z,t;

int main()
{
    scanf("%d%d",&n,&c);
    for(int i=0;i<n;++i)scanf("%d",&a[i]);
    std::sort(a,a+n);
    do
    {
        memset(f,0,sizeof f);
        f[n*a[n-1]][0]=1;
        for(rint i=0;i<n*c;++i)if(i%n)
            for(rint j=i;j<=n*c;++j)
                for(rint k=0;k<(1<<(n-1));++k)
                    if((k>>(i%n-1)&1)==0)
                        f[Min(Max(j,i+n*a[i%n-1]),n*c)][k|(1<<(i%n-1))]+=f[j][k];
        z+=f[n*c][(1<<(n-1))-1],++t;
    }while(std::next_permutation(a,a+n-1));
    printf("%.15f\n",(double)z/t/pow(c,n-1));
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const LL mo=998244353;
const int N=100001;
const int K=10000;
char s1[10002],s2[10002];
LL fac[100001],inv[100001];
int f[10001][10001];
LL mul(LL x,LL y) {
	if (y==0) return 1;
	LL now=mul(x,y/2);
	now=now*now%mo;
	if (y%2) now=now*x%mo;
	return now;
}
void pre_choose() {
	fac[0]=1;
	for (LL i=1;i<=N;i++) fac[i]=fac[i-1]*i%mo;
	inv[N]=mul(fac[N],mo-2);
	for (LL i=N-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mo;
}
LL C(LL x,LL y) {
	if (y>x||y<0) return 0;
	return fac[x]*inv[y]%mo*inv[x-y]%mo;
}
void pre_dp() {
	f[0][0]=1;
	for (LL i=1;i<=K;i++)
		for (LL j=1;j<=K;j++)
			f[i][j]=((LL)f[i-1][j]*j%mo+f[i-1][j-1])%mo;
}
int main() {
	pre_choose();
	pre_dp();
	scanf("%s",s1);
	scanf("%s",s2);
	int cnt1=0,cnt2=0;
	int len=strlen(s1);
	for (int i=0;i<len;i++) {
		if (s1[i]=='1'&&s2[i]=='1') cnt1++;
		if (s1[i]=='1'&&s2[i]=='0') cnt2++;
	}
	LL ans=0;
	int k=cnt1+cnt2;
	for (int i=cnt2;i<=k;i++) {
		LL now=C(k,i)*f[i][cnt2]%mo*fac[k-i]%mo*fac[k-i]%mo*fac[cnt2]%mo*fac[cnt2]%mo;
		now=now*fac[i-cnt2]%mo*C(cnt1,i-cnt2)%mo;
		ans=(ans+now)%mo;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 392576
#include <stdio.h>

int main()
{
	while (true)
	{
		int d[10];
		int va, vb;
		int sumd = 0;

		for (int i = 0; i < 10; i++)
		{
			if (scanf("%d,", &d[i]) == -1) return 0;
			sumd += d[i];
		}
		scanf("%d,%d", &va, &vb);

		double p = double(sumd) / double(va + vb) * double(va);
		int ans = 0;
		while (p > 0)
		{
			p -= d[ans];
			ans++;
		}

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

struct UnionFind {
  vector<int> uni;
  explicit UnionFind(int n): uni(n+5, -1) {}
  int  root(int x)        { return (uni[x] < 0)? x : uni[x] = root(uni[x]); }
  int  size(int i)        { return (-uni[root(i)]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y){
    if ( (x=root(x)) == (y=root(y)) )return false;
    if ( uni[y] < uni[x] ) swap(x,y);
    uni[x] += uni[y];  uni[y] = x;
    return true;
  }
};

signed main()
{
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);

  rep(i, 0, M) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }

  unordered_set<int> U;
  rep(i, 1, N+1) {
    U.insert(uf.root(i));
  }

  cout << U.size() << endl;
  return 0;
}



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

int main(){

  string s;
  int len;
  cin>>len>>s;
  
  string s_mae=s.substr(0,len/2);
  string s_ato=s.substr(len/2,len);

  if(s_mae==s_ato) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;

	if (a == b) cout << "Draw" << endl;

	else if (a == 1 || b == 1) {
		if (a == 1) cout << "Alice" << endl;
		else cout << "Bob" << endl;
	}

	else {
		if (a > b) cout << "Alice" << endl;
		else cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long int A, B;
	cin >> A >> B;
	long long int a, b = 0;
	a = max(A, B);
	b = min(A, B);
	if ((B - A) % 2 == 0) {
		cout << b + (a - b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	vector<int> a(m);
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[j];
			v[i] += a[j] * b[j];
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] + c > 0)sum++;
	}

	cout << sum << endl;

	return 0;
}

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

int main()
{
	int sx, sy, tx, ty;
	cin>>sx>>sy>>tx>>ty;
	for(int i = sy; i < ty ;++i)cout<<"U";
	for(int i = sx; i < tx ;++i)cout<<"R";
	for(int i = sy; i < ty ;++i)cout<<"D";
	for(int i = sx; i < tx ;++i)cout<<"L";
	cout<<"L";
	for(int i = sy; i < ty + 1 ;++i)cout<<"U";
	for(int i = sx; i < tx + 1 ;++i)cout<<"R";
	cout<<"D"<<"R";
	for(int i = sy; i < ty + 1 ; ++i)cout<<"D";
	for(int i = sx; i < tx + 1 ; ++i)cout<<"L";
	cout<<"U";
	return 0;
}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;

    map<ll, ll> postdc;
    rep(i, 1, s.size()) postdc[s[i] - '0']++;

    map<ll, ll> predc;
    set<ll> ans;
    predc[s[0] - '0']++;
    rep(i, 1, s.size() - 1) {
        postdc[s[i] - '0']--;
        if (postdc[s[i] - '0'] == 0) postdc.erase(s[i] - '0');
        REP(pre, 10) {
            if (predc.find(pre) == predc.end()) continue;
            REP(post, 10) {
                if (postdc.find(post) == postdc.end()) continue;
                ans.insert(pre * 100 + (s[i] - '0') * 10 + post);
            }
        }
        predc[s[i] - '0']++;
    }
    cout << ans.size() << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a[10];
	for (int i = 0; i < 10; i++)
	{
		cin >> a[i];
	}
	sort(a,a + 10);
	cout << a[9] << endl << a[8] << endl << a[7] << endl;
	
	return 0;
}

Measured memory_bytes: 3132
N,M = map(int,input().split())
S = input()
T = input()
ans = 0
a = 2

if S[0] != T[0]:ans = -1

elif N % M != 0 and M % N != 0:
    if N >= M:
        while True:
            if N * a % M == 0:
                ans = N * a
                b = int(N*a/M)
                for i in range(int(N/b)):
                    if T[a*i] != S[b*i]:
                        ans = -1
                        break
                break
            else:
                a += 1
    elif N < M:
        while True:
            if M * a % N == 0:
                ans = M * a
                b = int(M*a/N)
                for i in range(int(M/b)):
                    if T[b*i] != S[a*i]:
                        ans = -1
                        break
                break
            else:
                a += 1

elif N % M == 0:
    b = int(N/M)
    ans = N
    for i in range(M):
        if T[i] != S[b*i]:
            ans = -1
            break   

elif M % N == 0:
    b = int(M/N)
    ans = M
    for i in range(N):
        if S[i] != T[b*i]:
            ans = -1
            break   

print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();

		int[] rSum = new int[c];
		int cSum = 0, gSum = 0;
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				int cell = scan.nextInt();
				cSum += cell;
				rSum[j] += cell;
				System.out.print(cell + " ");
			}
			gSum += cSum;
			System.out.println(cSum);
			cSum = 0;
		}
		for (int i = 0; i < c; i++)
			System.out.print(rSum[i] + " ");
		System.out.println(gSum);

		System.exit(0);
	}

	private static int run(int n, int x) {
		int result = 0;
		for (int a = 1; a <= n; a++)
			for (int b = a + 1; b <= n; b++)
				for (int c = b + 1; c <= n; c++)
					if (a + b + c == x)
						++result;
		return (result);

	}
}

Measured memory_bytes: 41112
S = gets.chomp
LENGTH = S.size
def calc(pat)
    s = S.scan(/./)
    (LENGTH - 1).times{|i|
        if pat[i] == 1
            s.insert(LENGTH - 1 - i, "+")
        end
    }
    eval s.join
end
sum = 0
(2 ** (LENGTH - 1)).times{|i|
    sum += calc(i)
}
puts sum


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;


void ABC064A()
{
	int r, g, b;
	cin >> r >> g >> b;
	int ret = r * 100 + g * 10 + b;
	if (ret % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
int main()
{
	ABC064A();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N (200)
int n,m;
int a[N];
int main(){
	scanf("%d",&n);
	int s=0;
	for (int i=1;i<=n;i++) scanf("%d",a+i),s+=a[i];
	scanf("%d",&m);
	for (int i=1,b,c;i<=m;i++){
		scanf("%d%d",&b,&c);
		printf("%d\n",s-a[b]+c);
	}
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int a,b,c;
int main(){
	cin>>a;
	if(a%2==0)cout<<a/2<<endl;
	else cout<<a/2+1<<endl; 
	return 0;
}


Measured memory_bytes: 256
// AOJ 0179
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<functional>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long long int integer;

bool end(string s) {
  char c = s[0];
  int len = s.size();
  REP(i, len) {
    if (c != s[i]) {
      return false;
    }
  }
  return true;
}

vector<string> gonext(string worm) {
  vector<string> v;
  for (int i = 1, len = worm.length(); i < len; i++) {
    if (worm[i] == worm[i-1]) continue;
    string s = worm;
    char c = 'r' + 'g' + 'b' - worm[i] - worm[i-1];
    s[i] = s[i-1] = c;
    v.push_back(s);
  }
  return v;
}

typedef pair<integer,string> P;

integer solve(string worm) {
  priority_queue<P,vector<P>,greater<P> > q;
  set<string> s;
  q.push(make_pair(0,worm));
  while (!q.empty()) {
    P w = q.top();
    q.pop();
    if (end(w.second)) return w.first;
    vector<string> nxts = gonext(w.second);
    for (auto nxt : nxts) {
      if (s.find(nxt) == s.end()) {
        q.push(make_pair(w.first + 1, nxt));
        s.insert(nxt);
      }
    }
  }
  return -1;
}

int main() {
  string s;
  while (cin >> s and s != "0") {
    integer ans = solve(s);
    if (ans == -1) {
      cout << "NA" << endl;
    } else {
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 2384
a, b, c, x, y = map(int, input().split())
xy = [x, y]

total_ab = a * x + b * y
total_c = c * 2 * max(xy)
if x > y:
    total_abc = c * 2 * min(xy) + a * (x-y)
else:
    total_abc = c * 2 * min(xy) + b * (y-x)

total = [total_ab, total_c, total_abc]
print(min(total))

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){out << q.F << " " << q.S; return out;}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F-p2.F, p1.S-p2.S};}

void solve() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int tot = (h2-h1)*60;
    tot += m2-m1;
    tot--;
    if(tot >= k){
        cout << tot-k+1 << endl;
    } else {
        cout << 0 << endl;
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
    //#endif
   
    // cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


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

using namespace std;
typedef long long ll;

void cmp(string &a,string b)
{
  if(a=="-") a=b;
  else if(a.size()<b.size()) a=b;
  else if(a.size()==b.size()) if(a<b) a=b;
}

int main() {
	int n,m;
	cin >> n >> m;
	
	vector<int> a(m);
	for(int i=0; i < m; i++) {
		cin >> a[i];
	}
	
	vector<int> b = {2,5,5,4,5,6,3,7,6};
	
	vector<string> dp(n+1, "-");
	dp[0] = "";
	
	for(int i=0; i <= n; i++) {
		if(dp[i] == "-") continue;
		
		for(int num : a) {
			if(i + b[num-1] > n) continue;
			string next = dp[i] + static_cast<char>('0' + num);
			cmp(dp[i + b[num-1]], next);
		}
	}
	
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 43648
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b<<endl;
	else if(a>=6)cout<<b/2<<endl;
	else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

	int N,i,j,x=0;
	int ans[200]={0};
	
	scanf("%d",&N);
	
	for(i=1;i<=N;i++){
		for(j=1;j<=i;j++){
			if(i%2!=0 && i%j==0)
				ans[i-1]++;
	}	}
	for(i=0;i<200;i++){
		if(ans[i]==8)
			x++;
	}
	printf("%d",x);
	
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, r;
	cin >>n >>m >>r;
	VI t(r);
	rep(i, r){ cin >>t[i]; t[i]--;}
	vector<VI> a(n, VI(n, 1<<28));
	rep(i, n) a[i][i] = 0;
	rep(i, m){
		int x, y, z;
		cin >>x >>y >>z;
		if(a[x-1][y-1] > z){
			a[x-1][y-1] = a[y-1][x-1] = z;
		}
	}
	
	rep(k,n) rep(i,n) rep(j,n) a[i][j] = min(a[i][j], a[i][k]+a[k][j]);
	sort(all(t));
	ll ans = 1LL<<60;
	do {
		ll sm =0;
		rep(i,r-1){
			sm += a[t[i]][t[i+1]];
		}
		ans = min(ans, sm);
	} while ( next_permutation(all(t)) );

	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 384
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n+1];
   int count=0;
   for(int i=1;i<=n;i++){
       cin>>a[i];
       if(i%2!=0 && a[i]%2!=0)
       count++;
   
       
   }
   cout<<count;
   
    return 0;
}


Measured memory_bytes: 3620
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	N := nextInt()
	M := nextInt()
	A := make([]string, N)
	for i := 0; i < N; i++ {
		A[i] = nextString()
	}
	B := make([]string, M)
	for i := 0; i < M; i++ {
		B[i] = nextString()
	}
	ans := "No"

	for Ni := 0; Ni < N; Ni++ {
		for Nj := 0; Nj < N; Nj++ {
			if judge(Ni, Nj, N, M, A, B) {
				ans = "Yes"
				break
			}
			if ans == "Yes" {
				break
			}
		}
	}
	fmt.Println(ans)
}

func judge(Ni, Nj, N, M int, A, B []string) (result bool) {
	for i := 0; i < M; i++ {
		for j := 0; j < M; j++ {
			if Ni+i >= N || Nj+j >= N {
				return
			}
			if B[i][j] != A[Ni+i][Nj+j] {
				return
			}
		}
	}
	return true
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
mod=10**9+7

def calc(mat1,mat2):
  n=len(mat1)
  ret=[[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        ret[i][j]+=mat1[i][k]*mat2[k][j]
        ret[i][j]%=mod
  return ret

n,k=map(int,input().split())
tmp=[[0]*n for _ in range(n)]
for i in range(n):
  tmp[i][i]=1
matrix=[list(map(int,input().split())) for _ in range(n)]
for i in range(60):
  if k&(1<<i):
    tmp=calc(tmp,matrix)
  matrix=calc(matrix,matrix)  
ans=0
for i in range(n):
  for j in range(n):
    ans+=tmp[i][j]
    ans%=mod
print(ans)

Measured memory_bytes: 74376
#include<stdio.h>

int n,cont,flag=0;
int A[1000000];
int G[1000000];

void insertionSort(int *A,int n,int g){
  int v,j,i;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cont++;
    }
    A[j+g]=v;
  }
}

void shellSort(int *A,int n){
  int h,i;
  for(h=1; ; ){
    if(h>n) break;
    G[flag++]=h;
    h=3*h+1;
  }
  for(i=flag-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  cont=0;
  shellSort(A,n);
  printf("%d\n",flag);
  for(i=flag-1;i>=0;i--){
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cont);
  for(i=0;i<n;i++) printf("%d\n",A[i]);
  return 0;
}
  
  

Measured memory_bytes: 6372
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	string s1, s2, u;
	cin >> s1 >> s2;
	ll n, m;
	cin >> n >> m;
	cin >> u;
	if (u == s1)
	{
		cout << n - 1 << " " << m << "\n";
	}
	else
		cout << n << " " << m - 1 << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int MAXN = 300005;
constexpr int MOD = 998244353;

int sum(int a, int b) {
    int c = a + b;
    if (c >= MOD)
        c -= MOD;
    return c;
}

int prod(int a, int b) {
    return 1LL * a * b % MOD;
}

int modpow(int base, int exp) {
    int res = 1;
    int cur = base;
    for (int p = 1; p <= exp; p <<= 1) {
        if (exp & p)
            res = prod(res, cur);
        cur = prod(cur, cur);
    }
    return res;
}

int fact[MAXN], tcaf[MAXN];
void gen_fact() {
    fact[0] = tcaf[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = prod(fact[i - 1], i);
    }
    tcaf[MAXN - 1] = modpow(fact[MAXN - 1], MOD - 2);
    for (int i = MAXN - 2; i >= 0; --i) {
        tcaf[i] = prod(tcaf[i + 1], i + 1);
    }
}

int choose(int n, int k) {
    if (k < 0 or k > n)
        return 0;
    return prod(fact[n], prod(tcaf[k], tcaf[n - k]));
}

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

    gen_fact();

    // ax + by = k
    // x <= n
    // y <= n
    int n, a, b;
    ll k;
    scanf(" %d %d %d %lld", &n, &a, &b, &k);
    int ans = 0;
    for (int x = 0; x <= n; ++x) {
        ll rem = k - 1LL * x * a;
        if (rem % b == 0) {
            ll y = rem / b;
            if (0 <= y and y <= n)
                ans = sum(ans, prod(choose(n, x), choose(n, y)));
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 2560
n, a, b, c, d = map(int, input().split())
s = input()

if '##' in s[a-1:c] or '##' in s[b-1:d]:
    print('No')
else:
    if d<c and '...' not in s[b-2:d+1]:
        print('No')
    else:
        print('Yes')



Measured memory_bytes: 9352
#include<iostream>

using namespace std;

bool iswinner(char b[3][4],char c)
{
	int cnt=0;
	for(int i=0;i<3;i++){
		cnt=0;
		for(int j=0;j<3;j++)	if(b[i][j]==c)	cnt++;
		if(cnt==3)	return true;

		cnt=0;
		for(int j=0;j<3;j++)	if(b[j][i]==c)	cnt++;
		if(cnt==3)	return true;
	}

	cnt=0;
	for(int i=0;i<3;i++)	if(b[i][i]==c)		cnt++;
	if(cnt==3)	return true;

	cnt=0;
	for(int i=0;i<3;i++)	if(b[2-i][i]==c)	cnt++;
	if(cnt==3)	return true;

	return false;
}

int main()
{
	for(char board[3][4];cin>>board[0],board[0][0]-'0';){
		for(int i=1;i<3;i++)	cin>>board[i];
		if     (iswinner(board,'b'))	cout<<'b'<<endl;
		else if(iswinner(board,'w'))	cout<<'w'<<endl;
		else	cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
N=int(input())
A=list(map(int,input().split()))
dp=[[0]*2 for i in range(N+1)]
dp[0][1]=-10**30
for i in range(N):
    dp[i+1][0]=max(dp[i][0]+A[i],dp[i][1]-A[i])
    dp[i+1][1]=max(dp[i][1]+A[i],dp[i][0]-A[i])
print(dp[N][0])

Measured memory_bytes: 99164
import math, heapq
from operator import itemgetter
from collections import defaultdict
INF = float("inf")
MOD = int(1e9 + 7)

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

    AB = defaultdict(list)
    for _ in range(N):
        a, b = map(int, input().split())
        AB[a].append(b)

    v, que = 0, []
    for m in range(1, M + 1):
        if m in AB:
            for b in AB[m]:
                heapq.heappush(que, -b)
        if que:
            v += -heapq.heappop(que)
    print(v)

main()


Measured memory_bytes: 27640
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int dp[100001];

signed main(void) {
	int N,W;
	cin >> N>>W;
	vector<int>w(N),v(N);
	rep(i, N) {
		cin >> w[i]>>v[i];
	}
	rep(i, 100002) {
		dp[i] = INF;
	}

	dp[0] = 0;
	rep(i, N) {
		rrep(j, 100002) {
			if (j >= v[i]) 
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	rrep(i, 100002) {
		if (dp[i] <= W) {
			print(i);
			break;
		}
	}
}

Measured memory_bytes: 1152