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

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

// global variables

ll res=0;

int main() {
  string s;cin>>s;
  int n = s.size();

  rep(i,n){
    int l = i;
    int r = n-1-i;
    FOR(j, 1, r+1){
      ll tmp = 1;
      tmp = (s[i]-'0') * pow(10, j-1);
      tmp *= pow(2, l);
      tmp *= pow(2, r-j);
      res += tmp;
    }
    res += pow(2, l) * (s[i]-'0') * pow(10, r);
  }

  cout << res << endl;

  return 0;
}


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

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

  vector<int> result(N);

  for(int i=0;i<N;i++) {
    int number;
    cin >> number;

    result[number-1] = i+1;
  }

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

  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int d1[4] = { 1,0,-1,0 };
int d2[4] = { 0,1,0,-1 };
int d3[4] = { 0,-1,0,1 };
int main() {
	int w, h;
	while (cin >> w >> h, w) {
		char fi1[52][52]; char fi2[52][52];
		rep(i, 52) {
			rep(j, 52) {
				fi1[i][j] = fi2[i][j] = '#';
			}
		}
		string s, t;
		P s1, s2, g1, g2;
		rep1(i, h) {
			cin >> s >> t;
			rep1(j, w) {
				fi1[i][j] = s[j - 1];
				if (fi1[i][j] == '%') {
					g1 = { i,j };
				}
				else if (fi1[i][j] == 'L') {
					s1 = { i,j };
				}
			}
			rep1(j, w) {
				fi2[i][j] = t[j - 1];
				if (fi2[i][j] == '%') {
					g2 = { i,j };
				}
				else if (fi2[i][j] == 'R') {
					s2 = { i,j };
				}
			}
		}
		map<pair<P, P>, int> used;
		queue<pair<P, P>> v;
		bool f = false;
		v.push({ s1, s2 });
		used[{s1, s2}] = 1;
		while (!v.empty()) {
			pair<P, P> now = v.front();
			P n1 = now.first; P n2 = now.second; v.pop();
			if (n1 == g1 && n2 == g2) {
				f = true; break;
			}
			else if (n1 == g1 || n2 == g2) {
				continue;
			}
			rep(i, 4) {
				P nex1 = { n1.first + d1[i],n1.second + d2[i] };
				P nex2 = { n2.first + d1[i],n2.second + d3[i] };
				if (fi1[nex1.first][nex1.second] == '#') {
					nex1 = n1;
				}
				if (fi2[nex2.first][nex2.second] == '#') {
					nex2 = n2;
				}
				if (used[{nex1, nex2}]!=1) {
					used[{nex1, nex2}] = 1;
					v.push({ nex1,nex2 });
				}
			}
		}
		if (f) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 109064
#include <bits/stdc++.h>
#define MAXN 200001

using namespace std;

int h, w, n, x, y, si, sj;
/// L,R,U,D
int l[MAXN+1], r[MAXN+1], u[MAXN+1], d[MAXN+1];
char c;
string s, t;

bool possible = true;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	cin >> h >> w >> n;
	cin >> x >> y;
	
	l[n] = 0;
	r[n] = 0;
	u[n] = 0;
	d[n] = 0;
	
	cin >> s;
	
	for(int i =	n-1; i >= 0; i--){
		l[i] = l[i+1];
		r[i] = r[i+1];
		u[i] = u[i+1];
		d[i] = d[i+1];
		if(s[i] == 'L') l[i]++;
		if(s[i] == 'R') r[i]++;
		if(s[i] == 'U') u[i]++;
		if(s[i] == 'D') d[i]++;
	}
	
	cin >> t;
	
	sj = y;
	for(int i =	0; i < n; i++){
		if(s[i] == 'L'){
			sj--;
		}
		if(sj <= 0){
			possible = false;
			break;
		}
		if(i == n - 1) break;
		if(sj - l[i+1] <= 0 && t[i] == 'R'){
			sj++;
		}
		if(sj > w){
			possible = false;
			break;
		}
	}
	
	sj = y;
	for(int i =	0; i < n; i++){
		if(s[i] == 'R'){
			sj++;
		}
		if(sj > w){
			possible = false;
			break;
		}
		if(i == n - 1) break;
		if(sj + r[i+1] > w && t[i] == 'L'){
			sj--;
		}
		if(sj <= 0){
			possible = false;
			break;
		}
	}
	
	si = x;
	for(int i =	0; i < n; i++){
		if(s[i] == 'U'){
			si--;
		}
		if(si <= 0){
			possible = false;
			break;
		}
		if(i == n - 1) break;
		if(si - u[i+1] <= 0 && t[i] == 'D'){
			si++;
		}
		if(si > h){
			possible = false;
			break;
		}
	}
	
	si = x;
	for(int i =	0; i < n; i++){
		if(s[i] == 'D'){
			si++;
		}
		if(si > h){
			possible = false;
			break;
		}
		if(i == n - 1) break;
		if(si + d[i+1] > h && t[i] == 'U'){
			si--;
		}
		if(si <= 0){
			possible = false;
			break;
		}
	}
	
	if(!possible){
		cout << "NO\n";
	}else{
		cout << "YES\n";
	}
	
    return 0;
}

Measured memory_bytes: 3992
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, D;
  while (cin >> N >> D) {
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];
    int Q;
    cin >> Q;
    vector<int> q(Q);
    for (int i = 0; i < Q; i++) cin >> q[i], --q[i];
    vector<int> A(N + 1);
    A[0] = D;
    for (int i = 0; i < N; i++) {
      if (d[i] < 2 * A[i]) {
        A[i + 1] = abs(A[i] - d[i]);
      } else {
        A[i + 1] = A[i];
      }
    }
    vector<int> B(N + 1);
    B[N] = 1;
    for (int i = N - 1; i >= 0; i--) {
      if (d[i] >= 2 * B[i + 1]) {
        B[i] = B[i + 1];
      } else {
        B[i] = B[i + 1] + d[i];
      }
    }
    for (int x : q) {
      bool res = A[x] >= B[x + 1];
      cout << (res ? "YES" : "NO") << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 9728
use proconio::input;


fn main() {
    input! {
        n: usize
    }

    let mut vec = (0..=n).collect::<Vec<usize>>();
    let mut gen = (0..=n).collect::<Vec<usize>>();

    let mut tbl = vec![true; n+1];
    tbl[0] = false;
    tbl[1] = false;
    for i in 2..=n {
        if tbl[i] {
            gen[i] /= i;
            vec[i] *= 2;
            let mut j = i + i;
            while j <= n {
                tbl[j] = false;
                let mut count = 1;
                gen[j] /= i;
                while gen[j] % i == 0 {
                    count += 1;
                    gen[j] /= i;
                }
                vec[j] *= count+1;
                j += i;
            }
        }
    }

    let ans = {
        let mut ans = 1;
        for i in 2..=n {
            ans += vec[i];
        }
        ans
    };

    println!("{}",ans)

}



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

int main() {
	int h,n,ans,i,j;
	double cur;
	cin >> h >> n;
	vector<pair<int,int>> a(n);
	vector<int> dp(h+1,1000000000);
	
	for(i=0; i<n; i++){
		cin >> a[i].first >> a[i].second;
		a[i].first=min(a[i].first,h);
	}
	
	dp[0]=0;
	for(i=0; i<n; i++){
		for(j=1; j<=a[i].first; j++){
			dp[j]=min(dp[j],a[i].second);
		}
		for(j=a[i].first+1; j<=h; j++){
			dp[j]=min(dp[j],dp[j-a[i].first]+a[i].second);
		}
	}
	cout << dp[h] << endl;

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)
				break;
			
			
			int m = sc.nextInt();

			int[][] xy = new int[2][m];
			
			int[][] xx = new int[8][m];
			int[][] yy = new int[8][m];
			xy[0][0] = sc.nextInt();
			xy[1][0] = sc.nextInt();
			for(int i=1;i<m;i++){
				xy[0][i] = sc.nextInt() - xy[0][0];
				xy[1][i] = sc.nextInt() - xy[1][0];
			}
			xy[0][0] = xy[1][0] = 0;
			
			for(int i=0;i<4;i++){
				for(int j=0;j<m;j++){
					xx[i][j] = xy[i%2][j] * (i==0 || i==3 ? 1 : -1);
					yy[i][j] = xy[(i+1)%2][j] * (i/2==0 ? 1 : -1);
				}
				
				for(int j=m-1;j>=0;j--){
					xx[i+4][m-j-1] = xx[i][j]-xx[i][m-1];
					yy[i+4][m-j-1] = yy[i][j]-yy[i][m-1];
				}
//				System.out.println(Arrays.toString(xx[i]));
//				System.out.println(Arrays.toString(xx[i+4]));
			}
			
			for(int i=0;i<n;i++){
				m = sc.nextInt();
				xy = new int[2][m];
				xy[0][0] = sc.nextInt();
				xy[1][0] = sc.nextInt();
				for(int j=1;j<m;j++){
					xy[0][j] = sc.nextInt() - xy[0][0];
					xy[1][j] = sc.nextInt() - xy[1][0];
				}
				xy[0][0] = xy[1][0] = 0;
				if(solve(xy, xx, yy))
					System.out.println(i+1);
			}
			System.out.println("+++++");
		}
	}

	public boolean solve(int[][] xy, int[][] xx, int[][] yy) {
		if(xy[0].length != xx[0].length)
			return false;
		
		boolean res = false;
		for(int i=0;i<xx.length;i++){
			boolean r = true;
			for(int j=0;j<xx[i].length;j++){
				if(xx[i][j]!=xy[0][j] || yy[i][j]!=xy[1][j]){
					r=false;
					break;
				}	
			}
			res |= r;
		}
		
		return res;
	}

}

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

