akhauriyash/Code-Regression huggingface dataset:
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... 
// ................. WORK UNTILL YOUR IDOLS BECOME YOUR RIVALS................................

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define f first
#define mp make_pair
#define s second
#define delrep  a.erase(unique(a.begin(),a.end()),a.end());
#define all(a)  (a).begin(),(a).end()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=1000;
const int mod=998244353;
using namespace std;
int get_second( pair<int, int> i ){ return i.second; }  
int trail_zero(int n){while (n % 10 == 0) n /= 10 ; return n;}
typedef long long ll;
map<ll,ll> m11;
multiset<ll> s1;
map<pair<ll,ll>,ll> m1;
vector<pair<int,int>>v;
vector<int>ans;
map<char,int>m4;
map<char,int>m5;
char s111[N];
ll p2[N],p3[N];
//ll h[N];
ll n,k,m,x,y,ans1=INT_MAX;
bool check(int a,int b) { if(a>=0 || a<n) return true; if(b>=0 || b<m) return true; else return false;}
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
// char s[500][500];
vector<vector<ll>> adj(N);
vector<ll> vis(N),in(N),out(N),cnt(N);
vector<ll>ansx;
map<ll,ll>mx;
bool used[111][11];
void dfs( ll x, ll y )
{
    if( x<1 || x>10000 || used[x][y] || y>10000 ) return;
    if( x==m ) ans1=min(ans1, y);
    used[x][y]=1;
    dfs( x-1, y+1 );
    dfs( x*2, y+1 );
}
vector<pair<int, int>> e(100002), o(100002);
bool prime_check(ll a)
{
    if(a == 2)
        return true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i)
            continue;
        return false;
    }
    return true;
}
int smallest_divisor(ll a)
{
  for(int i=2;i*i<=a;i++)
  {
    if(a%i==0) return i;
  }
  return a;
}
 
int main()
{
  ll n,k; cin>>n>>k;
  if(k%2) { ll x=n/k;  cout<<x*x*x;  }
  else { ll x=n/k; ll y=(n+k/2)/k; cout<<x*x*x+y*y*y; }
  return 0;
}
 



Measured memory_bytes: 1920
N,*A=`dd`.split.map &:to_i;r={};B=[*1..N].sort_by{|i|r[A[i-1]-1]=i;A[i-1]};s=Hash.new 0;z=[];N.times{|i|n=B[N-i-1];z=[n]*~-n+z+[B[i]]*(N-B[i])};puts (N*N).times.any?{|i|z<<x=r[i]||z.shift;s[x]+=1;r[i]&&x!=s[x]}?:No:[:Yes,z]

Measured memory_bytes: 76812
import itertools
h,w,k=map(int,input().split())
C=[]
for _ in range(h):
    c=input()
    C.append(c)
l1=list(itertools.product([0,1],repeat=h))
l2=list(itertools.product([0,1],repeat=w))
count=0
for i in range(2**h):
    for j in range(2**w):
        black=0
        for ii in range(h):
            for jj in range(w):
                if l1[i][ii]==0 and l2[j][jj]==0 and C[ii][jj]=='#':
                    black+=1
        if black==k:
            count+=1
print(count)

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

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

    for (int i = 0; i < s.length(); i++) {
        if(s[i] == s[i+1]) {
            s.erase(i,1);
            i--;
        }
    }

    cout << s.length() << endl;
}

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

int path_len(int u, int dp[], const int n, const vector<int> g[]) {
    if (dp[u] > -1) return dp[u];
    int l = 0;
    for (int x : g[u]) l = max(l, path_len(x, dp, n, g) + 1);
    return dp[u] = l;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> g[n];
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        g[--x].push_back(--y);
    }

    int ans = 0;
    int dp[n];
    memset(dp, -1, sizeof(dp));
    rep(i, n) {
        ans = max(ans, path_len(i, dp, n, g));
    }

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

