akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int h,n;
  cin>>h>>n;
  vector<int>dp(100000,INF);
  vector<pair<int,int>>v(n);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    v[i].first = a;
    v[i].second = b;
  }
  dp[0] = 0;
  rep(i,h + 1){
    rep(j,n){
      int a = v[j].first,b = v[j].second;
      if(i - a < 0)dp[i] = min(dp[i],b);
      else dp[i] = min(dp[i],dp[i - a] + b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
  /*
  private static void roop(int a, int b){
    for(int i = 0; i < a; i++){
      System.out.print(b);
    }
    System.out.println();
  }
  */
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
	int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    //char[] a = sc.nextLine().toCharArray();
    if(s.equals(u)){
      a--;
    }
    else
    {
      b--;
    }
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<pair<pair<string,int>, int >>SP;
	rep(i,N){
		string S;int p;
		cin>>S>>p;
		SP.push_back({{S,-p},i+1});
	}
	sort(all(SP));
	rep(i,N){
		//cerr<<SP[i].first.first<<" "<<SP[i].first.second<<endl;
		cout<<SP[i].second<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int record[31][100001]={0};
int recordsum[31][100002]={0};
int main(){
	int N,C;
	int s[100000],t[100000],c[100000];
	int recordnummax=0;
	scan(N);scan(C);
	rep(i,N){
		scan(s[i]);scan(t[i]);scan(c[i]);
		record[c[i]][s[i]-1]++;
		record[c[i]][t[i]]--;
	}
	rep1(i,C){
		rep1(j,100001){
			recordsum[i][j]=recordsum[i][j-1]+record[i][j-1];
		}
	}
	rep1(i,C){
		rep1(j,100001){
			recordsum[i][j]=min(recordsum[i][j],1);
		}
	}
	rep1(j,100001){
		int recordnum=0;
		rep1(i,C){
			recordnum+=recordsum[i][j];
		}
		recordnummax=max(recordnummax,recordnum);
	}
	prin(recordnummax);
	return 0;
}


Measured memory_bytes: 25216
loop{
	a,op,b=gets.chomp.split(" ")
	a=a.to_i
	b=b.to_i
	break if op=='?'
	c=a+b if op=='+'
	c=a-b if op=='-'
	c=a*b if op=='*'
	c=a/b if op=='/'
	puts c
}

Measured memory_bytes: 6100
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	string res = "No";
	if (s < t) res = "Yes";
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  private int A, B, T;
  
  public Main(int a, int b, int c) {
    this.A = a;
    this.B = b;
    this.T = c;
  }
  
  private void getBuiscit () {
    System.out.println(T/A*B);
  }
    
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
    
    Main obj = new Main(scan.nextInt(), scan.nextInt(), scan.nextInt());
    obj.getBuiscit();
    
  }
}


Measured memory_bytes: 21844
import functools
N, C = map(int, input().split())
T = [[0 for i in range(10 ** 5 + 1)] for j in range(C)]
for i in range(N):
  s, t, c = map(int, input().split())
  for j in range(s - 1, t):
    T[c - 1][j] = 1
ans = 0
for j in range(10 ** 5 + 1):
  r = 0
  for i in range(C):
    r += T[i][j]
  ans = max(ans, r)
print(ans)

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

int main(){
	// sengen
	int n,m;
	// nyuryoku
	cin >> n >> m;
	long long dp[n+1] = {};
	int a[m];
	for(int i=0;i<m;i++){
		cin >> a[i];
		dp[a[i]] = -1;
	}
	// keisan
	dp[0] = 1;
	for(int i=0;i<n;i++){
		if(dp[i] == -1){
			continue;
		}
		if(dp[i+1] != -1){
			dp[i+1] += dp[i];
			dp[i+1] = dp[i+1]%1000000007;
		}
		if(i+2 <= n && dp[i+2] != -1){
			dp[i+2] += dp[i];
			dp[i+2] = dp[i+2]%1000000007;
		}
	}
	// syutsuryoku
	cout << dp[n] << endl;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] m=new int[n];
		for(int i=0;i<n;i++)m[i]=i;
		int b=s.nextInt();
		for(int i=0;i<b;i++){
            String[] str=s.next().split(",");
            int q=Integer.parseInt(str[0])-1;
            int w=Integer.parseInt(str[1])-1;
			int temp=m[q];
			m[q]=m[w];
			m[w]=temp;
		}
		for(int i=0;i<n;i++)System.out.println(m[i]+1);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int dp[3100][3100];

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

    int N, T;
    cin >> N >> T;

    vector<int> A(N), B(N);
    REP(i, N) { cin >> A.at(i) >> B.at(i); }
    vector<pair<int, int>> as(N);
    REP(i, N) {
        as[i].first = A[i];
        as[i].second = i;
    }
    sort(ALL(as));
    memset(dp, 0, sizeof(dp));
    REP(i, N) {
        REP(t, T + 1) {
            chmax(dp[i + 1][t], dp[i][t]);
            if (t - A[as[i].second] >= 0) {
                chmax(dp[i + 1][t], dp[i][t - A[as[i].second]] + B[as[i].second]);
            }
        }
    }
    /*
    int i = N - 1;
    int t = T - 1;
    vector<int> used(N, 0);
    while (i >= 0) {
        if (t - A[as[i].second] >= 0 && dp[i + 1][t] == dp[i][t - A[as[i].second]] + B[as[i].second]) {
            used[] = 1;
            t = t - A[as[i].second];
            i--;
        } else if (dp[i + 1][t] == dp[i][t]) {
            i--;
        }
    }*/

    int ans = dp[N][T];
    REP(i, N) { chmax(ans, dp[i][T - 1] + B[as[i].second]); }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 37888
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int N = 50007;
const int M = 328;
const int B = 203;
const double pi = acos(-1.0);
const double eps = 1e-8;
/*
bool en(double alp,int a,int b,int x) {
	double w = min((double)a,b / tan(alp));
	double can = w * w * w * tan(alp) * 0.5;
	if(b/tan(alp) - a <= -eps) can += a * a * (b - w);
	dd(alp/pi*180),dd(w),dd(can),de(can-x);
	return can - x >= -eps;
}*/
bool en(double alp,int a,int b,int x) {
	double can = 0;
	if(b / tan(alp) - a <= -eps) {
		double w = b / tan(alp);
		can = a * w * w * tan(alp) * 0.5;
	}else {
		can = a * a * a * tan(alp) * 0.5 + a * a * (b - a * tan(alp));
	}
	return can - x >= -eps;
}
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	double l = 0,r = pi / 2.0;
	while((r - l) > eps) {
		double m = (l + r) / 2.0;
		if(en(m,a,b,x)) l = m;
		else r = m;
	}
	printf("%.8f\n",(l + r) / 2 / pi * 180);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=1e5+500;
const ll mod=1e9+7;
const ll inf=2e18+500;


ll s[maxn];
vector<ll> vec[2];
ll fen[maxn][2];


bool f(char c){
	if(c=='a'){
		return 0;
	}
	return 1;
}	
void update(ll p,ll v,char c){
	bool b=f(c);
	vec[b].pb(p);
	p++;
	while(p<maxn){
		fen[p][b]=(fen[p][b]+v)%mod;
		p+=(p&(-p));
	}
}
ll finds(ll p,char c){
	bool b=f(c);
	p++;
	ll ans=0;
	while(p>0){
		ans=(ans+fen[p][b])%mod;
		p-=(p&(-p));
	}
	return ans;
}
void cle(char c){
	bool b=f(c);
	for(ll i=0;i<vec[b].size();i++){
		ll p=vec[b][i];
		p++;
		while(p<maxn){
			fen[p][b]=0;
			p+=(p&(-p));
		}
	}
	vec[b].clear();
}
void pri(char c){
	cout<<c<<":";
	cout<<finds(0,c)<<' ';
	for(ll i=1;i<8;i++){
		cout<<finds(i,c)-finds(i-1,c)<<' ';
	}
	cout<<endl;
}


int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	s[0]=-inf;
	s[1]=-inf;

	for(ll i=2;i<n+2;i++){
		cin>>s[i];
	}
	update(1,1,'a');
	update(0,1,'b');
	for(ll i=3;i<n+2;i++){
		ll va=upper_bound(s,s+n+2,s[i]-a)-s-1;
		ll ra=finds(va,'b');

		ll vb=upper_bound(s,s+n+2,s[i]-b)-s-1;
		ll rb=finds(vb,'a');	
		if(s[i]-s[i-1]<a){
			cle('a');
		}
		if(s[i]-s[i-1]<b){
			cle('b');
		}
		update(i-1, ra  ,'a');
		update(i-1, rb  ,'b');
	}
	cout<<(finds(maxn-2,'a')+finds(maxn-2,'b'))%mod;
}
/*    
	  .      _______    __    ___     ________      ________       _________     _________   ________
	  .     /       \  |  |  /  /    /        \    |        \     /         \   |        |  |   __   \
	  .    /   _____/  |  | /  /    /    ___   \   |   ___   \   |   _______/   |  ______|  |  |  \   \
	  .   /   /        |  |/  /    /    /   \   \  |  |   \   \  |  (______     |  |_____   |  |__/   /
	  .   |  |         |     /     |   /     \  |  |  |    |  |   \        \    |        |  |      __/
	  .   |  |         |     \     |   \     /  |  |  |    |  |    \______  \   |  ______|  |      \
	  .   \   \_____   |  |\  \    \    \___/   /  |  |___/   /    _______) |   |  |_____   |   |\  \
	  .    \        \  |  | \  \    \          /   |         /    /         /   |        |  |   | \  \
	  .     \_______/  |__|  \__\    \________/    |________/     \________/    |________|  |___|  \__\
 */


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

int N, Q;
vector<vector<int>> G;
vector<int> p, x;
vector<int> ans;
map<int,int> MP;


void dfs(int v, int p = -1){
    ans[v] += MP[v];

    for(auto u: G[v]){
        if(u == p) continue;

        ans[u] += ans[v];
        dfs(u, v);
    }
}

void solve(){

    for(int i = 0; i < Q; i++){
        MP[p[i]] += x[i];
    }
    ans.assign(N,0);
    dfs(0);

    for(auto e: ans) cout << e << endl;
}

int main(){
    cin >> N >> Q;
    G.assign(N,vector<int>());
    for(int i = 0; i < N - 1; i++){
        int a, b; cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    p.assign(Q,0), x.assign(Q,0); 
    for(int i = 0; i < Q; i++){
        cin >> p[i] >> x[i];
        p[i]--;
    }
    solve();
}


Measured memory_bytes: 40704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

int main()
{
	ll h,w;
	cin>>h>>w;

	vector<vector<int>> a(h,vector<int> (w));
  vector<vector<int>> b(h,vector<int> (w));
	vector<vector<int>> c(h,vector<int> (w));
	rep(i,h)rep(j,w)cin>>a[i][j];
	rep(i,h)rep(j,w){
		cin>>b[i][j];
		c[i][j]=abs(a[i][j]-b[i][j]);
	}
	bitset<dbase*2> dp[h+1][w+1];
	dp[0][0][dbase+c[0][0]]=1;
	dp[0][0][dbase-c[0][0]]=1;
	rep(i,h)rep(j,w){
		if (i>=1){
		dp[i][j]|=dp[i-1][j]>>c[i][j];
		dp[i][j]|=dp[i-1][j]<<c[i][j];
//	cout<<c[i][j]<<endl;
	}
	if (j>=1){
		dp[i][j]|=dp[i][j-1]>>c[i][j];
		dp[i][j]|=dp[i][j-1]<<c[i][j];
	//	cout<<c[i][j]<<endl;
	}
}
int ans=INF;
rep(i,dbase*2){
	if (dp[h-1][w-1][i]) {
		ans=min(ans,abs(dbase-i));
	//cout<<i<<endl;
}
}
cout<<ans;
}


Measured memory_bytes: 20864
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

const int d4[4][2] = {
    {0, 1},
    {1, 0},
    {0, -1},
    {-1, 0},
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int h, w;
    cin >> h >> w;
    V<string> g(h);
    V<int> dist(h * w, 10000);
    queue<int> que;
    auto to_id = [&](int r, int c) {
        return r * w + c;
    };
    for (int i = 0; i < h; i++) {
        cin >> g[i];
        for (int j = 0; j < w; j++) {
            int id = to_id(i, j);
            if (g[i][j] == '#') {
                dist[id] = 0;
                que.push(id);
            }
        }
    }


    int ans = 0;
    while (!que.empty()) {
        int id = que.front(); que.pop();
        int r = id / w, c = id % w;
        ans = max(ans, dist[id]);
        for (int d = 0;d < 4;d ++) {
            int nr = r + d4[d][0], nc = c + d4[d][1];
            if (!(0 <= nr && nr < h && 0 <= nc && nc < w)) continue;
            int nid = to_id(nr, nc);
            if (dist[nid] < 10000) continue;
            dist[nid] = dist[id] + 1;
            que.push(nid);
        }

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



Measured memory_bytes: 9344
import numpy as np

mod = 998244353

n, s = map(int, input().split())
A = list(map(int, input().split()))
DP = np.zeros(3005, dtype=np.int64)

for num, a in enumerate(A):
    double = DP * 2
    shift = np.hstack([np.zeros(a), DP[:-a]]).astype(np.int64)
    DP = double + shift
    DP[a] += pow(2, num, mod)
    DP %= mod

print(DP[s])


Measured memory_bytes: 27504
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int henA,henB,henC;
		cin>>henA>>henB>>henC;
		if(henA>henC){
			swap(henA,henC);
		}
		if(henB>henC){
			swap(henB,henC);
		}
		if(henA*henA+henB*henB==henC*henC)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w_cap;
    cin >> n >> w_cap;
    int v_max = 1e5;
    VI w(n), v(n);
    REP(i, n) cin >> w[i] >> v[i];
    VVL dp(n + 1, VL(v_max + 1, 1e10));
    dp[0][0] = 0;
    FOR(i, 1, n)FOR(j, 0, v_max) {
        if(j - v[i - 1] < 0)
            dp[i][j] = dp[i - 1][j];
        else
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
    }
    
    FORR(j, v_max, 0) {
        if(dp[n][j] <= w_cap) {
            cout << j << ln;
            return 0;
        }
    }
    return 0;
}


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

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


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<String> list = new ArrayList<>();

		while(true) {

			// ?????????????????°????????°???????´?
			int middle = in.nextInt();
			int term_end = in.nextInt();
			int retest = in.nextInt();
			int sum = middle + term_end;

			// ?????°?????¨????????????????????????????´?
			if(middle == -1 && term_end == -1 && retest == -1) {

				break;

			}else if(middle == -1 || term_end == -1) {

				list.add("F");

			}else if(sum >= 80) {

				list.add("A");

			}else if(sum < 80 && sum >= 65) {

				list.add("B");

			}else if(sum < 65 && sum >= 50) {

				list.add("C");

			}else if(sum < 50 && sum >= 30) {

				if(retest >=  50) {

					list.add("C");

				}else {

					list.add("D");

				}

			}else if(sum < 30) {

				list.add("F");

			}
		}

		// ???????????¨???
		for(String result: list) {

			System.out.println(result);

		}
	}
}

// -------??\????????¨??????????????¨????????????----------------------

/*public class Main7A {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true) {

			// ?????????????????°????????°???????´?
			int middle = in.nextInt();
			int term_end = in.nextInt();
			int retest = in.nextInt();
			int sum = middle + term_end;

			// ?????°????????£??????????????¨???
			if(middle == -1 && term_end == -1 && retest == -1) {

				break;

			}else if(middle == -1 || term_end == -1) {

				System.out.println("F");

			}else if(sum >= 80) {

				System.out.println("A");

			}else if(sum < 80 && sum >= 65) {

				System.out.println("B");

			}else if(sum < 65 && sum >= 50) {

				System.out.println("C");

			}else if(sum < 50 && sum >= 30) {

				if(retest >=  50) {

					System.out.println("C");

				}else {

					System.out.println("D");

				}

			}else if(sum < 30) {

				System.out.println("F");

			}
		}
	}
}*/

Measured memory_bytes: 26256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string, int> s;
    int q, a, b;
    string key, key2;
    cin >> q;
    rep(i, q) {
        cin >> a >> key;
        if(a == 0) {
            cin >> b;
            s[key] = b;
        } else if(a == 1) {
            if(s.find(key) != s.end())
                cout << s[key] << "\n";
            else
                cout << "0\n";
        } else if(a == 2) {
            s.erase(key);
        } else {
            cin >> key2;
            auto p1 = s.lower_bound(key);
            auto p2 = s.upper_bound(key2);
            while(p1 != p2) {
                cout << p1->first << " " << p1->second << "\n";
                p1++;
            }
        }
    }
}


