akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX


void solve()
{
    int n,l;
    cin >> n >> l;
    int arr[n];
    inp(arr, n);
    int curr = 0;
    int ans = 1;
    rep(i,0,n-1)
    {
        curr += arr[i];
        if(curr <= l)
            ans++;
    }

    cout << ans << endl;
}


signed main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
#pragma GCC optimize(3 , "Ofast" , "inline")

#include <bits/stdc++.h>

#define rep(i , a , b) for(register int i=(a);i<=(b);i++)
#define per(i , a , b) for(register int i=(a);i>=(b);i--)


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int , int> pi;

template<class T>
inline void read (T &x) {
    x = 0;
    int sign = 1;
    char c = getchar ();
    while (c < '0' || c > '9') {
        if ( c == '-' ) sign = - 1;
        c = getchar ();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar ();
    }
    x = x * sign;
}

const int maxn = 2e5 + 10;
const int inf = int (1e9);
const ll INF = ll (1e18);
const double PI = acos (- 1);
const int mod = 1e9+7;
const double eps = 1e-8;

unordered_map<string,int>mp;
char x[20];
string s[maxn];
int ma = 0;
vector<string>v;
int main () {
    int n;
    scanf ("%d",&n);
    rep (i,1,n) {
        scanf ("%s",x+1);
        int l = strlen (x+1);
        s[i] = "";
        rep (j,1,l) {
            s[i]+=x[j];
        }
        mp[s[i]]++;
        ma=max (ma,mp[s[i]]);
    }
    for(auto p:mp) {
        if(ma==p.second) {
            v.push_back (p.first);
        }
    }
    sort (v.begin (),v.end ());
    for( auto p:v) {
        int l = p.size ();
        rep (i,0,l-1) {
            x[i]=p[i];
        }
        x[l]='\0';
        printf ("%s\n",x);
    }
    return 0;
}


Measured memory_bytes: 28228
#include<stdio.h>
#include<math.h>
#define ARR_LEN 200000

int main() {
	int P[ARR_LEN];
	int N, i, j;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &P[i]);
	}

	int R = 0;
	int R_flag, P_min;
	P_min = P[0];
	for (i = 0; i < N; i++) {
		if (P_min >= P[i]) {
			P_min = P[i];
			R++;
		}
	}
	printf("%d\n", R);
	return 0;
}

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

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

using namespace std;

int n,m;

vector<vector<bool> > rotate90(const vector<vector<bool> >& piece){
  vector<vector<bool> > ret;
  int h = piece[0].size(), w = piece.size();
  ret.resize(h);
  for(int i=0;i<h;i++)ret[i].resize(w);
  for(int y=0;y<ret.size();y++){
    for(int x=0;x<ret[0].size();x++){
      ret[y][x] = piece[ret[0].size()-1-x][y];
    }
  }
  return ret;
}


int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
bool visited[100][100];

bool isValid(int x,int y) { return 0 <= x && x < n && 0 <= y && y < n; }

bool dfs(int x,int y,bool color,vector<vector<bool> > &vec){
  rep(i,4){
    int nx = x + dx[i], ny = y + dy[i];
    if( !isValid(nx,ny) ) continue;
    if( color == vec[ny][nx] && !visited[ny][nx] ) {
      vec[ny][nx] = !vec[ny][nx];
      visited[ny][nx] = true;
      dfs(nx,ny,color,vec);
    }
  }
}