int main() {

  int a, b, c; cin >> a >> b >> c;
  int M;
  M = max({a, b, c});
  if (2 * M == a + b + c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

	char A[N],B[N];
	void main()
	{
		int n=qread();scanf("%s%s",A+1,B+1);
		int mi=2*n;
		for(int ln=n;ln>=1;ln--)
		{
			bool gg=0;
			for(int i=1;i<=ln;i++) if(A[n-ln+i]!=B[i]) gg=1;
			if(!gg) mi=min(mi,2*n-ln)/*,printf("ln=%d\n",ln)*/;
		}
		write(mi);
	}
};
int main()
{
	mine::main();
}

Measured memory_bytes: 256
INF = 10 ** 9
n, $a, $b = gets.split.map(&:to_i)
$gap = $a - $b
$monsters = []
n.times { $monsters << gets.to_i }

def all_killed?(count)
  must_center_count = 0
  $monsters.each do |monster|
    rest = monster - $b * count
    next if rest <= 0
    div, mod = rest.divmod($gap)
    must_center_count += div
    must_center_count += 1 if mod > 0
  end
  must_center_count <= count
end

# 範囲オブジェクトにも #bsearch がある
puts (1..INF).bsearch { |count| all_killed?(count) }


Measured memory_bytes: 2996
#include<bits/stdc++.h>
using  namespace std;
#define ll long long int
#define f(i,j,k) for(ll i=j;i<k;i++)

int main()
{

 ll n,k,sum=0;
 cin>>n>>k;
 while(n>0)
 {
     n=n/k;
     sum++;
 }
 cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int num[3]={0,0,0};
	int i,j;
	int min=101,index,tmp;
	scanf("%d%d%d",&num[0],&num[1],&num[2]);
	for(i=0;i<3;i++){
		min=num[i];
		index=i;
		for(j=i+1;j<3;j++){
			if(min>num[j]){
				min=num[j];
				index=j;
			}
		}
		tmp=num[i];
		num[i]=num[index];
		num[index]=tmp;
	}
	printf("%d\n",num[2]-num[0]);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S;
        char[] c;
        int change=0;
        
        S = sc.next();
        c = S.toCharArray();
        
        
        if(c[0]!='C')change++;
        if(c[1]!='O')change++;
        if(c[2]!='D')change++;
        if(c[3]!='E')change++;
        if(c[4]!='F')change++;
        if(c[5]!='E')change++;
        if(c[6]!='S')change++;
        if(c[7]!='T')change++;
        if(c[8]!='I')change++;
        if(c[9]!='V')change++;
        if(c[10]!='A')change++;
        if(c[11]!='L')change++;
        if(c[12]!='2')change++;
        if(c[13]!='0')change++;
        if(c[14]!='1')change++;
        if(c[15]!='6')change++;
        
        System.out.println(change);
    }
}

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