Measured memory_bytes: 9472
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int inputHeight = sc.nextInt();
        int inputWeight = sc.nextInt();
        int[][] tableCalc = new int[inputHeight+1][inputWeight+1];
        
        //入力
        for(int hei = 0; hei < inputHeight; hei++){
            for(int wei = 0; wei < inputWeight; wei++){
                tableCalc[hei][wei] = sc.nextInt();
            }
        }
        
        //合計値格納
        for(int hei = 0; hei <= inputHeight; hei++){
            int sum  = 0;
            for(int wei = 0; wei <= inputWeight; wei++){
                if(wei == inputWeight){
                    tableCalc[hei][wei] = sum;
                }else{
                    sum += tableCalc[hei][wei];
                }
            }
        }
        
        //合計値格納
        for(int wei = 0; wei <= inputWeight; wei++){
            int sum  = 0;
            for(int hei = 0; hei <= inputHeight; hei++){
                if(hei == inputHeight){
                    tableCalc[hei][wei] = sum;
                }else{
                    sum += tableCalc[hei][wei];
                }
            }
        }
        
        //出力
        for(int hei = 0; hei <= inputHeight; hei++){
            for(int wei = 0; wei <= inputWeight; wei++){
                if(wei == inputWeight){
                    System.out.print(tableCalc[hei][wei] + "\n");
                    break;
                }
                System.out.print(tableCalc[hei][wei] + " ");
            }
        }
    }
}



Measured memory_bytes: 41376
N, M = map(int, input().split())
root = [[] for _ in range(N+1)]

for i in range(M):
    a, b = map(int, input().split())
    root[a].append(b)
    root[b].append(a)

ans = [10**9] * (N+1)
ans[0] = 0
ans[1] = 0

from collections import deque
q = deque([1])

while q:
    p = q.popleft()
    for i in root[p]:
        if ans[i] == 10**9:
            ans[i] = p
            q.append(i)

if 10**9 in set(ans):
    print('No')
else:
    print('Yes')
    for i in range(2, N+1):
        print(ans[i])

Measured memory_bytes: 97336
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

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

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

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

    ll n, a, b; cin >> n >> a >> b;
    cout << ((b - a) % 2 == 0 
            ? (b - a) / 2 
            : min(a + (b - a - 1) / 2, n - b + 1 + (n - (a + n - b + 1)) / 2 )) 
            << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))
#define cInf 9e18

class UnionFind
{
  public:
	explicit UnionFind(ll size)
		: mParent(size, -1)
		, mRank(size, 0)
        , mData(size, -1)
		, mData2(size, -1)
		{}
	bool unionSet(ll x, ll y)
	{
		if ((x = root(x)) == (y = root(y)))
			return false;
		if( mRank[x] < mRank[y] )
		{
			mParent[y] += mParent[x];
			mParent[x] = y;
            unionData( mData[y], mData[x] );
			mData2[y] += mData2[x];
		}
		else
		{
			mParent[x] += mParent[y];
			mParent[y] = x;
			if( mRank[x] == mRank[y] ) ++mRank[x];
            unionData( mData[x], mData[y] );
			mData2[x] += mData2[y];
		}
		return true;
	}
	bool isEqualSet(ll x, ll y)
	{
		return root(x) == root(y);
	}
	ll root(ll x)
	{
		return mParent[x] < 0 ? x : mParent[x] = root(mParent[x]);
	}
	ll size(ll x)
	{
		return -mParent[root(x)];
	}

    void unionData( ll& parent, ll& child )
    {
        parent = max( parent, child );
    }
    void setData( ll x, ll data )
    {
        mData[root(x)] = data;
    }
    ll getData( ll x )
    {
        return mData[root(x)];
    }
	void setData2( ll x, ll data2 )
	{
		mData2[root(x)] = data2;
	}
	ll getData2( ll x )
	{
		return mData2[root(x)];
	}

  public:
	vector<ll> mParent; // = mSize
	vector<ll> mRank;
	vector<ll> mData;
	vector<ll> mData2;
};

struct Node{
    ll a = 0;
    ll b = 0;
	ll c = 0;
	ll idx = 0;
};
bool operator<(const Node& l, const Node& r)
{ return l.c != r.c ? l.c < r.c : l.idx < r.idx; }
bool operator>(const Node& l, const Node& r)
{ return l.c != r.c ? l.c > r.c : l.idx > r.idx; }

