akhauriyash/Code-Regression huggingface dataset:
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;


fn binary_search<T: Ord>(v: &Vec<T>, key:T) -> usize {
    fn lower_bound<T: Ord>(v: &Vec<T>, index: usize, key: &T) -> bool {
        v[index] >= *key
    }
    fn upper_bound<T: Ord>(v: &Vec<T>, index: usize, key: &T) -> bool {
        v[index] > *key
    }

    let (mut left, mut right) = (-1, v.len() as isize);

    while right - left > 1 {
        let mid = left + (right - left) / 2;
        if upper_bound(v, mid as usize, &key) {
            right = mid;
        } else {
            left = mid;
        }
    }
    right as usize
}

fn main() {
    input!(n:usize, m:usize, k:usize, a:[usize; n], b:[usize; m]);
    let mut suma = vec![0];
    for x in a {
        suma.push(suma.last().unwrap()+x);
    }
    let mut sumb = vec![0];
    for x in b {
        sumb.push(sumb.last().unwrap()+x);
    }

    let mut ans = 0;
    for i in 0..suma.len() {
        let a = suma[i];
        if a > k {break;}
        let b = k - a;
        let j = binary_search(&sumb, b) - 1;

        ans = max(ans, i+j);
    }
    println!("{:?}", ans);

}



Measured memory_bytes: 11948
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to WzW
*/


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstring>
#define ll long long
using namespace std;
const int maxn = 1e5 + 10;

int f[maxn];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	while(m--){
		int x,y;cin >> x >> y;
		if(x == 1 && !y && n != 1 || f[x] && f[x] != y){
			printf("-1\n");return 0;
		}
		f[x] = y;
	} 
	if(n != 1 && !f[1]) f[1] = 1;
	int ans =  0;
	for(int i = 1 ; i <= n ; i++) ans = ans * 10 + f[i];
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>

typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int R;
	cin >> R;
	
		cout << 2 * M_PI * R << endl;

	

	return 0;

}

Measured memory_bytes: 3800
// 2018, Sayutin Dmitry.

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n = input<int>();
    vector<int> a(n);

    input_seq(ALL(a));

    auto can = [&](int let) {
        // len, digit
        vector<pair<int, int>> cur_str;
        int cur_len = 0;

        for (int elem: a) {
            if (cur_len < elem) {
                cur_str.emplace_back(elem - cur_len, 0);
                cur_len = elem;
            } else {
                while (cur_len > elem) {
                    if (cur_len - cur_str.back().first >= elem) {
                        cur_len -= cur_str.back().first;
                        cur_str.pop_back();
                    } else {
                        int SHORTEN = cur_len - elem;
                        cur_len -= SHORTEN;
                        cur_str.back().first -= SHORTEN;
                    }
                }

                int ptr = SZ(cur_str) - 1;
                int skipped = 0;
                while (ptr >= 0 and cur_str[ptr].second == let - 1) {
                    skipped += cur_str[ptr].first;
                    --ptr;
                }

                if (ptr == -1)
                    return false;

                int new_dig = cur_str[ptr].second + 1;
                if (cur_str[ptr].first == 1)
                    cur_str.resize(ptr);
                else {
                    cur_str[ptr].first -= 1;
                    cur_str.resize(ptr + 1);
                }

                cur_str.emplace_back(1, new_dig);
                if (skipped)
                    cur_str.emplace_back(skipped, 0);
            }
        }

        return true;
    };
    
    int l = 0; // can't
    int r = n; // can

    while (r - l > 1) {
        int m = (l + r) / 2;

        if (can(m))
            r = m;
        else
            l = m;
    }

    cout << r << "\n";
    
    return 0;
}


Measured memory_bytes: 4692
N = int(input())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]))

print(dp[N-1])


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	int cnt = 0;
	REP(i, 100) {
		REP(j, 100) {
			if (4 * i + 7 * j == n) cnt++;
		}
	}
	
	if (cnt == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n;
int c[100];
int v[100];

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

        cin >> n;

        REP(i,n)
                cin >>  v[i];

        REP(i,n)
                cin >>  c[i];


        int r = 0;
        REP(i, n)
                if(v[i] - c[i] > 0) r += v[i] - c[i];

        cout << r << endl;


        return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))

e = sum(range(1,p[0]+1))/p[0]
S = [e]

