akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	char buf[20];

	scanf("%s",buf);

	int length;
	for(length = 0; buf[length] != '\0'; length++);

	int ans = 0;
	int MINUS,PLUS;

	for(int left = -1; left < length-1; left++){

		if(left == -1){
			MINUS = 0;

			PLUS = 0;
			for(int i = 0; i < length; i++){
				PLUS = 10*PLUS + buf[i] - '0';
			}

		}else{

			if(buf[left+1] == '0')continue;

			MINUS = 0;
			for(int i = 0; i <= left; i++){
				MINUS = 10*MINUS + buf[i]-'0';
			}

			PLUS = 0;
			for(int i = left+1; i < length; i++){
				PLUS = 10*PLUS + buf[i] - '0';
			}
		}
		if(PLUS >= MINUS && (PLUS+MINUS)%2 == 0 && (PLUS-MINUS)%2 == 0)ans++;
	}


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

	return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>

int s(int, int);
int n,q,A[2000];

int main(){
  int i,j,m_i;

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

  scanf("%d",&q);
  for(j=0 ; j<q ; j++){
    scanf("%d",&m_i);

    if(s(0,m_i) == 1){
      printf("yes");
      printf("\n");
    }
    else if(s(0,m_i) == 0){
      printf("no");
      printf("\n");
    }
  }
    return 0;
}

int s(int x, int y){
  if(y == 0){
    return 1;
  }
  if(x >= n){
    return 0;
  }
  if(s(x+1,y)){
    return 1;
  }
  if(s(x+1,y-A[x])){
    return 1;
  }
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n;
    cin >> n;
    n=n%10;
    switch(n){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        case 3:
            cout << "bon";
            break;
    }
    return 0;
}

Measured memory_bytes: 3636
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Edge = Tuple!(int, "to", int, "c", int, "rev");
immutable inf = 101101;

void main() {
    int n, m;
    scan(n, m);

    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int ui, vi, ci;
        scan(ui, vi, ci);
        adj[ui] ~= Edge(vi, ci, adj[vi].length.to!int);
        adj[vi] ~= Edge(ui, 0, adj[ui].length.to!int - 1);
    }

    int ans = FordFulkerson(n, m, adj, 0, n - 1);

    writeln(ans);
}