int main()
{
    ll n, m;
    cin >> n >> m;
	VEC( Node, n, node, Node() );
	REP(i,n)
	{
		node[i].idx = i;
		cin >> node[i].a >> node[i].b;
		node[i].c = max( 0ll, node[i].a-node[i].b );
	}
	vector< vector<ll> > edge(n);
	REP( i, m )
	{
		ll a, b;
		cin >> a >> b;
		edge[a-1].push_back( b-1 );
		edge[b-1].push_back( a-1 );
	}

	sort( ALL(node) );

	UnionFind uf(n);
	REP( i,n )
	{
		auto& nod = node[i];
		uf.setData2( nod.idx, nod.b );
		ll dataMin = cInf;
		bool is[100010] = { false };
		vector<ll> vec;
		for( auto e : edge[nod.idx] )
		{
			if( uf.getData(e) < 0 )
			{ continue; }
			auto r = uf.root(e);
			if( !is[r] )
			{
				is[r] = true;
				vec.push_back(uf.root(e));
			}
		}
		ll sum = 0;
		for( auto e : vec ){ sum += uf.getData2(e); }
		for( auto e : vec )
		{
			auto data = uf.getData(e);
			data = nod.c <= data ? data + nod.b : nod.a;
			data += sum - uf.getData2(e);
			dataMin = min( dataMin, data );
		}
		
		if( dataMin == cInf )
		{
			dataMin = max( nod.a, nod.b );
		}
		uf.setData( nod.idx, dataMin );
		
		for( auto e : vec )
		{
			uf.unionSet( nod.idx, e );
		}
	}
	
	cout << uf.getData(0) << endl;

    return 0;
}

Measured memory_bytes: 13432
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	int x, y;
	cin >> x >> y;
	if(g[x] == g[y]){
			cout << "Yes" << endl;
	}else{
			cout << "No" << endl;
	}
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool b = false;
  if(S.at(0)==S.at(1) && S.at(2)==S.at(3) && S.at(2)!=S.at(0)) {
    b = true;
  }
  else if(S.at(0)==S.at(2) && S.at(1)==S.at(3) && S.at(0)!=S.at(1)) {
    b = true;
  }
  else if(S.at(0)==S.at(3) && S.at(1)==S.at(2) && S.at(2)!=S.at(3)) {
    b = true;
  }
  if(b == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; cin >> n;
  cout << n / 3 << endl;
  return 0;
}

Measured memory_bytes: 3176
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[1007];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i+=2)
	  if(a[i]%2==1)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3160
N = int(input())
W = {}
last=""
flg = True

w =[]

for i in range(N):
    w.append(str(input()))
    
cnt=0
for i in w:
    
    if i in W:
        flg = False
        break
    else:
        W[i] = 1
        
    if cnt !=0:
        if i[0] == last:
            last = i[-1]
        else:
            flg = False
            break
    else:
        last = i[-1]
            
    cnt+=1
        
if(flg == True):
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 3064
use std::io;
use std::str::FromStr;

