akhauriyash/Code-Regression huggingface dataset:
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    vector <int> v(3);
    for (auto &it : v) {
        cin >> it;
    }
    sort(all(v));
    if ((v[0] == v[1] && v[1] != v[2]) || (v[1] != v[0] && v[1] == v[2])) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int K;
vector<pair<int,int> >f(int X,int Y)
{
	if(X+Y==K)
	{
		return{make_pair(X,Y)};
	}
	if(K%2==0)
	{
		for(long l=2;;l++)
		{
			if(X+Y<=l*K)
			{
				long T=(l*K-X-Y)/2;
				vector<pair<int,int> >ret;
				ret.push_back(make_pair(K-T,-T));
				long x=K-T,y=-T;
				for(int i=1;i<l;i++)
				{
					if(x+K<=X)
					{
						ret.push_back(make_pair(x+=K,y));
					}
					else
					{
						int p=X-x;
						ret.push_back(make_pair(x=X,y+=K-p));
					}
				}
				return ret;
			}
		}
	}
	else
	{
		for(long l=(X+Y)%2==1?3:2;;l+=2)
		{
			if(X+Y<=l*K)
			{
				long T=(l*K-X-Y)/2;
				long V=0;
				if(T>=K)V=T-K,T=K;
				vector<pair<int,int> >ret;
				ret.push_back(make_pair(K-T,-T));
				long x=K-T,y=-T;
				for(int i=1;i<l-1;i++)
				{
					if(x+K<=X+V)
					{
						ret.push_back(make_pair(x+=K,y));
					}
					else
					{
						int p=X+V-x;
						ret.push_back(make_pair(x=X+V,y+=K-p));
					}
				}
				ret.push_back(make_pair(X,Y));
				return ret;
			}
		}
	}
}
main()
{
	int x,y;cin>>K>>x>>y;
	int X=abs(x),Y=abs(y);
	if(K%2==0&&(X+Y)%2==1)
	{
		cout<<-1<<endl;
		return 0;
	}
	bool flag=false;
	if(X<Y)
	{
		swap(X,Y);
		flag=true;
	}
	vector<pair<int,int> >ret=f(X,Y);
	cout<<ret.size()<<endl;
	for(pair<int,int>p:ret)
	{
		if(flag)swap(p.first,p.second);
		cout<<p.first*(x<0?-1:1)<<" "<<p.second*(y<0?-1:1)<<endl;
	}
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    string op;
    cin >> A >> op >> B;
    
    for (int i = 0; i < 1; i++) {
        if (op.at(i) == '+') {
            cout << A+B << endl;
        }
        else if (op.at(i) == '-') {
            cout << A-B << endl;
        }
    }
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        string s;
        cin>>s;
        if(s=="ABC")
            cout<<"ARC";
        else
            cout<<"ABC";
        return 0;
    }


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

int main() {
    long long int n, c, k, ans = 1;
    cin >> n >> c >> k;
    int t[n];
    for(int i = 0; i < n; ++i) cin >> t[i];
    sort(t, t+n);

    int limit = t[n-1] - k, num = 1;
    for(int i = n-2; i >= 0; --i) {
        if(t[i] >= limit && num < c) {
            num++;
        } else {
            limit = t[i] - k;
            num = 1;
            ans++;
        }
    }
    
    cout << ans << '\n';

    return 0;
}


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