void LinearSearch(int& Count, int t, vector<int> S)
{
	int n = S.size();
	for(int j = 0; j < n; j++){
		if(t == S[j]){
			Count ++;
			break;
		}	
	}
}

int main()
{
	int Count = 0;
	int n;
	cin >> n;
	vector<int> S;
	for(int i = 0; i < n; i++){
		int s;
		cin >> s;
		S.push_back(s);
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		LinearSearch(Count, t, S);
	}
	cout << Count << endl;
	return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> abc(3, vector<int>(n));
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < n; ++j){
      cin >> abc[i][j];
    }
  }
  sort(abc[0].begin(), abc[0].end());
  sort(abc[1].begin(), abc[1].end());
  sort(abc[2].begin(), abc[2].end());
  long long cntu = 0;
  long long cntd = 0;
  long long cnt = 0;
  for(int i = 0; i < n; ++i){
    cntu = lower_bound(abc[0].begin(), abc[0].end(), abc[1][i]) - abc[0].begin();
    cntd = n - (upper_bound(abc[2].begin(), abc[2].end(), abc[1][i]) - abc[2].begin());
    cnt += cntu * cntd;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
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);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

map<pair<int,int>,bool> M;

int main(){
    ll N,V,a,b;
    cin >> N >> V;
    rep(i,V){
        cin >> a >> b;
        M[mp(a,b)]=1;
    }
    for(auto P : M){
        if(P.first.first==1 && M[mp(P.first.second,N)]==1){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 18944
n, m = gets.split.map(&:to_i)
states = []
(n+1).times { states << [] }
py = []
m.times do
  p, y = gets.split.map(&:to_i)
  states[p] << y
  py << [p, y]
end

hash = {}
(n+1).times do |i|
  states[i].sort.each_with_index do |y, i|
    hash[y] = i+1
  end
end

py.each do |p_y|
  p, y = p_y
  puts "%06d%06d" % [p, hash[y]]
end

Measured memory_bytes: 34920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(l i=0;i<(l)(n);i++)
#define l int64_t
#define A(a) (a).begin(),(a).end()
#define mp make_pair
l O=1e9+7;
l N,M,X,Y,Z,K,a=0;
vector<l> p,m;
l r(l X){return p[X]==X?X:p[X]=r(p[X]);}
void u(l X,l Y){X=r(X);Y=r(Y);p[X]=Y;}
l mo(l a,l n){l r=1;while(n){if(n&1)r=r*a%O;a=a*a%O;n/=2;}return r;}
int main(){
cin>>N>>M>>K;
p.resize(N),m.resize(M);
vector<tuple<l,l,l>> e(M);
rep(i,M){cin>>X>>Y>>Z;
e[i]=make_tuple(Z,X-1,Y-1);
}
sort(A(e));
rep(i,M){
tie(m[i],Y,Z)=e[i];
rep(i,N)p[i]=i;
u(Y,Z);
rep(j,M){
tie(Z,X,Y)=e[j],m[i]+=(r(X)!=r(Y))*Z,u(X,Y);
}
}
sort(A(m));
rep(i,M)if(i&&m[i]==K)a+=mo(2,M-i);
cout<<a%O;
}


Measured memory_bytes: 3688
k = int(input())

lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(lst[k - 1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int N, A; cin >> N >> A;

  int sum = 0;
  vector <int> X(N);
  for (int i = 0; i < N; i++){
    cin >> X[i];
    sum += X[i];
  }
  
  long long DP[N + 1][N + 1][sum + 1];

  for (int i = 0; i < N + 1; i++){
    for (int j = 0; j < N + 1; j++){
      for (int k = 0; k < sum + 1; k++){
        DP[i][j][k] = 0;
      }
    }
  }
  
  DP[0][0][0] = 1;

  for (int i = 1; i < N + 1; i++){
    int card = X[i - 1];
    for (int j = 0; j < N + 1; j++){
      for (int k = 0; k < sum + 1; k++){
        if (i >= 1 && k < card){
          DP[i][j][k] = DP[i - 1][j][k];
        }else if(i >= 1 && k >= card){
          DP[i][j][k] = DP[i - 1][j][k] + DP[i - 1][j - 1][k - card];
        }        
      }
    }
  }

  
  long long ans = 0;
  for (int i = 1; i < N + 1; i++){
    if (i * A > sum) break;
    ans += DP[N][i][i * A];
  }
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 51072
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define fi first
#define se second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	string s, firstTow = "", last = "";
	cin >> s;
	for (int i = 0; i <= 1; i++)firstTow += s[i];
	for (int i = 2; i <= 4; i++)last += s[i];
	stringstream s1(firstTow);
	stringstream s2(last);
	int x1 = 0, x2 = 0;
	s1 >> x1;
	s2 >> x2;
	if (x1 > 0 && x1 <= 12 && (x2 > 0 && x2 <= 12)) {
		cout << "AMBIGUOUS\n";
		return 0;
	}
	
	else if ((x1 >= 1 && x1 <= 12) && (x2 >= 0 && x2 <= 99)) {
		cout << "MMYY" << endl;
	}
	else if ((x1 >= 0 && x1 <= 99) && (x2 >= 1 && x2 <= 12)) {
		cout << "YYMM" << endl;
	}
	else
		cout << "NA\n";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(next())
	s := make(map[string]int)
	for i := 0; i < n; i++ {
		s[next()]++
	}
	fmt.Println("AC x", s["AC"])
	fmt.Println("WA x", s["WA"])
	fmt.Println("TLE x", s["TLE"])
	fmt.Println("RE x", s["RE"])
}

func next() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(f.readLine());


        // twist: not just two stones ahead, K stones ahead

        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());

        int[] h = new int[n]; // nums
        st = new StringTokenizer(f.readLine());
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(st.nextToken());
        }

        int[] min_cost = new int[n];

        min_cost[0] = 0;

        for (int i = 1; i < min_cost.length; i++) {

            int j = Math.max(i - k, 0);

            int curMinCost = Integer.MAX_VALUE;
            for (; j < i; j++) {
                int _curMinCost = min_cost[j] + Math.abs(h[j] - h[i]);
                if (curMinCost > _curMinCost){
                    curMinCost = _curMinCost;
                }
            }
            min_cost[i] = curMinCost;
        }

        /* for (int i : min_cost) {
            System.out.print(String.valueOf(i) + " ");
        }
        System.out.println(); */
        System.out.println(min_cost[min_cost.length - 1]);

    }
}


