akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	string s,t;
  cin >> s >> t;
  string x="";
  rep(i,s.size()){
    x += t[i];
  }
  if(s == x) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline ll rd()
{
	static ll x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=100010;
int n,a[N],p[N],f[N];
ll b[N];
bool vis[N];

int main()
{
	n=rd();
	fo(i,1,n){
		a[i]=rd();
		b[i]=a[i]-a[i-1];
		f[i]=p[i]=i;
	}
	int m=rd();ll K=rd();
	fo(i,1,m){
		int x=rd();
		swap(p[x],p[x+1]);
	}
	fo(x,2,n)if(!vis[x]){
		int u=x;
		static vector<int>vec;
		vec.clear();
		for(;!vis[u];u=p[u])vec.push_back(u),vis[u]=1;
		int siz=vec.size();
		fo(i,0,siz-1)f[vec[i]]=vec[(i+K%siz)%siz];
	}
	ll hh=0;
	fo(i,1,n)printf("%lld.0\n",hh+=b[f[i]]);
	return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	const ll mod = 1e9 + 7;
	int n;
	string s;
	cin >> n >> s;
	int cnt[26] = {0};
	for (char c : s)
		cnt[c - 'a']++;
	ll ans = 1;
	forn(i, 26) ans *= (cnt[i] + 1), ans %= mod;
	cout << (ans - 1);
	return 0;
}

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

using namespace std;

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

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

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

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

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

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

bool used[114][114];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	cin>>n;
	int ans[114514][2];
	int cnt=0;
	if(n&1){
		FOR(i, 1, n){
			FOR(j, 1, n+1){
				if(i==j || used[i][j] || j==n-i){
					continue;
				}
				ans[cnt][0]=i;
				ans[cnt][1]=j;
				used[i][j]=used[j][i]=true;
				++cnt;
			}
		}
		FOR(i, 1, n){
			if(used[n][i]){
				continue;
			}
			ans[cnt][0]=n;
			ans[cnt][1]=i;
			used[i][n]=used[n][i]=true;
			++cnt;
		}
	}
	else{
		FOR(i, 1, n+1){
			FOR(j, 1, n+1){
				if(i==j || used[i][j] || j==n-i+1){
					continue;
				}
				ans[cnt][0]=i;
				ans[cnt][1]=j;
				used[i][j]=used[j][i]=true;
				++cnt;
			}
		}
	}
	cout<<cnt<<'\n';
	REP(i, cnt){
		cout<<ans[i][0]<<' '<<ans[i][1]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#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;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N, W;
    cin >> N >> W;

    vi w(N);
    vll v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvll dp(N + 1, vll(W + 1));
    rep(i, N)
    {
        reple(j, 0, W)
        {
            chmax(dp[i + 1][j], dp[i][j]);
            if(j - w[i] >= 0) chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }

    cout << dp[N][W] << endl;

    return 0; 
}

Measured memory_bytes: 83012
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

vector<pair<ll,int> > vs;
int main(void) {
  int X, Y, A, B, C;
  scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
  REP(i, A) {
    ll v;
    scanf("%lld", &v);
    vs.push_back(make_pair(v, 2));
  }
  REP(i, B) {
    ll v;
    scanf("%lld", &v);
    vs.push_back(make_pair(v, 1));
  }
  REP(i, C) {
    ll v;
    scanf("%lld", &v);
    vs.push_back(make_pair(v, 0));
  }
  sort(vs.begin(), vs.end());
  reverse(vs.begin(), vs.end());
  ll res = 0;
  int r = 0, g = 0, b = 0;
  REP(i, vs.size()) {
    ll v = vs[i].first;
    int t = vs[i].second;
    if(t == 2) {
      if(r < X) {
        ++r;
        res += v;
      }
    } else if(t == 1) {
      if(g < Y) {
        ++g;
        res += v;
      }
    } else {
      ++b;
      res += v;
    }
    // cerr << r << " " << g << " " << b << " " << res << endl;
    if(r + g + b == X + Y) {
      break;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 11240
N = int(input())
S = input()
p = 0
C = [[0,0]]
W = 0
for i in range(N):
    if p==0:
        if S[i] == "#":
            C[-1][0] += 1
        else:
            p = 1
            C[-1][1] += 1
            W += 1
    else:
        if S[i] == ".":
            C[-1][1] += 1
            W += 1
        else:
            C.append([1,0])
            p = 0
if C[0][0] == 0:
    W -= C.pop(0)[1]
if len(C) >0:
    if C[-1][1] == 0:
        C.pop(-1)
tmp = W
ans = W
for b,w in C:
    tmp += b
    tmp -= w
    ans = min(tmp,ans)

print(ans)

Measured memory_bytes: 13416
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple

ll M = 998244353;


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll h; int n; cin>>h>>n;
	ll p, sum=0;
	for(int i=0;i<n;i++)
	{
	    cin>>p; sum+=p;
	}
	if(sum>=h) cout<<"Yes";
	else cout<<"No";
	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		int x = scan.nextInt();
		int y =scan.nextInt();
		long ans = 0;
		int a = x;
		int b = 0;
		while(a >= 0) {
			if(2*a + b == y) {
				break;
			}
			a = a - 2;
			b = b + 1;
			if(a < 0) {
				System.out.println(0);
				System.exit(0);
			}
		}
		Main instance = new Main();

		long f1 =instance.fac(a+b);
		long f2 = instance.fac(a)*instance.fac(b)%1000000007;
		long f3 = 1;
		while(f3 < 1000000007) {
			if((f3*f2)%1000000007 == 1) {
				break;
			}
			else {
				f3++;
			}
		}
		ans = (f1*f3)%1000000007;
		System.out.println(ans);

	}

	public long fac(int n) {
		long l = 1;
		while(n > 0) {
			l = (l*n)%1000000007;
			n--;
		}
		return l;
	}

}


Measured memory_bytes: 22228
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d", &N);
    int A[N];
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
    int max = A[0];
    int min = A[0];
    for (int i = 0; i < N; i++)
    {
        if (A[i] > max)
        {
            max = A[i];
        }
        if (A[i] < min)
        {
            min = A[i];
        }
    }
    printf("%d", max - min);

    return 0;
}

Measured memory_bytes: 128
using System;
public class Hello{
    public static void Main(){
        string A = Console.ReadLine();
        string B = Console.ReadLine();
        if(
            (A.Substring(0,1) == B.Substring(2,1)) &&
            (A.Substring(1,1) == B.Substring(1,1)) &&
            (A.Substring(2,1) == B.Substring(0,1))
            ){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
 
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->left;
}
 
else x = x->right;
}
 
z->parent = y;
 
if(y == NIL) root = z;
 
else if(z->key < y->key) y->left = z;
else y->right = z;
 
 
 
 
 
}
 
void inorder(Node u){
if(u != NIL){
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
 
 
}
void preorder(Node u){
if(u != NIL){
printf(" %d",u->key);
if(u->left != NIL)preorder(u->left);
if(u->right != NIL)preorder(u->right);
}
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
     
   if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
     else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 24036
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    sum = a[i-1]+a[i]
    if sum>x:
        if sum-x<=a[i]:
            ans += sum-x
            a[i] -= sum-x
        else:
            ans += sum-x
            a[i] = 0
print(ans)

Measured memory_bytes: 14540
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int MAX = 0xFFFFFFF;

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

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

  int max_elem = 0;
  for(int i=0; i<N; ++i) {
    max_elem = max(A[i], max_elem);
  }

  vector<long long> dp(H + max_elem+1, MAX);
  dp[0] = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <dp.size(); ++j) {
      if(A[i] <= j)
        dp[j] = min(dp[j], dp[j - A[i]] + B[i]);
    }
  }

  long long ret = dp[H];
  for(int i=H; i<dp.size(); ++i) {
    ret = min(ret, dp[i]);
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
kss = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ll = [['0' for _ in range(N)] for __ in range(M)]
for i, ks in enumerate(kss):
  for k in ks[1:]:
    ll[i][k-1] = '1'

cnt = 0
for i in range(2**N):
  flag = True
  for j,l in enumerate(ll):
    if not flag: break
    oneNum = format(int(''.join(l), 2) & i, 'b').count('1')
    flag = (p[j]==int(oneNum%2))
  if flag: cnt += 1

print(cnt)


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

int main(){
  int H, W, K; cin >> H >> W >> K;
  vector<string> table(H);
  int ans = 0;
  
  for (int i=0; i<H; i++){
      cin >> table.at(i);
  }
  for (int i=0; i < (1<<H); i++){
    for (int j=0; j < (1<<W); j++){
      int cnt =0;
      for (int a=0; a<H; a++){
        for (int b=0; b<W; b++){
          if ((i >> a) & 1 && (j >> b) &1 && table.at(a).at(b) == '#'){
            cnt ++;
          }
        }
      }
      if(cnt==K){ans++;}
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
N = int(input())
slimes = [int(c) for c in input().split()]

cum_sum = [0]
for s in slimes:
    cum_sum.append(cum_sum[-1] + s)
dp = [[0] * N for _ in range(N)]
for L in range(N, -1, -1):
    for R in range(L, N):
        if R - L == 0:
            dp[L][R] = 0
        else:
            dp[L][R] = float('infinity')
            for i in range(L, R):
                dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + cum_sum[R+1] - cum_sum[L])

print(dp[0][N-1])


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

int main(){
  string s,ans="";
  cin >> s;
  vector<bool>aru(26);
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
    return 0;
  }
  for(int i=0;i<s.size();i++)
    aru.at(s.at(i)-'a')=true;
  bool ok=false;
  for(int i=0;i<26;i++){
    if(!aru.at(i)){
      ans=s;
      ans+=i+'a';
      ok=true;
      break;
    }
  }
  if(!ok){
    for(int i=24;i>=0;i--){
      if(s.at(i+1)>s.at(i)){
        if(i==0){
          ans+=s.at(0)+1;
          break;
        }
        ok=true;
        for(int j=0;j<i;j++){
          ans+=s.at(j);
        }
        vector<bool>deta(26,false);
        for(int j=0;j<ans.size();j++)
          deta.at(ans.at(j)-'a')=true;
        deta.at(s.at(i)-'a')=true;
        for(int j=s.at(i)-'a';j<26;j++){
          if(!deta.at(j)){
            ans+='a'+j;
            break;
          }
        }
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;

map<string,int> P;

int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;++i){
    string s;
    cin >> s;
    P[s]=1;
  }
  cout << P.size() << endl;
  return 0;
}


Measured memory_bytes: 18880
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int a,b;
	cin >> a >> b;
	if (a % 500 <= b) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N=in(); int K=in();
  vi h(N);
  rep(i,N) h[i]=in();
  sort(all(h));
  int m=numeric_limits<int>::max();
  rep(i,N){
    if(i+K-1>=h.size()) break;
    if(m>h[i+K-1]-h[i]) m = h[i+K-1] - h[i];
  }
  dump(h,K);
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ab.sort()

ans=0
B=0
cnt=0
for a,b in ab:
    B+=b
    if B<m:
        ans+=a*b
        cnt+=b
    else:
        ans+=a*(m-cnt)
        print(ans)
        exit()

Measured memory_bytes: 27880
// Created by Bingoo on 7/8/2020.
#include"bits/stdc++.h"
using namespace std ;
#define ll  long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

template <class ...Args>
auto &see(const Args &...args) {return ((cerr << " " << args), ...) << '\n';}
#define bug(...)  cerr << "[ "#__VA_ARGS__" ] = "; see(__VA_ARGS__) << '\n';
//C++17
template<typename... Args>
void read(Args&... args){((cin >> args), ...);}
template<typename... Args>
void write(Args... args){((cout << args << " "), ...);}

ll mod = 1e6 +3 ;
ll power(ll a, ll b)	//a is base, b is exponent
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    if (b % 2 == 1)
        return (power(a, b - 1) * a) % mod;
    ll q = power(a, b / 2);
    return (q * q) % mod;
}

bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    return a.second > b.second ;
}

string s;

int a ,b ,t ;

int main(){
    cin >> a >> b >> t ;

    cout << t/a * b <<'\n';
}




Measured memory_bytes: 3592
n = int(input())
a = list(map(int, input().split()))
hen1 = 0
hen2 = 0
hen_list = {}
for i in a:
    if(not i in hen_list):
        hen_list[i] = 0
    hen_list[i] += 1
for k, v in sorted(hen_list.items(), key=lambda x: -x[0]):
    if(v >= 4 and hen1 == 0):
        hen1 = k
        hen2 = k
        break
    if(v >= 2 and hen1 == 0):
        hen1 = k
    elif(v >= 2 and hen2 == 0):
        hen2 = k
    if(hen2!=0):
        break

print(hen1*hen2)


Measured memory_bytes: 25096
// abc138_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> B(N-1);
    REP(i, N-1) cin >> B[i];

    ll ans = B[0];
    REP(i,N-2){
        ans += min(B[i], B[i+1]);
    }
    ans += B[N-2];
    print(ans);



    return 0;
}


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

double d[30][1 << 8], t[8];
vector<P>E[30];
struct st {
	int p, a;
	double c;
};
bool operator<(st a, st b) {
	return a.c > b.c;
}
int main() {
	int n, m, p, a, b;
	while (scanf("%d%d%d%d%d", &n, &m, &p, &a, &b), n) {
		rep(i, m)E[i].clear();
		a--; b--;
		rep(i, n)scanf("%lf", &t[i]);
		rep(i, p) {
			int x, y, z; scanf("%d%d%d", &x, &y, &z);
			x--; y--;
			E[x].push_back(P(z, y)); E[y].push_back(P(z, x));
		}
		priority_queue<st>que;
		fill(d[0], d[m], INF);
		d[a][0] = 0; que.push({ a,0,0 });
		while (!que.empty()) {
			st s = que.top(); que.pop();
			if (d[s.p][s.a] != s.c)continue;
			for (P u : E[s.p]) {
				rep(i, n) {
					if (s.a >> i & 1)continue;
					if (d[u.second][s.a | 1 << i] > s.c + u.first / t[i]) {
						d[u.second][s.a | 1 << i] = s.c + u.first / t[i];
						que.push({ u.second,s.a | 1 << i,d[u.second][s.a | 1 << i] });
					}
				}
			}
		}
		double Min = INF;
		rep(i, 1 << n)Min = min(Min, d[b][i]);
		if (Min == INF)puts("Impossible");
		else printf("%.10lf\n", Min);
	}
}

Measured memory_bytes: 4512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,t;cin>>n>>t;
	vector<pair<int,int>> a(n);
	int x,y;
	for(int i = 0; i < n; i++) {
		cin>>x>>y;
		a[i] = mp(x,y);
	}
	sort(ALL(a));
	vector<vector<int>> dp(n + 1,vector<int>(t + 1,0));
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= t - 1; j++) {
			ans = max(dp[i - 1][j] + a[i - 1].sc,ans);
			if (a[i - 1].fs > j){
				dp[i][j] = dp[i - 1][j];
			}
			else{
				dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - a[i - 1].fs] + a[i - 1].sc);
			}
		}


	}

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

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  string ans = "";
  while(n > 0){
    int amari = n % 26;
    if(amari == 0) ans += 'z', n--;
    else ans += (char)amari - 1 + 'a';
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
fn main() {
    let inputs: Vec<i32> = read_vec();
    let x = inputs[0];
    let y = inputs[1];

    for i in 0..x + 1 {
        let crane = i;
        let turtle = x - i;

        let legs = (crane * 2) + (turtle * 4);
        if legs == y {
            println!("Yes");
            return;
        }
    }

    println!("No");
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2164
from collections import deque

N = int(input())
L = list(map(int,input().split()))

L = sorted(L)
q = deque(L)

while len(q) > 1 :
    a = q.popleft()
    b = q.popleft()
    x = a+b
    x /= 2
    q.appendleft(x)
print(q.popleft())


Measured memory_bytes: 38460
N = int(input())

from math import *

for h in range(1, 3501):
    for n in range(1, 3501):
        try:
            w = N*h*n / (4*h*n - N*n - N*h)
        except:
            continue
        if ceil(w) == floor(w) and w > 0:
            print(h, n, int(w))
            exit()


Measured memory_bytes: 40684
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int,int> P;
struct modint {
	long long num;
	long long p;
	modint() {
		num = 0;
		p = 1000000007;
	}
	modint(int x) {
		p = 1000000007;
		num = (long long)x%p;
	}
	modint(long long x) {
		p = 1000000007;
		num = x % p;
	}
	modint operator*(const long long &other) {
		modint ret;
		ret.p = p;
		ret.num = (num*(other%p)) % p;
		return ret;
	}
	void operator*=(const long long &other) {
		num = (num*other) % p;
	}
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<P> da(n+m);
    rip(i,n,0){
        cin >> da[i].first;
        da[i].second=1;
    }
    rip(i,m,0){
        cin >> da[i+n].first;
        da[i+n].second=0;
    }
	set<int> ch;
	rip(i,n,0){
		if(ch.count(da[i].first)){
			cout << 0 << endl;
			return 0;
		}
		else{
			ch.insert(da[i].first);
		}
	}
	ch.clear();
	rip(i,m,0){
		if(ch.count(da[i+n].first)){
			cout << 0 << endl;
			return 0;
		}
		else{
			ch.insert(da[i+n].first);
		}
	}
    modint ans(1);
    int now=n*m,h=0,w=0,cr=0;
    sort(all(da));
    reverse(all(da));
    int co=0;
	while(co<n+m){
		//printf("%d %d %d %d %d %lld\n",now,co,h,w,cr,ans.num);
		if(now<=0){
			cout << 0 << endl;
			return 0;
		}
		if(da[co].first==now){
			if(co<n*m-1){
				if(da[co+1].first==now){
					h++;
					w++;
					cr++;
					co++;
				}
				else{
					if(da[co].second){
						ans*=w;
						h++;
					}
					else{
						ans*=h;
						w++;
					}
					cr++;
				}
			}
			else{
				if(da[co].second){
					ans*=w;
					h++;
				}
				else{
					ans*=h;
					w++;
				}
			}
			co++;
		}
		else{
			if((h*w)-cr>0){
			ans*=(h*w)-cr;
			cr++;
			}
			else{
				cout << 0 << endl;
				return 0;
			}
		}
		now--;
	}
	rip(i,now+1,1){
		ans*=i;
	}
	cout << ans.num << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

def judge(A,B,C):
    s = S
    a = s.find(A)
    if a < 0:
        return False

    s = s[a+1:]
    b = s.find(B)
    if b < 0:
        return False

    s = s[b+1:]
    c = s.find(C)
    if c < 0:
        return False
    return True

l = '0123456789'
print(sum([int(bool(judge(a,b,c))) for a in l for b in l for c in l]))

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
    int H, N, attack = 0;
    cin >> H >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        attack += A.at(i);
    }
    if(H > attack) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)

class UnionFindTree{

private:
  // indexツづ個青板づ個親ツノツーツド
  vector<int> par;
  // indexツづーツ債ェツづつキツづゥツ姪伉づ個δ可δ督ク
  vector<int> rank;
  // ツ姪伉づ個催妥・ツ値
  int treeSize;
  
public:
  UnionFindTree(int initTreeSize = 1000){
     // ツ暗クツ青板づ与ツつヲツづァツづェツつスツ値ツづーツ催妥・ツ格ツ納ツ青板づつキツづゥUnionFindTreeツづ個催ャツ青ャ
    treeSize = initTreeSize;
    init();
  }
  
  
  void init(){
    
    for(int i = 0; i < treeSize; i++){
      par.push_back(i);
      rank.push_back(0);
    }
    
  }

  // ツ与ツつヲツづァツづェツつスツ青板つェツ格ツ納ツつウツづェツづつ「ツづゥツ姪伉づ個δ仰ーツトツづーツ探ツ催オ
  int find(int x){
    
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
    
  }
  
  void unite(int x,int y){
    
    x = find(x);
    y = find(y);
    
    if(x == y)
      return;
    
    if(rank[x] < rank[y]){
      par[x] = y;
    }
    else{
      par[y] = x;
      if(rank[y] == rank[x]){
	rank[x]++;
      }
    }
    
  }
  
  bool same(int x,int y){
    return find(x) == find(y);
  }

};
class Circle{
public:
	double x,y,z,r;
	Circle(){}
	Circle(double x_,double y_,double z_,double r_){
		x=x_;
		y=y_;
		z=z_;
		r=r_;
	}
};

const int MAX_V = 200;

double cost[MAX_V][MAX_V];
double mincost[MAX_V];
bool used[MAX_V];

int V;
const double INF = 1000000000;

double prim(){
	for(int i = 0; i < V; i++){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	double res = 0;
	while(1){
		int v = -1;
		// Xツづ可堕ョツつウツづ按つ「ツ陳クツ点ツづ個つ、ツつソXツつゥツづァツづ個陛督づ個コツスツトツつェツ催渉ャツづ可づ按づゥツ点ツづーツ探ツつキ
		for(int u = 0; u < V; u++){
			if(!used[u] && (v == -1 || mincost[u] < mincost[v]))
				v = u;
		}
		if(v==-1)
			break;
		used[v] = true;
		res += mincost[v];
		
		for(int u = 0; u < V; u++){
			mincost[u] = min(mincost[u],cost[v][u]);
		}
	}
	return res;
}


int main(){

	int n;
	while(cin>>n&&n!=0){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cost[i][j]=INF;
			}
		}
		V=n;
		vector<Circle> vc;
		for(int i = 0; i < n; i++){
			Circle c;
			cin>>c.x>>c.y>>c.z>>c.r;
			vc.push_back(c);
		}
		UnionFindTree uft(n);
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				//if(i==j)
				//	continue;
				double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
					+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
					+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
				// ツ重ツづ按づづつ「ツづゥ
				if(EQ(dist,(vc[i].r+vc[j].r))||(dist<(vc[i].r+vc[j].r))){
					uft.unite(i,j);
					//break;
				}
			}
		}
		// ツ重ツづ按づづつ「ツづゥツづÍRXg0Ìm[hð£ÁÄ¨­
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i==j)
					continue;
				if(uft.same(i,j)){
					cost[i][j]=0;
				}
				else{
					double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
						+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
						+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
					cost[i][j]=dist-(vc[i].r+vc[j].r);
					//if(cost[i][j]<0)
					//	cost[i][j]=0;
				}
			}
		}
		double res=prim();
		printf("%.3f\n",res);
	}


	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    int a=n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9) cout<<"hon"<<endl;
    else if(a==0 || a==1 || a==6 || a==8) cout<<"pon"<<endl;
    else cout <<"bon"<<endl;
}


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

