akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	ll n,i; cin >>n>>i;
	
	cout <<n-i+1<<endl;
	
	
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,l,r,ans=0;
	string s;
	cin >> s;
	l = 0; r = s.l_ength()-1;
	while(l<r){
		if(s[l]==s[r]){
			++l; --r;
		}else if(s[l]=='x'){
			++ans; ++l;
		}else if(s[r]=='x'){
			++ans; --r;
		}else{
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

// 0-indexd
namespace Heap {
  template<typename T, std::size_t N>
  void MaxHeapify_S1(T (&ps)[N], int n, int x) {
    int left = (x << 1) + 1;
    int right = (x << 1) + 2;
    int maxi = x;
    if( left < n ) {
      if( ps[maxi] < ps[left] ) {
        maxi = left;
      }
    }
    if( right < n ) {
      if( ps[maxi] < ps[right] ) {
        maxi = right;
      }
    }
    if( maxi != x ) {
      std::swap(ps[maxi], ps[x]);
      MaxHeapify_S1(ps, n, maxi);
    }
  }
  template<typename T, std::size_t N>
  void MaxHeapify(T (&ps)[N], int n) {
    assert( n <= (int)N );
    for(int i = n / 2; i >= 0; --i) {
      MaxHeapify_S1(ps, n, i);
    }
  }
};
using namespace Heap;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B
void Verify_1() {
  int xs[512345];
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &xs[i]);
  }
  MaxHeapify(xs, n);
  for(int i = 0; i < n; ++i) {
    printf(" %d", xs[i]);
  }
  puts("");
}

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

Measured memory_bytes: 5100
#data????§???????[y???][x???]??§??????

if __name__ == "__main__":
    while 1:
        w,h = list(map(int,input().strip().split()))
        if w == h == 0:break
        data = []
        data = []
        for _ in range(h):data.append(list(input()))
        visited = []
        position =(0,0)
        for i in range(h):
            if '@'in data[i]:position = (i,data[i].index('@'))
        stack = []
        count = 0
        stack.append(position)
        while len(stack) !=0:
            y,x= stack.pop()
            count +=1
            if y-1 >= 0 and not (y-1,x)in visited and data[y -1][x] == '.':
                visited.append((y-1,x))
                stack.append((y-1,x))
            if x -1 >= 0 and not (y,x-1)in visited and data[y][x-1] == '.':
                visited.append((y,x-1))
                stack.append((y,x-1))
            if y +1 < h and not (y+1,x)in visited and data[y +1][x] == '.':
                visited.append((y+1,x))
                stack.append((y+1,x))
            if x + 1 < w and not (y,x+1)in visited and data[y][x +1] == '.':
                visited.append((y,x+1))
                stack.append((y,x+1))

        print(count)

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

int main(){

    int n;
    int ans=0;
    cin>>n;
    vector<int> v(n),c(n);
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];

    for(int i=0;i<n;i++){
        if(v[i]-c[i]>0) ans+=v[i]-c[i];
    }
    cout<<ans<<endl;



    return 0;
}

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

using namespace std;
typedef long long LL;

const int N=1e5+10;

struct Edge{int to,next,cost; }way[N<<1];

int n,m,num[N],tot;
LL ans;

void Build(int a,int b,int cost) { way[++tot]=(Edge){b,num[a],cost}; num[a]=tot; }

void Init()
{
	scanf("%d%d",&n,&m);
	int a,b;
	for (int i=1;i<=m;++i)
	{
		scanf("%d%d",&a,&b);
		Build(a,b,1); Build(b,a,2);	
	}
}

int cnt[4],col[N],totedge;
bool circle;
void Dfs(int x)
{
	cnt[col[x]]++;
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to,d=(col[x]+way[i].cost)%3;
		if (i&1) totedge++;
		if (col[v]==-1) col[v]=d,Dfs(v);
		else if (col[v]!=d) circle=1;
	}
}

void Solve()
{
	for (int i=1;i<=n;++i) col[i]=-1;
	
	LL ans=0;
	for (int i=1;i<=n;++i)
		if (col[i]==-1)
		{
			circle=0; totedge=0; col[i]=0; cnt[0]=cnt[1]=cnt[2]=0;
			Dfs(i);
			if (circle) ans+=1ll*(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]);
			else if (cnt[0] && cnt[1] && cnt[2]) ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
			else ans+=totedge;
		}
	printf("%lld\n",ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}


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

typedef pair<ll,ll> P;
bool used[1000][1000][1000];