for i in range(1,N):
    ex = p[i]*(p[i]+1) / (2*p[i])
    S.append(ex + S[i-1])

ans = S[K-1]
for i in range(K,N):
    ans = max(ans,S[i]-S[i-K])

print(ans)


Measured memory_bytes: 100404
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a >= 1 && a <=9) && (b >= 1 && b <=9)) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(void){

  int k;

  scanf("%d", &k);

  int a, b;

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

  if((b - a) > k){
    printf("OK");
  }else{
    int i, flag = 0;
    for(i = a; i <= b; i++){
      if(i % k == 0){
        printf("OK");
        flag = 1;
        break;
      }
    }
    if(flag == 0){
      printf("NG");
    }
  }

  return 0;
}


Measured memory_bytes: 1724
#include<stdio.h>
#include<stdlib.h>
int a[200005], b[200005];
int depth[200005];
int asca(const void* x, const void* y)
{
	if (a[*(int*)x] > a[*(int*)y])return 1;
	if (a[*(int*)x] < a[*(int*)y])return -1;
	return 0;
}
int ascb(const void* x, const void* y)
{
	if (b[*(int*)x] > b[*(int*)y])return 1;
	if (b[*(int*)x] < b[*(int*)y])return -1;
	return 0;
}
int ascd(const void* x, const void* y)
{
	if (depth[*(int*)x] > depth[*(int*)y])return 1;
	if (depth[*(int*)x] < depth[*(int*)y])return -1;
	return 0;
}
int main()
{
	int n, q;
	scanf("%d %d", &n, &q);
	int i;
	for (i = 0; i < n - 1; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	int p[200005], x[200005];
	for (i = 0; i < q; i++)
	{
		scanf("%d %d", &p[i], &x[i]);
		p[i]--;
	}
	for (i = 0; i < n; i++)
		depth[i] = -1;
	depth[0] = 0;
	int c[200005], d[200005];
	for (i = 0; i < n - 1; i++)
		c[i] = d[i] = i;
	qsort(c, n - 1, sizeof(int), asca);
	qsort(d, n - 1, sizeof(int), ascb);
	int min, mid, max;
	int par[200005];
	int next[200005], l, m;
	next[0] = 0;
	l = 1;
	while (l > 0)
	{
		l--;
		m = next[l];
		min = 0;
		max = n - 1;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (a[c[mid]] < m)
				min = mid;
			else
				max = mid;
		}
		if (a[c[min]] < m)
			min++;
		if (min < n - 1)
		{
			while (a[c[min]] == m)
			{
				if (depth[b[c[min]]] < 0)
				{
					depth[b[c[min]]] = depth[a[c[min]]] + 1;
					par[b[c[min]]] = a[c[min]];
					next[l] = b[c[min]];
					l++;
				}
				min++;
				if (min >= n - 1)
					break;
			}
		}
		min = 0;
		max = n - 1;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (b[d[mid]] < m)
				min = mid;
			else
				max = mid;
		}
		if (b[d[min]] < m)
			min++;
		if (min < n - 1)
		{
			while (b[d[min]] == m)
			{
				if (depth[a[d[min]]] < 0)
				{
					depth[a[d[min]]] = depth[b[d[min]]] + 1;
					par[a[d[min]]] = b[d[min]];
					next[l] = a[d[min]];
					l++;
				}
				min++;
				if (min >= n - 1)
					break;
			}
		}
	}
	int count[200005];
	for (i = 0; i < n; i++)
		count[i] = 0;
	for (i = 0; i < q; i++)
		count[p[i]] += x[i];
	int e[200005];
	for (i = 0; i < n; i++)
		e[i] = i;
	qsort(e, n, sizeof(int), ascd);
	int ans[200005];
	ans[0] = count[0];
	for (i = 1; i < n; i++)
		ans[e[i]] = ans[par[e[i]]] + count[e[i]];
	for (i = 0; i < n - 1; i++)
		printf("%d ", ans[i]);
	printf("%d\n", ans[n - 1]);
	return 0;
}

