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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

vector<vector<int>> v(111111);

int dfs(int now, int pre, int s, int t){
	if(now == s)return 1;
	if(now == t)return 0;
	REP(i, v[now].size())if(v[now][i] != pre)return dfs(v[now][i], now, s, t);
	return 0;
}

int checkForm(int s, int t){
	int ret = 0;
	REP(i, 4)ret += dfs(v[s][i], s, s, t);
	return ret;
}

int main(){

	int n, m;cin >> n >> m;
	REP(i, m){
		int a, b;cin >> a >> b;
		a--;b--;
		v[a].EB(b);
		v[b].EB(a);
	}

	vector<int> four;
	int six = 0;

	REP(i, n){
		if(v[i].size() % 2){
			cout << "No" << endl;
			return 0;
		}

		if(v[i].size() == 4)four.PB(i);
		if(v[i].size() > 4)six++;
	}

	if(six > 0 || four.size() > 2){
		cout << "Yes" << endl;
		return 0;
	}

	if(four.size() == 2 && checkForm(four[0], four[1]) == 2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

const string YES = "Yes";
const string NO = "No";





struct  Combination{
  vector<ll> con;
  vector<ll> coni;
  ll n;
  ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
  }

  Combination(ll input){
    n=input;
    con.push_back(1);
    coni.push_back(1);
    rep(i,n){
      con.push_back(con[i]*(i+1)%MOD);
      coni.push_back(coni[i] * mpow(i+1,MOD-2) % MOD);
    }
  }
  
  ll comb(ll N, ll k){
    if(N == 0 && k == 1)return 1;
    if(N < k || k < 0)return 0;
    ll tmp=con[N]*coni[k]%MOD;
    return tmp*coni[N-k]%MOD;
  }
};

void solve(std::string S){
  map<char,int> a;
  rep(i,4){
    a[S[i]]++;
  }
  if(a.size()!=2){
    op(NO);
    return;
  }else {
    for(auto it:a){
      if(it.SE!=2){
        op(NO);
        return;
      }
    }
  }
  if(S[0]==S[1]&&S[1]==S[2]&&S[2]==S[3]){op(NO)return;}
  op(YES)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include"stdio.h"
main()
{int n,a[100],sum=0,j,t,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
sum=sum+a[i];
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j]) t=a[i],a[i]=a[j],a[j]=t; 
for(i=0;i<n;i++)
{if(a[i]%10==0) continue;
if(sum%10==0) sum=sum-a[i];
else break;}
if(sum%10==0) printf("%d\n",0);
else printf("%d\n",sum);
}