int main() {
    
    int a, b, c;
    cin >> a >> b >> c;

    int m = 0;
    unordered_map<string, bool> um;
    while(!(a & 1) and !(b & 1) and !(c & 1)) {
        int ahalf = a/2;
        int bhalf = b/2;
        int chalf = c/2;
        int na = bhalf + chalf;
        int nb = ahalf + chalf;
        int nc = ahalf + bhalf;
        string s = to_string(na) + " " +  to_string(nb) + " " + to_string(nc);
        if (um[s]) {
            cout << -1 << endl;
            return 0;
        }
        um[s] = true;
        a = na;
        b = nb;
        c = nc;

        m++;
    }
    
    cout << m << endl;


    return 0;
}

Measured memory_bytes: 3672
S = input()
l = len(S)
ans = 0

for i in range(2**(l-1)):
    T = S[0]
    for j in range(l-1):
        if i>>j & 1:
            T = T + ""
        else:
            T = T + "+"
        T = T+S[j+1]
    ans += eval(T)
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,now;
    cin >> n;
    vector<int> c(n),s(n),f(n);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n){
        now = 0;
        rep(j,i,n-1){
            if (now < s[j]) now = s[j];
            else{
                int wait = 0;
                while(now > wait){
                    wait += f[j];
                }
                now = wait;
            }
            now += c[j];
        }
        PRINT(now);
    }
}