int main(void){
    ll X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    ll A[X],B[Y],C[Z];
    rep(i,X) cin >>A[i];
    rep(i,Y) cin >>B[i];
    rep(i,Z) cin >>C[i];
    
    sort(A,A+X);
    sort(B,B+Y);
    sort(C,C+Z);
    
    ll num = (X-1)*1000*1000 + (Y-1)*1000 + (Z-1);
    ll sum = A[X-1] + B[Y-1] + C[Z-1];
    
    P p = {sum,num};
    
    priority_queue <P> que;
    que.push(p);
    
    ll cnt =0;
    while(1){
        p = que.top();
        que.pop();
        sum = p.first;
        num = p.second;
        ll x=num/(1000*1000),y=(num/1000)%1000,z=num%1000;
        if(used[x][y][z])continue;
        cout << sum << endl;
        if(x>0){
            sum = A[x-1] + B[y] + C[z];
            num = (x-1)*1000*1000 +y*1000 + z;
            p = {sum,num};
            que.push(p);
        }
        if(y>0){
            sum = A[x] + B[y-1] + C[z];
            num = x*1000*1000 +(y-1)*1000 + z;
            p = {sum,num};
            que.push(p);
        }
        if(z>0){
            sum = A[x] + B[y] + C[z-1];
            num = x*1000*1000 +y*1000 + z-1;
            p = {sum,num};
            que.push(p);
        }
        used[x][y][z] = true;
        cnt++;
        if(cnt == K)return 0;
    }
}

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

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

  int n;
  cin>>n;

  int a[n];

  int ans=0;

  for(int i=0; i<n; i++) {
    cin>>a[i];
    if((i+1)&1 and a[i]&1) {
        ans++;
    }
  }

  cout<<ans;
}

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    set<char> memo;
    for (auto c : s) memo.insert(c);

    bool is_find = false;
    for (char c = 'a'; c <= 'z'; ++c) {
        if (memo.count(c) == 0) {
            cout << c << endl;
            is_find = true;
            break;
        }
    }

    if (!is_find) cout << "None\n";

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long n; cin >> n;

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

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

int main(int argc, char *argv[])
{
  int **A;
  int **B;
  long **C;
  int n, m, l, i, j, k;

  scanf("%d %d %d", &n, &m, &l);

  A = (int **)malloc(sizeof(int *) * n);
  for (i = 0; i < n; i++) {
    A[i] = (int *)malloc(sizeof(int) * m);
  }
  B = (int **)malloc(sizeof(int *) * m);
  for (j = 0; j < m; j++) {
    B[j] = (int *)malloc(sizeof(int) * l);
  }
  C = (long **)malloc(sizeof(long *) * n);
  for (i = 0; i < n; i++) {
    C[i] = (long *)malloc(sizeof(long) * l);
  }

  for (i = 0; i < n; i++) {
    for (k = 0; k < l; k++) {
      C[i][k] = 0;
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &A[i][j]);
    }
  }
  for (j = 0; j < m; j++) {
    for (k = 0; k < l; k++) {
      scanf("%d", &B[j][k]);
    }
  }

  for (i = 0; i < n; i++) {
    for (k = 0; k < l; k++) {
      for (j = 0; j < m; j++) C[i][k] += A[i][j] * B[j][k];
    }
  }

  for (i = 0; i < n; i++) {
    for (k = 0; k < l; k++) {
      if (k != l - 1) printf("%ld ", C[i][k]);
      else printf("%ld\n", C[i][k]);
    }
  }

  return 0;
}

Measured memory_bytes: 760
X,Y,A,B,C=map(int, input().split())
AA=list(map(int, input().split()))
BB=list(map(int, input().split()))
CC=list(map(int, input().split()))
AA=sorted(AA,reverse=True)
BB=sorted(BB,reverse=True)
CC=sorted(CC,reverse=True)
XX=sorted(AA[0:X]+BB[0:Y]+CC,reverse=True)
XX=XX[0:X+Y]
print(sum(XX))