int main(){

  cin >> n >> m;

  vector<vector<bool> > vec(n,vector<bool>(n,false));

  rep(i,n) rep(j,n) {
    int v;
    cin >> v;
    vec[i][j] = (v?true:false);
  }

  rep(i,m){
    int o;
    cin >> o;
    if( o == 0 ) {
      int r,c,size,angle;
      cin >> r >> c >> size >> angle;
      --r, --c;
      swap(r,c);
      vector<vector<bool> > temp(size,vector<bool>(size));
      rep(y,size) rep(x,size) temp[y][x] = vec[c+y][r+x];
      rep(_,angle/90) temp = rotate90(temp);
      rep(y,size) rep(x,size) vec[c+y][r+x] = temp[y][x];
    } else if( o == 1 ) {
      int r,c,size;
      cin >> r >> c >> size;
      --r, --c;
      swap(r,c);
      rep(y,size) rep(x,size) vec[c+y][r+x] = !vec[c+y][r+x];
    } else if( o == 2 ) {
      int r;
      cin >> r;
      --r;
      //rep(x,n-1) swap(vec[r][x],vec[r][x+1]);
      rep(x,n-1) {
	bool temp = vec[r][x];
	vec[r][x] = vec[r][x+1];
	vec[r][x+1] = temp;
      }
    } else if( o == 3 ) {
      int r;
      cin >> r;
      --r;
      //for(int x=n-1;x>0;x--) swap(vec[r][x],vec[r][x-1]);
      for(int x=n-1;x>0;x--) {
	bool temp = vec[r][x];
	vec[r][x] = vec[r][x-1];
	vec[r][x-1] = temp;
      }
    } else {
      memset(visited,false,sizeof(visited));
      int r,c;
      cin >> r >> c;
      --r, --c;
      bool color = vec[r][c];
      visited[r][c] = true;
      vec[r][c] = !color;
      dfs(c,r,color,vec);
    }
  }

  rep(i,n) {
    rep(j,n){
      if( j ) cout << ' ';
      cout << vec[i][j];
    } puts("");
  }

  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int k;
	cin >> k;
	long long a[100000];
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}
	long long small = 2, big = 2;
	for (int i = k - 1; i >= 0; i--) {
		small = ceil((double)small / a[i])*a[i];
		big = floor((double)big / a[i])*a[i] + a[i] - 1;
		if (big < small) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << small << " " << big << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXN=200000;
int A[MAXN];

int main(){
    int k,n;
    cin >> k >> n;
    rep(i,n){
        cin >> A[i];
    }

    sort(A, A+n);
    int maxi = min(k-(A[n-1] - A[0]),A[n-1] - A[0]);
    rep(i,n-1){
        maxi = max((A[i+1]-A[i]),maxi);
    }
    cout << k - maxi << endl;

    return 0;
}

Measured memory_bytes: 4424
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    set<int> st;
    REP(i, n)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (!(i + 1 == j && j + 1 == k))
                    continue;
                int maxv = max(a[i], max(a[j], a[k]));
                int minv = min(a[i], min(a[j], a[k]));
                if (a[j] != maxv && a[j] != minv)
                    st.insert(a[j]);
            }
        }
    }
    cout << st.size() << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;

    vector<int> A(N);
    vector<vector<int>> sum(3, vector<int>(N+1, 0));
    for (int i=N-1; i>=0; --i) {
        int x = 0;
        if (S[i] == 'G') x = 1;
        if (S[i] == 'B') x = 2;
        A[i] = x + 1;
        for_(j,0,3) sum[j][i] = sum[j][i+1] + (j == x ? 1 : 0);
    }

    lint ans = 0;
    for_(i,0,N) for_(j,i+1,N) {
        if (S[i] != S[j]) {
            int k = 2 * j - i;
            if (k < N and S[i] != S[k] and S[j] != S[k]) --ans;
            int x = (A[i] ^ A[j]) - 1;
            ans += sum[x][j];
        }
    }
    cout << ans << endl;
}

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

int main() {
  ll n;
  string s;
  cin >> n >> s;
  
  ll cnt=1;
  rep(i,n-1){
    if(s[i] != s[i+1]) cnt++;
  }
  
  cout << cnt << endl;
  
  return(0);
}

