akhauriyash/Code-Regression huggingface dataset:
import itertools

N = int(input())
P = input().replace(" ","")
Q = input().replace(" ","")

from collections import deque
q = deque()
for i in range(1, N + 1):
  q.append(str(i))

a = -1
b = -1
cnt = 0
while q:
  cnt += 1
  st = q.popleft()
  if len(st) == N:
    if st == P:
      a = cnt
    if st == Q:
      b = cnt
    continue
  for i in range(1, N + 1):
    if str(i) not in st:
      q.append(st + str(i))

print(abs(a - b))

Measured memory_bytes: 11964
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    d, g = LI()
    pc = LIR(d)
    ans = float("INF")
    tokumono = list(itertools.product((0, 1), repeat=d))
    #print(tokumono)
    for toku in tokumono:
        #print(toku)
        ansa = 0
        ansb = 0
        for i in range(len(toku)):
            if toku[i] == 1:
                ansa += pc[i][0]
                ansb += pc[i][0] * (i + 1) * 100 + pc[i][1]
        for k in range(len(toku) - 1, -1, -1):
            if toku[k] == 0:
                for i in range(pc[k][0] + 1):
                    #print(ans, ansb, ansa)
                    if i == pc[k][0]:
                        ansb += pc[k][1]
                    if ansb >= g:
                        ans = min(ans, ansa)
                        break
                    ansa += 1
                    ansb += (k+1) * 100
                break

        

    print(ans)
            

    return

#D
def D():
    N, X = LI()
    def dfs(n, x):
        #print(n, x)
        if x == 1 and n > 0:
            return 0 
        elif x < 2 ** (n + 1) - 1:
            return dfs(n - 1, x - 1)
        elif x == 2 ** (n + 1) - 1:
            return 2 ** n 
        elif x == 2 ** (n + 2) - 3:
            return 2 ** (n + 1) - 1
        else:
            return dfs(n - 1, x - 2 ** (n + 1) + 1) + 2 ** n 
    a = dfs(N, X)
    print(a)
        
    return


#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

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

  double ans = r * 2 * M_PI;

  cout << ans << endl;
}



Measured memory_bytes: 3788
input_data = input().split()
n = int(input_data[0])
m = int(input_data[1])

if n == 1 or m == 1:
    if n == 1 and m != 1:
        print(m-2)
    elif m == 1 and n != 1:
        print(n-2)
    elif n == 1 and m==1:
        print(1)

if n>=2 and m>=2:
    print(n*m-(2*n+2*(m-2)))

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

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

int n,x,arr[101],cnt=1;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n>>x;
    rep(i,1,n)
        cin>>arr[i];
    rep(i,2,n)
        arr[i]+=arr[i-1];
    rep(i,1,n)
        if(arr[i]<=x)
            cnt++;
    cout<<cnt;
}


