akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

// 動作環境 : C++14 AOJ
int main(){
    vector<pair<ll, ll>> A;
    while(true){
        ll H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        A.pb(make_pair(H, W));
    }

    rep(i, 0, A.size()){
        cout << string(A[i].second, '#') << endl;
        rep(y, 1, A[i].first - 1){
            cout << "#" << string(A[i].second - 2, '.') << "#" << endl;
        }
        cout << string(A[i].second, '#') << endl;
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 2944
N = int(input())

grid = []

for i in range(N):
    grid.append([int(x) for x in input().split()])

dp = [[0]*3 for i in range(N)]
dp[0] = grid[0]

for i in range(1,N):
    for j in range(3):
        dp[i][j] = max(dp[i-1][k]+grid[i][j] for k in {0,1,2}-{j})

print(max(dp[:][N-1]))

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

int main() {
    string s;
    cin >> s;
    for(int i=0; i <= 2; ++i){
    	if(s[i] == '1') s[i] = '9';
    	else s[i] = '1';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
flag = 0
for i in range(1, 1001):
    iP = i * 0.08
    for j in range(1, 1001):
        jP = j * 0.1
        if int(iP) == A and int(jP) == B:
            if i == j:
                print(i)
                flag = 1
                break
    if flag == 1:
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;
  int a[2][n];
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    int sum = 0;
    for(int j = 0; j <= i; j++){
      sum += a[0][j];
    }
    for(int j = i; j < n; j++){
      sum += a[1][j];
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int t,n;
  for(int i=0;i<4;i++){
    cin>>t>>n;
    if(t==1){
      cout<<n*6000<<'\n';
    }
    if(t==2){
      cout<<n*4000<<'\n';
    }
    if(t==3){
      cout<<n*3000<<'\n';
    }
    if(t==4){
      cout<<n*2000<<'\n';
    }
  }
  return(0);
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
vecll divisor;
void fd(ll x){
  for(int i=1; i*i<=x; i++){
    if(x%(i)==0){
      divisor.push_back(i);
      if((x/i)!=i){
        divisor.push_back(x/i);
      }
    }
  }
  sortall(divisor);
}

int main(void) {
  ll x;
  cin >> x;

  fd(x);

  //prt2("--", divisor.size());

  rep(i,divisor.size()){
    rep(a,100000){
      ll b=a-divisor[i];
      //prt2(a,b);
      ll k=a*a*a*a*a-b*b*b*b*b;
      //prt(k);
      if(k>x && b>0) break;
      if(k==x){
        prt2(a, b);
        return 0;
      }
    }
  }


}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 0) cout << 0 << endl;
    else if (a + b > 0) cout << 1 << endl;
    else if (a + b < 0) cout << -1 << endl;
}


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

using namespace std;
typedef long long ll;

vector<vector<int> > vec(200010, vector<int>());
int cnt[200010];

void s(int c, int to) {
  if (c > 2) {
    return;
  }
  cnt[to] = c;
  for(int i = 0; i < vec[to].size(); i++) {
    s(c + 1, vec[to][i]);
  }
}

int main() {
  int N, M;
  cin >> N >> M;

  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    vec[a].push_back(b);
  }

  s(0, 1);

  if (cnt[N] == 2) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 9208
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 100010;

struct Node {
	int x, y;
} w[N];

inline bool cmp(Node a, Node b)
{
	if (a.y == b.y) return a.x < b.x;
	return a.y < b.y;
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d %d", &w[i].x, &w[i].y);
	}
	sort(w + 1, w + m + 1, cmp);
	int lst = 0, ans = 0;
	for (int i = 1; i <= m; ++i) {
		if (w[i].x > lst) {
			++ans;
			lst = w[i].y - 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using R = double;

ll C[51][51];

void comb_table(int N) {
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= i; ++j) {
            if(j == 0 or j == i) {
                C[i][j] = 1LL;
            } else {
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
            }
        }
    }
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    const int NMAX = 50;
    ll v[NMAX];
    for(int i = 0; i < N; i++) cin >> v[i];

    comb_table(N);
    sort(v, v + N);
    reverse(v, v + N);

    R max_average = 0.0;
    for(int i = 0; i < A; i++) max_average += v[i];
    max_average /= A;
    
    int a_num = 0, a_pos = 0;
    for(int i = 0; i < N; ++i) {
        if(v[i] == v[A - 1]) {
            a_num++;
            if(i < A) a_pos++;
        }
    }

    ll cnt = 0LL;
    if(a_pos == A) {
        for(a_pos = A; a_pos <= B; ++a_pos) {
            cnt += C[a_num][a_pos];
        }
    } else {
        cnt += C[a_num][a_pos];
    }

    printf("%.10f\n", max_average);
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#include <iostream>

constexpr int MAX_N = 300;
constexpr int MAX_M = 100;

int main(){
	int N, M;

	int friends[MAX_N], tgts[MAX_M];

	std::cin >> N >> M;

	for(int i = 0; i < N; ++i){
		friends[i] = 0;
	}

	for(int i = 0; i < M; ++i){
		int input;
		std::cin >> input;
		--input;

		tgts[i] = input;
	}

	for(int i = 0; i < M; ++i){
		for(int j = 0; j < N; ++j){
			int input;
			std::cin >> input;
			--input;

			if(input == tgts[i]){
				++friends[j];
			}
			else{
				++friends[tgts[i]];
			}
		}
	}

	for(int i = 0; i < N; ++i){
		std::cout << friends[i] << std::endl;		
	}

	return 0;
}

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

int N;
ll M;

bool C(const vector<ll> &v, ll K) {
    ll cnt = 0;
    REP(i,N) {
        cnt += (ll)(v.end() - lower_bound(all(v),K-v[i]));
    }
    return cnt >= M;
}

int main(){
    cin >> N >> M;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    sort(all(A));
    ll ub = 1LL<<30;
    ll lb = 0;
    ll mid;
    while(ub-lb>1) {
        mid = (ub + lb) / 2;
        bool f = C(A,mid);
        if (f) lb = mid;
        else ub = mid;
    }
    vector<ll> B(N+1,0);
    REP(i,N) B[i+1] = B[i] + A[i];
    ll ans = 0;
    ll cnt = 0;
    REP(i,N) {
        int itr = lower_bound(all(A),lb+1-A[i]) - A.begin();
        ans += A[i] * ((ll)N-itr) + B[N] - B[itr];
        cnt += (ll)N - itr;
    }
    ans += (M - cnt) * lb;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';
ll num=1, ans=0, cnt=0, sum=0;

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

  ll k, a, b;
  cin >> k >> a >> b;
  if(a%k == 0) cout << "OK" << newl;
  else if(b/k - a/k >= 1) cout << "OK" << newl;
  else cout << "NG" << newl;
  return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 5e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
vector<LL> ans;

void DFS(LL num, int pre,int cur,int maxlen){
    int st,en;
    if(ans.size()>100000) return;
    if(cur>maxlen){
        ans.push_back(num);
        return;
    }
    if(pre==-1){
        st=1;
        en=9;
    }
    else{
        st=max(0,pre-1);
        en=min(9,pre+1);
    }
    for(int i=st;i<=en;i++){
        LL tmpnum=num*10+i;
        DFS(tmpnum,i,cur+1,maxlen);
    }
}

void work(){
    for(int i=1;i<=10;i++){
        DFS(0,-1,1,i);
    }
//    for(int i=1;i<300;i++) printf("%lld\n",ans[i-1]);
    int k; scanf("%d",&k);
    printf("%lld\n",ans[k-1]);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 1400
object Main extends App {

  def solve(inputs: Array[Char]) = {
    def inner(ss: Array[Char], inps: Array[Char]): (Array[Char], Array[Char]) = {
      if (inps.isEmpty) (ss, Array())
      else {
        if (inps.head == 'B') inner(ss.take(ss.length - 1), inps.tail)
        else inner(ss ++ Array(inps.head), inps.tail)
      }
    }

    val (output, inps) = inner(Array(): Array[Char], inputs)
    output.mkString

  }

  val sc = new java.util.Scanner(Console.in)
  val s  = sc.next().toCharArray
  println(solve(s))
}

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

using namespace std;

const int MAXN = 5010;
const int MAXK = 5010;

int n, k;
vector<int> a;

bool A[MAXN][MAXK];
bool Arev[MAXN][MAXK];

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

    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    memset(A, 0, sizeof(A));
    A[0][0] = true;
    for (int i = 0; i < n; i++) {
        for (int s = 0; s < MAXK; s++) {
            if (!A[i][s]) {
                continue;
            }
            int new_sum = min(MAXK - 1, s + a[i]);
            A[i + 1][new_sum] = true;
            A[i + 1][s] = true;
        }
    }

    memset(Arev, 0, sizeof(Arev));
    Arev[0][0] = true;
    for (int i = 0; i < n; i++) {
        for (int s = 0; s < MAXK; s++) {
            if (!Arev[i][s]) {
                continue;
            }
            int new_sum = min(MAXK - 1, s + a[n - i - 1]);
            Arev[i + 1][new_sum] = true;
            Arev[i + 1][s] = true;
        }
    }

//     for (int s = 0; s <= k; s++) {
//         cout << s << ": " << A[n - 1][s] << endl;
//     }

    int good_elems = 0;
    for (int i = 0; i < n; i++) {
        int left = i;
        int right = n - i - 1;

        vector<int> cnt(MAXK, 0);
        for (int s = 0; s < MAXK; s++) {
            cnt[s] = (s ? cnt[s - 1] : 0) + (Arev[right][s] ? 1 : 0);
        }

        for (int l = 0; l < k; l++) {
            if (!A[left][l]) {
                continue;
            }
            int q = cnt[k - l - 1] -
                (k - a[i] - l - 1 >= 0 ? cnt[k - a[i] - l - 1] : 0);
//             cerr << i << ' ' << l << ' ' << q << endl;
            if (q) {
//                 cerr << "good\n";
                good_elems++;
                break;
            }
        }
    }
    cout << n - good_elems << endl;
}


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

int main() {
  int x[100]={0};
  int a, b = 0, c=0, ans = 0;
  cin >> a;
  for(int i=0;i<a;i++){
      cin >> x[i];
      b += x[i];
  }
  c = (double)b /(double) a + 0.5;
  for(int i=0;i<a;i++){
      ans+=(x[i]-c)*(x[i]-c);
  }
  cout << ans << endl;
}

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

int main() {
	int m;
	int t[3]={0};
	while(cin>>m){
		for(int i=0;i<3;i++)
			if(m>t[i]) swap(t[i],m);
	}
	for(int i=0;i<3;i++){
		cout<<t[i]<<endl;
	}
	return 0;
}

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

if k == 0:
    print(n**2)
else:
    ans = 0
    cnt = 1
    for b in range(k+1,n+1):
        ans += cnt*(n//b)
        if (n-b*(n//b))-(k-1) > 0:
            ans += (n-b*(n//b))-(k-1)
        cnt += 1
        #print(ans)
    print(ans)

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

int main(){
	int n, num;
	cin >> n;
	vector<int> vec(n);
	for (int i=0; i<n; i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	num = vec.at(n-1)-vec.at(0);
	cout << num << endl;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;



public class Main {
    public static void main(String[] args){
      int r,c;
      Scanner sc= new Scanner(System.in);
       r=sc.nextInt();//列 4
       c=sc.nextInt();//行  5
    
      int[][] mark= new int[r+1][c+1]; 
      
      for(int i=0;i<r;i++){
          for(int j=0;j<c;j++){
             mark[i][j]=sc.nextInt();
             }
      }
      
      for(int i=0;i<r;i++){
          int sumc=0;
          for(int y=0;y<c+1;y++){
              if(y!=c){//5
                 sumc+=mark[i][y]; 
              }else{
                  mark[i][y]=sumc;
              }
             
          }
      }
      for(int i=0;i<c+1;i++){
          int sumc=0;
          for(int y=0;y<r+1;y++){
              if(y!=r){
                 sumc+=mark[y][i]; 
              }else{
                  mark[y][i]=sumc;
              }
             
          }
      }
      
    
          for(int i=0;i<r+1;i++)
          {
              for(int y=0;y<c+1;y++)
              {
                  if(y!=c)
                  {
                      System.out.printf("%d ",mark[i][y]); 
                  }
                  else{System.out.printf("%d\n",mark[i][y]);
                  }
              }
          }
      
      
      
      
    } 
     
}




Measured memory_bytes: 58140
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll inf = 1e16;
const ll mod = 998244353;

int N,K,Q;
int arr[maxn];
int main(){
////    freopen("in.txt", "r", stdin);
//    ios::sync_with_stdio(0);
//    cin.tie(0);cout.tie(0);
    cin>>N>>K>>Q;
    int t;
    for(int i = 0;i<Q;i++){
        scanf("%d",&t);
        arr[t]++;
    }
    for(int i = 1;i<=N;i++){
        if(Q-arr[i]>=K) puts("No");
        else puts("Yes");
    }
    
    return 0;
}


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

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

	if ((a + b + c) % 2 != 0) {
		cout << "No" << endl;
	}
	else if ((a + b) == c) {
		cout << "Yes" << endl;
	}
	else if ((a + c) == b) {
		cout << "Yes" << endl;
	}
	else if ((b + c)== a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<iostream>
using namespace std;
const int maxn=10005;
typedef long long ll;
const int inf=0x3fffffff;
const int mod=1000000007;

int n,a,b;
string s;

int main() {
    //freopen("in.cpp","r",stdin);
    cin>>n>>a>>b;
    int call=0,cb=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='c')cout<<"No"<<endl;
        else if(s[i]=='a'){
            if(call<a+b){
                call++;
                cout<<"Yes"<<endl;
            } else cout<<"No"<<endl;
        }
        else{
            if(call<a+b&&cb<b){
                cb++;
                call++;
                cout<<"Yes"<<endl;
            }else cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
vector<int> A;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	bool F = true;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) F = false;
	}
	if (F) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int p[k+1];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<k+1;i++)p[i]=-1;
    for(int i=0;i<k+1;i++){
        for(int j=0;j<n;j++){
            if(i+a[j]<=k)if(p[i+a[j]]!=1)p[i+a[j]]=-1*p[i];
        }
    }
    if(p[k]==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[1000000],b[10000000],c[1000000],dp[1000000][4];
ll fun(ll n,ll ch)
{
    if(n<=0)
    return 0;
    if(n>0 && dp[n][ch]!=-1)
    return dp[n][ch];
    ll ans=INT_MIN;
    if(ch!=0)
    {
       
        ans=max(ans,a[n]+fun(n-1,0));
    }
    if(ch!=1)
    {
     
        ans=max(ans,b[n]+fun(n-1,1));
    }
    if(ch!=2)
    {
       
        ans=max(ans,c[n]+fun(n-1,2));
    }
    return dp[n][ch]=ans;
}
int main()
{
    ll i,n;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        
    }
    cout<<fun(n,4)<<endl;
}

Measured memory_bytes: 41864
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
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() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N;
	cin >> N;
 
	vl A(N), B(N), C(N - 1);
 
	ll out = 0;
 
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		cin >> B[i];
		out += B[i];
	}
	rep(i, N-1) {
		cin >> C[i];
	}
 
	rep(i, N-1) {
		if (A[i] == A[i + 1] - 1) {
			out += C[A[i]-1];
		}
	}
 
	cout << out << endl;



	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
    int e,y;
    cin >> e >> y;
    if(e==0){
        if(y>=1868&&y<=1911){
            cout << "M" << "" << y-1867 << endl;
        }else if(y>=1912&&y<=1925){
            cout << "T" << "" << y-1911 << endl;
        }else if(y>=1926&&y<=1988){
            cout << "S" << "" << y-1925 << endl;
        }else{
            cout << "H" << "" << y-1988 << endl;
        }
    }else if(e==1){
        cout << 1867+y << endl;
    }else if(e==2){
        cout << 1911+y << endl;
    }else if(e==3){
        cout << 1925+y << endl;
    }else{
        cout << 1988+y << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <climits>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

long long int bfs(vector< vector< pair<int, long long int> > > &graph, vector<long long int> &cons, int root) {
	vector<bool>visited(graph.size(), false);
	queue<int> q; q.push(root);
	visited[root] = true;
	cons[root] = 0;
	int n = graph.size() / 2;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int i = 0; i < graph[u].size(); ++i) {
			int v = graph[u][i].first;
			long long int w = graph[u][i].second;
			if (u < n) {
				if (cons[v] == LLONG_MAX) {
					cons[v] = cons[u] + w;
				} else {
					if (cons[v] != cons[u] + w) {
						return 0;
					}
				}
			} else {
				if (cons[v] == LLONG_MIN) {
					cons[v] = cons[u] - w;
				} else {
					if (cons[v] != cons[u] - w) {
						return 0;
					}
				}
			}
			if (!visited[v]) {
				q.push(v);
				visited[v] = true;
			}
		}
	}

	// for (int i = 0; i < n; ++i) {
	// 	cout << cons[i] << " " << cons[i + n] << endl;
	// }

	long long int solve = LLONG_MAX;
	for (int i = 0; i < n; ++i) {
		if (cons[i] != LLONG_MIN && cons[i + n] != LLONG_MAX) {
			long long int sum = cons[i] + cons[i + n];
			if (sum % 2 == 1) {
				return 0;
			} else {
				if (solve == LLONG_MAX) {
					solve = sum;
				} else {
					if (sum != solve) {
						return 0;
					}
				}
			}
		}
	}

	long long int lb = 0, ub = LLONG_MAX;
	for (int i = 0; i < n; ++i) {
		lb = max(lb, cons[i]);
		ub = min(ub, cons[i + n]);
	}
	long long int range = ub - lb - 1;
	if (range <= 0) {
		return 0;
	} else {
		if (solve != LLONG_MAX) {
			return 1;
		} else {
			return range;
		}
	}
}
 
int main(void) {
	int n, m;
	cin >> n >> m;
 
	vector< vector< pair<int, long long int> > > graph(2 * n);
 
	int u, v;
	long long int s;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v >> s;
		--u; --v;
		graph[u].push_back(make_pair(v + n, s));
		graph[v + n].push_back(make_pair(u, s));
		graph[v].push_back(make_pair(u + n, s));
		graph[u + n].push_back(make_pair(v, s));
	}

	vector<long long int> cons(2 * n);
	for (int i = 0; i < n; ++i) {
		cons[i] = LLONG_MIN;
		cons[i + n] = LLONG_MAX;
	}
	cout << bfs(graph, cons, 0) << endl;
	return 0;
}





Measured memory_bytes: 17280
#include <complex.h>
#include <math.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

int main() {
  xy_t P[100];
  int n;

  cin >> n;
  
  for (int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    P[i] = xy_t(x,y);
  }

  //center all coordinates based on first element
  for (int i = 1; i < n; i++) {
    P[i] -= P[0];
  }
  
  //calculate sum
  double sum = 0.0;
  for (int i = 1; i+1 < n ; i++) {
    xy_t  a = P[i] , b = P[i + 1];
    sum += cross_product(a, b) / 2.0;
  }

  printf("%.1f\n", abs(sum));
  
}

Measured memory_bytes: 3288
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    int table[h + 1][w + 1] = {};
    int dp[h + 1][w + 1] = {};
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cin >> table[i][j];
            dp[i][j] = (table[i][j] ? 0 : 1);
        }
    }
    int ans = 0;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            if(table[i][j]) continue;
            dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans * ans << endl;
    return 0;
}




Measured memory_bytes: 18476
n, a, b=map(int, input().split())
s=str(input())
cnt_a=0
cnt_b=0
for i in range(len(s)):
    if s[i]=='c':
        print('No')
    if s[i]=='a':
        if cnt_a+cnt_b<a+b:
            cnt_a+=1
            print('Yes')
        else:
            print('No')
    if s[i]=='b':
        if cnt_a+cnt_b<a+b and cnt_b<b:
            cnt_b+=1
            print('Yes')
        else:
            print('No')
        
    
    


Measured memory_bytes: 52952
n, m = map(int, input().split())
*point, = map(int, input().split())
count = 0
border = sum(point) / (4*m)
FLG = False

for num in point:
    if num >= border:
        count += 1

    if count >= m:
        FLG = True
        break

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

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, t;
    cin >> n >> t;
    ll ans = 0;
    ll time = 0;
    for (ll i = 0; i < n; i++)
    {
        ll v;
        cin >> v;
        if (time <= v)
        {
            ans += t;
            time = v + t;
        }
        else
        {
            ans += t - (time - v);
            time = v + t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 998244353;
signed main() {
    int h, w;
    cin>>h>>w;
    map<char, int> m;
    char c;
    for (int i = 0; i < h * w; i++) cin>>c, m[c]++;

    int cnt1, cnt2 = 0, cnt4 = 1;
    if (h % 2 && w % 2) cnt1 = 1;
    else cnt1 = 0;

    if (h % 2) cnt2 += w / 2;
    if (w % 2) cnt2 += h / 2;

    cnt4 *= h / 2;
    cnt4 *= w / 2;

    for (auto&& p: m) {
        if (p.second % 2) {
            p.second--;
            cnt1--;
            break;
        }
    }

    for (auto&& p: m) {
        if (p.second % 2) {
            cout<<"No"<<endl;
            return 0;
        } else if (p.second % 4 == 2) {
            p.second -= 2;
            cnt2--;
        }
    }

    if (cnt2 < 0) {
        cout<<"No"<<endl;
        return 0;
    }

    for (auto&& p: m) while (cnt4 > 0 && p.second > 0) cnt4--, p.second -= 4;

    for (auto&& p: m) {
        while (cnt2 > 0 && p.second > 0) p.second -= 2, cnt2--;
    }

    if (cnt1 == cnt2 && cnt2 == cnt4 && cnt4 == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	lli a, b, k, rema, remb;
	cin >> a >> b >> k;
	if (k <= a)
	{
		cout << a - k << " " << b << endl;
		return 0;
	}
	k -= a;
	if (k <= b)
	{
		cout << 0 << " " << b - k << endl;
	}
	else
	{
		cout << 0 << " " << 0 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}

////////////////////////////////////////////////////////////////////

int n;vector<int> g[210000];
int sum;
int dfs(int v, int pre){
  int ret = 1;
  rep(i,g[v].size()){
    int to = g[v][i];
    if(to == pre)continue;
    int cnt = dfs(to,v);
    ret += cnt;
    sum = (((sum + modpow(2, n))%MOD + (MOD - modpow(2, cnt)))%MOD + (MOD - modpow(2, n-cnt))) %MOD + 1;
    //cout << to << " " << cnt << " " << sum << endl;
  }
  return ret;
}

signed main(){
  cin>>n;
  rep(i,n-1){
    int aa, bb;cin>>aa>>bb;aa--;bb--;
    g[aa].push_back(bb);
    g[bb].push_back(aa);
  }
  dfs(0, -1);
  sum = (sum + modpow(2, n) - 1 + MOD - (modpow(2, n-1) * n)%MOD)%MOD;
  cout << (sum * modinv(modpow(2, n)))%MOD << endl;
}




Measured memory_bytes: 22912
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> H;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		H.push_back(x);
	}
	int a = 0, b = abs(H[1]-H[0]);
	int min = b;
	for (int i = 2; i < N; i++)
	{
		int x = a + abs(H[i] - H[i - 2]);
		int y = b + abs(H[i] - H[i - 1]);
		if (x > y)
		{
			min = y;
		}
		else
		{
			min = x;
		}
		a = b;
		b = min;
	}
	cout << min << endl;
}

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

using namespace std;

int N;
const int maxn = 100010;
int dp[maxn][3];

int nums[maxn][3];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> nums[i][0] >> nums[i][1] >> nums[i][2];
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (k == j) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k] + nums[i][j]);
			}
		}
	}

	int ans = 0;
	ans = max(ans, dp[N][0]);
	ans = max(ans, dp[N][1]);
	ans = max(ans, dp[N][2]);
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
#define N 3050
int n,p,c[N][N],s[N][N];
int pw(int a,int b,int p){int as=1;while(b){if(b&1)as=1ll*as*a%p;a=1ll*a*a%p;b>>=1;}return as;}
int main()
{
	scanf("%d%d",&n,&p);
	for(int i=0;i<=n;i++)c[i][i]=c[i][0]=1;
	for(int i=2;i<=n;i++)
	for(int j=1;j<i;j++)
	c[i][j]=(c[i-1][j-1]+c[i-1][j])%p;
	s[1][1]=1;s[0][0]=1;
	for(int i=2;i<=n;i++)
	for(int j=1;j<=i;j++)
	s[i][j]=(1ll*j*s[i-1][j]+s[i-1][j-1])%p;
	int as=0;
	for(int i=0;i<=n;i++)
	{
		int tp=1ll*(i&1?p-1:1)*c[n][i]%p*pw(2,pw(2,n-i,p-1),p)%p;
		int s1=1,s2=pw(2,n-i,p);
		for(int k=0;k<=i;k++)
		as=(as+1ll*tp*(s[i][k]+1ll*s[i][k+1]*(k+1)%p)%p*s1)%p,s1=1ll*s1*s2%p;
	}
	printf("%d\n",as);
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    string o,e;
    cin>>o>>e;
    string ans(SZ(o)+SZ(e),'#');
    int c=0;
    REP(i,SZ(o)) {
        ans[c]=o[i];
        c+=2;
    }
    c=1;
    REP(i,SZ(e)) {
        ans[c]=e[i];
        c+=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define INF 1e9+7
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
using P=pair<int,int>;
int d[21][21]={};
char maze[21][21];
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h)rep(j,w){
        cin>>maze[i][j];
        d[i][j]=INF;
    }
   int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
    queue<P> que;
    int mx=0;
    rep(i,h)rep(j,w){
        if(maze[i][j]=='#')continue;
        rep(m,h)rep(k,w)d[m][k]=INF;
        
        que.push(P(i,j));
        d[i][j]=0;
        
        while(!que.empty()){
            P now=que.front();
            que.pop();
            
            rep(k,4){
                int nx=now.first+dx[k],ny=now.second+dy[k];
                if(nx>=0&&nx<h&&ny>=0&&ny<w){
                    if(maze[nx][ny]=='.'&&d[nx][ny]==INF){
                        d[nx][ny]=d[now.first][now.second]+1;
                       // cout<<d[nx][ny]<<endl;
                        mx=max(mx,d[nx][ny]);
                        que.push(P(nx,ny));
                    }
                }
            }  
        }
    }
    cout<<mx<<endl;
    return 0;
}

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

int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  cin>>x1>>y1>>x2>>y2;
  int dx=x2-x1;
  int dy=y2-y1;
  x3=x2-dy;
  y3=y2+dx;
  x4=x3-dx;
  y4=y3-dy;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}


Measured memory_bytes: 256
def R(dice,U,S):
  def f(x): return str(dice.index(x))
  PAT=["12431","03520","01540","04510","02530","13421"]
  it=f(U)+f(S)
  for i in range(6):
    if PAT[i].find(it)>=0: return dice[i]

dice = map(int,raw_input().split())
for _ in [0]*int(raw_input()):
  U,S=map(int,raw_input().split())
  print R(dice,U,S)

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  sort(a.begin(), a.end());
  vector<int> x, y;
  int maxv = a.back(), minv = a.front();
  for (int i = 1; i < n - 1; i ++) {
    if (a[i] >= 0) {
      x.push_back(minv);
      y.push_back(a[i]);
      minv -= a[i];
    } else {
      x.push_back(maxv);
      y.push_back(a[i]);
      maxv -= a[i];
    }
  }
  x.push_back(maxv);
  y.push_back(minv);

  cout << maxv - minv << endl;
  for (int i = 0; i < x.size(); i ++) {
    cout << x[i] << " " << y[i] << endl;
  }
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    if (N == 1) {
        cout << abs(W - a[N - 1]) << endl;
        return 0;
    }
    cout << max(abs(W - a[N - 1]), abs(a[N - 1] - a[N - 2])) << endl;
}


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

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

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var D = cin.ReadIntArray(4);
			var (a,b,h,m)=(D[0], D[1], D[2], D[3]);
			var th = (h+m/60d)*PI*2/12;
			var tm = m*PI*2/60;
			var td = th-tm;
			var Res = a*a+b*b-2*a*b*Cos(td);
			Console.WriteLine(Sqrt(Res));
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

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

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second 

