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

typedef long long int ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0;i < n;i++){
    	cin >> a[i];
    }
    sort(a,a+n);
    ll cnt = 0;

    for(int i = 0;i < n;i++){
    	for(int j = i+1;j < n;j++){
    		if(a[j] == a[i]){
    			continue;
    		}
    		for(int k = j+1;k < n;k++){
    			if(a[k] == a[j] or a[k] == a[i]){
    				continue;
    			}else{
    				if(a[i]+a[j]> a[k]){
    					cnt++;
    				}
    			}
    		}
    	}
    }
    cout << cnt << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 3660
r, c = map(int, input().split())
sheet = []

for i in range(r):
    num = list(map(int, input().split()))
    sheet.append(num)
    
for i in sheet:
    last = sum(i)
    i.append(last)
    
inner = []
x = 0

for i in range(c + 1):
    for j in range(r):
        x += sheet[j][i]
      
    inner.append(x)
    
    x =0
    
   
    
sheet.append(inner)

for i in sheet:
    print(" ".join(map(str, i)))


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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int s,w;
    cin>>s>>w;
    if(s > w){
        cout<<"safe\n";
    }else{
        cout<<"unsafe\n";
    }
}

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

int main(){
    string n;
    cin >> n;
    while (true)
    {
        if(n == "0") break;
        int sum = 0;
        for(int i = 0; i < (int)n.size(); i++){
            sum += n[i] - '0';
        }
        cout << sum << endl;
        cin >> n;
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N;
vector<double> V;

int main(int argc, char** argv) {
  cin >> N;
  V.resize(N);
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }

  Sort(V);

  for (int i=0; i<N-1; i++) {
    V[i+1] = (V[i]+V[i+1])/2.0;
  }

  cout << V[N-1] << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val (xt, yt) = readLine()!!.split(' ').map { it.toInt() }

    val dx = mutableListOf<Int>()
    val dy = mutableListOf<Int>()
    s.split('T').forEachIndexed { i, sub ->
        if (i % 2 == 0) dx.add(sub.length) else dy.add(sub.length)
    }

    val x = dx.slice(1 until dx.size).sortedDescending()
            .fold(xt - dx[0]) { acc, i -> acc + if (acc > 0) -i else i }

    val y = dy.sortedDescending()
            .fold(yt) { acc, i -> acc + if (acc > 0) -i else i }

    println(if (x == 0 && y == 0) "Yes" else "No")
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

int h, w;
char s[22][22];
int dist[22][22];

int bfs(int sx, int sy) {
  rep(i, 22) {
    rep(j, 22) { dist[i][j] = INF; }
  }
  queue<P> que;
  dist[sy][sx] = 0;
  que.push(P(sx, sy));
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if (s[ny][nx] == '#') continue;
      if (dist[ny][nx] <= dist[p.second][p.first] + 1) continue;
      dist[ny][nx] = min(dist[ny][nx], dist[p.second][p.first] + 1);
      que.push(P(nx, ny));
    }
  }

  int ret = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      ret = max(ret, dist[i][j]);
    }
  }
  return ret;
}

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

  cin >> h >> w;
  rep(i, h) {
    rep(j, w) { cin >> s[i][j]; }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      ans = max(ans, bfs(j, i));
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll s;
ll dp[2222];
ll memo[2222];


int main(){
    cin >> s;
    ll mod=1e9+7;
    if(s<=2){
        cout << 0 << endl;
        return 0;
    }
    dp[3]=1;
    dp[4]=1;
    dp[5]=1;
    for(ll i=6;i<=s;i++){
        memo[i-3]=memo[i-4]+dp[i-3];
        memo[i-3]%=mod;
        dp[i]=memo[i-3]+1;
        dp[i]%=mod;
    }
    cout << dp[s] << endl;
    return 0;
}  


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

    public static void main(String[] args) throws Exception {
        //?????????
        final BigDecimal TAX_RATE = new BigDecimal("0.05");
        //?????°?????????????????????????????¨??????
        final int ROUND_UP_FRACTION = 1000;
        //???????????????????????????10???
        int deptLeft = 100000;

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        int countWeeks = Integer.parseInt(reader.readLine());
        //1??±??????????????¨??????????????????????????????????????????????¨??????????
        for (int count = 1; count <= countWeeks; count++) {
            deptLeft = BigDecimal.valueOf(deptLeft)
                    .add(BigDecimal.valueOf(deptLeft).multiply(TAX_RATE))
                    .intValue();
            //1000?????????????????????????????????
            if (deptLeft % ROUND_UP_FRACTION != 0) {
                deptLeft = deptLeft
                        + (ROUND_UP_FRACTION - deptLeft % ROUND_UP_FRACTION);
            }
        }
        System.out.println(deptLeft);
    }
}