namespace Contest20191031
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] sInput = Console.ReadLine().Split(' ');
            double n = double.Parse(sInput[0]);
            double k = double.Parse(sInput[1]);
            double sum = 0;




            for (double i = 1; i <= n; i++) 
            {
                double count = 0;
                double m = i;                
                while (m < k)
                {
                    m =  m * 2;
                    count++;
                }

                double l = 1;
                for (int o = 0; o < count; o++)
                    l *= 2;


                sum += (1 / n) * (1 / l);
            }

            Console.WriteLine(sum);

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    string s;
    vi ans(4, 0);
    rep(i, n) {
        cin >> s;
        if(s == "AC") ans[0]++;
        if(s == "WA") ans[1]++;
        if(s == "TLE") ans[2]++;
        if(s == "RE") ans[3]++;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define IL inline
#define _ 400005
#define ll long long
using namespace std ;

IL ll gi(){
    ll data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

ll L , A[_] , even[_] , odd[_] , even2[_] , Ans , pre[_] , suf[_] , n , bp[_] , bs[_] ; 

int main() {
	L = gi() ;
	memset(even , 0 , sizeof(even)) ;
	memset(odd , 0 , sizeof(odd)) ;
	for(int i = 1; i <= L; i ++) A[i] = gi() , Ans += A[i] ;
	for(int i = 1; i <= L; i ++) pre[i] = pre[i - 1] + A[i] ;
	for(int i = L; i >= 1; i --) suf[i] = suf[i + 1] + A[i] ;
	for(int i = 1; i <= L; i ++) {
		ll op = 0 ;
		if(A[i] > 0) op = A[i] % 2 ; else op = 2 ; 
		even[i] = min(pre[i] , even[i - 1] + op) ;
		even2[i] = even[i] ;
	}
	for(int i = L; i >= 1; i --) {
		ll op = 0 ;
		if(A[i] > 0) op = ((A[i] % 2) ^ 1) ; else op = 1 ;
		odd[i] = min(suf[i] , odd[i + 1] + op) ;
	}
	for(int i = 1; i <= L + 1; i ++) Ans = min(Ans , even[i - 1] + odd[i]) ;
	memset(even , 0 , sizeof(even)) ;
	memset(odd , 0 , sizeof(odd)) ;
	for(int i = 1; i <= L; i ++) {
		ll op = 0 ;
		if(A[i] > 0) op = ((A[i] % 2) ^ 1) ; else op = 1 ;
		odd[i] = min(pre[i] , odd[i - 1] + op) ;
	}
	for(int i = L; i >= 1; i --) {
		ll op = 0 ;
		if(A[i] > 0) op = A[i] % 2 ; else op = 2 ;
		even[i] = min(suf[i] , even[i + 1] + op) ;
	}
	for(int i = 1; i <= L + 1; i ++) Ans = min(Ans , odd[i - 1] + even[i]) ;
	for(int i = 1; i <= L ; i ++) A[i] = ((A[i] % 2) ^ 1) ;
	for(int i = 1; i <= L ; i ++) A[i] = A[i] + A[i - 1] ; 
	for(ll i = 1,bst = 1e18 ; i <= L; i ++) {
		bp[i] = A[i] + bst;
		bp[i] = min(bp[i] , A[i] - A[i - 1] + even2[i - 1]) ;
		bst = min(bst , - A[i - 1] + even2[i - 1]) ;
	}
	//for(int i = 1; i <= L; i ++) cout << bp[i] << " " ; cout << endl ;
	for(int i = L; i >= 1; i --) A[i] = A[i] - A[i - 1] ;
	for(int i = L; i >= 1; i --) A[i] = A[i] + A[i + 1] ;
	for(ll i = L,bst = 1e18 ; i >= 1; i --) {
		bs[i] = A[i] + bst ;
		bs[i] = min(bs[i] , A[i] - A[i + 1] + even[i + 1]) ;
		bst = min(bst , - A[i + 1] + even[i + 1]) ;
	}
	//for(int i = 1; i <= L; i ++) cout << bs[i] << " " ; cout << endl ;
	for(int i = 1; i <= L; i ++) A[i] = A[i] - A[i + 1] ;
	for(int i = 1; i <= L; i ++) Ans = min(Ans , bp[i] + bs[i] - A[i]) ; 
	cout << Ans << endl ; return 0 ; 
}


Measured memory_bytes: 24320
#include <iostream>
#include <math.h>
#include <queue>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll m[20][20];

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

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

int main(){
    ll h, w;
    cin >> h >> w;
    string o = h == w ? "Yes" : "No";
    cout << o << endl;
    return 0;
}

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

int main(){
  long long n,d;	cin >> n >> d;
  int c=0;
  rep(i,n){
    long long x,y;	cin >> x >> y;
    if(x*x+y*y<=d*d)	c++;
  }
  cout << c;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= b){
    cout << "No" << endl;
    return 0;
  }
  else if(b >= c){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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 all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
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};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n,W;cin>>n>>W;
  vector<vector<ll>>dp(n+1,vector<ll>(W+1,0));

  rep(i,n){
    ll w,v;cin>>w>>v;
    rep(j,W+1){
      if(j+w<=W)chmax(dp[i+1][j+w],dp[i][j]+v);
      chmax(dp[i+1][j],dp[i][j]);
      if(j+1<=W)chmax(dp[i][j+1],dp[i][j]);
    } 
  }

  cout<<dp[n][W]<<endl;


  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 80256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

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

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#define debug(...) printf(__VA_ARGS__)
#else
#define SIZE 123450
#define debug(...) /* */
#endif

string S;
// i桁目まで見て、余りがjの数
int DP[2][2020];

void print(int i) {
    auto dp = DP[i%2];
    debug("%lld---\n", i);
    REP(j,2020) {
        if (dp[j]) {
            debug("  %lld: %lld\n", j, dp[j]);
        }
    }
}

void solve() {
    cin>>S;
    int ans = 0;
    REP(i,S.size()+1) {
        int n = S[i]-'0';
        auto from = DP[i%2];
        auto to = DP[(i+1)%2];
        ans += from[0];
        REP(j,2020) to[j]=0;
        to[n] += 1;
        REP(j,2020) {
            int k = (j*10 + n) % 2019;
            to[k] += from[j];
        }
        print(i);
    }    
    cout << ans << endl;
}

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

using namespace std;

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

	multiset< int> st;

	int result = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		auto it = st.lower_bound(x);
		if (it == st.begin()) {
			result ++;
		} else {
			it --;
			st.erase(it);
		}
		st.insert(x);
	}

	cout << result << endl;
}

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

