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

typedef vector<pair<char, char>> VPII;
typedef pair<char, pair<pair<char, char>, VPII>> PIPPIIVPII;

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

void solve( int W, int H ) {
	VPII M;
	pair<char, char>start, goal;
	for( size_t i = 1; i <= H; i++ ) {
		for( size_t j = 1; j <= W; j++ ) {
			int x;
			cin >> x;
			if( x == 1 ) {
				M.push_back( make_pair( i, j ) );
			} else if( x == 2 ) {
				start = make_pair( i, j );
			} else if( x == 3 ) {
				goal = make_pair( i, j );
			}
		}
	}
	queue<PIPPIIVPII>que;
	que.push( make_pair( 0, make_pair( start, M ) ) );
	while( que.size() ) {
		PIPPIIVPII now = que.front(); que.pop();
		pair<char, char>nowplace = now.second.first;
		if( now.first < 10 ) {
			for( size_t i = 0; i < 4; i++ ) {
				auto nextplace = nowplace;
				auto nextP = now.second.second;
				bool f = false;
				while( true ) {
					nextplace.first += dx[i];
					nextplace.second += dy[i];
					if( nextplace.first == 0 || nextplace.first == H + 1 || nextplace.second == 0 || nextplace.second == W + 1 ) {
						f = true;
						break;
					}
					if( nextplace == goal ) {
						cout << ( int )now.first + 1 << endl;
						return;
					}
					bool g = false;
					for( auto ite = nextP.begin(); ite < nextP.end(); ite++ ) {
						if( *ite == nextplace ) {
							nextplace.first -= dx[i];
							nextplace.second -= dy[i];
							if( nowplace != nextplace ) {
								nextP.erase( ite );
								que.push( make_pair( now.first + 1, make_pair( nextplace, nextP ) ) );
							}
							g = true;
							break;
						}
					}
					if( g ) {
						break;
					}
				}
			}
		} else {
			break;
		}
	}
	cout << -1 << endl;
	return;
}

int main() {
	int W, H;
	while( cin >> W >> H, W || H ) {
		solve( W, H );
	}
}

Measured memory_bytes: 23680
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    multiset<int> as;
    int diam = 0;
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      diam = max(diam, a);
      as.insert(a);
    }
    bool res = true;
    for (int i = 0; i <= diam; i++) {
      int v = max(i, diam - i);
      auto it = as.find(v);
      if (it == as.end()) {
        res = false;
        break;
      }
      as.erase(it);
    }
    res &= all_of(as.begin(), as.end(),
                  [&](int v) { return v >= (diam + 1) / 2 + 1; });
    cout << (res ? "Possible" : "Impossible") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

		String str = sc.next();
		char[] n = str.toCharArray();

		for(int i=n.length-1; i>=0; i--){
			System.out.print(n[i]);
		}
		System.out.println();

	}

}

Measured memory_bytes: 15288
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	string s,t;
	cin>>s>>t;
	int a,b;cin>>a>>b;
	string u;
	cin>>u;
	if(u==s) cout<<a-1<<" "<<b<<endl;
	else cout<<a<<" "<<b-1<<endl;

}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int[] natu = ReadLine().Split(' ').Select(int.Parse).ToArray();
         int[] homework = ReadLine().Split(' ').Select(int.Parse).ToArray();

         if(natu[0] >= homework.Sum()) WriteLine(natu[0] - homework.Sum());
         else WriteLine(-1);
      }
   }
}

Measured memory_bytes: 29364
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    if A[0]!=0:
        print(-1)
        sys.exit()
    dp=[0]*n
    for i,a in enumerate(A[1:],1):
        if a>=A[i-1]+2:
            print(-1) 
            sys.exit()
        elif a==A[i-1]+1:
            dp[i]=1
        else:
            dp[i]=a
    print(sum(dp))

if __name__=='__main__':
    main()

Measured memory_bytes: 14120
#158
A, B = map(int,input().split())
if(12.5*A-10*(B+1)>=0 or 10*B-12.5*(A+1)>=0):
    print(-1)
