akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int v[2] = {-1, 1};
int main()
{
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p;
    cin>>t;
    rep(i,n-k){
        if(t[i]==t[i+k]){
            t[i+k]='F';
        }
    }
    ll pt=0;
    rep(i,n){
        if(t[i]=='r'){
            pt+=p;
        }else if(t[i]=='p'){
            pt+=s;
        }else if(t[i]=='s'){
            pt+=r;
        }
    }
    cout<<pt<<endl;

}

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

#define ar array
#define ll long long int

const ll mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
       int n;
       cin >> n;
       vector<int> a(n);
       for (int &x : a)         cin >> x;
        ll st = 0;
        int maxm = a[0];
        for (int i = 1; i < n; ++i) {
            if (a[i] < maxm) {
                st += 1LL * (maxm - a[i]);
            }
            maxm = max(maxm, a[i]);
        }
        cout << st;
    }

    return 0;
}

Measured memory_bytes: 3988
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

//in
// 3778
//out
// Bad
const main = (inp: string) => {

    if (inp[0] === inp[1] || inp[1] === inp[2] || inp[2] === inp[3]) {
        console.log('Bad');

    } else {
        console.log('Good');
    }
};
main(fs.readFileSync('/dev/stdin', 'utf8').trim());



Measured memory_bytes: 7372
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >>c >> d;
  if(abs(a-c)<=d) cout <<  "Yes" << endl;
  else  if((abs(a-b)<=d)&&(abs(b-c)<=d)) cout <<"Yes"<< endl;
  else cout <<"No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 int main()
{
 int i, j, k;
 int n, x;
 int count;
 while(1)
{
 scanf("%d %d ", &n, &x);
 if(n==0&&x==0)break;
 count=0;
 for(i=1;
3*i+3<=x;
i++)
{
 for(j=i+1;
i+2*j+1<=x;
j++)
{
 for(k=n;
k>j;
k--)
{
 if(x==i+j+k)
{
 count++;
 break;
 }
else if(x>=i+j+k)
{
 break;
 }
 }
 }
 }
 printf("%d\n", count);
 }
 return 0;
 }
 

 



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define vi vector <int>
#define pi pair <int, int>
typedef long long ll;

vector <vi> adj;
vi d, visited;
int n, m, s, t;

void input()
{
	int x, y;
	cin >> n >> m;
	adj.resize(3*n);
	d.resize(3*n);
	visited.resize(3*n);
	
	for (int i = 1; i <= m; i++)
	{
		cin >> x >> y; x--; y--;
		adj[3*x].push_back(3*y + 1);
		adj[3*x + 1].push_back(3*y + 2);
		adj[3*x + 2].push_back(3*y);
	}
	
	cin >> s >> t;
	s = 3*(s - 1);
	t = 3*(t - 1);
}