Measured memory_bytes: 23328
#include<stdio.h>
#include<math.h>
int a[100003];
int main(){
	int n,m,i,j,f,x,ans;
	scanf("%d%d",&n,&m);
	a[0]=0;
	for(i=1;i<n;i++){
		scanf("%d",&x);
		a[i]=a[i-1]+x;
	}
	ans=f=0;
	for(i=0;i<m;i++){
		scanf("%d",&x);
		ans=(ans+abs(a[f+x]-a[f]))%100000;
		f+=x;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int n,h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    int ans = 0;
    for(int i=n-1; i>=0 && b[i]>a[n-1] && h>0; i--){
        h -= b[i];
        ans++;
    }
    if(h>0){
        ans += (h+a[n-1]-1)/a[n-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,x; cin >> n >> x;
    vector<ll> a(n+1);
    for(int i = 0; i < n; i++) cin >> a[i+1];
    ll ans = 0;
    rep(i,0,n){
        if(a[i] + a[i+1] >= x){
            ans += a[i] + a[i+1] - x;
            a[i+1] = x - a[i];
        }
    }

    cout << ans << "\n";

}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
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 lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  ll a; cin >>a;
  double b; cin >>b; b *= 100; b += 0.5;
  ll res = a * (int)b / 100;
  cout <<res <<endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


int main() {
    vector<ll> abc(3);
    ll k; cin >> abc[0] >> abc[1] >> abc[2] >> k;

    sort(abc.begin(), abc.end());
    ll ans = abc[0] + abc[1] + (abc[2] * pow(2, k));

    cout << ans << endl;




    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll dp[2010][2010];
ll brui[2010][2010];//b番目の数字　wをいくつ見たか 
ll wrui[2010][2010];//w番目の数字  bをいくつ見たか

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<pair<char,ll> >pcl(2*n);
  for(int i=0;i<=n+1;i++)
    for(int j=0;j<=n+1;j++)
      dp[i][j]=llINF;
  dp[0][0]=0;
  for(int i=0;i<n*2;i++){
    cin>>pcl[i].F>>pcl[i].S;
    for(int j=0;j<i;j++){
      if(pcl[i].F=='B'){
	if(pcl[j].F=='W'){
	  brui[pcl[i].S][pcl[j].S]--;
	  brui[pcl[i].S][0]++;
	}else{
	  if(pcl[i].S<pcl[j].S){
	  brui[pcl[i].S][n+1]--;
	  brui[pcl[i].S][0]++;
	  }
	}
      }else{
	if(pcl[j].F=='W'){
	  if(pcl[i].S<pcl[j].S){
	  wrui[pcl[i].S][n+1]--;
	  wrui[pcl[i].S][0]++;
	  }
	}else{
	  wrui[pcl[i].S][pcl[j].S]--;
	  wrui[pcl[i].S][0]++;
	}
      }
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      brui[i][j+1]+=brui[i][j];
      wrui[i][j+1]+=wrui[i][j];
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]+brui[i+1][j]);
      dp[i][j+1]=min(dp[i][j+1],dp[i][j]+wrui[j+1][i]);
    }
  }
  cout<<dp[n][n]<<endl;
  return 0;
}


Measured memory_bytes: 94848
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ee := make([][]int, n)
	ww := make([]int, n)
	for i := 0; i < n; i++ {
		ee[i] = make([]int, 0)
	}

	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		ww[a]++
		ee[a] = append(ee[a], i+1)
	}

	fmt.Fprintln(writer, dfs(0, ww, ee))
}

func dfs(i int, ww []int, ee [][]int) int {
	max := 0
	cc := make([]int, 0)

	for _, to := range ee[i] {
		c := dfs(to, ww, ee)
		cc = append(cc, c)
	}
	sort.Ints(cc)
	n := len(cc)
	for i := 0; i < n; i++ {
		if max < cc[i]+n-i {
			max = cc[i] + n - i
		}
	}
	return max
}


Measured memory_bytes: 39680
#include <stdio.h>
#define MAX 100000
typedef long long ll;

int check(ll,ll*,int,int);
int main(){
  int n,k,i;
  ll lb,ub,mid,w[MAX],sum = 0;
 
  scanf("%d%d" ,&n ,&k);
  for(i = 0 ; i < n ; i++){
    scanf("%lld" ,&w[i]);
    sum += w[i];
  }
 
  lb = 0, ub = sum;
  while(ub - lb > 0){
    mid = (lb + ub) / 2;
 
    if(check(mid,w,n,k)){
      ub = mid;
    }else{
      lb = mid+1;
    }
  }
  printf("%lld\n" ,ub);
  return 0;
}
 
int check(ll limit,ll w[],int n,int k){
  int i,kk = 0;
  ll sum = 0;
 
  for(i = 0 ; i < n ; i++){
    if(limit < w[i]){
      return 0;
    }
    sum += w[i];
 
    if(sum == limit){
      kk++;
      sum = 0;
    }else if(sum > limit){
      kk++;
      sum = w[i];
    }
  }
 
  if(sum > 0){
    kk++;
  }
  return kk <= k;
}