Measured memory_bytes: 3740
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		read().stream()//
				.map(new Main()::execute)//
				.forEach(System.out::println);
	}

	private static List<Integer> read() {
		Scanner sc = new Scanner(System.in);

		int q = sc.nextInt();
		List<Integer> valueList = new ArrayList<>();
		for (int i = 0; i < q; i++) {
			valueList.add(sc.nextInt());
		}

		sc.close();
		return valueList;
	}

	public int execute(int originalValue) {
		if (originalValue < 10) {
			return 0;
		} else {
			return execute(originalValue, new HashSet<>()).getAsInt();
		}
	}

	public OptionalInt execute(int originalValue, Set<Integer> valueSet) {
		if (originalValue < 10) {
			return OptionalInt.of(valueSet.size());
		} else if (valueSet.contains(originalValue)) {
			return OptionalInt.of(-1);
		} else {
			valueSet.add(originalValue);
			return execute(next(originalValue).getAsInt(), copy(valueSet));
		}
	}

	private <T> Set<T> copy(Set<T> source) {
		Set<T> dest = new HashSet<T>();
		dest.addAll(source);
		return dest;
	}

	private OptionalInt next(int value) {
		String str = String.valueOf(value);
		return IntStream.range(1, str.length())//
				.map(i -> Integer.parseInt(str.substring(0, i)) * Integer.parseInt(str.substring(i))).max();
	}
}

Measured memory_bytes: 38404
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val s = (0 until h).map { sc.next().toCharArray() }
    println(problem088d(h, w, s))
}

fun problem088d(h: Int, w: Int, a: List<CharArray>): Int {
    val seen = Array(h) { Array(w) { "_" } }
    val deque = ArrayDeque<Pair<Int, Int>>()
    seen[0][0] = "0"
    deque.offer(0 to 0)
    var constCount = 1
    while (deque.isNotEmpty()) {
        val v = deque.poll()
        // left
        if (v.second - 1 >= 0 && a[v.first][v.second - 1] != '#' && seen[v.first][v.second - 1] == "_") {
            seen[v.first][v.second - 1] = (seen[v.first][v.second].toInt() + 1).toString()
            deque.offer(v.first to v.second - 1)
        }
        // right
        if (v.second + 1 < w && a[v.first][v.second + 1] != '#' && seen[v.first][v.second + 1] == "_") {
            seen[v.first][v.second + 1] = (seen[v.first][v.second].toInt() + 1).toString()
            deque.offer(v.first to v.second + 1)
        }
        // top
        if (v.first - 1 >= 0 && a[v.first - 1][v.second] != '#' && seen[v.first - 1][v.second] == "_") {
            seen[v.first - 1][v.second] = (seen[v.first][v.second].toInt() + 1).toString()
            deque.offer(v.first - 1 to v.second)
        }
        // bottom
        if (v.first + 1 < h && a[v.first + 1][v.second] != '#' && seen[v.first + 1][v.second] == "_") {
            seen[v.first + 1][v.second] = (seen[v.first][v.second].toInt() + 1).toString()
            deque.offer(v.first + 1 to v.second)
        }
    }
    if (seen[h - 1][w - 1] == "_") return -1
    var whiteCount = -1
    for (i in 0 until a.size) {
        for (j in 0 until a[i].size) {
            if (a[i][j] != '#') whiteCount++
        }
    }
    val minCost = seen[h - 1][w - 1]
//    debugLog(minCost, whiteCount)
    return whiteCount - minCost.toInt()
}

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

typedef long long ll;

