akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9	
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<long long int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

void solve() {
	int n;
	cin >> n;
	int w;
	cin >> w;

	VVI weight(n,VI(2));
	
	int64 sum = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 2; j++) {
			cin >> weight[i][j];
		}
			sum += weight[i][1];
			
	}

	VI dp(sum+1,INT_MAX);
	dp[0] = 0;

	for(int i = 0; i < n; i++) {
		for(int j = sum; j >= weight[i][1]; --j) {
			dp[j] = min(dp[j], weight[i][0] + dp[j-weight[i][1]]);			
		}
	}
	for(int i = sum; i >= 0; i--) {
		if(dp[i] <= w) {
			cout << i << " ";
			break;
		}
	}
}

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

	return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    string S;
    cin >> S;
    if(S.size() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    bool flag = 1;
    rep(i,S.size()/2){
        if(S.substr(i*2,2) != "hi") flag = 0;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

int main()
{
  int n ;
  cin >> n;
  string s;
  cin >> s;
  if(n%2 == 1)
    cout << "No";
  else
  {
    int flag = 0;
    int k = n/2;
  	for(int i = 0; i < n/2; ++i)
    {
      if(s[i] != s[k + i])
      {
        cout << "No";
        flag = 1;
      	break;
      }
    }
    if(!flag)
    cout << "Yes";
  }
}


Measured memory_bytes: 256
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
set<int> st;
vector<int> v;

int phi(int n) 
{ 
    float result = n; // Initialize result as n 
  
    // Consider all prime factors of n and for every prime 
    // factor p, multiply result with (1 - 1/p) 
    for (int p = 2; p * p <= n; ++p) { 
          
        // Check if p is a prime factor. 
        if (n % p == 0) { 
              
            // If yes, then update n and result 
            while (n % p == 0) 
                n /= p; 
            result *= (1.0 - (1.0 / (float)p)); 
        } 
    } 
  
    // If n has a prime factor greater than sqrt(n) 
    // (There can be at-most one such prime factor) 
    if (n > 1) 
        result *= (1.0 - (1.0 / (float)n)); 
  
    return (int)result; 
} 

main(void){
	scanf("%lld",&n);
	int at=phi(n);
	//~ cout<<at<<endl;
	int carp=7;
	for(int i=1;i<=max(n+5,at+5);i++){
		carp=carp%n;
		if(carp==0){printf("%lld\n",i);return 0;}
		carp=((carp%n)*(10%n))%n;
		carp=((carp%n)+(7%n))%n;
		carp=carp%n;
	}
	printf("-1\n");
	return 0;
}



Measured memory_bytes: 3820
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a:usize,
        b:usize
    }
    let strong = vec![2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1];
    if a == b {
        println!("Draw");
    } else {
        let mut a_index = 0;
        let mut b_index = 0;
        for i in 0..strong.len() {
            if a == strong[i] {
                a_index = i;
            }
            if b == strong[i] {
                b_index = i;
            }
        }
        if a_index > b_index {
            println!("Alice");
        } else {
            println!("Bob");
        }
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    long n,m,min,max,sum;
    scanf("%ld\n",&n);
    
    scanf("%ld",&m);
    sum=max=min=m;
    
    for(int i=1;i<n;i++){
        scanf("%ld",&m);
        sum+=m;

        if(min>m) min=m;
        if(max<m) max=m;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}
        


Measured memory_bytes: 2052
'use strict';
function main(input) {
  const args = input.split('\n'),
        N = parseInt(args[0]),
        H = args[1].split(' ');
  let cnt = 0;
  let tmp = 0;
  for (let i = 0; i < N-1; ++i) {
    if (parseInt(H[i]) >= parseInt(H[i+1])) {
      ++tmp;
      if (i === N-2 && tmp > cnt) {
        cnt = tmp;
      }
    } else {
      if (tmp > cnt) {
        cnt = tmp;
      }
      tmp = 0;
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 17804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);
    vector<int> a(m), b(m);
    rep(i, m)
    {
        cin >> a.at(i) >> b.at(i);
        a.at(i)--;
        b.at(i)--;
    }

    vector<set<int>> vs(n);
    rep(i, m)
    {
        vs.at(a.at(i)).insert(b.at(i));
        vs.at(b.at(i)).insert(a.at(i));
    }

    int answer = 0;
    rep(i, n)
    {
        bool is_good = true;
        set<int> connect_towers = vs.at(i);
        for (auto itr = connect_towers.begin(); itr != connect_towers.end(); itr++)
        {
            if (h.at(i) <= h.at(*itr))
            {
                is_good = false;
                break;
            }
        }
        if (is_good)
            answer++;
    }

    cout << answer << endl;
}

Measured memory_bytes: 18836
unittest
{
	assert( [ "2 1 1 0 0 0 0" ].solve == 3 );
	assert( [ "0 0 10 0 0 0 0" ].solve == 0 );
	
	assert( [ "3 0 0 1 1 0 0" ].solve == 5 );		// 追加ケース
	assert( [ "4 0 0 1 1 0 0" ].solve == 5 );		// 追加ケース
	assert( [ "3 0 0 2 2 0 0" ].solve == 6 );		// 追加ケース
	assert( [ "1 1 1 1 0 1 1" ].solve == 1 );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto as = input.front.split.to!( long[] );
	
	auto ans = 0L;
	
	// 棒と逆LとL1個ずつで2x6を作る
	if( 0 < as[ 0 ] && 0 < as[ 3 ] && 0 < as[ 4 ] && 1 < as[ 0 ] % 2 + as[ 3 ] % 2 + as[ 4 ] % 2 )
	{
		ans += 3;
		as[ 0 ]--;
		as[ 3 ]--;
		as[ 4 ]--;
	}
	
	// 縦棒2個で 2x4 を作る
	ans += as[ 0 ] / 2 * 2;
	
	// 四角1個で 2x2 を作る
	ans += as[ 1 ];
	
	// 逆L2個で 2x4 を作る
	ans += as[ 3 ] / 2 * 2;
	
	// L2個で 2x4 を作る
	ans += as[ 4 ] / 2 * 2;
	
	return ans;
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	for(ll i = 0;i < n;i++){
	    cin >> a[i];
	}
	ll dp[n][n],cost[n][n];
	for(ll i = 0;i < n;i++){
		for(ll j = 0;j < n;j++){
			cost[i][j] = 1e18;
		}
	}
	for(ll i = 0;i < n;i++){
	    dp[i][i] = a[i];
	    cost[i][i] = 0;
	}
	for(ll i = 2;i <= n;i++){
	    for(ll j = 0;j <= n - i;j++){
	    	for(ll k = j;k < j + i - 1;k++){
	    		if(cost[j][k] + dp[j][k] + dp[k+1][j + i - 1] + cost[k + 1][j + i - 1] < cost[j][j + i - 1]){
	    			cost[j][j + i - 1] = cost[j][k] + dp[j][k] + dp[k+1][j + i - 1] + cost[k + 1][j + i - 1];
	    			dp[j][j + i - 1] = dp[j][k] + dp[k + 1][j + i - 1];
	    		}
	    	}
	    	//cout << cost[j][j + i - 1] << " " << j << " " << j + i - 1 << endl;
 	    }
	}
	cout << cost[0][n - 1];
 	return 0;
}

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

int main(){

	string s, c = "01"; 
	pair<int,int> cont = {0,0};
	cin >> s;
	
	for(auto i : s){

		if (i==c[0]){
			if (cont.second) cont.second --;
			else cont.first++;
		}
		else{
			if (cont.first) cont.first --;
			else cont.second++;
		}
	}
	printf("%lu\n", s.size() - (cont.first + cont.second));
	return 0;
}


Measured memory_bytes: 3724
#include <stdio.h>
int main() {
	int p, n;
	int price = 0, num = 0, i = 0;

	while(scanf(" %d,%d ", &p, &n) != EOF) {
		price += p * n;
		num += n;
		i++;
	}
	printf("%d\n%d\n", price, (int)((double)num / (double)i + 0.5));
	return 0;
}

Measured memory_bytes: 596
n,y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1):
        c = n - a - b
        if 10000*a + 5000*b + 1000*c == y and 0 <= c <= n :
            print(a, b, c)
            exit()
print("-1 -1 -1")

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

int main() {
  map<string, int> m;
  int N, ans = 0;
  string s;
  
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> s;
    if(!(m[s])){
      m[s]++;
      ans++;
    }
  }
       
  cout << ans << endl;          
  
  return 0;
}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ep emplace_back
ll mod = 1e9 + 7;
ll big(ll b, ll p){
	if (p == 0) return 1;
	ll h = big(b, p / 2);
	ll r = h * h % mod;
	if (p % 2 == 1) r = r * b % mod;
	return r;
}
int main(){
	ll f[2001];
	f[0] = 1;
	for (ll i = 1; i <= 2000; i++) f[i] = f[i - 1] * i % mod;
	ll s, ans = 0;
	scanf("%lld", &s);
	for (ll i = 1; i * 3 <= s; i++){
		(ans += f[s - i * 2 - 1] * big(f[s - i * 3], mod - 2) % mod * big(f[i - 1], mod - 2) % mod) %= mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
ll modInverse(ll a, ll m)
{
    ll g = gcd(a, m);
    return(power(a,m-2,m));
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/
bool isprime(ll x)
{
    if(x==1)
        return(false);
    for(ll i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return(false);
    }
    return(true);
}
void solve()
{
    string s;
    cin>>s;
    if(s[1]=='R')
        cout<<"ABC"<<endl;
    else
        cout<<"ARC"<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.readline
import math

def INT(): return int(input())
def MAPINT(): return map(int, input().split())
def LMAPINT(): return list(map(int, input().split()))
def STR(): return input()
def MAPSTR(): return map(str, input().split())
def LMAPSTR(): return list(map(str, input().split()))

f_inf = float('inf')

x = LMAPINT()
for i, y in enumerate(x):
  if y == 0:
    print(i+1)
    exit()

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

const int N = 50;

main() {
  ll K; cin >> K;
  ll a[N];
  for (int i = 0; i < N; i++) {
    a[i] = i;
  }
  ll q = K / N;
  int r = K % N;
  for (int i = 0; i < N; i++) a[i] += q;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < N; j++) {
      if (j == i) {
        a[j] += N;
      } else {
        a[j]--;
      }
    }
  }
  cout << N << endl;
  for (int i = 0; i < N; i++) cout << a[i] << ( (i == N - 1) ? '\n' : ' ' );
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BOneClue {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int K, X;
	    in >> K >> X;
	    REP(i,X-K+1,X+K) {
	        out << i;
	        if (i!=X+K-1) out << " ";
	    }
	    out << "\n";
	}
};


int main() {
	BOneClue solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
Uses math;
var
	n,i,z,w,a,b,t:Longint;
	s:String;
begin
	readln(n,z,w);
	if n=1 then begin
		read(b);
		writeln(abs(b-w));
		exit;
	end;
	readln(s);
	i:=length(s);
	while s[i]>' ' do dec(i);
	for z:=i+1 to length(s) do b:=b*10+ord(s[z])-48;
	dec(i);
	t:=i;
	while(i>0)and(s[i]>' ')do dec(i);
	for z:=i+1 to t do a:=a*10+ord(s[z])-48;
	writeln(Max(abs(b-w),abs(a-b)));
end.


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	rep(i, 0, H) {
		rep(i2, 0, W){
			printf("%d", (i < B) ^ (i2 < A));
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1280
from collections import deque
s = list(input())
d = deque(s)
q = int(input())
flag = True
for i in range(q):
  l = list(map(str,input().split()))
  if l[0] == '1':
    if flag:
      flag = False
    else:
      flag = True
  else:
    if l[1] == '1':
      if flag:
        d.appendleft(l[2])
      else:
        d.append(l[2])
    else:
      if flag:
        d.append(l[2])
      else:
        d.appendleft(l[2])
if flag:
  ll = list(d)
  print(''.join(ll))
else:
  d.reverse()
  ll = list(d)
  print(''.join(ll))
  

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	cin >> N;
	vector<int64> a(N);
	vector<PLL> b;
	REP(i, N) cin >> a[i];
	sort(all(a));
	if(a[0]*2 > a[N-1]+a[N-1]%2){
		cout << "Impossible" << endl;
		return 0;
	}
	REP(i, a.size()){
		if(b.empty() || b.back().fs != a[i]) b.push_back({a[i], 1});
		else b.back().sc++;
	}
	int64 mini = INF;
	FOR(i, 1, b.size()) mini = min(mini, b[i].sc);
	if(b[0].sc != b[b.size()-1].fs%2+1 || mini == 1 || b[b.size()-1].fs-b[0].fs+1 != b.size()){
		cout << "Impossible" << endl;
		return 0;
	}

	cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD = 998244353;
const int MOD1 = 1e9 + 7;
const int N = 52;
const int nul = 0;
const int SIZE = 1e6 * 3;

map<int, int> ind;

signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    auto aa = a;
    sort(all(aa));
    for (int i = 0; i < n; i++) ind[aa[i]] = i;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 != ind[a[i]] % 2) cnt++;
    }
    assert(cnt % 2 == 0);
    cout << cnt / 2 << endl;

}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    ll res=0;
    rep(i, n){
        ll x;   cin >> x;
        if((i+1)%2 && x%2) res += 1;
    }
    cout << res << endl;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
  int n;
  string s;
  cin>>n>>s;
  string a = s.substr(0,n/2);
  string b = s.substr(n/2,n/2);
  if(n%2 == 0 && a == b)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3576
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MODU 1000000007
// ll modpow (ll a, ll b, ll m){
//   if(b==0) return 1;
//   else{
//     ll z = modpow(a, b/2, m);
//     z = (z*z)%m;
//     if(b%2==0) return z;
//     else return (z*a)%m;
//   }
// }
// ll gcd(ll a, ll b){
//   if(b==0) return a;
//   else return gcd(b, a%b);
// }

int i, j;
int main(){
  ll x, a, b;
  cin >> x >> a >> b;
  ll temp(0), temp2(0);
  temp = x-a;
  temp2 = temp/b;
  cout << temp - temp2*b << endl;
  return 0;
}
// notes
//


Measured memory_bytes: 256
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

from math import atan2, pi

def ccw(p1, p2, p3):
    val = (p2[1] - p1[1]) * (p3[0] - p2[0])
    val -= (p2[0] - p1[0]) * (p3[1] - p2[1])
    return val < 0

def solve(N, A):
    def getangle(i):
        x,y = A[i]
        return atan2(y,x)
    
    def massage(theta):
        if theta < 0:
            theta += 2 * pi
        return theta

    Abase = [(x, y, massage(atan2(y,x))) for x, y in A]
    Abase.sort(key=lambda z: z[2])
    A = Abase[:]
    for x, y, ang in Abase:
        A.append((x, y, ang + 2*pi))

    P = [(0,0)]
    sx=sy = 0
    for x, y, th in A:
        sx+=x;sy+=y
        P.append((sx,sy))

    ans = 0
    for i in xrange(N):
        for j in xrange(i, i+N):
            dx = P[j+1][0] - P[i][0]
            dy = P[j+1][1] - P[i][1]
            ans = max(ans, dx*dx+dy*dy)
    return ans**.5
    """
    def reflected(i):
        pt = A[i]
        return (-pt[0], -pt[1])

    def condition(i, j):
        # eg. A[j].angle < A[i].angle + pi
        return ccw(A[i], A[j], reflected(i))

    print A
    
    j = 0
    ans = 0
    for i in xrange(N):
        #while j+1 <= i+N-1 and A[j+1][2] < A[i][2] + pi:
        j = max(j, i)
        while j+1 <= i+N-1 and condition(i, j+1):
            j += 1
        print '!', i,j
        dx = P[j+1][0] - P[i][0]
        dy = P[j+1][1] - P[i][1]
        ans = max(ans, dx*dx+dy*dy)
    return ans**.5
    """

                
N=rri()
A=[rrm() for _ in xrange(N)]
print solve(N, A)


Measured memory_bytes: 30572
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long mini = 1e9+5;
    int n, k;
    cin >> n >> k ;
    long long a[100005];
    for ( int i=0; i< n; i++) cin >> a[i];
    sort (a, a+n);
    int d = k-1;
    for ( int i=0; i< n; i++){
        if ( i+ d < n){
            long long dif = a[i+d]-a[i];
            if ( dif < mini) mini = dif;
        }
    }
    cout << mini;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
bool isRight(int a, int b, int c)
{
    //?????§???c??????????????????????????´???
    if (a > c) {
        std::swap(a, c);
    }
    if (b > c){
        std::swap(b, c);
    }
    
    return a * a + b * b == c * c;
}

int main()
{
    int N;
    int a, b, c;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> a >> b >> c;
        if (isRight(a, b, c)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
}

Measured memory_bytes: 3088
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 3e3 + 5;
int n;
double p[maxn], dp[maxn][maxn];
int main() {
    IO;
    cin >> n;
    rep(i, 1, n) cin >> p[i];
    dp[0][0] = 1;
    rep(i, 1, n) rep(j, 0, i)
        if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]);
        else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 49300
#include<stdio.h>
using namespace std;
int main()
{
    int n,m,temp;
    scanf("%d%d",&n,&m);
    int** A=new int*[n];//这是？？，卧槽，指针忘了个七七八八
    for(int i=0;i<n;i++)
        A[i]=new int[m];//和第七行构成了一个二维数组
    int b[m];
    for(int i=0;i<n;i++)//读那个复杂点的数组
    {
        for(int j=0;j<m;j++)
        {
            scanf("%d",&temp);
            A[i][j]=temp;//这是怎么有前面的那个指针变成了一个类似于二维数组的鬼东西
        }
    }
    for(int i=0;i<m;i++)//读那个简单点的数组
    {
        scanf("%d",&temp);
        b[i]=temp;
    }
    long long int sum;
    for(int i=0;i<n;i++)
    {
        sum=0;
        for(int j=0;j<m;j++)
        {
            sum+=A[i][j]*b[j];
        }
        printf("%lld\n",sum);
    }
    for(int i=0;i<n;i++)
    {
        delete[] A[i];
    }
        delete A;

}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    lint k, x;
    cin >> k >> x;

    lint ans, tmp;

    k = k -1;
    FOR(i,x-k,x+k+1){
        if(i>=-1000000||i<=1000000){
            cout << i << "\n";
        }
    }

    return 0;
}

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

long long a[300],b[300],c[300];
int main()
{
    long long i, j=0, n=0, t, k,m, l=INT_MAX, INT=1e10, n1=0, n2=0, l1, k1;
    cin>>a[0]>>a[1]>>a[2]; sort(a,a+3);
    if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    vector<bool> baisu(10000001, true);
    unordered_map<int, int> hist;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        list[i] = tmp;
        hist[tmp]++;
    }

    for (auto x : hist)
    {
        int p = x.first, q = 2;
        if(baisu[p])
        {
            while (p * q <= 1000000)
            {
                baisu[p * q] = false;
                q++;
            }
        }
        
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp = list[i];
        if (hist[tmp] == 1 && baisu[tmp])
            ans++;
    }
    cout << ans;
}


Measured memory_bytes: 13256
N, K = gets.split.map(&:to_i)
as, bs = [], []
N.times do |i|
    as[i], bs[i] = gets.split.map(&:to_i)
end

cand = [K]
(0..30).each do |i|
    if K[i] == 1
        cand.push(((K>>i) << i) - 1)
    end
end

ans = 0
cand.each do |k|
    sum = 0
    N.times do |i|
        sum += bs[i] if k|as[i] == k 
    end
    ans = sum if ans < sum
end
puts ans

Measured memory_bytes: 3440
#include<bits/stdc++.h>
int a[200010];
int ans[200010];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=2;i<=n;i++) scanf("%d",&a[i]); 
  for(int i=2;i<=n;i++) ans[a[i]]++;
  for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
