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

int main(){
  ll N; cin>>N;
  vector<ll>transportation(5);
  for(int i=0;i<5;i++) cin>>transportation.at(i);
  sort(transportation.begin(),transportation.end());
  ll bottleneck=transportation.at(0);
  
  if(N%bottleneck==0)
    cout<<N/bottleneck+4;
  else
    cout<<N/bottleneck+5;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(){
    int n;
    double x1, x2, x3, x4, y1, y2, y3, y4, crs;
    
    scanf("%d", &n);
    
    while(n--){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        
        crs = (x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1);
        
        if(fabs(crs) < 1e-10)
            printf("YES\n");
        else
            printf("NO\n");
    }
     
    return 0;
}

Measured memory_bytes: 620
#pragma GCC optmize ("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
typedef long double ld;
ll n, k;
int main()
{
	spIO;
	while (cin >> n >> k)
	{
		int ans = 1;
		ll t = 1;
		while (true)
		{
			t *= k;
			if (t > n)
				break;
			ans++;
		}
		cout << ans;
	}
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: i32 = sc.read();
    let m: i32 = sc.read();
    println!("{}", n * (n - 1) / 2 + m * (m - 1) / 2);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 512
int N,C[MX],F[MX],S[MX];
int go(int u,int t){
    if(u+1==N)return t;
    t=max(t,S[u]);
    while(t%F[u])++t;
    return go(u+1,t+C[u]);
}
int main(void){
    scanf("%d",&N);
    F(N)scanf("%d%d%d",C+i,S+i,F+i);
    F(N)printf("%d\n",go(i,0));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define maxn 1010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int h, w;
ll k;
int s[maxn][maxn];
char inp[maxn];
struct mat {
	ll a[2][2];
	mat() {a[0][0] = a[1][1] = 1, a[1][0] = a[0][1] = 0;}
	mat operator * (mat y) {
		mat ans;
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 2; j++) {
				ans.a[i][j] = 0;
				for (int k = 0; k < 2; k++)
					ans.a[i][j] += a[i][k] * y.a[k][j], 
					ans.a[i][j] %= mod;
			}
		return ans;
	}
};
mat ksm(mat a, ll b) {
	if (!b) return mat();
	mat ns = ksm(a, b >> 1);
	ns = ns * ns;
	if (b & 1) ns = ns * a;
	return ns;
}
int main() {
	scanf("%d%d%lld", &h, &w, &k);
	int cnt = 0;
	for (int i = 0; i < h; i++) {
		scanf("%s", inp);
		for (int j = 0; j < w; j++)
			if (inp[j] == '#') s[i][j] = 1, cnt++;
			else s[i][j] = 0;
	}
	int fl[2] = {0, 0};
	for (int i = 0; i < h; i++)
		if (s[i][0] && s[i][w - 1]) fl[0]++;
	for (int i = 0; i < w; i++)
		if (s[0][i] && s[h - 1][i]) fl[1]++;
	if (fl[0] && fl[1]) cout << 1 << endl;
	else if (fl[0] == 0 && fl[1] == 0) 
		cout << ksm(cnt, k - 1) << endl;	
	else {
		int tot = 0, mn;
		if (fl[0]) {
			mn = fl[0];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					if (s[i][j] && s[i][j + 1]) tot++;
		}
		else {
			mn = fl[1];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					if (s[i][j] && s[i + 1][j]) tot++;
		}
		mat fr;
		fr.a[0][0] = fr.a[0][1] = 1, 
		fr.a[1][0] = fr.a[1][1] = 0;
		mat bk;
		bk.a[0][0] = cnt, bk.a[1][0] = -tot;
		bk.a[0][1] = 0, bk.a[1][1] = mn;
		bk = ksm(bk, k - 1);
		fr = fr * bk;
		ll res = fr.a[0][0];
		res %= mod;
		if (res < 0) res += mod;
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	float n;
	while(cin >> n)
	{
		cout << ceil(n/2) << '\n';
	}

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Point = pair<long long, long long>;

long long search(long long H, long long W, vector<string> grid){
  vector<vector<long long>> visit(H, vector<long long>(W, LLONG_MAX));
  queue<Point> que;
  que.push(make_pair(0, 0));
  visit[0][0] = 1;

  while(!que.empty()) {
    auto point = que.front();
    que.pop();

    vector<Point> next;

    if(point.first+1 < H) next.push_back(make_pair(point.first + 1, point.second));
    if(point.second+1 < W) next.push_back(make_pair(point.first, point.second + 1));
    if(point.first-1 >= 0) next.push_back(make_pair(point.first - 1, point.second));
    if(point.second-1 >= 0) next.push_back(make_pair(point.first, point.second - 1));

    for(auto x: next) {
      long long newcost = visit[point.first][point.second] + 1;

      if(grid[x.first][x.second] == '.' && visit[x.first][x.second] > newcost) {
        visit[x.first][x.second] = newcost;
        que.push(x);
      }
    }
  }

  long long mycount = accumulate(grid.begin(), grid.end(), 0LL, [](long long acc, string i){ return acc + count(i.begin(), i.end(), '.'); });

  return (visit[H-1][W-1] == LLONG_MAX) ? -1 : mycount - visit[H-1][W-1];
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long H, W;
  cin >> H >> W;
  vector<string> grid(H);

  for(long long i = 0; i < H; i++){
    cin >> grid[i];
  }

  cout << search(H,W,move(grid)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INF 10000000
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int skill[n][m];
    int cost[n];
    int minim = INF;
    for (int i = 0; i < n; i++)
    {
        cin >> cost[i];
        for (int j = 0; j < m; j++)
        {
            cin >> skill[i][j];
        }
    }
    int power[20];
    power[0] = 1;
    for (int i = 1; i < 20; i++)
    {
        power[i] = power[i - 1] * 2;
    }
    for (int mask = 0; mask < power[n]; mask++)
    {
        int skills[m] = {0};
        int total = 0;
        for (int i = 0; i < n; i++)
        {
            if (mask & (1 << i))
            {
                total += cost[i];
                for (int j = 0; j < m; j++)
                {
                    skills[j] += skill[i][j];
                }
            }
        }
        int flag = 0;
        for (int i = 0; i < m; i++)
        {
            if (skills[i] < x)
                flag = 1;
        }
        if (!flag)
        {
            minim = min(minim, total);
        }
    }
    if (minim == INF)
        minim = -1;
    cout << minim << endl;
    return 0;
}

Measured memory_bytes: 3640
/*
 * atcoder/abc97/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S;
int K, N;
vector<string> subs;
int counter[200] = {0};

void solve() {
  cin >> S >> K;
  N = S.size();
  for (int len=1; len<=K; len++) {
    for (int l=0; l+len<=N; l++) {
      subs.push_back(S.substr(l, len));
    }
  }
  sort(subs.begin(), subs.end());
  string prev = " ";
  int k=0;
  int n=1;
  for (; n<subs.size(); n++) {
    if (subs[n-1] != subs[n]) {
      k++;
      if (k==K) break;
    }
  }
  cout << subs[n-1] << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int X=50;
    int N, A;
    cin >> N >> A;
    vector<int> v(N);
    REP(i,N) cin >> v[i];

    vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>>(N+1,vector<ll>(N*X+10)));
    dp[0][0][0] = 1;

    REP(i,N) {
        REP(j,i+1) {
            REP(k,j*X+1) {
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+v[i]] += dp[i][j][k];
                //cerr << i+1 << " " << j << " " << k << " " << dp[i+1][j][k] << endl;
                //cerr << i+1 << ":" << j+1 << ":" << k+v[i] << ":" << dp[i+1][j+1][k+v[i]] << endl;
            }
        }
        //dp[i+1][1][v[i]]++;
    }
    

    ll ans = 0;
    FOR(i,1,N+1) {
        ans += dp[N][i][A*i];
        //cerr << i << " " << dp[N][i][A*i] << endl;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 52352
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  cout << N / 3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top, s[1000];

void push(int x){
    s[++top] = x;
}

int pop(){
    top--;
    return s[top+1];
}

int main(){
    int a,b; top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a -b);
        } else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}


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

int main()
{
  int n,t;
  cin>>n;
  t=n;
  set<int> s;
  while(t--)
  {
    int x;
    cin>>x;
    s.insert(x);
  }
  if(s.size()==n) cout<<"YES";
  else cout<<"NO";
 return 0; 
}

Measured memory_bytes: 9600
program main
    implicit none
    integer(4):: max_x=0, x=0
    integer(4):: n, i
    character(:),ALLOCATABLE:: s

    read*, n
    allocate(character(n):: s)

    read*, s

    do i=1, n
        if (s(i:i) == 'D') x=x-1
        if (s(i:i) == 'I') x=x+1

        max_x = max(max_x,x)
    end do

    print*, max_x
end program main

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

int main(){
	char alp[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	//input two cycles
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < 26; j++){
			if(s.at(i) == alp[j]){
				s.at(i) = alp[j + n];
				break;
			}
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ.Codes
{
    //問題の名称... DSL_1_A:   Disjoint Set: Union Find Tree
    //問題文のURL... http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
    //所要時間... AAA
    //学んだこと... AAA
    //教室内の大まかな着席位置... 左 x 奥

    class UnionFindTree
    {
        static void Main(string[] args)
        {

            //読み込み
            var x1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = x1[0];
            var q = x1[1];

            var input = new List<int[]>();

            for (int i = 0; i < q; i++)
            {
                var x2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                input.Add(x2);
            }

            //計算
            var P = new int[n];
            for (int i = 0; i < n; i++) P[i] = i;

            var ans = new List<bool>();

            foreach (var item in input)
            {
                var com = item[0];
                var x = item[1];
                var y = item[2];

                if (com == 0)
                {
                    //unite
                    var rx = GetRoot(x, P);
                    var ry = GetRoot(y, P);
                    P[rx] = ry;
                }
                else
                {
                    //same
                    ans.Add(GetRoot(x, P) == GetRoot(y, P));
                }
            }

            //出力
            foreach (var item in ans)
                Console.WriteLine(item ? 1 : 0);



            //Enterを押して終了
            Console.ReadLine();
        }

        static private int GetRoot(int i, int[] P)
        {
            while (true)
            {
                if (P[i] == i)
                    return i;
                else
                    i = P[i];
            }
        }
    }
}



Measured memory_bytes: 28616
#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 EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

    int c;
    a > b ? c = b : c = a;
    
    deque<int> sub;
    FOR(i, 1, c+1) {
        if (a%i==0 && b%i==0) sub.push_front(i);
    }
    cout << sub[k-1];
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min({b, n * a});
}


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

int main()
{
vector<int>ant(5);
for(int i = 0; i < 5; i++){
    cin >>ant[i];
}

int k;
cin >> k;

 int distance = ant[4]-ant[0];
 if(distance <= k ){
     cout << "Yay!" << endl;
 }else{
     cout << ":(" << endl;
 }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;
ll const MAX_V = 5005;

struct edge {
    ll to, cost;
};
vector<edge> G[MAX_V];

int main() {
    INIT;

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

    rep(i, N) {
        P[i]--;
        edge et = {P[i], C[P[i]]};
        G[i].push_back(et);
    }

    ll ans = -INF;
    rep(i, N) {
        ll v = i;
        vector<ll> s;
        ll score = 0;

        rep(n, 5005) {
            edge nv = G[v][0];
            score += nv.cost;
            s.pb(score);

            if (nv.to == i) break;
            v = nv.to;
        }

        ll total = s[SZ(s) - 1];
        rep(i, SZ(s)) {
            if (i + 1 > K) break;

            if (total > 0) {
                ll e = (K - (i + 1)) / SZ(s);
                s[i] += total * e;
            }

            chmax(ans, s[i]);
        }
    }
    cout << ans << endl;

    return 0;
}

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

class Dice
{
private:
  vector<int> dice;

public : Dice(vector<int> num) {
    for (int i = 0; i < (int)num.size(); ++i) {
      dice.push_back(num.at(i));
    }
  }

  int getDiceRightNum(int top, int forward) {
    int right = 0;
    for(int i = 0; i < (int)dice.size(); ++i){
      for(int j = 0; j < (int)dice.size(); ++j){
        if (dice.at(i) == top && dice.at(j) == forward) {
          if(i == 0 && j == 1) right = dice.at(2);
          if(i == 0 && j == 2) right = dice.at(4);
          if(i == 0 && j == 4) right = dice.at(3);
          if(i == 0 && j == 3) right = dice.at(1);
          if(i == 1 && j == 0) right = dice.at(3);
          if(i == 1 && j == 3) right = dice.at(5);
          if(i == 1 && j == 5) right = dice.at(2);
          if(i == 1 && j == 2) right = dice.at(0);
          if(i == 2 && j == 0) right = dice.at(1);
          if(i == 2 && j == 1) right = dice.at(5);
          if(i == 2 && j == 5) right = dice.at(4);
          if(i == 2 && j == 4) right = dice.at(0);
          if(i == 3 && j == 0) right = dice.at(4);
          if(i == 3 && j == 4) right = dice.at(5);
          if(i == 3 && j == 5) right = dice.at(1);
          if(i == 3 && j == 1) right = dice.at(0);
          if(i == 4 && j == 0) right = dice.at(2);
          if(i == 4 && j == 2) right = dice.at(5);
          if(i == 4 && j == 5) right = dice.at(3);
          if(i == 4 && j == 3) right = dice.at(0);
          if(i == 5 && j == 1) right = dice.at(3);
          if(i == 5 && j == 3) right = dice.at(4);
          if(i == 5 && j == 4) right = dice.at(2);
          if(i == 5 && j == 2) right = dice.at(1);
        }
      }
    }
    return right;
  }
};

int main(int argc, char *argv[])
{
  vector<int> num(6);
  int q, a, b;
  for(int i = 0; i < 6; ++i){
    cin >> num.at(i);
  }
  Dice dice(num);
  cin >> q;
  for (int j = 0; j < q; ++j) {
    cin >> a >> b;
    cout << dice.getDiceRightNum(a, b) << endl;
  }

  return 0;
}



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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int h,n,a[1001],b[1001],d[10001];

void nhap()
{
    scanf("%d %d",&h,&n);
    for (int i=1;i<=n;++i)
    {
        scanf("%d %d",&a[i],&b[i]);
    }
}

int solve(int s)
{
    if (s<=0) return 0;
    if (d[s]) return d[s];
    d[s]=INT_MAX;
    for (int i=1;i<=n;++i)
    {
        d[s]=min(d[s],solve(s-a[i])+b[i]);
    }
    return d[s];
}

int main()
{
    nhap();
    cout<<solve(h);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    IN(int, n);
    VIN(ll, a, n);
    a[0]--;
    bool flag = true;
    for (int i = 1; i < n; i++) {
        if (a[i]>a[i-1]) {
            a[i]--;
        }else if (a[i]<a[i-1]){
            flag = false;
            break;
        }
    }
    Yes(flag);
}


Measured memory_bytes: 4048
n=int(input())
a=[1,1,1]
def dp():
    a.append(sum(a[:len(a)-2])+1)
if n<3:
    print(0)
elif n<6:
    print(1)

else:
    for i in range(n-5):
        dp()
    print(a[-1]%(10**9+7))
    

Measured memory_bytes: 9296
function Puzzle(){
   var obj={};
   var arrA="123,234,345,456,567,678,789,111,222,333,444,555,666,777,888,999".split(",");
   var arrB="11,22,33,44,55,66,77,88,99".split(",");
   for(var i=0;i<16;i++)for(var j=0;j<16;j++)for(var k=0;k<16;k++)for(var l=0;l<16;l++)for(var m=0;m<9;m++){
      var str=arrA[i]+arrA[j]+arrA[k]+arrA[l]+arrB[m];
      str=str.split("").map(Number).sort(function(a,b){return a-b;}).join("");
      obj[str]=true;
   }
   return obj;
}
var P=Puzzle();
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   if(Arr.length==0)break;
   var str=Arr.shift();
   var ans=[];
   for(var i=1;i<=9;i++){
      var arr=str.split("").map(Number);
      arr.push(i);
      arr.sort(function(a,b){return a-b;});
      var cnt=[0,0,0,0,0,0,0,0,0,0];
      arr.forEach(function(v){cnt[v]++;});
      var max=Math.max.apply(null,cnt);
      if(max>=5)continue;
      if(P.hasOwnProperty(arr.join("")))ans.push(i);
   }
   console.log((ans.length==0)?"0":ans.join(" "));
}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
 
using namespace std;
 
int c[64][64];
 
void paint(int y, int x) {
  if (y < 0 || y >= 50 || x < 0 || x >= 50) return;
  if (c[y][x] == 0) return;
  c[y][x] = 0;
  for (int dy = -1; dy <= 1; ++dy) {
    for (int dx = -1; dx <= 1; ++dx) {
      paint(y + dy, x + dx);
    }
  }
}
 
int main() {
  int H, W;
  while (cin >> W >> H, H) {
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        cin >> c[i][j];
      }
    }
    int res = 0;
    for (int y = 0; y < H; ++y) {
      for (int x = 0; x < W; ++x) {
        if (c[y][x] == 1) {
          ++res;
          paint(y, x);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3220
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read2<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: u32 = read();
    let a: Vec<i32> = read2(n);
    let mut first: (i32, i32) = (0, 0);
    let mut second: (i32, i32) = (0, 0);
    let mut count: i32 = 0;
    for elem in a.iter() {
        if *elem > first.1 {
            second = first;
            first = (count, *elem);
        } else if *elem > second.1 {
            second = (count, *elem);
        }
        count += 1;
    }
    for i in 0..count {
        let result = match i == first.0 {
            true => second.1,
            false => first.1,
        };
        println!("{}", result);
    }
}

Measured memory_bytes: 5628
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<array>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<numeric>
#include<random>
#include<functional>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
using namespace std;




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

	int N, M;
	cin >> N >> M;
	vector<int>boxnum(N, 1);
	vector<int>redflag(N, 0);
	redflag[0] = 1;
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (redflag[x])redflag[y] = 1;
		boxnum[x]--;
		boxnum[y]++;
		if (boxnum[x] == 0)redflag[x] = 0;
	}
	cout << accumulate(ALL(redflag),0) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    string s1,s2;
    cin >> s1 >> s2;
    rep(i,s1.length()){
        cout << s1[i];
      	if(i<s2.length())cout << s2[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
R = []
for _ in range(M):
    a, b = map(int, input().split())
    R.append((a, b))

R.sort(key=lambda x:x[1])

end, ans = 0, 0
for i in range(M):
    if R[i][0] >= end:
        end = R[i][1]
        ans += 1

print(ans)


Measured memory_bytes: 18196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

const int maxn = 200000 + 7;

int n;
long long a[maxn], b[maxn];

void sort(long long *a, long long md) {
    int pos = n;
    for (int i = 0; i < n; i ++) {
        if (pos == n && a[i] >= md) pos = i;
        a[i] = a[i] & (md - 1);
    }
    inplace_merge(a, a + pos, a + n);
}

bool solve(long long limit) {
    long long ans = 0;
    int that = n - 1;
    for (int i = 0; i < n; i ++) {
        while (that >= 0 && a[i] + b[that] >= limit) that --;
        ans += n - 1 - that;
    }
    return ans & 1;
}
int main() {
        cin >> n;
        for (int i = 0; i < n; i ++) {
            scanf("%I64d", a + i);
        }
        for (int i = 0; i < n; i ++) {
            scanf("%I64d", b + i);
        }
        sort(a, a + n);
        sort(b, b + n);
        long long ans = 0;
        for (int i = 61; i >= 0; i --) {
            sort(a, (long long)2 << i);
            sort(b, (long long)2 << i);
            long long res =
                solve((long long)1 << i) ^
                solve((long long)2 << i) ^
                solve((long long)3 << i);
            ans |= res << i;
        }
        printf("%I64d\n", ans);
    return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
#define double long double
const int mod=1000000007,MAX=405,INF=1<<29;
int dis[MAX][MAX];
int N;

void floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                chmin(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
}

vector<int> dh={0,1,0,-1},dw={1,0,-1,0};

int dp[1<<12][12];
vector<int> pos;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int H,W;cin>>W>>H;
        if(H+W==0) break;
        N=H*W;
        
        for(int i=0;i<N;i++) for(int j=0;j<N;j++) dis[i][j]=INF;
        pos.clear();
        
        vector<string> S(H);
        for(int i=0;i<H;i++) cin>>S[i];
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(S[i][j]=='x') continue;
                if(S[i][j]=='o') pos.push_back(i*W+j);
                for(int k=0;k<4;k++){
                    int toi=i+dh[k],toj=j+dw[k];
                    if(toi<0||toi>=H||toj<0||toj>=W) continue;
                    if(S[toi][toj]=='x') continue;
                    dis[i*W+j][toi*W+toj]=1;
                }
            }
        }
        
        for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(S[i][j]=='*') pos.push_back(i*W+j);
        
        floyd();
        
        for(int i=0;i<12;i++) for(int j=0;j<(1<<12);j++) dp[j][i]=INF;
        dp[1][0]=0;
        
        int M=si(pos);
        
        for(int bit=0;bit<(1<<M);bit++){
            for(int i=0;i<M;i++){
                if(dp[bit][i]==INF) continue;
                if(!(bit&(1<<i))) continue;
                for(int to=0;to<M;to++){
                    if(bit&(1<<to)) continue;
                    chmin(dp[bit|(1<<to)][to],dp[bit][i]+dis[pos[i]][pos[to]]);
                }
            }
        }
        
        int ans=INF;
        
        for(int i=1;i<=M;i++) chmin(ans,dp[(1<<M)-1][i]);
        
        if(ans==INF) ans=-1;
        
        cout<<ans<<endl;
    }
}





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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint a,b,c,k; cin>>a>>b>>c>>k;
	cout<<(k%2==0?a-b:b-a)<<'\n';
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;
typedef vector<vector<ll>> Mat;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

bool to_reach[2502];
bool back_reach[2502];
Vec toward[2502];
Vec backward[2502];

void dfsto(ll x){
    if(to_reach[x]){
        return;;
    }
    to_reach[x]=true;
    for(ll a: toward[x]){
        dfsto(a);
    }
}

void dfsback(ll x){
    if(back_reach[x]){
        return;
    }
    back_reach[x]=true;
    for(ll a: backward[x]){
        dfsback(a);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, p;
    ll ans=0;
    cin>>n>>m>>p;
    Vec d(n+1, INF);
    struct edge{
        ll from,to,cost;
    };

    vector<edge> graph;
    rep(i, m) {
        ll a,b,c;
        edge e;
        cin>>a>>b>>c;
        e.from = a;
        e.to=b;
        e.cost=p-c;
        graph.pb(e);
        toward[a].pb(b);
        backward[b].pb(a);
    }
    dfsto(1LL);
    dfsback(n);
    d[1]=0;
    ll cnt = 0;
//    for(bool x:to_reach){
//        dbg(x);
//    }
//    for(bool x:back_reach){
//        dbg(x);
//    }
    while(true){
        bool update = false;
        if(cnt>n){
            cout << -1 << endl;
            return 0;
        }
        rep(j,m){
            edge &e = graph[j];
            if(!(to_reach[e.from]&&back_reach[e.from]&&to_reach[e.to]&&back_reach[e.to])){
                continue;
            }
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to] = d[e.from]+e.cost;
                update = true;
            }
        }
        cnt++;
        if(!update){
            break;
        }
    }
    cout << max(0LL,-d[n]) << endl;
}


Measured memory_bytes: 768
/*
ID: kiwio
LANG: C++14
TASK: 
*/

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

int n, m, i, x, toll, g0, gn;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);/*
#ifndef turtle
	ofstream cout (".out");
	ifstream cin (".in");
#endif*/
	cin >> n >> m >> x;
	for (i=1; i<=m; i++) {
		cin >> toll;
		if (toll<x) {
			g0++;
		}
		else {
			gn++;
		}
	}
	cout << min(g0, gn);
 }

Measured memory_bytes: 256
n = input()
M = []
  
def scalar(n):
   m = [[0 for i in range(len(n))] for j in range(len(n))]
  
   for l in range(1, len(n)):
      for i in range(0, len(n)-l):
         j = i + l
         m[i][j] = min(m[i][k] + m[k+1][j] + M[i][0]*M[k+1][0]*M[j][1] for k in range(i, j))
  
   return m[0][len(n)-1]
  
for i in range(n):
   M.append(map(int, raw_input().split()))
print scalar(M)

Measured memory_bytes: 6568
class Card:
    def __init__(self, suit, value, order):
        self.suit = suit
        self.value = value
        self.order = order
    def __str__(self):
        return self.suit + str(self.value)

n = int(input())
a = list(input().split())
cards = []
for i in range(n):
    c = Card(a[i][0], int(a[i][1]), i)
    cards.append(c)

c = cards + [] # copy list

# bubble sort
for i in range(n):
    for j in range(n-1, i, -1):
        if c[j].value < c[j-1].value:
            c[j], c[j-1] = c[j-1], c[j]
print(' '.join([str(c1) for c1 in c]))
for i in range(n-1):
    if c[i].value == c[i+1].value and c[i].order >= c[i+1].order:
        print('Not stable')
        break
else:
    print('Stable')

c = cards + [] # copy list

# selection sort
for i in range(n):
    minj = i
    for j in range(i, n):
        if c[j].value < c[minj].value:
            minj = j
    c[i], c[minj] = c[minj], c[i]
print(' '.join([str(c1) for c1 in c]))
for i in range(n-1):
    if c[i].value == c[i+1].value and c[i].order >= c[i+1].order:
        print('Not stable')
        break
else:
    print('Stable')



Measured memory_bytes: 5620
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x,y;
   x=(a+d-1)/d;
   y=(c+b-1)/b;
  if(x>=y)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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

#define MAX_N 1000
#define MAX_M 100

const long long INF = 1LL << 60;

//境界値に注意！！！

// DP テーブル
ll dp[100010];

int main() {
    ll n;
    cin >> n;
    vector<long double> ans(n);
    vector<long double> x(n);
    for(ll i=0;i<n;++i)cin >> x[i];
    sort(x.begin(),x.end());
    ans[0]=(x[0]+x[1])/2;
    for (ll i=1;i<n-1;++i){
        ans[i]=(ans[i-1]+x[i+1])/2;
    }
    cout << ans[n-2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,i,z,x[1000];
	char w[10];
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++){
		x[i]=0;
		x[i]=i+1;
	}
	z=0;
	for(i=0;i<b;i++){
		scanf("%d %c %d",&c,w,&d);
		z=x[c-1];
		x[c-1]=x[d-1];
		x[d-1]=z;
	}
	for(i=0;i<a;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	register short f=1;x=0;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	x*=f;
}
template<typename T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
template<typename T>inline void writeln(T x){
	write(x),putchar('\n');
}
int main(){
	int n;cin>>n;
	cout<<800*n-200*int(n/15)<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
e=[[] for _ in range(n+1)]
d=[-1]*(n+1)
for i in range(m):
  a,b=map(int,input().split())
  e[a]+=[b]
  e[b]+=[a]
q=deque([(1,0)])
d[1]=0
while q:
  now,par=q.popleft()
  for to in e[now]:
    if to==par:continue
    if d[to]==-1:
      d[to]=(d[now]+1)%2
      q.append((to,now))
    elif d[to]==d[now]%2:
      print(n*(n-1)//2-m)
      exit()
p=sum(d)+1
print(p*(n-p)-m)

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    bool is_easy = true;
    rep(0, s.size()) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                is_easy = false;
                break;
            }
        } else {
            if (s[i] == 'R') {
                is_easy = false;
                break;
            }
        }
    }

    cout << (is_easy ? "Yes" : "No") << endl;

    return 0;
}


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

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

  vector<pair<int,int>> v;

  for(int i = 0;i<n;i++){
    int a,b;
    cin >> a >> b;

    v.push_back({a,b});
  }

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

  for(int i = 0;i<n;i++){
    int a = v[i].first;
    int b = v[i].second;

    ans+=min(b,m)*a;
    //cout << a << " " << b << " " << ans << endl;
    m-=min(b,m);
    if(m==0)break;
  }

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


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    string s;
    int ret = 10000000;
    cin >> s;
    rep(i, s.size() - 2)
    {
        int t = atoi(s.substr(i, 3).c_str()); //)strcat(s[i], s[i + 1], s[i + 2]);
        ret = min(ret, abs(753 - t));
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static int[][] C;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);

        C = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                C[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve() ? "Yes" : "No");
    }

    static boolean solve() {
        int a0 = 0;
        int[] b = new int[3];
        for (int i = 0; i < 3; i++) {
            b[i] = C[0][i] - a0;
        }
        int[] a = new int[3];
        a[0] = a0;
        a[1] = C[1][0] - b[0];
        a[2] = C[2][0] - b[0];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if( a[i] + b[j] != C[i][j] ) return false;
            }
        }
        return true;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21204