Measured memory_bytes: 25908
#include <iostream>

using namespace std;

int main() {
    int A,B,K;
    cin >>A>>B>>K;
    int C=0;
    int D=0;
    C=A+B;
    while(D!=K){
        C=C-1;
        if(A%C==0 && B%C==0){
            D=D+1;
        }
    }
    cout<<C<<endl;
}  

Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


int main(){
    init();

    string s;
    cin>>s;
    ll a[4];
    a[0]=(s[0]-'0');
    a[1]=(s[1]-'0');
    a[2]=(s[2]-'0');
    a[3]=(s[3]-'0');
    
    for(int i=0;i<(1<<3);i++){
        ll num=a[0];
        string ans;
        ans+=s[0];
        for(int j=0;j<3;j++){
            if((i>>j)&1){
                num+=a[j+1];
                ans+='+';
            }else{
                num-=a[j+1];
                ans+='-';
            }
            ans+=s[j+1];
        }
        if(num==7){
            cout<<ans<<"=7"<<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
  int n,i,s=0,l,ex;
  cin >> n;
  l=s=0;
  while (s<=n) s+=++l;
  ex=s-n;
  for (i=1;i<=l;i++) if (i!=ex) cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a,b,c,d,e,f;
    cin >> a >>b >> c >> d >> e >> f;
    vector<int> water;
    for(int i = 1;i*a*100<=f;i++){
        for(int j = 0;j*b*100+i*a*100<=f;j++){
            water.push_back(j*b*100+i*a*100);
        }
    }
    water.push_back(b*100);
    sort(water.begin(),water.end());
    vector<int> suger;
    for(int i = 0;i*c<=f;i++){
        for(int j = 0;j*d+i*c<=f;j++){
            suger.push_back(j*d+i*c);
        }
    }
    sort(suger.begin(),suger.end());
    P ans = P(0,a*100);
    for(auto i:water){
        auto s = *--upper_bound(suger.begin(),suger.end(),i/100*e);
        if(s+i>f){
            s = *--upper_bound(suger.begin(),suger.end(),f-i);
        }
        if((double)ans.first/ans.second <(double)s/(i+s)){
            ans = P(s,i+s);
        }
    }
    cout << ans.second<<' ' << ans.first<< endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair <int , int> pii;
const int MAXN = 4e5 + 10 , INF = 202020;
int ans = 1e9;
vector <pii> v[MAXN];
int x[MAXN] , y[MAXN] , t[MAXN];
int tu(char c){
	if(c == 'U') return 0;
	else if(c == 'R') return 1;
	else if(c == 'D') return 2;
	return 3;
}
void check(int m){
	for(int i = 0 ; i <= 400000 ; ++ i)
		if((int)v[i].size() > 0){
			sort(v[i].begin() , v[i].end());
			int la = -INF;
			for(int k = 0 ; k < (int)v[i].size() ; ++ k)
				if(v[i][k].second == -1){
					if(la != -INF)
						ans = min(ans , (v[i][k].first - la) * m);
				}
				else
					la = v[i][k].first;
			v[i].resize(0);
		}
}
int main(){
	int N;
	scanf("%d" , &N);
	for(int i = 1 ; i <= N ; ++ i){
		char s[2];
		scanf("%d%d%s" , &x[i] , &y[i] , s);
	//	cout << i << " " << x[i] + y[i] << " " << x[i] - y[i] << " " << t[i] << endl; 
		t[i] = tu(s[0]);
	}
	for(int i = 1 ; i <= N ; ++ i)
		if(t[i] % 2 == 0)
			v[x[i]].push_back(make_pair(y[i] , (t[i] == 0 ? 1 : -1)));
	check(5);
	for(int i = 1 ; i <= N ; ++ i)
		if(t[i] % 2 == 1)
			v[y[i]].push_back(make_pair(x[i] , (t[i] == 1 ? 1 : -1)));
	check(5);
	for(int i = 1 ; i <= N ; ++ i)
		if(t[i] == 0 || t[i] == 3)
			v[y[i] - x[i] + 200000].push_back(make_pair(x[i] , (t[i] == 0 ? 1 : -1)));
	check(10);
	for(int i = 1 ; i <= N ; ++ i)
		if(t[i] == 1 || t[i] == 2)
			v[y[i] - x[i] + 200000].push_back(make_pair(x[i] , (t[i] == 1 ? 1 : -1)));
	check(10);
	for(int i = 1 ; i <= N ; ++ i)
		if(t[i] == 0 || t[i] == 1)
			v[x[i] + y[i]].push_back(make_pair(x[i] , (t[i] == 1 ? 1 : -1)));
	check(10);
	for(int i = 1 ; i <= N ; ++ i)
		if(t[i] == 2 || t[i] == 3)
			v[x[i] + y[i]].push_back(make_pair(x[i] , (t[i] == 2 ? 1 : -1)));
	check(10);
	if(ans == 1e9)
		cout << "SAFE" << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27916
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int N, cnt[3005];
void insert(int x)
{
    //质因数分解，并统计质因数出现次数
    for (ri i = 2; i * i <= x; ++i) {
        if (x % i)
            continue;
        while (x % i == 0) {
            cnt[i]++;
            x /= i;
        }
    }
    if (x != 1) {
        cnt[x]++;
    }
}
signed main()
{
    N = read();
    for (ri i = 1; i <= N; ++i) {
        insert(i);
    }
    int ans = 1;
    for (ri i = 2; i <= N; ++i) {
        ans = ans * (cnt[i] + 1) % MOD;
    }
    writeln(ans);
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   int N,M;
   cin>>N>>M;
   vector<ll>x(N),y(N),z(N);
   for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>z[i];

   vector<vector<ll> >data(8,vector<ll>(N,0));
   for(int i=0;i<N;i++){
      data[0][i] = x[i]+y[i]+z[i];
   }
   for(int i=0;i<N;i++){
      data[1][i] = x[i]+y[i]-z[i];
   }
   for(int i=0;i<N;i++){
      data[2][i] = x[i]-y[i]+z[i];
   }
   for(int i=0;i<N;i++){
      data[3][i] = x[i]-y[i]-z[i];
   }
   for(int i=0;i<N;i++){
      data[4][i] = -x[i]+y[i]+z[i];
   }
   for(int i=0;i<N;i++){
      data[5][i] = -x[i]+y[i]-z[i];
   }
   for(int i=0;i<N;i++){
      data[6][i] = -x[i]-y[i]+z[i];
   }
   for(int i=0;i<N;i++){
      data[7][i] = -x[i]-y[i]-z[i];
   }

   for(int i=0;i<8;i++)sort(data[i].rbegin(),data[i].rend());

   vector<ll>sum(8,0);
   for(int i=0;i<8;i++){
      for(int j=0;j<M;j++){
         sum[i] += data[i][j];
      }
   }

   cout<<*max_element(sum.begin(),sum.end())<<endl;
   return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<vector>
#include<string>

using namespace::std;

int main(){
  int k;
  string s;
  cin >> k;
  cin >> s;
  if(s.length() > k){
	cout << s.substr(0,k) << "..."<< endl;
  } else {
    cout << s << endl; 
  }
  return 0; 
}

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

int h, w;
int m[16][16];

int n;
int sy, sx;

int dfs(int y, int x, int b = (1 << n) - 1)
{
  if (b == 0){
    return (y == sy || x == sx);
  }

  int ret = 0;
  for (int i = y - 1; i >= 0; i--){
    if (m[i][x] == -1) continue;
    if (b & (1 << m[i][x])){
      ret += dfs(i, x, b - (1 << m[i][x]));
      break;
    }
  }
  for (int i = y + 1; i < h; i++){
    if (m[i][x] == -1) continue;
    if (b & (1 << m[i][x])){
      ret += dfs(i, x, b - (1 << m[i][x]));
      break;
    }
  }
  for (int i = x - 1; i >= 0; i--){
    if (m[y][i] == -1) continue;
    if (b & (1 << m[y][i])){
      ret += dfs(y, i, b - (1 << m[y][i]));
      break;
    }
  }
  for (int i = x + 1; i < w; i++){
    if (m[y][i] == -1) continue;
    if (b & (1 << m[y][i])){
      ret += dfs(y, i, b - (1 << m[y][i]));
      break;
    }
  }

  return ret;
}

int main()
{
  while (cin >> w >> h, w){
    n = 0;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cin >> m[i][j];
        if (m[i][j] == 0) m[i][j] = -1;
        if (m[i][j] == 2) {
          sy = i; sx = j;
          m[i][j] = -1;
        }
        if (m[i][j] == 1) m[i][j] = n++;
      }
    }

    cout << dfs(sy, sx) << endl;
  }
}

Measured memory_bytes: 3056
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    double x;
    double h;
    while(1)
    {
        cin >> x >> h;
        if(x == 0 && h == 0)
        {
            break;
        }
        double s = x * (sqrt(x * x + 4 * h *h)) + x * x;
        cout << fixed << setprecision(6) << s << endl;
    }
    return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=2;ii<=mx;ii++)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
ll n,a[100005],dp[100005];
ll rec(ll k)
{
    if(k>=n-1) return 0;
    if(dp[k]!=-1) return dp[k];
    ll opt1=INT_MAX,opt2=INT_MAX;
    if(k+1<n)opt1=abs(a[k]-a[k+1])+rec(k+1);
    if(k+2<n)opt2=abs(a[k]-a[k+2])+rec(k+2);
    dp[k]=min(opt1,opt2);
    return dp[k];
}

main()
{
    fastio();
    cin>>n;
    mem(dp,-1);
    ll i;
    forn(i,n) cin>>a[i];
    cout<<rec(0) el;
}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 9760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int ans = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) != T.charAt(i)) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 41268
#include <iostream>
#include <cmath>
#include<algorithm>
#include <string>
#include<iomanip>
#include <string.h>
#include<stdlib.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a = 0, b = 0 , c = 0 , d = 0;
    cin >> a >> b >> c >> d;
    long long mx1 = a*c;
    long long mx2 = a*d;
    long long mx3 = b*c;
    long long mx4 = b*d;
    long long ans = max(max(mx1,mx2),max(mx3,mx4));
    cout << ans;