Measured memory_bytes: 15112
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int k;
    cin>>k;
    ll n = 7%k;
    int ans = 1;
    vector<ll>a(k);
    while(1){
        if(n==0) {
            cout<<ans<<endl;
            return 0;
        }
        if(a[n]) {
            cout<<-1<<endl;
            return 0;
        }
        a[n]++;
        n = (10*n+7)%k;
        ans++;
    }

    return 0;
}


Measured memory_bytes: 11104
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a<b&&b<c&&a<c) cout << "Yes" << endl;
    else cout << "No"  << endl;
}
    





Measured memory_bytes: 3084
#include<stdbool.h>

bool flag[100005];

int main(){
	long n, m, x, y, i;
	long nbox[100005] = {0};
	scanf("%ld%ld", &n, &m);
	for(i = 0; i < n; i++) nbox[i] = 1;	
	
	flag[0] = 1;
	for(i = 0 ; i < m; i++){
		scanf("%ld%ld", &x, &y);
		if(nbox[x-1] >= 1){
			nbox[x-1]--;
			nbox[y-1]++;
			
			if(flag[x-1] == 1 && flag[y-1] == 0)
				flag[y-1] = 1;
			if(nbox[x-1] == 0) 
				flag[x-1] = 0;
		}
	}
	long tbox = 0;
	for(i = 0; i < n; i++) if(flag[i] == 1) tbox++;
	printf("%ld\n", tbox);	
	return 0;
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(auto& i : a) cin >> i;
  ll ans = 1;
  vector<ll> hat(3);
  for(auto& A : a){
    ll cnt = 0;
    for(auto& i : hat) if(i == A) cnt++;
    ans *= cnt;
    ans %= MOD;
    for(auto& i : hat) if(i == A){
      i++;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 16) + 50;
int n;
long long mem[N], a[17][17], s[N];
bool vis[N];

long long score(int bm) {
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (!(bm & (1 << i))) continue;
		for (int j = i + 1; j < n; j++) {
			if (!(bm & (1 << j))) continue;
			ans += a[i][j];
		}
	}
	return ans;
}

long long dp(int bm) {
	if (__builtin_popcount(bm) <= 1) {
		return 0;
	}
	if (vis[bm]) {
		return mem[bm];
	}
	vis[bm] = true;

	long long ans = 0;
	for (int fbm = bm; fbm; fbm = (fbm - 1) & bm) {
		long long tans = s[fbm] + dp(bm & ~fbm);
		ans = max(ans, tans);
	}

	return mem[bm] = ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 1; i < (1 << n); i++) {
		s[i] = score(i);
	}

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

	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 50000005
  #define INF 10000000000000
  #define eps 1e-6


  int32_t main()
  {         

    IOS

    int i = 1;

    int ans;
    int k;
    cin >> k;

    if(k == 1)
    {
      cout << 1;
      return 0;
    }
    while(i < k)
    {
      ans =  i;
      i = i << 1;
    }

    ans = ans << 1;
    if(ans == k)
    {
      ans = ans << 1;
    }

    cout << ans - 1;

    return 0; 
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
vector<int> g[maxn];
int vis[maxn];
int sum1,sum2;
bool dfs(int x,int z){
    if(z==1){
        vis[x]=2;
        sum2++;
    }
    else {
        vis[x]=1;
        sum1++;
    }
    for(int i=0;i<g[x].size();i++){
        int v=g[x][i];
        if(vis[v]==vis[x])
            return false;
        if(vis[v]==0){
            if(!dfs(v,vis[x]))
                return false;
        }
    }
    return true;
}
int n,m;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if(!dfs(1,-1)){
        printf("%lld\n",1ll*n*(n-1)/2-m);
    }
    else printf("%lld\n",1ll*sum1*sum2-m);

}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x; cin >> x;
  bool flag = false;
  REP(i,100001){
    if(i*100<=x && x<=i*105){
      flag = true;
      break;
    }
  }
  cout << (flag ? 1 : 0) << endl;
  return 0;
}


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int n;
  cin >> n;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (a % 2 == 0) if (!(a % 3 == 0 || a % 5 == 0)) ok = false;
  }
  cout << (ok ? "APPROVED" : "DENIED") << endl; 
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3612
n = int(input())