using System;

namespace abc160_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            int coinCount500 = x / 500;
            int sum = 0;

            int x5 = x;

            for (int i = 1; i <= coinCount500; i++)
            {
                sum += 1000;
                x5 = x5 % 500;
            }

            int coinCount5 = x5 / 5;

            for (int j = 1; j <= coinCount5; j++)
            {
                sum += 5;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27284
#include <iostream>

using namespace std;

int main()
{
    char s[3];
    int y;
    y=700;
    int i,j;
    for(i=0;i<3;i++)
        cin>>s[i];
    for(j=0;j<3;j++)
        if(s[j]=='o')
         y=y+100;
    cout <<y<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int  N=0;
	bool p=0, y=0, w=0, g=0;
	char input;

	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> input;
		if (input == 'P') p = 1;
		if (input == 'Y') y = 1;
		if (input == 'W') w = 1;
		if (input == 'G') g = 1;
	}
	if ((p + y + w + g) == 3){
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	sum := 0
	max := 0
	stdin.Scan()
	length_text := strings.Split(stdin.Text()," ")
	for i:=0;i<n;i++ {
		tmp, _ := strconv.Atoi(length_text[i])
		sum += tmp
		if max < tmp {
			max = tmp
		}
	}
	sum -= max
	if sum > max {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}

}

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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


int ans[] = { 1, -1, 1, -1, 0, 1, -1, 1, -1 };

int get(int n){
//	if (ans[n] == 0){ exit(0); }
//	else return ans[n];

	static map<int, int> m;
	if (m.count(n) > 0) return m[n];

	cout << n << endl;
	string t;
	cin >> t;
	if (t == "Vacant") { exit(0); return 0;}
	int tmp;
	if (t == "Female") tmp= 1;
	else tmp= -1;
	m[n] = tmp;
	return tmp;
}


signed main(){

	int N;
	cin >> N;
	int l, r;
	l = 0;
	r = N-1;

	while (r - l > 1){
		int mid = (r + l) / 2;

		if (get(l) == get(mid)){
			if ((mid - l + 1) % 2 == 0)
				r = mid;
			else
				l = mid;
		}
		else{
			if ((mid - l + 1) % 2 == 0)
				l = mid;
			else
				r = mid;
		}
	}
	get(l);
	get(r);


	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;

int main(){
  
  int N,sum=0;
  cin >> N;
  int l[N];
  int r[N];
  rep(i,N){
    cin >> l[i] >> r[i];
  }

  rep(i,N){
    sum += (r[i]-l[i]+1);
  }

  cout << sum << endl;

    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n; cin >> n;
    ll i=7, cnt = 0;
    while(cnt <= 50000000){
        cnt++;
        if(i % n == 0){
            cout << cnt  << "\n"  ; return;
        }
        i*= 10;
        i += 7;
        i %= n;
    }
    cout << "-1\n";

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3616