akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 998244353;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;
const int MAX_V = 110;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n; cin >> n;
	int ma = 0;
	VE a(n);
	rep(i, n) {
		int d; cin >> d;
		if (i == 0 && d != 0) {
			cout << 0 << endl; return 0;
		}
		a[d]++;
		chmax(ma, d);
	}
	if (a[0] != 1) {
		cout << 0 << endl; return 0;
	}
	int ans = 1;
	rep(i, ma) {
		rep(j, a[i + 1]) {
			ans *= a[i]; ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


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

const int lim = 105505;
int knap[lim];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    fill(knap,knap+lim,1e9);
    knap[0] = 0;
    int d,g;
    int probs[10],bonus[10];
    cin>>d>>g;
    g /= 100;
    for(int i=0;i<d;++i)
    {
        cin>>probs[i]>>bonus[i];
        bonus[i] /= 100;
    }
    

    for(int i = 0;i<d;++i)
    {
        int nows[lim];
        copy(knap,knap+lim,nows);
        for(int j = 0;j<lim;++j)
            if(knap[j]!=1e9)
            {
                for(int k=1;k<probs[i];++k)
                    if(j+k*(i+1)<lim)
                        nows[j+k*(i+1)] = min( nows[j+k*(i+1)], knap[j]+k );
                if(j+(i+1)*probs[i]+bonus[i]<lim)
                    nows[j+(i+1)*probs[i]+bonus[i]] = min( nows[j+(i+1)*probs[i]+bonus[i]], knap[j]+probs[i] );
            }
        copy(nows,nows+lim,knap);
    }

    int gmin = 2e9;
    for(int i=g;i<lim;++i)
        gmin = min(gmin,knap[i]);
    cout<<gmin<<endl;

    return 0;
}   

Measured memory_bytes: 1024
import itertools

n,m,x = map(int,input().split())
c = [0]*n
a = [[]]*n

for i in range(n) :
    d = list(map(int,input().split()))
    c[i] = d[0]
    a[i] = d[1:m+1]

max = 2**n
ans = 10**18
for i in range(max) :
    num = i
    cost = 0
    r = [0]*m
    check = 0
    for j in range(n) :
        f = num%2
        num = num//2
        if f == 0 :
            continue
        cost += c[j]
        r = [x+y for (x,y) in zip(r,a[j])]
    if all(elem >= x for elem in r) :
        ans = min(ans,cost)

if ans == 10**18 :
    print(-1)
else :
    print(ans)

Measured memory_bytes: 74468
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_A&lang=ja
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

// 盤面の縦横サイズ
const int SZ = 8;

// クイーンが配置可能かチェック
bool check(int row, int col, map<int, int> mp) {
    bool ret = true;
    REP(i, SZ) {
        // 左上, 右上
        if (mp.find(row - i) != mp.end()) {
            int t = mp[row - i];
            if (t == col - i || t == col + i) {
                ret = false;
                break;
            }
        }
        // 左下, 右下
        if (mp.find(row + i) != mp.end()) {
            int t = mp[row + i];
            if (t == col - i || t == col + i) {
                ret = false;
                break;
            }
        }
        // 列
        if (mp.find(i) != mp.end()) {
            int t = mp[i];
            if (t == col || t == col) {
                ret = false;
                break;
            }
        }
    }
    return ret;
}

// 深さ優先探索で配置可能な場所を探す。引数は行、配置済みのmap<行,列>
// 答えを出力したらtrueを返す。
bool dfs(int row, map<int, int> mp) {
    // クイーンを8行配置した
    if (row == SZ) {
        // 正解パターンを出力
        REP(row, SZ) {
            // Queenが存在する列
            int t = mp[row];
            REP(col, t) { cout << "."; }
            cout << "Q";
            FOR(col, t + 1, SZ) { cout << "."; }
            cout << "\n";
        }
        return true;
    }
    // その行にQueenが存在しなければ追加
    if (mp.count(row) == 0) {
        REP(col, SZ) {
            if (check(row, col, mp)) {
                mp[row] = col;
                if (dfs(row + 1, mp)) {
                    return true;
                }
            }
        }
    } else {
        if (dfs(row + 1, mp)) {
            return true;
        }
    }
    return false;
}

int main(void) {
    int N;
    cin >> N;
    map<int, int> mp;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        mp[a] = b;
    }
    dfs(0, mp);
    return 0;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

template <class T>
struct SegTree {
    int n;
    T identity;
    std::vector<T> values;
    std::function<T(T, T)> operateF;
    std::function<T(T, T)> updateF;

    SegTree(
        int n,
        T identity,
        std::function<T(T, T)> operateF,
        std::function<T(T, T)> updateF
    ) {
        this->identity = identity;
        this->operateF = operateF;
        this->updateF = updateF;

        int node = 1;
        while (node < n) node *= 2;
        this->n = node;
        this->values = std::vector<T>(2*node-1, identity);
    }

    void update(int i, T x) {
        i += n - 1;
        values[i] = updateF(values[i], x);
        while (i > 0) {
            i = (i-1) / 2;
            values[i] = operateF(values[i*2+1], values[i*2+2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](int i) {
        return values[i+n-1];
    }

private:
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return identity;
        if (a <= l && r <= b) return values[k];

        T childL = _query(a, b, 2*k+1, l, (l+r)/2);
        T childR = _query(a, b, 2*k+2, (l+r)/2, r);
        return operateF(childL, childR);
    }
};

int n, q;

int main() {
    cin >> n >> q;
    SegTree<ll> t = SegTree<ll>(
        n, 0,
        [](const ll& a, const ll& b) {
            return a + b;
        },
        [](const ll& a, const ll& b) {
            return a + b;
        }
    );

    REP(i, q) {
        int c, x, y; cin >> c >> x >> y;
        if (c == 0) {
            x--;
            t.update(x, y);
        } else {
            x--; y--;
            cout << t.query(x, y+1) << '\n';
        }
    }

    return 0;
}



Measured memory_bytes: 4904
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll n;
    cin>>n;
    cout<<ceil((double)n/(double)2);
}

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

int main() {
  string S , T ; cin >> S >> T ;
bool ans = false ;
for ( int i = 0; i < S . size (); ++ i ) {
if ( S == T ) {
ans = true ;
break ;
}
S = S . back () + S . substr (0 , S . size () -1);
}
if ( ans ) {
cout << " Yes " << endl ;
}
else {
cout << "No" << endl ;
}
}

Measured memory_bytes: 3580
#include <iostream>

using namespace std;

int main()
{
	int l, r;
	cin >> l >> r;
	int s = (r - l) > 2019 ? 2019 : r - l;
	int min = 1010101010;
	int mod = 2019;

	int t, u;
	for (int i = 0; i < s; i++) {
		for (int j = i + 1; j < s + 1; j++) {
			t = (l + i) % mod;
			u = (l + j) % mod;
			if (((t * u) % mod) < min) {
				min = ((t * u) % mod);
			}
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    long int k;
    int ans;
    cin >> a >> b >> c >> k;
    if(k%2 == 0){
        ans = a - b;
    }else{
        ans = b - a;
    }
    if(abs(ans) > 10000000000000000000){
        cout << "Unfair" <<endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    cout << n * n * n << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a <= b) {
    for (int i = 0; i < b; i++) {
      cout << to_string(a);
    }
    cout << endl;
  }
  else {
    for (int i = 0; i < a; i++) {
      cout << to_string(b);
    }
    cout << endl;
  }
  
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  a+=b;
  cout << a%24 << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
		String s = sc.next();
      	if(a >= 3200) System.out.println(s);
      	else System.out.println("red");	
    }
}

Measured memory_bytes: 35704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    int X;
    cin >> X;
    int count=0;
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(500*i+100*j+50*k==X){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import itertools
R = [i for i in range(5)]
A = []
for i in range(5):
    A.append(int(input()))
t = float('inf')
for k in itertools.permutations(R):
    tmp = 0
    for j in range(5):

        if j != 4:
            if A[k[j]] % 10 != 0:
                tmp += A[k[j]] + 10 - A[k[j]] % 10
            else:
                tmp += A[k[j]]
        else:
            tmp += A[k[j]]

    t = min(t, tmp)

print(t)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
string s,st,sn;
int i;
int main()
{
    cin>>s;
    st="hi";
    for(i=1;i<=7;i++)
    {
        sn+=st;
        if(sn==s)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

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

fn get_vec(n: &u64) -> Vec<u64> {
    let mut m = *n;
    let mut my_vec: Vec<u64> = Vec::new();
    my_vec.push(m / 100);
    m -= 100 * (m / 100);
    my_vec.push(m / 10);
    m -= 10 * (m / 10);
    my_vec.push(m);
    my_vec
}

fn main() {
    let n: u64 = input();
    let s: String = input();
    let s: Vec<char> = s.chars().collect();
    let mut counter = 0;
    for i in 0..1000 {
        let digit_vec = get_vec(&i);
        let mut j = 0;
        for c in &s {
            if j == 3 {                
                break;
            }
            if (*c as u64 - 48) == digit_vec[j] {
                j += 1;
            }
        }
        if j == 3 {
            counter += 1;            
        }
    }
    println!("{}", counter);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> to[200005];
int cnt[200005];
void dfs(int u, int p = -1) {
   for (int v : to[u]) {
      if (v == p) continue;
      cnt[v] += cnt[u];
      dfs(v, u);
   }
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, q;
   cin >> n >> q;
   rep(i, 0, n - 1) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      to[a].push_back(b);
      to[b].push_back(a);
   }
   rep(i, 0, q) {
      int p, x;
      cin >> p >> x;
      p--;
      cnt[p] += x;
   }
   dfs(0);
   rep(i, 0, n) cout << cnt[i] << endl;
   return 0;
}

Measured memory_bytes: 23552
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define ite ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int i;
int main(){
  int n;
  while(cin>>n,n){
    map<int,bool>t;
    rep(i,n){
      int tmp;
      cin>>tmp;
      t[tmp]=true;
    }
    vector<int>ta;
    vector<int>ha;
    loop(i,1,2*n+1){
      if(t[i])ta.pb(i);
      else ha.pb(i);
    }
    sort(all(ta));
    sort(all(ha));
    int ba=0;
    while(1){
      rep(i,ta.size())if(ta[i]>ba)break;
      if(i==ta.size())ba=0;
      else{
	ba=ta[i];
	ta.erase(ta.begin()+i);
      }
      if(!ta.size())break;
      //ここまで太郎の番
      rep(i,ha.size())if(ha[i]>ba)break;
      if(i==ha.size())ba=0;
      else{
	ba=ha[i];
	ha.erase(ha.begin()+i);
      }
      if(!ha.size())break;
      //ここまで花子の番
    }
    if(ta.size())cout<<0<<endl<<ta.size()<<endl;
    else cout<<ha.size()<<endl<<0<<endl;
  }	
}

Measured memory_bytes: 1228
n = int(input())
nums = list(map(int, input().split()))

count = 0
for i in range(n):
    min_j = i
    for j in range(i, n):
        if nums[j] < nums[min_j]:
            min_j = j
    if min_j != i:
        nums[i], nums[min_j] = nums[min_j], nums[i]
        count += 1

print(' '.join(map(str, nums)))
print(count)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) FOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;

bool f(int a){
  for(int i=2;i*i<=a;i++){
    if(a%i==0) return false;
  }

  return true;
}


int main(){
  cin>>n;

  for(int i=11,c=0;c<n;i+=10){
    if(f(i)){
      if(i!=11) cout<<' ';
      cout<<i;
      c++;
    }
  }

  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    INT(N);
    VEC(int, mochi, N);

    vec(int,num,100,0);

    int ans = 0;
    int i = 0;

    for(int i = 0; i < N; ++i){
        num[mochi[i]]++;
     }

    for(int i = 1; i <= 100; ++i){
        if(num[i] > 0){
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let s = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
    };

    let vs: Vec<u32> = {
        let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
        let mut vs = Vec::new();
        for _ in 0..n {
            vs.push(ws.next().unwrap().parse().unwrap());
        }
        vs
    };

    let mut map1: HashMap<u32, u32> = HashMap::new();
    let mut map2: HashMap<u32, u32> = HashMap::new();
    for (i ,v) in vs.iter().enumerate() {
        if i % 2 == 0 {
            if map1.contains_key(&v) {
                let tmp = map1[v].clone();
                map1.insert(v.clone(), tmp + 1);
            } else {
                map1.insert(v.clone(), 1);
            }
        } else {
            if map2.contains_key(&v) {
                let tmp = map2[v].clone();
                map2.insert(v.clone(), tmp + 1);
            } else {
                map2.insert(v.clone(), 1);
            }
        }
    }
    let mut max1 = 0;
    let mut max1b = 0;
    let mut v1 = 0;
    for (k, v) in &map1 {
        if v >= &max1 {
            v1 = k.clone();
            max1b = max1.clone();
            max1 = v.clone();
        }
    }

    let mut max2 = 0;
    let mut max2b = 0;
    let mut v2 = 0;
    for (k, v) in &map2 {
        if v >= &max2 {
            v2 = k.clone();
            max2b = max2.clone();
            max2 = v.clone();
        }
    }

    //println!("{:?}", map1);
    //println!("{:?}", map2);

    let mut ans1 = max1;
    let mut ans2 = max2;
    if v1 == v2 {
        if max1 == max2 {
            if max1b > max2b {
                ans1 = max1b;
            } else {
                ans2 = max2b;
            }
        } else if max1 > max2 {
            ans2 = max2b;
        } else {
            ans1 = max1b;
        }
    }
    println!("{}", n - ans1 - ans2);
}

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

int main() {
    string S ;
    cin >> S; // S  is 'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', or 'SAT'.
    if (S == "MON") cout << "6" << endl ;
    if (S == "TUE") cout << "5" << endl ;
    if (S == "WED") cout << "4" << endl ;
    if (S == "THU") cout << "3" << endl ;
    if (S == "FRI") cout << "2" << endl ;
    if (S == "SAT") cout << "1" << endl ;
    if (S == "SUN") cout << "7" << endl ;
	return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;

    if(a>b){
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
    else{
        for(int i=0;i<b;i++){
            cout<<a;
        }
    }
    cout<<endl;
}

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

int gcd(int n,int m){
  if(n<m){
    swap(n,m);
  }
  while(m>0){
    int r=n%m;
    n=m;
    m=r;
  }
  return n;
}
  
int main(){
  int n,m;

  cin>>n>>m;

  int ans=gcd(n,m);

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

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
int J[1005][1005],O[1005][1005],I[1005][1005];
using namespace std;
int main(){
	int N,M,K;
	cin>>N>>M;
	cin>>K;
	int cntJ=0,cntO=0,cntI=0;
	char a;
	memset(J,0,sizeof(J));
	memset(O,0,sizeof(O));
	memset(I,0,sizeof(I));
	for(int i=1;i<=N;i++){
		cntJ=0;
		cntO=0;
		cntI=0;
		for(int j=1;j<=M;j++){
			cin>>a;
			if(a=='J')cntJ++;
			if(a=='O')cntO++;
			if(a=='I')cntI++;
				J[i][j] = J[i-1][j]+cntJ;
				O[i][j] = O[i-1][j]+cntO;
			I[i][j] = I[i-1][j]+cntI;
		}
	}
	int aa,bb,cc,dd;
	for(int k=0;k<K;k++){
		cin>>aa>>bb>>cc>>dd;
	
	/*}
	for(int k=0;k<K;k++){*/
		cout<<J[cc][dd]+J[aa-1][bb-1]-J[aa-1][dd]-J[cc][bb-1]<<" ";
		cout<<O[cc][dd]+O[aa-1][bb-1]-O[aa-1][dd]-O[cc][bb-1]<<" ";
		cout<<I[cc][dd]+I[aa-1][bb-1]-I[aa-1][dd]-I[cc][bb-1]<<endl;
	}
}

Measured memory_bytes: 13004
def solution():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    diff = [j - i for i, j in zip(x, x[1:])]
    diff.sort()
    ans = sum(diff[:m-n]) if m-n > 0 else 0
    print(ans)

solution()


Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }

    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }

    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};


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

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

    vector<vector<pii>> querys(n);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--; r--;
        querys[l].push_back({r, i});
    }

    vector<vector<int>> points(n);
    vector<int> prev(n+1, -1);
    for(int i = 0; i < n; i++){
        int p = prev[a[i]];
        if(p != -1){
            points[p].push_back(i);
        }
        prev[a[i]] = i;
    }

    vector<int> ans(q);
    BIT<int> data(n);
    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j < points[i].size(); j++){
            data.add(points[i][j], 1);
        }
        for(int j = 0; j < querys[i].size(); j++){
            int r = querys[i][j].first;
            int index = querys[i][j].second;
            ans[index] = (r - i + 1) - data.sum(r);
        }
    }

    for(int i = 0; i < q; i++){
        cout << ans[i] << endl;
    }


}


Measured memory_bytes: 59796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for (int i=0;i<SZ(s);++i) {
        if (s[i] == 'S') {
            cnt++;
        }
        else {
            if (cnt == 0) {
                ans++;
            }
            else cnt--;
        }
    }
    cout << ans + cnt << endl;
}