ch  = 0

if(n>81):
    ch  = 0
else:
    for i in range(1,10):
        if(n%i==0):
            k = n//i
            if(k>=1 and k<=9):
                ch = 1
                
if(ch==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N),indegree(N),vis(N); char st[N];
vector<int> adj[N];
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(a>=k)
    {
        cout<<k;
        return;
    }
    sum+=a;
    k=k-a;
    if(b>=k)
    {
        cout<<sum;
        return;
    }
    k=k-b;
    cout<<sum-k;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1; 
    while(test--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19444
#include <bits/stdc++.h>
#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(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
// #define int long long

string S;




signed main(){
    
    int K;
    cin>> S;
    int centor = S.size()/2 ;
    
    // int ans = K;    
    // bool end_flag = false;
    // FOR(k,K+1, S.size() ){
    //     char tmp = S[S.size()-k];
    //     FOR(i,S.size()-k,k){
    //         if(tmp != S[i])end_flag = true;
    //     }
    //     if(end_flag)break;
    //     ans = k;        
    // }
    char tmp = S[centor];
    int count = 0;
    int N = S.size();

    if(N%2 == 0){
        K = N/2;
        rep(i,N/2){
            if(S[centor+i] == S[centor-1-i])count++;
            else break;
        }
    }else{
        K = N/2+1;
        rep(i,N/2){
            if( tmp == S[centor+1+i] && S[centor-1-i] == S[centor+1+i]  )count++;
            else break;
        }
    }

    print(K+count);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#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 RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



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


int main()
{
    int n ;
    cin >> n ;
    vector<int> vec(n) ;
    REP(i,n){
        cin >> vec.at(i) ;
    }
    int m ;
    cin >> m ;
    vector<int> vecv(m) ;
    REP(i,m){
        cin >> vecv.at(i) ;
    }
    
    int cnt = 0 ;
    
    REP(i,m){
        int key = vecv.at(i) ;
        REP(j,n){
            if(key==vec.at(j)){
                cnt++ ;
                break ;
            }
        }
    }
    
    cout << cnt <<endl ;

  return 0 ;
}




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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

vector<vector<int>> graph;
int n,t,m,temp,day;
bool visited[2502];
int adjacent_num(int src){
    int s=0;
    for(auto p=graph[src].begin();p!=graph[src].end();p++){
        if(!visited[*p]){
            visited[*p]=1;s++;
        }
}
    return s;
}
//void _(){
//    cin >> n;
//    graph.resize(n);
//    string s;
//    getline(cin,s);
//    for (int i = 0; i < n; ++i) {
//        cin >> m;
//        for (int j = 0; j < m; ++j) {
//            cin >> temp;
//            graph[i].emplace_back(temp);
//        }
//    }
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
//        memset(visited,0, sizeof(bool)*n);
//        set<int> known;
//        cin >> temp;
//        if(graph[temp].empty()){
//            cout << 0 <<"\n";
//            continue;
//        }
//        visited[temp]=1;
//        int mx=0,day_s;
//        day=1;
//        while (!all_of(visited,visited+n,[](bool a){ return a;})){
//            temp=0;
//
//            for (int j = 0; j < n; ++j) {
//                if(visited[j]){
//
//                    known.insert(j);
//                }
//            }
//            for(auto p=known.begin();p!=known.end();p++){
//                 temp+=adjacent_num(*p);
//            }
//            if(max(mx,temp)>mx){
//                mx=max(mx,temp);
//                day_s=day;
//            }
//
//            day++;
//        }
//        if(mx){
//            cout << mx << " "<< day_s <<"\n";
//        } else{
//            cout << 0 <<"\n";
//        }
//
//
//
//    }
//
//
//
//
//
//
//
//
//
//
//
//
//}

void _(){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d )){
        cout << "Yes";

    } else{
        cout <<"No";
    }

}




