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

int main(){

int N;
cin >> N;
int l[1100], r[1100];
for (int i = 0; i < N; i++) {
  cin >> l[i] >> r[i];
}

int count = 0;
for(int i = 0; i < N; i++){
  count += ((r[i]- l[i]) + 1);
}

cout << count << endl;
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MOD=1e9+7;
int n;char str[5005];
long long dp[5005][5005];
int main()
{
	scanf("%d%s",&n,str);
	int len=strlen(str);
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if(n!=j)
				dp[j][i]+=2ll*dp[j+1][i-1];
			if(j)
				dp[j][i]+=dp[j-1][i-1];
			else
				dp[j][i]+=dp[j][i-1];
			dp[j][i]%=MOD;
		}
	printf("%lld\n",dp[len][n]);
	return 0;
}


Measured memory_bytes: 195712
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<map>

using namespace std;

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

typedef pair<long, long> pii;

const long max_n = 10e5;
const long max_i = 10e9;
long n;
char com;
map<long, long> f2i;
map<long, long> i2f;

deque<pii> empty;
vector<pii> used[max_n];

void writef(long f, long c, long idx){
    f2i[f] = idx;
    i2f[idx] = f;

    while(1){
        if(c==0) break;

        pii e = empty.front();
        empty.pop_front();
        if(e.second-e.first>c){
            used[f2i[f]].push_back(make_pair(e.first, e.first+c));
            empty.push_front(make_pair(e.first+c, e.second));
            c = 0;
        } else {
            c -= (e.second - e.first);
            used[f2i[f]].push_back(e);
        }
    }
}

void delf(long f){
    deque<pii> tmp;
    REP(i, used[f2i[f]].size()){
        pii u = used[f2i[f]][i];
        while(!empty.empty()){
            pii e = empty.front();
            empty.pop_front();
            if(u.second<=e.first){
                tmp.push_back(u);
                empty.push_front(e);
                break;
            } else {
                tmp.push_back(e);
            }
        }
    }

    while(!tmp.empty()){
        pii t = tmp.back();
        tmp.pop_back();
        empty.push_front(t);
    }
    used[f2i[f]].clear();
}

void readf(long s){
    REP(i, n){
        REP(j, used[i].size()){
            pii u = used[i][j];
            if(u.first<=s && s<u.second){
                cout << i2f[i] << endl;
                return;
            }
        }
    }
    cout << -1 << endl;
}