static MOD: u64 = 1_000_000_000 + 7;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (h, w) = input_tuple();
    let mut grid: Vec<Vec<char>> = Vec::new();
    grid.push(vec!['#'; (w+2) as usize]);
    for _ in 0..h {
        let row: String = input();
        let mut row: Vec<char> = row.chars().collect();
        row.push('#');
        row.insert(0, '#');
        grid.push(row);
    }
    grid.push(vec!['#'; (w+2) as usize]);
    let mut dp: Vec<Vec<u64>> = vec![vec![0; (w+2) as usize]; (h+2) as usize];
    for i in 1..(h+1) {
        for j in 1..(w+1) {
            if i == 1 && j == 1 {
                dp[i][j] = 1;
                continue;
            }
            if grid[i][j] == '#' {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    println!("{}", dp[h][w]);
}


Measured memory_bytes: 16636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

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

    string s;
    cin >> s;
    bool a = false;
    bool b = false;
    for (auto x : s) {
        if (x == 'A') {
            a = true;
        } else {
            b = true;
        }
    }
    if (a && b) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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

using namespace std;

int cnt = 0, m=0;
vector<int> G;

void insertSort(vector<int> &arr, int n, int g)
{
	int j,v;
	for (int i = g; i != n; ++i)
	{
		v = arr.at(i);
		j = i - g;
		while (j >= 0 && arr.at(j) > v)
		{
			arr.at(j + g) = arr.at(j);
			j = j - g;
			++cnt;
		}
		arr.at(j + g) = v;
	}
}


void shellSort(vector<int> &arr, int n)
{
	for (int i = 1; i <= n; ++m)
	{
		G.push_back(i);
		i = i * 3 + 1;
	}

	reverse(G.begin(), G.end());

	for (int i = 0; i != m; ++i)
	{
		insertSort(arr, n, G[i]);
	}
}


int main()
{
	int n,t;
	vector<int> arr;

	cin >>n;
	for (int i = 0; i != n; ++i)
	{
		cin >> t;
		arr.push_back(t);
	}

	shellSort(arr, n);

	cout << m << endl;

	for (int i = 0; i != m; ++i)
	{
		cout << G.at(i);
		if (i == m - 1)
		{
			cout << endl;
			break;
		}
		cout << " ";
	}

	cout << cnt << endl;
	for (int i = 0; i != n; ++i)
	{
		cout << arr.at(i);
		if (i == n - 1)
		{
			cout << endl;
			break;
		}
		cout << " ";
	}

	

	return 0;

}


Measured memory_bytes: 6948
#include<bits/stdc++.h>
using namespace std;
bool cmp (int a,int b){
	return a>b;
}
int main () {
	int n,a[105],ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		if(i%2)ans+=a[i];
		else ans-=a[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
char s[200100];
int n,ans=1,num;
int main(){
    int i,j,k;
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<2*n;i++)
        if(!(((s[i]=='W')^num)&1))
            num++;
        else{
            ans=1ll*ans*num%mod;
            num--;
        }
    if(num!=0 || s[0]=='W' || s[2*n-1]=='W')
        return cout<<0<<endl,0;
    for(i=1;i<=n;i++)ans=1ll*ans*i%mod;
    printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main(){
  int a,b,c;
  int n=0;
  std::vector<int> dividor;

  cin>>a>>b>>c;

  for(int i=1; i<=c; i++){
    if(c%i==0){
      dividor.push_back(i);
    }
  }

  int size=dividor.size();

  for(int i=a; i<=b; i++){
    for(int j=0; j<size; j++){
      if(i==dividor[j]){
        n=n+1;
      }
    }
  }
  cout<<n<<endl;

  return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

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

			String str = sc.next();
			
			int ans = 0;

			//インデックスは0からスタートするので，奇数番目の文字は偶数のインデックスになる
		    for(int i = 0; i < str.length(); i ++){
		    	if (str.charAt(i) == '1'){
		    		ans ++;
		    	}
		    }
		    System.out.println(ans);

		}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct xstruct {
    ll val;
};
bool operator<=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val <= rhs.val;
}
bool operator<(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val < rhs.val;
}
bool operator>=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val >= rhs.val;
}
bool operator>(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val > rhs.val;
}
bool operator==(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val == rhs.val;
}
bool operator!=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val != rhs.val;
}
ostream& operator<<(ostream& os, xstruct const& xst) {
    return os << xst.val;
}

ll recursive(ll a, ll b, string& sa, string& sb, vector<vector<ll>>& dp) {
    ll maxval = 0;
    if (a == sa.length() || b == sb.length()) {
        return maxval;
    }
    if (dp[a][b] >= 0) {
        return dp[a][b];
    }

    if (sa.at(a) == sb.at(b)) {
        maxval = max(maxval, 1 + recursive(a + 1, b + 1, sa, sb, dp));
    }
    maxval = max(maxval, recursive(a + 1, b, sa, sb, dp));
    maxval = max(maxval, recursive(a, b + 1, sa, sb, dp));
    dp[a][b] = maxval;
    return dp[a][b];
}

int main() {
    ll N = 0;
    cin >> N;
    string nil;
    getline(cin, nil);
    for (ll iter = 0; iter < N; iter++) {
        string sa, sb;
        getline(cin, sa);
        getline(cin, sb);
        ll la = sa.length();
        ll lb = sb.length();

        vector<vector<ll>> dp(la, vector<ll>(lb));
        for (ll a = 0; a < la; a++) {
            for (ll b = 0; b < lb; b++) {
                dp[a][b] = -1;
            }
        }
        recursive(0, 0, sa, sb, dp);
        print(dp[0][0]);
    }
}



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

int main() {
	int N, W;
	cin >> N;
	vector<int> vec(N);
	int SUM = 0;

	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
		SUM += vec.at(i);
	}
	
	int sum = 0;
	int count = 0;

	for (int i = 0; i < N; i++) {
		sum += vec.at(i);

		if (sum >= SUM / 2)
			break;
      
      	count++;
	}

	int p = 2 * sum - SUM;
	int q = 2 * (sum - vec.at(count)) - SUM;

	cout << min(abs(p), abs(q)) << endl;
	
}