Measured memory_bytes: 12524
#include<stdio.h>
int main(void){
  int a,b,c,A1,A2,A3,min;
  scanf("%d %d %d",&a,&b,&c);
  A1=a+b;
  A2=b+c;
  A3=a+c;
  min=A1;
  if(min>A2){
    min=A2;
  }
  if(min>A3){
    min=A3;
  }
  printf("%d",min);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v[1],v1;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[1111][33];
long long l[23][2500511];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
priority_queue<long long,vector<long long>,greater<long long> > q;
//queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

//string r,r1;
//char r[2];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;

}


long long f(int n,int m)
{
    if(n>=a) return 1;
    if(l[n][m]>=0) return l[n][m];
    long long x=0;
    for(int h=0,i=1;h<a;i*=2,h++)
        if(o[n][h]&&(m&i)==0)
            x+=f(n+1,m+i),x%=mod;
    return l[n][m]=x;
}

int main()
{
    memset(l,-1,sizeof(l));
    scanf("%d",&a);
    for(int t=0;t<a;t++)
        for(int w=0;w<a;w++)
        scanf("%d",&o[t][w]);
    printf("%lld",f(0,0));
}





Measured memory_bytes: 449536
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

#define INT unsigned long long int
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define PINT(d) printf("%d\n", d);
#define PDOUBLE(lf) printf("%lf\n", lf);
#define PSTR(s) printf("%s\n", s);
#define ALL(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX_N 100000

using namespace std;

main(){
	long long int n, ans = 0, sum = 0;
	cin >> n;
	FOR1(n){
		int tmp;
		cin >> tmp;
		if(tmp == 0){
			ans += sum / 2;
			sum  = 0;
		}else{
			sum += tmp;
		}
	}
	if(sum != 0) ans += sum / 2;
	cout << ans;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME
// Allah amader korona virus theke rokkha korun.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp> //order_of_key return number of elements less than x, find_by_order return index (pointer use kora lgbe)

using namespace std;
using namespace __gnu_pbds;

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"
#define all(x) (x).begin(), (x).end()
//#define INF   ((int)2e18)
#define ii pair<ll, ll>

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

const int N=1e6+5;
const ll M=1e18;

typedef tree< ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

struct Edge
{
    int u, vv;
    bool operator<(Edge const& other)
    {
        return vv > other.vv;
    }
}; // eta joss jinis.krsukal er jnno and sort 1 out of 3 or more er jnno better

/////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//main function is here.........
int main()
{
       //ios
string s;
cin>>s;
if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
else cout<<"No";

}


/*
*/



//Alhamdulillah


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

int main(void){
    string s;
    long long int k;
    cin >> s >> k;
    if(k == 1)cout << s[0] << endl;
    else {
        int ans = 0;
        for(int i = 0;i < s.size();i++){
            if(s[i] != '1')break;
            else ans++;
        }
        if(k <= ans)cout << 1 << endl;
        else cout << s[ans] << endl;
    }
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define ac(x, i) get<i>(x)
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define ff first
#define ss second
#define MOD 1000000007

const int infi = 1e9;
const ll infl = 1e18;

ll max(ll a, ll b, ll c) {
  return max(a, max(b, c));
}

int main() {
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  #endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  ll v[n][3], dp[n][3];
  memset(dp, -1LL, sizeof(dp));
  for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) cin >> v[i][j];
  for (int j = 0; j < 3; j++) dp[0][j] = v[0][j];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp[i][j] = max(dp[i-1][k] + v[i][j], dp[i][j]);
      }
    }
  }
  cout << max(dp[n-1][0], dp[n-1][1], dp[n-1][2]) << "\n";
  return 0;
}

Measured memory_bytes: 4992
// Contest.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int* r = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> r[i];
    }
    int sum = 0;
    int min = 2147483647;
    for (int i = 1; i <= 100; i++) {
        for (int j = 0; j < n; j++) {
            sum += pow(r[j] - i, 2);
        }
        min = std::min(min, sum);
        sum = 0;
    }
    cout << min;
}



Measured memory_bytes: 256
n = gets.to_i
as = gets.split(' ').map(&:to_i)

max = 1000000
ds = (0..max).map {|i| i } 
(2..max).each do |i|
  next if ds[i] != i
  a = i
  while a <= max do
    ds[a] = i if ds[a] == a
    a += i
  end
end

