akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

struct person{
    ll deadTime;
    ll arrivedTime;
};

bool cmp(const person a, const person b){
    return a.deadTime > b.deadTime;
}

int main(){

    ll N, C, K;
    cin >> N >> C >> K;
    vector<person> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i].arrivedTime;
        p[i].deadTime = p[i].arrivedTime + K;
    }

    sort(all(p), cmp);
    ll ans = 0;
    ll people = 0;
    ll time ;
    while ( !p.empty() ){
        person next = p.back();
        //cout << " time" << next.arrivedTime << endl;
        if(people == 0){
            p.pop_back();
            people ++;
            time = next.deadTime;
        }
        else if(people == C){
            ans ++;
            people = 0;
        }
        else if(next.arrivedTime > time){
            ans ++;
            people = 0;
        }
        else{
            p.pop_back();
            people ++;
        }
    }
    cout << ans + 1 << endl;
    
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

//累乗 O(log N)
long long power(long long x, long long N){
	if(N == 0) return 1LL;
	if(N == 1) return x;
	long long tmp = power(x, N/2);
	if(N%2 == 0) return tmp * tmp % MOD;
	else return tmp * tmp % MOD * x % MOD;
}

//逆元 O(log x)
long long inverse(long long x){
	return power(x, MOD-2);
}

//コンビネーション
struct Combination{
private:
	int N;
	vector<long long> factorial, inv;
public:
	void init(int n){ //初期化する O(N)
		N = n;
		factorial.push_back(1);
		inv.push_back(1);
		for(long long i=1; i<=N; i++){
			factorial.push_back(factorial.back()*i%MOD);
			inv.push_back(inverse(factorial.back()));
		}
	}
	long long fact(int n){
		return factorial[n];
	}
	long long comb(int n, int k){ //nCkを求める O(1)
		if(n < k) return 0LL;
		return factorial[n] * inv[k] % MOD * inv[n-k] % MOD;
	}
};

int N, K;
ll A[100000];
Combination C;
ll ans = 0;

