akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<unordered_set>
#define N 105
#define UNDEFINED -1
static const int INF = (1<<21);

int n;
int u, k, v, c;
int G[N][N];
int distance[N], hasVisited[N];


void dijkstra(int s) {
    int minv;
    distance[s] = 0;
    while(true) {
        minv = INF;
        int u = UNDEFINED;
        for (int i = 0; i < n; ++i) {
            if(minv > distance[i] && hasVisited[i] != 1) {
                u = i;
                minv = distance[i];
            }
        }
        if(u == UNDEFINED) break;
        hasVisited[u] = 1;
        for (int v = 0; v < n; ++v) {
            if(distance[v] > distance[u] + G[u][v]) {
                distance[v] = distance[u] + G[u][v];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        printf("%i %i\n", i, distance[i]);
    }
}

int main() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            G[i][j] = INF;
        }
        distance[i] = INF;
        hasVisited[i] = 0;
    }

    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> u >> k;
        for (int j = 0; j < k; ++j) {
                std::cin >> v >> c;
                G[u][v] = c;
            }
        }

    dijkstra(0);

    return 0;
}


Measured memory_bytes: 3184
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int num = stdin.nextInt();
		
		long[] numbers = new long[num];
		long max = -1000001;
		long min = 1000001;
		long sum = 0;
	    
		for(int i = 0; i < num; i++) {
			numbers[i] = stdin.nextLong();
	          if(max < numbers[i]) max = numbers[i];
	          if(min > numbers[i]) min = numbers[i];
	          sum = sum + numbers[i];
		}
	
		
		System.out.println(min + " "+ max + " " + sum);
		
		stdin.close();
	}

}

Measured memory_bytes: 41872
import java.util.Scanner;
import java.util.HashSet;
//import java.util.Collections;

class Main{
      public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int x = sc.nextInt();
	int n = sc.nextInt();
	HashSet<Integer> p = new HashSet<>();
	for(int i=0;i<n;i++){
	    p.add(sc.nextInt());
	}
	if(n==0){
	    System.out.println(x);
	}else{
	    for(int i=0;;i++){
		if(!p.contains(x-i)){
		    System.out.println(x-i);
		    break;
		}
		if(!p.contains(x+i)){
		    System.out.println(x+i);
		    break;
		}
	    }
	}
	sc.close();
      }
}


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

