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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  string s;

  cin >> s;

  if (int(s.find('9')) == -1) printf("No\n");
  else printf("Yes\n");
}


Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = read_vec();
    let mut b: Vec<i64> = read_vec();

    let mut ans = 0;

    for i in 0..n {
      // i番目のモンスターを倒せるだけ倒す
      if a[i] > b[i] {
          ans += b[i];
          a[i] -= b[i];
          b[i] = 0;

      } else {
        ans += a[i];
        b[i] -= a[i];
        a[i] = 0;
      }

      // i+1番目のモンスターを出来るだけ倒す
      if a[i+1] > b[i] {
          ans += b[i];
          a[i+1] -= b[i];
          b[i] = 0;

      } else {
        ans += a[i+1];
        b[i] -= a[i+1];
        a[i+1] = 0;
      }
    }

    println!("{}", ans);
}


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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

#define F first
#define S second

//((time, pre_node), (power, node))
typedef pair<pair<double, int>, pii> State;

int main(void){
    for(int n, m; cin >> n >> m, n;){
        int s, z; cin >> s >> z;
        s--, z--;

        // (to, (length, limited_power))
        vector<vector<pair<int, pii>>> edge(n);
        rep(i, m){
            int x, y, d, c; cin >> x >> y >> d >> c;
            x--, y--;

            edge[x].pb(mp(y, mp(d, c)));
            edge[y].pb(mp(x, mp(d, c)));
        }

        priority_queue<State, vector<State>, greater<State>> q;
        for(auto e : edge[s]){
            q.push(mp(mp((double)e.S.F, s), mp(1, e.F)));
        }

        // [pre_node][power][node]
        vector<vector<vector<double>>> minDist(n, vector<vector<double>>(31, vector<double>(n, (double)inf)));
        while(!q.empty()){
            double cur_time = q.top().F.F;
            int cur_prev = q.top().F.S;
            int cur_power = q.top().S.F;
            int cur_v = q.top().S.S;
            q.pop();

            if(minDist[cur_prev][cur_power][cur_v] < (double)inf - eps) continue;

            minDist[cur_prev][cur_power][cur_v] = cur_time;

            int next_prev = cur_v;

            range(next_power, max(1, cur_power - 1), cur_power + 2){
                for(auto e : edge[cur_v]){
                    int next_v = e.F;
                    if(next_v == cur_prev || e.S.S < next_power || minDist[next_prev][next_power][next_v] < (double)inf - eps){
                        continue;
                    }
                    double next_time = cur_time + (double)e.S.F / next_power;

                    q.push(mp(mp(next_time, next_prev), mp(next_power, next_v)));
                }
            }
        }

        double res = (double)inf;
        rep(i, n){
            res = min(res, minDist[i][1][z]);
        }

        if(res >= (double)inf - eps) cout << "unreachable" << endl;
        else                         printf("%.5f\n", res);
    }

	return 0;
}

Measured memory_bytes: 14148
#include <iostream>
#include <algorithm>

int main()
{
    int a;
    std::cin>>a;
    int b[a];
    for(int i=0;i<a;i++){
      std::cin>>b[i];
    }
    std::sort(b, b + a);

    for(int j=1;j<=b[0];j++){
    bool cler=true;
    for(int i=0;i<a;i++){
      if(b[i]%j!=0) cler=false;
    }
    if(cler==true) std::cout << j<<std::endl;
  }


}



Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
using namespace std;

char str[]="^v<>";

void shot(vector<string> &m,int x,int y,int dir)
{
	static int dx[]={0,0,-1,1};
	static int dy[]={-1,1,0,0};
	
	while(true){
		x+=dx[dir];
		y+=dy[dir];
		if( x<0 || y<0 || x>=m[0].length() || y>=m.size()) break;
		if( m[y][x]=='*' ){
			m[y][x]='.';
			break;
		}		
		if( m[y][x]=='#' ){
			break;
		}		
	}
	return;
}

bool f(vector<string> &m,int x,int y)
{
	if( x<0 || y<0 || x>= m[0].length() || y>=m.size()) return false;
	return m[y][x]=='.';
}

