akhauriyash/Code-Regression huggingface dataset:
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        int[] c = new int[4];
        // int[] d = new int[3];
        c[0] = 0 <= B - A ? B - A : Integer.MAX_VALUE;
        c[1] = 0 <= B - (-A) ? B - (-A) + 1 : Integer.MAX_VALUE;
        c[2] = 0 <= (-B) - (-A) ? (-B) - (-A) + 2 : Integer.MAX_VALUE;
        c[3] = 0 <= (-A) - B ? (-A) - B + 1: Integer.MAX_VALUE;
        // c[0] = 0 <= B - A ? B - A : Integer.MAX_VALUE;
        // c[0] = 0 <= B - A ? B - A : Integer.MAX_VALUE;
        for (int num : c) {
            if (num < ans)
                ans = num;
        }
        System.out.println(ans);
    }
}

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

int main() {
  int n;
  cin >> n;

  vector<long long int> lucas(87);

  lucas[0] = 2;
  lucas[1] = 1;

  for(int i=2;i<lucas.size();i++) {
    lucas[i] = lucas[i-1] + lucas[i-2];
  }

  cout << lucas[n] << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


int chk(set<int> a,set<int> b){
	EACH(it,b){
		if( a.count(*it) == 0 ) return false;
	}
	return true;
}
int main(){
	int n;
	while(cin >> n && n){
		set<int> s[100];
		for(int i = 0 ; i < n ; i++){
			int a,b;
			cin >> a;
			for(int j = 0 ; j < a ; j++){
				cin >> b;
				b--;
				s[i].insert(b);
			}
		}
		int k;
		cin >> k;
		set<int> v;
		for(int i = 0 ; i < k ; i++){
			int b;
			cin >> b;
			b--;
			v.insert(b);
		}
		int ans = 0 , ans2 = 0;
		for(int i = 0 ; i < n ; i++)
			if( chk(s[i],v) ){
				ans++ , ans2 = i;
			}
		if( ans == 1 ){
			cout << ans2+1 << endl;
		}else{
			cout << -1 << endl;
		}
	}
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

int par[100005];
int rnk[100005];

void init(int n){
  rep(i,n){
    par[i]=i;
    rnk[i]=0;
  }
}

int find(int x){
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rnk[x]<rnk[y])par[x]=y;
  else{
    par[y]=x;
    if(rnk[x]==rnk[y])rnk[x]++;
  }
}

bool same(int x,int y){
  return find(x)==find(y);
}

signed main(){
  int n,m;
  cin>>n>>m;
  init(n+1);
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  rep(i,m){
    int x,y;
    cin>>x>>y;
    unite(x,y);
  }
  int ans=0;
  rep(i,n){
    if(same(i+1,p[i]))ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int w[]={512,256,128,64,32,16,8,4,2,1};
  int n;
  while(cin>>n){
    stack<int> a;
    for(int i=0;i<10;i++){
      if(n>=w[i]){
	a.push(w[i]);
	n-=w[i];
      }
    }
    cout<<a.top();
    a.pop();
    while(!a.empty()){
      cout<<' '<<a.top();
      a.pop();
    }
    cout<<endl;
  }
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, D, d[500000], Q, q[500000];

LL p[500001];
LL f[500001];

int main() {
	cin >> n >> D;
	inc(i, n) { cin >> d[i]; }
	cin >> Q;
	inc(i, Q) { cin >> q[i]; }
	
	p[0] = D;
	inc(i, n) {
		p[i + 1] = min(p[i], abs(p[i] - d[i]));
	}
	
	LL e = 1;
	dec(i, n) {
		if(p[i] >= e) { f[i] = true; }
		if(d[i] / 2 < e) {
			e += d[i];
		}
	}
	
	inc(i, Q) {
		cout << (f[ q[i] - 1 ] ? "YES" : "NO") << endl;
	}
	
	return 0;
}


Measured memory_bytes: 17536
#include<stdio.h>

int Rounding(double);

int main(){
  int price, number, sum=0, intavg;
  double doubleavg=0, count=0;
  char c;

  while(scanf("%d %c %d", &price, &c, &number) != EOF){
    sum = sum + price * number;
    doubleavg += (double)number;
    count++;
  }

  doubleavg /= count;
  intavg = Rounding(doubleavg);
  printf("%d\n%d\n", sum, intavg);

  return 0;
}

int Rounding(double x){
  x += 0.5;
  return (int)x;
}

Measured memory_bytes: 0
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL INF=300000000;
const LL MOD=1000000007;



int main(){
    int n,m;
    cin>>n>>m;
    int k;
    int a[31]={0};
    for(int i=0;i<n;++i){
        cin>>k;
        for(int j=0;j<k;++j){
            int s;
            cin>>s;
            a[s]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;++i){
        if(a[i]==n)ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int Q; string s;
int main() {
	while(cin >> Q, Q) {
		int a[3] = { 1, 2, 3 };
		int ret = 1;
		while(Q--) {
			cin >> s;
			if(s[0] == 'N') swap(a[0], a[1]), a[1] = 7 - a[1];
			if(s[0] == 'E') swap(a[0], a[2]), a[0] = 7 - a[0];
			if(s[0] == 'W') swap(a[0], a[2]), a[2] = 7 - a[2];
			if(s[0] == 'S') swap(a[0], a[1]), a[0] = 7 - a[0];
			if(s[0] == 'R') swap(a[1], a[2]), a[2] = 7 - a[2];
			if(s[0] == 'L') swap(a[1], a[2]), a[1] = 7 - a[1];
			ret += a[0];
		}
		cout << ret << endl;
	}
}

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

#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

void fillTable(bool *primes, long long lastNumber, vector<long long> &primesList){
	primesList.clear();
	memset(primes, 1, (lastNumber+1) * sizeof(bool));
	primes[0] = primes[1] = false;
	for (int i = 2; i <= lastNumber; i++){
		if (primes[i]){
			primesList.push_back(i);
			int value = i + i;
			while(value <= lastNumber){
				primes[value] = false;
				value += i;
			}
		}
	}
}

void getPrimeDivisors(long long n, vector < long long > &primes, map<long long, int> &divisorsList){
	divisorsList.clear();
	divisorsList[1] = 1;
	for (int i = 0; i < primes.size(); i++){
		if (n % primes[i] != 0) continue;
		while((n % primes[i]) == 0){
			divisorsList[primes[i]]++;
			n /= primes[i];
		}
	}
	if (n != 1){
		divisorsList[n]++;
	}
}

bool primes[1000001];

int main(){
	optimizar_io;
	vector<long long> primesList;
	fillTable(primes, 1000000, primesList);
	long long A, B;
	cin >> A >> B;
	map<long long, int> primeDivA, primeDivB;
	getPrimeDivisors(A, primesList, primeDivA);
	getPrimeDivisors(B, primesList, primeDivB);
	map<long long, int> common;
	for (auto it = primeDivA.begin(); it != primeDivA.end(); it++){
		if (primeDivB.count(it->first)){
			common[it->first] = min(it->second, primeDivB[it->first]);
		}
	}
	cout << common.size() << endl;
	return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000; //10^9

int main(){
    int N;
    cin >> N;
    int ans;
    ans = ceil((double)N / 1.08);
    if(floor(ans * 1.08) == N){
        cout << ans << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
cnt = 0
def merge(A,left,mid,right):
	'''n1 = mid - left
	n2 = right - mid
	L = []
	R = []
	for i in range(0,n1):
		L.append(A[left+i])

	for i in range(0,n2):
		R.append(A[mid+i])
	L.append(1000000001)
	R.append(1000000001)
	'''
	L = A[left:mid]+[1000000001]
	R = A[mid:right]+[1000000001]

	i = 0
	j = 0
	global cnt
	for k in range(left,right):
		cnt += 1
		if L[i] <= R[j]:
			A[k]=L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1

def mergeSort(A,left,right):
	if left+1 < right:
		mid = (left+right)//2
		mergeSort(A,left,mid)
		mergeSort(A,mid,right)
		merge(A,left,mid,right)


if __name__ == '__main__':
	n = (int)(input())
	a = list(map(int,input().split()))
	
	mergeSort(a,0,n)
	print(*a)
	print(cnt)

Measured memory_bytes: 63752
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 200007;

signed main(){
    int n;
    cin>>n;
    vector<int> cnt(MAXN, 0);
    int a[n];
    for(int i = 0;i<n;i++){
        cin>>a[i];
    }
    for(int i = 0;i<n;i++){
        if(a[i] == 1){
            cnt[a[i]]++;
        } else {
            cnt[a[i]]+=cnt[a[i]-1];
        }
    }
    int mx = 0;
    int lol= 0;
    for(int i = 1;i<=n;i++){
        lol = max(cnt[i], lol);
        if(cnt[i] > 0) {
            mx = max(mx, i);
        }
    }
    if(lol == 0){
        cout<<-1<<endl;
    } else {
        cout<<n-mx<<endl;
    }
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  long ans = 0;
  
  string s;
  map<char,int> te;
  map<char,char> win{{'r','p'},{'s','r'},{'p','s'}};
  cin >> n >> k;
  cin >> te['r'] >> te['s'] >> te['p'];
  cin >> s;
  for(int i = 0; i < (int)s.size();i++){
    switch(s[i]){
      case 'r':
        ans += te['p'];
        break;
      case 's':
        ans += te['r'];
        break;
      case 'p':
        ans += te['s'];
        break;
    }
  }
  
  for(int i = k; i < (int)s.size();i++){
    if(s[i - k] == s[i]){
      ans -= te[win[s[i]]];
      s[i] = '-';
    }
  }
  cout << ans << endl;
}  

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli n,k;
	cin>>k>>n;

	vector<lli> a;
	REP(i,0,n){
		lli aa;
		cin>>aa;
		a.push_back(aa);
	}

	lli ans = INF;
	//i=0
	ans = min(ans,a[n-1]-a[0]);
	ans = min(ans,k-(a[1]-a[0]));
	if(DEBUG)cout<<"ans="<<ans<<endl;

	REP(i,1,n-1){
		lli cTarget = (i+n-1)%n;
		lli ccTarget = (i+1)%n;

		if(DEBUG)cout<<"i="<<i<<" sT="<<cTarget<<" cT="<<ccTarget<<endl;

		ans = min(ans,k-abs(a[i]-a[cTarget]));
		if(DEBUG)cout<<"ans="<<ans<<endl;
		ans = min(ans,k-abs(a[ccTarget]-a[i]));
		if(DEBUG)cout<<"ans="<<ans<<endl;
	}

	//i=n-1
	ans = min(ans,a[n-1]-a[0]);
	ans = min(ans,k-(a[n-1]-a[n-2]));


	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2420
n = int(input())
a = list(map(int, input().split()))
b = min(a,key=abs)
c = 0
sum_abs_a = 0
for i in range(n):
  sum_abs_a += abs(a[i])
for i in a:
  if i < 0:
    c += 1
if c % 2 == 0:
  print(sum_abs_a)
else:
  print(sum_abs_a - abs(b)*2)




Measured memory_bytes: 20080
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) vl a(n + 1, 0); fab(i,0,n) cin>>a[i]
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N =(ll)3e5;
const ll inf =(ll)1e18 + 7;
const ll mod =(ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for(ll i = 3;i * i <= n; i += 2)
        if(prime[i])
            for(ll j = i; j * i <= n; j += 2)
                prime[j * i] = false;
        
    for(ll i = 3; i <= n; i += 2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result = n;
    for(ll p = 2; p * p <= n; p++)
    {
        if(n % p == 0)
        {
            while(n % p == 0)
                n /= p;
            result -= result/p;
        }
    }

    if(n > 1)
        result -= result/n;
    return result;
}

ll nCr(ll n, ll k) 
{ 
    vl C(k + 1, 0); 
    ll i, j; 
    C[0] = 1; 
    for (i = 1; i <= n; i++) { 
        for (j = min(i, k); j > 0; j--) { 
            add(C[j], C[j - 1]); 
        } 
    }
    return C[k] % mod; 
}


int main()
{
	sup;
    
    string s, t, u;
    cin >> s;
    string ans(s.length(), 'x');
    pr(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  long double a,b,c;
  cin >> a >> b;
  c=a*b;
  cout << (ll) c << endl;
}

Measured memory_bytes: 3728
N = int(input())
s_rb = input()

counter_R = 0
counter_B = 0
for i in range(N):
    if s_rb[i] == 'R':
        counter_R += 1
    elif s_rb[i] == 'B':
        counter_B += 1

if counter_R > counter_B:
    print('Yes')
else:
    print('No')

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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

double a[ N ];
int n;
bool vis[ 3005 ][ 3005 ];
double dp[ 3005 ][ 3005 ];

double solve( int idx , int cnt ) {
        if( idx > n ) return cnt > n/2 ? 1.0 : 0.0;
        if( vis[idx][cnt] ) return dp[idx][cnt];
        vis[idx][cnt] = true;
        double ret1 = 1.0 , ret2 = 1.0, ans = 0.0;
        ret1 *= solve( idx + 1 , cnt+1 ) * a[idx];
        ret2 *= solve( idx + 1 , cnt ) * ( 1.0 - a[idx] );
        ans += ( ret1 + ret2 );
        return dp[idx][cnt] = ans;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        memset( vis , false , sizeof( vis ) );
        cout << setprecision(10) << fixed << solve( 1, 0 ) << endl;
        return 0;
}












Measured memory_bytes: 78720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  YesNo(n==m);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

LL solve2(LL h, LL w, LL a) {
    LL b=max(h/2*w, w/2*h);
    LL c=h*w-b;
    return max({abs(c-a), abs(c-b), abs(a-b)});
}

LL solve(LL h, LL w) {
    LL res=1e18;
    for ( int i=1; i<=h/2; i++ ) {
        chmin(res, solve2(h-i, w, w*i));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL h,w;
    cin >> h >> w;
    if ( h%3==0 || w%3==0 ) {
        cout << 0 << '\n';
        return 0;
    }
    LL ans=1e18;
    chmin(ans, solve(h,w));
    chmin(ans, solve(w,h));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const ll sz = 505;
vector<ll> dat[sz];

int main() {
	ll N, M, Q;
	scll(N), scll(M), scll(Q);
	ll L, R;
	for (ll i = 0; i < M; ++i) {
		scll(L), scll(R);
		dat[L].pb(R);
	}
	for (ll i = 1; i <= N; ++i) {
		VSORT(dat[i]);
	}
	ll p, q;
	for (ll i = 0; i < Q; ++i) {
		scll(p), scll(q);
		ll ans = 0;
		for (ll j = p; j <= q; ++j) {
			if (dat[j].empty()) continue;
			ll idx = upper_bound(ALL(dat[j]), q) - dat[j].begin();
			if (idx < dat[j].size() && dat[j][idx] == q) {
				++idx;
			}
			ans += idx;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <unordered_map>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N, K;
  cin >> N >> K;
  int counter = 0;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h[i];
    if(h[i] >= K) counter++;
  }
  cout << counter << endl;
  
}


Measured memory_bytes: 888
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()
  cw=co(lw).most_common()
  
  ans = 0
  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  lw_tmp = lw[:]
  for j in sorted(lh_c, reverse=True):
    lw_tmp.pop(j)
  if len(lw_tmp) == 0:
    print(ch[0][1])
  else:
    cw_tmp = co(lw_tmp).most_common()
    ans = ch[0][1]+cw_tmp[0][1]
    
    tmp = cw[0][0]
    lw_c = [i for i, x in enumerate(lw) if x == tmp]
    lh_tmp = lh[:]
    for j in sorted(lw_c, reverse=True):
      lh_tmp.pop(j)
    if len(lh_tmp) == 0:
      print(cw[0][1])
    else:
      ch_tmp = co(lh_tmp).most_common()
      ans = max(ans, cw[0][1]+ch_tmp[0][1])
      print(ans)
    


Measured memory_bytes: 141812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1e9;
using namespace std;
int N, M;
bool vis[55];
bool g[55][55];
int A[55], B[55];

void dfs(int n) {
    vis[n] = true;
    rep(i, N) {
        if(vis[i])
            continue;
        if(!g[n][i])
            continue;
        dfs(i);
    }
}

signed main() {
    cin >> N >> M;
    int ans = 0;
    rep(i, N) {
        rep(j, N) { g[i][j] = false; }
    }
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        g[A[i]][B[i]] = true;
        g[B[i]][A[i]] = true;
    }
    rep(i, M) {
        g[A[i]][B[i]] = false;
        g[B[i]][A[i]] = false;
        rep(j, N) vis[j] = false;
        dfs(0);
        bool can = false;
        rep(j, N) {
            if(!vis[j]) {
                can = true;
                break;
            }
        }
        if(can) ans++;
        g[A[i]][B[i]] = true;
        g[B[i]][A[i]] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5,MAX_X=1e5;
ll N,X,psm[MAX_N+2],inx[MAX_N+1];
typedef tuple<ll,ll,ll> TUP;
TUP blu[MAX_N+1];

ll tsm(ll i){
	return get<1>(blu[i])*get<0>(blu[i])+get<2>(blu[i])*(X-get<0>(blu[i]));
}
ll ptsm(ll i,ll n){
	return get<1>(blu[i])*min(n,get<0>(blu[i]))+get<2>(blu[i])*(n-min(n,get<0>(blu[i])));
}
bool C(ll x){
	ll n=x/X,m=x%X;
	ll sm=0;
	REP(i,N+1){
		ll tmp=psm[n];
		if(i<n){
			tmp-=tsm(i);
			tmp+=ptsm(i,m);
			tmp+=tsm(n);
		}else{
			tmp+=ptsm(i,m);
		}
		sm=max(sm,tmp);
	}
	REP(i,N)sm-=get<1>(blu[i])*get<0>(blu[i]);
	return sm>=0;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>X;
	REP(i,N)cin>>get<0>(blu[i])>>get<1>(blu[i])>>get<2>(blu[i]);
	blu[N]=make_tuple(0,0,0);
	REP(i,N+1)inx[i]=i;
	sort(blu,blu+N+1,[](TUP x,TUP y){
		return get<1>(x)*get<0>(x)+get<2>(x)*(X-get<0>(x))
			>get<1>(y)*get<0>(y)+get<2>(y)*(X-get<0>(y));
	});
	psm[0]=0;
	REP(i,N+1){
		psm[i+1]=psm[i]+tsm(i);
	}
	ll lb=-1,ub=N*X;
	while(ub-lb>1){
		ll m=(lb+ub)>>1;
		if(C(m)){
			ub=m;
		}else{
			lb=m;
		}
	}
	cout<<ub<<endl;
}

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long
#define ld double

using namespace std ;

const int MAXN = 1001 * 1001 ; 

int a[MAXN] ; 

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n ; 
	cin >> n ; 
	n *= 3 ; 
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i] ; 
	int ans = -1e18 ; 
	multiset<int> s1 , s2 , s3 ; 
	int m = n / 3 ; 
	int sum1 = 0 , sum2 = 0 ; 
	for(int i = 0 ; i < n ; i ++ ) s2.insert(a[i]) , sum2 += a[i] ; 
	while(s2.size()>m)
	{
		sum2 -= *s2.rbegin() ;
		s3.insert(*s2.rbegin()) ; 
		s2.erase(s2.find(*s2.rbegin())) ; 
	}
	for(int i = 0 ; i < 2 * m ; i ++ ) 
	{
		s1.insert(a[i]) ; 
		sum1 += a[i] ; 
	//	cout <<'*'<< sum1 << ' ' << i << endl ; 
		if(s3.find(a[i])!=s3.end()) s3.erase(s3.find(a[i])) ; 
		else s2.erase(s2.find(a[i])) , sum2 -= a[i] ; 	
		while(s1.size()>m)
		{
			sum1 -= *s1.begin() ; 
			s1.erase(s1.find(*s1.begin())) ; 
		}
	//	cout << sum1<< endl ; 
		while(s2.size()<m)
		{
			sum2 += *s3.begin() ; 
			s2.insert(*s3.begin()) ; 
			s3.erase(s3.find(*s3.begin())) ; 
		}
		if(s1.size()>=m)
		{
	//		cout << sum2 << ' ' << sum1 << endl ; 
			ans = max(ans,sum1-sum2) ; 
		}
	}
	cout << ans << endl ; 
}

Measured memory_bytes: 18432
#include<bits/stdc++.h>
using namespace std;
int main(){
string s,t;
  cin>>s>>t;
  map<char,char>M;
  int N=s.size();
  bool x=true;
  for(int i=0;i<N;i++){
  if(!M.count(s.at(i)))
     M[s.at(i)]=t.at(i);
     else{
     if(t.at(i)!=M.at(s.at(i))){
      x=false; break;
     }
     }
  
  }if(!x)
     cout<<"No"<<endl;
     else{
     set<char>S;
       for(auto p:M){
       auto k=p.first;
         auto v=p.second;
         S.insert(v);
       }
       int m=M.size();
       int n=S.size();
       if(m==n)
         cout<<"Yes"<<endl;
       else
         cout<<"No"<<endl;
           }
   return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

vi A;
int d = 0;

int solve(int a, int b, int c) { // A[i - 1], A[i], A[i + 1]
	db(a); db(b); dbl(c);
	if (a > c) {
		swap(a, c);
	}
	int dd = 0;	
	if (b < a) dd = 2 * (a - b);
	else if (c < b) dd = 2 * (b - c);
	return d - dd;
}

int main() {
	int N; cin >> N;
	A.assign(N + 2, 0);
	rep2(i, 1, N + 1) cin >> A.at(i);
	rep(i, N + 1) d += abs(A[i + 1] - A[i]);
	dbl(d);
	dbv(A);
	rep2(i, 1, N + 1) cout << solve(A[i - 1], A[i], A[i + 1]) << endl;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 400100;
const int INF = (int) 1e9;

int n, l[N], r[N], a[N], b[N], pre[N], suf[N];
vector < pair <int, int> > c;

int main() {

	scanf("%d", &n);

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

	int lm = 0;
	int rm = INF;

	for (int i = 0; i < n; i++) {
		lm = max(lm, l[i]);
		rm = min(rm, r[i]);
	}

	int lp = -1;
	int rp = -1;

	for (int i = 0; i < n; i++) {
		if (lm == l[i]) {
			lp = i;
		}
		if (rm == r[i]) {
			rp = i;
		}
	}

	int res = 0;

	for (int i = 0; i < n; i++) {
		if (i != lp && rp != i) {
			res = max(res, r[i] - l[i] + 1 + max(0, rm - lm + 1));
		}
	}

	if (lp == rp) {
		printf("%d\n", res);
		exit(0);
	}

	for (int i = 0; i < n; i++) {
		a[i] = max(0, r[i] - lm + 1);
		b[i] = max(0, rm - l[i] + 1);
		if (i != lp && i != rp) {
			c.push_back(make_pair(a[i], b[i]));
		}
	}

	sort(c.begin(), c.end());

	suf[c.size()] = INF;

	for (int i = c.size() - 1; i >= 0; i--) {
		suf[i] = min(suf[i + 1], c[i].first);
	}

	pre[0] = INF;

	for (int i = 0; i < c.size(); i++) {
		pre[i + 1] = min(pre[i], c[i].second);
	}

	for (int i = c.size(); i >= 0; i--) {
		int u = r[lp] - l[lp] + 1;
		int v = r[rp] - l[rp] + 1;
		u = min(u, suf[i]);
		v = min(v, pre[i]);
		res = max(res, u + v);
	}

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

	return 0;

}

Measured memory_bytes: 6592
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{

    auto S = sread();
    repeat('x').take(S.length).array.writeln();
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;cin >> n >> x;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans=0;
	rep(i,n-1){
		if(a.at(i)+a.at(i+1)>x){
			if(a.at(i+1)>a.at(i)+a.at(i+1)-x){
				ans+=a.at(i)+a.at(i+1)-x;
				a.at(i+1)-=a.at(i)+a.at(i+1)-x;
			}
			else{
				ans+=a.at(i+1);
				ans+=a.at(i)-x;
				a.at(i+1)=0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;

const int MOD = 1e9 + 7;

int n;
long long k;


vector<vector<int>> mul(vector<vector<int>> A, vector<vector<int>> B) {
    vector<vector<int>> C(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                C[i][j] += ((long long) A[i][k] * B[k][j]) % MOD;
                C[i][j] %= MOD;
            }
        }
    }
    return C;
}

/*
vector<vector<int>> mod_pow(vector<vector<int>> A, long long k) {
    if(k % 2 == 1) {
        if (k == 1) return A;
        return mul(mod_pow(A, k - 1), A);
    } else {
        vector<vector<int>> half = mod_pow(A, k / 2);
        return mul(half, half);
    }
}
*/


vector<vector<int>> mod_pow(vector<vector<int>> A, long long k) {
    if (k == 0) {
        vector<vector<int>> ans(n, vector<int>(n, 0));
        for(int i = 0; i < n; ++i) ans[i][i] = 1;
        return ans;
    }
    vector<vector<int>> half = mod_pow(A, k / 2);
    if (k % 2 == 1) {
        return mul(mul(half, half), A);
    } else {
        return mul(half, half);
    }
}

void add_self(int & x, int y) {
    x += y;
    if(x >= MOD) x -= MOD;
}

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    vector<vector<int>> A(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> A[i][j];
        }
    }
    vector<vector<int>> ans = mod_pow(A, k);
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            add_self(cnt, ans[i][j]);
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,s,m,p;
    cin>>a>>b;
    s=a+b;
    m=a*b;
    p=a-b;
    if(s>=m && s>=p){
        cout<<s<<endl;
    }
    else if(m>=p && m>=s){
        cout<<m<<endl;
    }
    else{
        cout<<p<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<n;i++){
		cnt++;
		int j=i+1;
		for(;j<n;j++){
				if(s[i]!=s[j]){
					break;
				}
		}
		i=j-1;
	}
	cout<<cnt<<endl;
}

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

int p[200005];
int r[200005];
int n,m;
int A[200005];
void init(int n) {
  for(int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
  return;
}

int Find(int x) {
  return x == p[x] ? x : p[x] = Find(p[x]);
}

void Union(int x, int y) {
  int a = Find(x);
  int b = Find(y);
  if(a == b) return;
  if(r[a] > r[b]) {
    p[b] = a;
  }
  else {
    p[a] = b;
  if(r[a] == r[b]) r[b]++;
  }
}

int main() {
  cin >> n >> m;
  init(n);
  for(int i = 0; i < n; i++) {
    int p;
    cin >> p;
    p--;
    A[i] = p;
  }
  for(int i = 0; i < m; i++) {
    int x,y;
    cin >> x >> y;
    x--;y--;
    Union(x,y);
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(A[i] == i) {
      ans++;
      continue;
    }
    if(Find(i) == Find(A[i])) {
      ans++;
    }
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 1408
#include <stdint.h>

#include <limits>
#include <vector>

using namespace std;

template <typename T>
struct Edge {
  int64_t from;
  int64_t to;
  T cost;
  Edge(int64_t from_, int64_t to_, T cost_)
      : from(from_), to(to_), cost(cost_) {}

  T From(void) const { return from; }
  T To(void) const { return to; }
  T Cost(void) const { return cost; }
};

template <typename T>
using Edges = vector<Edge<T>>;

template <typename T>
bool BellmanFord(const Edges<T>& es, const int64_t V, const int64_t s,
                 vector<T>* dst, const T kInf = numeric_limits<T>::max()) {
  dst->resize(size_t(V));
  fill(dst->begin(), dst->end(), kInf);

  (*dst)[s] = 0;

  const int64_t E = int64_t(es.size());

  for (int64_t i = 0; i < V; ++i) {
    bool update = false;
    for (int64_t j = 0; j < E; ++j) {
      auto& e = es[j];
      if ((*dst)[e.From()] < kInf &&
          (*dst)[e.To()] > (*dst)[e.From()] + e.Cost()) {
        (*dst)[e.To()] = (*dst)[e.From()] + e.Cost();
        update         = true;
      }
    }
    if (!update) break;
    if (update && i == V - 1) {
      return false;
    }
  }
  return true;
}

#include <iostream>

#ifdef USE_STACK_TRACE_LOGGER
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <glog/logging.h>
#pragma clang diagnostic pop
#endif  //__clang__
#endif  // USE_STACK_TRACE_LOGGER

signed main(int argc, char* argv[]) {
  (void)argc;
#ifdef USE_STACK_TRACE_LOGGER
  google::InitGoogleLogging(argv[0]);
  google::InstallFailureSignalHandler();
#else
  (void)argv;
#endif  // USE_STACK_TRACE_LOGGER
  int64_t V, E, r;
  cin >> V >> E >> r;
  Edges<int64_t> es;
  for (size_t i = 0; i < size_t(E); ++i) {
    int64_t s, t, d;
    cin >> s >> t >> d;

    es.emplace_back(s, t, d);
  }
  vector<int64_t> ds;
  if (BellmanFord(es, V, r, &ds)) {
    for (auto d : ds) {
      if (d < numeric_limits<int64_t>::max())
        cout << d << endl;
      else
        cout << "INF" << endl;
    }
  } else {
    cout << "NEGATIVE CYCLE" << endl;
  }
  return EXIT_SUCCESS;
}


Measured memory_bytes: 3112
<?php
fscanf(STDIN, '%s', $s);
$n = strlen($s);
$arr = [$s[0]];
$s_tmp = '';
for($i = 1; $i < $n; $i++) {
    $m = count($arr);
    $s_tmp = $s_tmp . $s[$i];
    if ($arr[$m-1] !== $s_tmp) {
        $arr[] = $s_tmp;
        $s_tmp = '';
    }
}
$ans = count($arr);
echo $ans . PHP_EOL;

Measured memory_bytes: 19060
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

using llong = long long;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<pair<int,llong>>> graph(n);
  for(int i=0;i<m;++i){
    int a,b;
    llong c;
    cin >> a >> b >> c;
    graph[a-1].emplace_back(b-1,-c);
  }

  llong INF = 100000000000000000;
  vector<llong> dist(n,INF);
  dist[0] = 0;
  for(int cnt=0;cnt<n;++cnt){
    for(int i=0;i<n;++i){
      for(const auto &p:graph[i]){
        if(dist[p.first] > dist[i] + p.second){
          dist[p.first] = dist[i] + p.second;
          if(cnt == n-1 && p.first == n-1){
            cout << "inf" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << -dist[n-1] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
void prime_factorize_counter(int n, map<int, int> & prime)
{
    if (n <= 1)	return;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            prime_factorize_counter(i, prime);
            prime_factorize_counter(n / i, prime);
            return;
        }
    }
    prime[n]++;
    return;
}
int main()
{
    /*string s; cin >> s;
    if (s.back() == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    */

    /*int n; cin >> n;
    bool ans = false;
    int cnt = 0;
    rep(i, n) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) cnt++;
        else cnt = 0;
        if (cnt == 3) ans = true;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    */

    int n; cin >> n;
    int ans = 0;
    map<int, int> primes;
    for (int c = 1; c < n; c++) {
        int right = n - c;
        primes.clear();
        prime_factorize_counter(right, primes);
        if (right == 1) ans++;
        else {
            int tmp = 1;
            for (auto a : primes) tmp *= a.second + 1;
            ans += tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
// this solution belongs to Geothermal

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
    string S; cin >> S;
    bool bad[N+1]; F0R(i, N) bad[i] = S[i] == '1';

    int dist[N+1]; F0R(i, N+1) dist[i] = MX;
    dist[N] = 0;
    int nxt[N+1]; F0R(i, N+1) nxt[i] = -1;
    priority_queue<pi> q;
    q.push({0, -1*N});
    F0Rd(i, N) {
        if (bad[i]) continue;
        while (!q.empty() && -1*q.top().s > i+M) {
            q.pop();
        }
        if (!q.empty()) {
            pi cur = q.top();
            dist[i] = q.top().f * -1 + 1;
            nxt[i] = q.top().s * -1 - i;

        }
        q.push({-1*dist[i], -1*i});
    }

    if (dist[0] >= MX) {
        cout << -1 << endl; return 0;
    }

    int X = 0;
    while (X < N) {
        cout << nxt[X] << " ";
        X += nxt[X];
    }
    cout << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 2296
#include <iostream>

using namespace std;

int main() {
  string s, t;
  unsigned long count = 0;
  cin >> s >> t;
  
  for (unsigned long i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) count++;
  }
  
  cout << count;
  
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s, t;
    cin>>s>>t;
    int n = s.size();
    string tmp = t.substr(0, n);
    if(tmp==s) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C;
	bool ans;

	cin >> A >> B >> C;

	if ((A == B && B != C) ||
		(B == C && C != A) ||
		(C == A && A != B)) ans = true;
	else ans = false;

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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

string s;
char buf[500010];
int fail1[500010], fail2[500010]; 
int n;

void getfail(string &s, int *fail){
	fail[0] = -1;
	int j = -1;
	for (int i = 1; i <= n; i++){
		while (~j && s[j] != s[i - 1]) j = fail[j];
		fail[i] = ++j;
	}
}

int main(){
	scanf("%s", buf), s = buf;
	n = s.length();
	getfail(s, fail1);
	int len = n % (n - fail1[n]) == 0 && (n - fail1[n] <= n / 2) ? n - fail1[n] : -1;
	if (len == -1){
		printf("1\n1\n");
		return 0;
	}
	if (len == 1){
		printf("%d\n1\n", n);
		return 0;
	}
	printf("2\n");
	reverse(s.begin(), s.end());
	getfail(s, fail2);
	int ans = 0;
	for (int i = 1; i < n; i++){
		if ((!fail1[i] || i % (i - fail1[i])) && (!fail2[n - i] || (n - i) % ((n - i) - fail2[n - i]))) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<ll> yakusu(ll n){
  vector<ll> ret;
  for(ll p = 1; p*p <= n; p++){
    if(n%p == 0){
      ret.push_back(p);
      if(p*p != n){
        ret.push_back(n/p);
      }
    }
  }
  sort(all(ret));
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  string s;cin>>s;
  int n = s.size();
  auto sa = atcoder::suffix_array(s);
  auto lcp = atcoder::lcp_array(s, sa);
  ll ans = 0;
  rep(t,n){
    int i = sa[t];
    int len = n - i;
    if(t==0){
      ans += len;
    }else{
      int l = lcp[t-1];
      ans += len - l;
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 15600
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a, b;
 cin >> a >> b;
//scanf("%d %d", &a, &b);
long long r = a*b;
   if(r%2 == 0){
   //printf
       cout << "Even\n";
   }
   else{
   cout << "Odd\n";
   
   }

}

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

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

    long long b = a[0];
    long long cnt = 1, ans = 0;
    for (int i = 1; i < n; i++) {
        if (b == a[i]) cnt++;
        else {
            if (cnt % 2 == 1) ans++;
            b = a[i];
            cnt = 1;
        }
    }
    if (cnt % 2 == 1) ans++;

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

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> pic(H + 2, vector<char>(W + 2, '#'));
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            cin >> pic[i][j];
        }
    }
    for (int i = 0; i < H + 2; i++)
    {
        for (int j = 0; j < W + 2; j++)
            cout << pic[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256