Measured memory_bytes: 128
#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() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll d=c-a-b;
    if (d>0 && 4*a*b<d*d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

const int maxn = 120000;
int n;
char z[maxn];
char s[maxn];
bool check ( int a , int b ) {
	int i , tot;
	if ( a == 1 ) s[1] = 'S';
	else s[1] = 'W';
	if ( b == 1 ) s[2] = 'S';
	else s[2] = 'W';
	for ( i = 3 ; i <= n ; i++ ) {
		if ( s[i-1] == 'S' ) {
			if ( z[i-1] == 'o' ) s[i] = s[i-2];
			else s[i] = s[i-2]=='S'?'W':'S';
		}
		else {
			if ( z[i-1] == 'o' ) s[i] = s[i-2]=='S'?'W':'S';
			else s[i] = s[i-2];
		}
	}
	tot = 0;
	if ( z[1] == 'o' ) {
		if ( s[1] == 'S' && s[2] == s[n] ) tot++;
		if ( s[1] == 'W' && s[2] != s[n] ) tot++;
	}
	else {
		if ( s[1] == 'S' && s[2] != s[n] ) tot++;
		if ( s[1] == 'W' && s[2] == s[n] ) tot++;
	}
	if ( z[n] == 'o' ) {
		if ( s[n] == 'S' && s[1] == s[n-1] ) tot++;
		if ( s[n] == 'W' && s[1] != s[n-1] ) tot++;
	}
	else {
		if ( s[n] == 'S' && s[1] != s[n-1] ) tot++;
		if ( s[n] == 'W' && s[1] == s[n-1] ) tot++;
	}
	if ( tot == 2 ) return true;
	return false;
}
void work () {
	int i;
	scanf ( "%d" , &n );
	scanf ( "%s" , z + 1 );
	if ( check ( 1 , 1 ) == true ) {
		printf ( "%s\n" , s + 1 );
	}
	else {
		if ( check ( 1 , 2 ) == true ) {
			printf ( "%s\n" , s + 1 );
		}
		else {
			if ( check ( 2 , 1 ) == true ) {
				printf ( "%s\n" , s + 1 );
			}
			else {
				if ( check ( 2 , 2 ) == true ) {
					printf ( "%s\n" , s + 1 );
				}
				else printf ( "-1\n" );
			}
		}
	}
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

int main() {
    std::string N;
    std::cin >> N;
    
    int Sn = 0;
    for (auto itr = N.rbegin(); itr != N.rend(); itr++) {
        Sn += (*itr - '0');
    }
    
    if (std::stoi(N) % Sn == 0)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min((a * n), b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
 
int main () {
    int N,K;
    cin >> N >> K;

    vector <int>l(N);
    rep(i,N){
        cin >> l[i];
    }

    sort(l.begin(),l.end(),greater<int>());

    int ans =0;
    rep(i,K){
        ans += l[i];
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P2;
struct SegTree{
private:
  ll n;
  vector<ll> node;
public:
  SegTree(vector<ll> v){
    ll sz=v.size();
    n=1;
    while(n<sz) n*=2;
    node.resize(2*n+5,0);
    for(ll i=0;i<sz;i++) node[i+n-1]=v[i];
    for(ll i=n-2;i>=0;i--) node[i]=node[2*i+1]+node[2*i+2];
  }
  void update(ll x,ll val){
    x+=(n-1);
    node[x]+=val;
    while(x>0){
      x=(x-1)/2;
      node[x]+=val;
    }
  }
  ll getsum(ll a,ll b,ll k=0,ll l=0,ll r=-1){
    if(r<0) r=n;
    if(r<=a||b<=l) return 0;
    if(a<=l&&r<=b) return node[k];
    return getsum(a,b,2*k+1,l,(l+r)/2)+getsum(a,b,2*k+2,(l+r)/2,r);
  }
  void debug(){
    for(int i=0;i<node.size();i++) cout<<node[i]<<" ";
    cout<<endl;
  }
};
int main(){
  ll q;
  cin>>q;
  vector<P2> qr;
  vector<P> upd;
  vector<ll> k(200005,0);
  SegTree cnt=SegTree(k),val=SegTree(k);
  vector<P> comp;
  ll num=1;
  for(ll i=0;i<q;i++){
    ll f;
    cin>>f;
    if(f==1){
      ll a,b;
      cin>>a>>b;
      comp.push_back(P(a,num));
      num++;
      upd.push_back(P(a,b));
      qr.push_back(P2(f,P(a,b)));
    }
    else{
      qr.push_back(P2(f,P(0,0)));
    }
  }
  sort(comp.begin(),comp.end());
  //for(int i=0;i<comp.size();i++){cout<<comp[i].first<<" "<<comp[i].second<<endl;}
  vector<ll> idx(200005,0);
  vector<ll> aidx(200005,0);
  for(ll i=0;i<comp.size();i++){
    idx[comp[i].second]=i+1;
    aidx[i+1]=comp[i].first;
  }
  ll num2=1;
  ll tei=0;
  for(int i=0;i<q;i++){
    if(qr[i].first==1){
      int id=idx[num2];
      num2++;
      cnt.update(id,1);
      val.update(id,qr[i].second.first);
      tei+=qr[i].second.second;
    }
    else{
      ll lb=0,rb=comp.size()+1;
      while(rb-lb>1){
        ll mid=(lb+rb)/2;
      //  cout<<mid<<" "<<cnt.getsum(0,mid+1)<<"/";
        if(cnt.getsum(0,mid+1)<num2/2) lb=mid;
        else rb=mid;
      }

      ll ans=tei;
      ans+=val.getsum(rb+1,comp.size()+1);
      ans-=val.getsum(0,rb);
      if(num2%2==1) ans-=aidx[rb];
    //  cout<<tei<<" "<<val.getsum(lb+1,comp.size()+1)<<" "<<val.getsum(0,lb)<<" ";
      cout<</*rb<<" "<<*/aidx[rb]<<" "<<ans<<endl;
    }
  }
}


Measured memory_bytes: 27076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, int> c;
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += c[i - a];
        c[i + a]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20680
// inputに入力データ全体が入る
function Main(input) {
  var ans = 'No';
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.trim().split("\n");
  var [N] = input[0].split(" ").map((n) => parseInt(n));
  var data = input.slice(1)

  let cnt = 0
  for (let i = 0; i < data.length; i++) {
    let tmp = data[i].split(" ").map(n => parseInt(n))    
    if (tmp[0] == tmp[1])  {
      cnt++
      if (cnt >= 3) {
        ans = 'Yes'
        break
      }
    } else {
      cnt = 0
    }
  }

  console.log(ans);
}
// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input.txt", "utf-8"));


Measured memory_bytes: 29692
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	
	if (K % 2 == 0) {
		cout << A - B << endl;
	}
	else {
		cout << -A + B << endl;
	}

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> l(m),r(m);
  int i;
  for(i=0;i<m;i++){
    cin >> l.at(i) >> r.at(i);
  }
  int mini=1000000,maxi=0;
  for(i=0;i<m;i++){
    maxi=max(maxi,l.at(i));
    mini=min(mini,r.at(i));
  }
 
  cout << max(0,mini-maxi+1);
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String x = sc.next();
      String y = sc.next();
      if(x.equals(y)){
        System.out.println("=");
      	return;
      }
     
      System.out.println(x.compareTo(y) > 0 ? ">" : "<");
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
const int inf = 100100100;

int op(int a, int b){return max(a,b);}
const int MAXA = 300005;
int e(){return 0;}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  segtree<int, op, e> dp(MAXA);

  rep(i,n){
    int x = a[i];
    int l = x-k;
    int r = x+k+1;
    l = max(0,l);
    r = min(MAXA, r);
    int now = dp.prod(l,r)+1;
    dp.set(x,now);
  }
  int ans = dp.prod(0,MAXA);
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};

vector<int> howmany(int n,int k){
  vector<int> res;
  for(int i = 1;i*k <= n;i++){
    res.push_back(i*k);
  }
  return res;
}

int main(){
  
  int n;
  cin >> n;
  vector<int> count;
  vector<int> v(n+1);
  v[0] = -1;
  REP(i,n+1)if(i != 0)cin >> v[i];
  vector<int> u(n+1,0);
  for(int i = n;i > 0;i--){
    vector<int> cd = howmany(n,i);
    int eoro = 0;
    for(auto au : cd){
      if(u[au])eoro = 1 - eoro;
    }
    if(eoro != v[i])u[i]++,count.push_back(i);
  }
  if(!count.empty()){
    cout << count.size() << endl;
    REPD(i,(count.size()))cout << count[i] << " ";
  }else{
    cout << 0 << endl;
  }



  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';
bool check(string s, int size){
  for(int i = 0; i < size/2;i++){
    if(s[i] != s[size-1-i]){
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string get;
  int size;
  cin >> get;
  size = get.length();
  if(check(get,size)){
    if(get[0]==get[(size-1)/2-1] && get[(size+3)/2-1] == get[size-1])
      cout << "Yes";
    else
      cout << "No";
  }
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Random;
public class Main 
{
    public static void main(String[] args) 
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(2, in, out);
        out.close();
    }

    static class TaskC 
    {
        static boolean prime(int n)
        {
            for(int i=2;i<=Math.sqrt(n);i++)
            {
                if(n%i==0)
                {
                    return false;
                }
            }
            return true;
        }

        static void reverse(long[] a,long start,long end)
        {
            long temp = 0;
            while(start<end)
            {
                temp = a[(int)start];
                a[(int)start] = a[(int)end];
                a[(int)end] = temp;
                start++;
                end--;
            }
        }


   
        
        public void solve(int testNumber, Scanner in, PrintWriter out) 
        {
            long t = in.nextLong();
            long x = in.nextLong();
            long max = Math.max(t,x);
            if(max==t)
            {
                t-=1;

                System.out.println(max+Math.max(t,x));
            }
            else
            {
                x-=1;
                System.out.println(max+Math.max(x,t));
            }
        }


      
        
        
        static long maxdiff(long[] arr,long size)
        {
            long max = arr[1]-arr[0];
            long min = arr[0];
            for(int i=1;i<(int)size;i++)
            {
                if(arr[i]-min>max)
                {
                    max = arr[i]-min;
                }
                if(arr[i]<min)
                {
                    min = arr[i];
                }

            }
            return max;
        }

                
    }

}

Measured memory_bytes: 23764
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll M=1e9+7;
const ll MAXN=1000200;
ll i,j,mask,test;
ll mod(ll x){
   return ((x%M + M)%M);
}
ll add(ll a,ll b){
  return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
  return mod(mod(a)*mod(b));
}
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n;
cin>>n;
vector<pair<ll,ll> > v(n);
F(i,0,n)
{
    cin>>v[i].first>>v[i].second;
}
ll f=1;
F(i,0,n-2)
{
    f=1;
    F(j,i,i+3)
    {
        if(v[j].first!=v[j].second)
        {
            f=0;
            break;
        }
    }
    if(f==1)
    {
        break;
    }
}
if(f==1)
{
    cout<<"Yes";
}
else
    cout<<"No";
return 0;
}


Measured memory_bytes: 3656
N = int(input())
options = set()
blues = []
for i in range(N):
    card = input()
    blues.append(card)
    options.add(card)

M = int(input())
reds = []
for i in range(M):
    reds.append(input())

max_p = 0
for card in options:
    p = 0
    for blue in blues:
        if card == blue:
            p += 1
    for red in reds:
        if card == red:
            p -= 1
    max_p = max(p, max_p)

print(max_p)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

int main() {
    string str,S;
    cin >> str >> S;
    ll tmp = -1;

    if(str.size() < S.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;        
    }

    for(int i = 0; i <= ll(str.size()) - ll(S.size()); i++){
        bool flag = true;
        for(int j = 0; j < ll(S.size()); j++){
            if(str[i + j] == '?' || str[i + j] == S[j] ){
            }
            else{
                flag = false;
            }
        }
        if(flag){
            tmp = i;
        }
    }
    if(tmp == -1){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    else{
        for(int i = tmp; i < tmp + ll(S.size()); i++){
            str[i] = S[i - tmp];
        }
        for(int i = 0; i < ll(str.size()); i++){
            if(str[i] == '?'){
                str[i] = 'a';
            }
        }
    }
    cout << str << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

typedef struct war{
  int a;
  int b;
}War;

//昇順
int acs(const void *a, const void *b) {
  if (((War *)a)->a == ((War *)b)->a) return ((War *)a)->b - ((War *)b)->b;
  return ((War *)a)->a - ((War *)b)->a;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  War w[m];
  for (int i=0; i<m; i++) scanf("%d%d", &(w[i].a), &(w[i].b));
  int ans = 1, min = w[0].b;
  qsort(w, m, sizeof(War), acs);
  for (int i=0; i<m; i++) {
    if (w[i].a < min) {
      min = (min > w[i].b) ? w[i].b : min;
      continue;
    }
    ans++;
    min = w[i].b;
  }
  printf("%d\n", ans);
  return 0;
}


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

vector<int>x[11];
int X[11][5000];
int dp[11][5000];
int n, k, a, b;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		x[b].push_back(a);
	}
	for (int i = 1; i <= 10; i++) {
		sort(x[i].begin(), x[i].end());
	}
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= x[i].size(); j++) {
			X[i][j] = X[i][j - 1] + x[i][x[i].size() - j];
		}
	}
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= x[i].size(); j++) {
			X[i][j] += (j - 1)*j;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= 10; i++) {
		for (int j = 0; j < 3000; j++) {
			for (int k = 0; k <= x[i].size(); k++) {
				dp[i][j + k] = max(dp[i][j + k], max(dp[i - 1][j + k], dp[i - 1][j] + X[i][k]));
			}
		}
	}
	cout << dp[10][k] << endl;
	return 0;
}

Measured memory_bytes: 1460
#include<stdio.h>
int x=1;
int y=1;
int f=0;
int c[40],d[40]={0};
int a,b;
int z;
int memo[101][101]={0};
int miti(int x,int y);
int main(){
  int e=0;
  int g=0;
  int ans=0;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)break;
    scanf("%d",&f);
    for(e=0;e<f;e++){
      scanf("%d %d",&c[e],&d[e]);
    }
    ans=miti(x,y);
    printf("%d\n",ans);
    x=1;
    y=1;
    ans=0;
    for(e=0;e<40;e++){
    c[e]=0;
    d[e]=0;
    }
    for(e=0;e<100;e++){
      for(g=0;g<100;g++){
	memo[e][g]=0;
      }
    }
  }
  return 0;
}
int miti(int x,int y){
  for(z=0;z<f;z++){
    if(x==c[z]&&y==d[z]){
      return 0;
    }
  }
  if(memo[x][y]!=0){
    return memo[x][y];
  }
  if(x==a&&y==b){
    return memo[x][y]=1;
  }
  else if(x==a){
    return memo[x][y]=miti(x,y+1);
  }
  else if(y==b){
    return memo[x][y]=miti(x+1,y);
  }
  else{
    return memo[x][y]=miti(x+1,y)+miti(x,y+1);
  }
}

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

const int maxn = 2010;
int H, W, f[maxn][maxn], pre[maxn], suf[maxn];
char s[maxn][maxn];
bool chk[maxn][maxn];

int main() {
    scanf("%d %d", &H, &W);
    for (int i = 1; i <= H; i++) {
        scanf("%s", s[i] + 1);
        for (int j = 1; j <= W; j++) {
            if (i > 1 && j > 1) {
                int cnt = (s[i][j] == '.') + (s[i - 1][j] == '.') +
                    (s[i][j - 1] == '.') + (s[i - 1][j - 1] == '.');
                if (cnt & 1) chk[i - 1][j - 1] = 1;
            }
        }
    }
    H--, W--;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            f[i][j] = chk[i][j] ? 0 : (f[i - 1][j] + 1);
        }
    }
    int ans = max(H + 1, W + 1);
    for (int i = 1; i <= H; i++) {
        stack<int> st;
        f[i][0] = f[i][W + 1] = -1;
        st.push(0);
        for (int j = 1; j <= W; j++) {
            while (f[i][st.top()] >= f[i][j]) st.pop();
            pre[j] = st.top(), st.push(j);
        }
        while (!st.empty()) st.pop();
        st.push(W + 1);
        for (int j = W; j; j--) {
            while (f[i][st.top()] >= f[i][j]) st.pop();
            suf[j] = st.top(), st.push(j);
        }
        for (int j = 1; j <= W; j++) {
            ans = max(ans, (f[i][j] + 1) * (suf[j] - pre[j]));
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 27340
#include<cstdio>
#include<iostream>
#include<math.h>
#include<stdlib.h> 
using namespace std;
#define Max 100
#define nan -1
struct node{int p,l,r;};
int num;
node tree[Max];
int depth[Max];
int height[Max];
void cal_deep(int p,int u){
	depth[p]=u;
	if(tree[p].l!=nan) cal_deep(tree[p].l,u+1);
	if(tree[p].r!=nan) cal_deep(tree[p].r,u+1);
	return;
}
int  cal_height(int p){
	int h1=0;int h2=0;
	if(tree[p].r!=nan) h1=cal_height(tree[p].r)+1;
	if(tree[p].l!=nan) h2=cal_height(tree[p].l)+1;
	int h=max(h1,h2);
	height[p]=h;
    return h;
}
void print(){
	for(int i=0;i<num;i++){
		cout<<"node "<<i<<": parent = "<<tree[i].p<<", sibling = ";
		if(tree[i].p!=nan&&tree[tree[i].p].l!=i&&tree[tree[i].p].l!=nan) cout<<tree[tree[i].p].l;
		else if(tree[i].p!=nan&&tree[tree[i].p].r!=i&&tree[tree[i].p].r!=nan) cout<<tree[tree[i].p].r;
		else cout<<"-1";
		cout<<", degree = ";
		int degree=0;
		if(tree[i].l!=nan) degree++;
		if(tree[i].r!=nan) degree++;
		cout<<degree<<", depth = "<<depth[i]<<", height = "<<height[i]<<", ";
		string a;
		if(tree[i].p==nan) a="root";
		else if(tree[i].r==nan&&tree[i].l==nan) a="leaf";
		else a="internal node";
		cout<<a<<endl;
	}
}
int main(){
	scanf("%d",&num);
	for(int i=0;i<num;i++){tree[i].l=tree[i].r=tree[i].p=nan;}
	for(int i=0;i<num;i++){
		int v,l,r;
		scanf("%d %d %d",&v,&l,&r);
		if(r!=-1){tree[v].r=r;tree[r].p=v;}
		if(l!=-1){tree[v].l=l;tree[l].p=v;}
	}
	int root;
	for(int i=0;i<num;i++){
		if(tree[i].p==nan){
			root=i;break;
		}
	}
	cal_deep(root,0);
	cal_height(root);
	print();
}



Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 64;
ll f[N][10];
ll k;
void init()
{
    for (int i = 0; i <= 9; i ++ ) f[1][i] = 1;

    for (int i = 2; i < N; i ++ )
        for (int j = 0; j <= 9; j ++ )
            for (int k = 0; k <= 9; k ++ )
                if (abs(j - k) <= 1)
                    f[i][j] += f[i - 1][k];
}

ll dp(ll n)
{
    if (!n) return 0;

    vector<int> nums;
    while (n) nums.push_back(n % 10), n /= 10;

    ll res = 0;
    ll last = -1;
    for (int i = nums.size() - 1; i >= 0; i -- )
    {
        int x = nums[i];
        if (x)
        {
            for (int j = 1; j < x; j ++ )
                if (abs(last - j) <= 1 || last == -1)
                    res += f[i + 1][j];
            if (i != nums.size() - 1)
                if (abs(last - 0) <= 1)
                    res += f[i + 1][0];
        }

        if (last != -1 && abs(last - x) > 1) break;
        last = x;

        if (!i) res ++ ;
    }

    for (int i = 1; i < nums.size(); i ++ )
        for (int j = 1; j <= 9; j ++ )
            res += f[i][j];

    return res;
}

int main() {
    init();
    cin >> k;
    ll l = 1;
    ll r = 0x3f3f3f3f3f3f3f3f;
    ll res = -1;
    while(l <= r) {
        ll mid = (l + r) / 2;
        if(dp(mid) >= k) {
            res = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,K,A[200001],M;
int main(){
  cin>>K>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  M=A[N-1]-A[0];
  for(int i=1;i<N;i++)M=min(M,K-A[i]+A[i-1]);
  cout<<M<<endl;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = 7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        string s = to_string(n);
        int m = s.length();
        int num = 0;
        int mark[n]= {};
        for(int i=0;i<m;i++)num*=10LL,num%=n,num+=7LL,num%=n;
        for(int i=m;;i++)
        {
            if(!num)return cout<<i,0;
            if(mark[num])return cout<<-1,0;
            mark[num]++;
            num *= 10LL;
            num %= n;
            num += 7LL;
            num %= n;
        }
    }
    return 0;
}


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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	long long n, m;
	cin >> n >> m;


	long long  zx = min(n, m / 2);
	long long  left = n - zx;
	long long  right = m - (zx * 2);
	if (right == 0)
	{
		cout << zx << endl;
	}
	else {
		cout << zx + (right / 4) << endl;
	}


	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> a2(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    a2[i]=a[i];
  }
  int max,max2;
  max=0;
  max2=0;
  /*  for(int i=0;i<n;i++){
    if(a[i]>max){
      max=a[i];
      max2=max;
    }
  }*/
  sort(a2.begin(),a2.end());
    for(int i=0;i<n;i++){
      if(a[i]==a2[n-1]){
	cout<<a2[n-2]<<endl;
      }
      else{
	cout<<a2[n-1]<<endl;
      }
    }
  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
int main(){
    char a[8][8];
    for(int i=0;i<8;i++){
        scanf("%s",a[i]);
    }
    printf("90\n");
    for(int j=0;j<8;j++){
        for(int i=7;i>=0;i--){
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
    printf("180\n");
    for(int i=7;i>=0;i--){
        for(int j=7;j>=0;j--){
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
    printf("270\n");
    for(int j=7;j>=0;j--){
        for(int i=0;i<8;i++){
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

const ll INF = 1LL << 60;

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

/*
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

void Main()
{
	int N;
	cin >> N;

	ll h[100010];
	for (int i = 0; i < N; ++i) {
		std::cin >> h[i];
	}

	ll dp[100010];
	for (int i = 0; i < 100010; ++i) {
		dp[i] = INF;
	}

	dp[0] = 0;
	for (int i = 1; i < N; ++i) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) {
			chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}

	cout << dp[N - 1];
	return;
}

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

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
   int A,B,M;
   cin >> A >> B >> M;
  vector<int> a(A),b(B);
   rep(i,A){
     cin >> a[i];
   }
   rep(i,B){
     cin >> b[i];
   }
   vector<int> x(M),y(M),c(M);
   rep(i,M){
     cin >> x[i] >> y[i] >> c[i];
   }

   int mina = 10000000;
   int minb = 10000000;
   rep(i,A){
     mina = min(mina,a[i]);
   }
   rep(i,B){
     minb = min(minb,b[i]);
   }
   int ans = mina + minb;
   
   rep(i,M){
     int res = a[x[i]-1] + b[y[i]-1] - c[i];
     ans = min(ans,res);
   }
   cout << ans << endl;
 }

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

int data[510][510];
int main(){
	int n;
	int m;
	while(cin>>n>>m &&n&&m){
		fill_n((int*)data,510*510,0);
		set<int>ans;
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			data[x][y]=data[y][x]=1;
		}
		
		for(int i=1;i<=n;i++){
			if(data[1][i]==1){
				ans.insert(i);
				for(int j=2;j<=n;j++){
					if(data[i][j]==1)ans.insert(j);
				}
			}
		}
		cout<<ans.size()<<endl;
	}
}

Measured memory_bytes: 2228
/*

*/ 
//计数->期望/概率->独立 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inv_2=5e8+4;
const int N=3005;
int dp[N][N],a[N],x,y,ans,n,q;
void up(int &x,int y){x=x-mod+y;x=(x<0)?x+mod:x;}
int ksm(int x,int y)
{
	int res=1;
	while (y)
	{
		if (y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}
	return res;
}
void SWAP(int x,int y)
{
	for (int i=1;i<=n;i++)
	{
		if (i==x||i==y)
		{
			dp[x][y]=dp[y][x]=(ll)(dp[x][y]+dp[y][x])*inv_2%mod;
		}else{
			dp[i][x]=dp[i][y]=(ll)(dp[i][x]+dp[i][y])*inv_2%mod;
			dp[x][i]=dp[y][i]=(ll)(dp[x][i]+dp[y][i])*inv_2%mod;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&q);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
	  for (int j=1;j<=n;j++) dp[i][j]=a[i]>a[j];
	for (int i=1;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		if (x>y) swap(x,y);
		SWAP(x,y);
	}	
	int t=ksm(2,q);
	for (int i=1;i<=n;i++)
	  for (int j=i+1;j<=n;j++) up(ans,(ll)dp[i][j]*t%mod);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 35584
h,w = map(int, input().split())
fd = [list(input()) for i in range(h)]
	
dy = [1,0,-1,0,1,-1,1,-1]
dx = [0,1,0,-1,1,1,-1,-1]

for y in range(h):
	for x in range(w):
		if fd[y][x] == '#':
			continue
		c = 0
		
		for k in range(8):
			ny = y + dy[k]
			nx = x + dx[k]
			
			if ny < 0 or h <= ny or nx < 0 or w <= nx:
				continue
				
			if fd[ny][nx] == '#':
				c += 1
		fd[y][x] = str(c)
		
for y in range(h):
	print(''.join(fd[y]))


Measured memory_bytes: 3188
n = gets.to_s.to_i
s = gets.to_s.chomp.chars

cnt = 0
n.times do |i|
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    cnt += 1 if s[i] != s[j] && s[j] != s[k] && s[i] != s[k]
    t += 1
  end
end

ans = s.count('R') * s.count('G') * s.count('B') - cnt

puts ans

Measured memory_bytes: 14224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#define inf 2139062143   //2147483647.
#define mod 1000000007
using namespace std;
long long x,y,k=1,a;
int main(){
	scanf("%lld%lld",&x,&y);
	a=x;
	while(1){
		a*=2;
		if(a>y){
			printf("%lld\n",k);
			return 0;
		}
		k++;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	ok := true
	cFound := false
	for i, c := range s {
		if i == 0 {
			if c != 'A' {
				ok = false
				break
			}
		} else {
			if 2 <= i && i <= len(s)-2 {
				if c == 'C' {
					if cFound {
						ok = false
						break
					} else {
						cFound = true
						continue
					}
				}
			}
			if c < 'a' || 'z' < c {
				ok = false
				break
			}
		}
	}

	if ok && cFound {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


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

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

  vector< int > a(n + 1), b(n);

  for(auto &&s : a) {
    cin >> s;
  }
  for(auto &&s : b) {
    cin >> s;
  }

  ll sum = 0, diff = 0;
  for(int i = 0; i < n; i++) {
    if(b.at(i) + diff < a.at(i)) {
      sum += b.at(i)+diff;
      diff = 0;
    } else {
      diff = b.at(i) - (a.at(i) > diff ? a.at(i) - diff : 0);
      sum += a.at(i);
    }
  }

  cout << sum + (a.at(n) > diff ? diff : a.at(n)) << endl;
}


Measured memory_bytes: 1024
A, B, C = map(int, input().split())
K = int(input())

M = max(A, B, C)

SUM = M*(2**K)


if M == A:
	ADD=(B+C)
elif M == B:
	ADD=(A+C)
elif M == C:
	ADD=(A+B)

print(SUM+ADD)


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B, C, D; cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_ = 1001001;
int N, M, K;
vector<int> f[MAX_];
vector<int> b[MAX_];
int group[MAX_];
int group_size[MAX_];

void dfs() {
    vector<bool> color(N, false);
    for (int i = 0; i < N; ++i) {
        if (color[i]) continue;
        stack<int> s;
        s.push(i);
        color[i] = true;
        while(!s.empty()) {
            int p = s.top(); s.pop();
            group[p] = i;
            group_size[i]++;
            for (int np: f[p]) {
                if (color[np]) continue;
                color[np] = true;
                s.push(np);
            }
        }
    }
}

void solve() {
    cin >> N >> M >> K;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        f[a-1].push_back(b-1);
        f[b-1].push_back(a-1);
    }
    for (int i = 0; i < K; ++i) {
        int c, d;
        cin >> c >> d;
        b[c-1].push_back(d-1);
        b[d-1].push_back(c-1);
    }
    dfs();
    for (int i = 0; i < N; ++i) {
        int g_i = group[i];
        int g_size = group_size[g_i];
//        printf( "i: %d, g_i: %d, g_size: %d\n", i+1, g_i+1, g_size );
        int b_size = 0;
        for (int j = 0; j < b[i].size(); ++j) {
            int b_i = b[i][j];
            if (group[b_i] == g_i) b_size++;
        }
        int ans = g_size;
        ans -= 1;
        ans -= (f[i].size() + b_size);
        printf("%d ", (ans < 0 ? 0 : ans));
//        cout << endl;
    }
    cout << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 59992
x = int(input())
li,p,ans = [],1,0

for b in range(2,int(x**0.5//1)+1):
    while b**p<=x:
        ans = max(ans,b**p)
        p += 1
        li.append(b**(p-1))
        if b**p>x:
            p = 1
            break
if x <= 3:
    print(x)
else:
    print(max(li))

Measured memory_bytes: 3188
n, m = map(int, input().split())
q = [list(map(int, input().split())) for _ in range(m)]

for i in range(10**n + 1):
    i = str(i)
    if len(i) != n:
        continue

    flag = True
    for a_list in q:
        rank = a_list[0] - 1
        num = a_list[1]
        if int(i[rank]) != num:
            flag = False
            break

    if flag:
        print(i)
        exit()

print(-1)


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

int main() {
	int N, K;
	string S;
	cin >> N >> S >> K;
	char ch = S[K - 1];
	for (int i = 0; i < N; i++) {
		if (S[i] != ch) {
			S[i] = '*';
		}
	}
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int H,W;
bool exist(char c,set<char> &head,vector<string> &grid){
  int begin=100,end=-1;
  int ybegin=100,yend=-1;
  REP(y,H)REP(x,W)if(grid[y][x]==c)begin = min(begin,x),end = max(end,x)
    ,ybegin=min(ybegin,y),yend=max(yend,y);
  FOR(y,ybegin,yend+1)FOR(x,begin,end+1)if(grid[y][x]!=c&&head.find(grid[y][x])==head.end()) return false;
  return true;
}

int main(void){
  int n;
  cin>>n;
  while(n--){
    cin>>H>>W;
    vector<string> grid(H);
    set<char> mat;
    set<char> head;
    REP(i,H)cin>>grid[i];
    REP(y,H)REP(x,W)if(grid[y][x]!='.')mat.insert(grid[y][x]);
    bool ans = true;
    while(!mat.empty()){
      bool f= false;
      set<char>::iterator it = mat.begin();
      for(;it!=mat.end();it++){
        if(exist(*it,head,grid)){
          f = true;
          head.insert(*it);
          mat.erase(it);
          break;
        }
      }
      if(!f){
        ans = false;
        break;
      }
    }
    if(!ans) cout<<"SUSPICIOUS"<<endl;
    else cout<<"SAFE"<<endl;
  }
    

  return 0;
}

Measured memory_bytes: 928
#include<stdio.h>
#include<math.h>
int main(){
  int n;
  double x;
  while(scanf("%d",&n),n+1){
    x=n/2.0;
    while(fabs(x*x*x-n)>0.00001*n){
      x=x-(x*x*x-n)/(3*x*x);
    }
    printf("%f\n",x);
  }
  return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int c[3][3];

bool inline check(int x, int b1, int b2, int b3) {
    return (c[x][0]-b1) == (c[x][1]-b2) && (c[x][1]-b2) == (c[x][2]-b3);
}

int main() {
    REP(i, 3) REP(j, 3) {
        std::cin >> c[i][j];
    }

    int b1m = std::min(c[0][0], std::min(c[1][0], c[2][0]));
    int b2m = std::min(c[0][1], std::min(c[1][1], c[2][1]));
    int b3m = std::min(c[0][2], std::min(c[1][2], c[2][2]));
    for(int b1=0; b1<=b1m; ++b1) {
        for(int b2=0; b2<=b2m; ++b2) {
            for(int b3=0; b3<=b3m; ++b3) {
                if(check(0, b1, b2, b3) && check(1, b1, b2, b3) && check(2, b1, b2, b3)) {
                    std::cout << "Yes" << std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

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

int n;
int pos;
vector<int>pre,in,post;

void rec(int l, int r){
  if(l >= r) return;
  int root = pre[pos++];
  int m = distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}





void solve(){
  pos=0;
  rec(0,pre.size());
  for(int i=0; i<n; i++){
    if(i) cout << " ";
    cout << post[i];
  }
  cout << endl;
}




int main(){
  int k;
  cin >> n;

  for(int i=0; i<n; i++){
    cin >> k;
    pre.push_back(k);
  }
  for(int i=0; i<n; i++){
    cin >> k;
    in.push_back(k);
  }
  
  solve();
  
  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int v = 10;
int d[10][10] = {};
void warshallFloyd()
{

  for (int k = 0; k < v; k++)
  {
    for (int i = 0; i < v; i++)
    {
      for (int j = 0; j < v; j++)
      {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main()
{
  int h, w;
  cin >> h >> w;
  REP(i, 10)
  {
    REP(j, 10)
    {
      cin >> d[i][j];
    }
  }

  warshallFloyd();

  int result = 0;
  REP(c, h)
  {
    REP(r, w)
    {
      int a;
      cin >> a;
      if (a == -1)
        continue;
      result += d[a][1];
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 384
from heapq import heappop as hpop
from heapq import heappush as hpush

def main():
  
  while True:
    n, m = map(int, input().split())
    
    if not n:
      break
    
    cost_edges = [[] for _ in range(m)]
    time_edges = [[] for _ in range(m)]
  
    for _ in range(n):
      a, b, c, t = map(int, input().split())
      cost_edges[a - 1].append((c, b - 1))
      cost_edges[b - 1].append((c, a - 1))
      time_edges[a - 1].append((t, b - 1))
      time_edges[b - 1].append((t, a - 1))
    
    k = int(input())
  
    for _ in range(k):
      start, goal, r = map(int ,input().split())
      start -= 1
      goal -= 1
      
      if r:
        edges = time_edges
      else:
        edges = cost_edges
  
      que = [(0, start)]
      visited = [False for _ in range(m)]
      
      while True:
        score, station = hpop(que)
        visited[station] = True
        
        if station == goal:
          print(score)
          break
  
        for c, to_station in edges[station]:
          if not visited[to_station]:
            hpush(que, (score + c, to_station))

main()


Measured memory_bytes: 7364
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1005;
int h,w,a,b,s[N][N];

int main(){
	scanf("%d%d%d%d",&h,&w,&a,&b);
	
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			if(i <= b && j <= a)
				s[i][j] = 1;
			else if(i > b && j > a)
				s[i][j] = 1;
			else
				s[i][j] = 0;
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j)
			cout<<s[i][j];
		cout<<endl;
	}
}

Measured memory_bytes: 7544