Measured memory_bytes: 256
def process():
  count = int(input())
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

  if 0 in nums_int:
    result = 0
    return result
  else:
    result = 1
    for intn in nums_int:
      result *= intn
      if result > 10**18:
        result = -1
        return result
    return result
    
print(process())

Measured memory_bytes: 21752
#include <cstdio>
#include <set>

using namespace std;

#define MAX 131071

int main()
{
	bool is_prime[MAX] = {false};

	for(int i = 3; i < MAX; i += 2) {
		is_prime[i] = true;
	}
	is_prime[2] = true;
	for(int i = 3; i * i < MAX; i += 2) {
		if(!is_prime[i]) continue;
		for(int j = i * 2; j < MAX; j += i) {
			is_prime[j] = false;
		}
	}
	
	while(1) {
		int N, P;
		multiset<int> set_sum_p;
		int first_p;
		int ans;

		scanf("%d %d", &N, &P);
		if(N == -1 && P == -1) break;

		for(int i = N + 1; i < MAX; i++) {
			if(!is_prime[i]) continue;
			first_p = i;
			break;
		}
		
		int a = first_p, b = first_p;
		while(a < MAX) {
			if(!is_prime[a]) {
				a++;
				continue;
			}

			if(set_sum_p.size() >= P) {
				multiset<int>::iterator it = set_sum_p.begin();
				for(int i = 1; i < P; i++) {
					it++;
				}
				if(a + first_p > *it) {
					ans = *it;
					break;
				}
			}
			
			b = first_p;
			while(b <= a) {
				if(!is_prime[b]) {
					b++;
					continue;
				}
				set_sum_p.insert(a + b);
				b++;
			}
			a++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;
const int cons = 1000000007;

int dp[100003][3];

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, i;
    cin>>n;
    int a[n+1], b[n+1], c[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp, 0, sizeof(dp));
    for(i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][1], dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0], dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0], dp[i-1][1])+c[i];
    }
    cout<<max(max(dp[n][0], dp[n][1]), dp[n][2])<<endl;
}


Measured memory_bytes: 4992
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
 
        Scanner sc = new Scanner(System.in);
        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();

        int BigH2 = H2-H1;
        int BigH2M2 = BigH2*60+M2;
        int clearTime = BigH2M2-M1;
        int answer = clearTime - K ;
        System.out.println(answer);

/**
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
 
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
 
        // 通った街を記録する配列
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(1);    // 一つ目の町
 
        // ループの先頭の町がリストの何番目にあるかを格納する変数
        int check = -1;
 
        // 転送先を格納する変数。
        int temp = 1;   // 計算のため初期値１
 
        for (long i = 0; i < k; i++) {
            temp = a[temp-1];   //　転送先設定
            // 訪れた町かチェック
            // 訪れていた場合、ループ前のイントロ部分の長さを求める
            if (list.contains(temp)) {
                check = list.indexOf(temp);
            	break;
            }
            list.add(temp);
        }
        if(check == -1){
            System.out.println(temp);
        }else{
 
        // 合計移動回数をループ長で割った余りを求める
        int std = (int)(k-check) % (list.size() - check);
 
        System.out.println(list.get((int)(std + check)));
        }
        **/
    }
}

Measured memory_bytes: 35692
def main():    
    n = int(input())
    data = []
    
    for i in range(n):
        city, point = input().split()
        data.append((city, int(point), i+1))

    data = sorted(data, key=lambda x: x[1], reverse=True)
    data = sorted(data, key=lambda x:x[0])

    for d in data:
        print(d[2])



if __name__ == '__main__':
    main()

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