return 0;
}


Measured memory_bytes: 3652
str1 = raw_input()
str2 = raw_input()
n = len(str1)

for i in xrange(n):
    j = i
    s = 0
    for k in xrange(len(str2)):
        if (j+k) > (n-1):
            j = -k
        if str1[j+k] != str2[k]:
            s += 1
    if s == 0:
        print "Yes"
        break
else:
    print "No"

Measured memory_bytes: 6424
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ1159().doIt();
	}

	class AOJ1159{
		int n,p;
		void solve(){
			int[] person = new int[n];
			int wan = p;
			int ban = 0;
			int result = -1;
			while(true){
				if(wan==0){
					wan = person[ban];
					person[ban] = 0;
				}else{
					wan--;person[ban]++;
				}
//				System.out.println(Arrays.toString(person));
				if(person[ban]==p){
					result = ban;
					break;
				}
				ban = (ban+1)%n;
			}
			System.out.println(result);
		}
		void doIt(){
			while(in.hasNext()){
				n = in.nextInt();p = in.nextInt();
				if(n+p==0)break;
				solve();
			}
		}
	}

}

Measured memory_bytes: 18524
#include <iostream>
#include <stdio.h>
using namespace std;
int main ()
{
    int x,a,b,c,t=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int m=0;m<=c;m++)
            {
                if(500*i+100*j+m*50==x)
                    t++;

            }
     printf("%d",t);
}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long res = Long.MAX_VALUE;
         for(int v=-100; v <= 100; v++)
         {
            long temp = 0L;
            for(int x: arr)
               temp += (x-v)*(x-v);
            res = Math.min(res, temp);
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 32844
import numpy as np

h, w = map(int, input().split())
grid = (np.array([list(input())
                  for _ in range(h)]) == "#")
cost = np.full((h, w), 10 ** 9, dtype=np.int64)
cost[grid[:, :]] = 0

for i in range(1, h):
    cost[i] = np.minimum(cost[i], cost[i - 1] + 1)

for i in range(h - 1)[::-1]:
    cost[i] = np.minimum(cost[i], cost[i + 1] + 1)

for i in range(1, w):
    cost[:, i] = np.minimum(cost[:, i], cost[:, i - 1] + 1)

for i in range(w - 1)[::-1]:
    cost[:, i] = np.minimum(cost[:, i], cost[:, i + 1] + 1)

print(np.max(cost))

Measured memory_bytes: 25172
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	string S;
	cin >> S;

	int n = S.size();
	long long sum = 0;

	//cout <<( 1 << (n - 1) )<< endl;

	for (int mask = 0; mask < (1 << (n-1)); mask++) {
		long long tmp = (S[0] - '0');
		for (int i = 0; i < n-1; i++) {
			if (((mask >> i) & 1) == 1) {
				sum += tmp;
				tmp = 0;
			}
			tmp = tmp * 10 + (S[i+1] - '0');
		}
		sum += tmp;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    string s; cin >> s;
    vector<char> v;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != 'B') v.push_back(s[i]);
        else if(!v.empty()) v.pop_back();
    }
    for(int i = 0; i < v.size(); i++) cout << v[i];
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;
	static boolean[] used;
	static int f = 0;
	static int s = 0;

	static long mod = 1000000007;
	static ArrayList<Integer> saitan;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a+b>= 10){
			System.out.println("error");
		}else{
			System.out.println(a+b);
		}
		




	}
	static int lowerbond(int k, int[] data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return data[max];
	}


	static long cal(int n){
		long x = (long)n;
		for(int i = n-1;i > 0;i--){
			//	System.out.println(i);
			x *= i;
			x %= mod;
		}
		return x;
	}

}