else:
    if(A*100 % 8 == 0):
        print(max([10*B,A*100//8]))
    else:
        print(max([10*B,A*100//8+1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    char a;
    cin>>a;
    a++;
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
using ld=long double;
int32_t main()
{
	ld ans=0;
	int n=in();ld btc=380000.0 ;
	string s;ld mon;
	while(n--)
	{
		cin>>mon>>s;
		if(s=="BTC")ans+=mon*btc;
		else ans+=mon;
	}
	cout<<fixed<<setprecision(12)<<ans;
	
}

Measured memory_bytes: 3780
def d_no_need(N, K, A):
    from bisect import bisect_left
    # 値がK以上の要素は単体で不必要でない要素になれる
    A.sort()
    a_sorted = A[:bisect_left(A, K)]
    ans = len(a_sorted)  # a_sortedの要素は不必要となりうる

    dp = [False] * K  # dp[k]:a_sortedの一部の和を取った値をKにできるか？
    dp[0] = True
    current_max = 0
    for idx, a in reversed(list(enumerate(a_sorted))):
        if current_max + a >= K:
            ans = idx

        first_update = True
        for j in range(min(current_max, K - a - 1), -1, -1):
            if dp[j]:
                dp[j + a] = True
                if first_update:
                    current_max = max(current_max, j + a)
                    first_update = False
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_no_need(N, K, A))

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<string> p(n),q(n);
    string P,Q;
    for(int i=0;i<n;i++){
        cin>>p[i];
        P+=p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
        Q+=q[i];
    }
    string array[]={"1","2","3","4","5","6","7","8"};
    string per[100000];
    int j=0;
    int itr_p=0,itr_q=0;
    do{
        for(int i=0;i<n;i++){
            per[j]+=array[i];
        }
        if(per[j]<P){
            itr_p++;
        }
        if(per[j]<Q){
            itr_q++;
        }
        j++;
    }while(next_permutation(array,array+n));
    cout<<abs(itr_p-itr_q)<<endl;
}

Measured memory_bytes: 2944
N=int(input())
A=list(map(int,input().split()))
sum=[0]*(N+1)
for i in range(N):
        sum[i+1]=sum[i]+A[i]
sum.sort()
k=0
ans=0
for i in range(N):
        if sum[i]==sum[i+1]:k+=1
        else:k=0
        ans+=k
print(ans)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

vector<vector<ll>> dp(110,vector<ll>(10010,0));
vary(ll,v,110,0);
vary(ll,w,10010,0);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,W;
  cin >> N >> W;
  rep(i,N){
    cin >> v[i] >> w[i];
  }
  REP(i,0,N){
    REP(j,0,W+1){
      if(j-w[i]>= 0){
        dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]] + v[i]);
      }
      else
        dp[i+1][j] = dp[i][j];
    }
  }
//   rep(i,N+1){
//     rep(j,W+1){
//       cout << dp[i][j]<< " ";
//     }
//     cout << endl;
//   }
  cout << dp[N][W]<<endl;
  return 0;
}

Measured memory_bytes: 11964
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
#define bolt ios::sync_with_stdio(false)
#define ull unsigned long long
#define ll long long
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
using namespace std;

int main() {

/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
#endif*/

	bolt;
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll a, b, c; cin >> a >> b >> c;
	ll val = (c - (a + b));
	if (val < 0) {
		cout << "No" << endl;
		return 0;
	} 
	ll z = val * val;
	ll y = 4 * a * b;
	if (z > y) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	

	return 0;
}

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

using namespace std;
typedef long long LL;