int main(){
	int N, H, a, b;
	pair<int, int> maxp;
	
	cin >> N >> H;
	vector<pair<int, int>> vp(N);
	rep(i, N){
		cin >> a >> b;
		vp.at(i) = make_pair(a, b);
		if(i == 0 || maxp.first < a) maxp = vp.at(i);
	}
	
	sort(vp.begin(), vp.end(), [](auto const &l, auto const &r)->bool{
		return l.second > r.second;
	});
	
	int ans = 0;
	for(auto itr = vp.begin(); itr != vp.end(); itr++){
		if(H <= 0 || (itr->second) < maxp.first) break;
		H -= itr->second;
		ans++;
	}
	if(H > 0) ans += (H + maxp.first - 1)/(maxp.first);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n,cnt=1;
	cin >> n;
	vector<int>d(n);
	for (int& x : d)cin >> x;
	sort(d.begin(), d.end());
	for (int i = 0; i < n - 1; i++) {
		if (d[i] != d[i + 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

class Ps {
    String name;
    Integer t;
     
    public Ps( String name, Integer t )
    {
        this.name = name;
        this.t = t;
    }
}

class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
  
            String[] str = kb.readLine().split( " " );
            int n = Integer.parseInt( str[0] );
            int q = Integer.parseInt( str[1] );
             
            LinkedList<Ps> queue = new LinkedList<Ps>();
             
            for( int i=0; i<n; i++ ) {
                str = kb.readLine().split( " " );
                queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );
            }
 
            StringBuilder output = new  StringBuilder( );   
            Ps ps;         
            int time;
           	time = 0;
            while( null != ( ps = queue.poll() ) ) {
            	
                if( ps.t <= q ) {
                    output.append( ps.name );
                    output.append( " " );
                    time += ps.t;    
                    output.append(  time );
                    output.append( "\n" );
          
                } else {
                	ps.t -= q;
                    queue.offer( ps );
                    time += q;           
                }
            }
            System.out.print( output );
              
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 62896
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define DDD fixed<<setprecision(10)

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	double N;
	cin>>N;
	vector<double> A(N);
	REP(i,N){cin>>A[i];}

	double ans=0;
	REP(i,N){
		ans+=1/A[i];
	}
	ans=1/ans;

	cout<<DDD<<ans<<endl;




		

		return 0;
}




Measured memory_bytes: 3796
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template <typename T> using duo = std::pair<T, T>;
template <typename T> using vec = std::vector<T>;
using ll = long long;
using pii = duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<std::pair<T,int>>zipi(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() { //
  int N = in();
  auto A = in(N);
  int cnt = 0;
  rep(i, N) {
    int j = A[i] - 1;
    if (i > j) continue;
    if (A[j] == i + 1) cnt++;
  }
  pr(cnt);

  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

long long int modinv(long long int a, long long int m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//------------------------------------------------------------------------------------------------------------------------------


int main() {

	INPUT_INT(N);
	INPUT_LLINT(K);

	INPUT_VECTOR_INT(A, N);

	unsigned long long int a = 0; // Ai よりも大きい数が A 内にいくつあるか
	unsigned long long int b = 0; // Ai よりも後方で、かつ Ai よりも小さい数が A 内にいくつあるか (A内での転倒数)
	REP(i, N) {
		REP(j, N) {

			if (A[i] < A[j]) { ++a; }
			if (i < j && A[i] > A[j]) { ++b; }

		}
	}

	unsigned long long int d = 0;

	//for (int k = 1; k <= K; ++k) {
	//	d += a * (k - 1);
	//	d %= 1000000007;
	//}
	//d += b * K;
	//d %= 1000000007;

	//d += a * (K - 1) * K / 2;
	long long int X = (K-1) % 1000000007;
	long long int Y = K % 1000000007;
	d += (((a * X % 1000000007) * Y) % 1000000007) * modinv(2, 1000000007);
	d %= 1000000007;
	d += b * (K % 1000000007);
	d %= 1000000007;


	OUTPUT(d % 1000000007);

	return 0;
}

Measured memory_bytes: 256
/* 
* code by: imasnegi
**/

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

#define ll long long
#define nl "\n"
#define spc " "
#define fr(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define deb(a) cout << #a << " " << a << nl;

template<typename T>
void printArray(vector<T>& v) {
	for(auto& i : v)
		cout << i << spc;
	cout << nl;
}
const int MaxN = 2e5 + 5;
const int MOD = 1e9 + 7;

ll n;

void solve_cases() {
	cin >> n;

	set<ll> Set;
	Set.emplace(7);
	ll num = 7;
	ll cnt = 0;
	while(cnt <= 1e6+1) {
		num = num % n;
		if(num == 0) {
			cout << cnt + 1 << nl;
			return;
		}

		num = num * 10 + 7;
		if(Set.find(num) != Set.end()) {
			break;
		}
		Set.emplace(num);
		cnt++;
	}

	cout << "-1" << nl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cout << setprecision(10) << fixed;
	int t = 1;
	//cin >> t;
	FOR(tt, 1, t) {
		//cout << "Case #" << tt << ": ";
		solve_cases();
	}
}

Measured memory_bytes: 50452
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vvll a(9, vll(9));
    REP(i, n) {
        ll num = i + 1;
        ll last = num % 10, head;
        if (last == 0) continue;
        while (num) {
            if (num / 10 == 0) head = num;
            num /= 10;
        }
        a[last - 1][head - 1]++;
    }
    ll res = 0;
    REP(i, 9) {
        REP(j, 9) {
            res += a[i][j] * a[j][i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>


using namespace std;

int main() {
	int a;
	int b;
	int h;
	int m;

	cin >> a >> b >> h >> m;

	double ans;
	double theta;
	double hun;
	double ji;

	double theta_rad;
	theta_rad = abs(M_PI / 360 * (h * 60 + m) - M_PI / 30 * m);

	ans = sqrt(a * a + b * b - 2 * a * b * cos(theta_rad));

	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
N,M=map(int,input().split())

P=[]
A=round(M**0.5)+2
for i in range(1,A):
    if M%i==0:
        P.append(i)
        P.append(M//i)
P.sort()

B=M//N
ans=now=1
for p in P:
    now=p
    if now<=B:
        ans=now
print(ans)

Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9; //1(1倍)e(指数)9(10^9)
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = inf;
    for(int i = 0; i < n - 2; i++) {
        int temp = abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753);
        ans = min(ans, temp);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  string s;
  cin >> s;
  
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) {
    pt("Bad");
  }else {
    pt("Good");
  }
    
  
  
  
  
  
}












Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100000
#define FR first
#define SE second
pair<int,int> a[MAXN+5];
int n,b[MAXN+5],Pos[MAXN+5];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		a[i]=make_pair(b[i],i);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)Pos[a[i].SE]=i;
	for(int i=1;i<=n;i+=2)if(Pos[i]%2==0)ans++;
	printf("%d",ans);//
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long count = 0;
  long long r = 0, g = 0, b = 0;
  for (int i = 0; i < n; i++){
    if(s.at(i) == 'R') r++;
    else if(s.at(i) == 'G') g++;
    else if(s.at(i) == 'B') b++;
  }
  count = r * g * b;
  for (int i = 1; i < n; i++){
    for (int j = 0; j < n; j++){
      if(j+i+i > n-1) break;
      if(s.at(j) != s.at(j+i) && s.at(j) != s.at(j+i+i) && s.at(j+i) != s.at(j+i+i)) count --;
    }
  }
    
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3628
class Queue:
    def __init__(self, n):
        self.values = [None]*n
        self.n = n
        self.s = 0
        self.t = 0

    def next(self, p):
        ret = p+1
        if ret >= self.n:
            ret = 0
        return ret

    def enqueue(self, x):
        if self.next(self.s) == self.t:
            raise Exception("Overflow")
        self.values[self.s] = x
        self.s = self.next(self.s)

    def dequeue(self):
        if self.s == self.t:
            raise Exception("Underflow")
        ret = self.values[self.t]
        self.t = self.next(self.t)
        return ret

n, q = map(int, raw_input().split(' '))
queue = Queue(n+1)
for _ in range(n):
    name, time = raw_input().split(' ')
    time = int(time)
    queue.enqueue((name, time))

completed = []
cur = 0
while len(completed) < n:
    name, time = queue.dequeue()
    res = time-q
    if res <= 0:
        cur += time
        completed.append((name, cur))
    else:
        cur += q
        queue.enqueue((name, res))

for name, time in completed:
    print name, time

Measured memory_bytes: 18792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)


int main() {
    
    
    int n; cin >> n;
    map<int, int> mp;
    int a[n]; rep(i, n) { cin >> a[i]; mp[a[i]]++; }
    
    vector<pii> v;
    for (auto e : mp) {
        v.eb(pii(e.F, e.S));
        //out(e.F << " " << e.S);
    }
    if (v[0].F == 0 && v[0].S == n) out("Yes");
    else if (SZ(v) < 2) out("No");
    else if (v[0].F == 0 && v[0].S == n / 3 && v[1].S == 2 * n / 3) out("Yes");
    else if (SZ(v) == 2) out("No");
    else if ((v[0].F ^ v[1].F ^ v[2].F) == 0 && v[0].S == n / 3 && v[1].S == n / 3) out("Yes");
    else out("No");
}




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

typedef int64_t ll;

template <class T1, class T2>
using dict = std::unordered_map<T1, T2>;

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << max(A*B,C*D) << endl;
}

Measured memory_bytes: 256
while True:
  n, x = map(int,input().split())
  if n == 0 and x == 0:
    break
  else:
    l = []
    for i in range(1, n+1):
      for j in range(1, n+1):
        for k in range(1, n+1):
          if i + j + k == x and i != j and j != k and i !=k :
            l.append([f'{i},{j},{k}'])
  print(int(len(l) / 6))   




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


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

    string S;
    cin >> S;
    char moji;
    string ans="";
    for(moji='a';moji<='z';moji++){
        bool z=true;
        rep(i,S.size()){
            if(moji==S[i]){
                z=false;
                break;
            }
        }
        if(z) {
            ans=moji;
            break;
        }
    }
    if(ans=="") ans="None";
    cout << ans << endl;

}


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

using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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;
}

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll A, B, N;
    cin >> A >> B >> N;
    ll X = min(N, B-1);
    cout << (A*X)/B - A*(X/B) << endl;
}

Measured memory_bytes: 3652
/********************************************//**
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
#define endline "\n"
#define in(x) scanf("%d",&x);
const ll INF = 1e18L + 5;
const int inf = 1e9 + 5;
typedef pair<double, long> key;
struct comp {
	bool operator()(pair<int, int> p1, pair<int, int> p2) {
		if (p1.first < p2.first) return false;
		if (p2.first < p1.first) return true;
		return p1.second < p2.second;
	};
};
//greater<pair<int,int> , greater<int>>
ll a[M];


int main() {
	fastIO;
	int test = 1;
	//cin >> test;
	while (test--) {
		ll n;
		cin >> n;
		ll res = 0;
		ll a[n];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		for (int i = 1; i < n; i++) {
			if (a[i] >= a[i - 1]) continue;
			else {
				res += a[i - 1] - a[i];
				a[i] = a[i - 1];
			}
		}
		cout << res << endl;
	}




	return 0;

}


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

using namespace std;

const int TH = 333;
const int N_ = int(3.1e5);
using pii = pair<int, int>;

int N, M;
int A[N_];
vector<pii> pos[N_];

const int LEAF = 1<<19;
int tree[LEAF + LEAF];

void upd(int l, int r) {
  l += LEAF; r += LEAF;
  while(l <= r) {
    if( l & 1) tree[l] += 1;
    if(~r & 1) tree[r] += 1;
    l = (l + 1) >> 1;
    r = (r - 1) >> 1;
  }
}

int get(int x) {
  int ret = 0;
  x += LEAF;
  while(x > 0) {
    ret += tree[x];
    x >>= 1;
  }
  return ret;
}

int main() {
  scanf("%d%d", &N, &M);
  for(int i = 0; i < N; i++) {
    int l, r; scanf("%d%d", &l, &r);
    pos[r - l + 1].emplace_back(l, r); 
    // 길이가 L인 철로는, L >= D이면 무조건 지나감
  }

  int larger = N;
  for(int d = 1; d <= M; d++) {
    for(pii i : pos[d]) {
      upd(i.first, i.second);
      larger -= 1;
    }

    int ret = larger;
    for(int i = d; i <= M; i += d) {
      ret += get(i);
    }
    printf("%d\n", ret);
  }
  return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a_1(int a) {//素数判定
	int x = 0;
	for (int i = 2; i < a; i++) {
		if (a % i == 0)x++;
	}
	if (x == 0) {
		return 0;//素数であるとき
	}
	if (x != 0) {
		return 1;//素数でないとき
	}
}
int yakusuu(int n) {
	int ans = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		int cnt = 0;
		while (n % i == 0) {
			cnt++;
			n /= i;
		}
		ans *= (cnt + 1);
		if (n == 1) break;
	}
	if (n != 1) ans *= 2;
	return ans;
}
int gcd(int a, int b) {
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
int main() {
	int x, y;
	for (int i = 0;; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		cout << min(x, y) << " " << max(x, y) << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

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

	if (A == 1) A = 14;
	if (B == 1) B = 14;

	cout << ((A > B) ? "Alice" : ((A == B) ? "Draw" : "Bob")) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

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

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc054/tasks/abc054_c

int e[10][10];

int main() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        e[a][b] = 1;
        e[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) perm[i] = i+2;
    sort(perm.begin(), perm.end());

    int ans = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if(!e[now][perm[i]]) break;
            now = perm[i];
            if (i == perm.size() - 1) ans++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << ans << "\n";

    return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	string str;
	cin >> str;
	
	int rc = 0;
	if (str[0] == 'R') rc++;
	if (str[1] == 'R') rc++;
	if (str[2] == 'R') rc++;

	if (rc != 2) cout << rc << endl;
	else if (str[1] == 'R') cout << rc << endl;
	else cout << 1 << endl;


	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,k,a,L,MAX=0;
vector<int> v;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    for(int i=0;i<k;i++){
        L+=v[i]+1;
    }
    MAX=L;
    for(int i=0;i<n-k;i++){
        L+=v[k+i]+1;
        L-=v[i]+1;
        MAX=max(L,MAX);
    }
    cout<<setprecision(15)<<(long double)MAX/2.0<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

const int MAX = 1001001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    int n;
    cin>>n;
    cout<<n*n<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	long X;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		X = Long.parseLong(tokens[0]);
	}

	void calc() {
		long val = 100L;
		long count = 0;
		while (val < X) {
			double v = (double) val * 1.01;
			val = (long) Math.floor(v);
			++count;
		}
		System.out.println(count);
	}

	void showResult() {
	}

}


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

using namespace std;
#define EPS (1e-10)
typedef complex<double> P;
//実数同士の比較
bool EQ(double a, double b){
    return (abs(a - b) < EPS);
}
 
//二つのベクトルが等しいかどうか
bool EQV(P a, P b){
    return (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()));
}
 
//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}
 
//外積
double cross(P a, P b){
    return (a.real() * b.imag() - a.imag() * b.real());
}
 
// 点a,bを通る直線と点cとの距離
double distance_l_p(P a, P b, P c) {
  return abs(cross(b-a, c-a)) / abs(b-a);
}
 
// 点cが線分a,b上にあるかないか(3)
int is_point_on_line(P a, P b, P c) {
  // |a-c| + |c-b| <= |a-b| なら線分上
  return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}
 
// 点a,bを端点とする線分と点cとの距離
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}
 
//図を思い出す
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}
 
// a1,a2を端点とする線分とb1,b2を端点とする線分の交差判定
int is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 ) &&
           ( ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0 );
}
 
// a1,a2を通る直線とb1,b2を通る直線の交点計算
P intersection_l(P a1, P a2, P b1, P b2) {
  P a = a2 - a1; P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

double distance(P p0, P p1, P p2, P p3){
  double ans = 1e10;
        ans = min(ans, distance_ls_p(p0, p1, p2));
        ans = min(ans, distance_ls_p(p0, p1, p3));
        ans = min(ans, distance_ls_p(p2, p3, p0));
        ans = min(ans, distance_ls_p(p2, p3, p1));
        if(is_intersected_ls(p0, p1, p2, p3)) ans = 0.0;
		return ans;
}

int main(){
  while(true){
		int n; cin >> n;
		if(n == 0 )break;
		double x, y;
		cin >> x >> y;
		P s = P(x,y);
		cin >> x >> y;
		P g = P(x,y);
		vector<P> mins(n), maxs(n);
		vector<double> h(n);
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			//if(z == 24)printf("%.0f %.0f",x,y);
			mins[i].real(x); mins[i].imag(y);
			cin >> x >> y;
			//if(z == 24)printf(" %.0f %.0f",x,y);
			maxs[i].real(x); maxs[i].imag(y);
			cin >> h[i];
			//if(z == 24)printf(" %.0f \n",h[i]);
		}
		double ans = 1e9;
		for(int i = 0; i < n;i++){
			double d = 1e9;
			P p1 = mins[i], p3 = maxs[i];
			P p2(mins[i].real(), maxs[i].imag());
			P p4(maxs[i].real(), mins[i].imag());
			if(p1.real() < s.real() && s.real() < p3.real() && 
				p1.imag() < s.imag() && s.imag() < p3.imag()){
				ans = 0;/*
				if(z==24){
					printf("%.0f %.0f %.0f %.0f\n",p1.real(),p1.imag(),p3.real(),p3.imag());
					cout << "break" << endl;}*/
				break;
			}
			d = min(d, distance(s, g, p1,p2));
			d = min(d, distance(s, g, p2,p3));
			d = min(d, distance(s, g, p3,p4));
			d = min(d, distance(s, g, p4,p1));
			double r = (h[i]*h[i]+d*d)/(2*h[i]);
			if(h[i] < d){
				ans = min(ans, r);
			}
			else{
				ans = min(ans, d);
			}
		}
		printf("%.4f\n",ans);
	}

	return 0;
}




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