int n,t;
int a[105];

int main()
{
    scanf("%d",&n);
    int sum = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    int t = sum/2;
    int temp = 0;
    int j = 0;
    while(temp < t)
    {
        j++;
        temp += a[j];
    }
    int x = abs(sum-2*temp);
    int y = abs(sum-2*(temp-a[j]));
    int ans = x>y?y:x;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define dd double
#define ull unsigned long long
#define mes(x,y) memset(x,y,sizeof(x))
#define si(i) scanf("%d",&i)
#define ss(i) scanf("%s",(i))
#define sd(i) scanf("%lf",&i)
#define INF 0x3f3f3f3f
#define eps 1e-16
#define PI acos(-1)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int maxn=2e9+9;
const int mod=1e9+7;
ll GCD(ll a,ll b) {//最大公约数
    return b == 0 ? a : GCD(b, a % b);
}
int main() {
    FAST_IO;
    ll a;string s;
    while(cin>>a>>s){
        if(a>=3200)cout<<s<<endl;
        else cout<<"red"<<endl;
    }
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

class UnionFind {
 public:
  vector<int> parent;
  vector<LL> cnt;
  vector<set<int>> xs, ys;
  UnionFind(int n, vector<int> x, vector<int> y) {
    parent = vector<int>(n);
    cnt = vector<LL>(n, 1);
    for (int i = 0; i < n; i++) parent[i] = i;
    xs.resize(n);
    ys.resize(n);
    for (int i = 0; i < n; i++) {
      xs[i].insert(x[i]);
      ys[i].insert(y[i]);
    }
  }
  int find(int v) {
    if (v == parent[v]) return v;
    return parent[v] = find(parent[v]);
  }

  int uni(int u, int v) {
    u = find(u);
    v = find(v);
    if (u == v) return false;
    if (cnt[v] < cnt[u]) swap(v, u);
    for (auto val : xs[u]) xs[v].insert(val);
    for (auto val : ys[u]) ys[v].insert(val);

    parent[u] = v;
    cnt[v] += cnt[u];
    return true;
  }
};

int main() {
  int N;
  cin >> N;
  vector<int> xs, ys;
  vector<vector<int>> revx(100100), revy(100100);
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    xs.push_back(x);
    ys.push_back(y);
    revx[x].push_back(i);
    revy[y].push_back(i);
  }

  UnionFind uf(N, xs, ys);

  for (auto vec : revx) {
    for (int i = 1; i < vec.size(); i++) uf.uni(vec[0], vec[i]);
  }
  for (auto vec : revy) {
    for (int i = 1; i < vec.size(); i++) uf.uni(vec[0], vec[i]);
  }
  LL ans = 0;
  for (int i = 0; i < N; i++) {
    if (uf.parent[i] != i) continue;
    ans += (LL)uf.xs[i].size() * (LL)uf.ys[i].size();
  }
  cout << ans - N << endl;

  return 0;
}


Measured memory_bytes: 57184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a[] = new long[6];
		long mina = -5;
		for (int i = 1; i <= 5; i++) {
			a[i] = sc.nextLong();

		}
		mina = a[1];
		for (int i = 1; i <= 5; i++) {

			if (mina > a[i]) {
				mina = a[i];
			}
		}


		if(n%mina!=0){
			n=n+(mina-n%mina);
		}
System.out.println(n/mina+4);

	}
}