const int MX=200005,md=1000000007;
int n,f,a,b,c,s[MX],stk[MX],stc,w[MX],vis[MX];
int ans=1,res;
struct edge{int t,nxt,w;}e[MX<<1];int hed[MX],ec;
void ade(int x,int t,int w){e[++ec]=(edge){t,hed[x],w},hed[x]=ec;}
#define FE(i,k) for(int i=hed[k];i;i=e[i].nxt)
#define v e[i].t
inline int pw(int x,int y){
	int a=1;
	while(y){
		if(y&1)a=(LL)a*x%md;
		x=(LL)x*x%md,y>>=1;
	}
	return a;	
}
#define inv(x) pw(x,md-2)
void dfs1(int k, int fa){
	vis[k]=2,stk[++stc]=k;
	FE(i,k)if(v!=fa){
		if(vis[v]==2){
			a=k,b=v,c=e[i].w;
			int t=stc;
			do{
				--t;
				if(w[t]>c)a=stk[t],b=stk[t+1],c=w[t];
			}while(stk[t]!=v);
			++f;
		}else if(!vis[v])w[stc]=e[i].w,dfs1(v,k);
	}
	vis[k]=1,--stc;
}
void dfs2(int k,int fa,int w) {
	s[k]=1;
	FE(i,k)if(v!=fa&&v!=a&&(k!=a||v!=b)){
		dfs2(v,k,e[i].w);
		if(e[i].w<w)s[k]+=s[v];
	}
	res=(LL)res*inv(s[k])%md;
}
int main(){
	int i,x,y,k;
	cin>>n;
	for(i=1;i<=n*2;i++)cin>>x>>y,ade(x,y+n,x+y),ade(y+n,x,x+y);
	n<<=1;
	for(i=1;i<=n;i++)ans=(LL)ans*i%md;
	for(i=1;i<=n;i++)if(!vis[i]){
		f=0,dfs1(i,0);
		if(f!=1){ans=0;break;}
		res=1,dfs2(a,0,c);
		k=res;
		swap(a,b);
		res=1,dfs2(a,0,c);
		ans=(LL)ans*(k+res)%md;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13184
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int main(){
	int N,K;

	int tank[100];
	while(~scanf("%d %d",&N,&K)){
		if(N==K && K==0) break;
		for(int i=0;i<K;i++){
			scanf("%d",tank+i);
		}

		bool isok = true;
		for(int i=0;i<N;i++){
			for(int j=0;j<K;j++){
				int B;
				scanf("%d",&B);
				tank[j]-=B;
				if(tank[j]<0) isok = false;
			}
		}

		printf("%s\n",isok ? "Yes" : "No");
	}
}

Measured memory_bytes: 848
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll n,ans=0;

    
    cin >> n;

    vector<ll> c(n,0);

    ll rc=0,wc=0;
    for(ll i=0; i<n; i++){
        char ch;
        cin >> ch;
        c[i] = (ch == 'R');
        if(c[i]){
            rc++;
        }else
        {
            wc++;
        }
            
    }

    ll l=0, r=n-1;
    while(l<r){
        while(l<n&&l<=r){
            if(c[l] == 0) break;
            l++;
            
            print("*",l,r);
        }
        while(r>0&&l<=r){
            if(c[r] == 1) break;
            r--;
        }
        if(l<r){
            swap(c[l],c[r]);
            print(l,r);
            ans++;
        }
        l++;r--;
    }
    print(c);
    
    cout << ans << endl;
 
    return 0;
}



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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	ll mi = INF;
	ll ma = -INF;
	ll su = 0;
	rep(i, n) {
		ll a; cin >> a;
		su += a;
		mi = min(mi, a);
		ma = max(ma, a);
	}
	cout << mi << " " << ma << " " << su << endl;
}


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

int main() {
    string s;
  	cin >> s;
    int counter = 0;
    if (s[0] == s[1] && s[1] == s[2] ) cout << "Yes" << endl; 
    else if (s[1] == s[2] && s[2] == s[3] ) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();

		int[] a = new int[n];
		Pair[] pairs = new Pair[n];
		
		for(int i = 0;i < n;i++){
			Pair pair = new Pair();
			pair.from = sc.nextInt();
			pair.end = i+1;
			pairs[i] = pair;
		}
		Arrays.sort(pairs);
		
		for(int i= 0;i < n;i++){
			Pair pair = pairs[i];
			System.out.print(pair.end + " ");
		}
		

		
		
	}




	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
//		if(min == data.length-1){
//			if(data[min] > k){
//				return min;
//			}
//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int a;
  cin>>a;
  for(int i=0;i<10000;i++){
    if(IsPrime(a+i)==true){
      cout<<a+i<<endl;
      return 0;
    }
  }
}

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

joutai = "nasi"
m = 1000
k = 0

for i in range(n-1):
    if joutai == "nasi":
        if a[i] < a[i+1]:
            k = m // a[i]
            m -= k * a[i]
            joutai = "ari"
    else:
        if a[i] > a[i+1]:
            m += k * a[i]
            k = 0
            joutai = "nasi"