Measured memory_bytes: 256
#include<cstdio>

#define gec     getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)

typedef long long ll;
template<typename T>
inline void read(T &x)
{
	x=0;bool f=0; char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}

namespace IO
{
inline void fpr(char *c){fprintf(stderr,"%s\n",c);}
inline void fpr(int           x,char *c){fprintf(stderr,"[ %s ] : = %d   \n",c,x);}
inline void fpr(ll            x,char *c){fprintf(stderr,"[ %s ] : = %lld \n",c,x);}
inline void fpr(double        x,char *c){fprintf(stderr,"[ %s ] : = %.5lf\n",c,x);}
inline void fpr(long double   x,char *c){fprintf(stderr,"[ %s ] : = %.5Lf\n",c,x);} 
}using namespace IO;


const int MAXN(200010);
int n,m,a[MAXN],cnt[MAXN],num[MAXN],Ans;

int main()
{
	read(n);read(m);
	for(int i=1;i<=n;i++)read(a[i]),cnt[a[i]]++;
	for(int i=1,L,R;i<=n;i++)
	{
		L=i-cnt[i]+1; if(L<1)L=1;
		R=i;while(L<=R)num[L]++,++L;
	}
	for(int i=1;i<=n;i++)if(!num[i])Ans++;
	for(int i=1,x,y,L,last;i<=m;i++)
	{
		read(x);     read(y);
		if(a[x]==y){printf("%d\n",Ans);continue;}
		last=a[x];   a[x]=y;
		cnt[last]--; cnt[y]++;
		L=last-cnt[last];
		if(L>0) num[L]--,Ans+=(num[L]==0);
		L=y-cnt[y]+1;
		if(L>0) num[L]++,Ans-=(num[L]==1);
		printf("%d\n",Ans);
	}
	return 0;
}	

