akhauriyash/Code-Regression huggingface dataset:
//10-D
/*
２つのデータがどれだけ似ているかを、それらの距離で測る手法は、クラスタリングや分類など、
様々なところで使われています。ここでは、２つの n 次元ベクトル x={x1,x2,...,xn} と y={y1,y2,...,yn}の
距離を計算してみましょう

１行目に整数 n が与えられます。２行目にベクトル x の要素 {x1,x2,...xn}、
３行目にベクトル y の要素 {y1,y2,...yn} が空白区切りで与えられます。入力はすべて整数値です。
*/

import java.util.Scanner;

class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int[] x = new int[n];
        int[] y = new int[n];
        int[] z = new int[n];
        
        for(int i = 0 ; i < n ; i++ ){//配列xに代入
        	x[i] = sc.nextInt();
        }
        for(int j = 0 ; j < n ; j++ ){//配列yに代入
        	y[j] = sc.nextInt();
        }
        for(int k = 0 ; k < n ; k++ ){//x - x したものを代入
        	z[k] = Math.abs( x[k] - y[k] );//絶対値としいれる
        }
        
        //p1計算--------------------------------------------
        double sump1 = 0;
        for(int i = 0 ; i < n ; i++ ){
        	sump1 = sump1 + z[i];
        }
        System.out.println(sump1);
        
        //p2計算--------------------------------------------
        double sump2 = 0;
        for( int i = 0 ; i < n ; i++ ){
        	sump2 = sump2 + z[i] * z[i];	
        }
        sump2 = Math.sqrt(sump2);//sqrt平方根を計算する
        System.out.println(sump2);
        
        //p3計算--------------------------------------------
        double sump3 = 0;
        for( int i = 0 ; i < n ; i++ ){
        	sump3 = sump3 + z[i] * z[i] * z[i];	
        }
        sump3 = Math.cbrt(sump3);//cbrt立方根を計算する
        System.out.println(sump3);
        
        //pmax計算------------------------------------------
        double sumpmax = z[0];
        //double max = 0;
        for( int i = 0 ; i < n ; i++ ){
        	if( sumpmax < z[i]){
        		sumpmax = z[i];
        	}
        }
        System.out.println(sumpmax);
        
    }
}

Measured memory_bytes: 26600
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
typedef long long LL;
string ss,sss;
int work()
{
	sss=ss;
	int N=sss.length()-1,cnt=0;
	for(int i=0;i<N;++i)if(sss[i]==sss[i+1])
	{
		sss[i+1]='a'-1;++cnt;
	}
	return cnt;
}
int main()
{
	int N,K;
	cin>>ss;
	scanf("%d",&K);
	N=ss.length();
	int ans=work();
	if(ss[0]!=ss[N-1])
	{
		printf("%lld",(LL)ans*K);
		return 0;
	}
	int len=-1;
	for(int i=0;i<N-1;++i)if(ss[i]!=ss[i+1])
	{
		len=i+1;break;
	}
	if(len==-1)
	{
		printf("%lld",(LL)N*K/2);
		return 0;
	}
	ss=ss.substr(len,N-len)+ss.substr(0,len);
	printf("%lld",(LL)work()*(K-1)+ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include<fstream>
#include<list>
#include<sstream>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007

using namespace std;



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

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

	string s;
	cin >> s;
	int n = s.size();

	if (s[n - 1] == 's')
	{
		s += "es";
	}
	else
	{
		s += 's';
	}

	cout << s;

	return 0;
}


Measured memory_bytes: 3660
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main
   
   
}//class


Measured memory_bytes: 26108
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int solve(string x, string y)
{
    vector<vector<int> > c(x.size(), vector<int>(y.size(), 0));

    if (x[0] == y[0]) {
        c[0][0] = 1;
    }

    for (int i = 1; i < x.size(); i++) {
        if (c[i - 1][0] == 1 || x[i] == y[0]) {
            c[i][0] = 1;
        } else {
            c[i][0] = 0;
        }
    }
    for (int i = 1; i < y.size(); i++) {
        if (c[0][i - 1] == 1 || x[0] == y[i]) {
            c[0][i] = 1;
        } else {
            c[0][i] = 0;
        }
    }

    for (int i = 1; i < x.size(); i++) {
        for (int j = 1; j < y.size(); j++) {
            if (x[i] == y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i][j - 1], c[i - 1][j]);
            }
        }
    }

    return c[x.size() - 1][y.size() - 1];
}

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

    vector<string> x(q), y(q);
    for (int i = 0; i < q; i++) {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < q; i++) {
        cout << solve(x[i], y[i]) << endl;
    }

    return 0;
}



Measured memory_bytes: 6776
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;
char str[100005];
int len,dp[100005][13];