Measured memory_bytes: 1376
import math
N,M = list(map(int,input().split(" ")))
X = list(map(int,input().split(" ")))
X.sort()
diffs = []

if N >= M:
    print(0)
else:
    for i,x in enumerate(X[1:]):
        diff = abs(x-X[i])
        diffs.append(diff)
    diffs.sort()
    # print(diffs)

    if N == 1:
        print(sum(diffs))
    else:
        print(sum(diffs[:-(N-1)]))


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

long long solve(long long N, vector<long long> A, vector<long long> B){
    vector<long long> Dif(N);
    for(int i=0;i<N;i++) Dif[i]=A[i]-B[i];
    vector<long long> minus;  
    vector<long long> plus;
    for(auto dif: Dif){
        if(dif<0)minus.push_back(dif);
        else{
            plus.push_back(dif);
        }
    }
    long long sumOfMinus = 0;
    for(auto elm: minus)
        sumOfMinus+=elm;
    sort(plus.begin(), plus.end());
    long long ans=minus.size();
    while(true){
        if(sumOfMinus>=0){
            return ans;
        }else{
            if(plus.size()>0){
                sumOfMinus+=plus[plus.size()-1];
                plus.pop_back(); //biggest
                ans++;
            }else{
                return -1;
            }
        }
    }
}
int main() {
    long long N;
    cin>>N;
    vector<long long> A(N), B(N);
    for(int i=0;i<N;i++)
        cin>>A[i];
    for(int i=0;i<N;i++)
        cin>>B[i];

    cout<<solve(N,A,B)<<endl;
}


Measured memory_bytes: 5116
#include<iostream>
using namespace std;
// 3D vector
class Vector3
{
public:
    Vector3(float fx, float fy, float fz)
        :x(fx), y(fy), z(fz)
    {
    }

    // Subtract
    Vector3 operator - (const Vector3& v) const
    {
        return Vector3(x - v.x, y - v.y, z - v.z) ;
    }

    // Dot product
    float Dot(const Vector3& v) const
    {
        return x * v.x + y * v.y + z * v.z ;
    }

    // Cross product
    Vector3 Cross(const Vector3& v) const
    {
        return Vector3(
            y * v.z - z * v.y,
            z * v.x - x * v.z,
            x * v.y - y * v.x ) ;
    }

public:
    float x, y, z ;
};

// Determine whether point P in triangle ABC
bool PointinTriangle(Vector3 A, Vector3 B, Vector3 C, Vector3 P)
{
    Vector3 v0 = C - A ;
    Vector3 v1 = B - A ;
    Vector3 v2 = P - A ;

    float dot00 = v0.Dot(v0) ;
    float dot01 = v0.Dot(v1) ;
    float dot02 = v0.Dot(v2) ;
    float dot11 = v1.Dot(v1) ;
    float dot12 = v1.Dot(v2) ;

    float inverDeno = 1 / (dot00 * dot11 - dot01 * dot01) ;

    float u = (dot11 * dot02 - dot01 * dot12) * inverDeno ;
    if (u < 0 || u > 1) // if u out of range, return directly
    {
        return false ;
    }

    float v = (dot00 * dot12 - dot01 * dot02) * inverDeno ;
    if (v < 0 || v > 1) // if v out of range, return directly
    {
        return false ;
    }

    return u + v <= 1 ;
}
int main()
{
    float x1,y1,x2,y2,x3,y3,xp,yp;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
    {
        Vector3 A(x1,y1,1);
        Vector3 B(x2,y2,1);
        Vector3 C(x3,y3,1);
        Vector3 P(xp,yp,1);
        if(PointinTriangle(A,B,C,P))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }


    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
static const double eps = 1e-10;
bool equals(double a, double b)
{
	return(fabs(a - b) < eps);
}

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

	Point operator + (Point p){ return(Point(x + p.x, y + p.y)); }
	Point operator - (Point p){ return(Point(x - p.x, y - p.y)); }
	Point operator * (double a){ return(Point(a * x, a * y)); }
	Point operator / (double a){ return(Point(x / a, y / a)); }

	double abs(){ return(sqrt(norm())); }
	double norm(){ return(x * x + y * y); }

	bool operator < (const Point& p) const
	{
		return(x != p.x ? x < p.x : y < p.y);
	}

	bool operator == (const Point& p) const
	{
		return(fabs(x - p.x) < eps && fabs(y - p.y) < eps);
	}
};
typedef Point Vector;