Measured memory_bytes: 39044
import java.util.Scanner;
import java.lang.String;
 
public class Main {
  
  public static void main (String[] arg) {
    Scanner sc = new Scanner(System.in);
    solve(sc);
    sc.close();
  }
  
  private static void solve(Scanner sc) {
    String topCoStr = sc.next();
    char[] atCoStr = new char[topCoStr.length()];
    for (int i = 0; i < atCoStr.length; i++) {
      if (i % 2 == 0) {
        atCoStr[i] = 'g';
      } else {
        atCoStr[i] = 'p';
      }
    }
    
    int atCoPoint = 0;
    for (int k = 0; k < topCoStr.length(); k++) {
      if ((topCoStr.charAt(k) == 'g') && (atCoStr[k] == 'p')) {
        atCoPoint++;
      } else if ((topCoStr.charAt(k) == 'p') && (atCoStr[k] == 'g')) {
        atCoPoint--;
      }
    }
    
    System.out.println(atCoPoint);
  }
}

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

using namespace std;

int main(){
    int n, h, maxa=0, inda=-1, minb=2000000000, res=0, tmp;
    cin >> n >> h;
    vector<int>ind, so;
    int a[n], b[n];
    for(int i=0; i<n; i++)
        cin >> a[i] >> b[i];
    for(int i=0; i<n; i++)
        if(a[i]>maxa)
            maxa=a[i];
    sort(b, b+n);
    for(int i=n-1; i>=0; i--){
        if(b[i]>=maxa){
            h-=b[i];
            res++;
            if(h<=0){cout << res; return 0;}
        }
    }
    if(h%maxa==0) res+=h/maxa;
    else res+=h/maxa+1;
    cout <<res;
    return 0;
}