int main()
{
    scanf("%s",str);len = strlen(str);
    reverse(str,str+len);
    int base = 1;
    int ori = 0;
    for(int i=0;i<len;++i)
    {
        if(str[i]!='?'){
            ori+=(str[i]-'0')*base;
            ori%=13;
        }
        base*=10;base%=13;
    }
    dp[0][ori] = 1;

    if(str[0]=='?'){
        for(int i=0;i<10;++i)
        {
            for(int j=0;j<13;++j)
            {
                dp[1][(j+i)%13]+=dp[0][j];
                dp[1][(j+i)%13]%=mod;
            }
        }
        for(int j=0;j<13;++j){
            dp[0][j] = dp[1][j];
            dp[1][j] =0;
        }
    }

    base = 1;

    for(int t=1;t<len;++t)
    {
        base*=10;base%=13;
        if(str[t]!='?'){
            for(int j=0;j<13;++j)
                dp[t][j] = dp[t-1][j];
            continue;
        }
        for(int i=0;i<10;++i)
        {
            for(int j=0;j<13;++j)
            {
                dp[t][(j+i*base)%13]+=dp[t-1][j];
                dp[t][(j+i*base)%13]%=mod;
            }
        }
    }
    printf("%d\n",dp[len-1][5]);
    return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
const int N = 2e5+5;
const int mod = 1e9+7;
typedef long long ll ;
ll s[N],arr[N];


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int num;
    cin>>num;
    for(int i = 1;i<=num;i++)
    {
        ll temp;
        cin>>temp;
        arr[i]=temp;
        if(i==1)
            s[i]=temp;
        else
            s[i]=(s[i-1]+temp);
    }
    ll he = 0;
    for(int i =1;i<=num;i++)
    {
        he+=((s[num]-s[i])%mod)*arr[i];
        he=he%mod;
    }
    cout<<he<<endl;


}


Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define ll long long
#include <numeric>
using namespace std;
const int sz = 1e6+5;
ll int arr[sz], arr1[sz];
//ll int arr[100][100]= {0};
bool prime[sz]= {0};
vector <ll int> pr,vec1,vec2;
//vector <pair <int,int>> vec;

int main()
{
    ll int a,b,hcf,temp,lcm;
    cin>>a>>b;

    hcf = a;
    temp = b;

    while(hcf!=temp)
    {
        if (hcf>temp)
            hcf -=temp;
        else
            temp-= hcf;

    }

    lcm = (a*b)/hcf;
    cout<<lcm<<endl;


}


Measured memory_bytes: 3620
#include<cstdio>
using namespace std;
const int mod=1e9+7;
long long x[1000005],dp1[1000005],dp2[1000005];
int main(){
	int n;
	long long A,B;
	scanf("%d%lld%lld",&n,&A,&B);
	for (int i=1; i<=n; i++) scanf("%lld",&x[i]);
	dp1[0]=dp2[0]=1;
	int k1=0,k2=0,k3=0,k4=0;
	for (int i=2; i<=n; i++){
		while (k1+2<i && x[i]-x[k1+1]>=A) k1++;
		while (k2+2<i && x[i]-x[k2+1]>=B) k2++;
		int sum1=dp1[k2],sum2=dp2[k1];
		dp1[i-1]=sum2;
		dp2[i-1]=sum1;
		if (x[i]-x[i-1]<A){
			while (k3<i-1) {
				dp1[k3]=0;
				k3++;
			}
		}
		else (dp1[i-1]+=dp1[i-2])%=mod;
		if (x[i]-x[i-1]<B){
			while (k4<i-1){
				dp2[k4]=0;
				k4++;
			}
		}
		else (dp2[i-1]+=dp2[i-2])%=mod;
	}
	int ans=0;
	(ans+=dp1[n-1])%=mod,(ans+=dp2[n-1])%=mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll T;
  cin >> T;
  vl ANS(T, 0);
  REP(t, T) {
    ll N;
    string S;
    cin >> N;
    vl A(N);
    REP(i, N) cin >> A[i];
    cin >> S;
    vl base;
    RREP(i, N) {
      ll x = A[i];
      sort(ALL(base), REV(ll));
      AUTO(b, base) x = min(x, x ^ b);
      if (x != 0) {
        if (S[i] == '0')
          base.push_back(x);
        else {
          ANS[t] = 1;
          break;
        }
      }
    }
  }
  REP(t, T) cout << ANS[t] << endl;
  return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn =2e3+5;
const double pi=3.1415926535;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double jiao1=m/60.0*360.0;
	double shi=h*60.0+m;
	double jiao2=shi/720.0*360.0;
    //cout<<jiao1<<" "<<jiao2<<'\n';
    double jiao=max(jiao1,jiao2)-min(jiao1,jiao2);
    jiao=jiao*pi/180.0;
    double ans=a*a+b*b-2.0*a*b*cos(jiao);

    ans=sqrt(ans);
    cout<<fixed<<setprecision(10)<<ans<<'\n';






}