int main(){
    while(1){
        cin >> n;
        if(n==0) break;

        empty.clear();
        REP(i, max_n) used[i].clear();

        empty.push_back(make_pair(0, max_i));
        REP(i, n){
            cin >> com;

            if(com=='W'){
                long f, c; // file, count
                cin >> f >> c;
                writef(f, c, i);
            } else if(com=='D'){
                long f;
                cin >> f;
                delf(f);
            } else if(com=='R'){
                long s;
                cin >> s;
                readf(s);
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 65516
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
X = int(input())
MAX_X = 10**9
n = 0
while(1):
    n+=1
    if n**5 - (n-1)**5 > MAX_X:
        break
for i in range(n):
    for j in range(-n+1,n-1):
        if i**5 - j**5 == X:
            print (i,j)
            exit()
   

Measured memory_bytes: 9052
#include <stdio.h>

void sort(int *ar, int left, int right){
	int pivot = ar[(left+right)/2];
	int i = left,j = right;
	while(1){
	
		while(pivot < ar[i]){
			i++;
		}
		while(pivot > ar[j]){
			j--;
		}
		if(i >= j) break;
		int buf = ar[i];
		ar[i] = ar[j];
		ar[j] = buf;
		i++;j--;
	}
	if(left < i - 1)
		sort(ar, left, i-1);
	if(j + 1 <  right)
		sort(ar, j+1, right);
}
int main(void) {
    int x[5];
    int i;
    for(i = 0; 5 > i; i++){
    	scanf("%d", &x[i]);
    }
    sort(x, 0, 4);
	
    for(i = 0; 5 > i; i++){
    printf("%d", x[i]);
    if(i <= 3)	printf(" ");
    }
    	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;


class Main{

public static void main(String [] args){

Scanner sc = new Scanner(System.in);

for(int i = 1;;i++){
   int x = sc.nextInt();

   if(x != 0){
     System.out.println("Case " + i + ": " + x);
    }else{
    break;

    
}


}

    
     




}
}



Measured memory_bytes: 41668
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include <string>
#include<map> 
#include<deque>  
#include<vector>
#include<bitset>
#include<string>  
#include<cstring> 
#include<stack>  
#include<set>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
char ch[9],good;
int main()
{
	scanf("%s",ch);
	if(ch[2]==ch[1]&&(ch[0]==ch[1]||ch[1]==ch[3]))cout<<"Yes"<<endl;
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define pi acos(-1.0)
#define MAX 1000010
//////////////////////////////////////////////////////////////////////////
/* Custom function starts here */

/* Custom function ends here: */
//////////////////////////////////////////////////////////////////////////////

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

  /* MAIN Code STARTS here: */
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R'){
            while(s[i] == 'R'){
                cnt++;
                i++;
            }
            break;
        }
    }
    cout << cnt << endl;

  /* MAIN Code ENDS here: */

}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] x, y;

	static double solve() {
		double ret = 0;
		for (int i = 0; i < N; ++i) {
			ret += x[i] * y[i + 1] - x[i + 1] * y[i];
		}
		return Math.abs(ret) / 2;
	}

	public static void main(String[] args) {
		for (int t = 1;; ++t) {
			N = sc.nextInt();
			if (N == 0) break;
			x = new int[N + 1];
			y = new int[N + 1];
			for (int i = 0; i < N; ++i) {
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}
			x[N] = x[0];
			y[N] = y[0];
			System.out.printf("%d %.1f\n", t, solve());
		}
	}
}

Measured memory_bytes: 12000
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 D PIC ZZ9.999999.
        01 B PIC 9(10)V9(10).
        01 C PIC 9(15).
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT A.
      		MOVE A to B.
      		COMPUTE C = A / 2.
       		COMPUTE C = C * 2.
      		IF A = C THEN
      			MOVE 0.5 to B
      		ELSE
      			COMPUTE B = (B + 1.0) / (2.0 * B)
      		END-IF.
      		MOVE B to D.
			DISPLAY B.
		STOP RUN.

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<" : "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string week[]={"hoge","SAT","FRI","THU","WED","TUE","MON","SUN"};
	
	string s;
	cin>>s;
	
	REP(i,8){
		if(week[i]==s){
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100+19;

multiset<int> S;
Vi V;
int A[N];
int n,x,y,mx;

bool Work(int x,int y,int d){
	For(i,1,d){
		if (S.find(max(i,d-i))==S.end()) return 0;
		S.erase(S.find(max(i,d-i)));
	}
	for (int i:S){
		if (i<=(d+1)/2) return 0;
	}
	return 1;
}

int main(){
	n=IN();
	For(i,1,n+1){
		A[i]=IN();
		mx=max(mx,A[i]);
	}
	For(i,1,n+1){
		if (mx==A[i]) V.pb(i);
	}
	if (V.size()<2){
		puts("Impossible");
		return 0;
	}
	For(i,1,n+1){
		if (i!=V[0]&&i!=V[1]) S.insert(A[i]);
	}
	if (!Work(V[0],V[1],mx)){
		puts("Impossible");
		return 0;
	} else{
		puts("Possible");
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main()
{
    // cout<<(277/51.0)<<" "<<(296/54.0)<<endl;
    // cout<<(long double)9933233/99999.0<<" "<<(long double)9933333/100000.0<<endl;
    int t=1;
    // cin>>t;
    string s; cin>>s;
    if(s.back()=='s')
    {
        s+="es";
    }
    else s+="s";
    cout<<s;
}

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

int main(){

  while(1){ 

  int daikin;
  int sum = 0;
  int yj[9];
  
  cin >> daikin;
  if (daikin == 0){
    return 0;
  }

  for(int i = 0; i < 9; i++){
    cin >> yj[i];
  }
  
  for(int i = 0; i < 9; i++){
    sum += yj[i];
  }

  cout << daikin - sum << endl;
  }
  return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    int n;
    cin >> n;

    ll ar[n],cnt=0,tot=0;
    for (int i=0;i<n;i++){
        cin >> ar[i];
        if (ar[i]<0) cnt++;
        ar[i]=abs(ar[i]);
        tot+=ar[i];
    }

    sort(ar,ar+n);
    if (cnt&1) tot-=2*ar[0];

    cout << tot << el;

    return 0;
}

Measured memory_bytes: 1024
// Probably getting a WA/Tle
// Still trying
// Apna time ayega

#include<bits/stdc++.h>
#define ll long long int
#define FastRead ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    ll n,l,a,b,c,m,k,i,j,s,sum=0;
    cin>>n;
    set< ll >st;
    vector< ll >v(200005),u;
    for(i=0;i<n;i++){
        cin>>a;
        v[a]++;
        st.insert(a);
        u.push_back(a);
    }
    for(auto i:st){
        sum+=(v[i]*(v[i]-1))/2;
    }
    for(i=0;i<u.size();i++){
        sum-=(v[u[i]]*(v[u[i]]-1))/2;
        v[u[i]]--;
        sum+=(v[u[i]]*(v[u[i]]-1))/2;
        cout<<sum<<endl;
        sum-=(v[u[i]]*(v[u[i]]-1))/2;
        v[u[i]]++;
        sum+=(v[u[i]]*(v[u[i]]-1))/2;
    }

    return 0;
}


Measured memory_bytes: 11120
_,*A=*$<
101.times{|x|101.times{|y|a=A.map{i,j,k=_1.split.map &:to_i
[k,(i-x).abs+(j-y).abs]}
K,D=a.max
a.all?{_1==[K+D-_2,0].max}&&p(x,y,K+D)}}

Measured memory_bytes: 14408
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
#define mod 1000000007
using namespace std;
int main()
{
	cio;
	lli n,i,sum=0,sm2=0;
	cin>>n;
	lli a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		sum%=mod;
	}
	for(i=0;i<n;i++){
		sum=sum-a[i];
		if(sum<0)
		sum+=mod;
		sum%=mod;
		a[i]%=mod;
		sm2+=a[i]*sum;
		sm2%=mod;
	}
	cout<<sm2;
	return 0;
}

Measured memory_bytes: 5176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
class UnionFindTree
{
private:
   int N;
   int *rootnum;
   int *rank;
   int *unionnum;

public:
   UnionFindTree(int n)
   {
      /*0からn-1までの要素をunionとしてもつ*/
      N = n;
      rootnum = new int[N];
      rank = new int[N];
      unionnum = new int[N];
      for (int i = 0; i < N; i++)
      {
         rootnum[i] = i;
         rank[i] = 0;
         unionnum[i] = 1;
      }
   }

   int Find(int j)
   {
      if (rootnum[j] == j)
      {
         return j;
      }
      else
      {
         return rootnum[j] = Find(rootnum[j]);
      }
   }

   void Union(int i, int j)
   {
      int x = Find(i);
      int y = Find(j);
      if (x == y)
         return;
      N--;
      if (rank[x] < rank[y])
      {
         rootnum[y] = x;
         unionnum[x] += unionnum[y];
      }
      else
      {
         rootnum[x] = y;
         unionnum[y] += unionnum[x];
         if (rank[x] == rank[y])
            rank[x]++;
      }
   }

   int Num(int j)
   {
      /*与えられた要素の入っている集合の要素数を答える*/
      int x = Find(j);
      return unionnum[x];
   }

   int UnionNum()
   {
      /*集合の数を答える*/
      return N;
   }

   ~UnionFindTree()
   {
      delete rootnum;
      delete rank;
      delete unionnum;
   }
};

int main()
{
   int N;
   cin >> N;
   vector<pair<pair<int, int>, int>> point(N);
   for (int i = 0; i < N; i++)
   {
      cin >> point[i].first.first >> point[i].first.second;
      point[i].second = i;
   }
   sort(point.begin(), point.end());
   UnionFindTree uft(N);
   set<pair<int, int>> ys;
   for (int i = 0; i < N; i++)
   {
      int x = point[i].first.first;
      int y = point[i].first.second;
      int id = point[i].second;
      for (auto it = ys.begin(); it != ys.lower_bound(make_pair(y, id));)
      {
         uft.Union((*it).second, id);
         if (it == ys.begin())
            it++;
         else
            it = ys.erase(it);
      }
      ys.insert(make_pair(y, id));
   }
   for (int i = 0; i < N; i++)
   {
      cout << uft.Num(i) << endl;
   }
   return 0;
}


Measured memory_bytes: 12176
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

const int mod = 1'000'000'007;

ll Factorial(int n){
  if (n == 1){
    return 1;
  }
  ll sum = 1;
  sum = n * Factorial(n-1);
  return sum % mod;
}

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

  if (abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }

  ll ans = Factorial(n) * Factorial(m) % mod;
  if (n == m){
    ans = ans * 2 % mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> a(m);
    rep(i,0,m) cin>>a[i];
    int l=0,r=0;
    rep(i,0,m){
        if(a[i]<x) l++;
        else r++;
    }
    cout<<min(l,r)<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<ll> A(N);
    rep(i,N) cin>>A[i];

    ll M=0;

    for(int i=0;i<N-1;++i){
      for(int j=i+1;j<N;++j){
        M=max(abs(A[i]-A[j]),M);
      }
    }

  cout<<M<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=2e6+5;
/*
ll f(ll x, ll n){
    ll r=1;
    while(n>0){
        if(n&1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;
}

ll fact[N],ifact[N];
void build(){
    fact[0]=1;
    fact[1]=1;
    for(ll i=2;i<N;i++)
    fact[i]=(fact[i-1]*i)%mod;
    fr(i,0,N)
    ifact[i]=f(fact[i],mod-2);
}
ll C(ll n, ll r){
    if(r==0)
    return 1;
    ll ans=fact[n];
    ans=(ans*ifact[r])%mod;
    ans=(ans*ifact[n-r])%mod;
    return ans;
}
vector<vector<ll> > matmul(vector<vector<ll> > v1,vector<vector<ll> > v2){
    vector<vector<ll> > v(6,vector<ll>(6,0));
    fr(i,0,6){
        fr(j,0,6){
            fr(k,0,6)
            v[i][j]=(v[i][j]+ v1[i][k]*v2[k][j])%mod;
        }
    }
    return v;
}
vector<vector<ll> > matf(ll n){
    vector<vector<ll> >z={
    {1,1,1,1,1,1},
    {1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0}},
    r={{1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0},
    {0,0,0,0,0,1}};

    while(n>0){
        if(n&1){
            r=matmul(r,z);
        }
        z=matmul(z,z);
        n/=2LL;
    }
    return r;
}*/
void solve(){
    int n,k;
    cin>>n>>k;
    int a[n];
    fr(i,0,n)
    cin>>a[i];
    sort(a,a+n);
    int sum=0;
    fr(i,0,k)
    sum+=a[i];
    cout<<sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 3668
import numpy as np

h,w,k = map(int,input().split())
hw=[]
hwwk=[]
for i in range(h):
    hwwk.append(input())
    hw.append([1 if hwwk[i][j]=='#' else 0 for j in range(w)])
ahw=np.array(hw)
an=0
wk=np.zeros((h,w),int)
wwwk=0
for i in range(1,2**h):
    for j in range(h):
        bit=i>>j&1
#        print(bit)
        if bit!=0:
            wk[j]=ahw[j]
    #try:
     #   wwk=np.sum(wk,axis=1)
    #except:
     #   wwk=wk
    wwk=np.sum(wk,axis=0)
#    print(wk,wwk)
    for kk in range(1,2**w):
        for l in range(w):
            wbit=kk>>l&1
            if wbit!=0:
                wwwk+=wwk[l]
        if wwwk==k:
            an+=1
        wwwk=0
    wk=np.zeros((h,w),int)

print(an)

Measured memory_bytes: 27224
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
ll ini=1000;
 ll maisuu=0;
int n;cin>>n;
vi a(n+5);
//int n=80;
//vi a(80,200);
//rep(i,20)a.at(i)=110;
//int flag=0;
rep(i,n)cin>>a.at(i);
for(int i=0;i<=n-1;i++){
    if(maisuu==0){
        
    if(a.at(i)>=a.at(i+1)){
       continue;
    }else{
        maisuu=ini/a.at(i);
        ini=ini%a.at(i);

    }
    }
    if(maisuu!=0){
        
        if(a.at(i)>a.at(i+1)){
        ini=ini+a.at(i)*maisuu;
        maisuu=0;
    }else{
        continue;

    }
    }
    //if(flag)break;
}
cout<<ini<<endl;
return 0;
 }




Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    ll arr[n];
    ll dp[n];
    for(ll i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1]- arr[0]);
    for(ll i=2; i<n; i++)
    {
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] +abs(arr[i] - arr[i-2]) );
    }
    cout<< dp[n-1];
}

Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

    vector<ll> a(n, 0);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    
    int right = a[n-1];
    int left = 0;
    int target = (right + 1) / 2;

    auto index = lower_bound(a.begin(), a.end(), target);
    if(*index - target >= target - *(index-1)) left = *(index-1);
    else left = *index;

    cout << right << " " << left << endl;
}

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