int main() {
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int H,W;
		cin >> H >> W;
		vector<string> m(H);
		for(int h=0;h<H;h++){
			cin >> m[h];
		}
		int sx,sy,dir;
		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				char c=m[y][x];
				char *p=strchr(str,c);
				if(p){
					sx=x;
					sy=y;
					dir = p-str;
					m[y][x]='.';
					
//					cout << sx << "," << sy << "," << dir << endl;;
				}
			}
		}
		int n;
		cin >> n;
		for(int j=0;j<n;j++){
			char c;
			cin >> c;
			switch(c){
				case 'U':
					dir = 0;
					if(f(m,sx,sy-1)){
						sy--;
					}
					break;
				case 'D':
					dir = 1;
					if(f(m,sx,sy+1)){
						sy++;
					}
					break;
				case 'L':
					dir = 2;
					if(f(m,sx-1,sy)){
						sx--;
					}
					break;
				case 'R':
					dir = 3;
					if(f(m,sx+1,sy)){
						sx++;
					}
					break;
				case 'S':
					shot(m,sx,sy,dir);
					break;
			}
		}
		if(i!=0){
			cout << endl;
		}
		m[sy][sx]=str[dir];
		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				char c=m[y][x];
				cout << c;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + (x[j]**2)*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])

Measured memory_bytes: 68328
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 X,Y;
    cin >> X >> Y;
    if(abs(X-Y)<=1) cout << "Brown" << bn;
    else cout << "Alice" << bn;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	a, b := readInt(), readInt()

	d := n / (a + b)
	r := n % (a + b)

	ans := 0
	if a > r {
		ans = d*a + r
	} else {
		ans = d*a + a
	}
	fmt.Println(ans)
}


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

int store[5][5];

int main()
{
    int a1, a2, a3;
    int b;
    for (int i = 1; i <= 3; i++) for (int j = 1; j <= 3; j++) cin >> store[i][j];

    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            if (i == 1) {
                a1 = store[1][1];
                a2 = store[1][2];
                a3 = store[1][3];
            }
            else {
                if (j == 1) b = a1 - store[i][j]; /// cout << "1. " << b << endl;
                else if (j == 2) {if (a2 - store[i][j] != b) {printf("No\n"); return 0;}} ///cout << "2. " << a2 - store[i][j] << endl;
                else if (j == 3) {if (a3 - store[i][j] != b) {printf("No\n"); return 0;}} ///cout << "3. " << a3 - store[i][j] << endl;
            }
        }
    }

    printf("Yes\n");
}


Measured memory_bytes: 256
// ~maqsat~
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n";
#define TEZ ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout);
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> inline void cmin(T &a, U b) { a = min(a, b); }
template <class T, class U> inline void cmax(T &a, U b) { a = max(a, b); }
template <class T, class U, class X, class Y> inline void psmn(T &a, U b, X &p, Y i) { if(b < a)a = b,p = i; }
template <class T, class U, class X, class Y> inline void psmx(T &a, U b, X &p, Y i) { if(b > a)a = b,p = i; }
 
const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
 
int main() {
	fre(""); TEZ;

	int n;
	cin >> n;
	int a[150];
	for(int i = 0; i < n-1; i++) cin >> a[i];
	vi ans;
	ans.pb(a[0]);
	for(int i = 0; i < n-2; i++) {
		ans.pb(min(a[i], a[i+1]));
	}
	ans.pb(a[n-2]);
	int sum = 0;
	for(int i = 0; i < sz(ans); i++) sum += ans[i];
	cout << sum;

	return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int v[n],c[n];
	for(int i=0;i<n;i++)
		cin>>v[i];
	for(int i=0;i<n;i++)
		cin>>c[i];
	int max_val=INT_MIN;
	for(int i=0;i<=pow(2,n);i++){
		vector<pair<int,int>>vals;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				vals.push_back(make_pair(v[j],c[j]));
			}
		}
		int values=0,cost=0;
		for(int j=0;j<vals.size();j++){
			values+=vals[j].first;
			cost+=vals[j].second;
		}
		max_val=max(max_val,values-cost);
	}
	cout<<max_val;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
s = input()
sset = set(s)
c = 0
for i in range(n):
    s1 = s[:i]
    s2 = s[i:]
    clst = [1 for i in sset if s1.count(i) > 0 and s2.count(i) > 0]
    tc = sum(clst)
    if tc > c:
        c = tc
print(c)

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

int n, h, w, a[1000], b[1000], ta = 0;