signed main(){
	cin >> N >> K;
	rep(i, N) cin >> A[i];
	sort(A, A+N);
	C.init(N);

	rep(i, N){
		ans -= A[i] * C.comb(N-1-i, K-1);
		ans += A[i] * C.comb(i, K-1);
		while(ans < 0) ans += (-ans/MOD + 1) * MOD;
		ans %= MOD;
		//cout << C.comb(N-1-i, K-1) << " " << C.comb(i, K-1) << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2804
#include <iostream>

using namespace std;

int main() {
  int n;
  int ans = 0;
  cin >> n;

  for(int j = 1; j <= n; j+=2) {
    int tmp = 0;
    for(int i = 1; i <= n; i++) {
      if(j % i == 0) tmp++;
    }
    if(tmp == 8)   ans++;
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input_string = String::new();
    io::stdin().read_line(&mut input_string).expect("Error");
    let n: i32 = input_string.trim().parse::<i32>().unwrap();
    let mut result = 0;
    for x in 1..n + 1 {
        result += x;
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
function main() {
  var
  i, n, a, b, line, lines;
  for(i = 0; n = parseFloat(input[i++]); ) {
    a = b = 0;
    for(j = 0; j < n; j++) {
      line = input[i++].split(' ').map(parseFloat);
      x = line[0];
      y = line[1];
      if(x > y) {
        a += x + y;
      } else if(x < y) {
        b += x + y;
      } else {
        a += x;
        b += y;
      }
    }
    console.log("%d %d", a, b);
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 14924
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  vector<string> w(n);
  bool ans= true;

  //input
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin >>w.at(i);
  }
  
  //重複チェック  
  for (int i = 0; i < n; i++) {
      for (int j = i+1; j < n; j++) {
          if( w.at(i) == w.at(j) ){
            ans=false;
            break;
          }
      }
    if(ans==false)break;
  }
  //しりとりチェック
  if(ans){
    for (int i = 0; i < n-1; i++) {
      if( w.at(i).back() != w.at(i+1).front() ){ans=false;break;}
    }
  }
    
  //output
      if(ans){cout<<"Yes";}
      else{cout<<"No";}
}

  

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

int main() 
{
	long long int n,i,j;
	cin >> n;
	long long int m[n][3],dp[n][3];
	for(i=0;i<n;i++)
	for(j=0;j<3;j++)
	cin >> m[i][j];
	
	
	for(i=0;i<n;i++)
	for(j=0;j<3;j++)
	dp[i][j]=0;
	
	for(i=0;i<3;i++)
	dp[0][i]=m[0][i];
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+m[i][j];
		}
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
	return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A == 1)A = 14;
	if (B == 1)B = 14;
	if (A > B) {
		cout << "Alice";
	}
	else if (A == B) {
		cout << "Draw";
	}
	else {
		cout << "Bob";
	}

	return 0;
}

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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;

    string U; cin >> U;
    if (S == U) A--;
    else B--;

    cout << A << ' ' << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    cout<< ( N==M ? "Yes" : "No" )<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double
#define all(x) x.begin(), x.end()
#define uniq(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())

const int maxn = 1009;
int dp[maxn][maxn];
int dp1[maxn][maxn];
int dp2[maxn][maxn];
int n, k;
int mod = 998244353;

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s >> k;
    n = s.size();
    int len = 0;
    dp[0][0] = 1;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == '1')
        {
            len++;
            continue;
        }
        for (int e = 0; e <= n; e++)
            for (int j = n; j >= 0; j--)
                dp1[e][j] = (dp1[e][j + 1] + dp[e][j]) % mod;
        for (int e = 0; e <= n; e++)
            for (int j = 0; j <= n; j++)
        {
                dp2[e][j] = ((j ? dp2[e][j - 1] : 0) + dp[e + j][j]) % mod;
                if (j - len - 1 >= 0 && e + (j - len - 1) <= n)
                    dp2[e][j] = (dp2[e][j] - dp[e + (j - len - 1)][j - len - 1] + mod) % mod;
        }
        for (int e = 0; e <= n; e++)
            for (int j = 0; j <= n && j <= e; j++)
        {
            dp[e][j] = (dp1[e][j] + dp2[e - j][j] - dp[e][j] + mod) % mod;
//            cout << i << " " << e << " " << j << " " << dp[e][j] << "\n";
        }
        len = 0;
    }
    int ans = 0;
    for (int e = 0; e <= k && e <= n; e++)
        for (int j = 0; j <= n; j++)
            ans = (ans + dp[e][j]) % mod;
    cout << ans;
}


Measured memory_bytes: 9024
fn main() {
    let row: Vec<i32> = read_vec();
    let k: i32 = row[1];
    let h: Vec<i32> = read_vec();
    let ans = h.iter().filter(|&c| c >= &k).count();
    println!("{}", ans);
}

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()
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 2e5 + 5;
int h[maxn], dp[maxn];
int main()
{
	int n, k; scanf("%d %d",&n,&k);
	for(int i = 1; i <= n; i++)
		scanf("%d",&h[i]);
	memset(dp, 0x3f, sizeof(dp));
	dp[1] = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= k; j++)
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
	}
	printf("%d\n",dp[n]);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define CHKR
#define ll int
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008
ll n,m;
ll a[ARRS];
#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll k,p,q;
    cin>>n;
    n=2*n;
    for(int i=0; i<n; i++){
		cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    ll pas=0;
    for(int i=1; i<n; i+=2){
		pas+=a[i];
    }
    cout<<pas;

    return 0;
}


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