Measured memory_bytes: 3720
#include<stdio.h>

int main(void){

  int a,b;

  scanf("%d%d",&a,&b);

  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<cstdlib>

int n;
int cnt = 0;
int INFTY = RAND_MAX;

void merge(int S[],int left,int mid,int right){
  int n1,n2;
  
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1 + 1],R[n2 + 1];
  
  for(int i = 0;i < n1;i++){
    L[i] = S[left + i];
  }
  
  for(int i = 0;i < n2;i++){
    R[i] = S[mid + i];
  }
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  int i = 0,j = 0;
  
  for(int k = left;k < right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i += 1;
      cnt++;
    }else{
      S[k] = R[j];
      j += 1;
      cnt++;
    }
  }
}

void mergeSort(int S[],int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}
    
int main(){
  int S[500000];
  int left,right;
  
  std::scanf("%d",&n);
  
  for(int i = 0;i < n;i++){
    std::scanf("%d",&S[i]);
  }
  
  left = 0;
  right = n;
  
  mergeSort(S,left,right);
  
  for(int i = 0;i < n;i++){
    if(i > 0) std::printf(" ");
    std::printf("%d",S[i]);
  }
  
  std::printf("\n");
  std::printf("%d\n",cnt);
  
  return 0;
}



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

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve());
        pw.close();
    }

    private static int solve() throws IOException {
        int N = readInt();
        int K = readInt();

        int[] a = new int[N];
        int max = 0;
        long sum = 0;
        for (int i = 0; i < N; i++) {
            a[i] = readInt();
            if (max < a[i]) max = a[i];
            sum += a[i];
        }

        if (K == 0) return max;
        if (K >= sum - N) return 1;
        // Now 0 < K  < sum - N

        int low = 1;
        int high = max;
        // K cuts can make the longest log as small as
        // high but not as small as low.
        while (low + 1 < high) {
            int mid = (low + high) / 2;
            int c = 0;
            for (int i = 0; i < N; i++) {
                c += (a[i] + mid - 1) / mid - 1;
            }
            if (c <= K) high = mid;
            else low = mid;
        }
        return high;
    }
}