m += k * a[n-1]

print(m)

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

int main() {
  int i, j, k, c[3][3], a[3], b[3];
  
  rep(i,3){
    rep(j,3){
      cin >> c[i][j];
    }
  }
  
  rep(i,3) b[i]=c[0][i];
  rep(i,3) a[i]=c[i][0]-b[0];
  
  rep(i,2){
    rep(j,2){
      if(c[i+1][j+1]!=a[i+1]+b[j+1]){
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////

void solve()
{
    
    string s;
    cin>>s;

    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
    {
        cout<<"Yes"; 
    }
    else{
        cout<<"No";
    }


    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int a,b,c;
	char s,t;
	int count1=0,count2=0;
	while(true){
		cin>>a>>s>>b>>t>>c;
		if (cin.eof())break;
		if(c*c==a*a+b*b) count1++;
		if(a==b) count2++;
	}
	cout<<count1<<endl;
	cout<<count2<<endl; 
}

Measured memory_bytes: 2980
INF = 10**8
N = gets.to_i

arr = gets.split.map(&:to_i)
# p arr
dp = Array.new(N, INF)
dp[0] = 0
1.upto(N-1) do |i|
  if i-2 >= 0
    dp[i] = [dp[i-2] + (arr[i-2] - arr[i]).abs, dp[i-1] + (arr[i-1] - arr[i]).abs].min
  elsif i-1 >= 0
    dp[i] = dp[i-1] + (arr[i-1] - arr[i]).abs
  else
    puts "error!!"
  end
end
puts dp[N-1]

Measured memory_bytes: 11404
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    
    vl A(N); REP(i, N) cin >> A[i];
    map<ll, ll> cb;
    REP(i, N) cb[A[i]]++;
    REP(i, M){
        ll b, c; cin >> b >> c;
        if(cb.count(c) == 0){
            A.pb(c);
        }
        cb[c] += b;
    }
    sort(A.begin(), A.end(), greater<ll>());
    A = uniquen(A);
    
    ll ans = 0; ll idx = 0;
    while(N > 0){
        ll rem = min(N, cb[A[idx]]);
        ans += rem*A[idx];
        N -= rem;
        idx++;
        
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n,d;
    cin >> n >> d;
    int num;
    if(n%(d*2+1) == 0){
        num = n/(d*2+1);
    }else{
        num = n/(d*2+1) + 1;
    }
    cout << num << endl;
}



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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,m,l;
int p[110],t[110],v[110];

double rt[110][55];
double rp[110][55];

double com[55][55];
double ans[110];

void init(){
	rep(i,55)rep(j,i+1){
		if(j==0||j==i)
			com[i][j]=1.0;
		else
			com[i][j]=com[i-1][j]+com[i-1][j-1];
	}
}

int main(void){
	init();
	cin >> n >> m >> l;
	rep(i,n) cin >> p[i] >> t[i] >> v[i];
	rep(i,n)rep(j,m+1){
		rt[i][j]=1.0*l/v[i]+1.0*j*t[i];
		rp[i][j]=com[m][j]*pow(1.0*p[i]/100.0,j)*pow( (100.0-p[i])/100.0,m-j);
	}

	rep(i,n){
		ans[i]=0.0;
		rep(j,m+1){
			double prod=1.0;
			rep(a,n){
				if(a==i) continue;
				double sum=0.0;
				rep(b,m+1) if(rt[i][j]<rt[a][b]) sum+=rp[a][b];
				prod*=sum;
			}
			ans[i]+=rp[i][j]*prod;
		}
	}


	cout.precision(20);
	rep(i,n) cout << fixed << ans[i]  << endl;
	return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
	int i,j,n,k;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=2;i<=n;i++)
	{
		f[i]=INT_MAX;
		for(j=1;j<=min(k,i-1);j++)
			f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
	}
	printf("%d",f[n]);
	return 0;
} 

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		String[] d={
				"mon",
				"tue",
				"wed",
				"thu",
				"fri",
				"sat",
				"sun"
		};
		System.out.println(d[(getInt()+3)%7]);
	}
}

Measured memory_bytes: 26232
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let s: Vec<isize> = read_vec();
    let ans = if s[0] >= 1 && s[0] <= 9 && s[1] >= 1 && s[1] <= 9 {
        s[0] * s[1]
    } else {
        -1
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define sc second
#define pb push_back
typedef long long int ll;
typedef pair<ll,ll> P;
int K,N;
ll X1[50],X2[50],Y1[50],Y2[50],Z1[50],Z2[50];
vector<ll>X,Y,Z;
int cou[300][300][300];
int main()
{
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%lld%lld%lld%lld%lld%lld",&X1[i],&Y1[i],&Z1[i],&X2[i],&Y2[i],&Z2[i]);
		X.pb(X1[i]);X.pb(X2[i]);
		Y.pb(Y1[i]);Y.pb(Y2[i]);
		Z.pb(Z1[i]);Z.pb(Z2[i]);
	}
	sort(X.begin(),X.end());sort(Y.begin(),Y.end());sort(Z.begin(),Z.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	Z.erase(unique(Z.begin(),Z.end()),Z.end());
	for(int i=0;i<N;i++){
		int x1,x2,y1,y2,z1,z2;
		for(int j=0;j<(int)X.size();j++){
			if(X[j]==X1[i])x1=j;
			if(X[j]==X2[i])x2=j;
		}
		for(int j=0;j<(int)Y.size();j++){
			if(Y[j]==Y1[i])y1=j;
			if(Y[j]==Y2[i])y2=j;
		}
		for(int j=0;j<(int)Z.size();j++){
			if(Z[j]==Z1[i])z1=j;
			if(Z[j]==Z2[i])z2=j;
		}
		//printf("%d %d %d %d %d %d\n",x1,y1,z1,x2,y2,z2);
		for(int x=x1;x<x2;x++){
			for(int y=y1;y<y2;y++){
				for(int z=z1;z<z2;z++){
					cou[x][y][z]++;
				}
			}
		}
	}
	ll ans=0;
	for(int i=0;i<(int)X.size()-1;i++){
		for(int j=0;j<(int)Y.size()-1;j++){
			for(int k=0;k<(int)Z.size()-1;k++){
				if(cou[i][j][k]>=K){
					//printf("%d:%lld %d:%lld %d:%lld\n",i,X[i+1]-X[i],j,Y[j+1]-Y[j],k,Z[k+1]-Z[k]);
					ans+=(X[i+1]-X[i])*(Y[j+1]-Y[j])*(Z[k+1]-Z[k]);
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0){
    cout<<n/(2*d+1)<<endl;
  }else if(n%(2*d+1)>0){
    cout<<(n/(2*d+1))+1<<endl;
  }
}


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

int i,j;
int h,w;
vector<vector<char>> maze;
int dy[4]={1,-1,0,0},dx[4]={0,0,1,-1};

int main(){
    cin>>h>>w;
    maze.resize(h,vector<char>(w));
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>maze[i][j];
        }
    }

    
    vector<vector<bool>> seen;
    vector<vector<int>> ans(h,vector<int>(w,0));
    
    int maxi=0;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(maze[i][j]=='.'){    
                ans.assign(h,vector<int>(w,0));
                seen.assign(h,vector<bool>(w,false));//訪問したかどうか
                
                queue<pair<int,int>> que;
                que.push(make_pair(i,j));//start位置
                seen[i][j]=true;
                while(que.size()!=0){
                    pair<int,int> state=que.front();
                    que.pop();

                    for(int num=0;num<4;num++){
                        pair<int,int> next=make_pair(state.first+dy[num],state.second+dx[num]);
                        if(next.first<0 || next.second<0 || next.first>=h || next.second>=w) continue;//迷路の外
                        if(maze[next.first][next.second]=='#') continue;//壁
                        if(seen[next.first][next.second]==true) continue;//訪問済み

                        seen[next.first][next.second]=true;//訪問を記録
                        que.push(next);//queにdataを入れる
                        
                        ans[next.first][next.second]=ans[state.first][state.second]+1;
                        maxi=max(maxi,ans[next.first][next.second]);
                    }   
                }
            }    
        }
    }

    cout<<maxi<<endl;
    return 0;
}

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

const int mod = 1e9+7;

long long mpow(long long a, int n) {
	if (n == 0) return 1;
	if (n%2) return (a * (mpow(a, n-1) % mod)) % mod;
	else {
		long long tmp = mpow(a, n/2) % mod;
		return tmp * tmp % mod;
	}
}

const int MAX = 2000006;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long nCk(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
	int k;
	string s;
	cin >> k >> s;

	COMinit();

	long long ans = 0;
	for (int i = 0; i <= k; i++) {
		ans = (ans + mpow(26,i)*mpow(25,k-i)%mod * (nCk(s.size()+k-1-i, s.size()-1))%mod) % mod;
	}

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


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;

void Solve(ll) {
  ll n;
  cin >> n;
  vector<ll> arr(1 << n);
  RARA(a, arr) cin >> a;
  arr.push_back(0);
  auto cmp = [&](int a, int b) {
    return arr[a] > arr[b];
  };
  auto update = [&](pair<ll, ll>& a, pair<ll, ll> b) {
    array<int, 4> vals = {a.first, a.second, b.first, b.second};
    sort(ALL(vals), cmp);
    a.first = vals[0];
    VEVE(i, 1, 4) if (vals[i] != a.first) {
        a.second = vals[i];
        break;
      }
  };
  vector<pair<ll, ll>> dp(1 << n);
  VEVE(mask, 0, 1 << n) dp[mask] = {mask, 1 << n};
  VEVE(i, 0, n) VEVE(mask, 0, 1 << n) if (mask >> i & 1) update(dp[mask], dp[mask ^ 1 << i]);
  vector<ll> res;
  VEVE(mask, 1, 1 << n) res.push_back(arr[dp[mask].first] + arr[dp[mask].second]);
  VEVE(i, 1, SIZE(res)) res[i] = max(res[i], res[i - 1]);
  RARA(r, res) cout << r << "\n";
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 1;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		if(!n)
		cout<<1;
		else
		cout<<0;		
    }
    return 0;
}


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

const string YES = "yes";
const string NO = "no";

auto solve(std::string S){
    return set<char>(begin(S), end(S)).size() == S.size() ? YES : NO;
}

int main(){
    std::string S;
    std::cin >> S;
    auto result = solve(S);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int64_t ss[51][2501];
bool ms[51][2501];

struct R {
	int i;
	int64_t v;
	int64_t p;
};

struct C {
	int64_t t;
	int64_t v;
	int64_t p;
	vector<R> rs;
};

struct S {
	int c;
	int v;
	int64_t p;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	int64_t is; cin >> is;

	vector<C> cs(n + 1);
	FOR_LT(i, 0, m) {
		int u, v; cin >> u >> v;
		int64_t a, b; cin >> a >> b;
		cs[u].rs.push_back({ v, a, b });
		cs[v].rs.push_back({ u, a, b });
	}
	FOR_LT(i, 0, n) {
		int64_t a, b; cin >> a >> b;
		cs[i + 1].v = a;
		cs[i + 1].p = b;
	}

	auto comp = [](const S& lhs, const S& rhs) { return lhs.p > rhs.p; };
	priority_queue<S, std::vector<S>, decltype(comp)> search(comp);
	search.push({ 1, (int)min(is, (int64_t)2500), 0 });
	while (!search.empty()) {
		S s = search.top();
		search.pop();
		if (ms[s.c][s.v]) continue;
		ms[s.c][s.v] = true;
		ss[s.c][s.v] = s.p;

		auto& c = cs[s.c];
		for (auto& r : c.rs) {
			if (s.v < r.v) continue;
			if (ms[r.i][s.v - r.v]) continue;
			search.push({ r.i, (int)(s.v - r.v), s.p + r.p });
		}

		search.push({ s.c, (int)(min(s.v + c.v, (int64_t)2500)), s.p + c.p });
	}
	

	FOR_LE(i, 2, n) {
		int64_t ans = INT64_MAX;
		FOR_LT(j, 0, 2501) {
			if (ss[i][j] == 0) continue;
			ans = min(ans, ss[i][j]);
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

typedef pair<int, int> pint;
typedef pair<pint, pint> Data ;

int N, M, Q; 
vector<int> V, a, b, c, d;
int ans = 0;

void dfs(const int depth, const int max_v) {
  if(depth == N) {
    int work = 0;
    REP(i,Q) {
      if(V[b[i]] - V[a[i]] == c[i]) work += d[i];
    }
    if(work > ans) ans = work;
  } else {
    for(int v = V[depth-1]; v <= max_v; v++) {
      V[depth] = v;
      dfs(depth+1, max_v);
    }
  }
}

int main() {
  cin>>N>>M>>Q;
  a = vector<int>(Q);
  b = vector<int>(Q);
  c = vector<int>(Q);
  d = vector<int>(Q);
  REP(i,Q) {
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  V = vector<int>(N+2, 0);
  V[0] = 1;
  V[1] = 1;
  V[N+1] = M;
  for(int i = 1; i <= M; i++) {
    V[N] = i;
    dfs(2, i);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

  int n1;
  char *m;
  char num1[5];
  m = (fgets(num1, sizeof(num1), stdin));
  sscanf(num1, "%d\n", &n1);

  char str1[102];
  m = (fgets(str1, sizeof(str1), stdin));

  char str2[50];

  if ((n1 % 2) == 0) {                //偶数の時

    for (int i = 0; i < (n1 / 2); i++) {
      str2[i] = str1[i + (n1 / 2)];
    }

    if (strncmp(str1, str2, (n1 / 2)) == 0) {
      printf("Yes\n");
    }else{
      printf("No\n");
    }

  }else{                              //奇数の時
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <climits>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)

using pii=pair<int,int>;

string S;
int ans[200010];

signed main()
{
	cin >> S;
	S+='?';
	vector<pii> arr;
	int len = 0;
	rep(i, S.size()) {
		// R->0,L->1
		if (i and S[i] != S[i-1]) {
			arr.push_back(pii(len, S[i]=='L'));
			len = 0;
		}
		len++;
	}

	int cur = 0;

	for (int i = 0; i < arr.size(); i += 2) {
		cur += arr[i].first - 1;	

		// S[cur] is R
		ans[cur + 1] = arr[i].first / 2 + (arr[i+1].first + 1) / 2;
		ans[cur] = arr[i+1].first / 2 + (arr[i].first + 1) / 2;

		cur += arr[i+1].first + 1;
	}

	rep(i, S.size()-1) printf("%lld%c", ans[i], i==S.size()-2?'\n':' ');
}


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


int main() {
  double n;
  
  cin >> n;
  
  double flag = 0;
  
  
  for(int i=1; i<=n; i++){
    if(i%2 == 1)
      flag++;
  }
  
  double pro = flag/n;
  
  cout << pro;
  
  
  
}


Measured memory_bytes: 256
N = input()
N = int(N)
a = list(map(int,input().split()))

b = [0 for _ in range(len(a))]
xor = 0

for ai in a:
  xor ^= ai
  
b = 0
ans = ""
for j in range(len(a)):
  b = xor ^ a[j]
  ans += str(b)
  if j == len(a)-1:
    break
  ans +=" "

print(ans)

Measured memory_bytes: 31596
#include <bits/stdc++.h>
using namespace std;
int n,h,ma=0,ans=0;
vector <int> thr;
int main(){
	cin>>n>>h;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		ma=max(ma,t);
		cin>>t;
		thr.push_back(t);
	}
	sort(thr.begin(),thr.end(),std::greater<int>());
	for(int i=0;i<thr.size();i++){
		if(ma<thr[i]){
			ans++;
			h-=thr[i];
		}else{
			break;
		}
		if(h<=0){
			break;
		}
	}
	if(h>0){
		if(h%ma==0){
			ans+=h/ma;
		}else{
			ans+=h/ma+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double dx = abs(x1 - x2);
  double dy = abs(y1 - y2);
  cout << fixed << setprecision(4) << sqrt(dx * dx + dy * dy) << endl;
  return 0;
}



Measured memory_bytes: 3212
package main

import "fmt"

func main() {
	var a [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	var n int
	fmt.Scan(&n)
	var bs []int
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		bs = append(bs, tmp)
	}

	// 縦
	for j := 0; j < 3; j++ {
		tmp := true
		for i := 0; i < 3; i++ {
			if !tmp {
				break
			}
			tmp = search(a[i][j], bs)
		}
		if tmp {
			fmt.Print("Yes")
			return
		}
	}
	// 横
	for i := 0; i < 3; i++ {
		tmp := true
		for j := 0; j < 3; j++ {
			if !tmp {
				break
			}
			tmp = search(a[i][j], bs)
		}
		if tmp {
			fmt.Print("Yes")
			return
		}
	}
	// 斜め
	tmp := true
	for i := 0; i < 3; i++ {
		if !tmp {
			break
		}
		tmp = search(a[i][i], bs)
	}
	if tmp {
		fmt.Print("Yes")
		return
	}
	tmp = true
	for i := 0; i < 3; i++ {
		if !tmp {
			break
		}
		tmp = search(a[i][2-i], bs)
	}
	if tmp {
		fmt.Print("Yes")
		return
	}

	fmt.Print("No")
}

func search(n int, bs []int) bool {
	for _, b := range bs {
		if n == b {
			return true
		}
	}
	return false
}


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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String c[] = new String[3];
		c[0] = br.readLine().substring(0, 1);
		c[1] = br.readLine().substring(1, 2);
		c[2] = br.readLine().substring(2, 3);
		System.out.println(c[0] + c[1] + c[2]);
	}
}

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

res = 0

for i in range(N):
  m1 = min(B[i], A[i])
  res += m1
  A[i] -= m1
  B[i] -= m1
  m2 = min(B[i], A[i+1])
  res += m2
  A[i + 1] -= m2
  
print(res)
  

Measured memory_bytes: 18624
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)

g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar

print("{0} {1}".format(Smax+Hmax, Smax))


Measured memory_bytes: 3064
from itertools import product
n,m = map(int,input().split())
cake = [list(map(int,input().split())) for i in range(n)]

ans = 0
for x,y,z in product([1,-1], repeat = 3):
    tmp = []
    for a,b,c in cake:
        tmp.append(a * x + b * y + c * z)
    tmp.sort(reverse= True)
    ans = max(ans,sum(tmp[:m]))
print(ans)

Measured memory_bytes: 3384
#include<stdio.h>
int main()
{
	int n,i,j,k,m,a[100];
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(j==n-1)
				{
					printf("%d",a[j]);
				}
				else
				{
					printf("%d ",a[j]);
				}
			}
			printf("\n");
			for(m=i;m>=0;m--)
			{
				j=m+1;
				if(a[j]<a[m])
				{
					k=a[m];
					a[m]=a[j];
					a[j]=k;
				}
				else
				{
					break;
				}
			}
		}
	}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    for (int i = n-1; i > 1; --i) {
        for (int j = i-1; j > 0; --j) {
            if (l[i] >= l[j]+l[j-1]) break;
            if (l[i] < l[j]+l[0]) {
                ans += j;
                continue;
            }
            int le = 0, r = j-1;
            while (le+1<r) {
                int mid = (le+r) / 2;
                if (l[i] < l[j]+l[mid]) r = mid;
                else le = mid;
            }
            ans += j - r;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int x, a, b;

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

	if (a + b < 10) {
		cout << a + b << endl;
	}
	else {
		cout << "error" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import numpy as np
N,M,C = (int(j) for j in input().split())
B = [int(j) for j in input().split()]
list = [[0]* M]*N
for j in range(0,N):
        list[j] = [int(k) for k in input().split()]
count = 0
for j in range(0,N):
    if np.sum(np.array(list[j]) * np.array(B)) + C > 0:
        count = count + 1
print(count)

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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a=-2,b;
    cin>>n;b=n;
    string s;
    while(n!=0){
        if((n%a)<0){s+=(2+(n%a))+'0';n/=a;n+=1;}
        else {s+=(n%a)+'0';n/=a;}
    }
    reverse(s.begin(),s.end());
    if(b!=0)cout<<s<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;
  
int main()
{
  int a,b,c,ab,bc,ca;

  cin >> a >> b >> c;
  ab = a+b; bc = b+c; ca = a+c;
  
  cout << (std::min)({ab,bc,ca});
  
  return 0;
}


Measured memory_bytes: 384