int main() {
#ifdef debug
    freopen("/home/joduskame/Desktop/cp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cp/IO/Output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll x;
  cin>>x;
  ll ans=0;
  ans+=x/11*2;
  x%=11;
  if(x==0){
    cout<<ans<<endl;
  }
  else if(x<=6){
    cout<<ans+1<<endl;
  }
  else{
    cout<<ans+2<<endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var N, A int
	fmt.Fscanf(reader, "%d\n%d\n", &N, &A)
	NN := N * N
	fmt.Fprintf(writer, "%d\n", NN-A)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
    int h,w;
    
    while(1){
        cin >> h >> w;
        if(!h && !w) break;
        rep(i,h){
            rep(j,w){
                if((i+j)%2 == 0)
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;
const ll MOD=1e9+7;

struct UnionFind {
    vector<int> par,rank;
    vector<ll> cnt;
    UnionFind(int n):par(n),rank(n,0),cnt(n,1){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]){
            par[rx]=ry;
            cnt[ry]+=cnt[rx];
        }else{
            par[ry]=rx;
            cnt[rx]+=cnt[ry];
        }
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int count(int x){
        return cnt[root(x)];
    }
};
struct edge{
    int a,b,y;
    edge(){};
    edge(int a,int b,int y):a(a),b(b),y(y){};
    bool operator<(const edge& rhs){
        return y<rhs.y;
    }
};

int main(){
    string s;cin>>s;
    int n=(int)s.size();
    for(int i=0;i<n-1;++i){
        if(s[i]==s[i+1]){
            cout<<i+1<<' '<<i+2<<endl;
            return 0;
        }else if(i<n-2&&s[i]==s[i+2]){
            cout<<i+1<<' '<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<' '<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int n;
vector<int> c[100002];
vector<int> G[100002];
int visited[100002]={};
set<pair<int,int>> s;
map<pair<int,int>,int> p;
int Max=0;
void dfs(int now){
    visited[now]=1;
    int i = 1;
    //c[now].push_back(i);
    //cout<<now<<"から出る辺を"
    //s.insert(make_pair(now,i));
    for(int j=0;j<G[now].size();j++){
        int child = G[now][j];
        if(!visited[child]){
            while(s.count(make_pair(now,i))){
                i++;
            }
            c[now].push_back(i);
            c[child].push_back(i);
            s.insert(make_pair(now,i));
            s.insert(make_pair(child,i));
            //ans[now][child] = i;
            p[make_pair(now,child)] = i;
            if(Max<i){
                Max = i;
            }
            dfs(child);
        }
    }

}
//無向グラフの作り方
int main(){
    //int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n-1){
        cin >> a[i]>>b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(1);
    /*
    for(int i=1;i<=n;i++){
        cout << "G[" <<i <<"]={";
        for(unsigned int j=0;j<G[i].size();j++){
            cout<<G[i][j]<<" ";
        }
        cout<<"}"<<endl;
    }
    for(int i=1;i<=n;i++){
        cout << "C[" <<i <<"]={";
        for(unsigned int j=0;j<c[i].size();j++){
            cout<<c[i][j]<<" ";
        }
        cout<<"}"<<endl;
    }
    */
   cout<<Max<<endl;
    rep(i,n-1){
        cout<<p[make_pair(a[i],b[i])]<<endl;
    }
}

Measured memory_bytes: 28416
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a <= b && b <= c){
        printf("%d %d %d\n", a, b, c);
    } else if(a <= c && c <= b){
        printf("%d %d %d\n", a, c, b);
    } else if(b <= a && a <= c){
        printf("%d %d %d\n", b, a, c);
    } else if(b <= c && c <= a){
        printf("%d %d %d\n", b, c, a);
    } else if(c <= a && a <= b){
        printf("%d %d %d\n", c, a, b);
    } else if(c <= b && b <= a){
        printf("%d %d %d\n", c, b, a);
    } 
    
    return 0;
}


Measured memory_bytes: 3180
s=str(input())
cnt=0
ans=0
for i in range(len(s)):
  if cnt<=((i+1)//2 if i%2==0 else (i+1)//2-1):
    cnt+=1
    if s[i]=='p':
      ans-=1
  else:
    if s[i]=='g':
      if i+1<=len(s)-1 and s[i+1]=='p' and cnt<=((i+2)//2 if (i+1)%2==0 else (i+2)//2-1):
        cnt+=1
      else:
        ans+=1
    else:
      pass
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
char s[51];
scanf("%s",s);
int i,count=0;
for(i=2;i<n;i++){
if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C')
count++;}
printf("%d",count);
}

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

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

    int n;
    cin >> n;
    vector<int> A(n);
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
        if(A[i] < 0) ++cnt;
        ans += abs(A[i]);
    }
    sort(A.begin(), A.end());
    if(cnt == n) {
        ans = ans + 2*A[n-1];
    }else if(cnt == 0) {
        ans = ans - 2*A[0];
    }
    cout << ans << endl;
    int l = 0, r = n-1;
    if(n-cnt <= 1) {
        int pre = A[n-1];
        for(int i = n-2; i >= 0; --i) {
            cout << pre << " " << A[i] << endl;
            pre -= A[i];
        }
    }else {
        if(n == 2) {
            cout << A[1] << " " << A[0] << endl;
            return 0;
        }
        cout << A[l] << " " << A[r] << endl;
        int pre = A[l] - A[r];
        --r;
        ++l;
        while(r > max(cnt, 1)) {
            cout << pre << " " << A[r] << endl;
            pre -= A[r];
            --r;
        }
        cout << A[max(cnt, 1)] << " " << pre << endl;
        pre = A[max(cnt, 1)] - pre;
        --r;
        while(l < cnt) {
            cout << pre << " " << A[l] << endl;
            pre -= A[l];
            ++l;
        }
    }
}


Measured memory_bytes: 2304
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (H % 2 == 0 || W % 2 == 0) {
		cout << H * W / 2 << endl;
	}
	else {
		cout << H * W / 2 + 1 << endl;
	}

	return 0;
}



Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$A = array_map('intval', explode(' ',  trim(fgets(STDIN))));
$c = array_count_values($A);
$d = [];
foreach ($c as $k => $v) {
    $c[$k] = $v * ($v - 1) / 2;
    $d[$k] = ($v - 2) * ($v - 1) / 2;
}
$sum = array_sum($c);
$ans = [];
for ($i = 0; $i < $N; $i++) {
    $ans[] = $sum - ($c[$A[$i]] - $d[$A[$i]]);
}
echo implode(PHP_EOL, $ans);

Measured memory_bytes: 41216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    char x, y;
    cin >> x >> y;

    if ((int) x < int(y)) {
        cout << "<" << endl;
    } else if ((int) x > int(y)) {
        cout << ">" << endl;
    } else {
        cout << "=" << endl;
    }
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	ll a, b; cin >> a >> b;
	cout << a * b / __gcd(a, b) << '\n';
	

	return 0;
}

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

int main()
{
	int n;
	while(cin>>n,n){
		vector<int> key(n);
		for(int i=0;i<n;i++) cin>>key[i];
		string s;
		cin>>s;

		for(int i=0;i<s.size();i++){
			for(int j=0;j<key[i%key.size()];j++){
				if(s[i]=='a') s[i]='Z';
				else if(s[i]=='A') s[i]='z';
				else s[i]--;
			}
		}

		cout<<s<<endl;

	}

	return 0;
}

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

int main(void) {
	int a, b, c;
	while(cin >> a >> b) {
		if(a == 0 && b == 0) {
			break;
		}
			
		else if(a > b){
			cout << b << " "<< a << endl;
		}
		else if(a == b){
			cout << a << " "<< b << endl;
		}
		else if(a < b){
			cout << a << " " << b << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3008
#include <iostream>
using namespace std;
typedef long long ll;
#define int ll

int g[105][105], d[105], f[105];
int presenttime = 1, n;
bool is_search[105];

void dfs(int p) {
  d[p] = presenttime++;
  is_search[p] = true; // ??????????????§?????§??????

  for (int i = 0; i < n; i++) {
    if(is_search[i] == false && g[p][i] && p != i) dfs(i);
  }
  if (f[p] == 0) f[p] = presenttime++;
}

signed main(void) {
  int u, k, v;

  fill(is_search, is_search + n, false);

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int i = 0; i < k; i++) {
      cin >> v;
      g[u-1][v-1] = 1;
    }
   }

  int s = 0, i;

   while(1) {
    dfs(s);

    for (i = 0; i < n; i++) {
      if (is_search[i] == false) {
        s = i;
        break;
      }
    }
    if(i == n) break;
   }

   for (i = 0; i < n; i++) {
     cout << i+1 << " " << d[i] << " " << f[i] << endl;
   }
   return 0;
}

Measured memory_bytes: 1240
/*
 * 17-1-7_ABC051_D.cpp
 *
 *  Created on: 2017/01/07
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>
#include<limits.h>
#include<vector>
#include<queue>
#include<set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
			src(src), dst(dst), weight(weight) {
	}
};
bool operator <(const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
			e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

const Weight INF = INT_MAX/2;

set<pair<int, int> > S;

void shortestPath(const Matrix &g, Matrix &dist, vector<vector<int> > &inter) {
	int n = g.size();
	dist = g;
	inter.assign(n, vector<int>(n, -1));
	REP(k, n)
		REP(i, n)
			REP(j, n)
			{
				if (dist[i][j] > dist[i][k] + dist[k][j]) {
					dist[i][j] = dist[i][k] + dist[k][j];
					inter[i][j] = k;
				}
			}
}
void buildPath(const vector<vector<int> > &inter, int s, int t,
		vector<int> &path) {
	int u = inter[s][t];
	if (u < 0) {
		path.push_back(s);
		S.insert(make_pair(s, t));
		S.insert(make_pair(t, s));
	} else
		buildPath(inter, s, u, path), buildPath(inter, u, s, path);
}
vector<int> buildPath(const vector<vector<int> > &inter, int s, int t) {
	vector<int> path;
	buildPath(inter, s, t, path);
	path.push_back(t);
	return path;
}

int N, M;
int main() {
	cin >> N >> M;
	Matrix G(N, Array(N, INF));
	for (int i = 0; i < M; i++) {
		int a, b;
		Weight c;
		cin >> a >> b >> c;
		a--;
		b--;
		G[a][b] = c;
		G[b][a] = c;
	}
	/*for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(G[i][j]==INF)
				cout << "INF ";
			else
			cout << G[i][j] << " ";
		}
		cout << endl;
	}
	*/
	Matrix d;
	vector<vector<int> > in;
	shortestPath(G, d, in);
	/*for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(d[i][j]==INF)
					cout << "INF ";
				else
				cout << d[i][j] << " ";
			}
			cout << endl;
		}
		*/
	for (int s = 0; s < N; s++) {
		for (int t = s + 1; t < N; t++) {
			vector<int> path;
			buildPath(in, s, t,path);
		}
	}
	cout << M - (int) S.size() / 2 << endl;
	return 0;
}



Measured memory_bytes: 384
def main():
  n, y = map(int, input().split())
  for i in range(n + 1):
    for j in range(n + 1 - i):
      z = n - i - j
      if i * 10000 + j * 5000 + z * 1000 == y:
        print(i, j, z)
        exit()
  print('-1 -1 -1')
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 64432
n,m,c = gets.chomp.split(' ').map(&:to_i)
b_arr = gets.chomp.split(' ').map(&:to_i)
ans = 0
k = 1
while k <= n
  a_arr = gets.chomp.split(' ').map(&:to_i)
  i = 0
  sum = 0
  while i < m
    sum += a_arr[i] * b_arr[i]
    i += 1
  end
  sum += c
  if sum > 0
    ans += 1
  end
  k += 1
end
puts ans

Measured memory_bytes: 14276
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    return


def main():
    N = int(input())
    points = []
    for i in range(N):
        x, y = map(int, input().split())
        points.append((x, y))

    num = 0
    ans = 0
    l = list(range(N))
    for p in permutations(l):
        num += 1

        for i in range(1, len(p)):
            ans += sqrt((points[p[i - 1]][0] - points[p[i]][0]) ** 2 + (points[p[i - 1]][1] - points[p[i]][1]) ** 2)

    print(ans / num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4456
import java.util.*;


import java.io.*;



public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		int b[]=new int [n];
		int c[]=new int[n];
		
		for(int i=0;i<n;i++) {
			a[i]=s.nextInt();
			b[i]=s.nextInt();
			c[i]=s.nextInt();
		}
		
		long dp[][]=new long[n][3];
		dp[0][0]=a[0];
		dp[0][1]=b[0];
		dp[0][2]=c[0];
		
		for(int i=1;i<n;i++) {
			dp[i][0]=a[i]+Math.max(dp[i-1][1], dp[i-1][2]);
			dp[i][1]=b[i]+Math.max(dp[i-1][0], dp[i-1][2]);
			dp[i][2]=c[i]+Math.max(dp[i-1][0], dp[i-1][1]);
		}
		
		long ans=Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2]));
		System.out.println(ans);

	}
	
}