Measured memory_bytes: 23252
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(n: number) {
  let a = [];
  for (let i = 0; i < n; i++) a.push(i);
  return a;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const N = int();
  
  console.log(rep(N).map(i=>{
    const k=i+1
    if(k%3!=0 &&k%5!=0)return k;
    return 0;
  }).reduce((a,b)=>a+b,0));
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 72364
import sys
input = sys.stdin.readline

n,k = map(int,input().split())

res = [1]*(n+1)
res[0] = 0

for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for e in a:
        res[e] = 0

print(sum(res))



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(3e3 + 5);
const int MAX_M = (int)(5e3 + 5);

int n, m;
ll p;

vector<tuple<int, int, ll>> edges;

vector<int> graph[MAX_N];
vector<int> graph_rev[MAX_N];

bool rfb[MAX_N];  // reachable from begin
bool rte[MAX_N];  // reachable to end

ll d[MAX_N];

void dfs_from(int node) {
  if (rfb[node]) return;

  rfb[node] = true;

  for (auto &e : graph[node]) {
    dfs_from(e);
  }
}

void dfs_to(int node) {
  if (rte[node]) return;

  rte[node] = true;

  for (auto &e : graph_rev[node]) {
    dfs_to(e);
  }
}

void check_reachability() {
  for (int i = 0; i < n; ++i) {
    rfb[i] = false;
    rte[i] = false;
  }

  dfs_from(0);
  dfs_to(n - 1);
}

bool ok(int node) { return (rfb[node] && rte[node]); }

bool check_negative_loop() {
  ll td[MAX_N];

  fill(td, td + n + 3, 0);

  for (int i = 0; i < n; ++i) {
    for (auto &e : edges) {
      if (!ok(get<0>(e)) || !ok(get<1>(e))) continue;

      if (td[get<1>(e)] > td[get<0>(e)] + get<2>(e)) {
        td[get<1>(e)] = td[get<0>(e)] + get<2>(e);

        if (i == n - 1) return true;
      }
    }
  }

  return false;
}

void bellman_ford() {
  for (int i = 0; i < n; ++i) d[i] = INF;

  d[0] = 0;

  while (true) {
    bool update = false;

    for (auto &e : edges) {
      if (!ok(get<0>(e)) || !ok(get<1>(e))) continue;

      if (d[get<1>(e)] > d[get<0>(e)] + get<2>(e)) {
        d[get<1>(e)] = d[get<0>(e)] + get<2>(e);

        update = true;
      }
    }

    if (!update) break;
  }
}

int main(void) {
  // Here your code !
  scanf("%d %d %lld", &n, &m, &p);

  for (int i = 0; i < m; ++i) {
    int a, b;
    ll c;
    scanf("%d %d %lld", &a, &b, &c);

    // 1-index to 0-index
    a -= 1;
    b -= 1;

    // maximize plus => minimize minus
    edges.emplace_back(a, b, -1LL * (c - p));

    graph[a].push_back(b);
    graph_rev[b].push_back(a);
  }

  check_reachability();

  if (check_negative_loop()) {
    printf("%d\n", -1);
    return 0;
  }

  bellman_ford();

  ll ans = -1LL * min(d[n - 1], 0LL);

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

  return 0;
}


Measured memory_bytes: 768
from collections import defaultdict, deque
N, M, *L = map(int, open(0).read().split())
dic = defaultdict(list)
par =  [0]*(N+1)
cnt = [0]*(N+1)
for a,b in zip(*[iter(L)]*2):
  dic[a] += [b]
  cnt[b] += 1

for i in range(1,N+1):
  if cnt[i]==0:
    q = deque([i])
    break
  
while q:
  m = q.popleft()
  for c in dic[m]:
    cnt[c] -= 1
    if cnt[c]==0:
      par[c] = m
      q += [c]

for i in range(1,N+1):
  print(par[i])

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

int main() {
  int N;
  string A = "Three";
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      A = "Four";
      break;
    }
  }
  cout << A << endl;
  
  
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define M (ull)((1e9)+7)
using namespace std;
typedef unsigned long long ull;
string s1,s2;
int len,len2,ans;
set<ull> s;
 
ull com(vector<int> &v){
  ull h=0;
  for(int i=0;i<26;i++)
    h=h*M+v[i];
  return h;
}

