akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#define eps 1e-10
using namespace std;
const int maxn = 2e5 + 10;

struct Point{
    double x,y;
    Point(double x = 0, double y = 0) : x(x),y(y){}

};

typedef Point Vector;

Vector operator + (Vector A, Vector B){return Vector(A.x + B.x, A.y + B.y);}
Vector operator - (Vector A, Vector B){return Vector(A.x - B.x, A.y - B.y);}
Vector operator * (Vector A, double p){return Vector(A.x*p, A.y*p);}
Vector operator / (Vector A, double p){return Vector(A.x/p, A.y/p);}
bool operator < (const Point& A, const Point& B){return A.x < B.x || (A.x == B.x && A.y < B.y);}

int dcmp(double x){
    if(fabs(x) < eps) return 0;
    return x < 0 ? -1 : 1;
}

bool operator == (const Point& A, const Point& B){return dcmp(A.x-B.x) == 0 && dcmp(A.y-B.y) == 0;}

double Dot(Vector A, Vector B){return A.x*B.x + A.y*B.y;}
double Length(Vector A){return sqrt(Dot(A,A));}
double Angle(Vector A, Vector B){return acos(Dot(A,B)) / Length(A) / Length(B);}
double Cross(Vector A, Vector B){return A.x*B.y - A.y*B.x;}
double Area2(Point A, Point B, Point C){return Cross(B-A,C-A);}
// 向量所在象限(点积符号,叉积符号)
Vector Rotate(Vector A, double rad){return Vector(A.x * cos(rad) - A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad));}

Point ps[maxn];

vector<Point> convex_hull(Point * ps, int n)
{
   vector<Point> hull(n * 2);
   int tp = 0;
   for(int i = 0;i < n;++i){
      while(tp > 1 && dcmp(Cross(hull[tp-1] - hull[tp-2],ps[i] - hull[tp-2])) <= 0)tp--;
      hull[tp++] = ps[i];
   }
   for(int i = n-2,t = tp;i >= 0;--i){
      while(tp > t && dcmp(Cross(hull[tp-1] - hull[tp-2],ps[i] - hull[tp-2])) <= 0) tp--;
      hull[tp++] = ps[i];
   }
   hull.resize(tp-1);
   return hull;
}

long long dist(Point p)
{
   return abs(p.x) + abs(p.y);
}