int main()
{
	ll n,x;
	cin>>n>>x;

	ll a[n];

	for(ll i = 0 ; i < n ; i++)
	{
		cin>>a[i];
	}

	vector<ll> d;

	d.pb(0);

	for(ll i = 0 ; i < n; i++)
	{
		ll t1 = d[i] + a[i];
		d.pb(t1);
	}

	ll idx = upper_bound(d.begin(),d.end(),x) - d.begin();

	cout<<idx<<endl;


}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long i64;

i64 lucas[90] = {};

i64 get_lucas(int n){
    if(n == 0) return 2;
    else if(n == 1) return 1;
    else{
        if(lucas[n] != 0) return lucas[n];
        else return lucas[n] = get_lucas(n - 1) + get_lucas(n - 2);
    }
}

int main(void){
    int n;
    scanf("%d", &n);

    printf("%lld\n", get_lucas(n));
    return 0;    
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
tmp = 0
key = 0
SUMA = sum(a)

for i in range(n):
    if tmp + a[i] >= SUMA / 2:
        key = i
        break
    tmp += a[i]

ans = abs(sum(a[0:key]) - sum(a[key::]))
tmp = 0
key += 1
ans = min(abs(sum(a[0:key]) - sum(a[key::])), ans)
print(ans)


Measured memory_bytes: 89804
N, M = map(int, input().split())
H = list(map(int, input().split()))
ten = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ten[a].append(b)
    ten[b].append(a)
ans = 0
for i in range(N):
    flag = True
    for j in ten[i]:
        if H[i] <= H[j]:
            flag = False
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 29512
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static int num = 0;
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] a = new int[scanner.nextInt()];

		
		for(int i = 0; i < a.length; i++) {
			a[i] = scanner.nextInt();
		}
		
		int[] b = sortlist(a);
		for(int i = 0; i < a.length - 1; i++) {
			System.out.print(b[i]+" ");
		}
		System.out.print(b[a.length - 1]);
		System.out.println();
		System.out.println(num);
		scanner.close();
	}
	
	private static int[] sortlist(int[] i) {
		if(i.length == 1) {
			return i;
		}else {
			
			int[] a = sortlist(Arrays.copyOfRange(i,0,i.length/2));
			int[] b = sortlist(Arrays.copyOfRange(i, i.length/2, i.length));
			int j = 0, k = 0;
			while(j < a.length && k < b.length) {
				num += 1;
				if(a[j] > b[k]) {
					i[j+k] = b[k];
					k++;
				}else {
					i[j+k] = a[j];
					j++;
				}
			}
			if(j == a.length) {
				while(k < b.length) {
					num += 1;
					i[j+k] = b[k];
					k++;
				}
			}else {
				while(j < a.length) {
					num+= 1;
					i[j+k] = a[j];
					j++;
				}
			}
			return i;
		}
	}
}


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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int W,H;
int A[20][20];
int sy,sx,gy,gx;
int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};
int ans;

inline bool ok(int y,int x){
    return 0<=y&&y<H&&0<=x&&x<W;
}

void dfs(int y,int x,int t){
    if(t==10)return;
    rep(d,4){
        int yy=y+dy[d],xx=x+dx[d];
        if(!ok(yy,xx))continue;
        if(A[yy][xx])continue;
        bool go=true;
        while(true){
            if(yy==gy&&xx==gx){
                chmin(ans,t+1);
                go=false;
                break;
            }
            yy+=dy[d];xx+=dx[d];
            if(!ok(yy,xx)){
                go=false;
                break;
            }
            if(A[yy][xx])break;
        }
        if(!go)continue;
        A[yy][xx]=0;
        dfs(yy-dy[d],xx-dx[d],t+1);
        A[yy][xx]=1;
    }
}

signed main(){
    while(cin>>W>>H,W||H){
        rep(i,H)rep(j,W){
            cin>>A[i][j];
            if(A[i][j]==2)sy=i,sx=j,A[i][j]=0;
            if(A[i][j]==3)gy=i,gx=j,A[i][j]=0;
        }
        ans=11;
        dfs(sy,sx,0);
        if(ans==11)cout<<-1<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3072