Measured memory_bytes: 21332
<?php
  $t1 = 0;
  $t2 = 0;
  $t3 = 0;
  while($i=(int)fgets(STDIN)) {
      if($i>$t3) {
          if($i>$t2) {
              if($i>$t1) {
                  $t3 = $t2;
                  $t2 = $t1;
                  $t1 = $i;
              } else {
                  $t3 = $t2;
                  $t2 = $i;
              }
          } else {
              $t3 = $i;
          }
      }
  }
  echo $t1."\n".$t2."\n".$t3."\n";

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

using namespace std;

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

  int ans = 1;
  for (int i = 0; i < N; ++i) {
    if (ans < K) ans *= 2;
    else ans += K;
  }

  cout << ans;
}

Measured memory_bytes: 256
def bridge(G, N):
    result = set()
    label = [None] * (N+1)
    gen = 0
    cost = [0] * (N+1)
    def dfs(u, p):
        nonlocal gen
        res = 0
        for v in G[u]:
            if v == p:
                continue
            if label[v] is not None:
                if label[v] < label[u]:
                    cost[v] += 1
                    res += 1
            else:
                label[v] = gen; gen += 1
                r = dfs(v, u)
                if r == 0:
                    result.add((u, v) if u < v else (v, u))
                res += r
        res -= cost[u]
        return res
    for v in range(N):
        if not label[v]:
            label[v] = gen; gen += 1
            r = dfs(v, -1)
            assert r == 0, r
    return result