struct Segment
{
	Point p1, p2;
};
typedef Segment Line;

class Circle
{
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) : c(c), r(r){}
};

double dot(Vector a, Vector b)
{
	return(a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
	return(a.x * b.y - a.y * b.x);
}

Point project(Segment s, Point p)
{
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return(s.p1 + base * r);
}

Point reflect(Segment s, Point p)
{
	return(p + (project(s, p) - p) * 2.0);
}

bool isOrthogonal(Vector a, Vector b)
{
	return(equals(dot(a, b), 0.0));
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
	return(isOrthogonal(a1 - a2, b1 - b2));
}

bool isOrthogonal(Segment s1, Segment s2)
{
	return(equals(dot(s1.p2 - s2.p1, s2.p2 - s2.p1), 0.0));
}

bool isParallel(Vector a, Vector b)
{
	return(equals(cross(a, b), 0.0));
}

bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
	return(isParallel(a1 - a2, b1 - b2));
}

bool isParallel(Segment s1, Segment s2)
{
	return(equals(cross(s1.p1 - s1.p1, s2.p2 - s2.p1), 0.0));
}

void solve()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		Point p[4];
		for (int j = 0; j < 4; ++j)
		{
			cin >> p[j].x >> p[j].y;
		}
		if (isParallel(p[0], p[1], p[2], p[3]))
		{
			cout << "2" << endl;
		}
		else if (isOrthogonal(p[0], p[1], p[2], p[3]))
		{
			cout << "1" << endl;
		}
		else
		{
			cout << "0" << endl;
		}
	}
}

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

Measured memory_bytes: 1224
readlines.map(&:chomp).each{|input|
  t, h, s = input.split.map(&:to_i)
  break if t == -1 && h == -1 && s == -1
  tape = 120 * 60
  tape -= t * 3600 + h * 60 + s
  tape3 = tape * 3
  s = tape % 60
  h = ((tape - s) / 60) % 60
  t = (tape - s - h * 60) / 3600
  puts "%02d:%02d:%02d" % [t, h, s]
  s = tape3 % 60
  h = ((tape3 - s) / 60) % 60
  t = (tape3 - s - h * 60) / 3600
  puts "%02d:%02d:%02d" % [t, h, s]
}

Measured memory_bytes: 8568
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n,p;
    cin>>n>>p;
    for(ll i=pow(p,1.0/double(n))+1;i>0;i--){
        if(p%ll(pow(i,n))==0){
            cout<<i<<endl;
            return 0;
        }
    }
}


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

using namespace std;

static const int INFTY = (1<<30);

int V[10][10],mem[10][10][51];
int f,H,W,m,res;

// p=0 ????????????p=1?????????p=2??????
void solve(int x, int y, int o, int p, int cost) {
  if (o <= 0) return;
  // ????´???¨?????????????¨????
  if (V[y][x] >= 0) {
    o += V[y][x];
    if (o > m)
      o = m;
  } else {
    cost -= V[y][x];
  }
  // ?????§?????¨????¶????????????????
  if (cost > f) return;
  // ?????¢???
  if(mem[x][y][o] < cost) return;
  mem[x][y][o] = cost;
  if (y == H-1) {
    res = min(res,cost);
    return;
  }
  solve(x, y+1, o-1, 0, cost);
  if(x-1 >= 0 && p != 2) solve(x-1, y, o-1, 1, cost);
  if(x+1 < W && p != 1) solve(x+1, y, o-1, 2, cost);
}

int main() {
  int o;
  while(cin >> W >> H, W) {
    cin >> f >> m >> o;
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
        cin >> V[i][j];
    for(int i=0; i<10; i++)
      for(int j=0; j<10; j++)
        for(int k=0; k<=m; k++)
          mem[i][j][k]=INFTY;
    res = INFTY;
    for(int i=0; i<W; i++)
      solve(i, 0, o-1, 0, 0);
    if(res == INFTY)
      cout << "NA" << endl;
    else
      cout << res << endl;
  }
    
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)cin>>a[i];

  ll ans=0;
  while(true){
    ll k=0;
    REP(i,n)k+=a[i]/n;

    if(k==0)
      break;

    REP(i,n)a[i]=a[i]-a[i]/n*(n+1)+k;

    ans+=k;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
  int n,m,cnt=0;
  cin >> n >> m;
  int k,a,like[30]={};
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a;
      like[a-1]++;
    }
  } 
  for(int i=0;i<m;i++){
    if(like[i]>=n) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p + q, p + r, q + r}) << endl;
    return 0;
    
}

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