int main()
{
    int i,n,num[200000],b[200000];
    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&num[i]);
    for (i=0;i<n;i++)
    {
        if ((n-i)%2==0) b[n/2+(i+1)/2]=num[i];
        else b[n/2-(i+1)/2]=num[i];
    }
    for (i=0;i<n;i++)
        printf("%d ",b[i]);
    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;
const int N = 10001;
const int D = 101;
int dp[N][D][2][2];
int d, n;
char s[N];

int solve(int idx, int mod, bool notZero, bool lastDigit) {
    if (idx == n) {
        return mod == 0 && notZero;
    }
    int& ans = dp[idx][mod][notZero][lastDigit];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    if (lastDigit) {
        for (int i = 0; i <= s[idx] - '0'; i++) {
            ans += solve(idx + 1, (mod + (i) % d) % d, notZero || i, i == s[idx] - '0');
            ans %= MOD;
        }
    } else {
        for (int i = 0; i < 10; i++) {
            ans += solve(idx + 1, (mod + (i) % d) % d, notZero || i, false);
            ans %= MOD;
        }
    }
    return ans;
}

int main() {
    scanf("%s%d", s, &d);
    n = strlen(s);
    memset(dp, -1, sizeof dp);
    printf("%d\n", solve(0, 0, false, true));
    return 0;
}


