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

int main(){
  int r,g,b,n,ans=0;
  cin>>r>>g>>b>>n;
  for(int i=0;i<4000;i++){
    for(int j=0;j<4000;j++){
      int k=i*r+j*g;
      if(n-k>=0&&(n-k)%b==0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>

using namespace std;

int main() {
	int N = 16;
	int A, B;
	cin >> A >> B;
	if (A == B) cout << "Yay!"<<endl;
	else {
		
		B = max({ A,B });
		A = B - 1;
		if (A + B > N) cout << ":(" << endl;
		else cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
class Main{
    public static void main(String[] args) throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int s = Integer.parseInt(br.readLine());
	int h = s /3600;
	s %= 3600;
	int m = s / 60;
	s %= 60;
	System.out.println(h+":"+m+":"+s);
    }
}

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

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;
#define debug_ printf("OK\n")

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)

const long long mod = 1000000007;

void solve(lli a,lli b,lli k){
    if(k>=a)std::cout<<"0 "<<b-(k-a);
    else std::cout<<a-k<<" "<<b;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli a,b,k;
    std::cin>>a>>b>>k;
    if(k>=a+b)std::cout<<"0 0";
    else solve(a,b,k);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,max;cin>>n;
  int a,b,ans;
  ans=0;
  vector<int> h(n);
  for(i=0;i<n;i++){cin>>h[i];}
  max=*max_element(h.begin(),h.end());
  vector<vector<int>> vec(max,vector<int>(n));
  for(a=0;a<max;a++){
    for(b=0;b<n;b++){
      if(h[b]){h[b]--;vec[a][b]++;}
    }
  }
  for(a=0;a<max;a++){
    for(b=0;b<n;b++){
      if(vec[a][b]==1){ans++;while(vec[a][b]){b++;}}
    }
  }
cout<<ans<<endl;
}

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

int main() {
	ll n; cin >> n;
	vl a(n);
	list<ll> b;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (n % 2 == 0) {
			if (i % 2 == 0) {
				b.push_back(a[i]);
			} else {
				b.push_front(a[i]);
			}
		} else {
			if (i % 2 == 0) {
				b.push_front(a[i]);
			} else {
				b.push_back(a[i]);
			}
		}
	}
	for (auto itr = b.begin(); itr != b.end(); ++itr) {
		if (itr != b.begin()) cout << " ";
		cout << *itr;
	}
	cout << endl;
	return 0;
}


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

int main() {
    int n, r;
    cin >> n >> r;
    int ans;
    if (n >= 10) {
        ans = r;
    }
    else ans = r + (100 * (10 - n));
    cout << ans << endl;
}


Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int x, y, s;

void solve() {
	int ans = 0;
	
	for_(i,1,s) {
		for_(j,1,s) {
			int ii = i * (x + 100) / 100;
			int jj = j * (x + 100) / 100;
			
			if (ii + jj != s) continue;
			
			int ii_ = i * (y + 100) / 100;
			int jj_ = j * (y + 100) / 100;
			ans = max(ans, ii_ + jj_);
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> x >> y >> s, x) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
list<int>graf[100007];
long long int dp[100007][2];
const long long int md=1000000007;
int n,a,b;
int dpf(int cur,int par, int clr) //1 is black
{
	if(dp[cur][clr]!=-1)
		return dp[cur][clr];
	// cout <<"yee "<< cur << " " << par << " " << clr <<endl << "muz\n";
	bool flag=false;
	long long int muz=1;
	long long int temp2=1;
	for(auto x:graf[cur])
	{
		if(x!=par)
		{
			// cout << x << " ";
			flag=true;
			muz*=dpf(x,cur,0)%md;
			if(clr==0){
				temp2*=dpf(x,cur,1)%md;
				temp2%=md;
				temp2%=md;
			}
			muz%=md;
		}
	}
	// cout << "\n";
	if(clr==0)
	{
		muz+=temp2%md;
		muz%=md;
	}
	// else
	muz%=md;
		dp[cur][clr]=muz%md;
		return muz%md;
		
	
}
int main()
{
	memset(dp,-1,sizeof(dp));
	
	cin >> n;
 	for(int i=0;i<(n-1);i++)
 	{
 		cin >> a >> b;
 		graf[a].push_back(b);
 		graf[b].push_back(a);
 	}
 	cout << dpf(1,0,0);
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[1000];
  int l;
  double m=100000;
  int sum=0;
  double ave;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  ave = (double)sum/n;
  for(int i=0;i<n;i++){
    if(abs(a[i]-ave)<m){
      m=abs((double)a[i]-ave);
      l=i;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,m,i,j,lc[59],dep[59],msh[59],pas,k[59],zx,xc,xr[59];
pair <long long, long long> p[59];
vector <long long> v[59];
void dfsst(long long q, long long w){
	msh[q]=w;
	dep[q]=dep[w]+1;
	for(vector <long long>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		dfsst((*it),q);
	}
}
void dfs(long long q, long long w){
	for(vector <long long>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		dfs((*it),q);
		k[q]+=k[(*it)];
	}
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=1; b<a; b++){
		cin>>c>>d;
		v[c].push_back(d);
		v[d].push_back(c);
	}
	dfsst(1,0);
	xr[0]=1;
	for(i=1; i<=a; i++) xr[i]=xr[i-1]*2;
	cin>>m;
	for(i=0; i<m; i++){
		cin>>p[i].first>>p[i].second;
		c=p[i].first;d=p[i].second;
		while(c!=d){
			if(dep[c]>=dep[d]){
				c=msh[c];
			}else{
				d=msh[d];
			}
		}
		lc[i]=c;
	}
	for(i=1; i<(1<<m); i++){
		for(j=1; j<=a; j++) k[j]=0;
		for(j=0; j<m; j++){
			if((i&(1<<j))==0) continue;
			k[p[j].first]++;
			k[p[j].second]++;
			k[lc[j]]-=2;
		}
		dfs(1,0);
		zx=0;
		for(j=2; j<=a; j++) if(k[j]==0) zx++;
		if(__builtin_popcount(i)%2==1) pas+=xr[zx]; else pas-=xr[zx];
	}
	cout<<xr[a-1]-pas;
	return 0;
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim c As String = Cin.Str()
    Console.WriteLine(Chr(Asc(c) + 1))
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

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

int k, a, b;
long long ans = 1;

int main()
{
    scanf("%d%d%d", &k, &a, &b);
    ans += min(k, a - 1);
    k -= min(k, a - 1);
    if (a < b - 1)
    {
        ans += 1LL * (b - a) * (k / 2);
        k %= 2;
    }
    else
    {
        ans += k;
        k = 0;
    }
    printf("%lld", ans + k);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

struct edge { ll to, cost; };

int main() {
	IOS;
	string s[4] = { "dream" , "dreamer","erase","eraser" };
	REP(i, 4)reverse(ALL(s[i]));
	string t; cin >> t; reverse(ALL(t));
	int i = 0;
	int end = t.size();
	bool ans = true;
	while (1) {
		if (i == end)break;
		if (i + 5 <= end && t.substr(i, 5) == s[0]) {
			i += 5;
			continue;
		}
		if (i + 7 <= end && t.substr(i, 7) == s[1]) {
			i += 7;
			continue;
		}
		if (i + 5 <= end && t.substr(i, 5) == s[2]) {
			i += 5;
			continue;
		}
		if (i + 6 <= end && t.substr(i, 6) == s[3]) {
			i += 6;
			continue;
		}
		else {
			ans = false; break;
		}
	}
	dump((ans ? "YES" : "NO"));
}




Measured memory_bytes: 512
N, M = map(int, input().split())
if(N == 1 and M == 1):
    print(1)
elif(N == 1):
    if(M == 2):
        print(0)
    else:
        print(1 * M-2)
elif(M == 1):
    if(N == 2):
        print(0)
    else:
        print(1 * N-2)
else:
    print((N - 2) * (M - 2))

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct edge{int to; ll a_cost, b_cost;};

int main()
{
  int n, m; cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}


Measured memory_bytes: 3524
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        if (Math.abs(B - A - 1) % 2 != 0) {
            System.out.println("Alice");
        } else {
            System.out.println("Borys");
        }
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 1000 + 47;
string s;
PII A[MAX];

bool cmp(const PII & a, const PII & b) {
    return min(a.first, a.second + b.first) > min(b.first, b.second + a.first);
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;   
    FOR(i, 0, n) {
        cin >> s;

        int bal = 0;
        int minbal = 0;
        FOR(j, 0, SZ(s)) {
            bal += s[j] == '(' ? 1 : -1;
            minbal = min(minbal, bal);
        }

        A[i] = MP(minbal, bal);
    }

    int bal = 0;


    sort(A, A + n, cmp);
    FOR(i, 0, n) {
        if (bal + A[i].first < 0) {
            cout << "No" << endl;
            return 0;
        }

        bal += A[i].second;
    }

    if (bal == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  vector<long long> S(N);
  S.at(0) = a.at(0);
  for (int i = 1; i < N; i++) S.at(i) += S.at(i-1) + a.at(i);
  long long ans = 1LL << 60;
  for (int i = 0; i < N-1; i++) ans = min(ans, abs(2*S.at(i)-S.at(N-1)));
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; ++i)
#define INF (2e9)

int main() {
	ll n, k, h; cin >> n >> k;
	
	if(n <= k) {
		cout << 0 << endl;
		return 0;
	}
	
	vector<ll> monster(n);
	REP(i, n) {
		cin >> h;
		monster[i] = h;
	}
	
	sort(monster.begin(), monster.end());
	
	ll ans = 0;
	REP(i, n-k) ans += monster[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    int i;
    for (i = 1; i <= N; i++) {
        int sum = 0;
        sum += i % 10;
        sum += i / 10 % 10;
        sum += i / 100 % 10;
        sum += i / 1000 % 10;
        sum += i / 10000 % 10;
        if (A <= sum && sum <= B) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int sum1=0;
int sum2=0;
while(true){
	c=c-b;
	if(c<=0) {
     sum1=1;
	 break;	
	
}
	else{
		a=a-d;
		if(a<=0){
			sum2=1;
			break;
		}
		
	}
	
}
if(sum1==1){
	cout<<"Yes\n";
}
else{
	cout<<"No\n";
}
	
	
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/16  Problem: nagoya_19_04  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M;

LL ans = 0LL;
VVI G;


int g[10][10] = {};


int dfs(int s, int N, vector<bool>used) {
	bool flag = true;
	FOR(i, 0, N) {
		if (used[i] == false) {
			flag = false;
		}
	}
	if (flag)return 1;
	int sum = 0;
	FOR(i, 0, N) {
		if (g[s][i] == 0)continue;
		if (used[i])continue;
		used[i] = true;
		sum += dfs(i, N, used);
		used[i] = false;
	}
	return sum;
}


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

	int n, m;
	cin >> n >> m;
	FOR(i, 0, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = 1;
		g[b][a] = 1;
	}
	vector<bool> used(n);
	used[0] = true;
	cout << dfs(0, n, used) << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
S = str(input())
#N, A, B = map(int, input().split())
#A, B, C = map(int, input().split())

n = len(S)//2
c = 0
for i in range(n) :
  if S[i] != S[len(S)-1-i] :
    c += 1

print (c)

Measured memory_bytes: 3316
//
// Created by watemus on 09.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 1; i < n; i++) cin >> a[i];
    vector<int> cnt(n);
    for (int i = n - 1; i >= 1; i--) {
        cnt[a[i] - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << cnt[i] << '\n';
    }
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 6288
#include <stdio.h>
#include <algorithm>

int main(void)  {
  
  int x, y, s, res;
  
  while (true)  {
    
    scanf("%d %d %d", &x, &y, &s);
    
    if (x == 0) { break; }
    
    // 1円からs-1円の中から
    // 前の税込合計価格がs円になるものを探す
    
    res = -1;
    
    for (int a = 1; a <= s-1; a++)  {
      for (int b = 1; b <= s-1; b++)  {
        
        if (a * (100+x) / 100 + b * (100+x) / 100 == s) {
          res = std::max(res, a * (100+y) / 100 + b * (100+y) / 100);
        }
      }
    }
    
    printf("%d\n", res);
  }
  
  return 0;
}


Measured memory_bytes: 2672
h, w = map(int, input().split())
s = [input().rstrip() for _ in range(h)]

for y in range(h):
    for x in range(w):
        if s[y][x] == '.':
            continue
        if y > 0 and s[y - 1][x] == '#':
            continue
        if y < h - 1 and s[y + 1][x] == '#':
            continue
        if x > 0 and s[y][x - 1] == '#':
            continue
        if x < w - 1 and s[y][x + 1] == '#':
            continue
        print('No')
        exit(0)
print('Yes')

Measured memory_bytes: 9208
n = int(input())
l = list(map(int,input().split()))
l1 = [[l[i],i] for i in range(n+1)]
l1.sort()
for i in range(n):
    if l1[i][0] == l1[i+1][0]:
        a,b = l1[i][1],l1[i+1][1]

m = b-a+1
k = n-m+1

mod = 10**9+7 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod


for i in range(1,n+2):
    a = nCr(n+1,i,mod) -nCr(k,i-1,mod)
    
    print(a%mod)

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

using namespace std;

const int maxn = 101;
const int maxw = 1e5 + 5;

long long dp[maxn][maxw];
long long weight[maxn], value[maxn];

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

    int n, w;
    cin >> n >> w;

    for (int i = 1; i <= n; i++)
        cin >> weight[i] >> value[i];

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            if (j < weight[i])
                dp[i][j] = dp[i - 1][j];
            else
                dp[i][j] = max(value[i] + dp[i - 1][j - weight[i]], dp[i - 1][j]);
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below

void solve(){
	string str1,str2;
    cin>>str1>>str2;
    int n=str1.size()+1,m=str2.size()+1;
    int dp[n][m];
    for(int i=0;i<n;i++)
        dp[i][0]=0;
    for(int i=0;i<m;i++)
        dp[0][i]=0;
    
    string ans="";
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(str1[n-i-1]==str2[m-j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    // for(int i=0;i<n;i++,cout<<endl)
    //     for(int j=0;j<m;j++)
    //         cout<<dp[i][j]<<" ";
    if(dp[n-1][m-1]>0){
        // travel bottom up
        int i=n-1,j=m-1;
        while(i>0 and j>0 ){
            // cout<<" at i: "<<i<<" j: "<<j<<" we have a[] "<<str1[n-i-1]<<" and b[] "<<str2[m-j-1];
            if(str1[n-i-1]==str2[m-j-1]){
                // cout<<" matched and adding "<<str2[m-j-1];
                ans+=str2[m-j-1];
                i--;
                j--;
            }else{
                if(dp[i-1][j]>dp[i][j-1]){
                    i--;
                }else{
                    j--;
                }
            }
            // cout<<endl;
        }
    }

    // cout<<dp[n-1][m-1]<<endl;
    // reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

Measured memory_bytes: 38736
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

vvi to;
vi dp;
int rec(int n)
{
	if (dp[n] >= 0) return dp[n];
	int res = 0;
	for (auto next : to[n])
	{
		chmax(res, rec(next) + 1);
	}
	return dp[n] = res;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	to = vvi(n);
	rep(i, m)
	{
		int x, y; cin >> x >> y;
		x--; y--;
		to[x].push_back(y);
	}
	dp = vi(n, -1);
	int ans = -1;
	rep(i, n)
	{
		if (dp[i] < 0)rec(i);
		chmax(ans, dp[i]);
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <cmath>

using ll = long long;

using namespace std;

ll n, a, b, c, d, e;

int main()
{
	cin >> n >> a >> b >> c >> d >> e;
	vector<ll> nums{a, b, c, d, e};

	ll min = a;
	for (int i = 0; i < nums.size(); i++)
	{
		if (nums[i] < min)
		{
			min = nums[i];
		}
	}
	cout << ll(5 + floor((n - 1) / min)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int x, y;
int main() {
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
signed main() {
	int a[3]; cin >> a[0] >> a[1] >> a[2]; int k; cin >> k;
	rep(i, k) {
		sort(a, a + 3);
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int,input().split()))

area = [[0 for i in range(w)] for i in range(h)]
num = 1
count = 0

for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            area[i][j] = num
            count += 1
            if count == a[num-1]:
                num += 1
                count = 0
    else:
        for j in range(w-1, -1, -1):
            area[i][j] = num
            count += 1
            if count == a[num - 1]:
                num += 1
                count = 0

for i in range(h):
    for j in range(w):
        print(area[i][j], end=' ')
        if j == w-1:
            print()

Measured memory_bytes: 3916
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[20];
int q[20];
int dp[1<<14];
int sum[1<<14];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)scanf("%d%d",p+i,q+i);
		for(int i=0;i<(1<<a);i++){
			sum[i]=0;
			for(int j=0;j<a;j++)if(i&(1<<j))sum[i]+=q[j];
		}
		for(int i=0;i<(1<<a);i++)dp[i]=99999999;
		dp[0]=0;
		for(int i=0;i<(1<<a);i++){
			int now=(1<<a)-1-i;
			int fr=b;
			for(int j=0;j<a;j++)if(i&(1<<j))fr+=p[j]-q[j];
			while(now){
				int tmp=sum[now];
				if(fr>=tmp){
					dp[i+now]=min(dp[i+now],dp[i]+1);
				}
				now=(now-1)&((1<<a)-1-i);
			}
		}
		if(dp[(1<<a)-1]>99999)printf("Impossible\n");
		else printf("%d\n",dp[(1<<a)-1]);
	}
}

Measured memory_bytes: 1168
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  long long n,m,d;
  cin >> n >> m >> d;
  if(d==0){
    //cout << 1.0*(m-1)/(n*n)*(n-d);
    printf("%f\n",1.0*(n-d)/(n*n)*(m-1));
  }else{
    //cout << 2.0*(n-d)/(n*n)*(m-1);
    printf("%f\n",2.0*(n-d)/(n*n)*(m-1));
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, X, L[110];
i64 dp[2][550][550]; // *, num segments, total length
int cnt[550];

i64 invs[101010];
i64 fact[101010], facti[101010], sums[101010];
i64 C[1010][1010];

i64 modpow(i64 x, int p = MOD - 2)
{
	if (p == 0) return 1;
	i64 tmp = modpow(x, p / 2);
	tmp = tmp * tmp % MOD;
	if (p % 2 == 1) tmp = tmp * x % MOD;
	return tmp;
}

i64 comb(int x, int y)
{
	if (0 <= y && y <= x) return C[x][y];
	return 0;
}
i64 waf(int x, int y)
{
	// x holes, y items
	return comb(x + y - 1, y);
}

int main()
{
	scanf("%d%d", &N, &X);
	for (int i = 0; i < N; ++i) scanf("%d", L + i);
	for (int i = 0; i < N; ++i) ++cnt[L[i]];
	C[0][0] = 1;
	for (int i = 1; i <= 1000; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= 1000; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}

	for (int i = 1; i <= 1000; ++i) invs[i] = modpow(i);
	fact[0] = facti[0] = 1;
	for (int i = 1; i <= 1000; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		facti[i] = facti[i - 1] * invs[i] % MOD;
	}

	int t = 0;
	for (int j = 0; j <= X; ++j) {
		for (int k = 0; k <= X; ++k) {
			dp[t][j][k] = 0;
		}
	}
	dp[t][0][0] = 1;
	for (int i = X; i >= 1; --i) {
		for (int j = 0; j <= X; ++j) {
			for (int k = 0; k <= X; ++k) {
				dp[1 - t][j][k] = 0;
			}
		}
		for (int j = 0; j <= X; ++j) {
			for (int k = 0; k <= X; ++k) {
				if (dp[t][j][k] == 0) continue;
				int s = k;
				for (int l = 0; s <= X; ++l, s += i) {
					ADD(dp[1 - t][j + l][s], dp[t][j][k] * facti[l] % MOD);
				}
			}
		}
		for (int r = 0; r < cnt[i]; ++r) {
			for (int j = 0; j <= X; ++j) {
				for (int k = 0; k <= X; ++k) {
					if (dp[1 - t][j][k]) {
						dp[1 - t][j][k] = dp[1 - t][j][k] * max(0, k - j * (i - 1)) % MOD;
					}
				}
			}
		}
		t = 1 - t;
	}
	i64 ret = 0;
	for (int i = 1; i <= X; ++i) {
		for (int j = 0; j <= X; ++j) {
			i64 bas = dp[t][i][j];
			int n_range = i;
			int n_blank = X - j;
			i64 tmp = bas * fact[i] % MOD * waf(n_range + 1, n_blank - n_range + 1) % MOD;
			//printf("%d %d: %lld %lld\n", i, j, bas, tmp);
			if (n_blank % 2 == 1) tmp = MOD - tmp;
			ADD(ret, tmp);
		}
	}
	printf("%lld\n", ret);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    bool rev = false;
    deque<int> a;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (rev) {
            a.push_front(x);
        } else {
            a.push_back(x);
        }
        rev ^= 1;
    }
    if (rev) {
        for (int i = n - 1; i >= 0; i--) {
            printf("%d ", a[i]);
        }
    } else {
        for (int i = 0; i < n; i++) {
            printf("%d ", a[i]);
        }
    }
    printf("\n");
}



Measured memory_bytes: 2944
def simple(init,year,rate,fee):
    accum=0
    for i in range(year):
        accum+=int(init*rate)
        init-=fee
    return init+accum

def compound(init,year,rate,fee):
    for i in range(year):
        init+=int(init*rate-fee)
    return init

m=input()
for i in range(m):
    init=input()
    year=input()
    n=input()
    L=[map(float,raw_input().split()) for i in range(n)]
    maxInt=0
    for data in L:
        if data[0]==0:
            maxInt=max(maxInt,simple(init,year,data[1],data[2]))
        else:
            maxInt=max(maxInt,compound(init,year,data[1],data[2]))
    print int(maxInt)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p,ll b)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,b);
	z=(z*z)%b;
	if(p%2) z=(z*a)%b;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2,MOD);
}


int main()
{
	string s;
	cin>>s;
	int ans=0;
	int n=s.length();
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[n-1-i])
		{
			s[i]=s[n-1-i];
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    a_b = sorted([list(map(int, input().split())) for _ in range(M)])
    used = [0] * M
    ans = 0
    for i in range(M):
        k = M - i - 1
        if used[k]:
            continue
        used[k], c = 1, a_b[k][0]
        for j in range(k):
            if a_b[j][0] <= c < a_b[j][1]:
                used[j] = 1
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 64260
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(a * b / saikou(a, b))
}

func saikou(a int, b int) int {
	if a%b == 0 {
		return b
	}
	return (saikou(b, a%b))

}


Measured memory_bytes: 512
import Data.Char

solve :: Int -> Int -> Int
solve n m 
    | m > n = 0
    | (length $ show m) < 3 = solve'
    | check = 1 + solve'
    | otherwise = solve'
        where
            xs = map digitToInt $ show m
            check = (elem 7 xs) && (elem 5 xs) && (elem 3 xs)
            solve' = (solve n (m*10+7)) + (solve n (m*10+5)) + (solve n (m*10+3))

main = do
    n <- readLn :: IO Int
    print $ if (length $ show n) < 3 then 0 else solve n 0

Measured memory_bytes: 1020
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = sorted(inpl())
res = 0
for i in range(n-1):
    for j in range(i+1,n):
        c = bisect.bisect_left(a,a[i]+a[j]) 
        res += c-j-1
print(res)

Measured memory_bytes: 67928
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Set<String> set = new HashSet<>();
        for(int i = 0; i < N; i++) {
            String s = scanner.next();
            set.add(s);
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 77224
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){    
  long long N,M;
  cin >> N >> M;
  int A[N],sum=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }

  sort(A,A+N,greater<int>());
  double O = (double)sum/(4*M);
  //cout << M << endl;
  
  for(int i=0;i<M;i++){
    if(A[i]<O){
    cout << "No"  << endl;
    return 0;
    }
  }
     cout << "Yes" << endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int a, b;cin>>a>>b;
  cout<<(((a%3==0 || b%3==0)||(a+b)%3==0)?"Possible":"Impossible")<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int pre = -999;
  rep(i,n) {
    if (pre <= a[i]-1) {
      pre = a[i]-1;
    } else if (pre <= a[i]) {
      pre = a[i];
    } else {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
babies = [(a, i) for i, a in enumerate(A)]
babies.sort(reverse=True)
# print(babies)
dp = [[0]*(N+1) for _ in range(N+1)]
ans = 0
for l in range(N):
    for r in range(N):
        if l + r == N:
            ans = max(ans, dp[l][r])
            break
        active, index = babies[l+r]
        dp[l][r+1] = max(dp[l][r+1], dp[l][r] +
                         abs(index - (N - 1 - r))*active)
        dp[l+1][r] = max(dp[l+1][r], dp[l][r] + abs(index - l)*active)

print(ans)


Measured memory_bytes: 100756
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  int h,w;
  cin >> h >> w;

  vector<string> s(h,"");
  REP(i, h) REP(j, w){
    char c;
    cin >> c;
    s[i] += c;
  }

  REP(i, s.size()){
    cout << s[i] << endl << s[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <random>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)



int main() {
    int n;
    cin >> n;
    ll ans = pow((ll)n, 3);
    cout << ans << "\n";
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int n; cin >> n;
    ll a[n]; rep(i,n) cin >> a[i];
    ll ans = 0;
    ll b = 1;
    rep(i,61) {
        ll cnt = 0;
        rep(j,n) {
            if ((a[j]>>i)&1) cnt++;
        }
        ll p = cnt*(n-cnt)%mod;
        ans = (ans + p*b%mod)%mod;
        b = (b*2)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5884
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=200005;
ll fenv[N];
void addFenv(ll p, ll x) {
    for(; p < N; p |= p + 1)
        fenv[p] =(fenv[p] + x)%hell;
}
ll getFenv(ll r) {
    ll res = 0;
    for(; r >= 0; r = (r & (r + 1)) - 1)
        res = (res+fenv[r])%hell;
    return res;
}
void solve(){
    ll n,k;
    cin>>n>>k;
    vector<pii> ranges(k);
    rep(i,0,k-1){
        cin>>ranges[i].x>>ranges[i].y;
    }
    addFenv(1,1);
    rep(i,2,n){
        ll curr=0;
        for(auto j:ranges){
            ll minn=max(0ll,i-j.x);
            ll maxx=max(0ll,i-j.y);
            curr=(curr+(getFenv(minn)-getFenv(maxx-1)+hell)%hell)%hell;
        }
        // cout<<curr<<" ";
        addFenv(i,curr);
    }
    cout<<(getFenv(n)-getFenv(n-1)+hell)%hell<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

const int NMAX=200010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

vector<mint> dp;
vector<bool> flag;

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

  dp.resize(2*n);
  flag.resize(2*n, false);
  flag[2*n - 1] = true;

  vector<mint> apow(n+1), bpow(n+1);
  apow[0].x = 1;
  bpow[0].x = 1;
  rep(i,n) apow[i+1] = apow[i] * (mint)a / (mint)(a+b);
  rep(i,n) bpow[i+1] = bpow[i] * (mint)b / (mint)(a+b);  
  
  auto rec = [&](auto f, int i) {
	       if(flag[i]) return dp[i];
	       flag[i] = true;	       
	       mint res = (mint)100 + (mint)(a+b) * f(f, i+1);
	       res /= (mint)(100 - c);
	       return dp[i] = res;
	     };

  Make_Fact();
  Make_InvFact();

  rec(rec, 0);
  
  mint res = 0;
  for(int i = 0; i < n; ++i) {
    res += dp[i] * apow[n] * bpow[n-1-i] * Comb(2*n-i-2, n-1);
    res += dp[i] * apow[n-1-i] * bpow[n] * Comb(2*n-i-2, n-1);    
  }
  cout << res.x << "\n";
  return 0;
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c&&b!=c) cout<<"Yes";
	else if(a==c&&a!=b&&b!=c) cout<<"Yes";
	else if(b==c&&a!=b&&a!=c) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string in;
  while(cin>>in!='\0'){
    int j=1;
    while((in.size()-j)!=0){
      int i;
      for(i=0;i<in.size()-j;i++){
	in[i]+=in[i+1]-'0';
	if(in[i]>'9')
	  in[i]-=10;
      }
      //cout << in<<endl;
      in[i]='\0';
      //cout << in[i] << endl;
      //cout << in.length()<<endl;
      //break;
      j++;
    }
    cout << in[0] << endl;
  }
}

Measured memory_bytes: 1172
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
//A,T,G,C==0,1,2,3
//GCA
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;cin>>n;
    string s;cin>>s;
    ll r=0;
    ll b=0;
    rep(i,0,n){
        if(s[i]=='R')r++;
        else b++;
    }
    if(r>b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 888