from collections import deque

N,M,*abf = map(int, open(0).read().split())
ab = [abf[i*2:i*2+2] for i in range(M)]
connected = [[] for _ in range(N+1)]
ans = 0
for a, b in ab:
    connected[a].append(b)
    connected[b].append(a)
print(len(bridge(connected,N)))

Measured memory_bytes: 9468
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	char b;
  	cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'C') cout << 'G' << endl;
    if(b == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:1048576")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef tuple <int, int, int> t3;

int IT_MAX = 1 << 12;
const ll MOD = 1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)

vector <pll> conn[100050];
ll dis[100050];
int main() {
	int N, i, j, Q, K;
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2, t3;
		scanf("%d %d %d", &t1, &t2, &t3);
		conn[t1].emplace_back(t3, t2);
		conn[t2].emplace_back(t3, t1);
	}
	scanf("%d %d", &Q, &K);

	memset(dis, 0x3f, sizeof(dis));
	vector <int> Vu;
	dis[K] = 0;
	Vu.push_back(K);
	for (i = 0; i < Vu.size(); i++) {
		for (auto it : conn[Vu[i]]) {
			if (dis[it.second] == LL_INF) {
				dis[it.second] = dis[Vu[i]] + it.first;
				Vu.push_back(it.second);
			}
		}
	}
	while (Q--) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		printf("%lld\n", dis[t1] + dis[t2]);
	}
	return 0;
}

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