void bfs()
{
	queue <int> q;
	q.push(s);
	visited[s] = 1;
	
	while (!q.empty())
	{
		int v = q.front();
		q.pop();
		for (int u: adj[v])
			if (!visited[u])
			{
				q.push(u);
				visited[u] = true;
				d[u] = d[v] + 1;
			}
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	input();
	bfs();
	if (d[t]) cout << d[t]/3;
	else cout << -1;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;




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

  vector<int> mop10(s.size());
  mop10[0] = 1;
  for(int i = 1; i < s.size(); i++){
    mop10[i] = mop10[i-1] * 10 % 2019;
  }

  reverse(s.begin(), s.end());

  vector<int> sum(s.size());
  vector<int> cnt(2019, 0);

  sum[0] = (int)(s[0] - '0');
  cnt[sum[0]]++;
   ll ans = 0LL;
  
 
  for(int i = 1; i < s.size(); i++){
    sum[i] = sum[i-1] + mop10[i] * (int)(s[i] - '0');
    sum[i] %= 2019;
    if(sum[i] == 0){ans++;}
    cnt[sum[i]]++;
  }
  
  for(int i = 0; i < 2019; i++){
    ll num = cnt[i] * (cnt[i] - 1) / 2;
    ans += num;
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 5168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    ll n;
    cin>>n;
    map<ll,ll> dp;
    rep(i,n){
        ll a;
        cin>>a;
        dp[a]++;
    }
    
    vec<ll> e;
    for(auto p:dp){
        while(p.second>=2){
            e.pb(p.first);
            p.second-=2;
        }
    }
    sort(ALL(e));
    if(e.size()<1) cout<<0<<endl;
    else cout<<e[e.size()-1]*e[e.size()-2]<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c,d;
  	ci(a>>b>>c>>d);
  co(M(a*b,c*d))
}

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

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

    for (int i = 0; i < s.length(); i++){
        if(i%2==0 && s[i]=='L'){    // 奇数番目
            cout << "No" << endl;
            return 0;
        }
        if(i%2==1 && s[i]=='R'){    // 偶数番目
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===



ll gcd(ll a, ll b)
{
	if (b > a) swap(a, b);

	ll r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


bool prime_test(ll a)
{
	if (a == 1 || a == 2) {
		return true;
	}
	if (a % 2 == 0) {
		return false;
	}
	bool res = true;
	for (ll i = 3; i * i <= a; i += 2) {
		if (a % i == 0) {
			res = false;
			break;
		}
	}
	return res;
}



int main()
{
	ll A, B;
	cin >> A >> B;
	ll g = gcd(A, B);

	Vl ds;
	for (ll i = 1; i * i <= g; ++i) {
		if (g % i == 0) {
			ds.push_back(i);
			if (i * i != g) {
				ds.push_back(g / i);
			}
		}
	}

	int ans = 0;
	for (const auto& d : ds) {
		if (prime_test(d)) ++ans;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
import java.io.*;
class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        String str =br.readLine();
        
        int x=Integer.parseInt(str);
        double y=Math.pow(x,3);
        int z=(int)y;
        System.out.println(z);
    }
}


Measured memory_bytes: 24328
#include <stdio.h>

int main(){
  int hpT, atT, hpA, atA;
  scanf("%d%d%d%d", &hpT, &atT, &hpA, &atA);
  while(1){
    hpA -= atT;
    if(hpA <= 0){
      printf("Yes\n");
      break;
    }
    hpT -= atA;
    if(hpT <= 0){
      printf("No\n");
      break;
    }
  }
  return 0;
}


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


int main(void) {
    long t;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        long n, m, a, b;
        cin >> n >> m >> a >> b;
        long ans = floor_sum(n, m, a, b);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner shu = new Scanner(System.in);
        
        int N = shu.nextInt();
        
        int v, j;
        int[] A = new int[N];
        int b = 0;
        while(b < N){
                A[b] = shu.nextInt();
                b++;
            }
        for(int k = 0; k < N; k++){
            System.out.print(A[k]);
            if(k < N-1)System.out.print(" ");
        }
        System.out.println();
        
        for(int i = 1; i < N; i++){
            v = A[i];
            j = i - 1;
            
            while(j >= 0 && A[j] > v){
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = v;
            for(int t = 0; t < N; t++){
                System.out.print(A[t]);
                if(t < N-1)System.out.print(" ");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class BShiritori {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in>>n;
        map<string,ll> w;
        string ps;
        in >> ps;
        w[ps]++;
        rep(i,n-1){
            string s;
            in>>s;
            if(ps.at(ps.size()-1)!=s.at(0)){
                out<<"No"<<endl;
                return;
            }
            w[s]++;
            ps=s;

        }
        for (auto &i: w) {
                if(i.second!=1){
                    out<<"No"<<endl;
                    return;
                }
        }
        out<<"Yes"<<endl;
	}
};


int main() {
	BShiritori solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

//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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  
  string A,B,C;
  cin >> A >> B >> C;
  
  if(A.at(SZ(A)-1) == B.at(0) && B.at(SZ(B)-1) == C.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

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

  ll D; cin >> D;
  ll T; cin >> T;
  ll S; cin >> S;

  string ans = "Yes";
  if (D > T * S) ans = "No";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,x;
cin>>a>>b>>x;
if(x-a<=b&&x-a>=0){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    if (n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string S[10];

ll x[2] = {0, 1};
ll y[2] = {1, 0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    REP(i, H) {
        cin >> S[i];
    }

    queue<pll> q;
    q.push(pll(0, 0));

    while (!q.empty()) {
        pll t = q.front();
        q.pop();
        S[t.first][t.second] = '.';
        REP(i, 2) {
            ll nx = t.first + x[i], ny = t.second + y[i];
            if (nx >= H || ny >= W)
                continue;
            if (S[nx][ny] == '.')
                continue;
            q.push(pll(nx, ny));
            break;
        }
    }

    bool suc = true;
    REP(i, H) {
        REP(j, W) {
            if (S[i][j] == '#')
                suc = false;
        }
    }
    if (suc)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

void enqueue(P);
P dequeue();
int min(int, int);

P Q[LEN+1];
int head, tail, n;

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 0;
  tail = n;
  while (head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0)
      enqueue(u);
    else
      printf("%s %d\n",u.name,elaps);
  }

  return 0;
}

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  if (head == LEN-1){
    head = 0;
    return Q[LEN-1];
  }
  else{
    head++;
    return Q[head-1];
  }
}

int min(int a, int b){
  return a < b ? a : b;
}



Measured memory_bytes: 11844
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=100002;

 
void solve(){
	int a,b;
	cin>>a>>b;
	int gc=__gcd(a,b);
	a/=gc;b/=gc;
	cout<<a*1ll*b*gc;
	
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  int n, a = 0, b = 0, c = 0, result = 0;
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    if(tmp % 3 == 0)
      a++;
    if(tmp % 3 == 1)
      b++;
    if(tmp % 3 == 2)
      c++;
  }

  if (b == 0 && c == 0)
  {
    cout << 1 << endl;
    exit(0);
  }

  result += a;
  result += 2 * min(b, c);

  if(b == c)
  {
    cout << result << endl;
    exit(0);
  }

  if(b >= c)
    b--;
  else
    c--;

  if(abs(b - c) == 1)
  {
    result++;
  }
  else if (abs(b - c) >= 2)
  {
    result += 2;
  }

  cout << result + 1 << endl;

}



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

bool solve() {
    string S; cin >> S;
    rep(i, 0, S.size()) {
        if(i % 2 == 0 && S[i] == 'L') return false;
        else if(i % 2 && S[i] == 'R') return false;
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


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

//constexpr ll mod = 1000000007;
//constexpr ll INF = mod * mod;
//constexpr double pi = 3.14159265358979;

ll deviding(ll n,ll m) {
    ll ans = n / m;
    if(n % m != 0) ans++;
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> c(n),s(n),f(n);
    rep(i,n-1) {
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i,n-1) {
        ll counter = 0;
        for(int j = i; j < n-1; j++) {
            if(j == i) {
                counter += c[i] + s[i];
            }
            else {
                int diff = counter - s[j];
                if(diff < 0) diff = 0;
                int C = deviding(diff,f[j]);
                counter = s[j] + C * f[j];
                counter += c[j];
            }
        }
        cout << counter << endl;
        counter = 0;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
import math
import sys

N = int(input())
X = list(map(int, input().split()))

X.sort()
ans = sys.maxsize

for i in range(X[0], X[-1]+1):
    sum = 0
    for x in X:
        sum += (x-i)**2
    ans = min(ans, sum)  

print(ans)  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	long long sum = 0, dv = 0;
	for(int i = 1; i <= n; i++) sum += a[i - 1], dv += i;
	auto bad = [](){
		cout << "NO" << endl;
		exit(0);
	};
	if(sum%dv) bad();
	long long op = sum / dv;
	a.push_back(a[0]);
	for(int i = 0; i < n; i++){
		int fwd = a[i + 1] - a[i];
		if(op - fwd < 0) bad();
		if((op - fwd) % n) bad();
	}
	cout << "YES" << endl;
	return 0;
}


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


int main(){
 
  int n; cin>>n;
  float sum=0;
   for(int i=0;i<n;i++){
   float a;
    string b;
    cin>>a>>b;
     if(b=="BTC") sum+=a*380000.0;
     else sum+=a;
   }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	private int rect = 0, lozen = 0;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String str = scan.nextLine();
			String[] st = str.split(",");
			int num[] = new int[3];
			for (int i = 0; i < 3; i++) {
				num[i] = Integer.parseInt(st[i]);
			}
			
			if (num[0] != num[1]) {
				if (num[0] * num[0] + num[1] * num[1] == num[2] * num[2]) rect++;
			}else {
				lozen++;
			}
			//debug();
		}
		debug();
	}
	
	private void debug() {
		System.out.println(rect);
		System.out.println(lozen);
	}

}

Measured memory_bytes: 17136
#include <stdio.h>
#include <math.h>
#define num 1000000

// 0:素数かもしれない
// 1:素数ではない
// 2:素数である

int main(void){
	char prime[num];
	int primeTop = 2;
	int i, j, ans = 0;
	int n;
	for(i = 0; i < num; i++){
		prime[i] = '0';
	}
	
	while(primeTop < sqrt(num)){

		for(j = 1; j <= num; j++){
			if(primeTop * j < num)
				prime[primeTop * j] = '1';	// 素数ではないもの
		}
		prime[primeTop] = '2';	// 素数（確定）
	
		for(j = 2; j < num; j++){
			if(prime[j] == '0'){
				primeTop = j;	// 次の素数
				break;
			}
		}
	}
	
	for(i = 0; i < num; i++){
		if(prime[i] == '0') prime[i] = '2';	// 残りの素数かもしれないのを素数に確定する
	}

	
	while(scanf("%d", &n) != EOF){
		ans = 0;
		for(j = 2; j <= n; j++){
			if(prime[j] == '2'){
				ans++;
			}
		}
	
		printf("%d\n", ans);
	}
	return 0;
}
	

Measured memory_bytes: 1572
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 300;
int N;
int A[MAX_N+1][MAX_N+1];
                            
struct edge { int to, cost; };
const int MAX_V = MAX_N;
const ll INF = INFLL;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void add_edge(int u, int v, int c) {
  G[u].push_back((edge){v, c}); G[v].push_back((edge){u, c});
}

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<Pll, vector<Pll>, greater<Pll> > pque;
  d[s] = 0;
  pque.push(Pll(0, s));


  while (!pque.empty()) {
    Pll p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(Pll(d[v]+ e.cost, e.to));
      }
    }
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }
  V = N;

  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      pque.push(Pii(A[i][j], i*N+j));
    }
  }

  ll ans = 0;
  while (!pque.empty()) {
    Pii pii = pque.top(); pque.pop();
    int cost = pii.fi, i = pii.sc/N, j = pii.sc%N;
    
    dijkstra(i);
    if (d[j] < cost) {
      cout << -1 << endl;
      return 0;
    } else if (d[j] > cost) {
      add_edge(i, j, cost);
      ans += cost;
    }
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1908
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n =Integer.parseInt(sc.next());
		int m =Integer.parseInt(sc.next());
		
		int [][]ac = new int [n][2];
		boolean []flag = new boolean [n];
		
		for(int i = 0 ;i < m ;i++) {
			int p = Integer.parseInt(sc.next());
			String s = sc.next();
			
			if(s.equals("WA")) {
				if(flag[p-1]) {
					continue;
				}
				ac[p-1][0]++;
			}
			else if(s.equals("AC")) {
				flag[p-1] = true;
				ac[p-1][1] = 1;
			}
		}
		
		int ans1 = 0;
		int ans2 = 0;
		
		for(int i = 0 ;i < n ;i++) {
			ans1 += ac[i][1];
			if(ac[i][1] ==1) {
				ans2 += ac[i][0];
			}
		}
		
		System.out.println(ans1+" "+ans2);
	
	}

}


Measured memory_bytes: 62712
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define dreps(i,cc,n) for(int i=cc;i>(n);--i)
#define llreps(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	int flag = 0;
	rep(i, N)
	{
		cin >> A[i];
		if (A[i] == 0)
			flag = 1;
	}
	ll sum = 1;
	ll num = powl(10, 18);
	rep(i, N)
	{
		ld sa = log10l(sum) + log10l(A[i]);
		if (sa > 18.0 || sum * A[i] > num)
		{
			if (flag == 1)
				flag = 0;
			else
				flag = -1;
			cout << flag << endl;
			return 0;
		}
		sum *= A[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4112
#include <stdio.h>
int main(void)
{
    char a[100];
    char b[100];
    int i, y, t;
    scanf("%s", a);
    scanf("%s", b);
    while (1)
    {
        for (i = 0; a[i] != '\0'; ++i)
            ;
        for (t = 0; b[t] != '\0'; ++t)
            ;
        if (t - i == 1 && t<12 && 0<i)
        {
            for (i = 0; i < t; i++)
            {
                if (a[i] == '\0')
                {
                    printf("Yes\n");
                    break;
                }
                else if (a[i] != b[i])
                {
                    printf("No\n");
                    break;
                }
            }
        }
        else
        {
            printf("No\n");
        }
        break;
    }
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
int c[10][10];

using namespace std;
using ll = long long;

int main() {
	int H, W;
	cin >> H >> W;
	REP(i, 10) REP(j, 10) cin >> c[i][j];
	REP(h, 10) REP(i, 10) REP(j, 10) c[i][j] = min(c[i][j], c[i][h] + c[h][j]);
	int m = 0;
	int a;
	REP(i, H) REP(j, W) {
		cin >> a;
		if(a >= 0)m += c[a][1];	
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int MAX_N = 100000;

int _gcd(int m, int n){
    int a = max(m, n);
    int b = min(m, n);

    while(b != 1 && b != 0){
        a %= b;
        swap(a, b);
    }
    return b == 1 ? 1 : a;
}

int main(void){
    int N;
    int A[MAX_N];
    int L[MAX_N + 1];
    int R[MAX_N + 1];
    int answer = 0;

    cin >> N;

    rep(i, N){
        cin >> A[i];
    }

    L[0] = 0;
    R[N] = 0;

    rep(i, N){
        L[i + 1] = _gcd(L[i], A[i]);
        R[N - i - 1] = _gcd(R[N - i], A[N - i - 1]);
    }

    rep(i, N){
        answer = max(answer, _gcd(L[i], R[i + 1]));
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 1408
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

calc :: Int -> [Int] -> Int
calc pos [] = abs pos
calc pos (a:as) = abs (a - pos) + calc a as

solve :: Int -> [Int] -> [Int]
solve _ [a1, a2] = []
solve total (a1:a2:a3:as) = res : solve total (a2:a3:as)
  where res = total + abs (a3 - a1) - abs (a3 - a2) - abs (a2 - a1)

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  mapM_ print $ solve (calc 0 as) ([0] ++ as ++ [0])

Measured memory_bytes: 15100
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  char key = s[0];
  rep(i, s.size()) {
    if(s[i] != key) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
#! /usr/bin/env python3

# from fractions import gcd
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

S = input()
T = input()

if T[0:-1] == S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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 io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    mes(n*(n-1)/2);
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
priority_queue<int> q;
int n,M;

int main(){
    cin>>n>>M;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        q.push(x);
    }
    int t;
    for(int i=0;i<M;i++){
        t=q.top()/2;
        q.pop();
        q.push(t);
    }
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=q.top();
        q.pop();
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 892
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int h, w;
    cin >> h >> w;

    vec<string> map(h);
    for (auto& e : map)
    {
        cin >> e;
    }

    vvec<int> hDot(w), wDot(h), hSharp(w), wSharp(h);
    vvec<int> hs(w), ws(h);

    for (int y = 0; y < h; ++y)
    {
        bool isPrevX = true;
        for (int x = 0; x < w; ++x)
        {
            if (map[y][x] == '.')
            {
                if (isPrevX)
                    ws[y].push_back(x);
                isPrevX = false;
            }
            else
            {
                if (!isPrevX)
                    ws[y].push_back(x);
                isPrevX = true;
            }
        }
        if (!isPrevX)
            ws[y].push_back(w);
    }

    for (int x = 0; x < w; ++x)
    {
        bool isPrevX = true;
        for (int y = 0; y < h; ++y)
        {
            if (map[y][x] == '.')
            {
                if (isPrevX)
                    hs[x].push_back(y);
                isPrevX = false;
            }
            else
            {
                if (!isPrevX)
                    hs[x].push_back(y);
                isPrevX = true;
            }
        }
        if (!isPrevX)
            hs[x].push_back(h);
    }


    int ans {0};
    for (int y = 0; y < h; ++y)
        for (int x = 0; x < w; ++x)
        {
            if (map[y][x] == '#')
                continue;
            
            // 横
            auto r = upper_bound(ws[y].cbegin(), ws[y].cend(), x);
            auto l = prev(r);
            auto wlen = *r - *l;
            // 縦
        
            auto d = upper_bound(hs[x].cbegin(), hs[x].cend(), y);
            auto u = prev(d);
            auto hlen = *d - *u;

            ans = max({ans, wlen + hlen - 1});
        }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20736
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		Long K = reader.nextLong();
		long ans = 0;
		SortedMap<Long, Long> map = new TreeMap<Long, Long>();

		for (int i = 0 ; i < N; i++) {
			long key = reader.nextLong();
			long value = reader.nextLong();
			if (map.containsKey(key)) {
				value += map.get(key);
			}
			map.put(key, value);
		}

		for (Entry<Long, Long> entry : map.entrySet()) {
			K -= entry.getValue();
			if (K <= 0) {
				ans = entry.getKey();
				break;
			}
		}

		System.out.println(ans);
		reader.close();

	}
}





Measured memory_bytes: 94964
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(
        answer067aAlt(a, b)
    )
}

fun answer067aAlt(a: Int, b: Int): String {

    return if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        "Possible"
    }else {
        "Impossible"
    }
}

Measured memory_bytes: 29468
#include <cstdio>
    #include <algorithm>
     
    using namespace std;
     
    const int MAXN=2e5+10;
    int N;
    int arr[MAXN];
     
    typedef long long int ll;
     
    ll dp[MAXN];
     
    int main(){
        scanf("%d",&N);
        for(int i=1;i<=N;i++) scanf("%d",arr+i);
     
        // for(int i=1;i<=N;i++) printf("%d ",arr[i]);
        // putchar('\n');
     
        
        if (N%2){
            for(int i=1;i<=N;i++) 
                if (i%2) dp[i]=dp[i-1]+arr[i]; else dp[i]=dp[i-1]-arr[i];
     
            int lower_bound=1;
            int ans_l,ans_r;
            ll max_prefix=-1,min_seg=dp[1];
            for(int i=1;i<=N;i+=2){
                if (dp[i-1]>max_prefix){
                    max_prefix=dp[i-1];
                    lower_bound=i;
                }
     
                if(dp[i]-max_prefix<=min_seg){
                    min_seg=dp[i]-max_prefix;
                    ans_r=i;
                    ans_l=lower_bound;
                }
            }
     
            ll sum=0;
            for(int i=1;i<ans_l;i+=2) sum+=arr[i];
            for(int i=ans_l+1;i<=ans_r;i+=2) sum+=arr[i];
            for(int i=ans_r+2;i<=N;i+=2) sum+=arr[i];
     
            // printf("lower_bound=%d,upper_bound=%d\n",ans_l,ans_r);
     
            printf("%lld\n",sum);
        }else{
            ll sum=0ll;
            ll temp=0ll;
            for(int i=1;i<N;i+=2) temp+=arr[i];
            sum=temp;
            for(int i=N-1;i>=1;i-=2) {
                temp+=arr[i+1];
                temp-=arr[i];
                sum=max(sum,temp);
            }

     
            printf("%lld\n",sum);
        }
     
     
        return 0;
    }

Measured memory_bytes: 4072
from collections import deque

def main():
    ans = 0
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    for _ in range(M):
        ai, bi = map(int, input().split())
        for j in range(1, N+1):
            if ai == j:
                graph[j-1].append(bi)
            elif bi == j:
                graph[j-1].append(ai)
        
    q = deque()
    q.append([1, {_ for _ in range(2, N+1)}])

    while q:
        prev, exist = q.popleft()

        if not exist:
            ans += 1
        for next in exist:
            if next in graph[prev-1]:
                q.append([next, exist-{next}])

    print(ans)

if __name__ == "__main__":
    main()



Measured memory_bytes: 42736
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int n; cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  sort(ALL(v));
  ll ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      for(int k = j + 1; k < n; k++){
        if(v[i]==v[j] || v[j] == v[k] || v[k] == v[i]) continue;
        if(v[i] + v[j] > v[k]) ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>

int main(){
    
    int time, h, m, s;
    std::cin>>time;
    
    h = time/3600;
    m = (time - h*3600) / 60;
    s = (time - h*3600 - m*60);
    
    std::cout << h << ":" << m << ":" << s << std::endl;
    
    return 0;
}

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

const int maxn = 200010;
int n, a[maxn], b[maxn];

int main() {
    scanf("%d", &n);
    long long s = 0, mn = 1e18;
    bool flag = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &a[i], &b[i]);
        flag &= (a[i] == b[i]), s += a[i];
        if (a[i] > b[i]) mn = min(mn, (long long)b[i]);
    }
    if (flag) printf("0\n");
    else printf("%lld\n", s - mn);
    return 0;
}

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

int main()
{
	int X;
	cin >> X;
	if (X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;
 
 


//c++ templte for help............................................................................................................................................

typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; }
#define vdeb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;}

// to return everything in string
#define ret(...) {stringstream returnn;returnn<<__VA_ARGS__;return returnn.str();}

stringstream retvec;
template<typename... T>
void returnvector(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			for(ll j=0;j<(ll)ans[i].size();j++){
				retvec<<ans[i][j];
				if(j!=(ll)ans[i].size()-1)
					retvec<<" ";
			}
			if(i!=(ll)ans.size()-1)
				retvec<<endl;
		}
}
#define vret(...) {returnvector(__VA_ARGS__);return retvec.str();}
	


//for loop
#define fo(i,n) for(int i=0;i<(ll)n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
template<typename T>
void printV(T vec){
	fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	cout<<endl;
	}
	
 
#define M ll(998244353)
const ll INF=ll(1e9+5);
 
//iterate map
template<typename T>
void itR(T map){
	 for(auto itr=map.begin();itr!=map.end();itr++){
				deb(itr->first,itr->second);
			}
	cout<<endl;
}

//c++ template for help...........................................................................................................................................

string solve(){
	ll n,k;
	cin>>n>>k;
	
	vector<pair<ll,ll>> vec(n);
	fo(i,n){
		cin>>vec[i].first>>vec[i].second;
	}
	
	vector<ll> dp(n);
	dp[0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<k;j++){
			if(i-vec[j].first<0 and i-vec[j].second-1<0) continue;
			else if(i-vec[j].second-1<0) {dp[i]=(dp[i]%M+dp[i-vec[j].first]%M)%M;}
			else {dp[i]=(dp[i]%M+dp[i-vec[j].first]%M-dp[i-vec[j].second-1]%M+M)%M;}
		}
		dp[i]=(dp[i]%M+dp[i-1]%M)%M;
	}
		
	ret((dp[n-1]%M-dp[n-2]%M+M)%M);
	
}

int main() {
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		string ans1=solve();
		if(ans1!="")
			cout<<ans1<<endl;
	//}
	return 0;
}


Measured memory_bytes: 8008
// 2011/08/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++)
			for(int j=0; j<m; j++)
				if(i==j)
					C[i][j] = T[i][j] = 0;
				else
					C[i][j] = T[i][j] = 100000;

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		// tChÌASY
		for(int h=0; h<m; h++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					if(C[i][j]>C[i][h]+C[h][j])
						C[i][j] = C[i][h]+C[h][j];
					if(T[i][j]>T[i][h]+T[h][j])
						T[i][j] = T[i][h]+T[h][j];
				}
			}
		}

		int k;
		cin >> k;

		for(int i=0; i<k; i++){
			int p, q, r;
			cin >> p >> q >> r;
			if(r==0)
				cout << C[p-1][q-1] << endl;
			else
				cout << T[p-1][q-1] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 940