Measured memory_bytes: 3840
[a1,b1] = [int(i)-1 for i in input().split()]
[a2,b2] = [int(i)-1 for i in input().split()]
[a3,b3] = [int(i)-1 for i in input().split()]

s = [a1,a2,a3,b1,b2,b3]

route = {0:0,1:0,2:0,3:0}
for i in s:
    route[i] += 1
#print(route)
ok = 1
for i in range(4):
    if route[i] != 1 and route[i] != 2:
        ok = 0

if ok == 1:
    print("YES")
else:
    print("NO")


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll p = 26, sz = 1;
  while (p < n) {
    n -= p;
    p *= 26;
    sz++;
  }
  string sol;
  n--;
  for (int i = 0; i < sz; i++) {
    sol += (char) ('a' + n % 26);
    n /= 26;
  }
  reverse(sol.begin(), sol.end());
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int freq[10][10], n, x, y;
long long res;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        x = i, y = x % 10;
        while (x >= 10)
            x /= 10;
        ++freq[x][y];
    }
    for (int i = 1; i < 10; ++i)
        for (int j = 1; j < 10; ++j)
            res += freq[i][j] * freq[j][i];
    cout << res;
    PLEC
}


Measured memory_bytes: 256
def five(x):
    cnt1 = 0
    while x%5==0:
        cnt1+= 1
        x = x//5
    cnt2 = 0
    while x%2==0:
        cnt2+= 1
        x = x//2
    return (min(cnt1,18), min(cnt2,18))

