akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

// 最大公約数を求める関数。ユークリッドの除去法
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

// 最小公倍数を求める関数。
// a * b = gcd(a,b) * lcm(a,b)
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {

  int N;
  cin >> N;

  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = c[0];
  repi(i, 1, N) { ans = lcm(ans, c[i]); }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int n;
int main() {
    cin>>n;
    ll a[n+2],ans=0;
    a[0]=0;
    a[n+1]=0;
    REP(i,n){
        cin>>a[i+1];
    }

    REP(i,n+1){
        ans+=abs(a[i+1]-a[i]);
    }

    REP(i,n){
        cout<<ans-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i]-a[i+2])<<endl;
    }

    return 0;
}


Measured memory_bytes: 2048
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-19 20:51:03
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans = a;
    if (a > b) ans = b;

    if (ans == a) {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
        cout << endl;
    } else {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 300
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n;
double px[MAX],py[MAX],pz[MAX],vx[MAX],vy[MAX],vz[MAX],r[MAX],vr[MAX];

class State{
  public:
    int a,b;
    double time;
    State(int a,int b,double time):a(a),b(b),time(time){}
    bool operator<(State s)const{
      return time<s.time;
    }
};

void solve(){
  double res[MAX];
  fill(res,res+MAX,inf);
  vector<State> v;

  FOR(i,0,n){
    v.pb(State(i,i,r[i]/vr[i]));
    FOR(j,i+1,n){
      double X=px[i]-px[j],Y=py[i]-py[j],Z=pz[i]-pz[j];
      double VX=vx[i]-vx[j],VY=vy[i]-vy[j],VZ=vz[i]-vz[j];
      double R=r[i]+r[j],VR=vr[i]+vr[j];
      double c=X*X+Y*Y+Z*Z-R*R;
      double b=X*VX+Y*VY+Z*VZ+R*VR;
      double a=VX*VX+VY*VY+VZ*VZ-VR*VR;
      if(b*b-a*c<-eps)continue;
      double t1=(-b+sqrt(b*b-a*c))/a;
      if(t1<eps || r[i]<t1*vr[i] || r[j]<t1*vr[j])t1=inf;
      double t2=(-b-sqrt(b*b-a*c))/a;
      if(t2<eps || r[i]<t2*vr[i] || r[j]<t2*vr[j])t2=inf;
      double t=min(t1,t2);
      if(t!=inf)v.pb(State(i,j,t));
    }
  }

  sort(all(v));
  FOR(i,0,v.size()){
    int a=v[i].a,b=v[i].b;
    double t=v[i].time;
    if(res[a]==inf && res[b]==inf){
      res[a]=t;
      res[b]=t;
    }
  }
  FOR(i,0,n)pd(res[i]);
}

int main()
{
  while(cin>>n && n){
    FOR(i,0,n){
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 3272
/*
 * d.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;

/* typedef */

/* global variables */

int as[MAX_N][MAX_M], bs[MAX_M];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> as[i][j];
  for (int i = 0; i < m; i++) cin >> bs[i];

  for (int i = 0; i < n; i++) {
    int ci = 0;
    for (int j = 0; j < m; j++) ci += as[i][j] * bs[j];
    printf("%d\n", ci);
  }
  return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>

void main()
{
	int kazu;
	int iti;

	scanf("%d", &kazu);

	iti = kazu % 10;
	if ((iti == 2) || (iti == 4) || (iti == 5) || (iti == 7) || (iti == 9)) {
		printf("hon");
	}
	else if ((iti == 0) || (iti == 1) || (iti == 6) || (iti == 8)) {
		printf("pon");
	}
	else {
		printf("bon");
	}
}

Measured memory_bytes: 1732
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int n;
    string s;
    cin >> n >> s;

    int r = 0;
    int b = 0;
    REP(i, n) {
        if (s[i] == 'R') r++; else b++;
    }

    cout << Yes(r > b) << endl;
    
}

Measured memory_bytes: 256
from math import factorial as fact
import math
import sys
from itertools import product
import numpy as np
from collections import Counter
import datetime
from collections import deque
from bisect import bisect_left, bisect_right
import heapq



#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def swap(a,b):
	tmp=a
	a=b
	b=tmp
	return a,b

H,W,K=input2()
c=[list(input()) for _ in range(H)]

ans=0

for row_line in product(range(2),repeat=H): #[行]0:そのまま，1:赤く塗る
	for col_line in product(range(2), repeat=W): #[列]0:そのまま，1:赤く塗る
		# 黒("#")の数え上げ
		cnt=0
		for row in range(H):
			for col in range(W):
				if c[row][col]=="#" and row_line[row]==0 and col_line[col]==0:
					cnt+=1

		if cnt==K:
			ans+=1
print(ans)







Measured memory_bytes: 27132
h, w = map(int, input().split())

field = [list(input()) for i in range(h)]

cnt = 0

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            cnt += 1

if cnt == h + w - 1:
    print('Possible')
else:
    print('Impossible')

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

using namespace std;

int main(void) {
	long long a, b, c, ans;
	cin >> a >> b >> c;
	if (!(a & 1) || !(b & 1) || !(c & 1)) {
		printf("0\n");
		return 0;
	}
	ans = min(a * b, b * c);
	ans = min(ans, a * c);
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >>W;//HとWの入力を受け取る
    
  for(int i =0 ; i < W + 2;i ++) {
  cout << "#" ;
  }
  cout << endl;//一行目の##..の出力
  
  vector<string> vec(H);
  for(int i=0;i < H;i++)
    cin >> vec.at(i);//入力を配列で受け取る
    
   for(int j=0; j<H ;j++){
     
     cout << "#" << vec.at(j) << "#" << endl;//配列を出力
  	 
   }
  for(int i =0 ; i < W + 2;i ++) {
  cout << "#" ;
  }
  cout << endl;//最終行目の##..の出力
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC71 C

from collections import Counter

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

a = Counter(a)
a = list(a.items())

b = []

for i,j in a:
    if j >= 2:
        b.append(i)
        if j >= 4:
            b.append(i)
b.sort()
if len(b) < 2:
    print(0)
else:
    x = b[-1]
    y = b[-2]
    print(x*y)


Measured memory_bytes: 21412
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N;
int A[MAX_N];
priority_queue<P> que;
priority_queue<P> que2;

void solve()
{
  REP(i, N) que.push(P(A[i], i));
  for (int i = 0; i < N; i++) {
    int t = A[i];
    while (1) {
      P p = que.top();
      que.pop();
      que2.push(p);
      if (p.second == i) continue;
      cout << p.first << endl;
      break;
    }
    while (!que2.empty()) {
      P p = que2.top();
      que2.pop();
      que.push(p);
    }
  }
}

int main(void)
{
  cin >> N;
  REP(i, N) cin >> A[i];
  solve();
  return 0;
}


Measured memory_bytes: 4080
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int r = line[0], D = line[1], x = line[2];
            long tmp = x;
            for (var i = 0; i <= 9; i++)
            {
                tmp = r * tmp - D;
                Console.WriteLine(tmp);

            }
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const int C_MAX = 1200001;

int solve(int N, int M, int X, vector<int> C, vector<vector<int>> A) {
    vector<int> scores(M, 0);
    int min = C_MAX;

    for(int i = 0; i <= pow(2, N) - 1; i++) {
        int price = 0; // priceの初期化
        bool flg = true; // scoresの各要素がX以上かどうかのフラッグ
        int b = i; // bの初期化(00000...00001(N桁) <= b <= 11111...11111(N桁))
        for(int j = 0; j < M; j++) scores[j] = 0; // scoresの各要素を0で初期化
        for(int j = 0; j < N; j++) { // bの桁のうち、1になっている桁の要素だけpriceとscoresに加算
            price += C[j] * (b % 2);
            // cout << "b is " << b << ". (b % " << 2 << ") is " << b % 2 << endl;
            for(int k = 0; k < M; k++) scores[k] += A[j][k] * (b % 2);
            b /= 2;
        }
        for(int j = 0; j < M; j++) {
            if(scores[j] < X) {
                flg = false;
                break;
            }
        }
        
        if(flg && min > price) {
            min = price;
            continue;
        }
    }
    if(min < C_MAX) return min;
    else return -1;
}

int main() {
    int N, M, X;
     cin >> N >> M >> X;
    vector<int> C(N, 0);
    vector<vector<int>> A(N, vector<int>(M, 0));
     for(int i = 0; i < N; i++) {
         cin >> C[i];
         for(int j = 0; j < M; j++) {
             cin >> A[i][j];
         }
     }
  
    cout << solve(N, M, X, C, A) << endl;

    return 0;
}

Measured memory_bytes: 4060
n=int(input())
a,b,c = map(int,input().split())
aa=[a]
bb=[b]
cc=[c]
for i in range(1,n):
    x=aa[-1]
    y=bb[-1]
    z=cc[-1]
    a,b,c = map(int,input().split())
    aa.append(max(a+y,a+z))
    bb.append(max(b+x,b+z))
    cc.append(max(c+x,c+y))

print(max(aa[-1],bb[-1],cc[-1]))
    


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

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

    queue<int> qA, qB;
    for(int i=0; i<n+1; i++){
        int a;
        cin >> a;
        qA.push(a);
    }
    for(int i=0; i<n; i++){
        int b;
        cin >> b;
        qB.push(b);
    }

    long long ans = 0;
    for(int i=0; i<n; i++){
        if(qA.front()>=qB.front()){
            ans += qB.front();
            qA.pop();
            qB.pop();
        }
        else{
            ans += qA.front();
            qB.front() -= qA.front();
            qA.pop();

            if(qA.front()>=qB.front()){
                ans += qB.front();
                qA.front() -= qB.front();
                qB.pop();
            }
            else{
                ans += qA.front();
                qA.front() = 0;
                qB.pop();
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline long long read(){
	char ch=getchar();long long x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}
long long x[100010],l[100010],r[100010],lv[100010],lvx[100010],rv[100010],rvx[100010];  
int main(){
	int n=read();long long c=read();
	long long ans=0;
	for(int i=1;i<=n;i++){
		x[i]=read();
		r[i]=read();
		r[i]+=r[i-1];
		rv[i]=max(rv[i-1],r[i]-x[i]);
		rvx[i]=max(rvx[i-1],r[i]-2*x[i]);
	}
	for(int i=n;i>=1;i--){
		l[i]=r[n]-r[i-1];
		lv[i]=max(lv[i+1],l[i]-c+x[i]);
		lvx[i]=max(lvx[i+1],l[i]-2*c+2*x[i]);
	}
	for(int i=0;i<=n;i++){
		ans=max(ans,rvx[i]+lv[i+1]);
		ans=max(ans,rv[i]+lvx[i+1]);
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string ss;
        cin >> ss;
        sort(ss.begin(), ss.end());
        mp[ss]++;
    }
    ll ans = 0;
    for(auto& e: mp){
        ans += (ll)e.second * (e.second-1)/2;
    }

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

Measured memory_bytes: 11136
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);

    int a = s.nextInt();

    if(a == 7 || a == 5 || a == 3){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long[] x=new long[n];
		for(int i=0;i<n;i++)x[i]=sc.nextLong();
		
		long d=0;
		for(int i=0;i<n-1;i++){
			d+=Math.min(a*(x[i+1]-x[i]), b);
		}
		
		System.out.println(d);
	}
}


Measured memory_bytes: 49680
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int ans=power(10,n)-(2*power(9,n))%mod+power(8,n)+mod;
	ans%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
int main(void){
    int n,ans=0;
    while(cin>>n,n){
        vi s(n);
        rep(i,n) cin>>s[i];
        sort(all(s));
        cout<<floor(accumulate(s.begin()+1,s.end()-1,0)/(n-2))<<endl;
    }
}

Measured memory_bytes: 3292
import  java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        long x = cin.nextLong();
        long ans = 0;
        long d1 = (long)x/500;
        x = x - 500*d1;
        ans += d1*1000;
        d1 = (long)x/5;
        ans += d1*5;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(b*c<a)puts("No");
	else puts("Yes");
	return 0;
}


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

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  string s, t;
  cin >> s >> t;

  if (s.size() == t.size() - 1 && s == t.substr(0, t.size() - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n = sc.nextInt();
        Set<String> substr = new HashSet<>();
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < str.length() - i + 1; j++) {
                substr.add(str.substring(j, j + i));
            }
        }
        String result = "";
        for (int i = 0; i < n; i++) {
            String min = substr.iterator().next();
            for (String cur : substr) {
                if (min.compareTo(cur) > 0) {
                    min = cur;
                }
            }
            substr.remove(min);
            result = min;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 22860
import bisect
N = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        kmin = bisect.bisect_left(L, (b - a), j + 1)
        kmax = bisect.bisect_left(L, (a + b), j + 1)
        ans += (kmax - kmin)
print(ans)

Measured memory_bytes: 9252
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
int a[200010];
bool f[200010];

bool check( int x ){
  REP( i , 2*n-1 ){
    f[i] = a[i] >= x;
  }
  int c = n-1;
  int r = INF, l = -INF;
  FOR( i , c , 2*n-2 ){
    if( f[i] == f[i+1] ){
      r = i;
      break;
    }
  }
  for( int i = c; i >= 1; i-- ){
    if( f[i] == f[i-1] ){
      l = i;
      break;
    }
  }
  if( r == INF and l == -INF ){
    if( n % 2 == 1 ){
      return f[c];
    } else {
      return not f[c];
    }
  }
  if( c-l <= r-c ){
    return f[l];
  } else {
    return f[r];
  }
}


int main(){

  n = in();
  REP( i , 2*n-1 ){
    a[i] = in();
  }

  int lb = 1, ub = 2*n;
  while( ub - lb > 1 ){
    int md = ( lb + ub ) / 2;
    if( check( md ) ){
      lb = md;
    } else {
      ub = md;
    }
  }

  printf( "%d\n" , lb );
  
  return 0;
}


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

int main() {
  int x,y;
  cin >> x>>y;
  int sum;
  sum=0;

  if (x==1&&y==1) {
    sum+=400000;
  }
  if(x==1){
    sum+=300000;
  }
  if(y==1){
    sum+=300000;
  }
  if(x==2){
    sum+=200000;
  }
  if(y==2){
    sum+=200000;
  }
  if(x==3){
    sum+=100000;
  }
  if(y==3){
    sum+=100000;
  }
//	cout << x<<endl;
//  cout << y << endl;
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();

		int a = y;

		while((a = x % a) != 0) {
			x = y;
			y = a;
		}

		System.out.println(y);

	}

}



Measured memory_bytes: 26232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 100010






int main(){
	int nx, ny, nz;
	long long x[N];
	long long y[N];
	long long z[N];
	long long nxz[N];
	long long nyz[N];
	vector<pair<long long, int> >nxy;
	vector<pair<long long,int> >xy;
	priority_queue<pair<long long, int> >zy;
	priority_queue<pair<long long, int> >zx;
	int n, k;
	long long s, ans;
	bool v = true;
	s = 0;
	ans = 0;
	scanf("%d %d %d", &nx, &ny, &nz);
	s = 0;
	f(i, nx+ny+nz){
		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
		s += x[i];
		nxy.push_back(make_pair(y[i] - x[i], i));
	}
	sort(nxy.begin(), nxy.end(), greater<pair<long long, int> >());
	xy = nxy;
	nyz[0] = 0;
	f(i, ny){
		k = xy[i].second;
		nyz[0] += y[k] - x[k];
		zy.push(make_pair(z[k] - y[k], k));
	}
	f(i, nz){
		k = xy[ny + i].second;
		nyz[i + 1] = nyz[i] + y[k] - x[k];
		zy.push(make_pair(z[k] - y[k], k));
		k = zy.top().second;
		nyz[i + 1] +=z[k] - y[k];
		zy.pop();
	}

	xy = nxy;
	nxz[0] = 0;
	f(i, nx){
		k = xy[nx + ny + nz - i - 1].second;
		zx.push(make_pair(z[k] - x[k], k));
	}
	f(i, nz){
		k = xy[ny + nz - i - 1].second;
		zx.push(make_pair(z[k] - x[k], k));
		k = zx.top().second;
		nxz[i + 1] = nxz[i] + z[k] - x[k];
		zx.pop();
	}
	f(i, nz+1){
		ans = max(ans, s + nyz[i] + nxz[nz - i]);
	}


	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 10096
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll H(N);
        rep(i, 0, N) cin >> H[i];
        ll ans = 0;
        ll cnt = 0;
        repreverse(i, N-2, 0) {
                if (H[i] >= H[i+1]) ++cnt;
                else cnt = 0;
                chmax(ans, cnt);
        }
        cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>

using namespace std;
typedef pair<int, int> P;

string s;
vector<string> vec;
map<char, P> mp;
map<int, int> vmp[1005];
int nid;

int parseNum(string &s, int &p)
{
  int ret = 0;
  while(s[p] >= '0' && s[p] <= '9'){
    ret *= 10, ret += s[p]-'0';
    p++;
  }
  return ret;
}

char parseName(string &s, int &p)
{
  char ret = s[p];
  p++;
  return ret;
}

int parseExp(string &s, int &p)
{
  if(s[p] >= '0' && s[p] <= '9') return parseNum(s, p);
  char name = parseName(s, p);
  p++;
  int id = parseExp(s, p);
  p++;
  if(id == -1 || mp[name].second <= id || vmp[mp[name].first].count(id) == 0) return -1;
  return vmp[mp[name].first][id];
}

bool parseAss(string &s, int &p, char &name)
{
  p++;
  int id = parseExp(s, p);
  //cout << id << " " << mp[name].second << endl;
  if(id == -1 || mp[name].second <= id) return false;
  p++, p++;
  int val = parseExp(s, p);
  if(val == -1) return false;
  vmp[mp[name].first][id] = val;
  return true;
}

bool parseDec(string &s, int &p, char &name)
{
  p++;
  int num = parseExp(s, p);
  mp[name] = make_pair(nid++, num);
  return true;
}

int main(void)
{
  while(1){

    vec.clear();
    while(1){
      cin >> s;
      vec.push_back(s);
      if(s == ".") break;
    }
    if(vec[0] == ".") break;
    vec.pop_back();

    mp.clear();
    for(int i = 0; i < 1005; i++) vmp[i].clear();

    nid = 0;
    for(int i = 0; i < vec.size(); i++){
      string s = vec[i];
      s += "$";

      int pos = 0;
      char name = parseName(s, pos);

      bool ans;
      if(mp.count(name)) ans = parseAss(s, pos, name);
      else ans = parseDec(s, pos, name);
      if(!ans){
        cout << i+1 << endl;
        goto end;
      }

      //for(auto it = mp.begin(); it != mp.end(); it++) cout << it->first << " " << it->second.first << " " << it->second.second << endl;
    }
    cout << 0 << endl;

    end:;
  }
}



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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#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)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,W; cin >> N >> W;
    VI v(N), w(N); REP(i,N) cin >> v[i] >> w[i];
    int dp[N+1][W+1]; CLR(dp);
    REP(i,N)REP(j,W){
        if(j+1-w[i] >= 0) chmax(dp[i+1][j+1], dp[i][j+1-w[i]] + v[i]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
    }
    int ans = 0;
    REP(i,W) chmax(ans, dp[N][i+1]);
    cout << ans << en;
    return 0;
}


Measured memory_bytes: 7040
n, k = map(int, input().split())
arr = list(map(int, input().split()))

bit_cnt = [0] * 40

for a in arr:
    for i in range(40):
        if a >> i & 1:
            bit_cnt[i] += 1

x = 0
for i in range(39, -1, -1):
    if x + (1 << i) <= k and bit_cnt[i] <= n - bit_cnt[i]:
        x += (1 << i)

print(sum([x ^ y for y in arr]))

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

int main()
{
    string str="";
    ll i,n,mod,q;
    cin>>n;
    while(1)
    {
        q=n/26;
        mod=n%26;
        if(mod==0)str+='z';
        else str+=('a'-1+mod);


        if(mod==0)q--;
        if(q==0)break;
        n=q;
    }
    for(i=str.size()-1; i>=0; i--)cout<<str[i];
    cout<<endl;



    return 0;
}



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

int main(){
  int w,h,x,y,r;
  
  cin >> w >> h >> x >> y >> r;
  
  if(x-r<0 || y-r<0 || x+r>w || y+r>h){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
using namespace std;
#define MAX 100000
#define NIL -1

struct Node { int parent, left, right; };
struct Node T[MAX];

int D[MAX];

// int getDepth(int u){
//   d = 0;
//   while(T[u].parent != NIL){
//     u = T[u].parent;
//     d++;
//   }
//   return d;
// }

void setDepth(int u, int p){
  D[u] = p;
  if(T[u].right != NIL){
    setDepth(T[u].right, p);
  }
  if(T[u].left != NIL){
    setDepth(T[u].left, p+1);
  }
}

void print(int n){
  bool isFirst;
  for(int i=0; i<n; i++){
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "depth = " << D[i] << ", ";
    if(T[i].parent == NIL) cout << "root, ";
    else if(T[i].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    cout << "[";
    int c = T[i].left;
    isFirst = true;
    while(c != NIL){
      if(!isFirst) cout << ", ";
      isFirst = false;
      cout << c;
      c = T[c].right;
    }
    cout << "]" << endl;
  }
  return;
}

int main(void){
  int n, id, k, c, left, root;
  cin >> n;
  for(int i=0; i<n; i++){
    T[i].parent = T[i].left = T[i].right = -1;
  }

  for(int i=0; i<n; i++){
    cin >> id >> k;
    for(int j=0; j<k; j++){
      cin >> c;
      T[c].parent = id;
      if(j) T[left].right = c;
      else T[id].left = c;
      left = c;
    }
  }

  for(int i=0; i<n; i++){
    if(T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  print(n);
  return 0;
}



Measured memory_bytes: 7676
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        int n = sc.nextInt();
        for(i=1;i<=n;i++){
            int x = i;
            if (x % 3 == 0) {
                System.out.printf(" %d", i);
                continue;
            }
            while(x != 0) {
                if(x % 10 == 3){
                    System.out.printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
        System.out.printf("\n");
    }
}



Measured memory_bytes: 38832
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >>b>>c>>d;
    if(abs(a-c)<=d){
        cout << "Yes";
    }else if(abs(a-b)<=d && abs(b-c)<=d){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

int main()
{
        int abc[3];
        cin >> abc[0] >> abc[1] >> abc[2];


        int max = 0;
        int min = 0;
        int tmp = 0;

        for (int j = 0; j < 2; j++) {
        for (int i = 0; i < 2; i++) {
                if (abc[i] < abc[i+1]) {
                        tmp = abc[i];
                        abc[i] = abc[i+1];
                        abc[i+1] = tmp;
                }
        }
        }
        cout <<  abc[0] * 10 + abc[1] + abc[2] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///


int main(){

   int n;
   I(n);

   int ar[n+2];

   for(int i = 1;i<=n;i++){
       I(ar[i]);
   }
   int a[n+2];
   SET(a);

   int ans = 0;
   for(int i = 1;i<=n;i++){
       int k = n;
       for(int j = n;j>=0;j--){
           int val = ar[i];
           for(int k = i;k<=j;k++)val = min(val, ar[k]);
           if(a[i] < val){
            int baki = val - a[i];
             ans+=baki;
            for(int k = i;k<=j;k++)a[k] += baki;
           }
       }
       
   }

   cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll H, W, K;
vector<vector<char>> grid(10, vector<char>(10));
ll ans;

int main()
{
    cin >> H >> W >> K;
    ll sum_b = 0;
    rep(0, i, H)
    {
        rep(0, j, W)
        {
            cin >> grid.at(i).at(j);
            if (grid.at(i).at(j) == '#')
            {
                sum_b++;
            }
        }
    }

    ans = 0;

    for (ll i = 0; i < ((ll)1 << H); i++)
    {
        bitset<10> bit1(i);
        for (ll j = 0; j < ((ll)1 << W); j++)
        {
            vector<vector<ll>> memo(H, vector<ll>(W, 0));
            bitset<10> bit2(j);
            ll now_b = sum_b;

            rep(0, k, H)
            {
                if (bit1.test(k))
                {
                    rep(0, l, W)
                    {
                        if (grid.at(k).at(l) == '#' && memo.at(k).at(l) == 0)
                        {
                            now_b--;
                            memo.at(k).at(l) = 1;
                        }
                    }
                }
            }

            rep(0, k, W)
            {
                if (bit2.test(k))
                {
                    rep(0, l, H)
                    {
                        if (grid.at(l).at(k) == '#' && memo.at(l).at(k) == 0)
                        {
                            now_b--;
                            memo.at(l).at(k) = 1;
                        }
                    }
                }
            }

            if (now_b == K)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
int n;
int a[1000005];
int c[1000005];
vector <int> p;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
    }
    for(int i = 2;i <= 1000000;i++) {
        if(c[i]) continue;
        p.push_back(i); c[i] = 1;
        if(i > 1000) continue;
        for(int j = i*i;j <= 1000000;j += i) c[j] = 1;
    }
    memset(c,0,sizeof(c));
    int ch = 1;
    for(int i = 1;i <= n;i++) {
        int x = a[i];
        for(int j : p) {
            if(j > 1000) break;
            if(j*j > x) break;
            if(x % j == 0) {
                if(c[j]) {
                    ch = 0;
                    break;
                }
                c[j] = 1;
                while(x % j == 0) x /= j;
            }
        }
        if(x != 1&&c[x]) {
            ch = 0;
            break;
        }
        if(x != 1) c[x] = 1;
        if(!ch) break;
    }
    if(ch) {
        cout << "pairwise coprime\n";
        return 0;
    }
    int gcd = a[1];
    for(int i = 2;i <= n;i++) {
        gcd = __gcd(a[i],gcd);
    }
    if(gcd == 1) {
        cout << "setwise coprime\n";
        return 0;
    }
    cout << "not coprime\n";
    return 0;
}

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


int main()
{

    string a;
    cin >> a;
    int size;

    a.erase(std::unique(a.begin(), a.end()), a.end());
    size = a.size();
    if(size==4)
    {
        cout << "Good" << "\n";
        }
    else
    {
        cout << "Bad"
             << "\n";
             }

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
long long diff[100001][2];
vector<pair<pair<int,int>, int> > edge[100001];
bool ok = true;

void dfs(int pos, long long val, int pos_neg){
   //cout << pos << ", "<< val << ", "<< pos_neg << endl;
   if(ok==false) return;
   if(diff[pos][pos_neg]!=LLONG_MAX&&diff[pos][pos_neg]!=val){
      ok = false;
      return;
   }
   if(diff[pos][pos_neg]!=LLONG_MAX) return;
   diff[pos][pos_neg]=val;
   for(int i = 0 ; i < (int)edge[pos].size(); i++){
      int next = edge[pos][i].first.first;
      long long cost = edge[pos][i].first.second;
      long long nextCost = cost-val;
      if( diff[next][1-pos_neg]!=LLONG_MAX&&diff[next][1-pos_neg]!=nextCost){
         ok=false;
         return;
      }
      else{
            dfs(next,nextCost, 1-pos_neg);
      }
   }
   return;
}

int main(){
   int n,m;
   cin >> n >> m;
   for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < 2; j++){
         diff[i][j] = LLONG_MAX;
      }
   }
   for(int i = 0 ; i < m; i++){
      int u,v,s;
      cin >> u >> v >> s;
      u--;
      v--;
      edge[u].push_back(make_pair(make_pair(v,s),i));
      edge[v].push_back(make_pair(make_pair(u,s),i));
   }
   dfs(0,0,0);
   if(ok == false){
      cout << 0 << endl;
      return 0;
   }
   long long F=-1;
   long long min1=LLONG_MAX;
   long long min0=LLONG_MAX;
   for(int i = 0 ; i < n; i++){
   //   cout << diff[i][0] << ", "<< diff[i][1] << endl;
      if(diff[i][1]!=LLONG_MAX&&diff[i][0]!=LLONG_MAX){
         if(diff[i][1]-diff[i][0] > 0 &&(diff[i][1]-diff[i][0])%2==0&&(F==-1 || F == (diff[i][1]-diff[i][0])/2)){
            F=(diff[i][1]-diff[i][0])/2;
         }
         else{
            cout << 0 << endl;
            return 0;
         }
      }
      min0=min(min0,diff[i][0]);
      min1=min(min1,diff[i][1]);
   }
   long long lower_bound = -min0+1;
   long long upper_bound = min1-1;
   if( F != -1 ){
      if( lower_bound <= F && upper_bound >= F){
         cout << 1 << endl;
      }
      else{
         cout << 0 << endl;
      }
   }
   else{
      cout << max(0LL, upper_bound - lower_bound + 1)<<endl;
   }
   return 0;
}


Measured memory_bytes: 19712
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int P, Q, R;
  scanf("%d %d %d", &P, &Q, &R);
  int answer = fmin(fmin(P + Q, Q + R), R + P);

  printf("%d\n", answer);
  return 0;
}


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

#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n;
int a[200000],ans[200000];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        ans[a[i]-1]=i+1;
    }
    rep(i,n){
        cout<<ans[i];
        if(i==n-1)cout<<"\n";
        else cout<<" ";
    }
    return 0;
}



Measured memory_bytes: 2432
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;


set<string> str;
int main(){
	int n;
	int ans=0;
	
	cin>>n;	
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		str.insert(s);
	}
	cout<<str.size()<<endl;
	return 0;
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif*/
	string s;
	cin >> s;
	for (lld i = 0; i < s.length(); i++) {
		if (s[i] == '?') s[i] = 'D';
	}
	cout << s << endl;
}


Measured memory_bytes: 3744
#include <algorithm>
#include <iostream>
#include <list>
#include <cstdint>
#include <cstring>

using namespace std;

int main()
{
    int h, n;
    int dp[10001];

    cin >> h >> n;

    for (int i = 0; i <= h; i++) {
        dp[i] = 200000000;
    }

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j < h; j++) {
            int nj = min(j + a, h);
            dp[nj] = min(dp[j] + b, dp[nj]);
        }
    }
    cout << dp[h] << endl;

    return 0;
}


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

int main() {
  int D,Z=0;
  cin>>D;
  vector<int> sage(26);
  for(int i=0;i<26;i++){
    cin>>sage.at(i);
  }
  vector<vector<int>> man(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin>>man.at(i).at(j);
    }
  }
  vector<int> hini(D);
  vector<vector<int>> rkai(D+1,vector<int>(26));
  for(int i=0;i<26;i++){
    rkai.at(0).at(i)=1;
  }
  for(int i=0;i<D;i++){
    int a;
    cin>>a;
    a--;
    hini.at(i)=a;
  }
  for(int i=0;i<D;i++){
    Z+=man.at(i).at(hini.at(i));
  }
  for(int i=0;i<D;i++){
    rkai.at(i).at(hini.at(i))=0;
    for(int j=0;j<26;j++){
      Z-=sage.at(j)*rkai.at(i).at(j);
      rkai.at(i+1).at(j)=rkai.at(i).at(j)+1;
    }
  }
  
  int M;
  cin>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    int K=rkai.at(a).at(b),C=0;
    for(int j=a;j<D;j++){
      if(rkai.at(j).at(b)==0){
        break;
      }
      else{
        C++;
        rkai.at(j).at(b)-=K;
      }
    }
    Z+=K*C*sage.at(b);
    Z+=man.at(a).at(b);
    int e=hini.at(a);
    hini.at(a)=b;
    C=0;
    if(a==0){
      K=1;
    }
    else{
      K=rkai.at(a-1).at(e)+1;
    }
    for(int j=a;j<D;j++){
      if(rkai.at(j).at(e)==0&&j!=a){
        break;
      }
      else{
        C++;
        rkai.at(j).at(e)+=K;
      }
    }
    Z-=K*C*sage.at(e);
    Z-=man.at(a).at(e);
    cout<<Z<<endl;
  }
    
}

Measured memory_bytes: 3700