Measured memory_bytes: 55072
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var m = "abcdefghijklmnopqrstuvwxyz.?! ";
        var d = new Dictionary<string, char>();
        var p = 0;
        for (int i = 1; i <= 6; i++)
            for (int j = 1; j <= 5; j++)
                d[i.ToString() + (j).ToString()] = m[p++];
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var s = line.Trim();
            change(d, s);
        }
    }
    public static void change(Dictionary<string,char> d, string s)
    {
        var ret = "";
        var sL = s.Length;
        if (sL % 2 == 1) { Console.WriteLine("NA"); return; }
        for (int i = 0; i <= sL-2; i+= 2)
        {
            var t = s.Substring(i, 2);
            if (d.ContainsKey(t)) ret += d[t];
            else { Console.WriteLine("NA"); return; }
        }   
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
int i,n,t=0,j;
cin>>n;
string s[n];
for(i=0;i<n;i++)
{

    cin>>s[i];


}
sort(s,s+i);
for(i=0;i<n;i++)
{
    if(s[i]==s[i-1])
        t++;
}
cout<<n-t<<endl;
return 0;
}


Measured memory_bytes: 9880
#include <iostream>

namespace NS20200711Acing
{

  class XYZtriplets final
  {
  public:
    XYZtriplets() = default;
    ~XYZtriplets() = default;