N = int(input())

F = []
for i in range(N):
    A = float(input())
    A = round(A*(10**9))
    F.append(five(A))

F.sort()
# print(F)
j = 0
temp = 0
dp = [0]*19
k = 0
for i in range(N-1):
    if N-1-j < i:
        dp[min(F[i][1], 18)] -= 1
        # print(i, N - j - 1, dp)
    while N-1-j> i and F[i][0]+F[N-1-j][0] >= 18:
        dp[min(F[N-1-j][1],18)] += 1
        # print(i, N - j - 1, dp)
        j += 1
    k = sum(dp[:18-F[i][1]])
    temp += min(j, N-i-1) - k
    # print(j, N-i-1, k, temp)

print(temp)

"""
5
1
1
1
1
1
"""

Measured memory_bytes: 90048
#include <stdio.h>
#include <stdlib.h>

int func( int* va, int size, int num, int s, int* count) {
	int i, sum;
	if (size<=num) {
		sum =0;
		for(i=0;i<size;i++) {
			sum += *(va+ i*4);
		}
		if (sum == s) (*count)+=1;
		//printf("%d\n", sum);
		return 0;
	}else if (num>0) {
		for( i = *(va + (num-1) *4) + 1; i<=9; i++) {
			*(va + num*4)=i;
			func( va, size, num+1, s, count);
		}
	}else {
		for( i=0; i<9; i++) {
			*(va) = i;
			func( va, size, 1, s, count);
		}
	}
	return 0;
}