require 'set'
pairwise = true
ps = Set.new
gcd = as[0]
as.each do |a|
  if pairwise
    cur = a
    sps = Set.new
    until cur == 1 
      p = ds[cur]
      sps << p
      cur /= p
    end
    if ps.intersect?(sps)
      pairwise = false
    else
      ps.merge(sps)
    end
  end
  
  gcd = gcd.gcd(a)
end

if pairwise
  puts 'pairwise coprime'
elsif gcd == 1
  puts 'setwise coprime'
else
  puts 'not coprime'
end


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

signed main() {
    int N;
    cin >> N;

    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;

        A[i] = a + b;
        sum -= b;
    }

    sort(A.rbegin(), A.rend());
    for (int i = 0; i < N; i++) {
        if (i % 2) continue;
        sum += A[i];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b,k;
int main()
{
    cin>>a>>b;
    if((a+b)%3==0||a%3==0||b%3==0) cout<<"Possible";
    else                         cout<<"Impossible";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x,a,b,sum,remaining,change;
	scanf("%d\n%d\n%d",&x,&a,&b);
	
	remaining=x-a;
	
	if(remaining%b==0){
		sum=remaining/b;
	}else{
		while(remaining%b!=0){
			remaining--;
		}
		sum=remaining/b;
	}
	
	change=x-a-(b*sum);
	
	printf("%d\n",change);
	
	return 0;
}
		

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

using namespace std;

typedef long long ll;

const int MAXN = 100005;

int k[MAXN], b[MAXN], f[MAXN], g[MAXN];

int n;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> g[i];
	k[2] = -1, b[2] = g[1];
	for (int i = 3; i <= n; i++)
	{
		k[i] = -k[i - 1];
		b[i] = g[i - 1] - b[i - 1];	
	}
	ll x = (g[n] - b[n]) / (1 + k[n]);
	f[1] = x;
	for (int i = 2; i <= n; i++)
		f[i] = k[i] * x + b[i]; 
	for (int i = 1; i <= n; i++)
		cout << 2 * f[i] << " ";
	cout << endl;
	return 0;
}


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

int n;
int p[100000];
int dp[100006];

void dfs(int i, int t)
{
    if (t >= dp[i])
        return;
    if (i >= n)
        return;

    dp[i] = min(dp[i], t);

    if (p[i] == 0) {
        for (int j = 1; j <= 6; ++j) {
            dfs(i + j, t + 1);
        }
    } else {
        dfs(i + p[i], t);
    }
}

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

    for (int i = 0; i < n; ++i)
        scanf("%d", &p[i]);

    fill(dp, dp + 100006, 10000000);
    dfs(0, 0);
    printf("%d\n", dp[n - 1]);

    return 0;
}

Measured memory_bytes: 2312
#include<stdio.h>
#include<string.h>

int main(void)
{
	int n,i,j,num,flag=0,count=0;
	int a[100000];
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0; i<n; i++){
		num = a[i];
		if(a[num-1] == i+1) count++;
	}
	
	count = count / 2;
	
	printf("%d\n",count);
	
	return 0;
}


Measured memory_bytes: 512
i,j,k,s;
main(x)
{
  char a[99],b[99];
  for(scanf("%s%d",a,&x);x--;)
    {
      scanf("%s",b);
      for(i=0;i<10;i++)
	{
	  if(a[0]==b[i])
	    {
	      for(k=0,j=i;1;)
		{
		  j++;
		  k++;
		  j=j>9?0:j;
		  if(a[k]=='\0')
		    {s++;i=11;break;}
		  if(a[k]!=b[j])
		    break;
		}
	    }
	}
    }
  printf("%d\n",s);
  return 0;
}

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

int main(){
  string s,t;
  int a = 0;
  
  cin >> s >> t;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i) == t.at(i))
      a++;
  }
  
  if(a == s.size())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
#define ll long long int
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;
int prime(int n);
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b);
ll gcd(ll a, ll b);

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int prime(int n){
    int flag=1;
for(int i=2;i<=sqrt(n);i++){
    if(n%i==0){flag=0;break;}
}
  return flag;
}