int main(void){
    int d, n, x, ans = 0, cnt = 1;
    cin >> d >> n;
    x = pow(100, d);
    if (n == 100) n++;
    while (cnt <= n){
        ans += x;
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 262144
int dat[N*2+10],ad[N*2+10];
int inf=1000000000;
//[a,b)の最小値
//外からは(a,b,0,0,N)として呼ぶ
int query(int a,int b,int k=0,int l=0,int r=N){
	if(r<=a || b<=l) return inf;
	if(a<=l && r<=b) return dat[k]+ad[k];
	int vl=query(a,b,k*2+1,l,(l+r)/2);
	int vr=query(a,b,k*2+2,(l+r)/2,r);
	return ad[k]+min(vl,vr);
}
//[a,b)に加算する
void add(int a,int b,int x,int k=0,int l=0,int r=N){
	if(r<=a || b<=l) return;
	if(a<=l && r<=b) ad[k]+=x;
	else{
		add(a,b,x,k*2+1,l,(l+r)/2);
		add(a,b,x,k*2+2,(l+r)/2,r);
		dat[k]=min(dat[k*2+1]+ad[k*2+1],dat[k*2+2]+ad[k*2+2]);
	}
}
void update(int k,int a){
	k+=N-1;
	dat[k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1]+ad[k*2+1],dat[k*2+2]+ad[k*2+2]);
	}
	return;
}
//今kにどれくらいの数が加算されているのか
int cal(int k){
	k+=N-1;
	int ret=ad[k];
	while(k>0){
		k=(k-1)/2;ret+=ad[k];
	}
	return ret;
}
int b[200100];
vector<pint> v;
int main()
{
	int n,q,l,r;
	cin>>n;
	rep(i,n) cin>>b[i];
	cin>>q;
	rep(i,q){
		cin>>l>>r;l--;
		v.pb(mp(l,r));
	}
	v.pb(mp(0,0));v.pb(mp(n,n));sort(All(v));
	memset(ad,0,sizeof(ad));
	rep(i,N*2+10) dat[i]=inf;
	update(0,0);
	rep(i,q+1){
		REP(j,v[i].fi,v[i+1].fi){
			if(b[j]==0) add(j+1,n+10,1);
			else add(0,j+1,1);
		}
		if(i>=q) break;
		l=v[i+1].fi;r=v[i+1].se;
		int now=query(0,r+1),su=cal(r);
		update(r,now-su);
	}
	cout<<query(0,n+10)<<endl;
}


Measured memory_bytes: 6768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  if (S.size() >= 4U && S.substr(0, 4) == "YAKI") {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main(){
long long int i,j,k,l,m,n,x,y,a,b,c,r1=0,r2=0;
cin>>x>>y>>a>>b>>c;
vector<long long int> p,q,r,v;
for(i=0;i<a;i++){
	cin>>j;
p.push_back(j);
}
for(i=0;i<b;i++){
	cin>>j;
q.push_back(j);
}
for(i=0;i<c;i++){
	cin>>j;
r.push_back(j);
v.push_back(j);
}
sort(p.begin(),p.end(),greater<long long int>());
sort(q.begin(),q.end(),greater<long long int>());
//sort(r.begin(),r.end(),greater<long long int>());
for(i=0;i<x;i++)
r.push_back(p[i]);
for(i=0;i<y;i++)
r.push_back(q[i]);
sort(r.begin(),r.end(),greater<long long int>());//sort(r.begin(),r.end(),greater<long long int>());
for(i=0;i<x+y;i++)
	r1+=r[i];
cout<<r1;

}

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

using namespace std;

#define ll long long

const int mxN = 1003;
const int mo = 1e9 + 7;

int dp[mxN][mxN]={{0}};
int h, w;
char c;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w;
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j <= w; j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            } else if (i == 1 && j == 1 ) {
                cin >> c;
                dp[i][j] = 1;
            } else {
                cin >> c;
                if (c == '.')
                    dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mo;
            }
        }
    }
    cout << dp[h][w] << endl;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,m,lim,cnt[310][310],sq[310][310];

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