int main() {
	int *a;
	int n, s, c, ret;
	while(1) {
		scanf("%d %d", &n, &s);
		if ( (n==0)&&(s==0) ) break;
		c = 0;
		a = (int *)malloc( sizeof(int) * n );
		func( a, n, 0, s, &c);
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const Int MAX = 55;
Int dp[MAX][MAX][MAX];
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n),b(n),c(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];

  const Int INF = 1e9;
  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX;j++)
      for(Int k=0;k<MAX;k++)
	dp[i][j][k]=-INF;

  dp[0][m][0]=0;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<=m;j++){
      for(Int k=0;k<10;k++){
	for(Int x=0;x<10;x++){
	  if(j-x<0) continue;
	  Int res=c[i];
	  if(k) chmax(res,b[i]);
	  if(x) chmax(res,a[i]);

	  if(a[i]>=0&&x){
	    Int cnt=8;
	    Int tmp=a[i]*min(cnt,x);
	    cnt-=min(cnt,x);
	    tmp+=max((Int)0,b[i])*min(cnt,k);
	    chmax(res,tmp);
	  }
	  if(b[i]>=0&&k){
	    Int cnt=8;
	    Int tmp=b[i]*min(cnt,k);
	    cnt-=min(cnt,k);
	    tmp+=max((Int)0,a[i])*min(cnt,x);
	    chmax(res,tmp);
	  }
	  chmax(dp[i+1][j-x][x],dp[i][j][k]+res);
	}
      }
    }
  }

  Int ans=-INF;
  for(Int j=0;j<=m;j++)
    for(Int k=0;k<10;k++)
      chmax(ans,dp[n][j][k]);

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



