akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
int n,a[100010],i,ans=0;
char s;
scanf("%d\n",&n);
for(i=0;i<n;i++){
scanf("%c",&s);
if(s=='O'){
a[i]=0;
}
else{
a[i]=1;
}
}
a[i]=10000;
i=0;
while(i<n){
if(a[i]==0 && a[i+1]==1){
ans++;
i=i+2;
}
else if(a[i]==1 && a[i+1]==0){
ans++;
i=i+2;
}
else{
i++;
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2228
#include<cstdio>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX_N=1e5+10;
vector<int>adj[MAX_N];
pair<int,int>ans[MAX_N];
long long int from[MAX_N],to[MAX_N],dp[MAX_N],depth[MAX_N],rt;
bool vis[MAX_N];
void dfs(int v,int de,int p)
{
    depth[v]=de;
    vis[v]=1;
    for(int e:adj[v])
    {
        int u=from[e] xor to[e] xor v;
        if(e==p)
        {
            continue;
        }
        if(vis[u])
        {
            dp[v]=min(dp[v],depth[u]);
        }
        else
        {
            dfs(u,de+1,e);
            dp[v]=min(dp[u],dp[v]);
        }
    }
    if(dp[v]>=de&&p!=-1)
    {
        ans[rt]={min(from[p],to[p]),max(from[p],to[p])};
        rt++;
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(long long int i=0;i<=100000;i++)
    {
        dp[i]=999999;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>from[i]>>to[i];
        from[i];
        to[i];
        adj[from[i]].push_back(i);
        adj[to[i]].push_back(i);
    }
    dfs(0,0,-1);
    sort(ans,ans+rt);
    for(int i=0;i<rt;i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}

Measured memory_bytes: 8480
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    rep(i, n) cout << "ACL";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<string> s(n);
	vector<int> a(n);
	for(int i=0;i<n;++i)cin>>s[i]>>a[i];
	vector<int> ord(n);
	iota(ord.begin(),ord.end(),0);
	sort(ord.begin(),ord.end(),[&](int x,int y){
		if(s[x]==s[y])return a[x]>a[y];
		return s[x]<s[y];
	});
	for(auto e : ord)cout<<e+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s, t;

	cin >> s >> t;

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

	if (s < t)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  int c = 1, co = 0;
  vector<vector<int>> ans(h, vector<int>(w));
  rep(i, h){
    rep(j, w){
      int x;
      if(i % 2 == 0) x = j;
      else x = w - j - 1;
      ans.at(i).at(x) = c;
      co++;
      if(co == a.at(c-1)){
        co = 0;
        c++;
      }
    }
  }
  rep(i, h){
    rep(j, w){
      if(j != 0) cout << " ";
      cout << ans.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
    long long L, R;
    cin >> L >> R;
    long long amari = 2018;
    if (R-L+1 >= 2019){
        amari = 0;
    } else {
        for(long long i = L; i < R; i++){
            for (long long j = i + 1; j <= R; j++){
                amari = min(amari, (i*j)%2019);
            }
        }
    }

    cout << amari << endl;


}


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

int main(){
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(S[i] == '1') cout << "9";
    else if(S[i] == '9') cout << "1";
    else cout << S[i];
  }
  cout << 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;

/*
int g[100][100];

int dfs(int i,int j){
	if(g[i][j]!=-1) return g[i][j];
	set<int> S;
	for(int k=1;2*k<=i;k++) S.emplace(dfs(i-2*k,j+k));
	for(int k=1;2*k<=j;k++) S.emplace(dfs(i+k,j-2*k));
	for(int k=0;;k++) if(S.count(k)==0) return g[i][j]=k;
}
*/

int main(){
/*
	rep(i,100) rep(j,100) g[i][j]=-1;
	rep(i,60) rep(j,60) dfs(i,j);
	rep(i,40){ rep(j,40) printf("%2d ",g[i][j]); puts(""); }
*/
	long long x,y; cin>>x>>y;
	cout<<(abs(x-y)>1?"Alice":"Brown")<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int a,b;
	String after;
	String str1,str2,str3;
	String str_rep;
	

	String str = in.next();
	int n = in.nextInt();

	for(int i=0;i<n;i++){
	    after = in.next();
	    if(after.equals("print")){
		a = in.nextInt();
		b = in.nextInt();
		for(int j=a;j<=b;j++){
		    System.out.print(str.charAt(j));
		}
		System.out.println();
	    }else if(after.equals("reverse")){
		a = in.nextInt();
		b = in.nextInt();
		str1 = str.substring(0,a);
		StringBuffer str2_buffer = new StringBuffer(str.substring(a,b+1));
		str2_buffer = str2_buffer.reverse();
		str2 = str2_buffer.substring(0);
		str3 = str.substring(b+1);
		str = str1+str2+str3;
	    }else if(after.equals("replace")){
		a = in.nextInt();
		b = in.nextInt();
		str_rep = in.next();
		str1 = str.substring(0,a);
		str2 = str_rep;
		str3 = str.substring(b+1);
		str = str1+str2+str3;
	    }
	}
    }
}



Measured memory_bytes: 32568
#include<bits/stdc++.h>
using namespace std;
int MIN=9999;
string S;
void solve(int n,int m,int now){
 	if(m == 3){
      MIN = min(MIN,abs(753-now));
      return;
    }
  	if(n == S.size())
      return;
  	solve(n+1,m+1,10*now+(S[n]-'0'));
}
int main(){
  cin >> S;
  for(int i=0;i<S.size();i++)
  	solve(i,0,0);
  cout << MIN << endl;
}

Measured memory_bytes: 256
fn solve() {
    let stdin = std::io::stdin();
    let mut scn = Scanner { stdin: stdin.lock() };
    let n: usize = scn.read();
    let mut result =0;
    for i in 1..=n {
        if i % 3 == 0 {
            continue;
        }
        if i % 5 == 0 {
            continue;
        }
        result += i;
    }
    println!("{}", result);
}


fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	vector<int> cnt(26);
	rep(i,h){
		rep(j,w){
			cnt.at(s[i][j] - 'a')++;
		}
	}
	int cnt4 = 0, cnt2 = 0, cnt1 = 0;
	rep(i,26){
		cnt4 += cnt.at(i) / 4;
		cnt.at(i) %= 4;
	}
	rep(i,26){
		cnt2 += cnt.at(i) / 2;
		cnt.at(i) %= 2;
	}
	rep(i,26){
		cnt1 += cnt.at(i);
	}
	if(h % 2 == 0 && w % 2 == 0){
		if(cnt2 || cnt1) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else if(h % 2 == 0 || w % 2 == 0){
		if(w % 2 == 0) swap(h,w);
		if(cnt1 == 0 && cnt2 <= h / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else{
		if(cnt1 == 1 && cnt2 <= h / 2 + w / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val Array(n, k) = StdIn.readLine().split(" ").map(_.toInt)
  var snukes = (1 to n).toList
  for (_ <- 0 until k) {
    val d = StdIn.readInt()
    val a = StdIn.readLine().split(" ").map(_.toInt)
    snukes = snukes.filterNot(a.contains)
  }
  println(snukes.size)
}

Measured memory_bytes: 54964
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
using ll=long long;


struct city_t
{
	int x, y;
	int rx, ry;
	int id, passed;
};


vector<city_t> vcity;
vector<int> xrank2id, yrank2id;
int n;


bool x_cmp(city_t& a, city_t& b)
{
	return a.x<b.x;
}


bool y_cmp(city_t& a, city_t& b)
{
	return a.y<b.y;
}


int distance(city_t& a, city_t& b)
{
	return min(abs(a.x-b.x), abs(a.y-b.y));
}


struct que_t
{
	int m_id;
	ll m_cost;
	que_t(int id, int cost):m_id(id),m_cost(cost)
	{
	}
	bool operator<(const que_t&rhs) const
	{
		return m_cost>rhs.m_cost;
	}
};


ll solve(void)
{
	priority_queue<que_t> q;
	int id=0;
	ll cost=0;
	ll ans=0;

	q.push(que_t(id, cost));
	while(!q.empty())
	{
		int rank, rid;

		id=q.top().m_id;
		cost=q.top().m_cost;
		q.pop();

		if(vcity[id].passed) continue;
		vcity[id].passed=1;
		ans+=cost;

		rank=vcity[id].rx-1;
		if(rank>=0)
		{
			rid=xrank2id[rank];
			if(!vcity[rid].passed)
			{
				q.push(que_t(rid, distance(vcity[id], vcity[rid])));
			}
		}

		rank=vcity[id].rx+1;
		if(rank<n)
		{
			rid=xrank2id[rank];
			if(!vcity[rid].passed)
			{
				q.push(que_t(rid, distance(vcity[id], vcity[rid])));
			}
		}

		rank=vcity[id].ry-1;
		if(rank>=0)
		{
			rid=yrank2id[rank];
			if(!vcity[rid].passed)
			{
				q.push(que_t(rid, distance(vcity[id], vcity[rid])));
			}
		}

		rank=vcity[id].ry+1;
		if(rank<n)
		{
			rid=yrank2id[rank];
			if(!vcity[rid].passed)
			{
				q.push(que_t(rid, distance(vcity[id], vcity[rid])));
			}
		}
	}
	return ans;
}


int main(void)
{
	while(scanf("%d", &n)==1)
	{
		vcity.resize(n);
		xrank2id.resize(n);
		yrank2id.resize(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &vcity[i].x, &vcity[i].y);
			vcity[i].id=i;
			vcity[i].passed=0;
		}
		{
			auto temp=vcity;
			sort(temp.begin(), temp.end(), x_cmp);
			for(int i=0;i<n;i++)
			{
				xrank2id[i]=temp[i].id;
				vcity[temp[i].id].rx=i;
			}
			sort(temp.begin(), temp.end(), y_cmp);
			for(int i=0;i<n;i++)
			{
				yrank2id[i]=temp[i].id;
				vcity[temp[i].id].ry=i;
			}
		}

		printf("%lld\n", solve());
	}

	return 0;
}


Measured memory_bytes: 7512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll l[100];
int main(){
	int n;
	cin>>n;
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=n;i++){
    	l[i]=l[i-1]+l[i-2];
	}
	cout<<l[n];
}

Measured memory_bytes: 256
#include "vector"
#include "math.h"
#include "algorithm"
#include "iostream"

using namespace std;
typedef long long ll;

int main(){
    ll a;
    ll ma = 123456 * 2 + 10;
    vector<bool> isPrime(ma);
    fill(isPrime.begin(), isPrime.end(), true);
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=2; i*i <= ma; i++){
        if(isPrime[i]){
            for(int j=2; i*j <=ma; j++){
                isPrime[i*j] = false;
            }
        }
    }
    // for(int i=0; i<100;i++){
    //     if(isPrime[i]){
    //         cout << i << endl;
    //     }
    // }
    while(1){
        ll n;
        cin >> n;
        if(n==0) break;
        int cnt = 0;
        for(ll i=n+1; i<=2*n; i++){
            if(isPrime[i]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }


    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
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 all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 1000000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
  int w,h,n;cin>>w>>h>>n;
  vector<vector<int>> v(n,vector<int>(3));
  rep(i,n){
    cin>>v[i][0]>>v[i][1]>>v[i][2];
  }
  int lx=0,rx=w,uy=h,dy=0;
  rep(i,n){
    switch(v[i][2]){
      case 1:
      lx=max(lx,v[i][0]);
      break;
      case 2:
      rx=min(rx,v[i][0]);
      break;
      case 3:
      dy=max(dy,v[i][1]);
      break;
      case 4:
      uy=min(uy,v[i][1]);
      break;
    }
  }
  int a=rx-lx,b=uy-dy;
  int ans;
  if(a>0&&b>0)ans=a*b;
  else ans=0;
  cout<<ans<<endl;
}

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

int main(void)
{
	int seg[10][7] = {
		{1,1,1,1,1,1,0},	// 0
		{0,1,1,0,0,0,0},	// 1
		{1,1,0,1,1,0,1},	// 2
		{1,1,1,1,0,0,1},	// 3
		{0,1,1,0,0,1,1},	// 4
		{1,0,1,1,0,1,1},	// 5
		{1,0,1,1,1,1,1},	// 6
		{1,1,1,0,0,1,0},	// 7
		{1,1,1,1,1,1,1},	// 8
		{1,1,1,1,0,1,1}		// 9
	};
	int n,m,b;

	while(cin >> n,n >= 0){
		int code[7];
		b = -1;
		while(--n, n>=0){
			cin >> m;

			if(b < 0)
				for(int i = 0; i < 7; i++)
					code[i] = seg[m][i];
			else
			for(int i = 0; i < 7; i++){
				code[i] = seg[m][i] ^ seg[b][i];
			}

			for(int i = 6; i >= 0; i--)
				cout <<  code[i];
			cout << endl;

			b = m;
		}
	}

	return 0;
}
				
			

Measured memory_bytes: 1160
N=int(input())
primes=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
def factorize(n,x):
    q,r=divmod(n,x)
    if r==0:
        return(1 + factorize(q,x))
    else:
        return(0)
def factors(n):
    ans=[]
    for p in primes:
        ans.append(factorize(n,p))
    return(ans)
def sumOflist(a,b):
    ans=[]
    for i in range(len(a)):
        ans.append(a[i]+b[i])
    return(ans)
numbers=[i for i in range(3,N+1)]
fTwo = factors(2)
import functools
answer = functools.reduce(lambda acc,b: sumOflist(acc,factors(b)),numbers,fTwo)
MOD=1000000007
ans = functools.reduce(lambda x,y: x*(y+1),answer,1)%MOD
if N==1:
    print(1)
else:
    print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

int main()
{
    string S;
    cin >> S;
    if(S == "SUN")
        cout << 7 << endl;
    else if(S == "MON")
        cout << 6 << endl;
    else if(S == "TUE")
        cout << 5 << endl;
    else if(S == "WED")
        cout << 4 << endl;
    else if(S == "THU")
        cout << 3 << endl;
    else if(S == "FRI")
        cout << 2 << endl;
    else
        cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N = in();
  vi x(N);
  vi y(N);
  rep(i,N) cin >> x[i] >> y[i];

  map<pii, int> H;

  rep(i,N){
    rep(j,N){
      if(i==j) continue;
      pii key = {x[i] - x[j], y[i] - y[j]};
      H[key]++;
    }
  }
  int m = 0;
  for(auto kv : H){
    m = max(m,kv.second);
  }
  cout << N-m << endl;

  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
if n == 2:
  print("Second")
  exit()
stack = []
root = 0
for i in range(1,n+1)[::-1]:
  if deg[i] == 1:
    stack.append(i)
  else:
    root = i
flg = 0
deg[root] += 1
dp = [[] for i in range(n+1)]
dist = [-1]*(n+1)
while stack:
  x = stack.pop()
  if dp[x]:
    if dp[x].count(0)>=2:
      flg = 1
    if dp[x].count(0):
      dist[x] = 1
    else:
      dist[x] = 0
  else:
    dist[x] = 0
  for y in graph[x]:
    if deg[y] >= 2:
      dp[y].append(dist[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
if flg or dist[root]==0:
  print("First")
else:
  print("Second")



Measured memory_bytes: 46784
ABCD = list(input())
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

flag = True
for i in ['+', '-']:
    if flag:
        sumAB = A + B if i == '+' else A - B
        for j in ['+', '-']:
            if flag:
                sumABC = sumAB + C if j == '+' else sumAB - C
                for k in ['+', '-']:
                    if flag:
                        sumABCD = sumABC + D if k == '+' else sumABC - D
                        if sumABCD == 7:
                            print(str(A) + i + str(B) + j + str(C) + k + str(D) + "=7")
                            flag = False


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int res = 0;
			int []array1 = new int[]{1,2,3,4,5,6,7,8,9};
			int []array2 = new int[]{1,2,3,4,5,6,7,8,9};
			sc.close();
			for(int i = 0;i<9;i++) {
				for(int j = 0;j<9;j++) {
					if(n == (array1[i])*(array2[j])) {
						res++;
					}
				}
			}
			if(res>=1) 
				System.out.println("Yes");
			
			else
				System.out.println("No");
		}
	
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    if(n==1){
      System.out.println("Hello World");
    }else if(n==2){
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      System.out.println(a+b);
    }
  } 
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main(){
  ll N,H; cin >> N >> H;
  vector<ll> B(N);
  ll a_max = 1;
  for(ll i=0;i<N;i++){
    ll a,b; cin >> a >> b;
    a_max = max(a_max,a);
    B[i] = b;
  }
  sort(B.rbegin(),B.rend());
  ll sum = 0, cnt = 0;
  for(ll i=0;i<N;i++){
    if(sum >= H){
      cout << cnt << endl;
      return 0;
    }
    if(B[i]>=a_max){
      sum += B[i];
      cnt++;
    }else break;
  }
  H -= sum;
  cnt += (H+(a_max-1)) / a_max;
  cout << cnt << endl;
  return 0;
}
  
    

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    string a, b, ans=""; cin >> a >> b;
    if(a.length() > b.length()) ans = "GREATER";
    else if(a.length() < b.length()) ans = "LESS";
    else{
        if(a == b) ans = "EQUAL";
        if(a > b) ans = "GREATER";
        if(a < b) ans = "LESS";
    }
    cout << ans << "\n";
    return 0;
}

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

#define MAX 210000000
int main(){

  // iテァツ閉ェテァツ崢ョテ」ツ?ョテゥツδステ・ツクツづ」ツ?セテ」ツ?ァテ」ツ?ォjテヲツ猟・テ」ツ?凝」ツ?妥」ツ?ヲティツ。ツ古」ツ?湘ヲツ卍づ」ツ?ョテヲツ慊?・ツーツ湘ァツ鳴イテ・ツ環エテ・ツコツヲ
  // dp[N][M-1]
  int dp[1010][1010]={};
  for(int i = 0 ;i < 1010 ; ++i){
    for(int j = 0; j < 1010 ; ++j){
      dp[i][j] = MAX;
    }
  }
  int N,M;
  int D[1010];
  int C[1010];
  cin >> N >> M;

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


  for(int j = 0; j < M;++j){
    dp[0][j] = 0;
  } 

  for(int i = 0;i< N;++i){
    for(int j = 0;j < M; ++j){ 
      dp[i+1][j+1] = min( dp[i+1][j] , dp[i][j] + D[i]*C[j] );
    }
  }
 

  cout << dp[N][M]<< endl;
  
  

  return 0;
}

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

main() {
    int A,B,X; cin >> A >> B >> X;
    if(A<=X && X<=A+B) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  long long a;
  cin>>s>>a;
  if(s.size()==1){
    cout<<s[0]<<"\n";
    return 0;
  }
  int cnt=0;
  for(int i=0;i<s.size();i++){
   	if(s[i]!='1') break;
    cnt++;
  }
  if(a<=cnt)cout<<"1\n";
  else cout<<s[cnt]<<"\n";
  return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = NM[0]+1;
            var M = NM[1];
            var am = new HashSet<int>();
            for (var i=0;i<M;i++)
            {
                am.Add(int.Parse(Console.ReadLine()));
            }
            var dp = new List<int>(Enumerable.Range(0,N).Select(s=>0));
            dp[0] = 1;
            if (am.Contains(0)) dp[0] = 0;

            for (var i=1;i<N;i++)
            {
                if (am.Contains(i)) continue;
                else dp[i] = dp[i - 1];
                if (1 < i)
                {
                    dp[i] += dp[i - 2];
                    dp[i] %= 1000000007;
                }
            }
            Console.WriteLine(dp[N-1]);
        }
    }
}


Measured memory_bytes: 18528
/*??????????????§RMQ????±???????*/
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define RMQ_MAX ((1LL << 31) - 1)
template<typename T>
class SquareBucket{
public:
  SquareBucket(){}
  SquareBucket(const vector<T> &array):val(array){
    N = val.size();
    sqrtN = ceil(sqrt(N));
    B = (N + sqrtN - 1) / sqrtN;
    bucket.assign(B, RMQ_MAX);
    for (int i = 0; i < B; i++){
      for (int j = sqrtN * i; j < sqrtN * (i + 1); j++){
	if (j >= N)break;
	bucket[i] = min(bucket[i], val[j]);
      }
    }
  }
  void init(const vector<T> &array){
    val = array;
    N = val.size();
    sqrtN = ceil(sqrt(N));
    B = (N + sqrtN - 1) / sqrtN;
    bucket.assign(B, RMQ_MAX);
    for (int i = 0; i < B; i++){
      for (int j = sqrtN * i; j < sqrtN * (i + 1); j++){
	if (j >= N)break;
	bucket[i] = min(bucket[i], val[j]);
      }
    }
  }
  void update(int node, T v){
    val[node] = v;
    int X = node / sqrtN;
    bucket[X] = RMQ_MAX;
    for (int i = sqrtN * X; i < sqrtN * (X + 1); i++){
      if (i >= N)break;
      bucket[X] = min(bucket[X], val[i]);
    }
  }
  /*[l, r)???RMQ*/
  T range_minimum(int left, int right){
    int L = (left + sqrtN - 1) / sqrtN + 1;
    int R = right / sqrtN;
    T res = RMQ_MAX;
    if (L <= R){
      for (int i = left; i < sqrtN * L; i++){
	res = min(res, val[i]);
      }
      for (int i = L; i < R; i++){
	res = min(res, bucket[i]);
      }
      for (int i = sqrtN * R; i < right; i++){
	res = min(res, val[i]);
      }
    }else{
      for (int i = left; i < right; i++){
	res = min(res, val[i]);
      }
    }
    return res;
  }
  
private:
  vector<T> val;
  vector<T> bucket;
  int N;
  int sqrtN;
  int B;//the number of bucket
};

int N,Q;
int main(){
  cin >> N >> Q;
  vector<int> arr;
  arr.resize(N, RMQ_MAX);
  SquareBucket<int> rmq(arr);
  for (int i = 0; i < Q; i++){
    int com,x,y;
    cin >>com>> x >> y;
    if (com == 0){
      rmq.update(x, y);
    }else{
      cout << rmq.range_minimum(x, y + 1) << endl;
    }
  }
}

Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Text;

namespace ITP1_5_A_Print_a_Rectangle
{
    class Program
    {
        static string buildRect(int h, int w)
        {
            var line = new StringBuilder().Append( '#', w ).ToString();
            return Enumerable.Range( 0, h ).Select( _ => line ).Aggregate( new StringBuilder(), (acc, s) => acc.AppendLine( s ) ).ToString();
        }
        static void Main(string[] args)
        {
            string[] input = null;
            do
            {
                if(input!= null)
                {
                    var size = input.Select( int.Parse ).ToArray();
                    Console.WriteLine( buildRect( size[ 0 ], size[ 1 ] ) );
                }
                input = Console.ReadLine().Split( ' ' );
            } while ( input[0] != "0" || input[1] != "0" );
        }
    }
}

Measured memory_bytes: 5932
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  string s;
  cin >> s; 
  sort(s.begin(), s.end());
  if(s.at(0) == s.at(1) && s.at(1)!=s.at(2) && s.at(2)==s.at(3)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
    int n,k; cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    sort(h.rbegin(), h.rend());
    rep(i,min(n,k)) h[i] = 0;
    ll sum = 0;
    rep(i,n) sum += h[i];
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include<cstdio>

int main(){
    int n,a,b;
    scanf("%d",&n);
    scanf("%d",&a);
    int min = a;
    int max = a;
    long long sum = a;
    for(int i = 2; i <= n; i++){
        scanf("%d",&b);
        if(min >= b){
            min = b;
        }
        else{
            min = min;
        }
        if(max <= b){
            max = b;
        }
        else{
            max = max;
        }
        sum += b;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	lint a,b,c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.min
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    var (A, B, C) = nextLongList()
    val a = min(B, C)
    var ans = a * 2
    B -= a
    C -= a
    val b = min(A, C)
    ans += b
    A -= b
    C -= b
    ans += B
    ans += if (C > 0) 1 else 0
    println(ans)
}


Measured memory_bytes: 36432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using vi = vector<int>;
using si = set<int>;
using usi = unordered_set<int>;
using vll = vector<ll>;
using vd = vector<double>;
static const ll M = 1e9 + 7;

double solve(const vd &ps) {
    const int sz = ps.size();
    
    // probability for [i coins] to have [j heads]
    vector<vd> dp(sz + 1, vd(sz + 1, 0.0));
    dp[0][0] = 1.0;
    for (int j = 1; j <= sz; ++j) {
        dp[j][0] = dp[j - 1][0] * (1.0 - ps[j - 1]);
    }
    
    for (int i = 1; i <= sz; ++i) {
        for (int j = 1; j <= sz; ++j) {
            dp[i][j] = dp[i - 1][j] * (1.0 - ps[i - 1]) + dp[i - 1][j - 1] * ps[i - 1];
        }
    }
    
    double ans = 0.0;
    for (int i = sz / 2 + 1; i <= sz; ++i) {
        ans += dp[sz][i];
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(17);
    
    int sz;
    cin >> sz;
    vd ps(sz, 0.0);
    for (double &p : ps) cin >> p;

    cout << solve(ps) << endl; 
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN  = 100005;
int a[MAXN]={0};
int b[MAXN]={0};
int c[MAXN]={0};
int d[MAXN]={0};
int dfn[MAXN]={0};
int ans[MAXN]={0};
vector<int>x[MAXN];
vector<int>G;int cnt = 0;
void dfs(int u,int fa){
    G.push_back(u);
    dfn[u]=cnt;
    for(auto V:x[u]){
        if(!dfn[V])
            dfs(V,u);
    }
}

int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    int u,v;

    for(int i=0;i<m;i++){
        cin >> u >> v;
        x[u].push_back(v);
        x[v].push_back(u);
        ans[u]--;
        ans[v]--;
    }
    for(int i=0;i<k;i++)
        cin >> d[i] >> c[i];
    for(int i=1;i<=n;i++){
        if(!dfn[i]){
            ++cnt;
            G.clear();
            dfs(i,i);
            for(auto v:G){
                ans[v]+=G.size()-1;
            }
        }
    }
    for(int i=0;i<k;i++){
        if(dfn[c[i]]==dfn[d[i]])
            ans[c[i]]--,ans[d[i]]--;
    }
    for(int i=1;i<=n;i++)
        cout << ans[i] << " \n"[i==n];
    return 0;
}


Measured memory_bytes: 11832
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<ll,mp> mmp;
ll inf =  1e9;


int main(){
    vector<mmp> a;
    for(int i=1;i<=150;i++){
	for(int j=1;j<i;j++){//h
	    a.push_back( mmp( i*i+j*j, mp( j,i ) ) );
	}
    }
    sort( a.begin() , a.end() );
    while(1){
	int h,w;
	cin>>h>>w;
	if(h == 0)break;
	mmp now = mmp( h*h + w*w ,mp( h,w ) );
	auto it = upper_bound(a.begin(),a.end(), now );
	mp res = it->second;
	cout<<res.first<<' '<<res.second<<endl;
	     
    }
    return 0;
}



Measured memory_bytes: 3260
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
ll a[200000];

int main()
{
	int m,n,i,j,t,k,flag=0;
	cin>>n;
	ll s=1;

	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0) {
			flag=1;
		}
	 } 
	 if(flag==1){
	 	cout<<0; return 0;
	 }
	 else {
	 	
	 	for(i=1;i<=n;i++)
	{
		ll r=1000000000000000000/s;
		if(a[i]>r) {
			flag=2;break;
		}
		s*=a[i];
		
	 }
	  if(flag==2)
	  {
	  	cout<<-1;
		  }	
		  else cout<<s;
	 }

	 
 } 

Measured memory_bytes: 4408
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static List<char> list = new List<char> {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    public static List<string> runruns = new List<string>();
    public static void Main(){
        var k = Int32.Parse(Console.ReadLine());
        var q = new Queue<string>();
        
        q.Enqueue("1");
        q.Enqueue("2");
        q.Enqueue("3");
        q.Enqueue("4");
        q.Enqueue("5");
        q.Enqueue("6");
        q.Enqueue("7");
        q.Enqueue("8");
        q.Enqueue("9");

        var count = 0;
        while(true){
            var s = q.Dequeue();
            var last = s.Substring(s.Length - 1).ToCharArray()[0];
            var index = list.IndexOf(last);
            if(index != 0) q.Enqueue(s + list[index - 1]);
            q.Enqueue(s + list[index]);
            if(index != 9) q.Enqueue(s + list[index + 1]);
            count++;
            if(count == k){
                Console.WriteLine(s);
                return;
            }
        }
    }
}


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

#define  quick  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define s(x) sort(x.begin(),x.end())
#define sr(x) sort(x.begin(),x.end(),greater<ll>())
#define v1 vector<ll>
#define p1 pair<ll,ll>
#define m1 map<ll,ll>
#define ff first
#define ss second
#define ee '\n';
#define pb push_back
#define all(v) v.begin(),v.end()
#define f(i,x,y) for(i=x;i<y;i++)
#define mp make_pair
#define yes cout<<"YES"<<endl
#define no  cout<<"NO"<<endl

void solve()
{
      ll i,n,cnt=1,j;
      cin>>n;
      for(i=1;i<n;i++)
      {
             for(j=1;j<n;j++)
             {
                    if(i*j<n)
                    {
                          cnt++;
                    }
                    else if(i*j>=n)
                    {
                           break;
                    }
             }
      }
      cout<<cnt-1;
}

 int32_t main()
 {
    quick;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       solve();
    }
    return 0;
 }

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 100000
typedef long long ll;

bool visit[MAX];
int d[MAX];
typedef pair<int,int> P;
vector<P> G[MAX];

void dfs(int node, int dis){
	if (visit[node]){
		if (d[node] != dis){
		cout << "No" << endl;
		exit(0);	//プログラム終了
		}
		return;	//訪れたことがあるけど、矛盾は生じてない。
	}
	
	visit[node] = true;
	d[node]= dis;
	rep(i,G[node].size()){
	dfs(G[node][i].first, dis + G[node][i].second);
	}
}
	


int main(){
	int n,m;
	cin >> n>>m;
	int l,r,d;
	
	//adj listの作成
	rep(i,m){
	cin >>l>>r>>d;
	l--; r--;
	G[l].push_back(P(r,d));
	G[r].push_back(P(l,-d));
	}
	
	//点の個数だけ、深さ優先探索して矛盾がないか探索
	//訪れたことがなければ、その点を始点として探索開始
/*	rep(i,n){
	visit[i]=0;
	}
*/
	rep(i,n){
		if(!visit[i]) dfs(i,0);
	}
	
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define fr first
#define sc second
#define PI 3.14159265
#define ullt unsigned long long int
using namespace std;
bool vis[200200];
unordered_set<int>v[200200];
int dfs(int i) {
	int cnt = 1;
	vis[i] = true;
	for (auto child : v[i])
		if (!vis[child])
			cnt += dfs(child) ;
	return cnt;
}
void solve() {
	int n, m, ans = 0;
	cin >> n >> m;


	
		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			v[x].insert(y);
			v[y].insert(x);
		}
		for (int i = 1; i <= n; i++) {
			if (!vis[i])
				ans = max(ans, dfs(i));
		}
		cout<<ans;
	

}
int main()
{
	Start;

	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
		cout << "\n";
	}
	return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int a = 1; a < n; a++)
    {
        ans += (n - 1) / a;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

template
<
    typename TYPE,
    std::size_t SIZE
>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a,i,n) for(ll (i) = a ; (i) < (n) ; ++(i))
#define REP(i,n) REPS(0,i,n)

const int INF = 100001;

int a,b;


int main()
{
    cin >> a >> b;
    cout << (b-a)*(b-a+1)/2-b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int a[3],k;
    scanf("%d%d%d%d",&a[0],&a[1],&a[2],&k);
    while(k--)
    {
        sort(a,a+3);
        a[2]=2*a[2];
    }
    printf("%d\n",a[0]+a[1]+a[2]);
    return 0;
}


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


int main() {
  int N,A=0,Z=0;
  cin>>N;
  string S;
  cin>>S;
  int a=0;
  for(int i=0;i<N;i++){
    if(a==0&&S.at(i)=='2'){
      Z++;
    }
    if(a==0&&S.at(i)=='3'){
      Z+=2;
    }
    if(S.at(i)=='2'){
      A=1;
    }
    if(i!=N-1){
      int B=N-1-i,C=i+1;
    if(B%2==0){
      while(true){
        a++;
        B/=2;
        if(B%2==1){
          break;
        }
      }
    }
    if(C%2==0){
      while(true){
        a--;
        C/=2;
        if(C%2==1){
          break;
        }
      }
    }
  }   
  }
  if(A==1){
    cout<<Z%2<<endl;
  }
  else{
    cout<<Z%4<<endl;
  }
}

Measured memory_bytes: 1412
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,m,x,ans=MOD;cin>>n>>m>>x;
  vll c(n);
  vvll a(n,vll(m));
  rep(i,0,n){
    cin>>c[i];
    rep(j,0,m){
      cin>>a[i][j];
    }
  }
  rep(i,0,1<<n){
    vll tmp(m,0);ll tmpa=0;
    rep(j,0,n){
      if(i>>j&1){
        rep(k,0,m){
          tmp[k]+=a[j][k];
        }
        tmpa+=c[j];
      }
    }
    bool ok=true;
    rep(j,0,m){
      if(tmp[j]<x){ok=false;}
    }
    if(ok){ans=min(ans,tmpa);}
  }
  if(ans==MOD){ans=-1;}
  cout<<ans<<endl;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


struct Dinic{
    using F=long long;
    static const F INF=1ll<<50;

    struct Edge{
        int to;
        F cap;
        int rev;
        Edge(int to,F cap,int rev):to(to),cap(cap),rev(rev){}
    };

    int n;
    vector<vector<Edge>>G;
    vector<int>iter,level;
    Dinic(int n):n(n),G(n),iter(n),level(n){}

    inline void addEdge(int from,int to,F cap){
        G[from].push_back(Edge(to,cap,G[to].size()));
        G[to].push_back(Edge(from,0,G[from].size()-1));
    }
    /*   無向辺を追加する
    inline void addUndirectedEdge(int src,int to,F cap){
        G[src].push_back(Edge(to,cap,G[to].size()));
        G[to].push_back(Edge(src,cap,G[src].size()-1));
    }
    */

    void bfs(int s){
        level.assign(n,-1);
        queue<int>que;
        level[s]=0;
        que.push(s);
        while(que.size()){
            int u=que.front();
            que.pop();
            for(auto &e:G[u]){
                if(e.cap==0||level[e.to]!=-1)continue;
                level[e.to]=level[u]+1;
                que.push(e.to);
            }
        }
    }

    F dfs(const int &s,const int &u,F cur){
        if(s==u)return cur;
        F sum=0;
        for(int &i=iter[u];i<G[u].size();i++){
            Edge &e=G[u][i],&ee=G[e.to][e.rev];
            const int &v=e.to;
            if(level[v]>=level[u]||ee.cap==0)continue;
            F f=dfs(s,v,min(cur-sum,ee.cap));
            if(f<=0)continue;
            ee.cap-=f; e.cap+=f;
            sum+=f;
            if(sum==cur)break;
        }
        return sum;
    }

    F maxFlow(int s,int t){
        F flow=0;
        while(true){
            bfs(s);
            if(level[t]==-1)return flow;
            iter.assign(n,0);
            flow+=dfs(s,t,INF);
        }
    }
};

signed main(){
	int N,M;
	cin>>N>>M;
	Dinic d(N);
	rep(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		d.addEdge(a,b,c);
	}
	cout<<d.maxFlow(0,N-1)<<endl;
	return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;

struct Solver {
	void solve() {
		string S;
		cin >> S;

		if( S.size() == 3 ) {
			cout << S[2] << S[1] << S[0] << endl;
		}
		else {
			cout << S << endl;
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

struct UF
{
    vi p, s;
    UF(int n) : p(n, 0), s(n, 1)
    {
        iota(p.begin(), p.end(), 0);
    }
	
    int f(int x)
    {
        return (p[x] == x ? x : p[x] = f(p[x]));
    }
	
    ll u(int i, int j)
    {
        int x = f(i), y = f(j);
        if (x == y)
            return 0;

        ll r = 1ll * s[x] * s[y];
        p[x] = y;
        s[y] += s[x];
        return r;
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vii e;
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e.emplace_back(a, b);
    }
    reverse(all(e));
    ll sol = 1ll * n * (n - 1) / 2;
    UF uf(n);
    vector<ll> gsol;
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        tie(a, b) = e[i];
        gsol.push_back(sol);
        sol -= uf.u(a, b);
    }
    reverse(all(gsol));
    for (ll x : gsol)
        cout << x << '\n';
}


Measured memory_bytes: 3828