Measured memory_bytes: 16896
// atcoder 44
#include <iostream>
using namespace std;

int solve(int n, int k, int x, int y) {
    int days = min(n, k);
    int rem = n - days;

    if (rem <= 0) {
        return x * days;
    } else {
        return (x * days) + (y * rem);
    }
}

int main(int argc, char** argv) {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;

    cout << solve(N, K, X, Y) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 
	int n=Int;
	int x=Int;
	if(n>=10) cout<<x<<endl;
	else cout<<x+100*(10-n)<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll N;
  cin >> N;
  vector<ll> l(N,0),r(N,0);//r->(  l->)

  FOR(i,0,N){
    string s;
    cin >> s;
    int cnt=0; // ( のあまり
    FOR(j,0,s.size()){
      if(s[j] == '(')cnt++;
      else{
        if(cnt==0)l[i]++;
        else cnt--;
      }
    }
    r[i] = cnt;
  }


  vector<P> rl;
  ll r_sum = 0;
  ll l_sum = 0;
  FOR(i,0,N){
    if(r[i]==0){
      l_sum += l[i];
    }else if(l[i]==0){
      r_sum += r[i];
    }else{
      rl.push_back({r[i]-l[i],-l[i]});
    }
  }
  SORT(rl);
  REV(rl);
  
  bool ok = true;
  ll cntr = r_sum;
  FOR(i,0,rl.size()){
    rl[i].first -= rl[i].second;
    rl[i].second *= -1;
    cntr -= rl[i].second;
    if(cntr < 0)ok = false;
    cntr += rl[i].first;
  }

  if(ok && cntr==l_sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 18764
#include <bits/stdc++.h>
        #define ll  long long int
        #define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
        #define mod 1000000007
        using namespace std;
    
        int main()
            {fast;
            ll t =1;
            //cin>>t;

        while(t--){
            ll n;
            cin>>n;

            ll arr[n];
            ll sum=0;
            for(int i=0; i<n;i++)
            cin>>arr[i], sum+=arr[i];
            ll ans=0;
            sum%=mod;
            for(int i=0; i<n-1;i++){
                sum-=arr[i];
                sum=(sum+mod)%mod;
                ans+= (sum*arr[i])%mod;
                ans%=mod;
            }
            cout<<(ans+mod)%mod;
        }
                return 0;
        }

Measured memory_bytes: 5224
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

//[x][y]
int connect[101][1001];

int main(){
  int virtical_num,horizontal_num,search_pos;

  while(~scanf("%d %d %d",&virtical_num,&horizontal_num,&search_pos)){
    if(virtical_num == 0 
       && horizontal_num == 0 
       && search_pos == 0) break;

    int max_h = 0;
    memset(connect,-1,sizeof(connect));
    for(int i=0;i<horizontal_num;i++){
      int h,from,to;
      scanf("%d %d %d",&h,&from,&to);
      connect[from][h] = to;
      connect[to][h] = from;
      max_h = max(h,max_h);
    }

    int x = search_pos;
    for(int y=max_h;y>=0;y--){
      if(connect[x][y] != -1){
	x = connect[x][y];
	// printf("x:%d\n",x);
      }
    }

    printf("%d\n",x);
  }
}

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

int main() {
  double mini, maxi, h;
  mini = maxi = -1.0;
  while(cin >> h) {
    if(mini == -1.0) {
      mini = maxi = h;
    } else {
      mini = min(mini, h);
      maxi = max(maxi, h);
    }
  }
  cout << maxi - mini << endl;
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int inf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, a, b;
string s;
bool c[100000];
signed main() {
	cin >> n >> a >> b >> s;
	a += b;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a'&&a > 0)
			c[i] = 1, a--;
		if (s[i] == 'b'&&a > 0 && b > 0)
			c[i] = 1, a--, b--;
	}
	for (int i = 0; i < n; i++) {
		if (c[i])
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	getchar(); getchar();
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,q;
const ll big = 1000000007;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);
uniform_int_distribution<> DD(0, 1000000000);

ll random(ll r){
    return (ll(DD(eng))*1000000000 + ll(DD(eng)))%r;
}

const ll MAXN = 5001;

ll P[MAXN];
ll P2[MAXN];

ll A,B;

ll DP[MAXN][MAXN] = {0};
bool DPC[MAXN][MAXN] = {0};

ll dp(ll i, ll rp){
    if(i == n)return 0;
    if(DPC[i][rp])return DP[i][rp];
    ll ans = 0;
    if(P2[i] < rp){
        ans = A + dp(i+1, rp);
    }
    else{
        ans = min(B + dp(i+1, rp), dp(i+1, P2[i]));
    }
    DP[i][rp] = ans;
    DPC[i][rp] = 1;
    return ans;
}

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

    ll a,b,c,d;

    cin >> n >> A >> B;

    for(int c1 = 0; c1 < n; c1++){
        cin >> a;
        a--;
        P[c1] = a;
        P2[a] = c1;
    }

    a = dp(0,0);
    cout << a << "\n";

    return 0;
}


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

using namespace std;

const int N = 1e5 + 11;
int dp[N][3];

int main(){
	int n; cin>>n;
	for(int i = 1; i <= n; i++){
		int a, b, c; cin>>a>>b>>c;
		
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
	}
	
	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<"\n";
	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	long long int a[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	long long int sum = accumulate(a, a + n, (long long int)0) / 2;
	long long int sum_l[100001] = {};
	long long int sum_r[100001] = {};
	// sum_l[i] = a[i] + a[i - 2] + a[i - 4] + ...
	// sum_r[i] = a[i] + a[i + 2] + a[i + 4] + ...
	sum_l[0] = a[0];
	sum_l[1] = a[1];
	sum_r[n - 1] = a[n - 1];
	sum_r[n - 2] = a[n - 2];
	for(int i = 2; i < n; i++){
		sum_l[i] = a[i] + sum_l[i - 2];
	}
	for(int i = n - 3; i >= 0; i--){
		sum_r[i] = a[i] + sum_r[i + 2];
	}

	cout << 2 * (sum - sum_r[1]) << " " << 2 * (sum - sum_r[2]) << " ";
	for(int i = 2; i < n - 1; i++){
		// x_iが含まれるのは a[i - 1]とa[i]
		cout << 2 * (sum - (sum_l[i - 2] + sum_r[i + 1])) << " ";
	}
	cout << 2 * (sum - sum_l[n - 3]) << endl;
}

Measured memory_bytes: 3712
import math
N,K = map(int,input().split())
P=list(map(int,input().split()))


maxnum=0
index=0
num=0
for i in range(len(P)):
    num+=P[i]
    if maxnum<num:
        maxnum=num
        index=i




    if i>=K-1:
        num-=P[i-(K-1)]


List=[]
for i in range(K):
    x1=P[index-i]

    sumx1=(1+x1)/2
    List.append(sumx1)


print(sum(List))


Measured memory_bytes: 24548
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  int m = 999;
  for(int i = 0; i < s.size() - 2; i++){
    m = min(m, abs(753 - stoi(s.substr(i,3))));
  }
  cout << m << endl;
  return 0;

}


Measured memory_bytes: 256
#include <cstdio>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if(!a || !b || a < 0 && b > 0)
    printf("Zero\n");
  else if(a > 0)
    printf("Positive\n");
  else {
    if(b - a & 1)
      printf("Positive\n");
    else
      printf("Negative\n");
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

struct Edge {int to; ll cost;};

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<Edge>> G(N);
    REP(i, N) G[i].push_back(Edge{i - 1, 0});
    rep(i, M) {
        int L, R;
        ll C;
        cin >> L >> R >> C;
        --L; --R;
        G[L].push_back(Edge{R, C});
    }
    vector<ll> dist(N, INF);
    vector<int> used(N, 0);
    priority_queue<pair<ll, int>> pq;
    dist[0] = 0;
    pq.push(pair<ll, int>{0, 0});
    while (!pq.empty()) {
        int v = pq.top().second;
        pq.pop();
        if (used[v]) continue;
        for (auto e : G[v]) {
            ll alt = dist[v] + e.cost;
            if (alt < dist[e.to]) {
                dist[e.to] = alt;
                pq.push(pair<ll, int>{-alt, e.to});
            }
        }
    }
    if (dist[N - 1] == INF) cout << -1 << "\n";
    else cout << dist[N - 1] << "\n";
    return 0;
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

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

  cout << N * (N + 1) / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256