Measured memory_bytes: 1024
import Data.List
import Data.Char

differ :: Int -> [Int] -> Int
differ k l = dif (eval c) c (drop k sl) where
    sl = sort l
    c  = newCursor (take k sl) (k-1)
    dif m cl [] 
        | (eval cl) < m = eval cl
        | otherwise     = m
    dif m cl (x:xs)
        | d < m     = dif d (shift x cl) xs
        | otherwise = dif m (shift x cl) xs  
        where
            d  = eval cl

data Cursor a = Cursor [a] [a] deriving (Show)

newCursor :: [a] -> Int -> Cursor a
newCursor l k = Cursor (take k l) (drop k l)
    

shift :: a -> Cursor a -> Cursor a
shift a (Cursor [_] r) = Cursor (reverse r) [a] 
shift a (Cursor (f:fs) r) = Cursor fs (a:r)

eval :: Cursor Int -> Int
eval (Cursor (f:fs) (r:rs)) = r - f 

readData :: Int -> IO [Int]
readData 0 = return []
readData n = do
    stX <- getLine
    let x = read stX :: Int
    fmap (x:) $ readData (n-1)
        
main :: IO() 
main = do
    line1 <- getLine
    let [stN, stK] = words line1
        n = read stN :: Int
        k = read stK :: Int
    l <- readData n
    let ans = differ k l 
    print ans