int main(){
  cin>>s1>>s2;
  len=s1.size();
  len2=s2.size();
  for(int i=1;i<=len;i++){
    vector<int> v(26,0);
    for(int j=0;j<len;j++){
      if(i==j)s.insert(com(v));
      v[s1[j]-'a']++;
      if(j>=i){  
	v[s1[j-i]-'a']--;
	s.insert(com(v));
      }
    }
    if(i==len)s.insert(com(v));
    vector<int> v2(26,0);    
    for(int j=0;j<len2;j++){
      if(i==j&&s.count(com(v2)))
	ans=max(ans,i);
      v2[s2[j]-'a']++;
      if(j>=i){  
	v2[s2[j-i]-'a']--;
	if(s.count(com(v2)))
	  ans=max(ans,i);
      }
    }
    if(i==len2&&s.count(com(v2)))
      ans=max(ans,i);
    s.clear();
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3380
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<set>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
template<typename T>
T rabs(T a)
{
	return a>0?a:-a;
}
int n;
long long a[200005];
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{
		read(a[i]);
		a[i]-=i;
	}
	sort(a+1,a+1+n);
	long long gg=a[(n+1)/2];
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=rabs(a[i]-gg);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
 
int main(){
    int n; cin>>n;
    rep(_,n){
        ll x[2][2], y[2][2];
        rep(i,2){
            rep(j,2){
                double x_,y_;
                cin >> x_ >> y_;
                x[i][j] = x_*100000 + (x_ > 0 ? 1e-6 : -1e-6);
                y[i][j] = y_*100000 + (y_ > 0 ? 1e-6 : -1e-6);
            }
        }
        ll dx1=x[0][0]-x[0][1], dy1=y[0][0]-y[0][1];
        ll dx2=x[1][0]-x[1][1], dy2=y[1][0]-y[1][1];
        dump(dx1,dx2,dy1,dy2);
        puts(dx1*dy2==dx2*dy1 ? "YES" : "NO");
    }
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		if (A[i] - B[i] > 0) {
			res += A[i] - B[i];
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <climits>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <random>
//#include <string>
//#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 200005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

int n, ans;
char str[MAXN];
int pre[MAXN];

int main() {
    n = getint();
    ans = n;
    scanf("%s", str + 1);
    for (int i = 1; i <= n; ++i)
        pre[i] += pre[i - 1] + int(str[i] == '.');
    for (int i = 0; i <= n; ++i) {
        ans = min(ans, i - pre[i] + pre[n] - pre[i]);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  //int A, B, C, X, Y;
  char s[101]={};
  char s_temp[101]={};
  char t[101]={};
  int len=0;
  int a, b, c;
  int n[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=101;
  int max=0;
  int ans=0;

  long cnt =0;
  long long A_temp;
//    int k=0;

  scanf("%d", &a);
// printf("%d\n", a);

  for(i=0;i<a;i++){
    scanf("%d", &n[i]);
    ans=ans+n[i]-1;
//    printf("%d\n",ans);  
  }
  
  printf("%d\n",ans);  
  
return 0;
}


Measured memory_bytes: 256
import queue
n, q = map(int, input().split())
processes = queue.Queue()
logs = []
time_count = 0

for i in range(n):
  name, time = input().split()
  time = int(time)
  processes.put([name, time])

while processes.empty() == False:
  process = processes.get()
  if process[1] > q:
    time_count += q
    process[1] -= q
    processes.put(process)
  else:
    time_count += process[1]
    logs.append([process[0], time_count])

for i in range(n):
  print(" ".join(map(str, logs[i])))



Measured memory_bytes: 16184
def main():
    import sys 
    input=sys.stdin.readline 
    n=int(input())
    A=list(map(int,input().split()))
    
    dp1={}
    dp2={}
    for i in range(n):
        try:dp1[i+1+A[i]]+=1
        except:
            dp1[i+1+A[i]]=1
        if i+1>A[i]:
            try:dp2[i+1-A[i]]+=1
            except:
                dp2[i+1-A[i]]=1
        
    cnt=0
    
    #print(dp1)
    #print(dp2)
    for i in dp1:
        try:
            cnt+=dp1[i]*dp2[i]
        except:
            cnt+=0
    print(cnt)

if __name__=='__main__':
    main()

Measured memory_bytes: 41172
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;

   cin>>s;

   if(s[s.length()-1]!='s'){
   	  cout<<s+'s'<<endl;
   }else{
   	  cout<<s+"es"<<endl;
   }

    return 0;
  }

Measured memory_bytes: 3540
#include<stdio.h>
#define MAX 100

int main(void)
{
  int i, j, N, NN;
  int a, b, aa, bb, temp, ranknum, check;
  int max;
  int team[MAX];
  int rank[MAX];

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

  NN = N*(N-1)/2;

  for(i=1;i<=NN;i++)
    {
      scanf("%d %d %d %d",&a,&b,&aa,&bb);
      if(aa>bb)
	team[a]+=3;
      if(bb>aa)
	team[b]+=3;
      if(aa==bb)
	{
	  team[a]+=1;
	  team[b]+=1;
	}
    }

  max = 0;
  for(i=1;i<=N;i++)
    {
      if(max<team[i])
	{
	  max = team[i];
	  temp = i;
	}
    }
  rank[temp] = 1;
  
  temp = max;
  ranknum = 1;
  for(;temp>=0;temp--)
    {
      for(j=N;j>0;j--)
	{
	  if(team[j]==temp)
	    {
	      rank[j] = ranknum;
	      check++;
	    }
	}
      ranknum = ranknum + check;
      check = 0;
    }
  
  for(i=1;i<=N;i++)
    {
      printf("%d\n",rank[i]);
    }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#define ll long long
using namespace std;

int main()
{
  int N;
  cin>>N;
  int v[N];
  for(int i=0; i<N; i++) cin>>v[i];

  ll tot = 0;

  for(int i=0; i<N; i++)
  {
    tot += (v[i]/2);
    if(v[i]%2 == 1 && (i < N-1 && v[i+1] > 0))
    {
      v[i+1]--;
      tot++;
    }
  }

  cout<<tot;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int dp[2][100002];
int n;
int a[101];
int k;
int solve(int player,int stone)
{
    if(stone<0)
    return 0;
    if(stone==0)
    return 1;
    if(dp[player][stone]!=-1)
    return dp[player][stone];
    else
    {
        int ans=0;
        for(int i=0;i<n;i++)
        ans=ans|solve(player^1,stone-a[i]);
        return dp[player][stone]=!(ans);
    }
}
int main()
{
    int i,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<2;i++)for(j=0;j<=100000;j++)dp[i][j]=-1;
    cout<<(!solve(0,k)?"First":"Second")<<"\n";
}

Measured memory_bytes: 7296
s = input()
def kai(l):
  n = len(l)
  output = 'Yes'
  for i in range(n//2):
    if l[i] != l[n-i-1]:
      output = 'No'
  return output

ans = kai(s)
if ans == 'Yes':
  ans = kai(s[:len(s)//2])
if ans == 'Yes':
  ans = kai(s[len(s)//2+1:])
print(ans)

Measured memory_bytes: 3064
object Main extends App {
	val c = Array.ofDim[Int](3,3)

	for(i<-0 until 3){
		c(i) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	}


	val d1 = c(0)(0) - c(0)(1)
	val d2 = c(1)(0) - c(1)(1)
	val d3 = c(2)(0) - c(2)(1)

	val d4 = c(0)(0) - c(0)(2)
	val d5 = c(1)(0) - c(1)(2)
	val d6 = c(2)(0) - c(2)(2)

	val d7 = c(0)(1) - c(0)(2)
	val d8 = c(1)(1) - c(1)(2)
	val d9 = c(2)(1) - c(2)(2)

	val e1 = c(0)(0) - c(1)(0)
	val e2 = c(0)(1) - c(1)(1)
	val e3 = c(0)(2) - c(1)(2)

	val e4 = c(1)(0) - c(2)(0)
	val e5 = c(1)(1) - c(2)(1)
	val e6 = c(1)(2) - c(2)(2)

	val e7 = c(0)(0) - c(2)(0)
	val e8 = c(0)(1) - c(2)(1)
	val e9 = c(0)(2) - c(2)(2)

	if(d1 == d2 && d1 == d3 && d4 == d5 && d4 == d6 && d7 == d9 && d7 == d8){
		if(e1 == e2 && e1 == e3 && e4 == e5 && e4 == e6 && e7 == e9 && e7 == e8){
			println("Yes")
		}else{
			println("No")
		}
	}else{
		println("No")
	}

}

Measured memory_bytes: 27332
cards = [[m+" "+ str(n) for n in range(1,14)] for m in ["S","H","C","D"]]

num = int(input())
for i in range(num):
    x = input()
    x = x.split(" ")
    m = str(x[0])
    n = int(x[1])
    
    if m == "S": cards[0][n-1] = 0
    elif m == "H": cards[1][n-1] = 0
    elif m == "C": cards[2][n-1] = 0
    elif m == "D": cards[3][n-1] = 0
        
for i in range(len(cards)):
    for j in range(len(cards[i])):
        if cards[i][j] != 0:
            print(cards[i][j])
        


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    if(s == "Sunny") puts("Cloudy");
    else if(s == "Cloudy") puts("Rainy");
    else puts("Sunny");
    return 0;
}

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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_N = 21;

namespace modOp {
    int add(int a, int b, int mod = MOD) { return (a + b) % mod; }
    int sub(int a, int b, int mod = MOD) { return (a - b + mod) % mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a * b % mod; }
}
using namespace modOp;

int N;
int a[MAX_N][MAX_N];
int dp[(1 << MAX_N)];

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

	dp[0] = 1;
	for (int mask = 1; mask < (1 << N); ++mask) {
		int man = __builtin_popcount(mask) - 1;
		for (int woman = 0; woman < N; ++woman) {
			if (a[man][woman] && ((1 << woman) & mask) != 0) {
				dp[mask] = add(dp[mask], dp[(~(1 << woman) & mask)]);
			}
		} 
	}

	cout << dp[(1 << N) - 1] << '\n';

	return 0;
}

Measured memory_bytes: 8448
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


DIV=10**9+7

def mod_invs(n,mod=DIV):
    inv=[0]*(n+1)
    inv[0]=1
    inv[1]=1
    for i in range(2,n+1):
        inv[i] = (-(mod//i)*inv[mod%i]) % mod
    return inv



def main():
    N = int_raw()
    Ws  = ints_raw()
    S2 = sum(Ws)
    S1 = 0
    ans = abs(S2-S1)
    for w in Ws:
        S2-=w
        S1+=w
        ans = min(ans,abs(S2-S1))
    return ans

print(main())


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
 
int N,W;
int dp[111][20002];

signed main() {
    IOS();
    cin>>N>>W;
    vint w(N),v(N);
    rep(i,0,N){
        cin>>v[i]>>w[i];
    }
    
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    rep(i,0,N){
        rrep(j,0,W+1){
            if(dp[i][j]==-1)continue;
            chmax(dp[i+1][j],dp[i][j]);
            chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
        }
    }
    
    int ans=0;
    rep(i,0,W+1){
        chmax(ans,dp[N][i]);
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 20512
# coding: utf-8
# Your code here!

while True:
   a, b = map(int, input().split())
   if a + b == 0:
      break
   
   c = 0
   if a < b:
      a, b = b, a
   while b != 0:
      c += 1
      r = a % b
      a = b
      b = r
   print(a, c)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    INT n,x,m;
    cin >> n >> x >> m;
    
    bool check = true;
    int cnt = 0;
    int start=0;
    INT total=0;
    INT ans=0;
    vector<INT> past;
    
    past.push_back(x);
    while(check){
        x = x*x % m;
        past.push_back(x);
        cnt++;
        if(cnt==n-1){
            rep(i,n){
                ans += past[i];
            }
            cout << ans;
            return 0;
        }
        rep(i,cnt){
            if(past[i]==x){
                check=false;
                start = i;
                for(int j=start;j<cnt;j++){
                    total += past[j];
                }
                break;
            }
        }
        
    }
    INT initial_part_total = 0;
    for(int i=0;i<start;i++){
        initial_part_total += past[i];
    }
    INT roop = (n - start)/(cnt - start);
    INT last_part = (n-start)-((cnt-start)*roop);
    
    int last_part_total=0 ;
    rep(i, last_part){
        last_part_total += past[i+start];
    }
    
    ans = initial_part_total + (total*roop) + last_part_total;
    cout << ans;
    
	return 0;
}



Measured memory_bytes: 3928
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n, m; cin >> n >> m;
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  rep(i, n) {
    int a, b; cin >> a >> b;
    pq.push({a, b});
  }

  priority_queue<int> award;
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    bool empty_flag = false;
    if (pq.empty()) empty_flag = true;
    while (!empty_flag && !pq.empty() && pq.top().first <= i) {
      award.push(pq.top().second);
      pq.pop();
    }
    if (award.empty()) continue;
    ans += award.top(); award.pop();
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
   
   
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
	int x, y,temp;
	while (1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
		{
			break;
		}
		if (x > y)
		{
			temp = x;
			x = y;
			y = temp;
		}
		printf("%d %d\n", x, y);
		
	}
	return 0;
}

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

int main() {
  int n;
  string s;
  int a=0,b=0,c=0,d=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=="AC") a++;
    else if(s=="WA") b++;
    else if(s=="TLE") c++;
    else if("RE") d++;
  }
  cout <<"AC x " << a << endl;
    cout <<"WA x " << b << endl;
    cout <<"TLE x " << c << endl;
    cout <<"RE x " << d << endl;
  
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  sort(p.begin(), p.end());

  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }

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


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

const int N = 1e5 + 10;

int a[N], b[N], n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n+1; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        sum = sum + 1LL * min(a[i],b[i]);
        b[i] = b[i] - min(a[i], b[i]);
        sum = sum + 1LL * min(b[i], a[i+1]);
        a[i+1] -= min(b[i], a[i+1]);
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, c = (int(i) for i in input().split())
        G[a-1].append((b-1, c % 2))
        G[b-1].append((a-1, c % 2))

    color = [-1]*N

    def dfs(s):
        seen = [False]*N
        stack = [s]
        seen[s] = True
        color[0] = 0
        while stack:
            v = stack.pop()
            for u, dist in G[v]:
                if seen[u]:
                    continue
                if dist == 1:
                    color[u] = color[v] ^ 1
                else:
                    color[u] = color[v]
                stack.append(u)
                seen[u] = True

    dfs(0)
    print(*color, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 97828
N, K = map(int, input().split())
S = list(input())

if S[K-1] == 'A':
    S[K-1] = 'a'
    
if S[K-1] == 'B':
    S[K-1] = 'b'
    
if S[K-1] == 'C':
    S[K-1] = 'c'
    
res = ''
for i in range(N):
    res += S[i]

print(res)



Measured memory_bytes: 38384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,t;cin>>n>>t;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    ll minm=INF;
    chmin(minm,a[0]);
    ll cmax=0;
    for(ll i=1;i<n;i++){
        chmax(cmax,a[i]-minm);
        chmin(minm,a[i]);
    }
    minm=a[0];
    map<ll,ll>m;
    m[a[0]]++;
    for(ll i=1;i<n;i++){
        if(a[i]-minm==cmax){
            ans+=m[minm];
            m[minm+1]+=m[minm];
            m[minm]=0;
            minm++;
        }
        chmin(minm,a[i]);
        m[a[i]]++;
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 10368
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[][] table = new long[n][];
		for(int i = 0; i < n; i++) {
			table[i] = new long[n];
			for(int j = 0; j < n; j++)
				table[i][j] = 1000000007;
			table[i][i] = 0;
		}
		boolean[][][] using = new boolean[n][][];
		for(int i = 0; i < n; i++) {
			using[i] = new boolean[n][];
			for(int j = 0; j < n; j++)
				using[i][j] = new boolean[m];
		}
		int a, b, c;
		for(int i = 0; i < m; i++) {
			a = sc.nextInt() - 1;
			b = sc.nextInt() - 1;
			c = sc.nextInt();
			table[a][b] = c;
			using[a][b][i] = true;
			table[b][a] = c;
			using[b][a][i] = true;
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < n; k++) {
					if(table[j][i] + table[i][k] < table[j][k]) {
						table[j][k] = table[j][i] + table[i][k];
						for(int l = 0; l < m; l++)
							using[j][k][l] = using[j][i][l] || using[i][k][l];
					}
				}
			}
		}
		boolean result;
		int counter = 0;
		for(int i = 0; i < m; i++) {
			result = false;
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < n; k++)
					result = result || using[j][k][i];
			}
			counter += result ? 0 : 1;
		}
		System.out.println(String.valueOf(counter));
	}
}

Measured memory_bytes: 24820
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
using namespace std;
int n,c5,c3,c25,c15,c75;
map<int, int> mp;
void soinsuu_bunkai(int n){
    while(n>1){
        for(int i=2; i<=100;i++){
            if(n%i==0){
                mp[i]++;
                n/=i;
                break;
            }
        }
    }
}

int main(void){
    cin>>n;
    for(int j=1;j<=n;j++)soinsuu_bunkai(j);
    //soinsuu_bunkai(32400);
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        //cout<<itr->second<<" "<<itr->first<<endl;
        if(itr->second >= 4)c5++;
        if(itr->second >= 2)c3++;
        if(itr->second >= 24)c25++;
        if(itr->second >= 14)c15++;
        if(itr->second >= 74)c75++;
    }
    //cout<<c5<<" "<<c3<<endl;
    cout<<c75+c15*(c5-1)+c25*(c3-1)+c5*(c5-1)*(c3-2)/2<<endl;
    return 0;
}


Measured memory_bytes: 256