int main(){
    int w, h, n;
    cin >> w >> h >> n;

    int x, y, a;
    int ldx = 0, ldy = 0, rux = w, ruy = h;

    for(int i = 0; i < n; i++){
        cin >> x >> y >> a;
        if(a == 1){
            ldx = max(x,ldx);
        }else if(a == 2){
            rux = min(x,rux);
        }else if(a == 3){
            ldy = max(y, ldy);
        }else if(a == 4){
            ruy = min(y, ruy);
        }
    }

    int ans = max(0, (rux-ldx)) * max(0, (ruy-ldy));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ll x, y;
    cin >> x >> y;
    ll ay = abs(y);
    ll ax = abs(x);
    if(x < y)
    {
        if(x * y >= 0)
        {
            cout << abs(ay - ax) << endl;
        }
        else
        {
            cout << abs(ay-ax) + 1 << endl;
        }
    }
    else
    {
        if(x * y > 0)
        {
            cout << abs(ay - ax) + 2 << endl;
        }
        else
        {
            cout << abs(ay-ax) + 1 << endl;
        }
    }
}


Measured memory_bytes: 3572
# Problem B - Distance

import math

# input
N, D = map(int, input().split())

# initialization
count = 0

# count
for i in range(N):
    x, y = map(int, input().split())
    tmp = math.sqrt(x**2 + y**2)
    if tmp<=D:
        count += 1