Measured memory_bytes: 4216
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	char S[10];
	scanf("%s", S);
	int i = 0;
	while (i < 3) {
		if (S[i] == S[i + 1]) {
			printf("Bad");
			return 0;
		}
		i++;
	}
	printf("Good");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int n, m; 
bool can[1005][1005], vis[1005], ans[200005]; 
std::vector<std::pair<int, int> > adj[1005]; 
void dfs(int rt, int u)
{
	vis[u] = true; 
	for (auto it : adj[u])
	{
		if (it.first == rt || vis[it.first])
			continue; 
		dfs(rt, it.first); 
	}
}
void work()
{
	for (int i = 0; i < n; i++)
	{
		memset(vis, false, sizeof(vis)); 
		for (auto it : adj[i])
		{
			if (vis[it.first])
				ans[it.second] = true; 
			else
				dfs(i, it.first); 
		}
	}
}
void fill(int rt, int u)
{
	if (can[rt][u])
		return; 
	can[rt][u] = true; 
	for (auto it : adj[u])
		fill(rt, it.first); 
}
int main()
{
	// freopen("ARC092-F.in", "r", stdin); 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < m; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		adj[--u].pb(mp(--v, i)); 
	}
	for (int i = 0; i < n; i++)
		fill(i, i); 
	work(); 
	for (int i = 0; i < n; i++)
		std::reverse(adj[i].begin(), adj[i].end()); 
	work(); 
	for (int i = 0; i < n; i++)
	{
		for (auto it : adj[i])
			ans[it.second] ^= can[it.first][i]; 
	}
	for (int i = 0; i < m; i++)
		puts(ans[i] ? "diff" : "same"); 
	return 0; 
}


Measured memory_bytes: 5504
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AAirplane {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        vector<int> v(3);
        REP(i, 3) {
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        cout << v[0] + v[1] << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AAirplane solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N; cin>>N;
    vector<int>s(N);
    int sum=0;
    rep(i,N){
        cin>>s[i];
        sum+=s[i];
    }
      if(sum%10!=0){
          cout<<sum<<endl;
          return 0;
      }
    sort(s.begin(),s.end());
    rep(i,N){
        if(s[i]%10!=0){
            cout<<sum-s[i]<<endl;
            return 0;
        }
    }
    cout<<0<<endl;

}
 



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



int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;

   

}

Measured memory_bytes: 3608
n = int(input())