int FordFulkerson(int n, int m, Edge[][] adj, int s, int t) {
    auto visited = new bool[](n);

    int dfs(int u, int f) {
        if (u == t) {return f;}

        visited[u] = 1;

        foreach (ref e ; adj[u]) {
            if (!visited[e.to] && e.c > 0) {
                int d = dfs(e.to, min(f, e.c));

                if (d > 0) {
                    e.c -= d;
                    adj[e.to][e.rev].c += d;
                    return d;
                }
            }
        }

        return 0;
    }

    int F;

    while (true) {
        visited[] = 0;
        int f = dfs(0, inf);
        if (!f) break;
        F += f;
    }

    return F;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2520
#include<stdio.h>
int main(void){
	int n,i = 0;
	int a[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>-1;i--){
		printf("%d",a[i]);
		if (i>0)printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int main ()
{
    int N,R,S,A;
    cin>>N>>R;
    if(N<10)
    {
    S=100*(10-N);
    A=R+S;
    cout<<A<<endl;
    }
    else
        cout<<R<<endl;
    return 0;

}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

vector<long long> v[100010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N, M;
    cin >> N >> M;
    for (int i=0; i<N; ++i) {
        int A, B;
        cin >> A >> B;
        v[A].push_back(B);
    }

    long long sum = 0;
    priority_queue<long long> pq;
    for (int i=1; i<=M; ++i) {
        for (int j=0; j<(int)v[i].size(); ++j) {
            pq.push(v[i][j]);
        }
        if ((int)pq.size() > 0) {
            sum += pq.top();
            pq.pop();
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll A, B, C, K;

int main() {
  cin >> A >> B >> C >> K;
  ll m = max(A, max(B, C));
  ll rest = A + B + C - m;
  cout << m * pow(2, K) + rest << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      String tokens[] = scanner.nextLine().split(" ");
      
      int x = tokens[0].charAt(0);
      int y = tokens[1].charAt(0);
      
      if(x>y){
        System.out.println(">");
      }
      else if(x == y){
        System.out.println("=");
      }
      else{
        System.out.println("<");
      }
    }
}

Measured memory_bytes: 22608
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int x = 0;
		
		for(;a <= b; a++) {
			if(c%a == 0) {
				x++;
			}
		}
		
		System.out.println(x);
	}
}



Measured memory_bytes: 26408
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// スターリング数は、写像12相のうち以下に相当する
//  ・玉の区別をする
//  ・箱の区別をしない
//  ・箱に入る玉の数は1つ以上

// 計算方法
//  空箱の数で包除原理。k箱のうちi箱にのみ玉を入れるとすると↓
//  S(n,k) = (1/k!) * Σ(0<=i<=k) (-1)^(k-i) * {k,i} * i^n
//  計算量: O(K log(N))

class Combination {
public:
    vector <ll> fac, inv, fiv;
    Combination(int N) : fac(N), inv(N), fiv(N) {
        fac[0] = inv[0] = fiv[0] = 1;
        fac[1] = inv[1] = fiv[1] = 1;
        for (ll i = 2; i < N; i++) {
            fac[i] = fac[i - 1] * i % MOD; // n!
            inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
            fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
        }
    }
    ll C(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[k] % MOD * fiv[n - k] % MOD;
    }
};

ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}

ll stirling_number(int n, int k) {
    Combination Com(k + 1);
    ll ret = 0;
    for (int i = 0; i <= k; i++) {
        ll add = Com.C(k, i) * pow_mod(i, n, MOD) % MOD;
        if ((k - i) & 1) add *= -1;
        ret = (ret + add + MOD) % MOD;
    }
    return ret * Com.fiv[k] % MOD;
}


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_I&lang=jp
void AOJ_DPL_5_I() {
    int n, k;
    cin >> n >> k;
    cout << stirling_number(n, k) << "\n";
}

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



Measured memory_bytes: 3120
-- Is it a Right Triangle?
import Data.List -- sortBy
import Data.Ord  -- comparing Down
import Control.Applicative -- <$>

main = (solve <$> getLine) <*> getContents >>= putStr

solve :: String -> String -> String
solve n = unlines . map (isRight . sortBy (comparing Down) . map read) . map words . lines

isRight :: [Int] -> String
isRight [a,b,c] | a^2 == b^2 + c^2 = "YES"
                | otherwise        = "NO"

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

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

  string result = "NO";
  if (A[A.size() - 1] == B[0]) {
    if (B[B.size() - 1] == C[0]) {
      result = "YES";
    }
  };
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n,m=map(int,input().split())
    l=[tuple(map(int,input().split())) for _ in range(m)]
    py=sorted(l, key=lambda x: (x[0],x[1]))
    d={}
    i = 1
    prev=0
    for p,y in py:
        if prev != p:
            i = 1
            prev = p
        d[(p,y)] = "{:0>6}".format(p)+"{:0>6}".format(i)
        i += 1
    for x in l:
        print(d[x])

if __name__ == "__main__":
    main()

Measured memory_bytes: 43072
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  if (a==f&&b==e&&c==d)
  cout << "YES" << endl;
  else
  cout << "NO" << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        string s;
        cin >> s;

        if (s == "SUN")
        {
            cout << 7;
        }
        if (s == "MON")
        {
            cout << 6;
        }
        if (s == "TUE")
        {
            cout << 5;
        }
        if (s == "WED")
        {
            cout << 4;
        }
        if (s == "THU")
        {
            cout << 3;
        }
        if (s == "FRI")
        {
            cout << 2;
        }
        if (s == "SAT")
        {
            cout << 1;
        }

        return 0;
    }

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

int main() {
	int w;
	while (std::cin >> w) {
		std::vector<int> scales;
		while (w != 0) {
			int s = w % 2;
			scales.push_back(s);
			if (s == 1) w--;
			w = w / 2;
		}
		int weight = 0;
		bool first = false;
		for (std::vector<int>::iterator itr = scales.begin(); itr != scales.end(); ++itr) {
			if (weight == 0) weight = 1;
			else weight = weight * 2;
			if (*itr == 1) {
				if (first) std::cout << " ";
				std::cout << weight;
				first = true;
			}
		}
		std::cout << std::endl;
	}

	return 0;
}


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

#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r){bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r){bool a=l<r;if(a)l=r;return a;}
template <typename T>istream& operator>>(istream &is,vector<T> &v){for(auto &it:v)is>>it;return is;}

constexpr char ln = '\n';
constexpr int mod = 1e9+7;
const string ok = "Yes";
const string ng = "No";


int main(){
    int N,K;
    cin>>N>>K;
    int ret=K*N+1;
    int p=1;
    REP(i,N){
        p*=2;
        chmin(ret,p+(N-i-1)*K);
    }
    cout<<ret<<endl;
    return 0;
}


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

typedef long long ll;

ll getlen(ll n){
  ll sz = 1;
  ll num = 1;
  ll len = 0;
  while(num * 10 <= n){
    len += num * 9 * sz;
    sz++;
    num *= 10;
  }
  return len + (n - num) * sz;
}

int main(){
  ll n, k;
  string res;
  while(cin >> n >> k && (n || k)){
    ll hi = (ll)1e10;
    ll lo = 0;
    while(hi - lo > 1){
      ll md = (hi + lo) / 2;
      ll length = getlen(md);
      //      cout << "LEN " << length << " " << md << endl;
      //      cout << hi << " " << lo << endl;
      if(length < n) lo = md;
      else hi = md;
    }
    ll dif = n - getlen(lo) - 1;
    ostringstream out;
    for(int i = 0; i < 200; i++) out << lo + i;
    res = out.str();
    //    cout << res << endl;
    cout << string(res.begin() + dif, res.begin() + dif + k) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import bisect
import collections
import sys
import functools
import scipy
import math

sys.setrecursionlimit(100000000)
ACMOD = 1000000007
INF = 1 << 62

MOD = 998244353  # type: int

# def comb(n, r):
#     return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

from operator import mul
from functools import reduce


def modinv(a,*args):
    return pow(a, MOD - 2, MOD)

def combination_list(n, mod=MOD):
    lst = [1]
    for i in range(1, n+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst


def comb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def solve(N: int, M: int, K: int):
    if N == 1:
        print(M)
        exit()
    #
    # @functools.lru_cache(maxsize=None)
    # def f(i, k):
    #     if k < 0:
    #         return 0
    #     if i == N - 1:
    #         return M - 1 if k == 0 else M
    #     if i == 0:
    #         return M * f(i + 1, k)
    #     # diff color + same color
    #     return (M - 1) * f(i + 1, k) + f(i + 1, k - 1)
    #
    # print(f(0, K)%MOD)
    n = N - 1
    nCr = 1
    _sum = 0
    # (M - 1) ** (N - k - 1)
    e = [1]
    for i in range(N):
        e.append(e[-1] * (M - 1) % MOD)
    # print('ok')
    nCrArr = combination_list(n,MOD)
    for k in range(K + 1):
        # print(nCr)
        # nCr = cmb(N - 1, k)%MOD
        _sum += M * e[N - k - 1] * nCrArr[k] % MOD
        # print(nCr%MOD, comb(N - 1, k)%MOD)
        # nCr = nCr * (n - k) // (k + 1) * modinv(k ) % MOD
        # nCr= nCr%MOD
    print(_sum % MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int

    solve(N, M, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46744
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;

int main(){
int w,h,n; cin>>w>>h>>n;
bool white[h][w]; REP(i,h)REP(j,w)white[i][j]=1;

REP(l,n){
    int x,y,a; cin>>x>>y>>a;
    if(a==1)REP(i,h)REP(j,w)if(j<=x-1)white[i][j]=false;
    if(a==2)REP(i,h)REP(j,w)if(j>=x)white[i][j]=false;
    if(a==3)REP(i,h)REP(j,w)if(i<=y-1)white[i][j]=false;
    if(a==4)REP(i,h)REP(j,w)if(i>=y)white[i][j]=false;
  
  /*REP(i,h){
    REP(j,w){
    cout<<white[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
  */
}
  
int res =0;
REP(i,h)REP(j,w){
    if(white[i][j])res++;
}
cout <<res<<endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    li x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[51] = {0}, b[51] = {0};
	cin >> a >> b;
	char c[200] = {0};
	int len, i, count = 0;
	for(i = 0; count < strlen(a); i+=2){
		c[i] = a[count++];
	}
	count = 0;
	for(i = 1; count < strlen(b); i+=2){
		c[i] = b[count++];
	}
	cout << c;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  vector<int> t(3);
  cin >> t.at(0) >> t.at(1) >> t.at(2);
  //int p, q, r;
  //cin >> p >> q >> r;
  
  
  auto M = max_element(t.begin(), t.end());
  
  int sum = accumulate(t.begin(), t.end(), -*M);
  //int sum = q + p + r - M;
  cout << sum << endl;
}

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

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

int n;
vector<int> adj[100010];
ll dp[100010][2];
const int MOD = 1e9 + 7;

void dfs(int u, int par){
	dp[u][0] = 1;
	dp[u][1] = 1;

	for(auto v : adj[u]){
		if(par == v) continue;
		dfs(v, u);
		dp[u][1] *= dp[v][0]; dp[u][1] %= MOD;
		dp[u][0] *= (dp[v][0] + dp[v][1]) % MOD; dp[u][0] %= MOD;
	}
}

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

	for(int i = 0; i < n - 1; i++){
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);
	}

	dfs(1, -1);

	printf("%lld\n", (dp[1][0] + dp[1][1]) % MOD);

	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

struct warshall_floyd {
	static void solve(vector<vector<ll>>& d) {
		int n = d.size();
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
};

int main() {
    int n;
    cin >> n;
    vector<vector<ll>> graph(n, vector<ll>(n, 0));
    rep(i, n) {
        rep(j, n) cin >> graph[i][j];
    }
	auto copy = graph;
	warshall_floyd::solve(copy);
	rep(i, n) {
		rep(j, n) {
			if (copy[i][j] != graph[i][j]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	//i->jに至る経路に関して、i->k->jとなる代替経路があった場合
	//i->kとk->jはi->jより小さい
	//i->jを削ってもほかの経路に影響しない
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			ll dist = graph[i][j];
			ll dist2 = INF;
			for (int k = 0; k < n; k++) {
				if (k == i || k == j) continue;
				chmin(dist2, graph[i][k] + graph[k][j]);
			}
			if (dist2 > dist) {
				sum += dist;
			}
		}
	}
	cout << sum << endl;
    return 0;
}


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

using ll = long long;

constexpr int MAX_N = 1e5;

int a[MAX_N];

int main() {
  int N, Q;
  cin >> N >> Q;
  for (int i{}; i < N; ++i)
    cin >> a[i];

  for (int i{}; i < Q; ++i) {
    ll x;
    cin >> x;

    ll ans{};
    ll sum{};
    int right{};
    for (int left{}; left < N; ++left) {

      while (right < N
          // rightを1進めるための満たすべき条件
          && sum + a[right] <= x
          ) {
        // 条件更新となる処理
        sum += a[right];
        ++right;
      }

      // 総和がx以上の条件の場合で、満たさなくなったときをガード
      // ex) if (sum < x)
      // ex)   break;

      // 条件を満たすright取得時の処理
      ans += (right - left);

      if (left == right) {
        ++right;
      } else {
        // leftを1進めるときの処理
        sum -= a[left];
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3432
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int n;
vector<int> E[200010], F[200010];
bool usedE[200010], usedF[200010];
int cE[200010], cF[200010];
int groupE = 0, groupF = 0;

map<pair<int, int>, int> mp;

void dfs(int u, vector<int> M[], bool used[], int c[], int group) {
    c[u] = group;
    used[u] = true;
    for (int v : M[u]) {
        if (!used[v]) {
            dfs(v, M, used, c, group);
        }
    }
}

void makeGroup(int m, vector<int> M[], bool used[], int c[], int group) {
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        M[x-1].push_back(y-1);
        M[y-1].push_back(x-1);
    }

    for (int i = 0; i < n; i++) {
        if (used[i]) continue;
        dfs(i, M, used, c, group);
        group++;
    }
}

int main() {
    int k, l;
    cin >> n >> k >> l;

    makeGroup(k, E, usedE, cE, groupE);
    makeGroup(l, F, usedF, cF, groupF);

    for (int i = 0; i < n; i++) {
        mp[make_pair(cE[i], cF[i])]++;
    }

    for (int i = 0; i < n; i++) {
        if (i != 0) cout << ' ';
        cout << mp[make_pair(cE[i], cF[i])];
    }
    cout << endl;
}


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

int main()
{
    int N,Asum,Bsum;
    Asum = 0;
    Bsum = 0;
    cin >> N;
    vector<int>  card(N);

    for (int i=0; i < N; i++)
    {
        cin >> card.at(i);
    }
    sort(card.begin(),card.end());
    reverse(card.begin(), card.end());

    for (int i = 0; i < N;i++)
    {
        if(i%2 == 0)
        {
            Asum += card.at(i);
        }
        else
        {
            Bsum += card.at(i);
        }
    }
    cout << Asum - Bsum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

long cnt = 0;

void merge(int a[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[2000000];
  int R[2000000];
  for (int i = 0; i < n1; i++) {
    L[i] = a[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = a[mid + i];
  }
  L[n1] = 1000000000;
  R[n2] = 1000000000;

  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      a[k] = L[i++];
    } else {
      a[k] = R[j++];
      cnt += n1 - i;
    }
  }
}

void mergeSort(int a[], int left, int right) {
  int mid = 0;
  mid = (left + right) / 2;
  if (left + 1 < right) {
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main() {
  int n;
  scanf("%d\n", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  mergeSort(a, 0, n);
  printf("%ld\n", cnt);

  return 0;
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	copy_n(istream_iterator<int>(cin), a, p.begin());
	copy_n(istream_iterator<int>(cin), b, q.begin());
	copy_n(istream_iterator<int>(cin), c, r.begin());
	sort(p.begin(), p.end()), sort(q.begin(), q.end()), sort(r.begin(), r.end());
	p.erase(p.begin(), p.end() - x), q.erase(q.begin(), q.end() - y);
	vector<int> s;
	merge(p.begin(), p.end(), q.begin(), q.end(), back_inserter(s));
	long long cur = accumulate(s.begin(), s.end(), 0LL), res = cur;
	for(int t = 0; t < min(x + y, c); ++ t){
		cur += -s[t] + r.back();
		r.pop_back();
		ctmax(res, cur);
	}
	cout << res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 2552
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a,b,min = n + 1 - 2;
  FOR(i,1,ceil(sqrt(n)) + 1){
    if(n % i == 0 ){
      a = i;
      b = n / a;
      if(min > a + b - 2){
        min = a + b - 2;
      }
    }
  }
  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
# ビスケット生産装置を起動すると、起動してから
# A 秒後、2A 秒後、3A 秒後、... (A の倍数秒後) に B 枚ずつビスケットを生産します。
# ビスケット生産装置を起動してから T+0.5 秒後までに
# 生産されるビスケットの合計枚数を求めてください。

input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
t = input[2].to_i

biscuit = 0
time = a
while time <= t + 0
  biscuit += b
  time += a
end

puts biscuit


Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int H1 = Integer.parseInt(sc.next());
      Scanner scc = new Scanner(System.in);
      int M1 = Integer.parseInt(sc.next());
      Scanner scccc = new Scanner(System.in);
      int H2 = Integer.parseInt(sc.next());
      Scanner scccccc = new Scanner(System.in);
      int M2 = Integer.parseInt(sc.next());
      Scanner sccccccc = new Scanner(System.in);
      int K = Integer.parseInt(sc.next());

      
      int a=60*(H2-H1), b=M2-M1+a;
      int l=b-K;
      System.out.println(l);

      
    }
}


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

int main() {
  int N;
  cin >> N;
  long double ans = 0.00000000;
  long double coin = 0.00000000;
  for (int i = 0; i < N; i++) {
    long double x;
    cin >> x;
    string tmp;
    cin >> tmp;
    if (tmp == "JPY") ans += x;
    else coin += x;
  }
  cout << ans + coin*380000.0 << endl;
}


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

using namespace std;

int solve(int N, int M, vector<int>& xs)
{
    if (N >= M)
        return 0;

    sort(xs.begin(), xs.end());
 
    // Deltas entre os pontos ordenados
    priority_queue<int> ds;

    for (int i = 0; i < M - 1; ++i)
        ds.push(xs[i + 1] - xs[i]);

    // Para o caso N = 1, basta colocar o ponto em um dos extremos,
    // e a resposta é o tamanho do intervalo
    int ans = xs.back() - xs.front();
    --N;

    // Para N = 2, colocamos os pontos nos extremos do maior delta, e cada ponto segue na
    // direção oposta
    // Para N > 2, cada novo ponto pode eliminar mais um delta, se posicionado no extremo
    // oposto do ponto que caminha na direção deste delta

    while (N--)
    {
        ans -= ds.top();
        ds.pop();
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<int> xs(M);

    for (int i = 0; i < M; ++i)
        cin >> xs[i];

    auto ans = solve(N, M, xs);

    cout << ans << '\n';

    return 0;
}


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

#define rep(i, j, k) for(int i = (int) j; i < (int) k; ++i)
#define sz(x) ((int) (x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int >
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof (x))
#define zerox(x, y) memset((x), (y), sizeof (x))

using namespace std;
const int N = 203;

int g[N][N];
int n, m, r;

vector<int > v;

int main()
{
#ifdef PIT
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif //PIT

	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> r;
	rep(i, 0, N) rep(j, 0, N) {
		if(i == j) g[i][j] = 0;
		else g[i][j] = inf;
	}
	v.clear();
	rep(i, 0, r) {
		int x;
		cin >> x;
		v.pb(x);
	}
	rep(i, 0, m) {
		int a, b, c;
		cin >> a >> b >> c;
		g[a][b] = g[b][a] = c;
	}
	rep(k, 1, 1+n) rep(i, 1, 1+n) rep(j, 1, 1+n) {
		g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
	}
	sort(v.begin(), v.end());
	int res = inf;
	do {
		int mx = 0, ans = 0;
		rep(i, 1, r) {
			ans += g[v[i]][v[i-1]];
			mx = max(mx, g[v[i]][v[i-1]]);
		}
		res = min(res, ans);
	}while(next_permutation(v.begin(), v.end()));

	cout << res << endl;
	
#ifdef PIT
flush(cout);
cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif //PIT
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<cstring>
using namespace std;

bool MAP[5001][5001];
int x[3000],y[3000];
int cal(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
	int hmax=max(max(y1,y2),max(y3,y4)),hmin=min(min(y1,y2),min(y3,y4));
	int wmax=max(max(x1,x2),max(x3,x4)),wmin=min(min(x1,x2),min(x3,x4));
	int res=(hmax-hmin)*(wmax-wmin);
	if(hmax==y1)res-=((wmax-x1)*(x1-wmin))*2;
	if(hmax==y2)res-=((wmax-x2)*(x2-wmin))*2;
	if(hmax==y3)res-=((wmax-x3)*(x3-wmin))*2;
	if(hmax==y4)res-=((wmax-x4)*(x4-wmin))*2;
	
	return res;
}

int main(){
	
	int n;
	while(cin>>n,n){
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		memset(MAP,0,sizeof(MAP));
		
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i];
			MAP[x[i]][y[i]]=1;
		}
		int ans=0;
		int xd,yd,x3,y3,x4,y4;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				xd=x[j]-x[i];
				yd=y[j]-y[i];
				
				x3=x[i]+yd;
				y3=y[i]-xd;
				x4=x[j]+yd;
				y4=y[j]-xd;
				
				if(0<=x3&&x3<=5000&&0<=y3&&y3<=5000&&0<=x4&&x4<=5000&&0<=y4&&y4<=5000){
					if(MAP[x3][y3]&&MAP[x4][y4]){
						ans=max(ans,cal(x3,y3,x4,y4,x[i],y[i],x[j],y[j]));
					}
				}
				
				x3=x[i]-yd;
				y3=y[i]+xd;
				x4=x[j]-yd;
				y4=y[j]+xd;
				
				if(0<=x3&&x3<=5000&&0<=y3&&y3<=5000&&0<=x4&&x4<=5000&&0<=y4&&y4<=5000){
					if(MAP[x3][y3]&&MAP[x4][y4]){
						ans=max(ans,cal(x3,y3,x4,y4,x[i],y[i],x[j],y[j]));
					}
				}
				//(x[i]+yd,y[i]-xd)
				//(x[j]+yd,y[j]-xd)
				
				//(x[i]-yd,y[i]+xd)
				//(x[j]-yd,y[j]+xd)
				
				
				
			}
		}
		
		cout<<ans<<endl;
	}
	
	
	return 0;
}


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

using namespace std;

const int N = 2001, M = 1e9+7;
int n, dp[N] = {1};

inline void solve1() {
	for (register int i = 3; i <= n; ++i)
		for (register int j = i-3; j >= 0; --j)
			(dp[i] += dp[j]) %= M;
	printf("%d\n", dp[n]);
}

inline long long power(const long long &a, const long long &p) {
	if (!p) return 1;
	long long res = power(a, p >> 1);
	(res *= res) %= M;
	if (p & 1) res *= a;
	return res % M;
}

long long ans, k, den, nom, fact[N] = {1};
inline void solve2() {
	for (register int i = 1; i <= n; i++)
		fact[i] = fact[i-1] * i % M;
	for (register int i = 1; i <= n/3; i++) {
		k = n - i*3;
		den = (fact[k] * fact[i-1]) % M;
		nom = (fact[k+i-1] * power(den, M-2)) % M;
		(ans += nom) %= M;
	}
	printf("%lld\n", ans);
}

int main() {
	scanf("%d", &n);
	solve2();
	return 0;
}


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

int a[54];
int main(){
	string s;
	cin>>s;
	
	for(int i=0;i<s.size();i++)a[s[i]-'a']++;
	int flg=0;
	for(int i=0;i<26;i++)
	{if(a[i]>1)flg=1;}
	if(flg)puts("no");
	else puts("yes");
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin>>N>>K;
    if(K>(N-1)*(N-2)/2){
        cout<<-1<<endl;
    }else{
        cout<<(N-1)*(N-2)/2-K+N-1<<endl;
        FOR(i,0,N-1){
            cout<<1<<' '<<i+2<<endl;
        }
        ll ans=0;

        FOR(i,2,N+1){
            FOR(j,i+1,N+1){
                if(ans<(N-1)*(N-2)/2-K){
                    cout<<i<<' '<<j<<endl;
                    ans++;
                }
            }
        }
    }
}

//37行目見た

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int
solve [n, x] = count n x
    where
        count i j 
            | i == 0 && j == 0 = 0
            | i == 0 = 1
            | j < 2 = 0
            | j < l + 2 = count (i - 1) $ j - 1
            | otherwise = 1 + p + count (i - 1) (min l $ j - 2 - l)
            where
                (l, p) = lps V.! (i - 1)

        lps = V.fromList lenPads

        lenPads = (1, 1) : build 1 lenPads
            where
                build c ((l, p) : xs)
                    | c > n = []
                    | otherwise = (3 + 2 * l, 1 + 2 * p) : build (c + 1) xs


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

int main() {
  int a , b , c , N ;
  cin >> N ;
  a = N / 100 ;
  N = N % 100 ;
  b = N / 10 ;
  c = N % 10 ;
  cout << a + b + c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;


//ABC 102 D
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	vector<ll> aRuiseki = vector<ll>(n);
	rep(i, 0, n) {
		cin >> a[i];
		if (i > 0) aRuiseki[i] = a[i] + aRuiseki[i - 1];
		else aRuiseki[i] = a[i];
	}
	ll lIndex = 0;
	ll rIndex = 2;
	ll ans = 1e15;
	
	
	rep(mIndex, 1, n-1) {
		ll p, q, r, s;
		rep(i, lIndex, mIndex) {
			p = aRuiseki[i];
			q = aRuiseki[mIndex] - aRuiseki[i];
			ll minPQ = abs(aRuiseki[mIndex] - 2 * aRuiseki[lIndex]);
			if (abs(p - q) <= minPQ) {
				lIndex = i;
				minPQ = abs(p - q);
			}
			else break;
		}
		p = aRuiseki[lIndex];
		q = aRuiseki[mIndex] - aRuiseki[lIndex];
		rep(i, rIndex, n-1) {
			r = aRuiseki[i] - aRuiseki[mIndex];
			s = aRuiseki[n-1] - aRuiseki[i];
			ll test = aRuiseki[n - 1] - 2 * aRuiseki[rIndex] + aRuiseki[mIndex];
			ll minRS = abs(aRuiseki[n - 1] - 2 * aRuiseki[rIndex] + aRuiseki[mIndex]);
			if (abs(r - s) <= minRS) {
				rIndex = i;
				minRS = abs(r - s);
			}
			else break;
		}
		r = aRuiseki[rIndex] - aRuiseki[mIndex];
		s = aRuiseki[n - 1] - aRuiseki[rIndex];
		ll mx = max(p, max(q, max(r, s)));
		ll mn = min(p, min(q, min(r, s)));
		if (abs(mx - mn) < ans) ans = abs(mx - mn);
	}
	cout << ans << endl;
}

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

int main() {
  int N, K, x;
  int min=0;
  cin >> N >> K;
  
  for ( int i=0; i < N; i++) {
    cin >> x;
    if ( 2*x <= 2*(K-x)) {
      min += 2*x;
    }
    else {
      min += 2*(K-x);
    }
  }
    cout << min << endl;
}

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

int main(void){
	long str;
  long m=0,x=0;
  scanf("%ld",&str);
  for(int i=0;i<8;i++){
  	x=(str%(long)pow(10,i+3))/pow(10,i);
  	if(fabs(x-753)<fabs(m-753)) m=x;
  }
  
  printf("%d",(int)fabs(m-753));
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(a-b>=0&&b-a<x)ou("delicious");
  else if(b-a<=x)ou("safe");
  if(b-a>x)ou("dangerous");
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            char[] S = in.next().toCharArray();
            Map<Integer, TreeSet<Integer>> map = new HashMap<>();
            for (int i = 'a'; i <= 'z'; i++) {
                map.put(i, new TreeSet<>());
            }
            for (int i = 0; i < N; i++) {
                map.get((int) S[i]).add(i + 1);
            }
            int Q = in.nextInt();
            for (int i = 0; i < Q; i++) {
                int type = in.nextInt();
                if (type == 1) {
                    Integer iq = in.nextInt();
                    int cq = in.next().charAt(0);
                    int c = S[iq - 1];
                    if (!map.get(cq).contains(iq)) {
                        map.get(c).remove(iq);
                        map.get(cq).add(iq);
                        S[iq - 1] = (char) cq;
                    }
                } else {
                    int lq = in.nextInt();
                    int rq = in.nextInt();
                    int cnt = 0;
                    for (Map.Entry<Integer, TreeSet<Integer>> e : map.entrySet()) {
                        TreeSet<Integer> value = e.getValue();
                        Integer v = value.ceiling(lq);
                        if (v != null && v <= rq) {
                            cnt++;
                        }
                    }
                    out.println(cnt);
                }
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 87052
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
double max(double a, double b) { return a > b ? a : b; }
int main(){
    double a,b,h,m,theta,ans;
    int i,j;
    const double pai=3.1415926535898;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    theta=(60*h-11*m)/360*pai;
    ans=sqrt(a*a+b*b-2*a*b*cos(theta));
    printf("%.11lf\n",ans);
    return 0;
}

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

int gcd(int a, int b){
    if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
    
}

int main()
{
    int K;
    int hoji;
    int ans = 0;
    cin >> K;
    rep(a,K){
        rep(b,K){
            rep(c,K){
                hoji = gcd(a,b);
                ans += gcd(hoji,c);
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3644
use std::io::Read;

fn main() {
    let c: char = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        iter.next().unwrap().chars().next().unwrap()
    };
    
    println!("{}", ((c as u8) + 1) as char);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int power(int num)
{
	int ans=1;
	for(int i=0;i<num;i++)ans*=10;
	return ans;
}
int main() {
	int n,m;
	while(cin>>m>>n,n,m){
		string str;
		bool player[1000]={};
		for(int i=1,now=0,out=m;i<=n;i++,now=(now+1)%m){
			cin>>str;
			if(out>1){
				while(player[now])now=(now+1)%m;
				if(i%15==0&&str!="FizzBuzz"||i%3==0&&i%5>0&&str!="Fizz"||i%5==0&&i%3>0&&str!="Buzz")player[now]=1;
				else if(i%3>0&&i%5>0){
					int num=0;
					for(int j=0;j<str.size();j++)num+=(str[j]-'0')*power(str.size()-1-j);
					if(num!=i)player[now]=1;
				}
				if(player[now])out--;
			}
		}
		for(int i=0,co=0;i<m;i++){
			if(co==0&&!player[i]){
				cout<<i+1;
				co++;
			}
			else if(!player[i])cout<<" "<<i+1;
		}
		cout<<endl;
	}
}

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

int main()
{
  int n,t;
  cin>>n>>t;
  int at;
  vector<int> ii;
  vector<string> ss;
  for(int i=0;i<n;i++)
    {
      int st_t1,st_t2,ar_t1,ar_t2;
      string st_n,ar_n;
      char br;
      cin>>st_t1>>br>>st_t2>>st_n>>ar_t1>>br>>ar_t2>>ar_n;
      if(i>0 && (st_t1*60+st_t2)-at>=t)
	{
	  ii.push_back((st_t1*60+st_t2)-at);
	  ss.push_back(st_n);
	}
      at=ar_t1*60+ar_t2;
    }  
  cout<<ii.size()<<endl;
  for(int i=0;i<ii.size();i++)
    {
      cout<<ss[i]<<" "<<ii[i]<<endl;
    }
}

Measured memory_bytes: 1236
#include<stdio.h>
int main(){
    long long int a,b,x,t1,t2;
    scanf("%lld %lld %lld",&a,&b,&x);
    if(a==0){
        t1=(b/x)+1;
        printf("%lld",t1);
    }
    else if(a==1){
        t1=(b/x);
        printf("%lld",t1);
    }
    else{
        t2=(a-1)/x;
        t1=(b/x)-t2;
        printf("%lld",t1);
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	
	void prog()
	{
		cin = new Scanner();

		int[] hight = new int[10];
		for (int i = 0; i < 10; i++)
		{
			hight[i] = cin.nextInt();
		}
		Array.Sort(hight);
		Array.Reverse(hight);
		for (int i = 0; i < 3; i++)
		{
			Console.WriteLine(hight[i]);
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a,b,c,d;
	cin >> a>>b >> c >>d;
	ll ans=max(a*c,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  string Str;
  getline(cin, Str);
  bool tf = Str[2] == Str[3];
  bool ff = Str[4] == Str[5];
  if(tf * ff ){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256