int t[1010],cnt;
int f[100010];
int main()
{
	int n;
	scanf("%d",&n);
	int now=6;
	while(now<=n) t[++cnt]=now,now*=6;
	now=9;
	while(now<=n) t[++cnt]=now,now*=9;
	t[++cnt]=1;
	for(int i=0;i<=n;i++) f[i]=0x3f3f3f3f;
	f[0]=0;
	sort(t+1,t+cnt+1);

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=cnt;j++) 
		{
			if(t[j]>i) break;
			f[i]=min(f[i],f[i-t[j]]+1);
		}
	}
	printf("%d\n",f[n]);
	return 0;
}

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

const int MAXN = 100010;
void bye() { std::cout << "No\n"; exit(0); }
int deg[MAXN], xs[MAXN], ys[MAXN];
int n, m, vis[MAXN], tc;
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1];
void addedge(int b, int e, int tot) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int rt;
int dfs(int u, int fa = 0) {
	if (!fa) rt = u;
	vis[u] = true;
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != fa) {
			if (vis[to[i]]) {
				if (to[i] == rt) {
					xs[i >> 1] = 0;
					++tc;
					return true;
				}
			} else
			if (dfs(to[i], u)) {
				xs[i >> 1] = 0;
				++tc;
				return true;
			}
		}
	return false;
}
void reducecir() {
	memset(vis, 0, n + 1 << 2);
	memset(head, 0, n + 1 << 2);
	for (int i = 1; i <= m; ++i) if (xs[i])
		addedge(xs[i], ys[i], i * 2 - 1);
	for (int i = 1; i <= n; ++i) if (!vis[i] && dfs(i)) return ;
}

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		std::cin >> xs[i] >> ys[i];
		++deg[xs[i]]; ++deg[ys[i]];
	}
	for (int i = 1; i <= n; ++i) if (deg[i] & 1) bye();
	static int tx[MAXN], ty[MAXN], rk[MAXN];
	memcpy(tx, xs, m + 1 << 2);
	memcpy(ty, ys, m + 1 << 2);
	for (int i = 1; i <= m; ++i) rk[i] = i;
	std::mt19937 rd(time(0) + (unsigned long) new char);
	while (clock() / (double) CLOCKS_PER_SEC < 1.5) {
		std::shuffle(rk + 1, rk + 1 + m, rd);
		for (int i = 1; i <= m; ++i)
			xs[i] = tx[rk[i]], ys[i] = ty[rk[i]];
		tc = 0;
		reducecir();
		if (tc < m) reducecir();
		if (tc < m) {
			std::cout << "Yes\n";
			return 0;
		}
	}
	bye();
	return 0;
}