# output
print(count)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, M;
int d[110][110];
int n[110][110];
set<PII> s;


void warshallFloyd(){
	rep(i, 0, N){
		rep(j, 0, N){
			if(!d[i][j]) d[i][j] = INF;
			n[i][j] = j;
		}
	}
	rep(k, 0, N)
		rep(i, 0, N)
			rep(j, 0, N)
				if(d[i][j] > d[i][k]+d[k][j]) d[i][j] = d[i][k]+d[k][j], n[i][j] = n[i][k];
}


int solve(){
	rep(i, 0, N)
		rep(j, i+1, N)
			for(int k = i;k != j;k = n[k][j])
				s.insert({ min(k, n[k][j]), max(k, n[k][j]) });
	return M-SIZE(s);
}


signed main(){
	cin >> N >> M;
	rep(i, 0, M){
		int a, b, c;
		cin >> a >> b >> c, a--, b--;
		d[a][b] = d[b][a] = c;
	}

	warshallFloyd();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] seq = new int[n+2];
      seq[0] = seq[n+1] = 0;
      int[] d = new int[n+1];

      String line = in.readLine();
      char regex = ' ';
      boolean isContinue = true;
      for(int i=1, offset=0,next=0; isContinue; offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        seq[i++] = Integer.parseInt(line.substring(offset,next));
      }

      int sum=0;
      StringBuilder buf = new StringBuilder();
      for(int i=0; i<=n; i++) {
        sum += d[i] = Math.abs(seq[i+1] - seq[i]);
      }
      // sum += Math.abs(seq[n]);

      int ans=0;
      for(int i=1; i<=n; i++) {
        ans = sum;
        // ans -= Math.abs(seq[i] - seq[i-1]);
        // ans -= Math.abs(seq[i+1] - seq[i]);
        ans -= d[i-1];
        ans -= d[i];
        ans += Math.abs(seq[i+1] - seq[i-1]);
        buf.append(ans).append('\n');
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 41768