if n == 2:
    a, b = map(int, input().split())
    small = min(a, b)
    large = max(a, b)

    for i in range(1, min(small, large // 2)):
        if a % i == 0 and b % i == 0:
            print(i)

else:
    a, b, c = map(int, input().split())
    small = min(a, b, c)
    large = max(a, b, c)

    for i in range(1, min(small, large // 2)):
        if a % i == 0 and b % i == 0 and c % i == 0:
            print(i)



Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct Node{
    int node;
    int key;
    int parent_key;
    int left_key;
    int right_key;
};
vector<int> element;
int main(void){
    int n;
    cin >> n;
    element.push_back(0);
    for(int i=0;i<n;i++){
        int key;
        cin >> key;
        element.push_back(key);
    }
    for(int i=1;i<=n;i++){
        cout << "node " << i << ": " << "key = " << element[i] << ", ";
        if(i!=1){
            cout << "parent key = " << element[i/2] << ", ";
        }
        if(i * 2 <= n){
            cout << "left key = " << element[i*2] << ", ";
        }
        if(i * 2 + 1 <= n){
            cout << "right key = " << element[i*2+1] << ", ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
s=gets.chomp
t=s[2..3].to_i
s=s[0..1].to_i
if 0<t and t<=12
    if 0<s and s<=12
        puts "AMBIGUOUS"
    elsif s==0
        puts "YYMM"
    else
        puts "YYMM"
    end
elsif t==0
    if 0<s and s<=12
        puts "MMYY"
    elsif s==0
        puts "NA"
    else
        puts "NA"
    end
else
    if 0<s and s<=12
        puts "MMYY"
    elsif s==0
        puts "NA"
    else
        puts "NA"
    end
end



Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int cnt[5] = {};
  int a, b;
  int jud = 0;
  
  for(int i = 0;i < 3;i++){
	cin >> a >> b;
	cnt[a]++;
	cnt[b]++;
  }

  for(int i = 1;i <= 4;i++){
	if(cnt[i] >= 2) jud ++;
  }

  if(jud == 2){
	cout << "YES" << endl;
  }else{
	cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};

// FHCまでにスタックオーバーフローの罠を解決する

map<array<ll,2>,int> mp1[26],mp2[26];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    vector<pair<int,string>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].second;
        a[i].first = a[i].second.size();
    }
    sort(a.begin(),a.end());

    const ll mod1 = 1000000103, mod2 = 1000000483;
    ll mul1=10009;
    ll mul2=10007;

    
    ll ans = 0;
    int one[26]={};
    for(int i=0;i<n;i++){
        string s = a[i].second;
        if(s.size() == 1){
            one[s[0]-'a']++;
            continue;
        }
        ll h1=0;
        ll h2=0;
        int m = s.size(), c=26;
        int cnt[c][m+1]={};
        for(int j=0;j<m;j++){
            cnt[s[j]-'a'][j+1]++;
            for(int k=0;k<26;k++) cnt[k][j+1] += cnt[k][j];
        }
        // one
        for(int j=0;j<26;j++){
            if(cnt[j][m] == 0)continue;
            ans += one[j];
        }
        int now = 0;
        for(int j=m-1;j>=1;j--){
            now++;
            h1 = (h1*mul1 + s[j]) % mod1;
            h2 = (h2*mul2 + s[j]) % mod2;
            for(int k=0;k<26;k++){
                if(cnt[k][j] && mp1[k].count({now,h1}) && mp2[k].count({now,h2})){
                    ans += mp1[k][{now,h1}];
                }
            }
        }
        mp1[(int)(s[0]-'a')][{m-1,h1}]++;
        mp2[(int)(s[0]-'a')][{m-1,h2}]++;
    }
    cout << ans << endl;
    
}

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

int main(){
  char v;
  cin >> v;
  if(v == 'a' || v == 'o' || v == 'i' || v == 'u' || v == 'e')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define INF 1000000007
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N;
  scanf("%d", &N);
  int F[100][10];
  rep(i, 0, N) {
    rep(j, 0, 10) {
      scanf("%d", &F[i][j]);
    }
  }
  int P[100][11];
  rep(i, 0, N) {
    rep(j, 0, 11) {
      scanf("%d", &P[i][j]);
    }
  }

  // bit探索
  int max = -INF;
  int con = 1 << 10; 
  for ( int c = 1; c < con; c++ ) {
    int C[100] = {0};
    for ( int d = 0; d < 10; d++ ) {
      if ( ((c >> d) & 1) == 0 ) continue;
      for ( int i = 0; i < N; i++ ) {
        if ( F[i][d] == 0 ) continue;
        C[i]++;
      }
    }
    int val = 0;
    for ( int i = 0; i < N; i++ ) 
      val += P[i][C[i]];
    max = max(max, val);
  } 
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let a = (s[0] as u8 - '0' as u8) as i32;
    let b = (s[1] as u8 - '0' as u8) as i32;
    let c = (s[2] as u8 - '0' as u8) as i32;
    let d = (s[3] as u8 - '0' as u8) as i32;

    let mut ans = (0, 0, 0);
    for &i in &[0, 1] {
        for &j in &[0, 1] {
            for &k in &[0, 1] {
                let mut temp = a;
                if i == 0 {
                    temp += b;
                } else {
                    temp -= b;
                }
                if j == 0 {
                    temp += c;
                } else {
                    temp -= c;
                }
                if k == 0 {
                    temp += d;
                } else {
                    temp -= d;
                }

                if temp == 7 {
                    ans = (i, j, k);
                }
            }
        }
    }

    println!(
        "{}{}{}{}{}{}{}=7",
        a,
        if ans.0 == 0 { '+' } else { '-' },
        b,
        if ans.1 == 0 { '+' } else { '-' },
        c,
        if ans.2 == 0 { '+' } else { '-' },
        d
    );
}


Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[200005],b[200005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(b[i]==a[n]) cout<<a[n-1]<<endl;
		else cout<<a[n]<<endl;
	}
	return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++)
        sum += v[i];
    cout << sum;
	return 0;
}


Measured memory_bytes: 3604
n = gets.to_i

matches = n.times.map do
  a, b = gets.split
  case a <=> b
  when -1 then [0, 3]
  when  0 then [1, 1]
  when  1 then [3, 0]
  end
end

puts matches.transpose.map {|score| score.inject(:+) }.join(' ')

Measured memory_bytes: 6104
def pm(S,a,i):
	if i == 0:
		S += a
	else:
		S -= a

	return S

def ch(i):
	if i == 0:
		return '+'
	else:
		return '-'


if __name__ == '__main__':
	S = input()
	A = int(S[0])
	B = int(S[1])
	C = int(S[2])
	D = int(S[3])

	ans = ''

	for a in range(2):
		for b in range(2):
			for c in range(2):	
				goukei = A
				goukei = pm(goukei,B,a)
				goukei = pm(goukei,C,b)
				goukei = pm(goukei,D,c)

				if goukei == 7:

					ans = S[0] + ch(a) + S[1] + ch(b) + S[2] + ch(c) + S[3] + '=7'
					break
					break
					break

	print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int s[1005][1005] = {};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  REP(i, h)
  {
    REP(j, w)
    {
      if (i < b)
      {
        if (j < a)
        {
          cout << 0;
        }
        else
        {
          cout << 1;
        }
      }
      else
      {
        if (j < a)
        {
          cout << 1;
        }
        else
        {
          cout << 0;
        }
      }
    }
    cout << '\n';
  }
  return 0;
}


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

using namespace std;

const int N = 1e5 + 1;

int n, m, dp[ N ], vis[ N ];
vector<int> g[ N ];

int dfs(int u) {
    vis[ u ] = 1;
    for(int v : g[ u ]) {
        if( !vis[ v ] )
            dfs(v);
        dp[ u ] = max(dp[ u ], 1 + dp[ v ]);
    }
    return dp[ u ];
}

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

    cin >> n >> m;
    while( m-- ) {
        int u, v;
        cin >> u >> v;
        g[ u ].push_back(v);
    }
    for(int i = 0; i <= n; i += 1) dp[ i ] = 0, vis[ i ] = 0;
    int ans = 0;
    for(int i = 1; i <= n; i += 1) {
        if( !vis[ i ] ) {
            ans = max(ans, dfs(i));
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 8576
//http://tsutaj.hatenablog.com/entry/2017/03/30/224339
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
    int N;
    string s, t;
    cin >> N >> s >> t;
    rep(i, N) {
        if (s.substr(i, N - i) == t.substr(0, N - i)) {
            cout << N + i << "\n";
            return 0;
        }
    }
    cout << 2 * N << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>
int main (){
long long int n,i,a,digit;
digit=0;
scanf("%lld",&n);
a=sqrt(n);
for(i=a;i>=1;i--){
if (n%i==0) {
a=n/i;
while(a !=0){
a = a / 10;
++digit;
}
printf("%lld",digit);
break;
}
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    int n,m;
    cin >> n >> m;
    vector<int> p(m),y(m);  // 県とできた年のベクター
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> y[i];
        p[i]--;
    }
    vector<vector<int>> vals(n);
    for (int i = 0; i < m; ++i) vals[p[i]].push_back(y[i]);
    // それぞれの県に市を入れていく

    for (int i = 0; i < n; ++i) {
        sort(vals[i].begin(),vals[i].end()); // それぞれの県の市を誕生順にソート
    }

    for (int i = 0; i < m; ++i) {
        printf("%06d",p[i]+1);

        int id = lower_bound(vals[p[i]].begin(),vals[p[i]].end(),y[i]) - vals[p[i]].begin();
        // 座標圧縮
        printf("%06d\n",id+1);
    }
    return 0;
}

Measured memory_bytes: 7808
import numpy as np
import copy
  
N = int(input())  
A = np.zeros(N)

for i in range(N):
    A[i] = int(input())

ans = int(np.max(A))
K = np.where(A == ans)[0]
k = np.where(A == ans)[0][0]

if K.size > 1:
    for i in range(N):
        print(ans)
        
else:
    for i in range(N):
        if i == k:
            B = np.delete(A, i)
            print(int(np.max(B)))
    
        else:
            print(ans)

Measured memory_bytes: 17248
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

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

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	long long n, luca[100];

	cin >> n;

	luca[0] = 2;
	luca[1] = 1;

	if (n >= 2) {
		for (int i = 2; i <= n; i++)
		{
			luca[i] = luca[i - 1] + luca[i - 2];
		}
	}
	

	cout << luca[n] << "\n";


	return 0;
}

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

int main() {
	int n;
  cin >> n;
  map<string, int> a;
  	
  	int mx=0;
  	for(int i=0; i<n; i++) {
		string s;
      cin >> s;
      a[s]++;
      mx=max(a[s], mx);
    }
    
    for(auto aa:a) {
      	if(aa.second==mx) cout << aa.first << endl; 
    }
 	return 0; 
}

Measured memory_bytes: 25216
# https://atcoder.jp/contests/abc057/tasks/abc057_c
# C - Digits in Multiplication

N = int(input().split()[0])
c = 0
for i in range(int(N ** (1/2)), 0, -1):
    if N % i == 0:
        a = int(N / i)
        d = (i, a)
        break

ans = len(str(max(d)))
print(ans)


Measured memory_bytes: 3060
function Main(input) {
  input = input.trim()
  input = input.split("\n");
  var N = input[0]
  var S = input[1].split("");
  var p=0;
for(var i=0;i<N/2;i++){
  if(S[i]!==S[i+N/2]){
    p++
  }
}
if(p==0){
  console.log("Yes")
}else{
  console.log("No")
}
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

const int MAXR = 1000000000;

int n;

vector<pair<int, int> > segs;

int maxl, minr;

int main() {
	scanf("%d", &n);
	maxl = -1;
	minr = MAXR + 1;
	for (int i = 0; i < n; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		segs.push_back(make_pair(l, r));
		if (l > maxl) {
			maxl = l;
		}
		if (r < minr) {
			minr = r;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int tmp = max(0, minr - maxl + 1);
		tmp += segs[i].second - segs[i].first + 1;
		ans = max(ans, tmp);
	}
	sort(segs.begin(), segs.end());
	int minr2 = MAXR + 1;
	for (int i = n - 2; i >= 0; --i) {
		int l = segs[i].first;
		minr2 = min(minr2, segs[i + 1].second);	
		int tmp = max(0, minr2 - maxl + 1) + max(0, minr - l + 1);
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}


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

struct st {
	int a[3];
	st(int*b) {
		rep(i, 3)a[i] = b[i];
		sort(a, a + 3);
	}
	bool operator<(const st&r)const {
		rep(i, 3) {
			if (a[i] != r.a[i])return a[i] < r.a[i];
		}
		return false;
	}
};
int main() {
	int n; scanf("%d", &n);
	set<st>s;
	rep(i, n) {
		int a[3]; rep(j, 3)scanf("%d", &a[j]);
		st p(a); s.insert(p);
	}
	printf("%d\n", n - s.size());
}

Measured memory_bytes: 3264
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)


ans_list = []
graph = UnionFind(N)
last = N * (N-1) // 2
ans_list.append(last)
for i in range(M-1, -1, -1):
    a, b = AB[i]
    if graph.same(a-1, b-1):
        ans_list.append(ans_list[-1])
    else:
        ans_list.append(ans_list[-1] - graph.size(a-1) * graph.size(b-1))
    graph.unite(a-1, b-1)

for i in range(M-1, -1, -1):
    print(ans_list[i])

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

int main()
{
	int a, b;
	int d, r;
	double f;

	cin >> a >> b;


	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	printf("%d %d %.5f\n",d,r,f);

	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    double a,b;
    cin>>a>>b;
    cout<<fixed<<setprecision(12)<<a*b/(a+b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+20;
map<int,int> mp;
int main()
{
    int n,m,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        mp[x]++;
    }
    cin>>m;
    bool flag=true;
    for(int i=0;i<m;i++)
    {
        scanf("%d",&x);
        if(mp[x]>=1)
            mp[x]--;
        else
            flag=false;
    }
    if(flag)
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 11648
import java.util.Scanner;
import static java.lang.System.out;

class Range {
    private boolean isDesk; // ?????????????????????????????????

    Range(int a, int b, int c) {
        this.isDesk =  ( a < b) ? ( ( b < c) ? true : false) : false;
    }

    @Override
    public String toString() {
        return isDesk ? "Yes" : "No";
    }
}

public class Main {
    public static void main( String... args) {
        Scanner scan = new Scanner( System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        out.println(new Range(a, b, c));
    }
}

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

using namespace std;

const int max_n = 100011, inf = 1000111222;

int n, a[max_n];
long long x[max_n], sum[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    sum[1] = 2 * a[0];
    for (int i = 2; i < n; ++i) {
        sum[i] = 2 * a[i - 1] - sum[i - 1];
    }
    x[0] = (2 * a[n - 1] - sum[n - 1]) / 2;
    for (int i = 1; i < n; ++i) {
        x[i] = 2 * a[i - 1] - x[i - 1];
    }
    for (int i = 0; i < n; ++i) {
        printf("%lld ", x[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, ans = 1;
	cin >> n;
	while(1){
	    if(pow(ans + 1, 2) > n){
	        std::cout << ans*ans << std::endl;
	        return 0;
	    }else{
	        ans++;
	    }
	}
	return 0;
}

Measured memory_bytes: 256
H, N = map(int,input().split())
M = [list(map(int,input().split())) for k in range(N)]
dp = [float("inf")]*(H+1)
dp[0] = 0

for e in M:
    a, b = e[0], e[1]
    for k in range(min(a+1,H+1)):
        dp[k] = min(dp[k],b)
    for k in range(a+1,H+1):
        dp[k] = min(dp[k],dp[k-a]+b)
print(dp[H])


Measured memory_bytes: 49244
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;

int main() {
	vector<ll> num(3);
	ll n, ans = 0;
	cin >> num[0] >> num[1] >> num[2] >> n;
	for (ll i = 0; i <= n; i++)
	{
		for (ll j = 0; j <= n; j++)
		{
			if ((n - i * num[0] - j * num[1]) >= 0 && (n - i * num[0] - j * num[1]) % num[2] == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
m,k = map(int,input().split())
if m == 1 and k == 0:
  print("0 0 1 1")
  quit()
n=2**m
k += (n == 2 and k == 1)
p=list(range(n))
print(" ".join([str(t) for t in p[:k]+p[k::-1]+p[:k:-1]+p[k:]]) if k<n else -1)


Measured memory_bytes: 28644
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int i, j;
	char gra[110][110];
	int h, w;
	scanf("%d %d", &h, &w);
	for(i = 1; i <= h; i++)
			scanf("%s", &gra[i]);
		for(i = 1; i <= h; i++)
		{
				printf("%s\n", gra[i]);
				printf("%s\n", gra[i]);
		}
}

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

int n, m;

vector <vector <int> > adj;

vector <int> topoSort;
vector <int> memo;
vector <bool> visited;

void dfs (int u) {
	visited[u] = true;
	for (int v : adj[u])
		if (!visited[v])
			dfs(v);
	topoSort.push_back(u);
	return;
}

void relax () {
	for (int u : topoSort) {
		for (int v : adj[u])
			memo[v] = max(memo[v], memo[u] + 1);
	}
	int ans = -1;
	for (int i = 0; i < n; i++) {
		ans = max(ans, memo[i]);
	}
	cout << ans << "\n";
}

int main () {
	cin >> n >> m;
	int x, y;
	adj.assign(n, vector <int>());
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		x--, y--;	// TODO
		adj[x].push_back(y);
	}
	visited.assign(n, false);
	for (int i = 0; i < n; i++)
		if (!visited[i])
			dfs(i);
	reverse(topoSort.begin(), topoSort.end());
	memo.assign(n, 0);
	relax();
//	for (int u : topoSort)
//		cout << u + 1 << " ";
	return 0;
}

Measured memory_bytes: 8696
// maximum heap
// re-construct to max-heap
#include<iostream>
int parent(int);
int left(int);
int right(int);
void maxHeapify(int*, int);
void buildMaxHeap(int*);
int n;
int main(){
  int *T, i;
  std::cin >> n;
  T = new int[n+1];
  for(i=1; i<=n; i++) std::cin >> T[i];
  buildMaxHeap(T);
  for(i=1; i<=n; i++) std::cout << " " << T[i];
  std::cout << "\n";
  return 0;
}
int parent(int n){
  return n/2;
}
int left(int n){
  return 2*n;
}
int right(int n){
  return 2*n+1;
}
void maxHeapify(int *A, int i){
  int l=left(i), r=right(i), largest, temp;
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
}
void buildMaxHeap(int *A){
  int i;
  for(i=n/2; i>0; i--) maxHeapify(A,i);
}

Measured memory_bytes: 5064
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(std::vector<std::vector<ll>> c) {
  vector<int> a(3), b(3);

  for (int a0 = 0; a0 <= 100; a0++) {
    a.at(0) = a0;

    b.at(0) = c.at(0).at(0) - a.at(0);
    b.at(1) = c.at(0).at(1) - a.at(0);
    b.at(2) = c.at(0).at(2) - a.at(0);

    a.at(1) = c.at(1).at(0) - b.at(0);
    a.at(2) = c.at(2).at(0) - b.at(0);

    bool result = true;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a.at(i) + b.at(j) != c.at(i).at(j)) {
          result = false;
          break;
        }
      }
    } 
    if (result) {
      yes();
      return;
    }
  }

  no();
}

int main() {
  std::vector<std::vector<ll>> c(3, std::vector<ll>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%lld", &c[i][j]);
    }
  }
  solve(std::move(c));
  return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int ans;
	ans = max(a - b, a + b);
	ans = max(ans, a*b);
	cout << ans << endl;
	return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

map<long long, long long> memo;
long long dfs(long long H) {
    if (H == 1) return 1;
    auto it = memo.find(H);
    if (it != memo.end()) return it->second;
    return memo[H] = 1 + 2 * dfs(H/2);
}

void solve(long long H) {
    cout << dfs(H) << endl;
}

int main() {
    long long H;
    scanf("%lld", &H);
    solve(H);
    return 0;
}


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

int main(void){
    int n;
    string s;
    cin>>n>>s;
    vector<char> change(n);
    rep(i, s.size()) change[i]=s[i];
    int flag=0;
    while(true){
        int cnt=0;
        rep(i, change.size()-1){
            if(change[i]=='(' && change[i+1]==')') {
                cnt++;
                if(change.size()==2) {
                    flag=1;
                    break;
                }
                change.erase(change.begin()+i);
                change.erase(change.begin()+i);
                i=0;
            }
        }
        if(cnt==0 || flag==1) break;
    }
    int l=0;
    int r=0;
    rep(i, change.size()){
        if(change[i] == '(') r++;
        else l++;
    }
    if(flag){
        l=0;
        r=0;
    }
    rep(i, l) cout<<'(';
    cout<<s;
    rep(i, r) cout<<')';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
typedef double weight;
struct edge
{
	int to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

typedef vector<edge> Edges;
typedef vector<Edges> Graph;
//int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int h, w;
int ind(int x, int y, int t) { return h*w*t + h*y + x; }
int edx[] = { 0, 1, 1, 0, -1, -1 }, edy[] = { 1, 0, -1, -1, -1, 0 };
int odx[] = { 0, 1, 1, 0, -1, -1 }, ody[] = { 1, 1, 0, -1, 0, 1 };

void dijkstra(Graph &g, vector<weight> &d, int s)
{
	d.assign(g.size(), INF);
	d[s] = 0;
	typedef pair<weight, int> P;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty())
	{
		weight dist = que.top().first;
		int v = que.top().second;
		que.pop();
		if (d[v] < dist) continue;
		REP(i, g[v].size())
		{
			edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}



int main()
{
	int sx, sy, gx, gy, n;
	cin >> sx >> sy >> gx >> gy >> n;
	vector<pii> v;
	REP(i, n)
	{
		int x, y;
		cin >> x >> y;
		v.push_back(pii(x, y));
	}
	int lx, ly;
	cin >> lx >> ly;
	sx += lx, sy += ly, gx += lx, gy += ly;
	h = lx * 2 + 1;
	w = ly * 2 + 1;
	vector<vi> fld(h, vi(w));
	REP(i, n)
	{
		int x = v[i].first + lx, y = v[i].second + ly;
		fld[x][y] = 1;
	}
	Graph g(h*w * 6);
	REP(t, 6)REP(i, h)REP(j, w)
	{
		if (fld[i][j] == 1) continue;
		int now = ind(i, j, t);
		REP(k, 6)
		{
			int nx = i + (abs(i-lx) % 2 ? odx[k] : edx[k]), ny = j + (abs(i-lx) % 2 ? ody[k] : edy[k]);
			if ((!valid(nx, ny, h, w))||fld[nx][ny]==1) continue;
			int next = ind(nx, ny, (t + 1) % 6);
			if (abs((i - lx)*(j - ly)*t) % 6 == k) g[now].push_back(edge{ next, 0 });
			else g[now].push_back(edge{ next, 1 });
		}
		g[now].push_back(edge{ ind(i, j, (t + 1) % 6), 1 });
	}
	vector<weight> d;
	dijkstra(g, d, ind(sx, sy, 0));
	int ans = INF;
	REP(i, 6) chmin(ans, (int)d[ind(gx, gy, i)]);
	if (ans == INF) puts("-1");
	else cout << ans << endl;
	return 0;
}

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

using namespace std;

const int P = 1000000000 + 7;
const int N = 2000 + 10;

long long dp[N];

int main() {
    int sum;    cin >> sum;
    dp[0] = 1;
    for (int i = 0; i <= sum; i++) {
        for (int j = 3; i + j <= sum; j++) {
            dp[i + j] = (dp[i] + dp[i + j]) % P;
        }
    }
    cout << dp[sum];
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

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

int main() {
  int N, N1000, N100, N10, N1;
  int eq1000_100 = 0, eq100_10 = 0, eq10_1 = 0;
  cin >> N;
  N1000 = N / 1000;
  N100 = N % 1000 / 100;
  N10 = N % 100 / 10;
  N1 = N % 10;
  if (N1000 == N100 && N100 == N10)
    cout << "Yes" << endl;
  else if (N100 == N10 && N10 == N1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
	ll x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	for (int i = 0; i < x; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < y; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < z; i++) {
		cin >> c[i];
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	vector<ll> bc(y*z);
	for (int i = 0; i < y; i++) {
		for (int j = 0; j < z; j++) {
			bc[i*z + j] = b[i] + c[j];
		}
	}
	sort(bc.begin(), bc.end());
	
	vector<ll> abc(x * min(3000ll, y*z));
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < min(3000ll, y*z); j++) {
			abc[i*min(3000ll, y*z) + j] = a[i] + bc[y*z - j - 1];
		}
	}
	sort(abc.begin(), abc.end());

	for (int i = 0; i < k; i++) {
		cout << abc[x*min(3000ll, y*z) - i - 1] << endl;
	}


	return 0;
}

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

#define bll long long
#define clr(a) memset(a,0,sizeof(a));

int N,M,t,a[10100],ans[110][110];

int main()
{
    while (scanf("%d %d",&N,&M)!=EOF)
    {
        scanf("%d",&t);
        for (int i=1;i<=t;i++) scanf("%d",&a[i]);
        int x = 0, y = 0, cnt = 1;
        clr(ans);
        for (int i=1;i<=t;i++)
        {
            while (a[i]--)
            {
                ans[y][x] = i;
                x += cnt;
                if (x == M) 
                {
                    cnt = -1;
                    x += cnt;
                    y++;
                }
                else
                    if (x == -1)
                    {
                        cnt = 1;
                        x += cnt;
                        y++;
                    }
            }
        }
        for (int i=0;i<N;i++)
        {
            for (int j=0;j<M;j++) printf("%d ",ans[i][j]);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 384