int main() {
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    queue<char> qa,qb,qc;
    for(int i = 0; i < sa.size(); i++) qa.push(sa[i]);
    for(int i = 0; i < sb.size(); i++) qb.push(sb[i]);
    for(int i = 0; i < sc.size(); i++) qc.push(sc[i]);
    qa.push('w'),qb.push('w'),qc.push('w');
    char x=qa.front();
    qa.pop();
    while(!qa.empty() && !qb.empty() && !qc.empty()){
        if(x=='a'){
            x=qa.front();
            qa.pop();
        }
        if(x=='b'){
            x=qb.front();
            qb.pop();
        }
        if(x=='c'){
            x=qc.front();
            qc.pop();
        }
    }

    if(qa.empty()) cout << 'A' << endl;
    else if(qb.empty()) cout << 'B' << endl;
    else cout << 'C' << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//const int MOD = pow(10,9)+7;
//const int MAX = 100001;

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


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




int Myunion_tree(vector< P > reducedlinks,int N){

    UnionFind u(N+1);
    
    for(auto l: reducedlinks){
        u.unionSet(l.first,l.second);
    }
    
    for(auto i = 1; i<N; i++){
        
        if (!u.findSet(i,i+1)){
            return 0;
        }
        
    }

    return 1;
}

int main() {
    
    int N = in();
    int M = in();
    P links[M];
    
    int st;
    int gl;
    for(auto i = 0; i<M; i++){
        st = in();
        gl = in();
        
        links[i] = make_pair(st,gl);
    }
    
    int count = 0;
    
    for(auto l = 0; l < M; l++){
        
        vector<P> reducedlinks;
        
        for(auto i = 0; i<M; i++){
            
            if(i == l) continue;
            
            reducedlinks.push_back(links[i]);
            
        }
        

        count += 1-Myunion_tree(reducedlinks, N);
        
    }
    
    cout << count << endl;
    
    
    return 0;
    
    
}



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

ll N, M, K;

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};



/*
  N個のブロックをM色で塗る。同じ色の隣接がK個
    先頭のブロック M通り 
    同じ色を追加 1通り  K回
    違う色を追加 (M-1)通り  (N-K-1)回
    追加の組み合わせ C(N-1,K)
  
  → M * 1^(K) * (M-1)^(N-K-1) * C(N-1,K)
*/


int main(){
	cin >> N >> M >> K;
	
	COMinit();
	
	using mint = modint<998244353>;
	
	// (M-1)^i の計算
	mint m1pow[N];
	mint p = 1;
	for ( int i = 0; i < N; i++ ){
		m1pow[i] = p;
		p *= (M-1);
	}
	
	
	
	mint result = 0;
	for ( int i = 0; i <= K; i++ ){
		result +=  m1pow[N-i-1] * M * COM(N-1,i);
	}
	
	cout << result.value() << endl;
	
	return 0;
}



Measured memory_bytes: 17104
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

vector<ll> make_divisors(ll n){
    vector<ll> divisors;
    //cout << 1 << endl;
    FOR(i,1,ll(sqrt(n))){
        if(n%i==0){
            divisors.PB(i);
            if(i!=ll(n/i))divisors.PB(ll(n/i));
        }
    }
    return divisors;
}

signed main(){
    ll n;cin >> n;
    map<ll,ll> a;
    REP(i,n){
        ll x;cin >> x;
        a[x]+=1;
    }
    ll ans=0;
    for(auto i=a.begin();i!=a.end();i++){
        vector<ll> div=make_divisors(i->F);
        //cout << 1 << endl;
        ll f=true;
        REP(j,SIZE(div)){
            if((a.find(div[j])!=a.end() and div[j]!=(i->F))or(div[j]==(i->F) and (i->S)>1)){
                f=false;
                break;
            }
        }
        if(f)ans++;
    }
    cout << ans << endl;
}

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

*/
int main(){
  ll L,R,d; cin>>L>>R>>d;
  ll ans=R/d-(L-1)/d;
  cout<<ans<<endl;
}

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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7 ;