int main(){
    int a,b,c,n;
    cin>>a>>b>>c>>n;
    ll ans=0;
    for (int i=0;a*i<=n;++i){
        for (int j=0;b*j+a*i<=n;++j){
            int k=n-a*i-b*j;
            if (k%c!=0) continue;
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
x, y = gets.chomp.split(" ").map(&:to_i)
array = []

y.times do
  num1 = gets.to_i
  num2 = gets.chomp.split(" ").map(&:to_i)
  num2.each do |e|
    array << e
  end
end

puts x - array.uniq.length


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll h,w;
	cin >> h >>w;
	if(h%3==0 || w%3==0){ puts("0"); return 0;}
	
	ll ans = 1LL<<50;
	
	
	ll h3= h/3;
	ans = min(ans,  w*(h3+1) - w*h3 );
	
	rep2(i, max(h3-1,1LL), min(h3+2,h)){
		ll m1 = w*i;
		ll m2 = (h-i) * (w/2);
		ll m3 = (h-i) * (w - w/2);
		ll mn = min({m1, m2, m3});
		ll mx = max({m1, m2, m3});
		//printf("%lld;%lld:%lld:%lld,  ",i,m1,m2,m3);
		ans = min(ans, mx-mn);
	}
	ll w3 = w/3;
	ans = min(ans,  h*(w3+1) - h*w3 );
	
	rep2(i, max(w3-1,1LL), min(w3+2,w)){
		ll m1 = h*i;
		ll m2 = (w-i) * (h/2);
		ll m3 = (w-i) * (h - h/2);
		ll mn = min({m1, m2, m3});
		ll mx = max({m1, m2, m3});
		//printf("%lld;%lld:%lld:%lld,  ",i,m1,m2,m3);
		ans = min(ans, mx-mn);
	}

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



Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;
int main(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i1=1;i1<=n;i1++){
		if(i1%3!=0&&i1%5!=0){
			ans+=i1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    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;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//datatypes
	#define int long long
	#define vi vector<int>
	#define si set<int>
	#define vii vector<ii>
	#define ii pair<int,int>
	#define mii map<int,int>
	#define M 1000000007
	#define pi 3.141592653589793
	#define in(x) int x; cin>>x;
	#define sz(x) (int)x.size()
	#define fr first
	#define sc second
	#define pb push_back
	#define mkp make_pair
	#define inputFile \
	    freopen("input.txt", "r", stdin); 
	#define outputFile \
	    freopen("output.txt", "w", stdout)
	#define rep(i,a,b) for(int i=a; i<b; i++)
	#define trav(a) for(auto &x:a)
	#define test cout<<"hello\n";
	#define all(x) (x).begin(),(x).end()
	#define mem0(x) memset(x, 0, sizeof(x))
	#define mem1(x) memset(x, -1, sizeof(x))
	#define sa(x) std::sort(all(x))
	#define sd(x) std::sort(all(x),greater<int>())
int n;
int s;
vi w, v;
#define rep(i,a,b) for(int i=a; i<b; ++i)

signed solve()
{
	cin>>n>>s;

	w.resize(n+1);
	v.resize(n+1);
	rep(i,0,n)cin>>w[i+1]>>v[i+1];

	int dp[n+1][s+1]={};
	for(int it=1; it<n+1; ++it)
	{
		for(int cw=0; cw<=s; cw++)
		{
			if(cw<w[it])
				dp[it][cw]=dp[it-1][cw];
			else
				dp[it][cw]=max(v[it]+dp[it-1][cw-w[it]], dp[it-1][cw]);
		}
	}
	/*rep(i,0,n+1)
	{
		rep(j,0,s+1)
		cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	cout<<dp[n][s];

	return 0;
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	//cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 79232
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int a[200000], visited[200000];

ll dfs(int x, int y) {
  ll res = 0LL;
  while (a[x] != y) {
    x = a[x];
    res++;
  }
  return res + 1LL;
}

int main() {
  int n, p = 0, pp;
  ll k, cnt = 0LL;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  while (k && visited[p] == 0) {
    visited[p] = 1;
    p = a[p];
    k--;
  }
  if (k == 0 || a[p] == p) {
    cout << p + 1LL << endl;
    return 0;
  }
  cnt = dfs(p, p);
  k %= cnt;
  for (ll i = 0; i < k; i++) {
    p = a[p];
  }
  cout << p + 1LL << endl;
}

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

int main(){
    string s;
    int flg=0;
    cin >> s;
    for(int i=1;i<(int)s.size();i++){
        if(s[i-1]==s[i]){
            cout << max(i-1,1) << ' ' << i+1 << endl;
            flg=1;
            break;
        }
        if(i>=2 && s[i-2]==s[i]){
            cout << i-1 << ' ' << i+1 << endl;
            flg=1;
            break;
        }
    }
    if(flg==0) cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define prll(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll nn;
  cin >> nn;
  ll mx = 0;
  ll d[105];
  clr(d, 0);
  rep(i, 0, nn) {
    ll a;
    cin >> a;
    mx = max(a, mx);
    d[a]++;
  }
  ll n = mx + 1;
  if (n % 2 == 0) {
    ll flag = 1;
    rep(i, n / 2 + 1, n) {
      if (d[i] < 2)flag = 0;
    }
    if (d[n / 2] != 2)flag = 0;
    if (flag == 1) {
      cout << "Possible" << endl;
    }
    else {
      cout << "Impossible" << endl;
    }
    return 0;
  }
  else {
    ll flag = 1;
    rep(i, n / 2 + 1, n) {
      if (d[i] < 2)flag = 0;
    }
    if (d[n / 2] != 1)flag = 0;
    if (flag == 1) {
      cout << "Possible" << endl;
    }
    else {
      cout << "Impossible" << endl;
    }
    return 0;
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<set>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev){
    // ノードcurrentを訪問した直後の処理
    prenum[current] = lowest[current] = timer;
    timer++;
    visited[current] = true;

    int next;

    for(int i=0;i<G[current].size();i++){
        next = G[current][i];
        if(!visited[next]){
            parent[next] = current;
            dfs(next,current);
            //ノードnextの探索が終了した直後の処理
            lowest[current] = min(lowest[current],lowest[next]);
        }else if(next != prev){
            lowest[current] = min(lowest[current],prenum[next]);
        }
    }
    //ノードcurrentの探索が終了した直後の処理
}

void art_point(){
    for(int i=0;i<N;i++) visited[i] = false;
    timer = 1;
    
    //lowestの計算
    dfs(0,-1);//0==root

    set<int> ap;
    int np = 0;
    for(int i=1;i<N;i++){
        int p = parent[i];
        if(p==0) np++;
        else if(prenum[p]<=lowest[i]) ap.insert(p);
    }
    if(np>1) ap.insert(0);
    for(set<int>::iterator it = ap.begin();it!=ap.end();it++){
        cout << *it << endl;
    }
}

int main(){
    int m;
    cin >> N >> m;
    for(int i=0;i<m;i++){
        int s,t;cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_point();
}


Measured memory_bytes: 7064
#include "bits/stdc++.h"
#define inf 0x3f3f3f3f
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
typedef unsigned long long ull;
//typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
#define MOD 998244353
typedef long long ll;
using namespace std;
const int maxn = 100005;
char b[maxn];
const char p[]="ACGT";
int n,s[maxn],q;
int main(){
	cin>>n>>q>>b;
	for(int i=2;i<=n;i++){
		if(b[i-1]=='C'&&b[i-2]=='A') s[i]=s[i-1]+1;
		else s[i]=s[i-1];
		//cout<<s[i]<<endl;
	}
	for(int i=0;i<q;i++){
		int u,v;
		cin>>u>>v;
		int ans=s[v]-s[u-1];
		if(u>1&&u<v&&b[u-2]=='A'&&b[u-1]=='C') ans--;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main() {
	int a1, a2, a3;
	int sum;
	scanf("%d %d %d", &a1, &a2, &a3);

	sum = a1 + a2 + a3;
	if (sum < 22){
		printf("win\n");
	}else{
		printf("bust\n");
	}
	
	return 0;
}

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

int main(){
	int d,i;
	long sum;
	
	while(std::cin >> d){
		sum = 0;
		for(i=d;i<600;i+=d){
			sum+= d*i*i;
		}
		std::cout << sum << std::endl;
	}
}

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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
#define R0F(i, a) for (int i = a; i >= 0; i--)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
typedef vector<vi64> vvi64;
typedef vector<vpi64> vvpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};
const int rm[] = {+1, +4, +5, +9, +10, +40, +50, +90, +100, +400, +500, +900, +1000};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << (a == b ? "Yes" : "No") << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int ac = 0, wa = 0, tle = 0, re = 0;

            for(int i = 0; i < N; i++) {
                String s = in.next();
                if(s.equals("AC")) ac++;
                else if(s.equals("WA")) wa++;
                else if(s.equals("TLE")) tle++;
                else re++;
            }

            out.println("AC x " + ac);
            out.println("WA x " + wa);
            out.println("TLE x " + tle);
            out.println("RE x " + re);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 38764
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X;
    cin >> N >> X;
    int L[110];
    rep(i, N) cin >> L[i];
    int ans = 0;
    int sum = 0;
    rep(i, N) {
        if(sum <= X) ans++;
        sum += L[i];
    }
    if(sum <= X) ans++;
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 3656
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
import numpy as np
n=int(input())
s=list(input() for _ in range(n))

for i in range(n):
    s[i]=sorted(s[i])
s.sort()

ans=0
cnt=1
for i in range(1,n):
    if s[i]==s[i-1]:
        cnt+=1
    elif (s[i]!=s[i-1]) & (cnt>1):
        ans+=combinations_count(cnt, 2) 
        cnt=1
    else:
        continue
if cnt>1:
    ans+=combinations_count(cnt, 2)
print(ans)
        


Measured memory_bytes: 34396
#include<iostream>
 
using namespace std;
 
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
    cout<<"No";
    else if(a==b || b==c || a==c)
    cout<<"Yes";
    else 
    cout<<"No";
    return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
int main() 
{
ll h,w;
cin>>h>>w;
if(h==1 || w==1)
{
    cout<<1;
    return 0;
}
if(h%2==0)
{
    cout<<(h/2)*w<<endl;
}
else
if(h%2!=0)
{
    ll x=h/2;
    ll y=w/2;
    ll res=(x*y);
    //cout<<res;
    res+=(h-x)*(w-y);
    //cout<<res;
    cout<<res<<endl;
    
}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
for i in range(1, N+1):
  if i % 2 == 1:
    cnt = 0
    for j in range(1, i+1):
      if i % j == 0:
#        print(i, j)
        cnt += 1
    if cnt == 8:
      ans += 1
print(ans)

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

using namespace std;

int N;

int main() {
	int sum;
	string target, RingInfo;

	sum = 0;
	cin >> target >> N;
	for (int i = 0; i < N; ++i) {
		cin >> RingInfo;
		RingInfo += RingInfo;
		//cout << RingInfo << endl;
		if (RingInfo.find(target) != string::npos) {
			++sum;
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
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;
}

int main() {
  int M1, D1;
  cin >> M1 >> D1;
  int M2, D2;
  cin >> M2 >> D2;

  cout << (M1 != M2) << endl;
}

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

typedef long long ll;

int main()
{
  int n;
  ll a[MAX];

  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]%2==1 && a[i+1]>0){
      a[i+1]--;
      a[i]++;
    }
  }
  ll count=0;
  for(int i=0;i<n;i++){
    count+=(a[i]/2);
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << ((modpow(2, n) - nCkmod(n, a) - nCkmod(n, b) - 1) % mod + mod) % mod << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to;
};

int main() {
	int n;
	cin >> n;
	vector<int> num(n);
	map<int, int> cou;
	REP(i, n) {
		scanf("%d", &num[i]);
		cou[num[i]]++;
	}
	int ans = 0;
	for (auto itr : cou) {
		if (itr.first > itr.second) {
			ans += itr.second;
		}
		else
			ans += itr.second - itr.first;
	}

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

Measured memory_bytes: 5120
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-i for i in a]
heapq.heapify(a)
for i in range(m):
    c = heapq.heappop(a)
    c = -c // 2
    heapq.heappush(a, -c)
    if a[0] == 0:
        break
print(-sum(a))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][102];

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

	string s;
  cin>>s;
  ll n=s.size();
  string ans = s.substr(0,n-8);
  cout<<ans<<endl;

}




Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        int[][] cij = new int[3][];

        try (InputScanner is = new InputScanner(System.in)) {
            cij[0] = is.nia(3);
            cij[1] = is.nia(3);
            cij[2] = is.nia(3);
        }
        boolean con1 = (cij[1][0] - cij[1][1]) == (cij[0][0] - cij[0][1]);
        boolean con2 = (cij[2][0] - cij[2][1]) == (cij[0][0] - cij[0][1]);
        boolean con3 = (cij[1][0] - cij[1][2]) == (cij[0][0] - cij[0][2]);
        boolean con4 = (cij[2][0] - cij[2][2]) == (cij[0][0] - cij[0][2]);

        boolean con5 = (cij[0][1] - cij[1][1]) == (cij[0][0] - cij[1][0]);
        boolean con6 = (cij[0][2] - cij[1][2]) == (cij[0][0] - cij[1][0]);

        boolean con7 = (cij[0][1] - cij[2][1]) == (cij[0][0] - cij[2][0]);
        boolean con8 = (cij[0][2] - cij[2][2]) == (cij[0][0] - cij[2][0]);

        if (con1 && con2 && con3 && con4 && con5 && con6 && con7 && con8) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

long long int euclidean_gcd(long long int a, long long int b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}

int main(){
    long long int N, X;
    long long int G;
    long long int x;
    cin >> N >> X;
    long long int i = 0;
    cin >> x;
    G = abs(x-X);
    for(i = 1; i < N; i++){
        cin >> x;
        x = abs(x-X);
        G = euclidean_gcd(G, x);
    }
    
    cout << G << endl;
}


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

using namespace std;
typedef long long ll;
typedef double ld;

ll x, n;
ll p[110];
map<ll, ll> chk;
ll minn = 19876543210, numm;

int main(void)
{
	scanf("%lld %lld", &x, &n);
	
	for(ll i = 0 ; i < n ; i++)
	{
		scanf("%lld", &p[i]);
		
		chk[p[i]] = 1;
	}
	
	for(ll i = -1000 ; i <= 1000 ; i++)
	{
		if(chk[i])
			continue;
		
		if(minn > abs(x - i))
		{
			minn = abs(x - i);
			numm = i;
		}
	}
	
	printf("%lld", numm);
	return 0;
}

Measured memory_bytes: 3944
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
  double x, y;
  Point() {};
  Point(double x, double y): x(x), y(y) {}

  Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
  Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
  Point operator * (double d) { return Point(d * x, d * y); }
  Point operator / (double d) { return Point(d / x, d / y); }

  bool operator < (const Point &p) const {
    return (x == p.x ? y < p.y : x < p.x);
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

  friend ostream& operator << (ostream &os, Point &p) {
    return os << "Point(" << p.x << ", " << p.y << ")";
  }
};

typedef Point Vector;

struct Segment {
  Point p0, p1;
};

double cross (Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

double abs(Point p) {
  return sqrt(norm(p));
}

Point cross_point(Segment s0, Segment s1) {
  Vector base = s1.p1 - s1.p0;
  double h1 = abs(cross(base, s0.p0 - s1.p0)) / abs(base);
  double h2 = abs(cross(base, s0.p1 - s1.p0)) / abs(base);
  double t = h1 / (h1 + h2);
  return s0.p0 + (s0.p1 - s0.p0) * t;
}

int main() {
  int xs[4];
  int ys[4];
  Segment ss[2];

  int q; cin >> q;

  while (q--) {
    for (int i = 0; i < 4; i++) {
      cin >> xs[i];
      cin >> ys[i];
    }

    Segment s0;
    s0.p0 = Point(xs[0], ys[0]);
    s0.p1 = Point(xs[1], ys[1]);

    Segment s1;
    s1.p0 = Point(xs[2], ys[2]);
    s1.p1 = Point(xs[3], ys[3]);

    Point p = cross_point(s0, s1);
    cout << fixed << setprecision(10)
         << p.x << ' '
         << p. y << endl;
  }
}

Measured memory_bytes: 1240
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>
#include <cmath>


int main(void) {
    
    using namespace std;
    
    int a, b;
    
    cin >> a;
    cin >> b;
    
    if(a + b == 3){
        cout << 3 << endl;
    } else if(a + b == 4){
        cout << 2 << endl;
    } else if(a + b == 5){
        cout << 1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;
int main(){
	ll n,k;
	cin>>n>>k;
	vector<vector<ll> > edges;
	edges.resize(n);
	for(ll i1=0;i1<n-1;i1++){
		ll a,b;
		cin>>a>>b;
		edges[a-1].push_back(b-1);
		edges[b-1].push_back(a-1);
	}
	if(n==1){
		cout<<k<<endl;
	}else{
		ll ans = (k*(k-1))%mod;
		for(ll i1=0;i1<n;i1++){
			for(ll i2=0;i2<edges[i1].size()-1;i2++){
				ans *= (k-2-i2);
				ans %= mod;
				if(ans==0){
					cout<<0<<endl;
					return 0;
				}
			}
		}
		cout<<ans<<endl;
	}

}


Measured memory_bytes: 6516
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        ans[1] = n - k + 1
        if n != k:
            for i in range(2, min(n - k + 1, k) + 1):
                ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                          2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                          sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 77020
import java.util.*;
class Main {
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();
       int x = sc.nextInt();
       
       int answer = 0;
       for(int i = 0; i <= a; i++){
           for(int j = 0; j <= b; j++){
               for(int k = 0; k <= c; k++){
                   int tmp = i * 500 + j * 100 + k * 50;
                   if(tmp == x) answer++;
               }
           }
       }
       
       System.out.print(answer);
   }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,m,T;
int x,y,a[maxn];
map<pair<int,int>,bool> s;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m); read(T);
	for (int i=1;i<=n;i++) a[i]=m+1;
	while (T--) {
		read(x); read(y);
		s[make_pair(x,y)]=1;
		a[x]=min(a[x],y);
	}
	int j=1;
	for (int i=1;i<=n;i++) {
		if (a[i+1]<=j) {
			printf("%d\n",i); return 0;
		}
		if (s[make_pair(i+1,j+1)]||j>=m) continue;
		j++;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 22656
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
if m%2:
  print(-1)
else:
  G = [[] for _ in range(n+1)]
  par = [-1]*(n+1)
  ch = [[] for _ in range(n+1)]
  seen = [False]*(n+1)
  used = set()
  C = [0]*(n+1)
  for _ in range(m):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
  
  stack = [1]
  seen[1] = True
  while stack:
    v = stack.pop()
    for nv in G[v]:
      if seen[nv]:
        if par[v] != nv:
          if (v, nv) not in used:
            used.add((v, nv))
            used.add((nv, v))
            print(v, nv)
            C[v] ^= 1
      else:
        seen[nv] = True
        par[nv] = v
        ch[v].append(nv)
        stack.append(nv)
  
  def bottom_up(v):
    for nv in ch[v]:
      bottom_up(nv)
    if v == 1:
      return
    if C[v]:
      C[v] ^= 1
      print(v, par[v])
    else:
      C[par[v]] ^= 1
      print(par[v], v)
      
  bottom_up(1)

Measured memory_bytes: 123924
r=range
def a(i,j,k,l=0):print("+<"[l],i,j,k)
print(6484)
a(0,1,3)
a(2,3,3,1)
for x in 0,1:
	a(x,3,x)
	for t in r(30):a(v:=x+4,v,v);a(v,3,6),exec('a(6,6,6);'*(29-t));a(6,x,T:=x*60+9+t,1);a(v,T,v)
for t in r(60):a(2,2,2);[(a(8+t-s,69+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int h, w;
  cin>>h>>w;
  char s[30][30];
  REP(i, w+2){
    s[0][i]=s[h+1][i]='#';
  }
  REP(i, h+2){
    s[i][0]=s[i][w+1]='#';
  }
  REP(i, h){
    REP(j, w){
      cin>>s[i+1][j+1];
    }
  }
  int ans=0;
  FOR(x, 1, h+1){
    FOR(y, 1, w+1){
      if(s[x][y]=='#'){
        continue;
      }
      FOR(a, 1, h+1){
        FOR(b, 1, w+1){
          if(s[a][b]=='#'){
            continue;
          }
          bool used[30][30];
          int d[30][30];
          FOR(i, 1, h+1){
            FOR(j, 1, w+1){
              used[i][j]=false;
            }
          }
          used[x][y]=true;
          d[x][y]=0;
          queue<pii> que;
          que.push(pii(x, y));
          while(que.size()){
            pii uv=que.front();que.pop();
            int u=uv.first, v=uv.second;
            if(u==a && v==b){
              break;
            }
            REP(i, 4){
              int uu=u+dx[i], vv=v+dy[i];
              if(s[uu][vv]=='#' || used[uu][vv]){
                continue;
              }
              used[uu][vv]=true;
              que.push(pii(uu, vv));
              d[uu][vv]=d[u][v]+1;
            }
          }
          CHMAX(ans, d[a][b]);
        }
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256