int main(){
	string o, e;
	cin >> o >> e;
	for(int i = 0; i < (int)o.size(); i++) {
		printf("%c", o[i]);
		if(i < (int)e.size()) printf("%c", e[i]);
	}
	printf("\n");
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll a,b,c;cin >> a >> b >> c;
    if(c-a-b>=0)
    {
        if ((c - a - b) * (c - a - b) > 4 * a * b)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 3580
import math

a, b, h,m = map(int, input().split())

# 角度を求める
a_angle = (h/12 + m/(60*12)) *360
b_angle = m/60*360

#print(a_angle)
#print(b_angle)

line = 0

if a_angle > b_angle:
    angle = a_angle - b_angle
elif a_angle < b_angle:
    angle = b_angle - a_angle 
else:
    angle = 0


    
if angle >=180:
    angle = 360-angle

#print(angle)

c2 = pow(a,2) + pow(b,2) - 2 * a * b * math.cos(math.radians(angle))

c = pow(c2, 1/2)
print(c)


Measured memory_bytes: 9540
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

int main() {
    SS(ll,n)
    SV(ll,a,n)
    map<pair<ll,ll>,ll>ma;
    rep(i,n){
        ll A=i+1,B=a[i];
        if(B>A)swap(A,B);
        ma[{A,B}]++;
    }
    ll ans=0;
    for(auto v:ma)if(v.second>1)ans++;
    p(ans);

}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

class Dice {
    public:
    int x, y, z;
    Dice() : x(3), y(1), z(2) {}
    ~Dice() {}
    void S() {
        int z_ = z;
        z = y;
        y = 7-z_;
    }
    void N() {
        int y_ = y;
        y = z;
        z = 7-y_;
    }
    void W() {
        int y_ = y;
        y = x;
        x = 7-y_;
    }
    void E() {
        int x_ = x;
        x = y;
        y = 7-x_;
    }
    void L() {
        int z_ = z;
        z = x;
        x = 7-z_;
    }
    void R() {
        int x_ = x;
        x = z;
        z = 7-x_;
    }
    void r(int u, int f) {
        if(y==7-u) {
        	this->N();
        	this->N();
        }else if(x==u)this->W();
        else if(x==7-u)this->E();
        else if(z==u)this->N();
        else if(z==7-u)this->S();
        
        if(z==7-f) {
        	this->L();
        	this->L();
        	
        }else if(x==f)this->L();
        else if(x==7-f)this->R();
    }
    void p() {
        cout<<x<<' '<<y<<' '<<z<<endl;
    }
};

int m[2][7];
Dice d;

bool check() {
    bool r = true;
    r = r && (m[0][1] == m[1][d.y] && m[0][2] == m[1][d.z]);
    r = r && (m[0][3] == m[1][d.x] && m[0][4] == m[1][7-d.x]);
    r = r && (m[0][5] == m[1][7-d.z] && m[0][6] == m[1][7-d.y]);
    return r;
}

int main(){
    cin.tie(0);
    rep(j, 2)rep(i, 6)cin>>m[j][i+1];
    
    bool c = false;
    for_(i, 1, 7) {
        for_(j, 1, 7) {
        	if(j == i || j==7-i)continue;
            d.r(i, j);
            if(check()) {
                c = true;
                break;
            }
        }
    }
    
    cout<<(c?"Yes":"No")<<endl;
    
    return 0;
}



Measured memory_bytes: 3108
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int a[] = na(n);
		int s = 0;
		int e = n - 1;
		long ssum = 0;
		long esum = 0;
		while(s <= e) {
			if(ssum <= esum) {
				ssum += (long)a[s];
				s++;
			} else {
				esum += (long)a[e];
				e--;
			}
		}
		System.out.println(Math.abs(ssum - esum));		
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 56820
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    string f = "Yes";
    for (int i = 0; i< s.length();i++){
        if((i+1)%2){
            if (s[i] == 'L') {
                f ="No";
            }
        }else{     
            if(s[i] == 'R'){
                f = "No";
            }
        }
    }
    cout << f;
}


Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline

class Edge:
    def __init__(self, id, node1=-1, node2=-1, cost=-1):
        self.id = id
        self.node1 = node1
        self.node2 = node2
        self.cost = cost
    
    def next(self, num):
        if num == self.node1:
            return self.node2
        elif num == self.node2:
            return self.node1
        else:
            return False

def main():
    N, M = map(int, input().split())

    edges = [list() for i in range(N)]
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edge = Edge(i, a, b, c)
        edges[a].append(edge)
        edges[b].append(edge)

    ans = set([i for i in range(M)])
    for start in range(N):
        q = []
        check = [False] * N
        costs = [-1] * N
        heapq.heappush(q, (0, start, None))
        used_edge = set()
        while len(q) > 0:
            cost, node, pre_edge = heapq.heappop(q)
            if check[node]:
                if costs[node] == cost:
                    used_edge.add(pre_edge)
                continue
            costs[node] = cost
            check[node] = True
            if pre_edge != None:
                used_edge.add(pre_edge)
            for edge in edges[node]:
                next_node = edge.next(node)
                if not check[next_node]:
                    heapq.heappush(q, (cost + edge.cost, next_node, edge.id))
        ans -= used_edge
    print(len(ans))




if __name__ == "__main__":
    main()

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    set<int> st;
    int a;
    for(int i=0;i<3;i++){
        cin>>a;
        st.insert(a);
    }
    cout<<st.size()<<"\n";
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool c = false;
  for(int i = 1; i < 10; i++){
    if(N / i < 10 && N % i == 0){
      c = true;
    }
  }
  if(c){
	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

bool judge(int ans,int d[],int k){
	while(ans > 0){
		for(int i = 0; i < k; i++){
			if(d[i] == ans%10) return false;
		}
		ans = ans / 10;
	}
	return true;
}
int main(void)
{
	int n,k; cin>>n>>k;
	int d[k]; for(int i = 0; i < k; i++) cin>>d[i];
	int ans = n-1;
	bool flag = false;
	
	while(flag == false){
		ans++;
		//out<<"ans = "<<ans<<endl;
		flag = judge(ans,d,k);
	}
	
	//ans = judge(1000,d,k);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int a[n][m], b[m];
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++)
      cin >> a[i][j];
  for(int j = 0; j < m; j++)
    cin >> b[j];
  for(int i = 0; i < n; i++) {
    int sum = 0;
    for(int j = 0; j < m; j++)
      sum += a[i][j] * b[j];
    cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mm multimap<ll,ll>
#define mp make_pair
#define pii pair<ll,ll>

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
ll n,k;
cin>>n;
ll arr[n][3],dp[n][3];
for(ll i=0;i<n;i++)
{
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    if(i==0)
    {
        dp[i][0]=arr[i][0];
        dp[i][1]=arr[i][1];dp[i][2]=arr[i][2];
    }
    else
    {
        dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
        dp[i][1]=max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
        dp[i][2]=max(dp[i-1][0]+arr[i][2],dp[i-1][1]+arr[i][2]);
    }
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  if (x==3 || x==5 || x==7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int N = 50;
            long[] a = new long[N];
            for (int i = 0; i < a.length; i++) {
                a[i] = i;
            }

            long n = K / N;
            for (int i = 0; i < a.length; i++) {
                a[i] += n;
            }

            K %= N;
            for (int i = 0; i < K; i++) {
                a[i] += N;
                for (int j = 0; j < a.length; j++) {
                    if (j == i) {
                        continue;
                    }
                    a[j]--;
                }
            }

            // Utils.debug(calculateSum(Arrays.copyOf(a, a.length)));

            print(N, a);
        }
    }

    // private static long calculateSum(long[] a) {
    // Utils.debug("a", a);
    // long sum = 0;
    // for (;;) {
    // long before = sum;
    // for (int i = 0; i < a.length; i++) {
    // long l = a[i] / a.length;
    // sum += l;
    //
    // // long ll = l / N;
    // // sum += ll * (N - 1);
    // //
    // // long lll = l % N;
    //
    // a[i] %= a.length;
    //
    // for (int j = 0; j < a.length; j++) {
    // if (j == i) {
    // continue;
    // }
    // a[j] += l;
    // }
    // // print(N, a);
    // // Utils.debug(i, sum, l, a);
    // }
    // if (sum == before) {
    // break;
    // }
    // }
    // // Utils.debug("i", index, "sum", sum);
    // Utils.debug("sum", sum);
    // return sum;
    // }

    private static void print(int N, long[] a) {
        System.out.println(N);
        for (int i = 0; i < a.length; i++) {
            if (i > 0) {
                System.out.print(" ");
            }
            System.out.print(a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll R,G,B,N; cin >> R >> G >> B >> N;
    ll ans = 0;

    for(int r=0; r<=3000; r++){
        for(int g=0; g<=3000; g++){
            ll rest = N-r*R-g*G;
            if(rest >= 0 && rest%B == 0) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <queue>
#include <map>
#include <list>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int h, w;
int dp[100][100];

int minPath(int i, int j, const vector< vector<bool> >& ss) {
  if (dp[i][j] >= 0) return dp[i][j];
  if (i == h - 1 && j == w - 1 ) {
    return dp[i][j] = 0;
  }
  if (i == h - 1) {
    return dp[i][j] = ((ss[i][j] && !ss[i][j + 1]) ? 1 : 0) + minPath(i, j + 1, ss);
  }
  if (j == w - 1) {
    return dp[i][j] = ((ss[i][j] && !ss[i + 1][j]) ? 1 : 0) + minPath(i + 1, j, ss);
  }
  return dp[i][j] = min(
    ((ss[i][j] && !ss[i + 1][j]) ? 1 : 0) + minPath(i + 1, j, ss),
    ((ss[i][j] && !ss[i][j + 1]) ? 1 : 0) + minPath(i, j + 1, ss)
  );
}

int solve(const vector< vector<bool> >& ss) {
  return minPath(0, 0, ss) + (ss[0][0] ? 0 : 1);
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cin >> h >> w;
  vector< vector<bool> > ss(h, vector<bool>(w));
  rep(i, h) rep(j, w) {
    char s;
    cin >> s;
    ss[i][j] = s == '.';
  }

  for(auto& v : dp) for(auto& x : v) x = -1;  
  cout << solve(ss) << endl;
  return 0;
}




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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	if(n>=400 && n<=599){
		cout<<8<<"\n";
	}
	if(n>=600 && n<=799){
		cout<<7<<"\n";
	}
	if(n>=800 && n<=999){
		cout<<6<<"\n";
	}
	if(n>=1000 && n<=1199){
		cout<<5<<"\n";
	}
	if(n>=1200 && n<=1399){
		cout<<4<<"\n";
	}
	if(n>=1400 && n<=1599){
		cout<<3<<"\n";
	}
	if(n>=1600 && n<=1799){
		cout<<2<<"\n";
	}
	if(n>=1800 && n<=1999){
		cout<<1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const long double zero = 0.0;
ll x[1010], y[1010], r[1010];
long double dist(int i, int j)
{
    ll dx = (x[i] - x[j]);
    ll dy = y[i] - y[j];
    return pow((long double)(dx * dx + dy * dy), 0.5);
}

int main() {
    cout.precision(100);
    ll xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> r[i];
    }
    x[0] = xt;
    y[0] = yt;
    r[0] = 0;
    x[n + 1] = xs;
    y[n + 1] = ys;
    vector<pair<long double, int> > cost;
    for(int i = 0; i <= n; i++){
        pair<long double, int> in;
        in.first = max(zero, dist(i, n + 1) - r[i]);
        in.second = i;
        cost.push_back(in);
    }
    sort(cost.begin(), cost.end());
    for(int i = 0; i <= n; i++){
        if(cost[i].second == 0){
            cout << cost[i].first << endl;
            return 0;
        }
        for(int j = i + 1; j <= n; j++){
            cost[j].first = min(cost[j].first, cost[i].first + max(zero, dist(cost[i].second, cost[j].second) - r[cost[i].second] - r[cost[j].second]));
        }
        sort(cost.begin() + i + 1, cost.end());
    }
    return 0;
}


Measured memory_bytes: 384
N=int(input())
X = list(map(int,input().split()))
sums = 0
sumsum = 0
sumsumA = 0
P = 0

X.sort()

for i in X:
    sums += i
P = sums // len(X)

for i in X:
    sumsum += (i - P)**2

for i in X:
    sumsumA += (i - (P+1))**2
print(sumsum if sumsum < sumsumA else sumsumA)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int *root=new int[N];
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    root[a-1]++;
    root[b-1]++;
  }
  for(int i=0;i<N;i++){
    cout<<root[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

vector<vector<pii> > G(100005);
vector<int> e(100005, -1);
void dfs(int v) {
    int col = -1;
    for (pii p : G[v]) {
        if (e[p.S] != -1) {
            col = e[p.S];
            break;
        }
    }
    int c = 1;
    rep(i, sz(G[v])) {
        if (e[G[v][i].S] != -1) continue;
        if (c == col) ++c;
        e[G[v][i].S] = c++;
        dfs(G[v][i].F);
    }
}

void solve() {
    int n;
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].eb(b, i);
        G[b].eb(a, i);
    }
    
    dfs(0);
    cout << *max_element(all(e)) << endl;
    rep(i, n - 1) cout << e[i] << endl;
}


Measured memory_bytes: 12332
import java.util.*;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		Node[] nodes=new Node[n];
		Edge[] edges=new Edge[n-1];
		
		for(int i=0;i<n;i++) {
			nodes[i]= new Node();
			nodes[i].no=i;
		}
		

		for (int i=0;i<n-1;i++) {
			Edge e=new Edge();
			int a=sc.nextInt();
			int b=sc.nextInt();
			e.from=nodes[a-1];
			e.to=nodes[b-1];
			nodes[a-1].edges.add(e);
			nodes[b-1].edges.add(e);
			edges[i]=e;
		}
		List<Node>path = new ArrayList<Node>();
		path.add(nodes[0]);
		path=dfs(nodes,edges, path, nodes[n-1], new boolean[n]);
		
		for(int i=0;i<path.size();i++) {
			if(i*2<path.size()) {
				path.get(i).color=1;
			}
			else {
				path.get(i).color=-1;
			}
		}
		
		dfs2(nodes,edges,nodes[0], new boolean[n],(byte)1);
		dfs2(nodes,edges,nodes[n-1], new boolean[n],(byte)-1);

		int fennec=0;
		int snuke=0;
		for(int i=0;i<n;i++) {
			if(nodes[i].color==1) {
				fennec++;
			}
			else {
				snuke++;
			}
		}
		System.out.println(fennec>snuke ? "Fennec" : "Snuke");
	}
	
	static List<Node> dfs(Node[] nodes, Edge[] edges, List<Node> path, Node destination, boolean[] looked) {
		Node current=path.get(path.size()-1);
		if(current==destination) {
			return path;
		}
		else {
			looked[current.no]=true;
			for (Edge e : current.edges) {
				Node next= e.from==current ? e.to : e.from;
				if(!looked[next.no]) {
				path.add(next);
				return dfs(nodes, edges, path, destination, looked);
				}
			}
			path.remove(path.size()-1);
			return dfs(nodes,edges,path,destination,looked);
		}
	}
	
	static void dfs2 (Node[] nodes, Edge[] edges, Node current, boolean[] looked ,byte color) {
		looked[current.no]=true;
		current.color=color;
		for(Edge e : current.edges) {
			Node next= e.from==current ? e.to : e.from;
			if(!looked[next.no] && color*next.color!=-1) {
			dfs2(nodes, edges, next, looked, color);
			}
		}
	}
}

class Node {
	int no;
	List<Edge> edges=new ArrayList<Edge>();
	byte color;
}

class Edge {
	Node from;
	Node to;
}

Measured memory_bytes: 111412
while True:
	t = raw_input().split()

	if t[1] == "0":
		break

	l = int(t[1])
	a = []
	for i in range(l - len(t[0])):
		a.append(0)
	a = a + map(int, t[0])


	f = [-1 for i in range(10 ** l + 1)]

	def toi(a):
		return int("".join(map(str, a)))

	def toa(a, l):
		ret = []
		for i in range(l - len(str(a))):
			ret.append(0)
		ret = ret + map(int, str(a))
		return ret

	f[toi(a)] = 0

	for i in range(1, 21):
		a.sort()
		amin = toi(a)
		a.reverse()
		amax = toi(a)

		a = toa(amax - amin, l)
		an = toi(a)

		if f[an] != -1:
			print f[an], an, i - f[an]
			break

		f[an] = i

Measured memory_bytes: 59224
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;

    cout << (b - a) * (b - a - 1) / 2 - a << endl;
}

Measured memory_bytes: 256
for i in range(input()):
    L = map(int, raw_input().split())
    L1, L2 = [], []
    for x in L:
        if not L1 or L1[-1] < x:
            L1.append(x)
        elif not L2 or L2[-1] < x:
            L2.append(x)
        else:
            print "NO"
            break
    else:
        print "YES"

Measured memory_bytes: 4208
#include<bits/stdc++.h> 
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
int counts=1,maxn=-1;
int head[MAXN];
struct node{
	int to;
	int next;
	int color;
}edge[MAXN];

void addedge(int a,int b)  //链式前向星 
{	
	edge[counts].to=b;
	edge[counts].color=0;
	edge[counts].next=head[a];
	head[a]=counts++;
}

void dfs(int u,int c)  //与u相连的线段，上一个点与u相连的编号是c 
{
	int tmp=1;
	for(int i=head[u];i!=0;i=edge[i].next){
		if(tmp==c) tmp++;//如果tmp到了c就 tmp++ 
		maxn=max(maxn,tmp);  //maxn一直记录最大的颜色数
		edge[i].color=tmp;
		dfs(edge[i].to,tmp);
		tmp++;
	}
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a,b);
	}
	dfs(1,0);
	printf("%d\n",maxn);
	for(int i=1;i<counts;i++)
		printf("%d\n",edge[i].color);  //按照输入的顺序输出颜色 
	return 0;
}

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

#define ll long long

using namespace std;


int main(){
  int a,b,c,d,e,f;
  cin>>a>>b;
  c=a+b;
  d=a-b;
  e=a*b;
  f=c>d?(c>e?c:e):(d>e?d:e);
  cout<<f<<endl;


}



Measured memory_bytes: 256
n, l = gets.split.map(&:to_i)
a = []
n.times { |i| a << i + l }
sum = 0
a.each { |i| sum += i }
puts sum < 0 ? sum + a.map{ |i| i.abs }.sort.first : sum - a.map{ |i| i.abs }.sort.first

Measured memory_bytes: 1788
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

set <pii> Sx;
pair<int, pii> in[200050];
int ans[200050];
int main() {
	int N, Q, i, j;
	scanf("%d %d", &N, &Q);
	for (i = 1; i <= N; i++) {
		int t1, t2, t3;
		scanf("%d %d %d", &t1, &t2, &t3);
		in[i] = mp(t3, pii(t1, t2));
	}
	for (i = 1; i <= Q; i++) {
		int x;
		scanf("%d", &x);
		Sx.emplace(x, i);
	}
	sort(in + 1, in + N + 1);

	for (i = 1; i <= Q; i++) ans[i] = -1;
	for (i = 1; i <= N; i++) {
		int S = in[i].second.first - in[i].first;
		int T = in[i].second.second - in[i].first - 1;
		while (1) {
			auto it = Sx.lower_bound(pii(S, -INF));
			if (it == Sx.end() || it->first > T) break;
			ans[it->second] = in[i].first;
			Sx.erase(it);
		}
	}
	for (i = 1; i <= Q; i++) printf("%d\n", ans[i]);
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  unordered_set<int> islands;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    int x = 0;
    if (a == 1) x = b;
    if (b == n) x = a;
    if (x != 0) {
      if (islands.find(x) != islands.end()) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
      islands.insert(x);
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 8520
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
int N;
string S;

int main(int argc, const char * argv[]) {
    cin >> S;
    int n = S.length();

    int mindiff = 100000;
    rep(i, n-2) {
        string s = S.substr(i, 3);
        int k = stoi(s);
        chmin(mindiff, abs(k-753));
    }

    output(mindiff);

    return 0;
}

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

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

    ll N, M;
    cin >> N >> M;
    ll ans = 0;

    if (N >= M) {
        ans = M / 2;
    } else {
        if (N >= M / 2) {
            ans = M / 2;
        } else {
            ans = N + (M - N * 2) / 4;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main = readLn >>= main'
    where
        main' n = breads >>= B.putStrLn . solve n

-- |
-- >>> solve 3 [1, 10, 100]
-- "Yes"
--
-- >>> solve 4 [1, 2, 3, 4]
-- "No"
--
-- >>> solve 3 [1, 4, 1]
-- "Yes"
--
-- >>> solve 2 [1, 1]
-- "No"
--
-- >>> solve 6 [2, 7, 1, 8, 2, 8]
-- "Yes"
solve :: Int -> [Int] -> B.ByteString
solve n = judge . foldl' ff (0, 0)
    where
        ff (acc4, acc2) x
            | x `mod` 4 == 0 = (acc4 + 1, acc2)
            | x `mod` 2 == 0 = (acc4, acc2 + 1)
            | otherwise = (acc4, acc2)

        judge (n4, n2)
            | n4 >= (n - (n2 `div` 2) * 2) `div` 2 = "Yes"
            | otherwise = "No"

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 7804
/*   786     */


#include <bits/stdc++.h>
using namespace std;

//typedefs
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;

//#Defines
#define rep(i,a,b)	for(i=a;i<=b;i++)
#define repR(i,a,b)	for(i=a;i>=b;i--)
#define pb push_back
// #define pb emplace_back
#define F first
#define S second
#define mp make_pair
#define all(c)		c.begin(),c.end()
#define endl '\n'
#define pf(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define MOD 1000000007
#define trace(x) cerr << #x << ": " << x << " " << endl;

inline void normal(LL &a) { a %= MOD; (a < 0) && (a += MOD); }
inline LL modMul(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline LL modAdd(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline LL modSub(LL a, LL b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline LL modPow(LL b, LL p) { LL r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline LL modInverse(LL a) { return modPow(a, MOD-2); }
inline LL modDiv(LL a, LL b) { return modMul(a, modInverse(b)); }


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
//   cout<<std::setprecision(12)<<

int main()
{
    ll n,m;

    cin>>n>>m;
    ll ans = (n*(n-1))/2;
    ans += (m*(m-1))/2;
    //if(m%2)m--;
   // ans += n*m;

    cout<<ans<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,j,m,n,sum=0,S[10001],T[500];
  scanf("%d",&m);
  for(i=0;i<m;i++)scanf("%d",&S[i]);
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&T[i]);
  
  for(i=0;i<n;i++){
    S[m]=T[i];
    j = 0;
    while(S[j]!=T[i]){
      j++;
      if(j==m)break;
    }
    if(j!=m)sum++;
  }
  
  printf("%d\n",sum);
  return 0;
} 

Measured memory_bytes: 640