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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int r;
  cin >> r;
  cout << 3 * r * r << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vll;
typedef vector<vector<long long>> vvll;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const double eps9 = 1e-9;



int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int x;
	cin >> x;
	vector<bool> dp(x + 1, false);
	vi p(6);
	iota(all(p), 100);
	dp[0] = true;
	for (int cx = 1; cx <= x; cx++)
	{
		for (int i = 0; i < sz(p); i++)
		{
			if (cx - p[i] >= 0)
				dp[cx] = dp[cx - p[i]] || dp[cx];
		}
	}
	if (dp[x])
		cout << 1;
	else
		cout << 0;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    string a,b;
    cin >> a >> b;
    string s=a+b;
    ll n=stoi(s);
    ll x=sqrt(n);
    if (x*x==n)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    akari<seika> g(h);
    yukari<int> ans(h, akari<int>(w, -1));
    for (int i = 0; i < h; i++)
    {
        cin >> g[i];
        //cout << g[i] << endl;
    }
    int cnt = 1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (g[i][j] == '#')
            {
                ans[i][j] = cnt;
                cnt++;
                continue;
            }
            if (j && ans[i][j] == -1)
            {
                ans[i][j] = ans[i][j - 1];
            }
        }
        for (int j = w - 2; j >= 0; j--)
        {
            if (ans[i][j] == -1)
            {
                ans[i][j] = ans[i][j + 1];
            }
        }
    }
    for (int i = h - 2; i >= 0; i--)
    {
        for (int j = 0; j < w; j++)
        {
            if (ans[i][j] == -1)
            {
                ans[i][j] = ans[i + 1][j];
            }
        }
    }
    for (int i = 1; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (ans[i][j] == -1)
            {
                ans[i][j] = ans[i - 1][j];
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}

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


Measured memory_bytes: 1280
#include <stdio.h>

int main(){
   int x, y, z, i, n;
   n = 0;
   scanf("%d %d %d", &x, &y, &z);
   for( i = x; i <= y; i++){
      if( z % i == 0 ){
         n = n + 1;
      }
   }
   printf("%d\n", n);

   return 0;

}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll e[n];
  for(ll i=0;i<n;i++) cin >>e[i];
  sort(e,e+n);
  vector <pair<ll,ll>> ee;
  ll c=1;
  for(ll i=0;i<n;i++){//配列の中身がそれぞれ何個あるかのカウント
   if(e[i]==e[i+1]){
     c++;
     if(i==n-2){//122333みたいなときは3のところがansに入らないので
       ee.push_back(make_pair(c,e[i]));
       break;
     }
   }
   else{
     ee.push_back(make_pair(c,e[i]));
     if(i==n-2) {
         ee.push_back(make_pair(1,e[i+1]));//112223とかのときにansに3の分を足すため
         break;
     }
     c=1;
   }
 }
 ll es=ee.size();
 vector <pair<ll,ll>> p;
 for(ll i=0;i<es;i++){
   if(ee[i].first>1) p.push_back(make_pair(ee[i].first,ee[i].second));
 }
 ll ps=p.size();
 if(ps==0) cout <<0<<endl;
 else if(ps==1){
  if(p[0].first>=4) cout <<p[0].second*p[0].second<<endl;
  else cout <<0<<endl;
 }
 else{
     if(p[ps-1].first>=4) cout <<p[ps-1].second*p[ps-1].second<<endl;
     else cout <<p[ps-1].second*p[ps-2].second<<endl;
 }
}


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

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

    int _out = 1;

    for(int i=6; i>0; i--){
        if(n >= (1<<i)){
            _out = 1<<i;
            break;
        }
    }

    cout << _out << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define Q 50000
#define notFound 0

int binarySearch(int[],int,int);