int main() {
	cin >> n >> h >> w;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++) {
		if (h <= a[i] && w <= b[i]) {
			ta++;
		}
	}
	cout << ta << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{

   
    int n;
    cin>>n;
    double prob[n];
	double dp[n+1][n+1];
    for(int i=0;i<n;i++)
    {
    	cin>>prob[i];
	}
	dp[0][0]=1;
	for(int i=1;i<n+1;i++)
	{
		dp[0][i]=0*1.0;
	}
	dp[1][0]=1-prob[0];
	for(int i=2;i<n+1;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-prob[i-1]);
	}
	for(int i=1;i<n+1;i++)
	{
		for(int j=1;j<n+1;j++)
		{
			if(j>i)
			{
				dp[i][j]=0;
			}
			else
			{
				dp[i][j]=dp[i-1][j]*(1-prob[i-1])+dp[i-1][j-1]*prob[i-1];
			}
			
		}
	}
/*	for(int i=0;i<n+1;i++)
	{
		for(int j=0;j<n+1;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	double s=0;
	for(int i=(n+2)/2;i<(n+1);i++)
	{
		s+=dp[n][i];
	}
	printf("%.10f",s);
}



Measured memory_bytes: 70528
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>
#include <iomanip>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 'Z'+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....

signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        int l,r,d;
        cin>>l>>r>>d;
        int ans=r/d;
        ans-=(l-1)/d;
        cout<<ans;
    }
}

Measured memory_bytes: 3144
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int Maxn = 12;
const int Maxm = 1000;
const int INF = 0x3f3f3f3f;

int N, M;
struct Node {
	int A, C;
};
Node A[100000 + 5];

int f[Maxm + 5][(1 << Maxn) + 5];

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d" ,&N, &M);
	for(int i = 1; i <= M; i++) {
		int x;
		scanf("%d %d", &A[i].A, &x);
		int t = 0;
		for(int j = 1; j <= x; j++) {
			int tmp;
			scanf("%d", &tmp);
			t |= (1 << (tmp - 1));
		}
		A[i].C = t;
	}
	memset(f, 0x3f, sizeof f);
	f[0][0] = 0;
	for(int i = 1; i <= M; i++) {
		for(int s = 0; s < (1 << N); s++) {
			int s1 = s | A[i].C;
			f[i][s1] = min(f[i][s1], f[i - 1][s] + A[i].A);
			f[i][s] = min(f[i][s], f[i - 1][s]);
		}
	}
	if(f[M][(1 << N) - 1] != INF)printf("%d\n", f[M][(1 << N) - 1]);
	else puts("-1");
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y) {
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
      ll n;
      cin >> n;
      map<char,int> mp;
      int cnt = 0;
      for(int i=0; i<n; i++)
      {
          char val;
          cin >> val;
          if(!mp[val])cnt++;
          mp[val]++;

      }
      if(cnt==3)cout << "Three" << endl;
      else cout << "Four" << endl;
}


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


#define INF 1000000000000

signed main()
 {
int k,a,b;
cin>>k>>a>>b;
rep(i,1000){
  if(k*i>=a&&k*i<=b){cout<<"OK";exit(0);}
}
cout<<"NG";
}


Measured memory_bytes: 3636
x, y = map(int, input().split())
mod = 10**9+7

def comb(n,r,mod, g):
    if r < 0 or n < r: return 0
    return g[n] * pow(g[r], mod-2, mod) * pow(g[n-r], mod-2, mod) % mod

def cmb_mod(n, r, mod):
    g = [1,1]
    for i in range(2, n+1):
        g.append( (g[-1] * i) % mod)
    return comb(n, r, mod, g)

if (x+y) % 3 != 0:
    print('0')
else:
    n = (2 * y - x)
    m = (2 * x - y)
    if (n % 3 != 0 or m % 3 != 0) or (n < 0 or m < 0):
        print('0')
    else:
        n = n // 3
        m = m // 3
        print(cmb_mod(n+m, min(n, m), mod))


Measured memory_bytes: 86512
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}

const int MAX_NUM = 10;

bool checklast2(stack<int> st1, stack<int> st2) {
    if (st1.size() > 1) {
        int top, second;
        top = st1.top(); st1.pop();
        second = st1.top();
        if (top < second) return false;
    }
    if (st2.size() > 1) {
        int top, second;
        top = st2.top(); st2.pop();
        second = st2.top();
        if (top < second) return false;
    }
    return true;
}

bool dfs2(stack<int> st1, stack<int> st2, vector<int> v, int size);

bool dfs1(stack<int> st1, stack<int> st2, vector<int> v, int size) {
    if (size == MAX_NUM) {
        if (!checklast2(st1, st2)) return false;
        else return true;
    }else {
        if (!checklast2(st1, st2)) return false;
    }
    st1.push(v[size]);
    if (dfs1(st1, st2, v, size+1)) {//
        return true;
    }else {
        return dfs2(st1, st2, v, size+1);
    }
}

bool dfs2(stack<int> st1, stack<int> st2, vector<int> v, int size) {
    if (size == MAX_NUM) {
        if (!checklast2(st1, st2)) return false;
        else return true;
    }else {
        if (!checklast2(st1, st2)) return false;
    }
    st2.push(v[size]);
    if (dfs1(st1, st2, v, size+1)) {//
        return true;
    }else {
        return dfs2(st1, st2, v, size+1);
    }
}

void solve33() {
    stack<int> st1;
    stack<int> st2;
    vector<int> v;
    PUSH(MAX_NUM,v);
    if (dfs1(st1, st2, v, 0)) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        solve33();
    }
    return 0;
}

Measured memory_bytes: 1244
import java.util.Scanner;

public class Main {

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

	    int A=gi();
	    int B=gi();

	    if ((A-B) % 2==0) {
	    	System.out.print((A+B)/2);
	    } else {
	    	System.out.print("IMPOSSIBLE");
	    }
        //System.out.println((int)(K* Math.pow(K-1, N-1)));
//        if (a<=c&&c<=b) {
//        	System.out.print("Yes");
//        }else{
//        	System.out.print("No");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35480
def cross_product(a,b):
  return (a.conjugate()*b).imag
n = int(input())
for i in range(n):
    A = list(input().split())
    B = []
    for i in A:
        #print(i)
        if '.' not in i:
            #print('you',i)
            j = int(i)*(10**5)
        elif '-' not in i:
            #print('meiyou',i)
            p,q = i.split('.')
            j = int(p)*(10**5)+int(q)*10**(5-len(q))
        else:
            #print('youmeiyou',i)
            p,q = i.split('.')
            j = int(p)*(10**5)-int(q)*10**(5-len(q))
        #print(j)
        B.append(j)
    #print(B)
    u = complex(B[2]-B[0],B[3]-B[1])
    v = complex(B[6]-B[4],B[7]-B[5])
    #print(abs(cross_product(u,v)))
    if abs(cross_product(u,v)) == 0:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 5616
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            int[] Dn = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
            long sum = 0L;
            for (var i = 0; i < N; i++)
            {
                for (var j = i + 1; j < N; j++)
                {
                    sum += Dn[i] * Dn[j];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

ll lev[100],A[100][100],N,M,X,C[100],sol=1ll<<60,cont,c;

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> M >> X;

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

    for(int i=1;i<1 << N;i++){
        for(int j=0;j<N;j++)
            if(i & (1 << j) ){
               for(int k=0;k<M;k++)
                  lev[k]+=A[j][k];
               c+=C[j];
            }
        for(int j=0;j<M;j++){
            if(lev[j]>=X)
                cont++;
            lev[j]=0;
        }
        if(cont == M)
            sol = min(sol,c);

        cont = c = 0;
    }

    if(sol == 1ll << 60)
        sol = -1;
    cout << sol;







}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  vector<long long> A(N);
  priority_queue<pair<long long, long long> > q;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
    q.push(make_pair(A[i], 1));
  }
  vector<long long> B(M), C(M);
  for(int i = 0; i < M; ++i) {
    cin >> B[i] >> C[i];
    q.push(make_pair(C[i], B[i]));
  }
  int cnt = 0;
  long long ans = 0;
  while(cnt < N) {
    ans += q.top().first;
    if(q.top().second > 1) {
      pair<long long, long long> tmp = make_pair(q.top().first, q.top().second-1);
      q.pop();
      q.push(tmp);
    } else {
      q.pop();
    }
    cnt++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8688
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] x = new int[n];
      	int[] y = new int[n];
		for(int i=0; i<n; i++){
			x[i] = scn.nextInt();
          	y[i] = scn.nextInt();
		}
      	double nnn = 1;
      	for(int i=1; i<=n; i++){
          nnn*=i;
        }
      	double way=0;
      	for(int i=1; i<n; i++){
          way+=i;
        }
      	double count = nnn*(n-1)/way;
    	double ave = 0;
		for(int i=0; i<n; i++){
      		for(int j=i+1; j<n; j++){
         		ave+=(Math.sqrt(Math.pow(Math.abs(x[i]-x[j]),2)+Math.pow(Math.abs(y[i]-y[j]),2)))/nnn;
     		 }
    	}
    	ave*=count;
    	System.out.println(ave);
      	
	}
}


Measured memory_bytes: 36096
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

X, Y = map(int, input().split())

for x in range(0, X+1):
    leg = 2*x + 4*(X-x)
    if Y == leg:
        print('Yes')
        exit()
else:
    print('No')

Measured memory_bytes: 65260
from collections import Counter
N,M = map(int,input().split())
X = list(map(int,input().split()))
c = Counter(X)
pair = [0]*M
num = [0]*M
for i in range(1,10**5+1):
    rem = i % M
    pair[rem] += c[i]//2
    num[rem] += c[i]
ans = 0
for i in range(M//2+1):
    j = (M-i) % M
    if i == j:
        ans += num[i]//2
    else:
        if num[i] > num[j]:
            i,j = j,i
        ans += num[i]
        ans += min(pair[j],(num[j]-num[i])//2)
print(ans)

Measured memory_bytes: 91944
#include <stdio.h>

int main(void) {
	int n, ar[100], i;
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%d", &ar[i]);
	}
	for(i = 0; n > i; i++){
		printf("%d", ar[n-1-i]);
		if(i != n-1)
		printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

bool foo1(char t){
	if('A'<=t&&t<='Z') return true;
	return false;
}

int main(){
	string s;
	char t;
	while(cin>>s>>t,t!='X'){
		vector<string> vs;
		int x=0;
		rep(i,s.size()){
			if(i==0) continue;
			if(foo1(s[i])){
				vs.PB(s.substr(x,i-x));
				x=i;
			}
			else if(s[i]=='_'){
				vs.PB(s.substr(x,i-x));
				x=i+1;
			}

		}
		vs.PB(s.substr(x));
		rep(i,vs.size()){
			rep(j,vs[i].size()){
				if(foo1(vs[i][j])){
					vs[i][j]+='a'-'A';
				}
			}
		}
		if(t=='U'){
			rep(i,vs.size()){
				vs[i][0]+='A'-'a';
				cout<<vs[i];
			}
			// cout<<endl;
		}
		else if(t=='L'){
			rep(i,vs.size()){
				if(i) vs[i][0]+='A'-'a';
				cout<<vs[i];
			}
		}
		else if(t=='D'){
			rep(i,vs.size()){
				if(i){
					cout<<"_";
				}
				cout<<vs[i];
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1196
S = input()
T = input()


S = list(S)
T = list(T)


def check(S,T):
    len_S = len(S)
    len_T = len(T)

    for i in range(len_S):
        if S[i] != T[i]:
            return "No"

    return "Yes"

result = check(S,T)
print(result)

Measured memory_bytes: 9028
package main

import (
        "bufio"
        . "fmt"
        "os"
        "strconv"
)

func init() {
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
                panic(e)
        }
        return i
}
func main() {
        sc.Split(bufio.ScanWords)
        a, b := nextInt(), nextInt()
        if a == b {
                Printf("a == b\n")
        } else if a < b {
                Printf("a < b\n")
        } else {
                Printf("a > b\n")
        }
}


Measured memory_bytes: 1100
def submit():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    pos = {i: 0 for i in range(n)}
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1

        if h[a] > h[b]:
            pos[b] += 1
        elif h[a] < h[b]:
            pos[a] += 1
        else:
            pos[a] += 1
            pos[b] += 1


    ans = sum(map(lambda x: x == 0, pos.values()))
    print(ans)


submit()

Measured memory_bytes: 33168
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    v = list()

    for i in map(int, input().split()):
        v.append(i)

    v.sort()

    ans = v[0]
    for i in range(1, n):
        ans = (ans + v[i]) / 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String T = sc.next();		
		int a = sc.nextInt();
		int b = sc.nextInt();
		String U = sc.next();
      
		if(S.equals (U)) {
			a--;
		}else {
			b--;
		}
		
		System.out.print(a+" "+b);
		

	}

}



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

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

int main()
{
    int n;
    cin>>n;
    long long ans=0;
    int a;
    for(int i=1;i<=n;i++)
    {

        for(int j=1;j<=n;j++)
        {
            a=gcd(j,i);
            for(int k=1;k<=n;k++)
            {
                ans+=k>a?gcd(k,a):gcd(a,k);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		while (true ){
		String str = br.readLine();
		int a = Integer.parseInt(str);
		if (a == 0 ) break;
		list.add(a);
		}
		
		for (int i = 1 ; i-1 < list.size() ; i++){
			System.out.println("Case " + i + ": " + list.get(i-1));
		}

	}

}

Measured memory_bytes: 27880
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector <int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin() , a.end());
    for(int i = 0; i < 2; i++){
        cout << a.at(i) << ' ';
    }
    cout << a.at(2) << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 100005
#define endl "\n"
#define mod 1000000007
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,c; vector<ll> vc[N]; ll cl[N]; ll an=0;
void dfs(ll i,ll par){
		
	ll k=(c-2);
	for(auto it:vc[i]){
		if(it==par) continue;

		an=((an%mod)*(k%mod))%mod;
		k--;
		dfs(it,i);
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>c;

	for(i=1;i<n;i++){
		cin>>k>>l;
		vc[k].ps(l);
		vc[l].ps(k);
	}
	if(n==1){
		cout<<c<<endl;return 0;
	}

	an=c;
	k=c-1;
	for(auto it:vc[1]){
		an=((an%mod)*(k%mod))%mod;
		k--;
		dfs(it,1);
	}
	cout<<an;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) cout << c;
  if (a == c) cout << b;
  if (b == c) cout << a;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3608
import sys
n = int(sys.stdin.readline())
ab = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
now = 0
for t in ab:
    now += t[0]
    if now > t[1]:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 53616
#pragma gcc optimize("Ofast")
#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(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  VIN(A)
  OUT(VSUM(A) - n);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr LL kInf = 1e18;
constexpr LL kNegativeLoop = -kInf;

struct Edge {
  int from;
  int to;
  LL cost;
};

// detect closed-loop -> return false,  else return true.
vector<LL> belman_ford(int s, int V, const vector<Edge>& es) {
  vector<LL> d(V, kInf);
  d[s] = 0;

  for (int i = 0; i < 2 * V; ++i) {
    bool update = false;
    for (const Edge& e : es) {
      if (d[e.from] == kInf) continue;
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = (i < V - 1) ? d[e.from] + e.cost
                              : kNegativeLoop;
        update = true;
      }
    }
    // finish
    if (!update) {
      break;
    }
  }
  return d;
}

int main() {
  int N, M, P; cin >> N >> M >> P;
  vector<Edge> es(M);
  for (int i = 0; i < M; ++i) {
    int A, B, C; cin >> A >> B >> C;
    --A, --B;
    es[i] = {A, B, -(C-P)};
  }

  auto d = belman_ford(0, N, es);
  if (d[N-1] != kNegativeLoop) {
    cout << max(0LL, -d[N-1]) << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

long long n, mina = 10000, ans = 0;

class nim{
public:
  long long v, id;
  bool operator<(const nim &another) const{
    return v < another.v;
  }
};

long long func(vector<long long> t){
  long long mint = 10000, sum = 0, ret;
  for(int i = 0; i < t.size(); i++){
    sum += t[i];
    mint = min(t[i], mint);
  }
  ret = sum + mint * (t.size() - 2);
  return ret;
}

long long func2(vector<long long> t){
  long long mint = 10000, sum = 0, ret;
  for(int i = 0; i < t.size(); i++){
    sum += t[i];
    mint = min(t[i], mint);
  }
  ret = sum + mina * (t.size()) + mina + mint;
  return ret;
}

void solve(){
  cin >> n;
  vector<nim> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i].v;
    a[i].id = i;
    mina = min(a[i].v, mina);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if(a[i].v == -1) continue;
    int y = a[i].id;
    vector<long long> t;
    t.push_back(a[i].v);
    while(a[y].v != a[i].v){
      t.push_back(a[y].v);
      a[y].v = -1;
      y = a[y].id;
    }
    a[i].v = -1;
    ans += min(func(t), func2(t));
  }
  cout << ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = 2 * c*max(x, y);
	for (int i = 0; i <= max(x, y);i++) {
		int cost = 2 * c*i + a * max(0, x - i) + b * max(0, y - i);
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

struct edge {
	ll from;
	ll to;
	ll cost;

	bool operator < (const edge& x) const {//コストの順番にソート出来る。今回は不要。
		return cost < x.cost;
	}
};

bool Bellman_Ford(int start,int E,int V,vector<edge> Edge,vector<ll> &d) {//V:頂点数 E:辺数 
	fill(d.begin(), d.end(), LONGINF);
	d[start] = 0;
	vector<bool> t(V,false);

	for (int i = 0; i < V - 1; i++) {
		for (int j = 0; j < E; j++) {
			edge e = Edge[j];
			if (d[e.from] == LONGINF) { continue; }
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
			}
			if (t[e.from]) {
			}
		}
	}

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < E; j++) {
			edge e = Edge[j];
			if (d[e.from] == LONGINF) { continue; }
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				t[e.to] = true;
			}
			if (t[e.from]) {
				t[e.to] = true;
			}
		}
	}
	if (t[V - 1]) {
		return false;
	}
	return true;
}

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> g(n);
	vector<edge> e(m);
	
	for (int i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--; c = c * (-1);
		g[a].emplace_back(b);
		e[i].from = a;
		e[i].to = b;
		e[i].cost = c;
	}
	vector<ll> d(n);
	if (Bellman_Ford(0, m, n, e, d)) {//閉路検出(無限ループでinf)なし
		cout << -1*d[n - 1] << endl;
	}
	else {//閉路検出した
		cout << "inf" << endl;
	}

	return 0;
}

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

class Dice {
    public:
        int *num;

        Dice(int *n) {
            num = n;
        }

        void move(char c) {
            int n[6];
            for (int i = 0; i < 6; i++) {
                n[i] = num[i];
            }
            if (c == 'N') {
                num[0] = n[1];
                num[1] = n[5];
                num[4] = n[0];
                num[5] = n[4];
            } else if (c == 'S') {
                num[0] = n[4];
                num[1] = n[0];
                num[4] = n[5];
                num[5] = n[1];
            } else if (c == 'W') {
                num[0] = n[2];
                num[2] = n[5];
                num[3] = n[0];
                num[5] = n[3];
            } else {
                num[0] = n[3];
                num[2] = n[0];
                num[3] = n[5];
                num[5] = n[2];
            }
        }
};

int main() {
    int a[6], b[6];
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < 6; i++) {
        cin >> b[i];
    }
    Dice ad(a);
    Dice bd(b);


    for (int j = 0; j < 4; j++) {
        if (ad.num[1] == bd.num[1]) break;
        ad.move('S');
    }
    if (ad.num[1] != bd.num[1]) {
        ad.move('W');
        for (int j = 0; j < 4; j++) {
            if (ad.num[1] == bd.num[1]) break;
            ad.move('S');
        }
    }
    while (ad.num[0] != bd.num[0]) {
        ad.move('W');
    }
    bool result = true;
    for (int i = 0; i < 6; i++) {
        result = result && (ad.num[i] == bd.num[i]);
    }
    if (result) cout << "Yes"; else cout << "No";
    cout << endl;
}

Measured memory_bytes: 1160
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n, a, b;
  cin >> n >> a >> b;
  if (a + b - 1 > n || a * b < n) {
    cout << -1 << endl;
    return 0;
  }
  if (a == 1) {
    assert(b == n);
    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 1);
    reverse(ans.begin(), ans.end());
    printv(ans);
    return 0;
  }
  if (b == 1) {
    assert(a == n);
    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 1);
    printv(ans);
    return 0;
  }
  queue<int> que;
  for (int i = n; i >= 1; i--) que.push(i);
  vector<int> ans;
  if ((n - b) % (a - 1) == 0) {
    int k = (n - b) / (a - 1);
    for (int i = 0; i < k; i++) {
      vector<int> tmp;
      for (int j = 0; j < a; j++) {
        tmp.push_back(que.front());
        que.pop();
      }
      reverse(tmp.begin(), tmp.end());
      for (auto v : tmp) ans.push_back(v);
    }
    while (!que.empty()) {
      ans.push_back(que.front());
      que.pop();
    }
    assert(ans.size() == n);
    printv(ans);
    return 0;
  }
  int m = (n - b + 1) % (a - 1);
  if (m == 0) {
    m = a - 1;
  }
  int k = (n - b - m + 1) / (a - 1);
  for (int i = 0; i < k; i++) {
    vector<int> tmp;
    for (int j = 0; j < a; j++) {
      tmp.push_back(que.front());
      que.pop();
    }
    reverse(tmp.begin(), tmp.end());
    for (auto v : tmp) ans.push_back(v);
  }
  {
    vector<int> tmp;
    for (int i = 0; i < m; i++) {
      tmp.push_back(que.front());
      que.pop();
    }
    reverse(tmp.begin(), tmp.end());
    for (auto v : tmp) ans.push_back(v);
  }
  while (!que.empty()) {
    ans.push_back(que.front());
    que.pop();
  }
  assert(ans.size() == n);
  printv(ans);
}


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

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

	int n,a[200001],b[200001],t,maxi,i,j;
	bool f;
	cin>>n;
	for(i=0;i<n;++i){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n,greater<int>());
	for(i=0;i<n;++i){
		f=0;
		for(j=0;j<n;++j)
			if(a[i]==b[j]&&!f){
				f=1;
			}
			else if((a[i]==b[j]&&f)||(a[i]!=b[j])){
				cout<<b[j]<<endl;
				break;
			}
	}
	return 0;
}


Measured memory_bytes: 3200
from collections import deque

N, M = map(int, input().split())

in_node = [0 for i in range(N+1)]
G = [[] for i in range(N+1)]

for _ in range(M):
    x, y = map(int, input().split())
    G[x].append(y)
    in_node[y] += 1

que = deque()

dp = [0 for i in range(N+1)]

for i in range(1, N+1):
    if in_node[i] == 0:
        que.append(i)

while que:
    x = que.popleft()
    for child_node in G[x]:
        dp[child_node] = max(dp[child_node], dp[x]+1)
        in_node[child_node] -= 1
        if in_node[child_node] == 0:
            que.append(child_node)

ans = max(dp)

print(ans)

Measured memory_bytes: 94580
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n, a, w, t, r;
    n = a = w = t = r = 0;
  	string str;
    cin >> n;
    while (n-- > 0) {
    	cin >> str;
      	if (str == "AC") {
        	a++;
        } else if (str == "WA") {
        	w++;
        } else if (str == "TLE") {
        	t++;
        } else if (str == "RE") {
        	r++;
        }
    }
  	cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

Measured memory_bytes: 3640
s = int(input())
k = len(str(s))-1
x1 = 0
y1 = 0
x2 = 0
y2 = 0
if k >= 10:
    x1 = 10**9
    if s%x1 == 0:
        y2 = int(s//x1)
    else:
        y2 = int(s//x1)+1
    x2 = x1*y2-s
    y1 = 1
else:
    x1 = s
    y2 = 1

print(0,0,x1,y1,x2,y2)

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

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

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

	//calculation
	int output = A[0] + K - A[N - 1];
	for (int i = 0; i < N - 1; i++) {
		int temp = A[i + 1] - A[i];
		if (temp > output) {
			output = temp;
		}
	}
	output = K - output;

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 1152
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define invalid -55
using namespace std;
int n;
int a[19];
int x[19][19],y[19][19];
inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
int valo(int mask)
{
    for(int i=0;i<n;i++)
    {   if(checkBit(mask,i)){
        for(int j=0;j<a[i];j++)
        {
            if(checkBit(mask,x[i][j])!=y[i][j])return invalid;

        }
    }
    }
    return __builtin_popcount(mask);
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        for(int j=0;j<a[i];j++)
        {
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ses=0;
    int tmp=(1<<n);
    for(int i=0;i<tmp;i++)
    {
        ses=max(ses,valo(i));
    }
    cout<<ses<<endl;
    return 0;
}











































































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

int main() {
  
  int x,a;
  cin >> x >> a;
  
  if(x >= a) cout << 10 << endl;
  else cout << 0 << endl;
   
}


Measured memory_bytes: 256