int main()
{
	n=read();m=read();lim=read();
	memset(sq,0x3f,sizeof(sq));
	memset(cnt,0x3f,sizeof(cnt));
	rep(i,1,n) sq[i][i]=cnt[i][i]=0;
	rep(i,1,m)
	{
		int u=read(),v=read(),w=read();
		sq[u][v]=sq[v][u]=w;
	}
	rep(k,1,n) rep(i,1,n) rep(j,1,n)
		sq[i][j]=min(sq[i][j],sq[i][k]+sq[k][j]);
	rep(i,1,n) rep(j,1,n)
		if ((i!=j) && (sq[i][j]<=lim)) cnt[i][j]=1;
	rep(k,1,n) rep(i,1,n) rep(j,1,n) 
		cnt[i][j]=min(cnt[i][j],cnt[i][k]+cnt[k][j]);
	int ask=read();
	while (ask--)
	{
		int u=read(),v=read();
		if (cnt[u][v]<maxd) printf("%d\n",cnt[u][v]-1);
		else printf("-1\n");
	}
	return 0;
}
	

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define INF 10000000000
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;

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

    while(cin >> w >> h >> n){
        ans = 0;
        ll board[h][w] = {};
        rep(i, n){
            cin >> x >> y >> a;
            if(a == 1){
                rep(j, h){
                    rep(k, x){
                        board[j][k]++;
                    }
                }
            }else if(a == 2){
                rep(j, h){
                    rep(k, x, w){
                        board[j][k]++;
                    }
                }
            }else if(a == 3){
                rep(j, h - y, h){
                    rep(k, w){
                        board[j][k]++;
                    }
                }
            }else{
                rep(j, h - y){
                    rep(k, w){
                        board[j][k]++;
                    }
                }
            }
        }
        rep(i, h){
            rep(j, w){
                if(board[i][j] == 0){
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.


int main() {
int N;
cin >> N;
long long int a[N][3];
for (int i = 0; i < N; ++i)
{
	cin >> a[i][0] >> a[i][1] >> a[i][2];
}

long long int dp[N][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];

for (int i = 1; i < N; ++i)
{
	dp[i][0] = max(dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
	dp[i][1] = max(dp[i-1][0]+a[i][1], dp[i-1][2]+a[i][1]);
	dp[i][2] = max(dp[i-1][1]+a[i][2], dp[i-1][0]+a[i][2]);
}

cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) <<endl;

   return 0;
}

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

int main()
{
    int i,j,p,q,r,c=0;
    string a,b;

    cin>>a>>b;

    p=a.length();
    q=b.length();

    for(i=0,j=0;i<p,j<q;i++,j++)
    {
        if(a[i]==b[j])
           c++;
    }

    cout<<c<<endl;

    return 0;

}


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

from collections import deque

an = list(map(int, input().split()))

bn = list(map(int, input().split()))

accum_a = [0]
accum_b = [0]

for a_i in range(0, len(an)):
    a_i = accum_a[-1] + an[a_i]
    if a_i > k:
        break
    accum_a.append(a_i)

for b_i in range(0, len(bn)):
    i_ = accum_b[-1] + bn[b_i]
    if i_ > k:
        break
    accum_b.append(i_)

ans = 0
for a_i in range(len(accum_a)):

    sumCandidate = accum_a[a_i]
    rest = k - sumCandidate

    j = (len(accum_b)) // 2
    finalBIndex = j
    left = -1
    right = len(accum_b)
    while right - left > 1:
        mid = left + (right - left) // 2

        if accum_b[mid] > rest:
            right = mid
        else:
            left = mid

    ans = max(ans, a_i + right - 1)

print(ans)


Measured memory_bytes: 124108
#include <iostream>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin>>x>>y;
		if(x==0&&y==0)break;
		if(x>y){
			swap(x,y);
		}
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

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

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

  int h,m,s;
  h=S/3600;
  S%=3600;
  m=S/60;
  S%=60;
  s=S;
  cout << h << ":";
  cout << m << ":";
  cout << s << endl;
}



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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    // 処理
    int d   = 0;
    int tmp = 0;
    int ans = 0;

    for (int i = 0; i < k; i++) {
        tmp = max({a, b, c});
        if (tmp == a) {
            a = a * 2;
        } else if (tmp == b) {
            b = b * 2;
        } else {
            c = c * 2;
        }
        ans = a + b + c;
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a==5 && b==5 && c==7){
    cout<<"YES\n";
}

    else if(a==5 && b==7 && c==5){
        cout<<"YES\n";
    }

else if(a==7 && b==5 && c==5){
    cout<<"YES\n";
}
else{
    cout<<"NO\n";
}

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e18;
const int inf=(1ull<<31)-1;
ll a,b,k;

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>a>>b>>k;
	if (k>=a)
		k-=a,
		a=0,
		b=max(b-k,(ll)0);
	else 
		a-=k;
	cout<<a<<" "<<b;
	return 0;
}

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


signed main(){
	int h,w;cin>>h>>w;
  	vector<string>s(h);
	for(auto&& u:s)cin>>u;

	vector<vector<int>>l(h+2,vector<int>(w+2,0));
	vector<vector<int>>r(h+2,vector<int>(w+2,0));
	vector<vector<int>>u(h+2,vector<int>(w+2,0));
	vector<vector<int>>d(h+2,vector<int>(w+2,0));

//  int l[h+2][w+2],r[h+2][w+2],u[h+2][w+2],d[h+2][w+2];

	rep0(i,h)rep0(j,w){
		if(s[i-1][j-1]=='.'){
		l[i][j]=l[i][j-1]+1;
		u[i][j]=u[i-1][j]+1;
		}
	}
	rep1(i,h)rep1(j,w){
		if(s[i-1][j-1]=='.'){
		r[i][j]=r[i][j+1]+1;
		d[i][j]=d[i+1][j]+1;
	}
	}
	int ret=0;
	rep0(i,h)rep0(j,w){
	if(s[i-1][j-1]=='.')ret=max(ret,l[i][j]+u[i][j]+r[i][j]+d[i][j]-3);
	}
	cout<<ret<<endl;

}


Measured memory_bytes: 129920
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;

    REP(S,1<<3){
        int result=s[0]-'0';
        REP(i,3){
            if(S>>i&1) result+=s[i+1]-'0';
            else result-=s[i+1]-'0';
        }
        if(result==7){
            string ans="0-0-0-0=7";
            REP(i,4) ans[2*i]=s[i];
            REP(i,3) if(S>>i&1) ans[2*i+1]='+';
            cout<<ans<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c-min(a, b + c)+b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    LL A,B,C,K;cin >> A >> B >> C >> K;
    if(abs(A-B)>=1000000000000000000){
        COUT("Unfair");
        return 0;
    }
    COUT(K%2==0?A-B:-(A-B));
    return 0;
}


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

int main() {
  string s;
  int x, y, sx = 0;
  int N = 8010;
  int slen = 32010;
  int len = 0;
  int lens[N];
  int lens_idx = 0;
  bool dp[2][2][slen];
  int offset = slen / 2;
  cin >> s >> x >> y; x += offset; y += offset;

  for (int i=0; s[i]=='F' && i<s.length(); i++) sx++;
  
  for (int i=0; i<N; i++) {
    lens[i] = 0;
  }
  for (int j=0; j<slen; j++) {
    dp[0][0][j] = dp[0][1][j] = false;
    dp[1][0][j] = dp[1][1][j] = false;
  }
  dp[0][0][offset + sx] = true;
  dp[1][0][offset] = true;
  for (int i=sx + 1; i<s.length(); i++) {
    if (s[i] == 'T') {
      lens[lens_idx++] = len;
      len = 0;
    } else {
      len++;
      if (i == s.length() - 1) lens[lens_idx++] = len;
    }
  }

  for (int li=0; li<lens_idx; li++) {
    for (int i=lens[li]; i<slen-lens[li]; i++) {
      dp[1-(li&1)][(li/2+1)&1][i] = dp[1-(li&1)][(li/2)&1][i - lens[li]] | dp[1-(li&1)][(li/2)&1][i + lens[li]];
    }
    for (int j=0; j<slen; j++) {
      dp[1-(li&1)][(li/2)&1][j] = false;
    }
  }
  cout << ((dp[0][(lens_idx/2)&1][x] & dp[1][((lens_idx+1)/2)&1][y]) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main() {
int L;
cin >> L;
int i,c;
int f = -1;
vector<int> s;
vector<bool> v(110,false);
for(i=0;i<L&&f<0;i++) {
cin >> c;
if(c>0) {
if(!v[c]) {
s.push_back(c);
v[c] = true;
}
else f = i+1;
}
else if(s.size()==0?false:s[s.size()-1]==-c) {
s.erase(s.end()-1);
v[-c] = false;
}
else f = i+1;
}
if(f>0)cout << f << endl;
else cout << "OK" << endl;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
#include<utility>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc104_c(){
    //入力
    int n;
	cin >> n;
  
    //処理
  
    //出力
    cout << 48-n << enter;
    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s;
    string t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256