Measured memory_bytes: 67964
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cfloat>
#include <algorithm>
#include <vector>
#include <iostream>
#define PI 3.141592
using namespace std;
 
int main (){
    int x;
    cin >> x;
    cout << 24 - x + 24 << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	string s;
	int count = 0;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < s.size(); j++){
			if(s[i]==s[j]){
				count++;
			}
		}
		if(count >= 2){
				cout << "no" << endl;
				return 0;
			}
		count =0;
	}
	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
void print(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)print(x/10);
	putchar(x%10+48);
}
int gcd(int x,int y){
    if(y==0)return x;
    else return gcd(y,x%y);
}
int main()
{
	int n=read(n);
    long long ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                ans+=gcd(i,gcd(j,k));
            }
        }
    }
    printf("%lld\n",ans);
	return 0;
}



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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define forall(i, a, b) for(int i=a; i < b; i++)
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,constant) memset(a, constant, sizeof(a))
#define mp make_pair
#define checkbit(n,b) ( (n >> b) & 1)
#define sort(a) sort(all(a))
#define PI acos(-1.0)
#define DEBUG 0

int main ()

{
    fast;
    
    string s;
    cin >> s;
    
    if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
    
    else cout << "No" << endl;

    return 0;
}


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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)

const int H = 11;
const int W = 1010;

const int MAXVAL = 1031;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int h, w, K;
char s[W];

int sum[H][W];
il int Get(int c, int l, int r) {
    return sum[r][c] - sum[l - 1][c];
}

int tot, pos[H], now[H], tp[H];
int ans = 0x3f3f3f3f;

int main() {
    h = read(), w = read(), K = read();
    Rep(i, 1, h) {
        gets(s + 1);
        Rep(j, 1, w) sum[i][j] = sum[i - 1][j] + (s[j] == '1');
    }
    int MAX = (1 << (h - 1)) - 1;
    Rep(i, 0, MAX) {
        memset(now, 0, sizeof(now));
        tot = 0; int tp_ans = 0;
        Rep(j, 0, h - 2) {
            if (i & (1 << j)) pos[++tot] = j + 1;
        }
        tp_ans = tot, pos[++tot] = h;
        bool failed = false;
        Rep(j, 1, w) {
            Rep(k, 1, tot) {
                tp[k] = Get(j, pos[k - 1] + 1, pos[k]);
                if (tp[k] > K) {failed = true; break;}
            }
            if (failed) break;
            Rep(k, 1, tot) {
                now[k] += tp[k];
                if (now[k] > K) {
                    Rep(l, 1, tot) now[l] = tp[l];
                    ++tp_ans; break;
                }
            }
        }
        if (failed) continue;
        ans = min(ans, tp_ans);
    } 
    return printf("%d", ans) & 0;
}

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