int main(void){
	
	int N,sum=1,check;
	
	cin>>N;
	
	int H[N];
	
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	
	for(int i=1;i<N;i++){
		check=0;
		for(int j=0;j<i;j++){
			if(H[i]<H[j])
				check=1;
		}
		if(check==0)
			sum++;
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, k, s;
    cin >> n >> k >> s;
    forn(i, k) cout << s << " ";
    if (s != 1e9)
        forn(i, n - k) cout << 1000000000 << " ";
    else
        forn(i, n - k) cout << 999999999 << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll  MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;//最下位ビットが立っているときにx^(2^i)をかける
        x = x * x % mod; //xを順次二乗していく
        n >>= 1;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans = 1;
    ll ma = 0;
    vector<ll> d(N);
    REP(i,N){
        ll x;
        cin >> x;
        if(i == 0){
            if(x != 0){
                cout << 0 << endl;
                return 0;
            }
        }
        d[x]++;
        chmax(ma, x);
    }
    if(d[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1;i<=ma;i++){
        ans *= mod_pow(d[i-1], d[i], MOD);
        ans %= MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;


#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> a, b;
	int x = 0, y = 0;
	
	cin>>N;
	
	
	
	if(N%2 == 0) {
		x = N/2 - 1;
		y = N/2;
	} else {
		x = N/2;
		y = N/2;
	}
	
	for(int i = 0; i < N; i++){
		int A, B;
		
		cin>>A>>B;
		
		a.push_back(A);
		b.push_back(B);
	}
	
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	
	if(N%2)cout<<b[y] - a[x] + 1<<endl;
	else {
		cout<<(b[x] + b[y]) - (a[x] + a[y]) + 1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> a(N), b(N), c(N);
    for(int i=0; i<N; i++) cin >> a[i];
    for(int i=0; i<N; i++) cin >> b[i];
    for(int i=0; i<N; i++) cin >> c[i];

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll ans = 0LL;
    for(int i=0; i<N; i++){
        auto itr1 = lower_bound(a.begin(), a.end(), b[i]);
        auto itr2 = upper_bound(c.begin(), c.end(), b[i]);

        ll up = itr1 - a.begin();
        ll down = c.end() - itr2;
        ans += up*down;
    }

    cout << ans << endl;
}

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

int main() {
  int n, S = 0, min = 10e8;
  cin >> n;
  vector<int> v(n);
  for(int i = 0;i < n;i++) {
    cin >> v[i];
  }
  for(int i = 1;i < 101;i++) {
    S = 0;
    for(int j = 0;j < n;j++) {
      S += (v[j] - i) * (v[j] - i);
    }
    if(S < min) min = S;
  }
  cout << min << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // B - Cakes and Donuts

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String ans = "No";
        loop:
        for (int i = 0; i <= n / 4; i++) {
            for (int j = 0; j <= n / 7; j++) {
                if (i * 4 + j * 7 == n) {
                    ans = "Yes";
                    break loop;
                }
            }
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 23124
n=int(input())
a=[input() for s in range(n)]
m=int(input())
b=[input() for t in range(m)]
aa=list(set(a))
bb=list(set(b))
aa.extend(bb)
category=list(set(aa))
c=[0]*len(category)
for i in a:
   for j in category:
       if i==j:
           c[category.index(j)]+=1
for i in b:
   for j in category:
       if i==j:
           c[category.index(i)]-=1
          
if max(c)<0:
    c.append(0)
print(max(c))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int main() {
	string s; cin>>s; int n=s.size(),tmp1=0,tmp2=0;
	for( int i=0;i<n;i++ ) {
		if(i&1) {
			if(s[i]=='0') tmp1++;
			else tmp2++;
		}else {
			if(s[i]=='1') tmp1++;
			else tmp2++;
		}
	}cout<<min(tmp1,tmp2);
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=sum(b)
for i in range(1,N,1):
    if (a[i]==a[i-1]+1):
        ans+=c[a[i-1]-1]

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();

    sc.close();

    int[] x = new int[11];
    
    x[0] = X; 

    for (int i = 1; i < 11; i++) {
      x[i] = r * x[i-1] - D;
      System.out.println(x[i]);
    }

  }

}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int p[n + 1], s[n + 1];
    s[n] = 0;
    p[0] = 0;
    for (int i = n - 1; i >= 0; i--) {
        s[i] = __gcd(s[i + 1], a[i]);
    }
    for (int i = 1; i <= n; i++) {
        p[i] = __gcd(p[i - 1], a[i - 1]);
    }
    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = max(ans, __gcd(p[i], s[i + 1]));
    }
    cout << ans << "\n";
}


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

vector<pair<ll, ll> > v;

int main() {
    ll n, x, y;
    cin >> n;

    for(int i = 0; i < n; ++i) {
        cin >> x >> y;
        v.push_back({y, x});
    }

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

    ll t = 0;
    for(int i = 0; i < n; ++i) {
        t += v[i].second;
        //cout << t << " -> " << v[i].first << ", " << v[i].second << endl;
        if(t > v[i].first) {
            cout << "No\n";
            return 0;
        }
    }

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

Measured memory_bytes: 6384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  int n, m;
  ll k;
  cin >> n >> m >> k;
  vector<ll> as(n), bs(m);
  rep(i, n){
	  cin >> as[i];
  }
  ll t = 0;
  rep(i, m){
	  cin >> bs[i];
	  t += bs[i];
  }
  int l = m;
  int ans = 0;
  rep(i,n+1){
	  while(1){
		  if(k >= t || l==0) break;
		  else{
			  l--;
			  t-=bs[l];
		  }
	  }
	  //cout << l <<endl;
	  if(t > k) break;
	  ans = max(ans,i+l);
	  if(i == n) break;
	  t+=as[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6360
#include <stdio.h>
#include <math.h>
int main()
{
    int a,b,c,d,m=0,n=0,i,j;
    scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
    for(i=0;i<=a;i++)
    {
    n=i*500;
    if(n<d)
        for(j=0;n<=d&&j<=b;j++)
        {
            n=j*100+i*500;
            if((d-n)%50==0&&(d-n)/50<=c&&n<=d)
                m++;
        }
           else
            if((d-n)%50==0&&(d-n)/50<=c&&n<=d)
                m++;
    }
    printf("%d",m);
    return 0;
}


Measured memory_bytes: 128
n = int(input())


s_count ={}

for i in range(n):
    s = input()
    
    if(s in s_count):
        s_count[s] += 1
    else:
        s_count[s] = 1


max_val = max(s_count.values())
max_s_list = [key for key in s_count if s_count[key] == max_val]
result = sorted(max_s_list)

for k in result:
    print(k)

Measured memory_bytes: 32988
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main(){
int w,h,n;
cin >>w>>h>>n;
int x[110],y[110],a[110];
for(int i=0;i<n;i++)
cin >>x[i]>>y[i]>>a[i];

int maxx=0,maxy=0;
int minx=w,miny=h;

for(int i=0; i <n ; i++){
  if(a[i]==1&& x[i]>maxx) maxx=x[i];
  else if(a[i]==2 && x[i]<minx) minx=x[i];
  else if(a[i]==3 && y[i]>maxy) maxy=y[i];
  else if(a[i]==4 && y[i]<miny) miny=y[i];
}
if(minx-maxx<=0 || miny-maxy<=0) cout <<0<<endl;
else cout << (minx-maxx)*(miny-maxy) << '\n';

}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
  int a, b, c, count = 0;
  scanf("%d %d %d", &a, &b, &c);
  for(int i=a; i<=b; i++) {
    if(c%i == 0) count++;
  }
  printf("%d\n", count);
  
  return 0;
}



Measured memory_bytes: 2752
R, G, B, N = map(int, input().split())

lst = [R, G, B]
lst.sort()
k2, k1, k0 = lst

ans = 0
if lst != [1, 1, 1]:
    for n0 in range(N//k0 + 1):
        for n1 in range(N//k1 + 1):
            nn = (N - n0 * k0 - n1 * k1)
            if nn >= 0 and nn % k2 == 0: ans += 1
    print(ans)
else:
    for n0 in range(N+1):
        for n1 in range(n0, N+1):
            if n0 + n1 > N:continue
            if n0 == n1: ans += 1
            else: ans += 2
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string ROTATE(string S){
  char b = S.at(S.size()-1);
  S.pop_back();
  S = b + S;
  return S;
}

int main()
{
  string S, T;
  cin >> S >> T;

  int flag = 0;
  REP(i,S.size()){
    if(S == T){
      flag = 1;
    }
    S = ROTATE(S);
  }

  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math
def calcAngle(h,m):
    if (h < 0 or m < 0 or h > 12 or m > 60): 
            print('Wrong input') 
          
    if (h == 12): 
        h = 0
    if (m == 60): 
        m = 0
    hour_angle = 0.5 * (h * 60 + m) 
    minute_angle = 6 * m
    angle = abs(hour_angle - minute_angle) 
    angle = min(360 - angle, angle) 
    return angle 
a,b,h,m=map(int,input().split())
angle=math.cos(math.radians(calcAngle(h,m)))
length=math.sqrt(a**2+b**2-2*a*b*angle)
print(length)

Measured memory_bytes: 9528
n = int(input())
ans = 10**6
for i in range(0, n+1):
  cnt = 0
  
  a = i
  b = n - i
  p = 0
  # aは6のn乗何個で表すことができるか。a+b=n
  while a > 0:
    p += a % 6 # 6**Xをaから何個引くことができるか
    a = a // 6
    
  q = 0
  while b > 0:
    q += b % 9
    b = b // 9
    
  ans = min(ans, p+q)
  
  
print(ans)


Measured memory_bytes: 3060
/*
    Just Another Source code by - shahincsejnu
*/
#include                        <bits/stdc++.h>
#define   ulli                  unsigned long long int
#define   lli                   long long int
#define   MOD                   1000000007
#define   PI                    acos(-1.0)
#define   UNIQUE(V)             (V).erase(unique(ALL(V), (V).end()) //vector/string etc must need to be sorted
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define   ALL(V)                (V).begin(), (V).end()
#define   MEM(a, val)           memset(a, val, sizeof(a))
#define   SORT(v)               sort(v.begin(),v.end())
#define   REV(v)                reverse(v.begin(),v.end())
using     namespace             std;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //timesave; 
    
    int n, l;

    cin >> n >> l;

    vector<string> v;
    string s;

    for(int i = 1; i <= n; i++){
        cin >> s;
        v.push_back(s);
    }

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

    for(int i = 0; i < n; i++) cout << v[i];
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, m; readV(n, m);

  auto c = new int[](n+1);
  foreach (_; 0..m) {
    int a, b; readV(a, b);
    if (a == 1) c[b]++;
    if (b == n) c[a]++;
  }

  writeln(c.canFind(2) ? "POSSIBLE" : "IMPOSSIBLE");
}


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

class Dice{
public:
	Dice(){
		number = new int[6];
		work = new int[6];
	};
	~Dice(){
		delete[] number;
		delete[] work;
	};

	void setLabel(int index,int num){
		number[index] = num;
	};

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	int returnPeek(){
		return number[0];
	}
	int returnfront(){
		return number[1];
	}
	int returnright(){
		return number[2];
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* work;
};

int main(){
	Dice dice;
	int label;
	char ch;
	for(int i = 0; i < 6; i++){
		scanf("%d",&label);
		dice.setLabel(i,label);
	}
	int n;
    cin >> n;
    int a,b;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        int j=0;
        while(dice.returnfront()!=b){dice.roll('N');j++;if(j==4){
            dice.roll('E');
        }}
        while(dice.returnPeek()!=a)dice.roll('E');
        cout << dice.returnright() << endl;
    }
}


Measured memory_bytes: 3152
N = int(input())
N_List = list(map(int,input().split()))
ct = 0
for i in range(1,N):
    if N_List[i] < N_List[i-1]:
        ct += N_List[i-1] - N_List[i]
        N_List[i] = N_List[i-1]
    

print(ct)

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

int		not_double(char *str, int n)
{
	int i = 0;
	while (i < n)
	{
		if (str[i] == str[n])
			return (0);
		i++;
	}
	return (1);
}

int main()
{
	char str[101];
	scanf("%s", str);
	if (strlen(str) % 2)
	{
		printf("No\n");
		return (0);
	}
	int i = 0;
	int j;
	int count;
	while (str[i])
	{
		if (not_double(str, i))
		{
			count = 0;
			j = i;
			while (str[j])
			{
				if(str[i] == str[j])
					count++;
				j++;
			}
			if (count % 2)
			{
				printf("No\n");
				return (0);
			}
		}
		i++;
	}
	printf("Yes\n");
	return (0);
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        String N;

        while((N = num.next()).charAt(0) != '0'){
            int sum = 0;
            for(int i = 0; i < N.length(); i++) {
                sum += (int)N.charAt(i) - 48;
            }
            System.out.println(sum);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

typedef set<int> si;
typedef set<ii> sii;
typedef set<ld> sd;
typedef set<ll> sl;

typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef queue<int> qi;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second

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

const ll MOD = 1e9 + 7;

ll addmod(ll a, ll b) {
    return (a % MOD + b % MOD) % MOD;
}
ll mulmod(ll a, ll b) {
    ll res = 0;
    a %= MOD;
    b %= MOD;
    if (b > a) swap(a, b);
    while (b > 0) {
        if (b % 2) res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
  	int n; string s;
    cin >> n >> s;

    // get count for each char
    vl ct(26);
    for (auto c : s) {
        ct[c - 'a']++;
    }

    vl ans(26);
    for (char i = 'a'; i <= 'z'; i++) {
        for (char j = 'a'; j < i; j++) {
            ans[i - 'a'] = addmod(ans[i - 'a'], mulmod(ct[i - 'a'], ans[j - 'a']));
        }
        ans[i - 'a'] = addmod(ans[i - 'a'], ct[i - 'a']);
    }

    ll anss = 0;
    for (auto &x : ans) anss = addmod(anss, x);
    cout << anss << endl;
}

/*
USE LONG LONG!!!!

:pray: :fishy15:
:pray: :summitosity:
:pray: :prodakcin:

          .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)    
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o
*/

Measured memory_bytes: 512
def main():
    o = list(input())
    e = list(input())

    ans = ''
    if len(o) == len(e):
        for i in range(len(o)):
            ans += o[i]+e[i]
    else:
        for i in range(len(o)-1):
            ans += o[i]+e[i]
        ans += o[-1]
    print(ans)


if __name__ == "__main__":
    main()


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    ll M = 1e18;
    ll res = 1;
    //cout << M << endl;
    REP(i, N){
        if(A[i]==0){
            cout << 0 << endl;
            return 0;
        }
        res *= A[i];
        M /= A[i];
    }    
    if(M<=0) cout << -1 << endl;
    else cout << res << endl;

    return 0;
}

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

string s;
vector<string> vs; 
bool f[26];

void dfs(string t, int now){
    if(now == s.size()){
        string r = t;
        memset(f, false, sizeof(f));
        rep(i, 0, r.size()){
            if(f[r[i] - 'a'] == false && r[i] != 'a'){
                r[i] = r[i] - 1;
            }
            f[t[i] - 'a'] |= true;
        }
        if(r == s) vs.push_back(t);
        return;
    }
    int d[26] = {};
    rep(i, 0, now) d[t[i] - 'a']++;
    if(t[now] != 'z' && d[t[now] + 1 - 'a'] == 0){
        string tmp = t;
        tmp[now] = tmp[now] + 1;
        dfs(tmp, now + 1);
    }
    if(t[now] == 'a' || d[t[now] - 'a'] != 0) dfs(t, now + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (1) {
        cin >> s;
        if(s == "#") break;
        vs.clear();
        dfs(s, 0);
        int ans = vs.size();
        sort(vs.begin(), vs.end());
        cout << ans << endl;
        if(ans <= 10){
            rep(i, 0, ans){
                cout << vs[i] << endl;
            }
        }else{
            rep(i, 0, 5){
                cout << vs[i] << endl;
            }
            rep(i, ans - 5, ans){
                cout << vs[i] << endl;
            }
        }
    }
}


Measured memory_bytes: 4312
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  int n;
  string s;
  cin >> n >> s;

  for(int i = 0;i < s.size();i++){
    if(s[i] + n > 'Z') {
      s[i] = s[i] + n - 26;
    }
    else {
      s[i] = s[i] + n; 
    }
  }

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256