  public:
    void Run()
    {
      Input();
      Calc();
      Output();
    }

    void Input()
    {

      std::cin >> m_N;
    }

    void Calc()
    {
      int max_k = 0;      
      for (int i = 1; i < m_N; ++i)
      {
        int sum = i * i + 2 * i + 3;
        if (sum > m_N) { max_k = i-1; break; }
      }

      for (int i = 1; i <= max_k; ++i)
      {
        int i2 = i * i;
        for (int j = 1; j <= max_k; ++j)
        {
          int j2 = j * j;
          int ji = j * i;
          if (i2 + j2 + ji > m_N) break;
          for (int k = 1; k <= max_k; ++k)
          {
            int sum = i2 + j2 + k*k + ji + j*k + i*k;
            if (sum <= m_N)
            {
              ++m_A[sum];
            }
            else
            {
              break;
            }
          }
        }
      }
    }

    void Output()
    {
      for(int i=1;i<=m_N;++i)
        std::cout << m_A[i] << std::endl;
    }

  private:
    static const int N_MAX = 10000;
    int m_N;
    int m_A[N_MAX+1] = {};
  };

}
int main()
{
  NS20200711Acing::XYZtriplets prob;
  prob.Run();

  return 0;
}





Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");

        int[] data = new int[line.length];
        for (int i = 0; i < data.length; i++) {
        	data[i] = Integer.parseInt(line[i]);
		}

        Dice dice = new Dice(data);

        char[] moveData = br.readLine().toCharArray();
        for (int i = 0; i < moveData.length; i++) {
        	dice.move(moveData[i]);
        }

        System.out.println(dice.getTop());
    }
}