Measured memory_bytes: 94788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int A, B;
    cin >> A >> B;
    cout << A * B / __gcd(A, B) << endl;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

const ll MAX_N = 1e5;
vector<Pii> G[MAX_N];
bool color[MAX_N], check[MAX_N] = {};

void dfs(ll x, bool b){
  //xを色bで塗る
  color[x] = b; check[x] = true;
  for(auto &e : G[x]){
    ll y = e.first, w = e.second;
    if(check[y]) continue;
    (w % 2 == 0) ? dfs(y, b) : dfs(y, !b);
  }
}

int main(){
  ll n; cin >> n;
  REP(i, n - 1){
    ll u, v, w; cin >> u >> v >> w; u--; v--;
    G[u].pb(mp(v, w)); G[v].pb(mp(u, w));
  }
  dfs(0, 0);
  REP(i, n) cout << color[i] << endl;

}


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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long ncrmodp(int n,int r,long p){
  long ans = 1;
  long tmp = 1;
  int i;
  for(i=n;i>n-r;i--){
    ans*=i;
    ans%=p;
  }
  for(i=2;i<=r;i++){
    tmp*=i;
    tmp%=p;
  }
  for(long bit = 1;bit<=p-2;bit*=2){
    if(bit & p-2){
      ans *= tmp;
      ans %= p;
    }
    tmp = tmp* tmp;
    tmp %= p;
  }
  return ans;
}


int main(){
  long n,a,b;
  cin >> n >> a >> b;
  long const mod = 1000000007;
  long ans = 1;
  long tmp = 2;
  int i;
  for(long bit = 1;bit<=n;bit*=2){
    if(bit & n){
      ans *= tmp;
      ans %= mod;
    }
    tmp=tmp*tmp;
    tmp%=mod;
  }
  ans -= ncrmodp(n,a,mod);
  ans -= ncrmodp(n,b,mod);
  ans-=1;
  while(ans<0)ans+=100*mod;
  ans%=mod;
  cout << ans << endl;


}


Measured memory_bytes: 256
from collections import *
import sys
inp = raw_input

def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = [ni() for _ in range(N)]

A2 = list(A)
A2.sort()
for ai in A:
    if ai == A2[-1]:
        print(A2[-2])
    else:
        print(A2[-1])



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

int main() {
  string S;
  cin >> S;
  int s = S.size();
  string T;
  cin >> T;
  T = T.erase(s);
  
  if (T == S){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3608