ll n, p, dp[N];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> p;
	dp[0] = 1;
	fo(i, n)
	{
		ll u;
		cin >> u;
		ll x = dp[0];
		ll y = dp[1];
		if(u % 2 == 0)
			x += x,
			y += y;
		else
			x += dp[1],
			y += dp[0];
		dp[0] = x;
		dp[1] = y;
	}
	cout << dp[p];


	return 0;
}
               

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
    int a,b,t;
    cin >>a >>b >>t;
    int sum = 0;
    for(int i = 1; i <= t; i++){
        if(i % a == 0){
            sum += b;
        }
    }
    printf("%d\n", sum);
    return 0;
}

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

int main() {
  int n,h[105],ans=0;
  cin>>n;
  for(int i=0; i<n; i++) cin>>h[i];
  for(int i=0; i<n-1; i++){
    if(h[i]>h[i+1]) ans += h[i] - h[i+1];
  }
  cout<<ans + h[n-1];
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#include<assert.h>
#include<iomanip>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll h, w; cin >> h >> w;
    ll ans = h * w / 2;
    if(h == 1 || w == 1)ans = 1;
    else if(h * w % 2 == 1)ans++;
    cout << ans << endl;    
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2020/05/16.
//

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main() {
    //CFS;
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(i, q) {
        int c, a, b;
        cin >> c >> a >> b;
        if (c == 0) {
            d.merge(a, b);
        } else {
            cout << (d.same(a, b) ? 1 : 0) << endl;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;

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

  if (n == 0) {
    if (a[0] == 1) {
      cout << 1 << '\n';
    } else {
      puts("-1");
    }
    return 0;
  }

  if (a[0] > 0) {
    puts("-1");
    return 0;
  }


  vector<P> range(n + 1);
  range[n] = P(a[n], a[n]);
  for (int i = n - 1; i >= 0; --i) {
    range[i] = P(ceil((double)range[i + 1].first / 2), range[i + 1].second + a[i]);
  }


  if (range[0].first > 1) {
    puts("-1");
    return 0;
  }

  ll ans = 1;
  ll pre = 1;
  for (int i = 1; i < n + 1; ++i) {
    if (a[i] > pre * 2) {
      puts("-1");
      return 0;
    }
    ll ma = min((pre - a[i - 1]) * 2, range[i].second);
    ans += ma;
    pre = ma;
  }
  cout << ans << '\n';
  return 0;
}



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

sys.setrecursionlimit(1000000)
mod = 1000000007
cnt = 0
def solve():
    def lowlink(v):
        global cnt
        def dfs(x):
            global cnt
            for y in v[x]:
                if pre[y] is None:
                    cnt += 1
                    pre[y] = low[y] = cnt
                    par[y] = x
                    py = dfs(y)
                    if py < low[x]:
                        low[x] = py
                else:
                    if par[x] != y and pre[y] < low[x]:
                        low[x] = pre[y]
                if pre[x] < low[y]:
                    res.append((x,y))
            return low[x]

        pre = [None]*n
        low = [None]*n
        par = [None]*n
        res = []
        for x in range(n):
            if pre[x] is None:
                pre[x] = low[x] = cnt
                dfs(x)
        return res

    n,m = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    ans = lowlink(v)
    print(len(ans))
    return

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


Measured memory_bytes: 38384
# -*- coding: utf-8 -*-

"""
全探索
・再帰で作る
・2^20でTLEするからメモ化した
"""

N = int(input())
aN = list(map(int, input().split()))
Q = int(input())
mQ = list(map(int, input().split()))

def dfs(cur, depth, ans):
    # 終了条件
    if cur == ans:
        return True
    # memo[現在位置]に数値curがあれば、そこから先はやっても同じだからやらない
    if cur in memo[depth]:
        return False
    memo[depth].add(cur)
    # 全探索
    for i in range(depth, N):
        if dfs(cur+aN[i], i+1, ans):
            return True
    # 見つからなかった
    return False

for i in range(Q):
    memo = [set() for j in range(N+1)]
    if dfs(0, 0, mQ[i]):
        print('yes')
    else:
        print('no')



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

int main(){
  string S;
  cin >> S;
  bool good = true;
  for(int i=0;i<3;i++){
    if(S[i]==S[i+1]){
      good = false;
    }
  }
  if(good){
    cout << "Good" << endl;
  }
  else{
    cout << "Bad" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# coding=utf-8

if __name__ == '__main__':
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    inf = float('inf')

    dp = [inf] * N
    dp[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if i + j < N:
                if dp[i+j] > dp[i] + abs(h[i] - h[i+j]):
                    dp[i+j] = dp[i] + abs(h[i] - h[i+j])

    print(dp[N-1])


Measured memory_bytes: 85816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D;
  cin>>N>>D;
  int kotae=0;
  if(N%(2*D+1)==0){
    kotae=N/(2*D+1);
  }else{
    kotae=1+N/(2*D+1);
  }
  cout << kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define ll long long

ll M=998244353;
ll fact[300001],ifact[300001];

ll mpow(ll x,ll n){
  ll ans=1;
  while(n != 0){
    if(n&1) ans=ans*x%M;
    x=x*x%M;
    n=n>>1;
  }
  return ans;
}

ll combi(ll n,ll x){
  if(n==0&&x==0)return 1;
  if(n<x||n<0)return 0;
  return fact[n]*ifact[n-x]%M*ifact[x]%M;
}

int main(){
  ll i,n,a,b,k,j,ans;
  scanf("%lld %lld %lld %lld",&n,&a,&b,&k);
  fact[0]=1;
  ifact[0]=1;
  for(i=1;i<=n;i++){
    fact[i]=fact[i-1]*(i)%M;
    ifact[i]=ifact[i-1]*mpow(i,M-2)%M;
  }
  for(i=0;i<=n;i++){
    ll j=(k-i*a)/b;
    if(0<=j&&j<=n&&i*a+j*b==k)ans=(ans+combi(n,i)*combi(n,j))%M;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n,a[N];
ll sum=0;
inline int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}
int main(){
//	freopen("a.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i) a[i]=read(),sum+=a[i];
	if(n%2==0){
		puts(sum&1?"First":"Second");return 0;
	}if(sum%2==0){puts("First");return 0;}
	while(1){
		bool flag=0;int g=0;
		for(int i=1;i<=n;++i){
			if(a[i]==1||(a[i]&1&&flag)){puts("Second");return 0;}
			if(a[i]&1){a[i]--;flag=1;}
			g=gcd(g,a[i]);
		}if((sum/=g)%2==0){puts("Second");return 0;}
		for(int i=1;i<=n;++i) a[i]/=g;
		flag=0;g=0;
		for(int i=1;i<=n;++i){
			if(a[i]==1||(a[i]&1&&flag)){puts("First");return 0;}
			if(a[i]&1){a[i]--;flag=1;}
			g=gcd(g,a[i]);
		}if((sum/=g)%2==0){puts("First");return 0;}
		for(int i=1;i<=n;++i) a[i]/=g;
	}
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int A;
string S;
void input(){
    cin>>A>>S;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int x = (char)(S[0]-'0');
    int y = atoi(S.substr(2).c_str());
    cout<<A*(x*100+y)/100<<endl;
    return 0;
}


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    ans += min(a,b);
    ans += min(c,d);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def ggg(h,w):
	a=0
	b=0
	while b < h:
		if b%2==0 and a == w-1:
			na = a
			nb = b+1
		elif b %2==0:
				na = a+1
				nb = b
		elif a == 0:
			na=a
			nb = b+1
		else:
			na = a-1
			nb = b
		yield a, b, na, nb
		a=na
		b=nb


def main():
	#a = int(input())
	h, w = tin()
	#s = input()
	mp = [lin() for _ in range(h)]
	ret = []
	lg = ggg(h, w)
	oddf = False
	for a, b, na, nb in lg:
		if mp[b][a] %2 == 1:
			oddf = not oddf
		if oddf and nb < h:
			ret.append([b+1, a+1, nb+1,na+1])
	print(len(ret))
	for k in ret:
		print(*k)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 96044
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair


const int mod = 1e9+7;

inline int add(int a,int b){a+=b;if(a>=mod)a-=mod; return a;} 
inline int sub(int a,int b){a-=b;if(a<0) a += mod; return a;}
inline int mul(int a, int b){ return a*1ll*b%mod;}
inline int power(int x, ll y){
  int res = 1;
  while(y){
    if(y&1) res = mul(res , x);
    x = mul(x,x);
    y >>= 1;
  }
  return res;
}

int main(){
  fio; cout<<fixed<<setprecision(25);	
  int d , t , s;
  cin >> d >> t >> s;
  if(t*s >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3508