int main()
{
  int i,n,q,key,cnt=0;
  int S[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySearch(S,key,n)){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  
  
  return 0;
}

int binarySearch(int A[],int key,int n)
{
  int left=0,right,mid;
  
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(A[mid] == key){
      return mid;
    }
    else if(key<A[mid]){
      right = mid;
    }
    else {
      left = mid+1;
    }
  }
  return notFound;
  
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  vector<string> items;  
  rep(i, s.size()) {
    if (s[i] == t[0] || s[i] == '?') {
      bool ok = true;
      for (int j = 0; j < t.size(); j++) {
        if (i+j >= s.size()) {
          ok = false;
          break;
        }
        if (s[i+j] == t[j] || s[i+j] == '?') continue;
        ok = false;
      }
      if (ok) {
        string c = "";
        rep(j, s.size()) {
          c += s[j];
        }
        rep(j, t.size()) c[i+j] = t[j];
        rep(j, s.size()) {
          if (c[j] == '?') c[j] = 'a';
        }
        items.push_back(c);
      }
    }
  }
  if (items.size()) {
    sort(items.begin(), items.end());
    cout << items[0] << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int top;
int A[1000000];

void push(int x){
  top = top + 1;
  A[top] = x;
}

int pop(){
  top = top -1;
  return A[top+1];
}

int main(){
  int x;
  char s[100];
  int y,z;
  top = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      y = pop();
      z = pop();
      push(y + z);
    } else if ( s[0] == '-' ){
      z = pop();
      y = pop();
      push(y - z);
    } else if ( s[0] == '*' ){
      y = pop();
      z = pop();
      push(y * z);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<string> t;
    rep(i,s.size()){
        if((s[i]-'A'+n)<26){
            s[i] += n;
        }else{
            s[i] = 'A' + (s[i]-'A'+ n-26);
        }
        
    }
    cout << s<< endl;
    

    return 0;
}


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

int main()
{
	int ans=0, a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	for (int i = 0; i < 5; i++){
		if (a[i] > 40)ans += a[i];
		else ans += 40;
	}
	cout << ans / 5<<endl;
	return 0;
}




Measured memory_bytes: 3104
import math

n = int(input())

a = math.ceil(math.sqrt(n))

li = []
for i in range(1,a+1):
    if n%i == 0:
        li.append(i)

memo1 = li[-1]
memo2 = n//memo1

m1 = len(str(memo1))
m2 = len(str(memo2))

print(max(m1,m2))



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{

  int n; cin>>n;
  ve arr(n),A(n);
  rep(i,n&&cin>>arr[i])
  {
      A[i]=arr[i];
  }
     sort(all(A));
  rep(i,n)
 {
    if(arr[i]<A[n-1])
        cout<<A[n-1]<<endl;
    else
        cout<<A[n-2]<<endl;
 }
go;
}


Measured memory_bytes: 3200
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

dp = [[0] * w for _ in range(h)]
dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if (j != w - 1) and (a[i][j + 1] == '.'):
                dp[i][j + 1] += dp[i][j]
        if (i != h - 1) and (a[i + 1][j] == '.'):
                dp[i + 1][j] += dp[i][j]
print(dp[-1][-1]%(10**9+7))


Measured memory_bytes: 165252
n,a,b = map(int,input().split())
s= input()

all_cnt = 0
for_cnt = 0
for i in range(n):
    if s[i] == "a":
        if all_cnt < a+b:
            print("Yes")
            all_cnt += 1
        else:
            print("No")
    elif s[i] == "b":
        if all_cnt < a+b and for_cnt < b:
            print("Yes")
            all_cnt += 1
            for_cnt += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
object Main extends App {
  val Array(n, x) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val l = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var ans = 1
  var now = 0
  l.foreach { i =>
    now += i
    if (now <= x) {
      ans += 1
    }
  }


  println(ans)
}


Measured memory_bytes: 27204
a=[0]
for i in range(28):
    n=int(input())
    a.append(n)
a.append(31)
a.sort()
i=1
j=0
while True:
    if a[i]-a[j]>1:
        print(a[j]+1)
    i+=1
    j+=1
    if i==30:
        break


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
*/


//3111111111111111111111111111111



int n;
int n1;
int k;
int tmp1[31];
int morty[310];
int mortyy[310];
int mortyyy[310];
int mortyyyy[310];
int rick = 0;

	void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}

	void solve(){
		in(n);
		in(n1);
		in(k);
		FOR(i,0,k){
			in(morty[i]);
			in(mortyy[i]);
			in(mortyyy[i]);
			in(mortyyyy[i]);
		}
		dfs(1,1);
		out(rick);

	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  
  for (int j = 0; j < W + 2; j++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i); 
    cout << "#" + vec.at(i) + "#" << endl;
  }
  
  for (int k = 0; k < W + 2; k++) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <vector>
#include<valarray>
#include<map>
#include <utility>
#include <deque>
#include <queue>
using namespace std;

int main()
{
unsigned long long int n;
char c;
string s;
cin>>n;
long long counter=0;
while (n>=26)
{


    if(n%26!=0)
    {
        counter++;
        n--;
    }
     else if(n%26==0&&counter==0)
    {
         s+='z';
         n-=1;
         n/=26;

    }
    else if(n%26==0)
    {


        c =(96+counter);



        s+=c;
        counter=0;
        n/=26;
    }

}

if(n==26)
    s+='a';
else if(n>=1&&n<26) {


    c = (96 + n);
    s += c;
}
reverse(s.begin(),s.end());

cout<<s;


    return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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;}

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    ll n, g; cin >> n >> g;
    vector<vector<ll> > dp(n+1, vector<ll>(2e4, 0));
    REP(i, 0, n){
        int p, c; cin >> p >> c;
        vector<ll> cpi = dp[i];
        vector<ll> lis = cpi;
        REP(l, 0, p){
            REP(k, 0, 1e4 + 500){
                lis[k+l] = max(cpi[k+l], cpi[k]+l*100*(i+1));
            }
        }
        REP(k, 0, 1e4 + 500){
            lis[k+p] = max(cpi[k+p], cpi[k]+p*100*(i+1)+c);
        }
        dp[i+1] = lis;
    }
    REP(i, 0, 2e4){
        if(dp[n][i] >= g){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2464
#include <stdio.h>

int main(void){
    int n, m, x;
    
    scanf("%d %d %d", &n, &m, &x);
    
    int fee[m], i;
    
    for (i = 0; i < m; i++){
        scanf("%d", fee + i);
    }
    
    int left = 0, right = 0;
    
    for (i = 0; i < m; i++){
        if (fee[i] < x){
            left = i + 1, right = (m - left);
        }
    }
    
    if (left >= right){
        printf("%d", right);
    } else {
        printf("%d", left);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

int main(){
    int h,w;
    cin >>h >>w;
    vector<ll> a(h),b(w);
    rep(i,h) cin >>a[i];
    rep(i,w) cin >>b[i];
    sort(all(a));
    sort(all(b));

    ll ans = 0;
    ll A=0, B=0;
    int ai=0, bi=0;
    while(ai<h && bi<w){
        ll av = INF, bv = INF;
        if(ai<h) av = a[ai];
        if(bi<w) bv = b[bi];

        if(av<=bv){
            ans += av*(w-B);
            ++A;
            ++ai;
        }
        else{
            ans += bv*(h-A);
            ++B;
            ++bi;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4424
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  string S;
  cin >> S;
  lint L=S.length();
  string S2="";
  rep(i,L){
    if(i<L-1 && S[i]=='B' && S[i+1]=='C') S2+='D',i++;
    else if(S[i]=='A') S2+='A';
    else S2+='B';
  }
  lint L2=S2.length(),ans=0,count=0;
  rep(i,L2){
    if(S2[i]=='A') count++;
    else if(S2[i]=='D') ans+=count;
    else count=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 916
def main03():
    data = int(input())
    data2 = input().split()
    num = []
    for i in range(data):
        num.append(int(data2[i]))
    are = 0
    for i in range(1,data,1):
        if i % 2 == 1:
            are = are + num[i]
        else:
            are = are - num[i]
    are = num[0] - are
    results = []
    are = int(are / 2)
    results.append(are)
    for i in range(data-1):
        are = num[i] - are
        results.append((are))
    for i in range(data):
        print((results[i]*2), end='')
        print(" ", end='')
    print("")

if __name__ == "__main__":
    main03()

Measured memory_bytes: 19708
N,M =[int(i) for i in input().split(' ')]
table = [0]*N

for i in range(M):
    a,b = [int(i) for i in input().split(' ')]
    if a==1:
        table[b-1] +=1
        if b==N:
            table[b-1] +=1
    if b==N:
        table[a-1]+=1
#    print(table)
flag = True
for i in table:
    if i==2:
        print("POSSIBLE")
        flag = False
        break

if flag:
    print("IMPOSSIBLE")

#print(table)


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

long long gcd(long long c,long long d){
  if(d==0) return c;
  return gcd(d,c%d);
}

int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long e=c*d/gcd(c,d);//eは最小公倍数
  a--;
  long long first=a/c+a/d-a/e;
  long long last=b/c+b/d-b/e;
  cout<<b-a-(last-first)<<endl;
}

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

using namespace std;

using ll = long long;

constexpr ll M = 1000000007;

ll modpow(ll n, ll r = M - 2) {
  if (r == 0) return 1;
  auto prev = modpow(n, r / 2);
  auto hoge = (prev * prev) % M;
  return (r % 2 == 0) ? hoge : (hoge * n) % M;
}

ll comb(ll n, ll k) {
  ll pat = 1;
  for (ll i = 0; i < k; i++) {
    pat *= n - i;
    pat %= M;
    pat *= modpow(i + 1ll);
    pat %= M;
  }
  return pat;
}

ll sum_mans(ll n, ll m) {
  ll total = 0;
  auto add = [&total](ll d, ll l) {
    ll dis = d * (d + 1) / 2ll;
    dis %= M;
    dis *= l;
    dis %= M;
    total += dis;
    total %= M;
  };
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      add(i, m);
      add(n - i - 1, m);
      add(j, n);
      add(m - j - 1, n);
    }
  }
  return total;
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m, k;
  cin >> n >> m >> k;
  ll res = sum_mans(n, m);
  res *= comb(n * m - 2, k - 2);
  res %= M;
  res *= modpow(2);
  res %= M;
  cout << res << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
def factorization(n): #2以上の整数n => [[素因数, 指数], ...]の2次元リストを返す
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
N = int(input())
if N == 1:
    print(0)
else:
    li = factorization(N)
    ans = 0
    for arr in li:
        num = arr[1]
        cur = 1
        while num >= (cur)*(cur+1) // 2:
            cur += 1
        ans += cur-1
    print(ans)


Measured memory_bytes: 10848
#include <stdio.h>
#include <algorithm>
#include <numeric>

using namespace std;


int gcd(int a, int b) {
  if (a < b){
    gcd(b, a);
  }

  int r;
  while (r = a % b) {
    a = b;
    b = r;
  }

  return b;
}

int main() {
  int n;
  scanf("%d", &n);

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

  sort(x, x+n+1);

  if (n + 1 <= 2) {
    printf("%d\n", x[1] - x[0]);
    return 0;
  }

  int g = gcd(x[1] - x[0], x[2] - x[1]);
  for (int i = 2; i < n; i++) {
    g = gcd(g, x[i+1] - x[i]);
  }

  printf("%d\n", g);
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


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 MAX_H 20
#define MAX_W 20
#define INF 1152921504606846976

typedef pair<i64, i64> P;

i64 H, W;
char G[MAX_H][MAX_W];
i64 d[MAX_H][MAX_W];

i64 dy[] = {-1,  0, 1, 0};
i64 dx[] = { 0, -1, 0, 1};

bool inside(i64 y, i64 x) {
  return (0 <= y && y < H && 0 <= x && x < W);
}

i64 bfs(i64 sy, i64 sx) {
  i64 maxd = 0;
  queue<P> que;

  REP(y, H) {
    REP(x, W) {
      d[y][x] = INF;
    }
  }

  que.push(mp(sy, sx));
  d[sy][sx] = 0;

  i64 ny, nx;
  while (!que.empty()) {
    P yx = que.front(); que.pop();
    REP(i, 4) {
      ny = yx.F + dy[i];
      nx = yx.S + dx[i];
      if (inside(ny, nx) && d[ny][nx] == INF && G[ny][nx] == '.') {
        que.push(mp(ny, nx));
        d[ny][nx] = d[yx.F][yx.S] + 1;
        chmax(maxd, d[ny][nx]);
      }
    }
  }

  return maxd;
}

void solve() {
  i64 maxd = 0;

  REP(sy, H) {
    REP(sx, W) {
      if (G[sy][sx] == '#') continue;
      chmax(maxd, bfs(sy, sx));
    }
  }

  cout << maxd << endl;
}

int main() {
  cin >> H >> W;
  REP(y, H) {
    REP(x, W) {
      cin >> G[y][x];
    }
  }

  solve();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<ll> b(n-1);
    rep(i,0,n-1)cin>>b[i];
    vector<ll> a;
    a.push_back(b[0]);
    a.push_back(b[0]);
    rep(i,1,n-1){
        if(a.back() <= b[i]){
            a.push_back(b[i]);
        }else{
            a.pop_back();
            a.push_back(b[i]);
            a.push_back(b[i]);
        }
    }
    ll ans=0;
    rep(i,0,a.size()){
        ans += a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

using namespace std;

#define MOD 1000000007
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ALL(x) ((x).begin(), (x).end())
#define sync(); ios_base::sync_with_stdio(0);

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


int main() {
  sync();

  ll n;
  cin >> n;
  vector<ll> v(n);
  for(ll i = 0; i < n; i++){
    cin >> v[i];
    v[i]--;
  }

  ll ans = 0;
  for(ll i = 0; i < n; i++){
    if(v[i] > i && v[v[i]] == i){
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
  

}


Measured memory_bytes: 1024
X,K,D=map(int,input().split())
res = X
n = abs(int(X/D))
rest = 0
if n >= K:
  if X < 0:
    res = X+K*D
  else:
    res = X-K*D
else:
  if X < 0:
    res = X+n*D
  else:
    res = X-n*D
  rest = K-n
  if rest % 2 == 1:
    if res < 0:
      res = res+D
    else:
      res = res-D
  else:
    pass
res = abs(res)
print(res)

Measured memory_bytes: 9192
#include <stdio.h>

int main () {
	int n, a, b, dig1, dig2, dig3, dig4, dig5;
	int sum = 0;
	scanf("%d %d %d", &n, &a, &b);
	for(int i = 1; i <= n; i++) {
		dig1 = i%10;
		dig2 = (i/10)%10;
		dig3 = (i/100)%10;
		dig4 = (i/1000)%10;
		dig5 = (i/10000)%10;
		if ((dig1+dig2+dig3+dig4+dig5) >= a && (dig1+dig2+dig3+dig4+dig5) <= b) {
			sum += i;
		}
	}
	printf("%d\n", sum);
	
	
	return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int mod = 1000000007;
    long long res = 1;
    for (int i = 0; i < n; i++) {
        res = res * (i + 1) % mod;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict

N = int(input())
c = [int(i) - 1 for i in input().split()]
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  a, b = map(int, input().split())
  vec[a - 1].append(b - 1)
  vec[b - 1].append(a - 1)

ret = [N * (N - 1) // 2 + N] * N

par = [[N + i] for i in range(N)]
vec2 = [[] for _ in range(N * 2)]
have = [0] * (N * 2)
way = [0] * (N * 2)
fr = [0] * (N + 2)

for i in range(N, 2 * N) :
  have[i] = N + 1

mem = defaultdict(int)

def dfs(cur, pre) :
  s = 1
  ancestor = par[c[cur]][-1]
  vec2[ancestor].append(cur)
  if pre != -1 :
    fr[cur] = way[ancestor]
  par[c[cur]].append(cur)
  for nex in vec[cur] :
    if nex == pre : continue
    way[cur] = nex
    s += dfs(nex, cur)
    mem[(cur, nex)] = have[nex]
  par[c[cur]].pop()
  have[cur] = s
  return s
  
dfs(0, -1)

for i in range(N, 2 * N) :
  mem[(i, 0)] = N

for i in range(N) :
  q = [(N + i, -1)]
  while q :
    cur, pre = q.pop()
    for nex in vec2[cur] :
      mem[(cur, fr[nex])] -= have[nex]
      q.append((nex, cur))

for k, v in mem.items() :
  if v <= 0: continue
  if k[0] >= N :
    ret[k[0] % N] -= v * (v - 1) // 2 + v
  else :
    ret[c[k[0]]] -= v * (v - 1) // 2 + v
  
for i in range(N) :
  print(ret[i])

Measured memory_bytes: 417756
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n,@k = gets.split.map(&:to_i)
  end

  def solve
    n - k + 1
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

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

string a;
int cnt;
char t;
int main()
{
    int i;
//    freopen ("input.txt", "r", stdin);
    cin >> a;
    t = a[0];
    cnt = 1;
    for (i = 1; i < a.size(); i++) {
        if (t != a[i]) cnt++;
        t = a[i];
    }
    cout << cnt - 1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using P = pair<int, int>;

signed main() {
    while (true) {
        int N, M, a;
        cin >> N >> M >> a;
        if (N == 0 && M == 0 && a == 0) break;
        map<P, int> nexts;
        for (int i = 0; i < M; i++) {
            int h, p, q;
            cin >> h >> p >> q;
            nexts[P(h, p)] = q;
            nexts[P(h, q)] = p;
        }

        int y = 1001;
        int x = a;

        while (y > 0) {
            if (nexts.find(P(y, x)) == nexts.end()) {
                y--;
            } else {
                x = nexts[P(y, x)];
                y--;
            }
        }

        cout << x << endl;
    }

    return 0;
}


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

int main() {
  int d,n;
  cin>>d>>n;
  int count=0;
  for(int i=1;i>0;i++){
    int d_a=pow(100,d);
    int d_b=pow(100,d+1);
    if(i%d_a==0&&i%d_b!=0){count++;}
    if(count==n){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 384
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()
    q = i_input()
    current_sum = sum(num_list)
    cnt_list = Counter(num_list)
    # print(cnt_list)
    # print(current_sum)

    # print('----')

    for _ in range(q):
        b, c = i_map()
        b_cnt = cnt_list[b]
        cnt_list[b] = 0
        cnt_list[c] += b_cnt
        current_sum += (c-b) * b_cnt
        print(current_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94780
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 1000000007

typedef struct data{
  struct data *next;
  int end;
}cell;

cell *edge[100005];

long long f[100005],g[100005];
int a[100005],b[100005],N,used[100005];

cell *make(int b);
void comb(int i);

int main(void){
  int i,buff;
  char str[100],*p;
  cell *q;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  for(i=1;i<N;i++){
    edge[i]=NULL;
  }
  
  for(i=0;i<N-1;i++){
    fgets(str,sizeof(str),stdin);
    p=strtok(str," \n");
    a[i]=atoi(p);
    p=strtok(NULL," \n");
    b[i]=atoi(p);
    q=make(b[i]);
    q->next=edge[a[i]],edge[a[i]]=q;
    q=make(a[i]);
    q->next=edge[b[i]],edge[b[i]]=q;
  }
  
  comb(1);
  
  printf("%lld\n",f[1]);
  
  return 0;
}


cell *make(int b){
  
  cell *p;
  p=malloc(sizeof(edge));
  p->end=b;
  
  return p;
}

void comb(int i){
  cell *q;
  int num=0;
  
  used[i]=1;
  
  q=edge[i];
  if(q==NULL){
    f[i]=2,g[i]=1;
    return;
  }
  
  f[i]=1,g[i]=1;
  
  
  while(q!=NULL){
    
    if(used[q->end]==0){
      comb(q->end);
      f[i]*=g[q->end];
      f[i]%=INF;
      g[i]*=f[q->end];
      g[i]%=INF;
    }
    q=q->next;
  }
  
  f[i]+=g[i],f[i]%=INF;
  
  return;
}


Measured memory_bytes: 808576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 105
#define BLACK 0
#define GRAY 1
#define WHITE 2

int n;
int G[MAX][MAX];
int d[MAX], f[MAX], color[MAX];
int t;

void init();
void dfs();
void dfs_s(int s);

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

    for(int i = 0; i < n; i++){
        int u,k; cin >> u >> k;
        for(int j = 0; j < k; j++){
            int v; cin >> v;
            G[u-1][v-1] = 1;
        }
    }

    dfs();

    for(int i = 0; i < n; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}

void init(){
    t = 1;
    for(int i = 0; i < n; i++){
        d[i] = f[i] = 0;
        color[i] = WHITE;
        for(int j = 0; j < n; j++){
            G[i][j] = 0;
        }
    }
}

void dfs(){
    for(int i = 0; i < n; i++){
        if(color[i] == WHITE){
            dfs_s(i);
            t++;
        }
    }
}

void dfs_s(int s){
    stack<int> S;
    S.push(s); color[s] = GRAY; d[s] = t;
    int now;

    while(!S.empty()){
        now = S.top();
        t++;
        bool fl = true;

        for(int i = 0; i < n; i++){
            if(G[now][i] == 1 && color[i] == WHITE){
                S.push(i); color[i] = GRAY; d[i] = t;
                now = i; fl = false; break;
            }
        }

        if(fl){
            int top = S.top(); S.pop();
            color[top] = BLACK; f[top] = t;
            now = top;
        }
    }
}


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

int main() {
	// your code goes here
	int n,i;
	cin>>n;
	long long A[n];
	for(i=0;i<n;i++)
		cin>>A[i];
	long long dp[n];
	for(i=0;i<n;i++)
		dp[i]=0;
	dp[0]=0;
	dp[1]=abs(A[0]-A[1]);
	for(i=2;i<n;i++)
		dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
# coding:utf-8

from fractions import gcd


def main():
    # N = int(input())
    A, B, C, D = map(int, input().split())
    length = B - A + 1
    divc = B//C - A//C
    if A % C == 0:
        divc += 1

    divd = B//D - A//D
    if A % D == 0:
        divd += 1
    lcm = C*D//gcd(C, D)
    divcd = B//lcm - A//lcm

    if A % (C*D) == 0:
        divcd += 1
    # print(divc, divd, divcd)

    ans = length - divc - divd + divcd

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64620
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, k, i, j, x, ans = 0, MOD = 1000000007, p, MAXLEVEL = 30;

	cin >> n >> k;
	vector<long long> s(k + 1, 0);
	for (i = k; i >= 1; i--) {
		x = k / i;
		// calculate x ^ n
		p = 1;
		for (j = 0; j < MAXLEVEL; j++) {
			if ((1LL << j) & n) p = (p * x) % MOD;
			x = (x * x) % MOD;
		}

		// minus s[2i, 3i, ...]
		p += MOD * MOD;
		for (j = 2 * i; j <= k; j += i) p -= s[j];
		s[i] = p % MOD;

		ans = (ans + i * s[i]) % MOD;
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <stack>

using namespace std;

int main() {
    string s;
    stack<char> t;
    cin >> s;
    for (string::iterator it = s.begin(); it != s.end(); ++it) {
        if (!t.empty() && t.top() != *it) {
            t.pop();
        } else {
            t.push(*it);
        }
    }
    cout << s.size() - t.size() << endl;
}

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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    string s, keeper;
    cin >> s;
    LL ans = 0;
    for(int i = 0; i < s.size(); i++){
        keeper = s[i];
        ans += stoi(keeper);
    }
    int n = stoi(s);
    cout << (n % ans == 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0, GRAY = 1, BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX], color[MAX];

  for(int i = 0; i < n; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    minv = INFTY;
    int u = -1;

    for(int i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    
    for(int v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(int i = 0; i < n; i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}
  int main(){
    cin >> n;

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	M[i][j] = INFTY;
      }
    }

    int k, c, u, v;

    for(int i = 0; i < n; i++){
      cin >> u >> k;

      for(int j = 0; j < k; j++){
	cin >> v >> c;
	M[u][v] = c;
      }
    }

    dijkstra();

    return 0;
	       
  }
	
	  
      
	   



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

int main(){
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c = 0;
    if(a == 1)c += 300000;
    if(a == 2)c += 200000;
    if(a == 3)c += 100000;
    if(b == 1)c += 300000;
    if(b == 2)c += 200000;
    if(b == 3)c += 100000;
    if((a == 1)&&(b == 1))c +=400000;
    cout << c <<endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import groupby
s = input()
lr = [(k, len(list(v))) for k, v in groupby(s)]
res = [0] * len(s)
tmp = 0
for k, v in lr:
    if k == "R":
        if v % 2 == 0:
            res[tmp + v - 1] += v // 2
            res[tmp + v] += v // 2
            tmp += v
        else:
            res[tmp + v - 1] += (v + 1) // 2
            res[tmp + v] += (v - 1) // 2
            tmp += v
    else:
        if v % 2 == 0:
            res[tmp - 1] += v // 2
            res[tmp] += v // 2
            tmp += v
        else:
            res[tmp - 1] += (v - 1) // 2
            res[tmp] += (v + 1) // 2
            tmp += v
print(" ".join(map(str, res)))

Measured memory_bytes: 17744
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int c = a * b;
  if (c % 2 == 0)
    cout << "Even" << endl;
  else
    cout << "Odd" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	 long c=sc.nextLong();
	 String[] letter = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

	 
	 long i=0;
	 int j=0;
	 String str="";
	 while(c>26)
	 {
	 	
	 	i=c/26;
	 	if(c%26==0)
	 	{
	 		i=i-1;
	 	}
	 	j=(int)(c%26);
	 	if(j==0){
	 	str=letter[25]+str;

	 	}
	 	else{
	 	str=letter[j-1]+str;

	 	}
	 	c=i;

	 }
	 int x = (int)c;
	 str=letter[x-1]+str;
	 
	 
	System.out.println(str);
	
				
		
	}
}

Measured memory_bytes: 39336
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    int V, E, r;
    cin>>V>>E>>r;
    vector<vector<pair<int, int> > > edge(V);
    int s, t, d;
    for(int i=0;i<E;++i){
        cin>>s>>t>>d;
        edge[s].push_back(make_pair(t, d));
    }
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    que.push(make_pair(0, r));
    pair<int, int> state;
    int dist[V];
    for(int i=0;i<V;++i){
        dist[i] = inf;
    }
    while(!que.empty()){
        state = que.top();que.pop();
        if(dist[state.se] < state.fi) continue;
        dist[state.se] = state.fi;
        for(int i=0;i<edge[state.se].size();++i){
            if(dist[edge[state.se][i].fi] == inf) que.push(make_pair(state.fi + edge[state.se][i].se, edge[state.se][i].fi));
        }
    }
    for(int i=0;i<V;++i){
        if(dist[i]==inf) cout<<"INF"<<endl;
        else cout<<dist[i]<<endl;
    }
}




Measured memory_bytes: 13956
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {

    string str;
    cin>>str;

    for(int bit = 0;bit<(1<<3);bit++){
        int ans = str[0] - '0';
        char op[4];
        for(int i=0;i<3;i++){
            if(bit&(1<<i)){
                op[i] = '+';
            }else{
                op[i] = '-';
            }
        }

        for(int i=0;i<3;i++){
            if(op[i]=='+'){
                ans = ans + (str[i+1]-'0');
            }else{
                ans = ans - (str[i+1]-'0');
            }
        }

        if(ans==7){
            cout<<str[0]<<op[0]<<str[1]<<op[1]<<str[2]<<op[2]<<str[3]<<"="<<7<<endl;
            break;
        }

    }

    return 0;
}






































































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200005],b[200005];
int main(){
	long long x,d,ans=0,sum;
	cin >> x >> d;
	for(int i=0;i<x;i++){
		scanf("%lld %lld",&a[i],&b[i]);
		sum=a[i]*a[i]+b[i]*b[i];
		if(sum<=d*d)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6880