Measured memory_bytes: 8704
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pub push_back
#define pob push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[1000005],y[500005],z[500005];
ll nega[500005],posi[500005];
ll len[500005],dep[500005];
bool dame,flag;
//char s[500005],t[500005];
//bool used[500005];
ll snum;




int main(){
    cin >> n;
	while(n != 0){
		if(n % 10 == 2){
			ans ++;
		}
		n /= 10;
	}
	p(ans);
	return 0;
}

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

const int N = 1005;
int n, tp, x[N], y[N];
bool d, ux[40], uy[40];

inline void calc(int x, bool* c) {
	bool fCheck = x < 0;
	if (fCheck)x = -x;
	c[30] = c[31] = 1;
	for (int i = 1; i <= 30; i++)c[i - 1] = x >> i & 1;
	if (fCheck)for (int i = 0; i < 31 + d; i++)c[i] ^= 1;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", x + i, &tp);
		y[i] = x[i] - tp, x[i] += tp;
		if (!i)d = x[i] & 1;
		if (x[i] & 1 ^ d || y[i] & 1 ^ d) return puts("-1"), 0;
	}
	printf("%d\n", 31 + d);
	for (int i = 0; i < 30; i++)printf("%d ", 1 << i);
	printf("%d", (1 << 30) - 1);
	puts(d ? " 1" : "");
	for (int i = 0; i < n; i++) {
		calc(x[i], ux), calc(y[i], uy);
		for (int j = 0; j < 31 + d; j++)putchar(ux[j] ? uy[j] ? 'R' : 'U' : (uy[j] ? 'D' : 'L'));
		puts("");
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var SP = new (string s, long p, long n)[N];
            for (var i = 0; i < N; ++i)
            {
                var (s, p) = Slice<string, long>();
                SP[i] = (s, 100 - p, i + 1);
            }
            Array.Sort(SP);
            foreach (var sp in SP)
                WriteLine(sp.n);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28220
//逆

#include<iostream>
#include<algorithm>
#include<bitset>

#include<cmath>
#include<cstring>
#include<climits>

#include<vector>
#include<set>
#include<map>
#include<unordered_set>
//#include<unordered_map>
#include<tr1/unordered_map>

#include<fstream>
#include<chrono>

using namespace std;
using namespace std::tr1;
using namespace std::chrono;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef vector<int> v32;
typedef vector<ll> v64;

const ll MOD7 = 1e9 + 7;
const ll MOD9 = 1e9 + 9;
const ll INF  = 1LL << 57LL;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ITER iterator
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define ones __builtin_popcount
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

ll dp[101][100001];

int main()
{
    // DANGER;
    ofstream out("output.txt");

    // ll t;
    // cin>>t;

    auto start = high_resolution_clock::now();

    ll n, W;
    cin>>n>>W;
    ll w[n], v[n];
    rep(i,0,n-1) cin>>w[i]>>v[i];

    mem( dp,-1 );
    dp[0][0] = 0, dp[0][w[0]] = v[0];

    rep(i,0,n-2)
    {
        rep(j,0,W)
        {
            if( dp[i][j]==-1 )
            continue;
            dp[i+1][j] = max( dp[i+1][j],dp[i][j] );
            ll J = j+w[i+1];
            if( J<=W )
            dp[i+1][J] = max( dp[i+1][J],dp[i][j]+v[i+1] );
        }
    }

    ll ans = 0;
    rep(i,0,W) ans = max( ans,dp[n-1][i] );
    cout<<ans<<"\n";

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 79104
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll h, w;
  cin >> h >> w;

  ll ans = h * w / 2;
  if (h % 2 == 1 && w % 2 == 1) ans++;
  if (h == 1 || w == 1) ans = 1;
  cout <<  ans << endl;


  
  return 0;
}

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

k = []
half_k = []
for i in range(1,N+1):
    if(i%K == 0):
        k.append(i)
    elif(i%(K/2) == 0):
        half_k.append(i)

if(K%2 == 0):
    print((len(k) ** 3) + (len(half_k) ** 3))
else:
    print(len(k) ** 3)

Measured memory_bytes: 11016
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  REP(i, N - 1) { cin >> C[i] >> S[i] >> F[i]; }
  REP(i, N) {
    int time = 0;
    for (int j = i; j < N - 1; j++) {
      if(time<S[j]){
        time = S[j] + C[j];
      }else{
        time = ((time+F[j]-1) / F[j])*F[j];
        time+=C[j];
      }
    }
    cout << time << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int n;
int sum;

int main(void){
	for(int i=0;i<10;i++){
		cin >> n;
		sum+=n;
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int MAX=1e5;
vector<int> dist(MAX);
vector<vector<int>> adj(1e5);
int dfs(int u){
    if(dist[u]!=-1){
        return dist[u];
    }
    int ans=0;
    for(int it:adj[u]){
        ans=max(ans,1+dfs(it));
    }
    return dist[u]=ans;
}
void solve(){
    int n,m;
    cin>>n>>m;
    dist.assign(n,-1);
    while(m--){
        int x,y;
        cin>>x>>y;
        x--,y--;
        adj[x].push_back(y);
    }
    int res=0;
    for(int i=0;i<n;i++){
        res=max(res,dfs(i));
    }
    cout<<res<<'\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 8192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{
	int a,b,k,temp;
	int j = 0,v[100];
	scanf("%d %d %d",&a,&b,&k);
	for (int i = 1; i <= (a < b ? a : b); ++i){
		if(!(a % i) && !(b % i))	v[++j] = i;
	}
	printf("%d\n", v[j - k + 1]);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
L, R = A[0], A[N-1]
S = R - L
x, y = 1, N - 2
while x <= y:
  a, b, c, d = abs(L-A[y]), abs(L-A[x]), abs(R-A[y]), abs(R-A[x])
  M = max(a, b, c, d)
  if M == a:
    L = A[y]
    y -= 1
    S += a
  elif M == b:
    L = A[x]
    x += 1
    S += b
  elif M == c:
    R = A[y]
    y -= 1
    S += c
  elif M == d:
    R = A[x]
    x += 1
    S += d
print(S)

Measured memory_bytes: 7512
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
const long nPrime = 1000000007;

int main(){
    long n;
    scanf("%ld", &n);
    if(n == 1){
        printf("0");
        return 0;
    } 
    
    long iTenPow = 1;
    long iNinePow = 1;
    long iEightPow = 1;
    for(long i = 0; i < n; i++){
        iTenPow *= 10;
        iTenPow %= nPrime;
        iNinePow *= 9;
        iNinePow %= nPrime;
        iEightPow *= 8;
        iEightPow %= nPrime;
    }
    long nAns = iTenPow - iNinePow;
    nAns %= nPrime;
    nAns -= iNinePow;
    nAns %= nPrime;
    nAns += iEightPow;
    nAns %= nPrime;
    if(nAns < 0){
        nAns += nPrime;
    }
    printf("%ld", nAns);
    return 0;
}


Measured memory_bytes: 3228
from collections import Counter

n = int(input())
d = list(map(int, input().split()))
mod = 998244353
cnt = Counter(d)

if d[0] != 0 or cnt[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(len(cnt)+1):
    ans *= pow(cnt[i], cnt[i+1], mod)
    ans %= mod
print(ans)


Measured memory_bytes: 19936
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
	
	char str[128] = {0};
	int num = 0;
	
	while(scanf("%s",str) != EOF){
		int len = strlen(str);
		
		for(int i = 0; i < len; ){
			if(str[i] < 48 || str[i] > 57){
				i++;
				continue;
			}
			int cnt = 0;
			char g[16]={0};
			
			for(int j = i;;j++){
				if(str[j] < 48 || str[j] > 57){
					num += atoi(g);
					i += cnt;
					break;
				}
				else{
					g[cnt] = str[j];
					cnt++;
				}
			}
		}	
	}
	
	printf("%d\n",num);
	
	return 0;
}

Measured memory_bytes: 976
n = int(input())
a = list(map(int, input().split()))
l = r = 0
ans = 0
while l < n:
    while r < n and a[l] == a[r]:
        r += 1
    k = r - l
    if k > 1:
        ans += k // 2
    l = r
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int tate,yoko;
  while(1){
    scanf("%d %d",&tate,&yoko);
    if(tate == 0&&yoko == 0){
      break;
    }else{
      for(int i = 1;i <= tate;i++){
        for(int k = 1;k <= yoko;k++){
          if(i == 1||i == tate){
            printf("#");
          }else{
            if(k == 1||k == yoko){
              printf("#");
            }else{
              printf(".");
            }
          }
        }
        printf("\n");
      }
      printf("\n");
    }
  
  }
  return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define LL long long
#define int LL
const int maxn = 200004;
const int mod = 1000000007, inf = 1000000007;

inline int powmod(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return res;
}
inline int inv(int a) {
	return powmod(a, mod - 2);
}
int f[maxn];
int c[maxn];

signed main() {
	int n, k, ans = 0;
	scanf("%lld %lld", &n, &k);
	k = std::min(n, k);
	c[0] = f[0] = 1;
	for (int i = 1; i <= n; ++i) f[i] = f[i - 1] * (n - i) % mod * inv(i) % mod;
	for (int i = 1; i <= n; ++i) c[i] = c[i - 1] * (n - i + 1) % mod * inv(i) % mod;
	for (int i = 0; i <= k; ++i) (ans += c[i] * f[i]) %= mod;
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 3328