class Dice {
	private int top;
	private int bottom;
	private int left;
	private int right;
	private int front;
	private int back;


	Dice(int[] data) {
		this.top    = data[1 - 1];
		this.bottom = data[6 - 1];
		this.left   = data[4 - 1];
		this.right  = data[3 - 1];
		this.front  = data[2 - 1];
		this.back   = data[5 - 1];
	}

	public void move(char m) {
		int temp = -1;
		switch (m) {
		case 'N':
			temp = this.top;
			this.top    = this.front;
			this.front  = this.bottom;
			this.bottom = this.back;
			this.back   = temp;

			break;

		case 'E':
			temp = this.top;
			this.top    = this.left;
			this.left   = this.bottom;
			this.bottom = this.right;
			this.right  = temp;

			break;

		case 'W':
			temp = this.top;
			this.top    = this.right;
			this.right  = this.bottom;
			this.bottom = this.left;
			this.left   = temp;

			break;

		case 'S':
			temp = this.top;
			this.top    = this.back;
			this.back   = this.bottom;
			this.bottom = this.front;
			this.front  = temp;

			break;
		}
	}

	public int getTop() {
		return this.top;
	}
}

Measured memory_bytes: 24360
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
#define WHITE 0
#define GRAY 1
#define BLACK 2
int H, W;
vector<string> maze;