int main(){
  int n;
  cin >> n;
  int count = 0;
  vector<int> A(n);
  int a = 1;
  rep(i,n) cin >> A[i];
  rep(i,n){
    if(a == A[i]){
      count++;
      for(int j = i+1;j<n;++j){
        if(a+1 == A[j]){          
        count++;
        a++;
      }
    }
    break;
  }
}
  if (count == 0) puts("-1");
  else cout << n-count << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        out.println(sc.nextInt()+1-sc.nextInt());
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
//※最小公倍数はa*b/gcd(a,b)である
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define optimize()   ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl'\n';
int main()
{
    optimize();
    int n,x,t,b,a;

    cin>>n>>x>>t;
    a=ceil(n/(double)x);
    cout <<a*t;



}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;

//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		ll x;cin>>x;
		if(x>=30)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

int main()
{
  int N, ans=0;
  cin>>N;
  string name;
  cin>>name;
  for(int i=0; i<N; i++){
    string board;
    cin>>board;
    bool ok=false;
    for(int d=1; d<board.size(); d++){
      for(int j=0; j<board.size(); j++){
        for(int k=0; k<name.size(); k++){
          if(j+d*k >= board.size()) break;
          if(board[j+d*k]!=name[k]) break;
          if(k==name.size()-1) ok =true;
        }
      }
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int p=0;
  int s=0;
  while(p<N){
    int l,r;
    cin>>l>>r;
    s=s+r-l+1;
    p++;
  }
  cout << s << endl;
}
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a[4],b[4],flg[4];
	int i,j;
	int hit,blow;
	
	while(1){
		cin>>a[0];
		if(cin.eof()==1)	break;
		for(i=1;i<4;i++){
			cin>>a[i];
			flg[i]=0;
		}
		for(i=0;i<4;i++)	cin>>b[i];
		hit=0;
		blow=0;
		for(i=0;i<4;i++){
			if(a[i]==b[i]){
				hit++;
				flg[i]=1;
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(i!=j||flg[j]==0){
					if(a[i]==b[j])	blow++;
				}
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    string s;
    cin >>N >>s;
    int r,b;
    r=0;
    b=0;
    for(int i=0; i<N; i++){
        if(s[i]=='R'){
            r++;
        }
        if(s[i]=='B'){
            b++;
        }
    }
    
    if(r>b){
        cout <<"Yes";
    }else{
        cout <<"No";
    } 
    
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto ans = (n + 1) / 2 * 1.0 / n;
    writefln("%.12f", ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

#define int long long

using namespace std;

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

	
	int ans = 0 ,n,m,i,k;
	
	cin >> n >> m;
	
	double x[n],y[n];
	
	for(i=0;i<n;i++)
	{
		cin >> x[i] >> y[i];
		
		if(sqrt(x[i]*x[i]+y[i]*y[i])<=m)
		{
			ans++;        
		}
	}
	
	cout << ans << "\n";
	
	return 0;
} 

Measured memory_bytes: 6892
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

d = [(1,0),(0,1)]
def solve():
    h,w = LI()
    a = [input() for i in range(h)]
    q = deque([(0,0)])
    bfs = [[0]*w for i in range(h)]
    bfs[0][0] = 1
    while q:
        y,x = q.popleft()
        if q:
            print("Impossible")
            return
        for dy,dx in d:
            ny,nx = y+dy,x+dx
            if 0 <= ny < h and 0 <= nx < w:
                if a[ny][nx] != ".":
                    if not bfs[ny][nx]:
                        bfs[ny][nx] = 1
                        q.append((ny,nx))
    for y in range(h):
        for x in range(w):
            if a[y][x] != "." and not bfs[y][x]:
                print("Impossible")
                return
    print("Possible")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
import sys

x = [0] * 3
y = [0] * 3
z = [0] * 3
for i in range(3):
    x[i], y[i], z[i] = map(int, input().split())
N = int(input())
S = []
for j in range(N):
    S.append(int(input())) 
for l in range(N):
    for k in range(3):
        if x[k] == S[l]:
            x[k] = 0
        else:
            a = 1
        if y[k] == S[l]:
            y[k] = 0
        else:
            a = 1
        if z[k] == S[l]:
            z[k] = 0
        else:
            a = 1
        
if x[0] == y[0] == z[0] == 0 or  x[1] == y[1] == z[1] == 0 or  x[2] == y[2] == z[2] == 0 or x[0] == x[1] == x[2] == 0 or y[0] == y[1] == y[2] == 0 or z[0] == z[1] == z[2] == 0 or x[0] == y[1] == z[2] == 0 or z[0] == y[1] == x[2] == 0:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb,lc,lx;
  double da,db,dc;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> s;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
a = s.size();
  
  rep(i,0,a/2){
    if(s[i] != s[a-i-1]) ans++;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#B
c_min=1001
N,T=map(int,input().split())
for n in range(N):
    c,t=map(int,input().split())
    if t<=T:
        if c<=c_min:
            c_min=c
if c_min==1001:
    print("TLE")
else:
    print(c_min)


Measured memory_bytes: 2940
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
long long n,m,a,b,i,j,d[110][101010];
int main(){
  scanf("%lld %lld",&n,&m);
  for(i=0;i<110;i++){
    for(j=0;j<100010;j++)d[i][j]=1e18;
  }
  for(i=d[0][0]=0;i<n;i++){
    scanf("%lld %lld",&a,&b);
    for(j=0;j<100000;j++){
      d[i+1][j  ]=MIN(d[i+1][j  ],d[i][j]);
      if(d[i][j]+a<=m)d[i+1][j+b]=MIN(d[i+1][j+b],d[i][j]+a);
    }
  }
  for(i=j=0;i<100001;i++){
    if(d[n][i]<=m)j=i;
  }
  printf("%lld\n",j);
}


Measured memory_bytes: 86912
program bbb
implicit none

integer :: n, i, j, res
integer,allocatable,dimension(:) :: d

read*, n
allocate(d(n))
read*, d

res=0

do i=1,n
 do j=i+1,n
 res=res+d(i)*d(j)
 end do
end do

write(*,'(i0)') res

end program

Measured memory_bytes: 768
(let* ((n (read))
    (a (make-array n))
    (b (make-array n)))

    (dotimes (i n)
        (setf (aref a i) (read))
    )
    (loop for i below n do
        (setf (aref b (- (aref a i) 1)) i)
    )
    (loop for i below n do
        (format t "~D " (+ (aref b i) 1))
    )
)

Measured memory_bytes: 77092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=20;
const ll MAXLG=__lg(MAXN)+2;

ll n,a[MAXN][MAXN];
ll dp[1<<MAXN],sm[1<<MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        REP (j,n) {
            cin >> a[i][j];
        }
    }

    REP (s,1<<n) {
        ll sum = 0;
        REP (i,n) {
            REP(j,i) {
                if ((s&(1<<i)) && (s&(1<<j))) {
                    sum += a[i][j];
                }
            }
        }
        sm[s] = sum;
    }

    REP (s,1<<n) {
        vector<ll> pos;
        REP (i,n) {
            if (s & (1<<i)) {
                pos.eb(i);
            }
        }

        REP (ss,1<<SZ(pos)) {
            ll es = 0;
            REP (i,SZ(pos)) {
                if (ss & (1<<i)) {
                    es += 1 << pos[i];
                }
            }
            dp[s] = max(dp[s],dp[s - es] + sm[es]);
        }
    }

    cout << dp[(1<<n)-1] << endl;
    return 0;
}


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

int N;
const int MAX_N = 50;
int V[MAX_N];

int main()
{
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> V[i];
  }
  sort(V, V + N);
  double res = (V[0] + V[1]) / 2.;
  for (int i = 2; i < N; ++i)
  {
    res = (res + V[i]) / 2.;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
struct BIT {
    int N;
    vector<T> dat;

    // 0-indexing
    explicit BIT(int n): N(n), dat(N + 1, 0) {}

    T sum(int i) {
        T s = T();
        for(++i; i > 0; i -= i & -i) s += dat[i];
        return s;
    }

    void add(int i, const T& x) {
        for (++i; i <= N; i += i & -i) dat[i] += x;
    }

    // min_x {x | v1 + v2 + ⋯ + vx ≧ w}
    // Assuming v_q >= 0
    int lower_bound(T w) {
        if (w <= 0) return 0;

        int x = 0; T k = 1;
        while (k * 2 <= N) k <<= 1;
        for (; k > 0; k /= 2) {
            if (x + k <= N && dat[x + k] < w) {
                w -= dat[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, Q;
    cin >> N >> Q;

    vll c(N);
    for(auto &e: c) cin >> e;
    for(auto &e: c) --e;

    vector<vector<pair<int, int>>> query(N);
    REP(i, Q) {
        int l, r; cin >> l >> r;
        --l; --r;
        query[r].eb(l, i);
    }

    vector<int> last(N, -1);
    BIT<int> bit(N);
    vector<int> ans(Q);
    REP(i, N) {
        if (~last[c[i]]) bit.add(last[c[i]], -1);
        last[c[i]] = i;
        bit.add(i, 1);

        for(auto &p: query[i]) {
            ans[p.se] = bit.sum(i) - bit.sum(p.fi-1);
        }
    }

    for (auto &e: ans) {
        print(e);
    }

}


Measured memory_bytes: 35236