int main(){
       ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n;
cin>>n;
ll a[n][3],dp[n][3];
for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
            cin>>a[i][j];}
}
for(int i=0;i<3;i++)dp[0][i]=a[0][i];
for(int i=1;i<n;i++){
dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
//cout<<dp[i][0]<<endl;
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

int main()
{
    string str;
    cin >> str;

    map<char,int> m;
    m[str[0]]++;
    m[str[1]]++;
    m[str[2]]++;
    m[str[3]]++;

    if (m.size() == 2 && m.begin()->second == 2) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main(){
    int N, A, B, result = 0;
    cin >> N >> A >> B;

    auto func = [=](int i, int res=0){
        for (; i!=0; res+=i%10, i/=10);
        return res>=A && res<=B;
    };

    for(int i=1; i<=N; result+=func(i++)? i-1: 0);

    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int num[101], d[100], n, res = 0;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> d[i];
    
    for (int i = 1; i <= 100; i++) {
        for (int j = 0; j < n; j++) {
            if (d[j] == i) num[i]++;
        }
    }
    for (int i = 1; i <= 100; i++) {
        if (num[i] != 0) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


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

int main() {
	int n, q;
	cin >> n >> q;
	vector<stack<int>> s(n);
	VI print;
	rep(i, q) {
		int cos; cin >> cos;
		if (cos == 0) {
			int t, x; cin >> t >> x;
			s[t].push(x);
		}
		else if (cos == 1) {
			int t; cin >> t;
			if (!s[t].empty())print.pb(s[t].top());
		}
		else if (cos == 2) {
			int t; cin >> t;
			if (!s[t].empty())s[t].pop();
		}
	}
	for (auto a : print) {
		cout << a << endl;
	}
}


Measured memory_bytes: 4252
import sys

f_i = sys.stdin

max_d = float("inf")

V, E = map(int, f_i.readline().split())

# adjacency matrix
A = [[max_d] * i + [0] + [max_d] * (V - i - 1) for i in range(V)]

for l_i in f_i:
    s, t, d = map(int, l_i.split())
    A[s][t] = d


# Warshall???Floyd Algorithm
for k in range(V):
    for i in range(V):
        for j in range(V):
            A[i][j] = min(A[i][j], A[i][k] + A[k][j])

# check whether A has negative cycle
is_negative = 0
for k in range(V):
    if A[k][k] < 0:
        is_negative = 1
        print("NEGATIVE CYCLE")
        break

# Output
if not is_negative:
    for a in A:
        print(*[str(e).upper() for e in a])

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

#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pdd pair<double,double>

int N, C;
vector<pdd> V[40];
vector<double> S;

signed main()
{
    cin >> N >> C;
    rep(i, N)
    {
        double s, t;
        int c;
        cin >> s >> t >> c;
        V[c].push_back({s, t});
    }

    for(int i = 1; i <= C; i++)sort(V[i].begin(), V[i].end());

    for(int i = 1; i <= C; i++)
    {
        for(int j = 0; j < V[i].size(); j++)
        {
            double s = V[i][j].first - 0.5;
            while(j != V[i].size() - 1 && V[i][j].second == V[i][j + 1].first)j++;
            double t = V[i][j].second;
            S.push_back(s);
            S.push_back(t);
        }
    }

    sort(S.begin(), S.end());

    int ans = 0;
    int tmp = 0;
    for(auto e : S)
    {
        //cout << e << endl;
        if(e == (int)e)
        {
            tmp++;
        }
        else
        {
            if(tmp == 0)ans++;
            else tmp--;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

bool isprime(int n) {
  int p = 2;
  while (p * p <= n) {
    if (n % p == 0) return false;
    p++;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, cnt = 0;
  cin >> N;
  for (int p = 3; p <= 55555; p += 2) {
    if (p % 5 == 1 && isprime(p)) {
      cout << p << " ";
      cnt++;
    }
    if (cnt == N) return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <string.h>
#include <assert.h>
#include <stack>
#define PI 3.1415926535897932384626433832795028

using namespace std;
struct point 
{
	double x,y,z;
}a[30];
int n,m,num[1000];
double map[100][100];
double f()
{
	double k=0;
	for(int i=0;i<n;i++)
	{
		if(num[i]==0)
		{
			for(int j=i+1;j<n;j++)
			{
				if(num[j]==0&&i!=j)
				{
					k+=map[i][j];
				}
			}
		}
	}
	return k;
}
int main()
{
	int i,j,nx,ny,k;
	double max1,max2,sum,ans,temp;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].z);
		}
		if(m==1)
		{
			printf("0.00000000000000000000\n");
			continue;
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(i!=j)
				{
					map[i][j]=(a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z);
				}
			}
		}
		ans=0;
		for(int j=(1<<m)-1;j<1<<n;j++)
		{							    
			memset(num,1,sizeof(num));
			int count=0;
			for(int i=0;i<n;i++)
			{
				if(j&(1<<i))  num[i]=0,count++;
			}
			if(count==m)
			{
				temp=f();
				if(temp>ans) 
					ans=temp;
			}
		}
		printf("%.20lf\n",ans);
	}
	return 0;
}

Measured memory_bytes: 900
var inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split(" ");

W = ~~inputs[0];
H = ~~inputs[1];
x = ~~inputs[2];
y = ~~inputs[3];
r = ~~inputs[4];

horizontal = r <= x && x <= W-r;
vertical = r <= y && y <= H-r;
if (horizontal && vertical) {
        console.log("Yes");
} else {
        console.log("No");
}


Measured memory_bytes: 15096
N,M=map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

start=-1
for i in range(N):
    if B[0] in A[i]:
        start=i
        break
if start==-1 or start+M>N:
    print('No')
    exit()
else:
    for i in range(M):
        if (B[i] in A[start+i])!=1:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3064
import java.util.*;

public class Main {

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

    // int N = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), M = scanner.nextInt();
        scanner.nextLine();
        List<List<Edge>> edgeList = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            edgeList.add(new ArrayList<>());
            if (i > 0) {
                edgeList.get(i).add(new Edge(i - 1, 0));
            }
        }
        for (int i = 0; i < M; i++) {
            int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            edgeList.get(e[0] - 1).add(new Edge(e[1] - 1, e[2]));
        }

        Queue<Edge> q = new PriorityQueue<>(Comparator.comparingLong(x -> x.cost));
        q.add(new Edge(0, 0));
        long dist[] = new long[N];
        Arrays.fill(dist, Long.MAX_VALUE / 2);
        while (!q.isEmpty()) {
            Edge e = q.poll();
            if (dist[e.to] <= e.cost) {
                continue;
            }
            dist[e.to] = e.cost;
            for (Edge ne: edgeList.get(e.to)) {
                q.add(new Edge(ne.to, e.cost + ne.cost));
            }
        }
        System.out.println(dist[N - 1] == Long.MAX_VALUE / 2 ? -1 : dist[N - 1]);
    }

    static class Edge {
        int to;
        long cost;

        public Edge(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }
    }
}

Measured memory_bytes: 173556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<ll, ll>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;

ll comb(ll a, ll b) {
    if (b<0 || b>a) return 0LL;
    if (b==0 || b==a) return 1LL;
    ll res = 1LL;
    rep(i, b) {
        res *= (a-i);
        res /= (i+1);
    }
    return res;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(rwhole(v));
    vector<ll> s(n+1);
    rep(i, n) s[i+1] = s[i] + v[i];
    vector<P> x;
    for (ll i=a; i<=b; i++) {
        x.emplace_back(s[i], i);
    }
    P best = P(0LL, 1LL);
    ll num = 0;
    int nx = x.size();
    rep(i, nx) {
        if (x[i].first*best.second>best.first*x[i].second) {
            best = x[i];
        }
    }
    double ans = static_cast<double>(best.first)/static_cast<double>(best.second);
    printf("%.10f\n", ans);
    map<ll, ll> mp;
    rep(i, n) mp[v[i]]++;

    rep(i, nx) {
        if (x[i].first*best.second==best.first*x[i].second) {
            int c = a+i;
            ll th = v[c-1];
            int cnt = 0;
            rep(j, c) {
                if (v[j]==th) cnt++;
            }
            num += comb(mp[th], cnt);
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    map<int,int> m;
    int sum = 0;
    m[0]++;
    ll ans = 0;
    ll pow10 = 1;
    rrep(i,n) {
        sum += (s[i]-'0')*pow10;
        sum %= 2019;
        pow10 = pow10*10%2019;
        ans += m[sum];
        m[sum]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       ll k;
       cin>>k;
       ll ans = 0;
       fri(i,1,k+1)
       {
              fri(j,1,k+1)
              {
                     fri(l,1,k+1)
                     {
                            ll gg = __gcd(i,j);
                            gg = __gcd(gg,l);
                            ans += gg;
                     }
              }
       }
       cout<<ans<<endl;

}


Measured memory_bytes: 3636
a, b, c = list(map(int, input().split()))

# 全部奇数または偶数にする
# そこからそれぞれ2ずつ足していく
ans = 0
if a%2 == 0 and b%2 == 0 and c%2 == 0:
    pass
elif a%2 == 1 and b%2 == 1 and c%2 == 1:
    pass

elif a%2 == 0 and b%2 == 1 and c%2 == 1:
    b += 1
    c += 1
    ans += 1
elif a%2 == 1 and b%2 == 0 and c%2 == 1:
    a += 1
    c += 1
    ans += 1
elif a%2 == 1 and b%2 == 1 and c%2 == 0:
    a += 1
    b += 1
    ans += 1
elif a%2 == 0 and b%2 == 0 and c%2 == 1:
    a += 1
    b += 1
    ans += 1
elif a%2 == 0 and b%2 == 1 and c%2 == 0:
    a += 1
    c += 1
    ans += 1
elif a%2 == 1 and b%2 == 0 and c%2 == 0:
    b += 1
    c += 1
    ans += 1

while not a == b == c:
    if a == min(a, b, c):
        a += 2
        ans += 1
    
    if a == b == c:
        break

    if b == min(a, b, c):
        b += 2
        ans += 1

    if a == b == c:
        break

    if c == min(a, b, c):
        c += 2
        ans += 1

    if a == b == c:
        break
print(ans)



Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
   int S,h,m,s;
   
   scanf("%d",&S);
   h=S/3600;
   m=(S-h*3600)/60;
   s=S-h*3600-m*60;
   printf("%d:%d:%d\n",h,m,s);

   return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#define SIZE 205
#define INF 1000000000

using namespace std;

struct MaxFlow
{
	struct edge
	{
		int to,cap,rev;
		edge(int to=0,int cap=0,int rev=0):to(to),cap(cap),rev(rev){}
	};
	vector <edge> vec[SIZE];
	int level[SIZE];
	int iter[SIZE];
	
	void add(int s,int t,int c)
	{
		int S=vec[s].size(),T=vec[t].size();
		vec[s].push_back(edge(t,c,T));
		vec[t].push_back(edge(s,0,S));
	}
	void bfs(int s)
	{
		memset(level,-1,sizeof(level));
		queue <int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty())
		{
			int v = que.front();que.pop();
			for(int i=0;i<vec[v].size();i++)
			{
				edge&e=vec[v][i];
				if (e.cap>0&&level[e.to]<0)
				{
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	int flow_dfs(int v,int t,int f)
	{
		if (v==t) return f;
		for(int &i=iter[v];i<vec[v].size();i++)
		{
			edge &e=vec[v][i];
			if (e.cap>0&&level[v]<level[e.to])
			{
				int d=flow_dfs(e.to,t,min(f,e.cap));
				if(d>0)
				{
					e.cap-=d;
					vec[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s,int t)
	{
		int flow = 0;
		while(1)
		{
			bfs(s);
			if (level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			while (1)
			{
				int f=flow_dfs(s,t,INF);
				if(f==0) break;
				flow += f;
			}
		}
	}
};
MaxFlow MF;
char mp[SIZE][SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%s",&mp[i]);
	int sx,sy,gx,gy;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(mp[i][j]=='S') sx=i,sy=j;
			else if(mp[i][j]=='T') gx=i,gy=j;
		}
	}
	if(sx==gx||sy==gy)
	{
		puts("-1");
		return 0;
	}
	MF.add(sx,sy+n,INF);
	MF.add(sy+n,sx,INF);
	MF.add(gx,gy+n,INF);
	MF.add(gy+n,gx,INF);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(mp[i][j]=='o')
			{
				MF.add(i,j+n,1);
				MF.add(j+n,i,1);
			}
		}
	}
	printf("%d\n",MF.max_flow(sx,gx));
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n; cin>>n;
    if(n % 2 == 1) {cout<<0<<endl; return 0;}
    
    int now = 5;
    int ans = 0;
    while(now < INF){
        ans += n / (now*2);
        now *= 5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int a,i,j;
    scanf("%d",&a);
    double x[a],y[a],z[3],b=0,c=0;
    for(i=0;i<a;i++){
        scanf("%lf",&x[i]);
    }
    for(i=0;i<a;i++){
        scanf("%lf",&y[i]);
    }
    for(i=0;i<3;i++){
        for(j=0;j<a;j++){
            z[i]+=fabs(pow((x[j]-y[j]),i+1));
        }
    }
    for(i=0;i<a;i++){
        b=fabs(x[i]-y[i]);
        if(b>c)c=b;
    }
    printf("%lf\n",z[0]);
    printf("%lf\n",sqrt(z[1]));
    printf("%lf\n",pow(z[2],1.0/3.0));
    printf("%lf\n",c);
    return 0;
}

Measured memory_bytes: 716
from collections import Counter
N = int(raw_input())
d = Counter()

for i in range(1, N+1):
    n = i
    for p in range(2, i+1):
        while n % p == 0:
            n /= p
            d[p] += 1
ans = 1
for p in d:
    ans *= d[p] + 1
    ans %= 10 ** 9 + 7
print ans


Measured memory_bytes: 2812
n = int(input())
s = list(input())
ans = 0

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    k = val[count]
    for j in s:
        if j == k:
            count += 1
            if count <= 2:
                k = val[count]
            elif count == 3:
                ans += 1
                break
print(ans)



Measured memory_bytes: 9364
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

int N, M;
int P[100005], Y[100005];
vector<int> yd[100005];
int main()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> P[i] >> Y[i];
		yd[P[i]].push_back(Y[i]);

	}

	for (int i = 0; i < N; i++)
		sort(yd[i + 1].begin(), yd[i + 1].end());
	for (int i = 0; i < M; i++)
	{
		printf("%06d", P[i]);
		printf("%06d\n", lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    bool ans = false;
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i * j == n) {
                ans = true;
                break;
            }
        }
    }

    puts(ans?"Yes":"No");

    return 0;
}


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

using namespace std;

int k = 3;
int N = 1 << k;

// void p_id(int id) {
//   std::string s = "";
//   for (size_t i = 0; i < N; i++) {
//     s = std::to_string(id & (N - 1)) + s;
//     id >>= k;
//   }
//   std::cout << s << std::endl;
// }

int swap(int i, int j, int id){
  int sft_i = i * k;
  int sft_j = j * k;
  int x = id & ((N - 1) << sft_i);
  int y = id & ((N - 1) << sft_j);
  id = id ^ x;
  id = id ^ y;
  id = id | ((x >> sft_i) << sft_j);
  id = id | ((y >> sft_j) << sft_i);
  return id;
}

int get_id(int b[]) {
  int id = 0;
  for (size_t i = 0; i < N; i++) id = (id << k) | b[i];
  return id;
}

int get_pos0(int id) {
  for (size_t i = 0; i < N; i++) {
    int d = id & (N - 1);
    if (d == 0) return i;
    id >>= k;
  }
  return -1;
}

void next_ids(int id, std::vector<int> *v){
  int pos0 = get_pos0(id);
  int No2 = N >> 1;
  v->clear();
  if (pos0 < No2) {
    v->push_back(swap(pos0, pos0 + No2, id));
    if (pos0 != 0)       v->push_back(swap(pos0, pos0 - 1, id));
    if (pos0 != No2 - 1) v->push_back(swap(pos0, pos0 + 1, id));
  } else {
    v->push_back(swap(pos0, pos0 - No2, id));
    if (pos0 != No2)     v->push_back(swap(pos0, pos0 - 1, id));
    if (pos0 != N - 1)   v->push_back(swap(pos0, pos0 + 1, id));
  }
}

std::map<int, int> tbl;
std::queue<int> q;

int main() {
  int board[N];
  for (size_t i = 0; i < N; i++) board[i] = i;
  int id = get_id(board);

  q.push(id);
  tbl[id] = 0;
  while (!q.empty()) {
    id = q.front(); q.pop();
    int step = tbl[id];
    std::vector<int> v;
    next_ids(id, &v);
    for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
      if (tbl.find(*it) == tbl.end()) {
        q.push(*it);
        tbl[*it] = step + 1;
      }
    }
  }

  while(1){
    for(int i = 0; i < N; ++i){
      if(scanf("%d", &board[i]) == EOF){
        return 0;
      }
    }
    printf("%d\n", tbl[get_id(board)]);
  }
}

Measured memory_bytes: 4060