Measured memory_bytes: 4448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  for(int i = 0; i < 4; i++) cout << s[i];
  cout << " ";
  for(int i = 4; i < s.size(); i++) cout << s[i];
  cout << endl;
 return 0;
}

Measured memory_bytes: 256
N = int(input())
lis = map(int, input().split())
judge = True
for i in lis:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            judge = False
    else:
        pass
if judge == True:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    int N,K;cin>>N>>K;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    ll ans = 0;
    K = min(K,2*N);
    rep(i,K+1) {
        for (int j = (i+1)/2;j<min(i+1,N+1);j++) {
            for (int k = 0;k<j+1;k++) {
                priority_queue<int,vector<int>,greater<int>> qu;
                ll sum = 0;
                for (int p = 0;p<k;p++) {
                    sum+=v[p];
                    qu.push(v[p]);
                }
                for(int p = N - 1;p>N-1-j+k;p--) {
                    sum+=v[p];
                    qu.push(v[p]);
                }
                rep(p,i-j) {
                    sum -= qu.top();
                    qu.pop();
                }
                ans = max(ans,sum);
                // if(i==19) {
                //     cout<<k<<" "<<ans<<endl;
                // }
            }
        }
        // cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int data[51][51];
int dx[8] = {-1,-1,0,1,1,1,0,-1};
int dy[8] = {0,1,1,1,0,-1,-1,-1};

int h,w;
bool inrange(int x,int y){
	if(x<0||y<0||x>h-1||y>w-1) return false;
	else return true;
}

bool search(int x,int y){
	bool rst = false;
	if(data[x][y] == 0) return rst;
	else {
		data[x][y] = 0;
		rst = true;
	}
	REP(i,8){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(!inrange(nx,ny)) continue;
		search(nx,ny);
	}
	return rst;
}

int main(){
	while(1){
		cin >> w >> h;
		if(w==0&&h==0) break;
		int ans = 0;
		REP(i,h) REP(j,w) cin >> data[i][j];
		REP(i,h){
			REP(j,w){
				if(search(i,j)==true) ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1236
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		sc.fill(a, b);

		Set<Integer> left = new HashSet<>();
		Set<Integer> right = new HashSet<>();
		for (int i = 0; i < M; i++) {
			if (a[i] == 1) {
				left.add(b[i]);
			}
			if (b[i] == N) {
				right.add(a[i]);
			}
		}

		left.retainAll(right);
		System.out.println(left.size() > 0 ? "POSSIBLE" : "IMPOSSIBLE");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 51412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

class BIT{
public:
	vector<int> bit;
	int M;
	// 1-index
	BIT(int M):
		bit(vector<int>(M+1, 0)), M(M) {}

	int sum(int i) {
		if (!i) return 0;
		return bit[i] + sum(i-(i&-i));
	}

	void add(int i, int x) {
		if (i > M) return;
		bit[i] += x;
		add(i+(i&-i), x);
	}
};

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

	int N;
	cin >> N;
	vector< pair<int,char> > v(2*N+1);
	vector<int> B(N+1),W(N+1);
	int dp[N+1][N+1];
	FOR(i,0,N+1)FOR(j,0,N+1)dp[i][j]=MOD;

	FOR(i,1,2*N+1){
		int a;
		char c;
		cin >> c >> a;
		v[i] = {a,c};
		if(c=='B')B[a] = i;
		if(c=='W')W[a] = i;
	}

	dp[0][0] = 0;
	BIT bit(2*N);
	FOR(i,1,N+1)bit.add(B[i],1);
	FOR(b,0,N+1){
		FOR(i,1,N+1)bit.add(W[i],1);
		if(b!=0)bit.add(B[b],-1);
		FOR(w,0,N+1){
			if(w!=0)bit.add(W[w],-1);
			if(b<N)dp[b+1][w] = min( dp[b+1][w] , dp[b][w] + bit.sum(B[b+1]) - 1 );
			if(w<N)dp[b][w+1] = min( dp[b][w+1] , dp[b][w] + bit.sum(W[w+1]) - 1 );
		}
	}
	cout << dp[N][N] << "\n";
}

Measured memory_bytes: 16000
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

    ans = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)
            if ans == 0:
                return 0

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060