int main()
{
   int n;
   cin>>n;
   for(int i = 0;i < n;++i){
      cin>>ps[i].x>>ps[i].y;
   }
   sort(ps,ps+n);
   
   vector<Point> H = convex_hull(ps,n);
   int cnt = H.size();
   if(cnt == 2){
      printf("%lld\n",dist(H[0] - H[1]));
      return 0;
   }
   int i = 0,j = 0;
   for(int k = 0;k < cnt;++k){
      if(dcmp(H[i].x - H[k].x) > 0) i = k;
      if(dcmp(H[j].x - H[k].x) < 0) j = k; 
   }
   long long res = 0;
   int si = i,sj = j;
   while(i != sj && j != si){
      res = max(res,dist(H[j] - H[i]));
      if(dcmp(Cross(H[(i+1) % cnt] - H[i], H[(j+1) % cnt] - H[j]) < 0)){
         i = (i + 1) % cnt;
      }
      else j = (j + 1) % cnt;
   }
   printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 12896
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

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

  ll N, M;
  std::cin >> N;
  std::vector< ll > vt(N, 0LL);

  ll sum = 0LL;
  for (ll i = 0; i < N; i++) {
    std::cin >> vt[i];
    sum += vt[i];
  }

  std::cin >> M;
  for (ll i = 0; i < M; i++) {
    ll p, x;
    std::cin >> p >> x;
    p--;
    ll diff = vt[p] - x;
    std::cout << (sum - diff) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    F0R(i,n)
    {
        int elem;
        cin >> elem;
        if(elem%2==0 && (elem%3 && elem%5))
        {
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 


ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 674;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;

ll dp[100005];

void solve(int tc = 0) {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i <= k; ++i) dp[i] = 0;
	for (ll i = 0; i < n; ++i) {
		for (ll j = k - a[i]; j >= 0; --j) {
			dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]);
		}
	}
	
	ll ans = 0;
	for (int i = 0; i <= k; ++i) ans = max(ans, dp[i]);
	cout << ans << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("cowland");
	#endif
	
	// usaco("cowland");
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

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

int main(){
  int n;
  cin >> n;
  map<string, vector<P>> m;
  rep(i, n){
    string s;
    int p;
    cin >> s >> p;
    m[s].push_back(P(p, i+1));
  }
  for(auto x: m){
    sort(x.second.begin(), x.second.end(), greater<P>());
    rep(i, x.second.size()) cout << x.second[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 +7;
void add(ll& a, ll b){
  if(b<0) b += MOD;
  a = (a+b) % MOD;
}
void mul(ll& a, ll b){
  a = a*b % MOD;
}

ll modpow(ll a , ll b){
  if (b == 0) return 1;
  ll ret;
  if (b%2 == 0){
    ll  t = modpow(a, b/2)%MOD;
    ret = t*t %MOD;
  }else{
    ll t = modpow(a, (b-1)/2)%MOD;
    ret = a*t %MOD * t % MOD;
  }
  ret %= MOD;
  return ret;
}

int main() {
  string L; cin >> L;
  int d = L.size();
  
  vector<vector<ll>> dp(d+1, vector<ll>(2, 0));
  dp[0][0] = 1;

  FOR(i, 1, d+1){
    if(L[i-1] == '0'){
      dp[i][0] = dp[i-1][0];
      dp[i][1] = 3 * dp[i-1][1]% MOD;
      dp[i][1] %= MOD;
    }else{
      dp[i][0] = dp[i-1][0] * 2% MOD;
      dp[i][0] %= MOD;
      dp[i][1] = dp[i-1][1] * 3% MOD + dp[i-1][0] % MOD;
      dp[i][1] %= MOD;
    }
  }

  ll ans = dp[d][0] + dp[d][1] % MOD;
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 5760
def main():
    x = input()
    y = input()

    l = []
    for i in range(len(x)):
        s = x[-i - 1:] + x[:-i - 1]
        l.append(s)

    if y in l:
        print("Yes")
    else:
        print("No")


def main2():
    x = input()
    y = input()
    ans = False

    s = x
    for i in range(len(x)):
        if s == y:
            ans = True
            break
        s = s[-1] + s[:-1]

    if ans:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main2()


Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int i,j,p,n;
    int prime[10001]={0};

    while(scanf("%d",&n),n){

        for(i = 2;i < 10000;i++) prime[i]=1;

        for(i = 2;i <= n;i++) if(prime[i]) for(j=i+i;j<=n;j+=i) prime[j]=0;

        for(i=3;i<=n-2;i+=2) if(prime[i]) if(prime[i+2]) p=i;

        printf("%d %d\n",p,p+2);

    }   
    return 0;
}

Measured memory_bytes: 644
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from enum import Enum
#======================================================#
class State(Enum):
    UP = 1
    DOWN = 2
    HORI = 3

def main():
    n = II()
    prev, *aa = MII()
    state = State.HORI
    cnt = 1
    for a in aa:
        if prev < a:
            if state == State.HORI:
                state = State.UP
            elif state == State.DOWN:
                cnt += 1
                state = State.HORI
        elif prev > a:
            if state == State.HORI:
                state = State.DOWN
            elif state == State.UP:
                cnt += 1
                state = State.HORI
        prev = a
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14816
#include <stdio.h>
 int main(void)
  {
 char s[100000];
  int num=0,cnt=0,i;
  scanf("%s", &s);
  for(i=0;i<100000;i=i+2)
 { if(s[i]=='\0') break;
   if(s[i]!='1')
   cnt++;
  if(s[i+1]=='\0') break;
    if(s[i+1]!='0')
   cnt++;
   }
 
    for(i=0;i<100000;i=i+2)
 { if(s[i]=='\0') break;
   if(s[i]!='0')
   num++;
  if(s[i+1]=='\0') break;
    if(s[i+1]!='1')
   num++;
   }
if(num<cnt)
  printf("%d",num);
 if(num>=cnt)
  printf("%d",cnt); 
   return 0;
  }

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

char c[200000],bc[200000];
int a[200000],b[200000];


signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> c[i] >> a[i];
    bc[i] = c[i];
    b[i] = a[i];
  }

  for(int i = 0; i < n; i++){
    for(int j = n-1; j > i; j--){
      if(a[j] < a[j-1]){
        swap(c[j],c[j-1]);
        swap(a[j],a[j-1]);
      }
    }
  }

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << c[i] << a[i];
  }
  cout << endl;
  cout << "Stable" << endl;

  for(int i = 0; i < n; i++){
    int minj = i;
    for(int j = i; j < n; j++){
      if(b[j] < b[minj]){
        minj = j;
      }
    }
    swap(bc[i],bc[minj]);
    swap(b[i],b[minj]);
  }

  int f = 0;
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << bc[i] << b[i];
    if(c[i] != bc[i] || a[i] != b[i]) f = 1;
  }
  cout << endl;
  if(f) cout << "Not stable" << endl;
  else cout << "Stable" << endl;

  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
using namespace std;
int main(){
	int m,f,r,s;
	
	while(true){
		cin >> m >>f >>r;
		if(m==-1 && f==-1 && r==-1){
			break;
		}
		if(m==-1 || f== -1){
			cout << 'F' <<endl;
		}
		else { s = m+f; 
			if(s >= 80){
				cout <<'A' << endl;
			}
			else if(s>=65){
				cout <<'B' << endl;
			}
			else if(s>=50){
				cout <<'C' << endl;
			}
			else if(s>=30){
				if (r < 50){
						cout << 'D' << endl;
				}
				else {
					cout << 'C' << endl;
				}
			}
			else{
				cout <<'F' << endl;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int k;
    cin>>k;
    vector<ll>a(k);
    rep(i,k)cin>>a[i];
    a.pb(2);
    ll minv=2,maxv=2;
    for(int i=k-1;i>=0;--i){
        if((minv+a[i]-1)/a[i]*a[i]>maxv){
            cout<<-1<<"\n";
            return;
        }
        if(i<k-1){
        minv=(minv+a[i]-1)/a[i]*a[i];
        maxv=maxv/a[i]*a[i]+a[i]-1;
        }
        else {
            minv=2;maxv=3;
        }
    }
    cout<<minv<<" "<<maxv<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  string s; cin>>s;
  int k; cin>>k;
  if (s == string(s.size(), '1')) {
    print('1');
    return 0;
  }
  rep(i, s.size()) {
    if (i+1 == k) {
      print(s[i]);
      return 0;
    }
    if (s[i] != '1') {
      print(s[i]);
      return 0;
    }
  }

  return 0;
}

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

using namespace std;

int main() {
	string o;
	string e;
	cin >> o;
	cin >> e;
	int len = (int)e.size();
	int i;
	for (i = 0; i < len; i++) {
		cout << o.substr(i, 1) + e.substr(i, 1);
	}
	if ((int)o.size() - (int)e.size()) {
		cout << o.substr(i , 1);
	}
	cout << "\n";
	cin >> e;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll r, D, x;

    cin >> r >> D >> x;

    for(int i = 0; i < 10; i++){
        x = r * x - D;
        cout << x << endl;
    }


    return 0;
}


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

int main(){
    string str;
    cin>>str;
    char last;
    bool ok = true;
    for(int i = 1;i<str.size();i++){
        last = str[i-1];
        if(str[i]== last){
            ok = false;
            break;
        }
    }
    if(ok){
        cout<<"Good";
    } else{
        cout<<"Bad";
    }
    return 0;
}

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

int main() {
    char c[201];
    cin >> c;

    int n = (int)strlen(c);

    for (int k = n - 2; k > 0; k -= 2) {
        int b = 0;
        for (int i = 0; i < k / 2; i++) {
            if (c[i] != c[i + k / 2]) {
                b = 1;
                break;
            }
        }
        if (b == 0) {
            cout << k << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int, int> pll;
bool visited[100005];
const int max_N = 1e5 + 10;

char S[10];


int main(void) {
	cin >> S;
	int max = 0;
	int tmp = 0;
	for (int i = 0; i < 10; i++) {
		if (S[i] == 'A') {
			tmp++;
		}
		else if (S[i] == 'T') {
			tmp++;
		}
		else if (S[i] == 'G') {
			tmp++;
		}
		else if (S[i] == 'C') {
			tmp++;
		}
		else {
			if (tmp > max) max = tmp;
			tmp = 0;
		}
	}
	if (tmp > max) max = tmp;

	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DIV_NUM (1000000007)

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> difficulty;

    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        difficulty.push_back(tmp);
    }

    sort(difficulty.begin(), difficulty.end());

    int max_abc = difficulty[N / 2 - 1];
    int min_arc = difficulty[N / 2];

    cout << min_arc - max_abc << endl;

    return 0;
}




Measured memory_bytes: 892
n,k = map(int,input().split())

ans=[]

for i in range(n):
    a,b=map(int,input().split())
    ans.append([a,b])

ans.sort()

s=0
i=0

while s<k:
    s+=ans[i][1]
    i+=1

print(ans[i-1][0])

Measured memory_bytes: 20064
n = gets.to_i
h = gets.split.map(&:to_i)
flag = ' Yes '
res = 0
num = 0
num2 = 0

if n != 1
 for index in 0..n - 2
  if h[index] - 1 > h[index + 1]
    flag = ' No '
    break
  end
  if h[index] > h[index + 1]
    res = res + 1
    num2 = h[index + 1]
    if num < num2
      num = num2
    end
    if num > h[index + 1]   
      flag = ' No '
      break
    end
  end
 end
end
puts flag


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

#define STRING(str) #str

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

int main() {
	int T;
	cin >> T;
	for (int i=0;i<T;i++) {
		int N, M, A, B;
		cin >> N >> M >> A >> B;
		cout << floor_sum(N, M, A, B) << endl;;
	}
}

Measured memory_bytes: 3664
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let c: i32 = sc.read();
    if a == b {
        println!("{}", c);
    } else if b == c {
        println!("{}", a);
    } else {
        print!("{}", b);
    }
}

Measured memory_bytes: 4352
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iostream>



using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",a^b^c);
    return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
a=[ord(i)-ord('a') for i in s]
k=int(input())
for i in range(n):
    if a[i]+k>=26 and a[i]>0:
        k-=26-a[i]
        a[i]=0
k%=26
a[-1]+=k
a=[chr(i + ord('a')) for i in a]
print(*a,sep="")

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define ceel(x, y) ((x) / (y) + !((x) % (y) == 0))
#define ss second
#define ff first
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    fastio;
    ll n;
    cin >> n;
    cout << (n * (n + 1 + n * n));
    
    return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0, b = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R') r++;
        else if (s[i] == 'B') b++;
    }
    if(r > b) cout << "Yes";
    else cout << "No";
    
    
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int al[26];

int main() {
    string w;
    cin >> w;
    for (auto z : w)
        al[z - 'a']++;
    for (auto z : al) {
        if (z & 1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 
const int MAXN = 2e5 + 5;

ll t[4 * MAXN];

void build(int v, int tl, int tr, vi &a) {
    if (tl == tr) {
        t[v] = a[tl];
    }
    else {
        int tm = (tl + tr)/2;
        build(2*v, tl, tm, a);
        build(2*v + 1, tm + 1, tr, a);
        t[v] = max(t[2*v], t[2*v + 1]);
    }   
}

ll findMax(int v, int tl, int tr, int l, int r) {
    if (l > r)  return 0ll;
    if (tl == l && tr == r) return t[v];
    int tm = (tl + tr)/2;
    return max(findMax(2*v, tl, tm, l, min(r, tm)), findMax(2*v + 1, tm + 1, tr, max(l, tm + 1), r));
}

void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr)   t[v] = new_val;
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)  update(v*2, tl, tm, pos, new_val);
        else    update(v*2 + 1, tm + 1, tr, pos, new_val);
        t[v] = max(t[v*2], t[v*2 + 1]);
    }
}

int main() {
    int n;
    cin >> n;
    vi h(n), b(n);
    for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    vi dp(n, 0);
    memset(t, 0, sizeof(t));
    dp[0] = b[0];
    update(1, 1, n, h[0], b[0]);
    for (int i = 1; i < n; ++i) {
        dp[i] = b[i] + findMax(1, 1, n, 1, h[i] - 1);
        update(1, 1, n, h[i], dp[i]);
    }
    ll ans = 0;
    for (auto i : dp)   ans = max(ans, i);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//ex.n = 60 = 2^2 * 3 * 5なら{(2, 2), (3, 1), (5, 1)}を返す
vector<P> prime_factorize(int n){
   vector<P> res;
   for(int p = 2; p * p <= n; p++){
       if(n % p != 0) continue;
       else{
           int num = 0;
           while(n % p == 0) {
               num++;
               n /= p;
           }
           res.push_back(make_pair(p, num));
       }
   }
   if(n != 1) res.push_back(make_pair(n, 1));
   return res;
}

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  vec b(n + 1,0);
  int m = 0;
  RREP(i, n){
    int t = i + 1;
    int cnt = 0;
    //(n / i)回のループ
    while(t < n+1){
      if(b[t] == 1) cnt++; 
      t += i + 1;
    }
    if(cnt % 2 != a[i]){
      b[i + 1]++;
      m++;
    }
  }
  cout << m << endl;
  REP(i, n + 1){
    if(b[i + 1] == 1) cout << i+1 << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3968
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {  
            string[] temp= Console.ReadLine().Split(' ');
            int D = int.Parse(temp[0]);
            int N = int.Parse(temp[1]);

            if (N == 100) N++;
            Console.Write(N);

            for (int i =0; i < D; i++)
            {
                Console.Write("00");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<int> ans;
signed main(){
    int n;cin >> n;
    string s;cin >> s;
    int q;cin >> q;
    vector<set<int>> st(26);
    vector<char> nani(n);
    rep(i,n){
        nani[i] = s[i];
        st[s[i] - 'a'].insert(i);
    }

    while(q--){
        int t;cin >> t;
        if(t == 1){
            int i;cin >> i;
            i--;
            char last = nani[i];
            char c;cin >> c;
            st[last - 'a'].erase(i);
            st[c - 'a'].insert(i);
            nani[i] = c;

        }
        else if(t == 2){
            int l,r;cin >> l >> r;
            l--;--r;
            int ret = 0;
            rep(i,26){
                auto  tmp = st[i].lower_bound(l);
                
                if(tmp != st[i].end() && *tmp <= r)ret++;
            }
            
            cout << ret << endl;
        }

    }
    
    return 0;
}

Measured memory_bytes: 27684
//https://atcoder.jp/contests/abc136/tasks/abc136_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N; 
    ll ans=0;
    FOR(i,1,N+1){
        auto s=to_string(i);
        if(s.size()%2==1)++ans;
    }
    cout<<ans<<endl;   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
// sum(x) x以下の和
// sum(a,b) a以上b以下の和


 int main(){
  ll n, k ; cin>> n>> k ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  vector<ll> ke(41) ;
  rep(i,n){
    bitset<41> s(A[i]) ;
    rep(j,41){
      if(s[j]) ke[j]++ ;
    }
  }

  bitset<41> base(k) ;
  ll dp[42] ;
  ll ep[42] ;
  dp[0]=0 ;ep[0]=0 ;
  int ok=0 ;
  rep2(i,1,41){
    ll now= ke[41-i] ;
    if(base[41-i]) ok++ ;
    if(ok==0){
      dp[i]=0 ;
      ep[i]=ep[i-1]*2+now ;
    }

    else{
      if(!base[41-i]){
     dp[i]=dp[i-1]*2+max(now,n-now) ;
     ep[i]=ep[i-1]*2+now ;
    }
    
    else{
      if(ok>=2)dp[i]=max(dp[i-1]*2+max(now,n-now),
       ep[i-1]*2+now) ;
      else dp[i]=ep[i-1]*2+now ;
      ep[i]=ep[i-1]*2+(n-now) ;
      
    }
    ok++ ;
    }
   
  }
  
  cout<< max(dp[41],ep[41])<<endl ;
   return 0 ;
 }



Measured memory_bytes: 4028
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }

    var cnt5 = 0
    var cnt7 = 0

    if (a == 5) {
        cnt5++
    } else if (a == 7) {
        cnt7++
    }

    if (b == 5) {
        cnt5++
    } else if (b == 7) {
        cnt7++
    }

    if (c == 5) {
        cnt5++
    } else if (c == 7) {
        cnt7++
    }

    if (cnt5 == 2 && cnt7 == 1) {
        println("YES")
    } else {
        println("NO")
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k&1){
        cout<<b-a<<endl;
    }
    else{
        cout<<a-b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define print(x) printf("%d",x)
#define scan(x) scanf("%d",&x)
#define printn(x) printf("%d\n",x)
#define rep(i,n,m) for(int i = n; i < m; i++)

int main(void){
	int x,i,j,n;
	int count = 0;
	int flag;
	scan(n);

	rep(j,0,n){
		scan(x);
		if(x == 2){
			flag = 1;
		}else if(x < 2 || x%2 == 0){
			flag = 0;
		}else{
			flag = 1;
			for(i = 3; i <= sqrt(x); i+=2){
				if(x%i == 0){
					flag = 0;
					break;
				}
			}
		}
		if(flag){
			count++;
		}
	}
	printn(count);
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

bool is_prime(ll X){
    if(X==2) return true;
    for(int i=2;i<=sqrt(X)+1;++i){
        if(X%i==0) return false;
    }
    return true;
}

int main() {
    ll X;
    cin>>X;

    while(!is_prime(X)){
        ++X;
    }
    cout<<X<<endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
v = []
v = gets.split.map(&:to_f)

v = v.sort.reverse

v1, v2 = 0
while not v.size == 1
  v1 = v.pop
  v2 = v.pop
  v.push((v1+v2)/2)
  v = v.sort.reverse
  # puts "#{v}"
end
puts v[0]

Measured memory_bytes: 1788
x,n = map(int, input().split())
lst = list(map(int, input().split()))[:n]
incr = 0
ans = 0
while True:
    found = True
    now = x-incr
    for ele in lst:
        if now == ele:
            found = False
    if found == True:
        ans = now
        break
    found = True
    now = x + incr
    for ele in lst:
        if now == ele:
            found = False
    if found == True:
        ans = now
        break
    incr = incr + 1
print(ans)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll even(ll n) {
  ll res = 0;
  ll k = n / 2;
  ll x = k / 5;
  while (x > 0) {
    res += x;
    x /= 5;
  }
  return res;
}

ll odd(ll n) {
  ll res = 0;
  ll k = n / 2;
  ll x = k / 5;
  while (x > 0) {
    res += x;
    x /= 5;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  // ll all = 0;

  // ll y = n;
  // while (y > 0) {
  //   all += y / 5;
  //   y /= 5;
  // }

  if (n % 2 == 0) {
    cout << even(n) << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
int main() {
	string str;
	cin>>str;
	int k=0,ans=0;
	for(int i=0;i<str.size();++i){
		if(str[i]!='A'&&str[i]!='T'&&str[i]!='C'&&str[i]!='G'){
			ans=max(ans,k);
			k=-1;
		}
		k++;
	}
	ans=max(ans,k);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int x, y, l, g, n=0;
    while(n < 3000)
    {
        cin >> x >> y;
        if(x==0 && y==0) break;
        l = (y>=x) ? x : y;
        g = (y>=x) ? y : x;
        cout << l << " " << g << endl;
        n++;
    }    

    return 0;
}


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

typedef vector<long long int> vi;
#define pb push_back
#define all(x) x.begin(),x.end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define sciiii(x, y, z, w) int x, y, z, w; scanf("%d %d %d %d", &x, &y, &z, &w);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}

vector<int> get_Factors(ll n)
{
      vector <int> v;
      for(ll i=1; i<=sqrt(n)+1; i++)
      {
            if(n%i==0)
            {
                  v.push_back(i);
                  v.push_back(n/i);
            }
      }
 
      return v;
}
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
 
ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}


long long powerexp(long long base, long long exp) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) ;
      exp = exp >> 1;
      base = (base * base) ;
   }
   return res;
}
long long powerexpwithmod(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}


int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  

int myXOR(int x, int y) 
{ 
   return (x | y) & (~x | ~y); 
} 
 



int main() 
{ 
    
    set<int>s1;
    rep(i,1,5){
      s1.insert(i);
    }
    rep(i,0,4){
      int a;
      cin>>a;
      if(a!=0) s1.erase(a);
    }
    auto it=s1.begin();
    cout<<*it;
    return 0;      
   
} 








Measured memory_bytes: 3724
#include<cstdio>
#include<set>
#include<queue>
#include<iostream>
#include<cstring>
using namespace std;
struct str{
    int t,n,w;
}e[1000000];
int t,i,h[10000000],u,vv,w,v[10000000],d[10000000],n,m;
set<int>c[1000000];
void add(int u,int v,int w)
{
    t++;
    e[t].t=v;
    e[t].w=w;
    e[t].n=h[u];
    h[u]=t;
}
priority_queue<pair<int,int> >q;
void dij()
{
    memset(d,0x3f,sizeof(d));
    d[1]=0;
    q.push(make_pair(d[1],1));
    while (q.size())
    {
        int u=q.top().second;
        q.pop();
        if (v[u])
            continue;
        v[u]=1;
        for (int i=h[u]; i; i=e[i].n)
        {
            int k=e[i].t,w=c[u].count(e[i].w)?0:1;
            if (d[k]>d[u]+w)
            {
                d[k]=d[u]+w;
                q.push(make_pair(-d[k],k));
                c[k].clear();
                c[k].insert(e[i].w);
            }
            else if (d[k]==d[u]+w)
                c[k].insert(e[i].w);
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for (i=1; i<=m; i++)
    {
        scanf("%d%d%d",&u,&vv,&w);
        add(u,vv,w);
        add(vv,u,w);
    }
    dij();
    if (d[n]==0x3f3f3f3f)
        printf("-1\n");
    else
        printf("%d\n",d[n]);
}

Measured memory_bytes: 106232
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int p =sc.nextInt();
			int q = sc.nextInt();
			int x = p % q * 10;
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			map.put(x, 0);
			StringBuilder sb = new StringBuilder();
			for(int i = 1; ; i++){
				int temp = (x % q) * 10;
				int temp2 = x / q;
				sb.append(temp2);
				if(temp == 0){
					System.out.println(sb.toString());
					break;
				}
				if(map.containsKey(temp)){
					System.out.println(sb.toString());
					StringBuilder anssec = new StringBuilder();
					int len = map.get(temp);
					for(int j = 0; j < len; j++){
						anssec.append(" ");
					}
					for(int j = len; j < i; j++){
						anssec.append("^");
					}
					System.out.println(anssec.toString());
					break;
				}
				map.put(temp, i);
				x = temp;
			}
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 12000
S = int(input())

firsthalf = int(S/100)
latterhalf = int(S%100)

if (firsthalf>12 or firsthalf==0) and (latterhalf>12 or latterhalf==0):
    print("NA")
elif firsthalf<=12 and (latterhalf>12 or latterhalf==0):
    print("MMYY")
elif (firsthalf>12 or firsthalf==0) and latterhalf<=12:
    print("YYMM")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3060
from collections import defaultdict

N, MA, MB = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in range(N)]

dp = defaultdict()

dp[(0, 0)] = 0
for a, b, c in X:
    dp2 = defaultdict()
    for sa, sb in dp:
        if (sa+a, sb+b) not in dp:
            dp2[(sa+a, sb+b)] = dp[(sa, sb)] + c
        elif dp[(sa+a, sb+b)] > dp[(sa, sb)] + c:
            dp2[(sa+a, sb+b)] = dp[(sa, sb)] + c
    for (na, nb) in dp2:
        dp[(na, nb)] = dp2[(na, nb)]

a, b = MA, MB
ans = 100000
while a <= 400 and b <= 400:
    if (a, b) in dp:
        ans = min(ans, dp[(a, b)])
    a += MA
    b += MB

if ans == 100000:
    print -1
else:
    print ans


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

int main()
{
  int num;
  cin >> num;
  int a, b, c, d;
  a = num / 1000;
  b = num % 1000 / 100;
  c = num % 100 / 10;
  d = num % 10;
  
  int ans[8] = { a + b + c + d,
                 a - b + c + d,
                 a + b - c + d,
                 a + b + c - d,
                 a + b - c - d,
                 a - b + c - d,
                 a - b - c + d,
                 a - b - c - d,
               };
  
  bool flg = false;
  for (int i = 0; i < 8; i++) {
    if (ans[i] == 7 ) {
      flg = true;
      switch (i) {
        case 0:
          cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
          break;
		case 1:
          cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
          break;
 		case 2:
          cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
          break;
		case 3:
          cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
          break;
		case 4:
          cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
          break;
		case 5:
          cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
          break;
		case 6:
          cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
          break;
		case 7:
          cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
          break;
        default:
          break;
      }
    }
    if (flg == true) break;
  }
      
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;



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

	int n;
	cin >> n;
	cout << 0 << endl;
	cout.flush();

	string sts0;
	cin >> sts0;
	if(sts0 == "Vacant") return 0;

	int lb = 0, ub = n;

	while(true){
		int mid = (lb + ub) >> 1;

		cout << mid << endl;
		cout.flush();

		string tmp;
		cin >> tmp;
		if(tmp == "Vacant") return 0;

		if((mid % 2 == 0 && tmp == sts0)
			|| (mid % 2 == 1 && tmp != sts0)){
			lb = mid;
			// cout << "lb" << endl;

		}else{
			ub = mid;
			// cout << "ub" << endl;
		}

		// if(cond(mid)) ub = mid;   // Answer is in (lb, mid]
		// else lb = mid;            // Answer is in (mid, ub]
	}
}


Measured memory_bytes: 852
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int answer = 0;
    if(a==b){
      answer = 2*a;
    }else{
      answer = Math.max(a,b) + Math.max(a,b) -1;
    }
    System.out.println(answer);
  }
  

  
}


Measured memory_bytes: 24276
#include<iostream>

using namespace std;

int main(){

	int n;

	int memo[100];

	while(1){

		cin>>n;

		if(n==0) break;

		memo[0]=1;
		memo[1]=1;
		memo[2]=2;
		for(int i=3;i<=n;i++){
			memo[i]=memo[i-1]+memo[i-2]+memo[i-3];
		}
		cout<<memo[n]/365/10+1<<endl;
	}
}

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) { return b < a && (a = b, true); }
struct SetUp { SetUp() { cout << fixed << setprecision(20); }; } setUp;

int H, W, A, B;
signed main() {
    cin >> H >> W >> A >> B;
    vector<bool> a;
    rep(i, A) { a.push_back(0); }
    rep(i, W - A) { a.push_back(1); }
    for (int i = 0; i < B; i++) {
        rep(i, W) { cout << a[i]; }
        cout << endl;
        rep(i, W) { cout << !a[i]; }
        cout << endl;
    }
    for (int i = 0; i < H - B * 2; i++) {
        rep(i, W) { cout << !a[i]; }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}
void DBG() {cerr << "]" << endl;}
template<class H, class... T> void DBG(H h, T... t) {
cerr << to_string(h);
if(sizeof...(t)) cerr << ", ";
DBG(t...);}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
bool ispalingrome(string s){
 int n = sz(s);
 for(int i=0;i<n;i++){
   	if(s[i]!=s[n-i-1]){
	  return false;
	}
 }
 return true;
}
int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 string s;
 cin>>s;
 int n = sz(s);
 if(ispalingrome(s)){
   string left="";
   string right="";
   for(int i=0;i<(n-1)/2;i++){
     left+=s[i];
   }
   for(int i=((n+3)/2)-1;i<n;i++){
     right+=s[i];
   }
   if(ispalingrome(left)&&ispalingrome(right)){
     cout<<"Yes\n";
   }
   else{
     cout<<"No\n";
   }
 }
 else{
  cout<<"No\n";
 }
}




Measured memory_bytes: 3644
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    
    string N;
    
    cin >> N;
    
    string ans = "No";
    
    if( N[2] == N[3] && N[4] == N[5] ) ans = "Yes";
    
    cout << ans;
}


Measured memory_bytes: 888