int bfs(int sy, int sx, int gy, int gx)
{
    int seen[30][30];
    memset(seen, 0, sizeof(seen));
    int dist[30][30];
    memset(dist, 0, sizeof(dist));

    queue<int> yque;
    queue<int> xque;
    seen[sy][sx] = true;
    dist[sy][sx] = 0;
    yque.push(sy);
    xque.push(sx);

    while (!yque.empty() && !xque.empty())
    {
        int nowy = yque.front();
        yque.pop();
        int nowx = xque.front();
        xque.pop();

        for (int i = 0; i < 4; i++)
        {
            int nexty = nowy + dy4[i];
            int nextx = nowx + dx4[i];

            bool isOKY = (0 <= nexty && nexty < H);
            bool isOKX = (0 <= nextx && nextx < W);

            if (!(isOKY && isOKX))
                continue;
            if (maze[nexty][nextx] == '#')
                continue;
            if (seen[nexty][nextx])
                continue;

            seen[nexty][nextx] = true;
            dist[nexty][nextx] = dist[nowy][nowx] + 1;

            yque.push(nexty);
            xque.push(nextx);
        }
    }

    return dist[gy][gx];
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> H >> W;
    maze.resize(H);
    rep(h, H) cin >> maze[h];

    int ans = 0;
    for (int sh = 0; sh < H; sh++)
    {
        for (int sw = 0; sw < W; sw++)
        {
            for (int gh = 0; gh < H; gh++)
            {
                for (int gw = 0; gw < W; gw++)
                {
                    if (maze[sh][sw] == '#')
                        continue;
                    if (maze[gh][gw] == '#')
                        continue;
                    ans = max(ans, bfs(sh, sw, gh, gw));
                }
            }
        }
    }

        cout << ans << endl;
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
  long long  sum=0;
     int n;
  cin>>n;
  for(int i=1;i<=n;i++)
     for(int j=1;j<=n;j++)
         for(int k=1;k<=n;k++)
           sum += gcd(i,gcd(j,k));
          
  cout<<sum<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    set<char> se1{'R', 'U', 'D'}, se2{'L', 'U', 'D'};
    bool good = true;
    for(int i=1; i<=n; i++){
        char c = s[i-1];
        if(i%2==0){
            if(se2.count(s[i-1])==0){
                good = false;
                break;
            }
        }
        else{
            if(se1.count(s[i-1])==0){
                good = false;
                break;
            }
        }
    }
    if(good) 
        cout <<"Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

#define 	N 200*1000+5
int n, m;
vi v[N];
bool check[N];


bool dfs(int pos, int cnt){
	if(cnt > 2) return false;
	check[pos] = true;
	if(pos == n-1) return true;
	bool tt = false;
	rep(i,0,sz(v[pos]))
		if(!check[v[pos][i]])
			tt = tt || dfs(v[pos][i], cnt+1);
	return tt;
}
void solve(){
	cin>>n>>m;
	rep(i,0,m){
		int a, b;
		cin>>a>>b;
		a--, b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	if(dfs(0,0))cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12144
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    rep(i, 0, n - 1){
        if(a[i] == a[i + 1]){
            ans = a[i];
            rep(j, i + 2, n - 1){
                if(a[j] == a[j + 1]){
                    ans *= a[j];
                    cout << ans << endl;
                    return 0;
                }
            }
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 1024
a, b, c, x = [int(input()) for i in range(4)]

same_count = 0
for a_i in range(a+1):
    for b_i in range(b+1):
        for c_i in range(c+1):
            if 500*a_i + 100*b_i + 50*c_i == x:
                same_count += 1

print(same_count)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
  {
 int a,b,n,count=0;
  cin>>a>>b>>n;
  
  for(int i =a;i<=b;i++){
    if(i%n==0)
      {
      count++;
      }
    }
  cout<<count<<endl;
  }
  

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

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

    vector<int> f(n+1);
    f[1] = 1;
    
    for (int i = 2; i <= n; i++) {
        for (int j = 2, d = i; j <= i; j++) {
            while (!(d % j)) {
                f[j]++;
                d /= j;
            }
        }
    }

    int ans = 0;

    for (int i = 2; i <= n - 2; i++) {
        for (int j = i + 1; j <= n - 1; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (f[i] >= 2 && f[j] >= 4 && f[k] >= 4) ans++;
                if (f[i] >= 4 && f[j] >= 2 && f[k] >= 4) ans++;
                if (f[i] >= 4 && f[j] >= 4 && f[k] >= 2) ans++;
            }
        }
    }

    for (int i = 2; i <= n - 1; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (f[i] >= 2 && f[j] >= 24) ans++;
            if (f[i] >= 24 && f[j] >= 2) ans++;
            if (f[i] >= 4 && f[j] >= 14) ans++;
            if (f[i] >= 14 && f[j] >= 4) ans++;
        }
    }

    for (int i = 2; i <= n; i++) {
        if (f[i] >= 74) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int S=1e5;
vector<int> m[S];
int x[S];
int N,L;

int g(int a,int k){
	if(k==0){
		return a;
	}
	if(m[a].size()==0){
		int v=upper_bound(x+a,x+N,x[a]+L)-x-1;
		m[a].push_back(v);
	}
	int e=0;
	int j=1;
	while(2*j<=k){
		if(m[a].size()==e+1){
			int v=g(m[a][e],j);
			if(m[a][e]==N){
				return N;
			}
			m[a].push_back(v);
		}
		e++;
		j*=2;
	}
	return g(m[a][e],k-j);
}
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	cin >> L;
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		if(a>b){
			swap(a,b);
		}
		//cerr << a << b << endl;
		int low=0;
		int hi=S;
		while(low+1<hi){
			int mid=(low+hi)/2;
			int v=g(a,mid);
			//cerr << mid << ": " << v << endl;
			if(b<=v){
				hi=mid;
			}
			else{
				low=mid;
			}
		}
		/*
		for(int j=0;j<m[a].size();j++){
			cerr << m[a][j] << " ";
		}
		cerr << endl;
		*/
		cout << hi << endl;
	}


	return 0;
}



Measured memory_bytes: 14336