Measured memory_bytes: 256
/******************************************************************************

                            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 <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a, &b);
    if(a+b < 10) printf("%d\n", a+b);
    else printf("error\n");
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<P> p;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        p.push_back(P(b,a));
    }
    ll t = 0;;
    sort(p.begin(), p.end());

    rep(i,n) {
        P tmp = p[i];
        t += tmp.second;
        if(t > tmp.first) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const int NMAX = 3100;
int dp[NMAX][NMAX] = {};

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

    string s, t; cin >> s >> t;

    for(int i=0; i<(int)s.size(); ++i){
        for(int j=0; j<(int)t.size(); ++j){
            if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }

    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while(0<i && 0<j){
        if(s[i-1] == t[j-1]){
            res += s[i-1];
            --i; --j;
        }
        else if(dp[i][j] == dp[i-1][j]) --i;
        else --j;
        // if (dp[i][j] == dp[i-1][j]) {
        //     --i; // DP の遷移を遡る
        // }

        // // (i, j-1) -> (i, j) と更新されていた場合
        // else if (dp[i][j] == dp[i][j-1]) {
        //     --j; // DP の遷移を遡る
        // }

        // // (i-1, j-1) -> (i, j) と更新されていた場合
        // else {
        //     res += s[i-1];; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
        //     --i, --j; // DP の遷移を遡る
        // }
    }

    reverse(res.begin(), res.end());
    cout << res << endl;

	return 0;
}


Measured memory_bytes: 37120
def divisor(x):
    table = []
    i = 1
    while i * i <= x:
        if x%i == 0:
            table.append(i)
            table.append(n//i)
        
        i +=1
        
    table.sort()
    return table 
    
n = int(input())

l = divisor(n)
c = len(l)

ans = 100100100100100
for i in range(c):
    x = l[i] - 1
    y = l[c-i-1] - 1
    tot = x + y
    ans = min(ans,tot)
    
print(ans)

Measured memory_bytes: 9372
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
        double r;
        double area, circum;

        cin >> r;

        area = M_PI * r * r;
        circum = 2.0f * M_PI * r;

        printf("%f %f\n", area, circum);

        return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A1(N), A2(N);
  for (int i = 0; i < N; i++) cin >> A1.at(i);
  for (int i = 0; i < N; i++) cin >> A2.at(i);
  vector<int> S1(N), S2(N);
  S1.at(0) = A1.at(0);
  for (int i = 1; i < N; i++) S1.at(i) = S1.at(i-1) + A1.at(i);
  S2.at(N-1) = A2.at(N-1);
  for (int i = N-2; i >= 0; i--) S2.at(i) = S2.at(i+1) + A2.at(i);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, S1.at(i) + S2.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  int N;cin>>N;
  vint a(N);
  int sum=0;
  repeat(i,N){
    cin>>a[i];
    sum += a[i];
  }
  ll dif=INF;
  ll ans=0;
  repeat(i,N){
    if(dif>abs(sum-a[i]*N)){
      dif=abs(sum-a[i]*N);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int MOD = 1000000007;

int N, M;
vector<bool> check;

int main() {
  cin >> N >> M;
  check.assign(N + 1, true);
  for (int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    check[a] = false;
  }

  vector<int> dp(N + 1, 0);
  
  dp[0] = 1;
  if (check[1]) dp[1] = 1;
  for (int n = 2; n <= N; ++n) {
    if (check[n - 1]) dp[n] += dp[n - 1];
    if (check[n - 2]) dp[n] += dp[n - 2];
    dp[n] %= MOD;
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
// int inverse_mod(int x){
//     return power(x,mod-2);
// }

int const N = 105;
int const inf = 1e10;
int a[N][N];

void solve(){
    int i,j,l;
    int n,m,k;
    string s;
    cin>>s;
    n = s.size();
    int ans = 0;
    for(i=0;i<n/2;i++){
        if(s[i] != s[n-1-i]) ans++;
    }
    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    int t;
    t = 1;
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

0111110000000
1000010000000

01101101
10010101


*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define MAX_S 200000
using namespace std;
int main(void)
{
    char str[MAX_S];
    while(scanf("%s",str)==1)
    {
        int len=strlen(str);
        bool ok=false;
        int beg,end;
        for(int i=0;i<len;i++)
        {
            if(str[i]=='A'&&!ok)
            {
                beg=i;
                ok=true;
            }
            if(str[i]=='Z')
            end=i;
       }
        cout<<end-beg+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include "iostream"
using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[100001];
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		a[i] = a[i - 1] + 1;
		if (i - 6 >= 0) {
			if (a[i] > a[i - 6] + 1)
				a[i] = a[i - 6] + 1;
		}
		if (i - 36 >= 0) {
			if (a[i] > a[i - 36] + 1)
				a[i] = a[i - 36] + 1;
		}
		if (i - 216 >= 0) {
			if (a[i] > a[i - 216] + 1)
				a[i] = a[i - 216] + 1;
		}
		if (i - 1296 >= 0) {
			if (a[i] > a[i - 1296] + 1)
				a[i] = a[i - 1296] + 1;
		}
		if (i - 7776 >= 0) {
			if (a[i] > a[i - 7776] + 1)
				a[i] = a[i - 7776] + 1;
		}
		if (i - 46656 >= 0) {
			if (a[i] > a[i - 46656] + 1)
				a[i] = a[i - 46656] + 1;
		}
		if (i - 9 >= 0) {
			if (a[i] > a[i - 9] + 1)
				a[i] = a[i - 9] + 1;
		}
		if (i - 81 >= 0) {
			if (a[i] > a[i - 81] + 1)
				a[i] = a[i - 81] + 1;
		}
		if (i - 729 >= 0) {
			if (a[i] > a[i - 729] + 1)
				a[i] = a[i - 729] + 1;
		}
		if (i - 6561 >= 0) {
			if (a[i] > a[i - 6561] + 1)
				a[i] = a[i - 6561] + 1;
		}
		if (i - 59049 >= 0) {
			if (a[i] > a[i - 59049] + 1)
				a[i] = a[i - 59049] + 1;
		}
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
h=list(map(int,input().split()))
a=[[int(i) for i in input().split()] for l in range(m)]

l=[True]*n

for x in a:
    if h[x[0]-1]>=h[x[1]-1]:l[x[1]-1]=False
    if h[x[0]-1]<=h[x[1]-1]:l[x[0]-1]=False

cnt=0
for y in l:
    if y:cnt+=1
print(cnt)


Measured memory_bytes: 30424
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)

#define mp make_pair
#define fi first
#define se second

#define bit(n) (1LL<<(n))

i64 gcm(i64 a, i64 b){
  i64 c;
  while(a != 0){
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}

i64 N,M,A[10000010];

void Main()
{
  cin >> N >> M;
  rep(i,N) cin >> A[i];

  i64 lcm = A[0];
  rep(i,1,N){
    lcm = lcm * A[i] / gcm(lcm,A[i]);
    if(lcm/2 > M){
      cout << 0 << "\n";
      return;
    }
  }

  i64 count_zero = 0;
  while((lcm>>count_zero)%2==0){
    count_zero++;
  }

  rep(i,N){
    if(A[i]%bit(count_zero)!=0){
      cout << 0 << "\n";
      return;
    }
    if((A[i]>>count_zero)%2==0){
      cout << 0 << "\n";
      return;
    }
  }

  i64 ans = M/(lcm/2);
  if(ans%2==0) ans -= 1;
  ans -= ans/2;
  cout << ans << "\n";
}

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


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

using namespace std;

int jav = 1, n;
string s, a;

int main()
{
	cin >> s;
	n = s.size();
	a = s[0];
	
	for (int i = 1; i < n; i ++)
	{
		string c;
		c = s[i];
		if (a == c)
		{
			if(i < n - 1)
			{
				a = s[i];
				a += s[i + 1];
				jav += 1;
				i += 1;
			}
		}	
		else
		{
			a = s[i];
			jav += 1;
		}
	}
	cout << jav << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // ver2.1.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int mypow(int x, int n, int m){  //  高速累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,g;
  cin >> n >> g;
  int nowi,ans=INF,roop = mypow(2,n,INF);
  Vi a(n),qu(n),bo(n),comp(n);
  rep(i,0,n){
    cin >> qu[i] >> bo[i];
    comp[i] = bo[i] + qu[i]*((i+1)*100);
  }
  //Vout(comp);
  
  int nowp,max0,nowct,nkr;
  
  rep(i,0,roop){
    nowct = 0;
    nowi = i;
    max0 = -1;
    nowp = 0;
    
    rep(j,0,n){
      a[j] = nowi%2;
      nowi /= 2;
      if(a[j]==0) max0 = j;
    }
    
    //Vout(a);
    rep(i,0,n){
      if(a[i]==1) {
        nowp += comp[i];
        nowct += qu[i];
      }
    }
    
    //cout << nowp <<' '<<nowct<< endl;
    if(nowp >= g) {
      ans = min(ans,nowct);
      //cout <<'!'<< nowct << endl;
      continue;
    }
    
    nkr = g - nowp;
    
    //  dem(nkr,((max0+1)*100))　解く必要のある問題数
    if(qu[max0]-1 < dem(nkr,((max0+1)*100))) continue;
    
    nowct += dem(nkr,((max0+1)*100));
    ans = min(ans,nowct);
    //cout << '&'<< nowct << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
x = I()
ans = 0
if x >= 11:
    el = x//11
    ans += el * 2
    x -= 11 * el
if 0 < x <= 6:
    ans += 1
elif 6 < x < 11:
    ans += 2
print(ans)


Measured memory_bytes: 10380
N = int(input())
A =  list(map(int, input().split())) 

r_exists = True
s_count = 0

while r_exists == True:

    r_exists = False

    i = N - 1

    while i >= 1:

        if A[i] < A[i - 1]:
            
            A[i], A[i - 1] = A[i - 1], A[i]

            s_count += 1

            r_exists = True
        
        i -= 1

s = ''

for x in A:

    s = s + str(x) + ' '

print(s.rstrip())
print(s_count)



Measured memory_bytes: 5600
import fractions
from functools import reduce

b = input()
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
ans %= 1000000007

print(ans)

Measured memory_bytes: 6136
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n, d, x[11][11];
  cin >> n >> d;
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++){
      cin >> x[i][j];
    }
  }
  int ans=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      int norm=0;
      for(int k=0; k<d; k++){
        int diff=abs(x[i][k]-x[j][k]);
        norm+=diff*diff;
      }
      bool flag=false;
      for(int k=0; k<=norm; k++){
        if(k*k==norm){
          flag=true;
        }
      }
      if(flag){
        ans++;
      }
    }
  }
  cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
D = list(map(int, readline().split()))
Edge = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, readline().split())
    u -= 1
    v -= 1
    Edge[u].append((D[v], i, v))
    Edge[v].append((D[u], i, u))

inf = 10**9+7
table = [inf]*M

Col = [None]*N
def solve():
    Di = sorted([(D[i], i) for i in range(N)])
    for dvn, vn in Di:
        dvf, enum, vf = min(Edge[vn])
        if dvn < dvf:
            return False
        table[enum] = dvn
    
    used = set()
    for i in range(N):
        if i in used:
            continue
        Col[i] = 1
        stack = [i]
        while stack:
            vn = stack.pop()
            for _, enum, vf in Edge[vn]:
                if table[enum] == inf:
                    continue
                if vf in used:
                    continue
                Col[vf] = not Col[vn]
                used.add(vf)
                stack.append(vf)
    for i in range(M):
        if table[i] == inf:
            table[i] = 10**9
    return True

if not solve():
    print(-1)
else:
    print(''.join(['B' if Col[i] else 'W' for i in range(N)]))
    print('\n'.join(map(str, table)))


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

int main() {
    
    int N,a;
    cin >> N;
    a = 0;
    for (int i = 0; i < N;i++) {
        string s;
        cin >> s;
        if (s == "Y") {
            a++;
            break;
        }
        
    };

    if (a>0) {
        cout <<"Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[1401][1401]={},m,h,w,f,i,j;
main(){
	cin>>h>>w;
	m=0;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		cin>>f;
		if(!f){
			dp[i+1][j+1]=min(dp[i][j],min(dp[i+1][j],dp[i][j+1]))+1;
			m=max(m,dp[i+1][j+1]);}
	}
	cout<<m*m<<endl;
}


Measured memory_bytes: 9664
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
char s[500], t[500];

int main() {

    scanf("%d %s %s", &n, s, t);

    string u = s;
    string v = t;

    for (int i = 0; i <= v.size(); i++) {
        string t = u;
        t += v.substr(v.size() - i, v.size());
        if (t.substr(t.size() - n, t.size()) == v) {
            printf("%d\n", t.size());
            break;
        }
    }

    return 0;

}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  int ans=0;
  if(k <= a+b){
    cout << min(a, k) << endl;
  }else{
    cout << a - (k-a-b)<< endl;
  }

}



Measured memory_bytes: 3632
s = input()

a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
     'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]

b = [0] * 26

for i in range(len(s)):
    for j in range(26):
        if s[i] == a[j]:
            b[j] +=1

jug = True

for i in range(26):
    if b[i] == 0:
        print(a[i])
        jug = False
        break

if jug == True:
    print("None")

Measured memory_bytes: 41580
package main

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

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

type segmentTree struct {
	data   []int
	offset int
}

func newSegmentTree(n int) segmentTree {
	var result segmentTree
	t := 1
	for t < n {
		t *= 2
	}
	result.offset = t - 1
	result.data = make([]int, 2*t-1)
	return result
}

func (st segmentTree) update(index, value int) {
	i := st.offset + index
	st.data[i] = value
	for i >= 1 {
		i = (i - 1) / 2
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) _query(start, stop, index, left, right int) int {
	if right <= start || stop <= left {
		return 0
	}
	if start <= left && right <= stop {
		return st.data[index]
	}
	a := st._query(start, stop, index*2+1, left, (left+right)/2)
	b := st._query(start, stop, index*2+2, (left+right)/2, right)
	return gcd(a, b)
}

func (st segmentTree) query(start, stop int) int {
	//return st._query(start, stop, 0, 0, st.offset+1)
	result := 0
	q := make([][3]int, 1)
	q = append(q, [3]int{0, 0, st.offset + 1})
	for len(q) != 0 {
		index := q[0][0]
		left := q[0][1]
		right := q[0][2]
		q = q[1:]
		if right <= start || stop <= left {
			continue
		}
		if start <= left && right <= stop {
			result = gcd(result, st.data[index])
			continue
		}
		q = append(q, [3]int{index*2 + 1, left, (left + right) / 2})
		q = append(q, [3]int{index*2 + 2, (left + right) / 2, right})
	}
	return result
}

func main() {
	N := readInt()
	A := readInts(N)

	st := newSegmentTree(N)
	for i, v := range A {
		st.update(i, v)
	}

	result := st.query(1, N)
	for i := 1; i < N-1; i++ {
		result = max(result, gcd(st.query(0, i), st.query(i+1, N)))
	}
	result = max(result, st.query(0, N-1))

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 13184
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize, usize); m],
    }
    let mut g = vec![vec![]; n + 1];
    for &(a, b) in e.iter() {
        g[a].push(b);
    }
    let mut ans = (n + 1, 0, 0); // 頂点数、始点、終点
    for i in 1..(n + 1) {
        let mut dp = vec![n + 2; n + 1];
        dp[i] = 0;
        let mut q = std::collections::VecDeque::new();
        q.push_back(i);
        while let Some(v) = q.pop_front() {
            for &u in g[v].iter() {
                if dp[u] > dp[v] + 1 {
                    dp[u] = dp[v] + 1;
                    q.push_back(u);
                }
            }
        }
        for j in 1..(n + 1) {
            for &u in g[j].iter() {
                if u == i {
                    ans = std::cmp::min(ans, (dp[j], i, j));
                }
            }
        }
    }
    if ans.0 > n {
        println!("-1");
        return;
    }
    let mut dp = vec![n + 2; n + 1];
    let (_, s, t) = ans;
    dp[s] = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(s);
    while let Some(v) = q.pop_front() {
        for &u in g[v].iter() {
            if dp[u] > dp[v] + 1 {
                dp[u] = dp[v] + 1;
                q.push_back(u);
            }
        }
    }
    let mut ig = vec![vec![]; n + 1];
    for &(a, b) in e.iter() {
        ig[b].push(a);
    }
    let mut ans = vec![];
    let mut now = t;
    while now != s {
        ans.push(now);
        for &u in ig[now].iter() {
            if dp[u] < dp[now] {
                now = u;
                break;
            }
        }
    }
    ans.push(s);
    println!("{}", ans.len());
    for a in ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

int main(){

    long long A, B;
    cin >> A >> B;

    long long M = max(A, B);
    long long m = min(A, B);

    long long ans;

    if(M == m){
        ans = M;
    }else{
        if (m != 0){
            m -= 1;
        }
        
        vector <int> V,v;

        V.push_back(((M + 1) / 2) % 2);
        v.push_back(((m + 1) / 2) % 2);

        for (int i = 1; pow(2, i) <= M; i++){
            long long j = pow(2, i + 1);
            long long a = M % j;

            if (a < j / 2){
                V.push_back(0);
            }else{
                long long b = (a - 1) % 2;
                V.push_back(b);
            }
            
            a = m % j;
            if (a < j / 2){
                v.push_back(0);
            }else{
                long long b = (a - 1) % 2;
                v.push_back(b);
            }            
        }

        for (int i = 0; i < v.size(); i++){
            if (V[i] == v[i]){
                V[i] = 0;
            }else{
                V[i] = 1;
            }
        }
        
        ans = 0;
        for (int i = 0; i < v.size(); i++){
            long long c = pow(2, i);
            ans += V[i] * c;
        }
    }
    
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[200000],y[200000];
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n){
		cin>>x[i];
		y[i]=x[i]-i-1;
	}
	sort(y,y+n);
	f(i,n){
		ans+=abs(x[i]-y[n/2]-i-1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;

int main() {
#ifdef PAUNSVOKNO
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int n, p;
    cin >> n >> p;
    ll ans = 1;
    for (int i = 1; i < n; i++) ans *= 2;
    bool w = false;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        w |= (x & 1);
    }
    if (w) cout << ans << endl;
    else if (p) cout << 0 << endl;
    else cout << ans * 2 << endl;
	return 0;
}

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


int main(){
	int n;
	if (scanf("%d", &n)==EOF){return 0;}
	if(n % 2 ==1){printf("No\n"); return 0;}
	char s[n+1];
	if (scanf("%s", s)==EOF ){return 0;}
	
	//char echo[n/2 + 1];
	//strncpy(echo, s, n/2 + 1);
	int yes = 1;
	for(int i = 0; i< n/2; i++){
		if(s[i] != s[n/2 + i]){yes = 0; break;}	
	}
	if(yes==1){printf("Yes\n");}else{printf("No\n");}
	return 0;

}

Measured memory_bytes: 1640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;

typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int, int>
#define Point Vect
#define no {cout << "No\n"; return;}

const int N = 2e5 + 7, INF = 1e9 + 7;

 void solve() {
    int n;
    cin >> n;
    vector <int> d, dn;
    for (int i = 1; i * i <= n; ++i) {
        if ((n - 1) % i == 0) {
            d.pb(i); d.pb((n - 1) / i);
        }
        if (n % i == 0) {
            dn.pb(i); dn.pb(n / i);
        }
    }
    for (int a : dn) {
        if (a == 1) continue;
        int x = n;
        while (x % a == 0)
            x /= a;
        if (x % a == 1)
            d.pb(a);
    }
    sort(all(d));
    d.resize(unique(all(d)) - d.begin());
    cout << d.size() - 1;
 }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 384
class Rect
	attr_accessor :h, :w, :len
	def initialize(h, w)
		@h = h
		@w = w
		@len = h * h + w * w
	end
end

rects = []

for i in 1..151
	for j in (i+1)..151
		rects << Rect.new(i, j)
	end
end

rects.sort!{|i,  j|
	if i.len == j.len
		i.h <=> j.h
	else
		i.len <=> j.len
	end
}

#for i in 0..20
#	puts "#{rects[i].h} #{rects[i].w} #{rects[i].len}"
#end

loop do
	h, w = gets.chomp.split.map(&:to_i)
	if h == 0 && w == 0
		break
	end
	ans = 0
	rects.each_with_index do |r, i|
		if r.h == h && r.w == w
			ans = i+1
		end
	end
	puts "#{rects[ans].h} #{rects[ans].w}"
end

Measured memory_bytes: 6388
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dis = []
for i in range(M):
  dis.append(list(map(int, input().split())))
  
total = []
total.append(min(a) + min(b))

for k in range(M):
  x = dis[k][0] - 1
  y = dis[k][1] - 1
  c = dis[k][2]
  discount = a[x] + b[y] - c
  total.append(discount)
  
  
print(min(total))

Measured memory_bytes: 42400
#include <stdio.h>
#include <string.h>
int main(){
  long cal=0;
  char s[100000];
  scanf("%s",&s);
  for (long i=0;i<strlen(s);i++){
    if (s[i]=='0'){
      cal++;
    }
    else {
      cal--;
    }
  }
  if (cal<0){
      cal+=strlen(s);
  }
  else{
      cal=strlen(s)-cal;
  }  
  printf("%ld\n",cal);
  return 0;
}

Measured memory_bytes: 256
//E
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool G[20][1010];
int pre[20][1010];
int main(){
	int h,w,k;
	cin >> h >> w >> k;
	for(int i = 1;i <= h;i++){
		string s;
		cin >> s;
		for(int j = 0;j < w;j++){
			G[i][j+1] = s[j]-'0';
			pre[i][j+1] = pre[i][j] + G[i][j+1];
		}
	}
	ll ans = 1e17+10;
	int M = (1<<(h-1));
	for(int d = 0;d < M;d++){
		auto bit = bitset<31>(d);
		ll lst = 0,tans = 0,bcnt = 0;
		for(int i = 0;i < 30;i++)if(bit[i])bcnt++;
		for(int j = 1;j <= w;j++){
			ll cnt = 0,tcnt = 0;
			for(int i = 1;i <= h;i++){
				tcnt += pre[i][j] - pre[i][lst];
				if(bit[i-1]){
					cnt = max(cnt,tcnt);
					tcnt = 0; 
				}
			}
			cnt = max(cnt,tcnt);
			if(cnt > k){
				tans++;
				if(j-1 == lst){
					tans = 1e9;break;
				}
				lst = j-1;
			}
		}
		ans = min(ans,tans+bcnt);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to count all possible 
// triangles with arr[] elements 
int findNumberOfTriangles(int arr[], int n) 
{ 
    // Count of triangles 
    int count = 0; 
  
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 

            for (int k = j + 1; k < n; k++) 

                if ( 
                    arr[i] + arr[j] > arr[k] 
                    && arr[i] + arr[k] > arr[j] 
                    && arr[k] + arr[j] > arr[i] &&(arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[i]!=arr[k])) 
                    count++; 
        } 
    } 
    return count; 
} 

int main() 
{ 
    int n, arr[105];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
    	scanf("%d", &arr[i]);
	}
	cout<<findNumberOfTriangles(arr, n)<<endl;
  
    return 0; 
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = LINF;
    ll x = 0;
    ll y = 0;
    rep(i, n) y += a[i];
    rep(i, n-1) {
        x += a[i];
        y -= a[i];
        ans = min(ans, abs(x-y));
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) begin(x), end(x)

constexpr ll mod = 1'000'000'007;
int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);

  int n; cin >> n;
  string s, t; cin >> s >> t;

  static ll sum[27];
  t[0] = 'z' + 1;
  sum[26] = 1;

  rep(i, n) {
    sum[t[i]-'a'] %= mod;
    if (i == n-1) cout << sum[t.back()-'a'] % mod << "\n";
    sum[s[i]-'a'] += sum[t[i]-'a'];
  }
}



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

typedef long long ll;

int main()
{
	ll a, b, c; cin >> a >> b >> c;
	int ans = 0;
	while (!((a|b|c)&1))
	{
		ll A = (b+c)>>1, B = (a+c)>>1, C = (a+b)>>1;
		if (A == a && B == b && C == c)
		{
			ans = -1;
			break;
		}
		a = A, b = B, c = C;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
def popcount(x):
    return bin(x).count('1')

def initialize(N):
    i=1
    while i<N:
        i*=2
    return [0]*(2*i-1),i

def update(i,x):
    i+=d-1
    bit=ord(x)-97
    SEG[i]=0 | (1<<bit)
    while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
        
def find(a,b,k,l,r):
    if r<=a or b<=l:
        return 0
    if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
        
N=int(input())
S=input()
Q=int(input())
SEG,d=initialize(N)
for i in range(N):
    update(i,S[i])
for i in range(Q):
    com,s,t=map(str,input().split())
    if(com=='1'):
        update(int(s)-1,t)
    else:
        print(popcount(find(int(s)-1,int(t),0,0,d)))

Measured memory_bytes: 94920
import sys
S = list(input())
if S == list(reversed(S)):
    if S[:int((len(S)-1)/2)] == list(reversed(S[:int((len(S)-1)/2)])):
        if S[int((len(S)-1)/2)+1:] == list(reversed(S[int((len(S)-1)/2)+1:])):     
            print('Yes')
            sys.exit()
print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll dp[51][2];

int main() {
	int n, p;
	cin >> n >> p;
	dp[0][0] = 1;
	REP(i,n){
		int a;
		cin >> a;
		a %= 2;
		REP(j,2){
			dp[i+1][j] += dp[i][j];
			dp[i+1][(j+a) % 2] += dp[i][j];
		}
	}
	cout << dp[n][p] << endl;
	return 0;
}

Measured memory_bytes: 256
def Bellmanford(n,edges,r):
    d = [float('inf')]*n
    d[r] = 0
    for i in range(n):
        for u,v,c in edges:
            if d[u] != float('inf') and d[u]+c < d[v]:
                d[v] = d[u]+c
                if i ==n-1 and v == n-1:
                    return 'inf'
    return -d[n-1]
n,m = map(int,input().split())
edges = [None]*m
for i in range(m):
    a,b,c = map(int,input().split())
    edges[i] = (a-1,b-1,-c)
ans = Bellmanford(n,edges,0)
print(ans)

Measured memory_bytes: 74988
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int A, B;	cin >> A >> B;
  int ans = max(A - 2 * B , 0);
  
  SCOUT(ans) << endl;
  

  return 0;
}

Measured memory_bytes: 256
#include"iostream"
#include"cstdio"
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>0)
	{
		cout<<"Positive";
		return 0;
	}		
	if(b<0)
	{
		if((b-a)%2==0)	
			cout<<"Negative";
		else
			cout<<"Positive";
		return 0;
	}
	cout<<"Zero";
	return 0;
}

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

int main(){
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;++i) cin>>v[i];
    sort(v.begin(),v.end());
    double ans = (double)(v[0]+v[1])/2;
    for(int i=2;i<n;++i) ans=(ans+v[i])/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long n, i, x, min, max, total;
	scanf("%ld", &n);
	scanf("%ld", &x);
	min=x;
	max=x;
	total=x;
	for (i=2; i<=n; i++)
	{
		scanf("%ld", &x);
		if (min>x) {
			min=x;
		}
		if (max<x) {
			max=x;
		}
		total=total+x;
	}
	printf("%ld %ld %ld\n", min, max, total);
	return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int r;
    in(r);
    out(r * r);
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main(){
  int n, i, j, A[N];
  int swap, count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
 
  for(i=0;i<n-1;i++)
    for(j=n-1;j>i;j--)
      if(A[j]<A[j-1]){
	swap = A[j];
	A[j] = A[j-1];
	A[j-1] = swap;
	count++;
      }

  printf("%d",A[0]);
  for(i=1;i<n;i++)
    printf(" %d",A[i]);

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

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n,m;
	std::cin >> n >> m;
	std::vector<uint32> a(m), b(m), c(n, 0);
	for (uint32 i = 0;i < m;++i) {
		std::cin >> a[i] >> b[i];
		++c[a[i] - 1];
		++c[b[i] - 1];
	}
	for (uint32 i = 0;i < n;++i) {
		if (c[i] & 1) {
			std::cout << "NO\n";
			return 0;
		}
	}
	std::cout << "YES\n";
	return 0;
}

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

static const int Max = 100;

int selectionSort(int* A, int N) {
	int times = 0;
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j) {
			if (A[j] < A[minj]) {
				minj = j;	
			}
			
		}
		int v = A[i];
		A[i] = A[minj];
		A[minj] = v;
		if (i != minj) {
		++times;
			}
	}

	return times;
}

void show(int* A, int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) {
			cout << ' ';
		}
		cout << A[i];
	}
	cout << endl;
}

int main() {
	int N;
	int A[Max];

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	int times = selectionSort(A, N);
    
	show(A, N);
	cout << times << endl;

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;

int N;
vector<int> Edge[MAX_N];

int dp[MAX_N][2];

int solve(int pos, int color, int pre = -1)
{
  if(dp[pos][color] != -1) {
    return dp[pos][color];
  }

  int ret = 1;

  for(int next : Edge[pos]) {
    if(next == pre) {
      continue;
    }

    int tmp = solve(next, 0, pos);
    if(color != 1) {
      tmp += solve(next, 1, pos);
    }
    tmp %= MOD;

    ret *= tmp;
    ret %= MOD;
  }
  // cerr << pos << " " << color << " " << ret << endl;
  return dp[pos][color] = ret;
}

signed main()
{
  cin >> N;
  REP(n,N-1) {
    int a,b; cin >> a >> b; a--; b--;
    Edge[a].emplace_back(b);
    Edge[b].emplace_back(a);
  }

  memset(dp, -1, sizeof(dp));
  cout << (solve(0,0) + solve(0,1)) % MOD << endl;

  return 0;
}

Measured memory_bytes: 14208