akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
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

#A
def A():
    a,b = LI()
    print(max(a+b,a-b,a*b))
    return

#B
def B():
    k,x = LI()
    ans = []
    for i in range(x-k+1,x+k):
        ans.append(i)
    print(*ans)
    return

#C
def C():
    def f(s):
        res = [0]*m
        for i in s:
            res[alp.index(i)] += 1
        return res
    alp = list("abcdefghijklmnopqrstuvwxyz")
    m = len(alp)
    n = I()
    s = [input() for i in range(n)]
    d = defaultdict(lambda : 0)
    for i in s:
        d[tuple(f(i))] += 1
    ans = 0
    for i in d.values():
        ans += (i*(i-1))//2
    print(ans)
    return

#D
def D():
    n,m = LI()
    g = LIR(n)
    g.sort(key = lambda x:x[0])
    ans = 0
    f = [1]*n
    j = 0
    q = []
    for i in range(m)[::-1]:
        while j < n and m-g[j][0] >= i:
            a,b = g[j]
            heappush(q,(-b,a))
            j += 1
        if q:
            x,a = heappop(q)
            if i+a <= m:
                ans -= x
    print(ans)
    return

#E
def E():
    def dfs(x,f):
        for y,w in v[x]:
            if f[y]:
                if dp[y] < dp[x]+w:
                    f[y] = 0
                    dp[y] = dp[x]+w
                    dfs(y,f)
                    f[y] = 1
            else:
                if dp[y] < dp[x]+w:
                    dp[y] = float("inf")
                    dfs(y,f)
    n,m,p = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b,c = LI()
        a -= 1
        b -= 1
        v[a].append((b,c-p))
    f = [1]*n
    dp = [-float("inf")]*n
    dp[0] = 0
    f[0] = 0
    dfs(0,f)
    ans = dp[n-1]
    if ans == float("inf") or ans == -float("inf"):
        print(-1)
    elif ans < 0:
        print(0)
    else:
        print(ans)
    return

#F
def F():

    return

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


Measured memory_bytes: 9716
import kotlin.math.*

fun int() = readLine()!!.toInt()
fun ints() = readLine()!!.split(" ").map {it.toInt()}.toIntArray()

fun triangle(n:Int) = n*(n+1)/2

fun main() {
	abc000X()
}

fun abc000X() {
	val day = int()
	val days = 0 until day
	val types = 0..25

	val penalty = ints()
	fun calcPenalty(type:Int,deltad:Int) = penalty[type]*triangle(deltad)

	val advantage = Array(day) {ints()}

	val result = (0..364).asSequence().map {k->
		var r = 0L
		val t = IntArray(day) {-1}
		val last = IntArray(26) {-1}

		for(d in days) {
			val e = min(364,d+k)

			val base = types.sumBy {calcPenalty(it,e-last[it])}

			val ct = types.maxBy {advantage[d][it]-base+calcPenalty(it,e-last[it])-calcPenalty(it,d-last[it])-calcPenalty(it,k)}!!
			r += advantage[d][ct]-calcPenalty(ct,d-1-last[ct])
			t[d] = ct
			last[ct] = d
		}

		for(ct in types)
			r -= calcPenalty(ct,364-last[ct])

		t to r
	}.maxBy {it.second}!!

	System.err.println(result.second)
	result.first.forEach {println(it+1)}
}


Measured memory_bytes: 51036
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n, d, ans;
        cin >> n >> d;
        if(n % 2) ans = d;
        else ans = 127 xor d;
        cout << ans + 127 * (n - 1) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];

int main() {
    int h,w,n;
    cin >> h >> w;
    cin >> n;
    vector<int> a(n+10),b(h*w+10);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int j1 = 0;
    for (int i = 0; i < n; ++i) {
        while(a[i]--){
            b[j1] = i+1;
            j1++;
        }
    }
    vector<vector<int>> c(h,vector<int>(w,0));
    j1 = 0;
    for (int i = 0; i < h; ++i) {
        if(i %2 == 0){
            for (int j = 0; j < w; ++j) {
                c[i][j] = b[j1];
                j1++;
            }
        }else{
            for (int j = w-1; j >= 0; --j) {
                c[i][j] = b[j1];
                j1++;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(j != w-1) cout << c[i][j] << " ";
            else cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define N 500000
#define M 2000000000

int count,S[N],L[N/2+2],R[N/2+2];

void mergeSort(int * ,int ,int);

void merge(int * ,int ,int ,int);

int main()
{
  int n,i;

  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}
void merge(int *S,int left,int mid,int right){
  int i,j,k;
  int l,r;

  l=mid-left;
  r=right-mid;

  for(i=0;i<l;i++)
    L[i]=S[left+i];
  for(i=0;i<r;i++)
    R[i]=S[mid+i];

  L[l]=M;
  R[r]=M;

  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j])S[k]=L[i++];
    else S[k]=R[j++];
  }
}

void mergeSort(int *S,int left,int right){
  int mid;
 
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}


Measured memory_bytes: 5672
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a >= 10||b>=10) {
		printf("-1\n");
	}
	else {
		printf("%d\n", a * b);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0){
				break;
			}
			int[] a = new int[100];
			for(int i = 0; i < n;i++){
				int d = cin.nextInt();
				d /= 10;
				a[d]++;
			}
			for(int i = 0; i < 6;i++){
				System.out.println(a[i]);
			}
			int sum=0;
			for(int i = 6; i < a.length; i++){
				sum += a[i];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  int a,b,c,tem;
  cin>>a>>b>>c;
  tem=b/a;
  if(tem>c)cout<<c<<endl;
  else cout<<tem<<endl;
}
void solveH()
{
  int a,b,c,tem,i;
  cin>>a>>b>>c;
  tem=min(a,b);
  vector<int>vec;
  for(i=1;i<=tem;i++)
  {
    if(a%i==0&&b%i==0)
    {
      vec.push_back(i);
    }
  }
  cout<<vec[vec.size()-c]<<endl;
}
void solveI()
{
  double t,x;
  cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
}
void solveJ()
{
  int n,i;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  sort(ar,ar+n);
  int sum=0;
  for(i=0;i<n-1;i++)
  {
    sum=sum+ar[i];
  }
  if(ar[n-1]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
void solveK()
{
  int A,B,x,y;
  cin>>A>>B;
  x=max((A+B),(A-B));
  y=max(x,A*B);
  cout<<y<<endl;
}
void solveM()
{
  int i,j;
  char ar[3][3];
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      cin>>ar[i][j];
    }
  }
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      if(i==j)cout<<ar[i][j];
    }
  }
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 //solveF();
// solveG();
//solveH();
//solveI();
//solveJ();
//solveK();
solveM();
  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    ll ans=1;
    REP(i,1,n+1){
        ans*=i;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;

   
char temp;
   ll H,W,K;
   ll black = 0;
   ll white = 0;
   ll ans = 0;
  
    cin >> H>>W>>K;

 vector<vector <char> > a(H, vector<char>(W));

  rep(i,H){
      rep(j,W){
          cin >> temp;
          a[i][j]=temp;
          if(temp == '.')white++;
          else if (temp == '#')black++;
      }
  }


if(black<K){
    cout<<0<<endl;
    return 0;
}

ll count=0;
for (int bit = 0; bit < (1<<H); ++bit)
    {
        for (int bit1 = 0; bit1 < (1<<W); ++bit1)
    {
        count = 0;
        rep(i,H){
            rep(j,W){
                if(a[i][j]== '#' && !(bit & (1<<i)) && !(bit1 & (1<<j))){
                    count++;
                }
            }
        }
        if(count == K)ans++;

    }

    }
  
cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    string s;cin >> s;
    string a;
    for(int i = 0; i < 4; i++){
        a.push_back(s[i]);
    }
    a.push_back(' ');
    for(int i = 4; i < s.size(); i++){
        a.push_back(s[i]);
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}


int dp[41][401][401];
int a[41];
int b[41];
int c[41];

int main(){
    cin.tie(0);

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

    int INF = 100000000;
    fill(dp[0][0], dp[41][0], INF);
    dp[0][0][0] = 0;
    for (int i = 1; i <= 40; i++){
        for (int j = 0; j < 401; j++){
            for (int k = 0; k < 401; k++){
                if (dp[i-1][j][k] == INF) continue;
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
                if (j + a[i-1] <= 400 && k + b[i-1] <= 400){
                    dp[i][j+a[i-1]][k+b[i-1]] = min(dp[i][j+a[i-1]][k+b[i-1]], dp[i-1][j][k] + c[i-1]); 
                }     
            }
        }
    }
    int ans = INF;
    for (int j = 1; j < 401; j++){
        for (int k = 1; k < 401; k++){
            if (j*Mb == k*Ma){
                ans = min(ans, dp[N][j][k]);
            }                 
        }
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <tuple>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#pragma GCC target ("avx2")

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  	return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  	cin.tie(0);
  	cout.tie(0);
  	ios::sync_with_stdio(false);
	
	long long n, ans = 0;
	cin >> n;
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	ans += n / 10;
	n /= 10;
	while(n){
		ans += n / 5;
		n /= 5;
	}
	cout << ans << endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main ()
{
  string S;
  cin>>S;
  int n=S.size();
   for(int i=0;i<(n-1)/2;i++)
  {
    if(S[i]!=S[n-i-1]||S[i]!=S[((n-1)/2)-i-1]||S[((n+3)/2)+i-1]!=S[n-i-1])
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    int ans;
    if (s == "SUN"){
        ans = 7;
    }
    if (s == "MON"){
        ans = 6;
    }
    if (s == "TUE"){
        ans = 5;
    }
    if (s == "WED"){
        ans = 4;
    }
    if (s == "THU"){
        ans = 3;
    }
    if (s == "FRI"){
        ans = 2;
    }
    if (s == "SAT"){
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum = 0
i = 0
j = 0

while (sum + A[i]) <= K:
  sum += A[i]
  i += 1
  if i >= N:
    break
  
while (sum + B[j]) <= K:
  sum += B[j]
  j += 1
  if j >= M:
    break
  
max = i + j

if max == M+N:
  print(max)
else:
  while (0 < i and j < M):
    sum -= A[i-1] 
    i -= 1
    while (sum + B[j]) <= K:
      sum += B[j]
      j += 1
      if j >= M:
        break
    if (i + j) > max:
      max = (i + j)
  print(max)


  
  

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

// a[i] が [0, b[i]) の範囲を動く a.size() 重ループ（a[0] が一番内側）
bool next_array(vector<int> & a, const vector<int> & b) {
	int d = a.size();
	inc(i, d + 1) {
		if(i == d) { return false; }
		a[i]++;
		if(a[i] == b[i]) { a[i] = 0; } else { break; }
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	
	int ans = 0;
	incII(d, 3, 9) {
		vector<int> a(d), b(d, 3);
		do {
			if(
				count(ALL(a), 0) == 0 ||
				count(ALL(a), 1) == 0 ||
				count(ALL(a), 2) == 0
			) { continue; }
			
			int v = 0, x[] = { 3, 5, 7 };
			dec(i, d) { v = 10 * v + x[a[i]]; }
			
			if(v <= n) { ans++; } else { break; }
		} while(next_array(a, b));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

// (x,y)
typedef pair<int,int> P;
// ( 速度 , (前の町,今の町) )
typedef pair<int,P> Node;
// (cost,Node)
typedef pair<double,Node> State;

const int MAX_V = 31;
const double INF = 1e200;

struct edge{
	int to, d, c;
	edge(int to_, int d_, int c_){
		to = to_; d = d_; c = c_;
	}
};

// グラフ
vector<edge> G[MAX_V];
// スタートからゴールに辿りつけるかどうか
bool memo[MAX_V];
bool is_connect;

// 入力
int n, m;

// 初期化
void init(){
	is_connect = false;
	for(int i=0 ; i < MAX_V ; i++ ){
		G[i].clear();
	}
}

// 辺の追加
void add_edge(int x, int y, int d, int c){
	edge e( y , d , c );
	G[x].push_back( e );
	e.to = x;
	G[y].push_back( e );
}

// スタートからゴールに辿りつけるかどうかチェック
void check(int v, int g){
	if( v == g ){
		is_connect = true;
	}
	if( memo[v] ) return;
	memo[v] = true;
	
	for(int i=0 ; i < G[v].size() ; i++ ){
		int to = G[v][i].to;
		if( memo[to] ) continue;
		check( to , g );
	}
}

// ダイクストラ法
double solve(int s, int g){
	// d[v][x][y] := 速度v, 前の町x, 今の町yまでの最小コスト
	double d[31][31][31];
	// 訪れたかどうか
	bool visited[31][31][31];
	// 初期化
	for(int y=0 ; y < MAX_V ; y++ ){
		for(int x=0 ; x < MAX_V ; x++ ){
			for(int v=0 ; v < 31 ; v++ ){
				d[v][y][x] = INF;
				visited[v][y][x] = false;
			}
		}
	}
	
	// State := (cost,Node), Node := ( 速度 , (前の町,今の町) )
	priority_queue< State, vector<State> , greater<State> > q;
	for(int i = 0 ; i < G[s].size() ; i++ ){
		int to = G[s][i].to;
		double dis = G[s][i].d;
		
		Node start( 1 , P(s,to) );
		q.push( State(dis,start) );
		d[1][s][to] = dis;
	}
	
	double ans = INF;
	int cnt=0;
	while( !q.empty() ){
		//cnt++;
		//if( cnt >= 2000000 ) break;
		
		// 値を取り出す
		double now_cost = q.top().first;
		int v = q.top().second.first;
		int x = q.top().second.second.first;
		int y = q.top().second.second.second;
		q.pop();
		
		if( now_cost >= ans || visited[v][x][y] ) continue;
		visited[v][x][y] = true;
		
		// 目的地のとき
		if( y == g && v == 1 ){
			ans = min( ans , now_cost );
			break;
		}
		
		for(int i=0 ; i < G[y].size() ; i++ ){
			int to = G[y][i].to;
			int dis = G[y][i].d;
			int c = G[y][i].c;
			if( to == x ) continue;
			
			for(int dv = -1 ; dv <= 1 ; dv++ ){
				int next_v = v + dv;
				if( next_v > c || next_v <= 0 ) continue;
				
				double cost = (double)dis / next_v;
				if( now_cost + cost < d[next_v][y][to] ){
					d[next_v][y][to] = now_cost + cost;
					
					Node next( next_v , P(y,to) );
					State p( now_cost + cost , next );
					q.push( p );
				}
			}
		}
	}
	return ans;
}

int main(){
	while( scanf("%d %d", &n, &m) , n || m ){
		// 初期化
		init();
		
		int s, g;
		cin >> s >> g;
		
		for(int i=0 ; i < m ; i++ ){
			int x, y, d, c;
			scanf("%d %d %d %d", &x, &y, &d, &c );
			add_edge( x , y , d , c );
		}
		
		{
			// スタートからゴールに辿りつけるかどうか
			for(int i=0 ; i < MAX_V ; i++ ){
				memo[i] = false;
			}
			check( s , g );
		}
		
		// ゴールに辿りつけないとき
		if( is_connect == false ){
			puts("unreachable");
		}else{
			double ans = solve( s , g );
			printf("%.4f\n", ans );
		}
	}
}

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

int main(){
	int N, Q;
	string S;
	cin >> N >> Q >> S;
	vector<int> l(Q), r(Q),A(N);
	for (int i = 0; i < Q; i++)
	{
		cin >> l.at(i) >> r.at(i);
	}
	for (int j = 0; j < N-1; j++)
	{	
		if (S.at(j) == 'A'&&S.at(j+1) == 'C') {
			A.at(j+1) = A.at(j) + 1;
		}
      	else
          A.at(j+1) = A.at(j);
	}
	for (int k = 0; k < Q; k++)
	{
		cout << A.at(r.at(k)-1) - A.at(l.at(k)-1) << endl;
	}
}

Measured memory_bytes: 2176
#!/usr/bin/env python3

def main():
    n, k = map(int, input().split())
    arr = sorted([list(map(int, input().split())) for i in range(n)])
    for ab in arr:
        k -= ab[1]
        if k <= 0:
            ans = ab[0]
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 28260
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <deque>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e15;

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	fast();
	string s;
	cin >> s;
	if (s.back() == 's')
		cout << s << "es" << '\n';
	else
		cout << s << "s\n";
	return 0;
}

Measured memory_bytes: 3636
class UnionFind:
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def all_group_members(self):
        dic = {}
        for x in range(self.N):
            r = self.find(x)
            dic.setdefault(r, [])
            dic[r].append(x)
        return dic

H,W=map(int, input().split())
S=[input() for _ in range(H)]
D=[1,0,-1,0,1]
UF=UnionFind(H*W)
for i in range(H):
    for j in range(W):
        for k in range(4):
            x=i+D[k]
            y=j+D[k+1]
            if 0<=x<H and 0<=y<W:
                if S[i][j]!=S[x][y]:
                    UF.union(x*W+y,i*W+j)
ans=0
for g in UF.all_group_members().values():
    w=0
    b=0
    for v in g:
        x,y=divmod(v,W)
        if S[x][y]=="#":
            b+=1
        else:
            w+=1
    ans+=w*b
print(ans)

Measured memory_bytes: 30240
#include <stdio.h>

int search(int A[],int n,int key){
 int i = 0;
 int a = 0;
 A[n] = key;


  while(A[i] != key){
    i++;
 }
 if(i != n)
   a = 1;
 return a;

}


int main(){
 int i, n, q, S[10000+1], c , key= 0;
 
 scanf("%d",&n);
 for(i = 0;i < n;i++){
   scanf("%d ",&S[i]);
  }
 scanf("%d",&q);
 for(i = 0;i < q;i++){
   scanf("%d ",&key);
   if(search(S, n, key) == 1)
      c++;
 }

 printf("%d\n",c);
 return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));


vpll prime_fac(ll x){
    vpll ans;
    ll tmp = 0;
    ll s = sqrt(x);
    while(x % 2 == 0){
        x /= 2;
        tmp++;
    }
    if (tmp > 0) ans.emplace_back(pll{2, tmp});
    for(ll y = 3; y <= s; y += 2){
        tmp = 0;
        while(x % y == 0){
            x /= y;
            tmp++;
        }
        if (tmp > 0) ans.emplace_back(pll{y, tmp});
    }
    if (x>1) ans.emplace_back(pll{x, 1});
    return ans;
}

int main(){
    ll n, max;
    cin >> n;
    REP(i,sqrt(n)){
        if(n%(i+1)==0) max = i+1;
    }
    cout << max + n/max - 2 << endl;
    return 0;
}


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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        int a,b;
        cin>>a>>b;
        cout<<max(a-(2*b),0);
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define replb(i,a,b) for(ll i=a;i>=b;i--)
#define repl(i,a,b) for(ll i=a;i<b;i++)
#define repit(arr)  for(auto it=arr.begin();it!=arr.end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set <int>
#define setl set <ll>
#define dseti set <int, greater <int> >
#define dsetl set <ll, greater <ll> >
#define mseti multiset <int>
#define msetl multiset <ll>
#define dmseti multiset <int, greater <int> >
#define dmsetl multiset <ll, greater <ll> >
#define sortA(arr)   sort(arr.begin(),arr.end())
#define ssort(arr) stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int gcd(int a,int b){
    if (a < b) swap(a, b);
    if (b == 0) return a;
    else return gcd(b, a % b);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,x,S=0;cin>>n;vi V;
    rep(i,0,n){
        cin>>x;S^=x;V.pb(x);
    }
    rep(i,0,n){
        cout<<(S^(V[i]))<<' ';
    }
    return 0;
}

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

int main() {
  string n;
  cin >> n;
  
  char l = n.at(n.size()-1);
  if(l == '3') cout << "bon" << endl;
  else if(l == '0' || l == '1' || l == '6' || l == '8') cout << "pon" << endl;
  else if(l == '2' || l == '4' || l == '5' || l == '7' || l == '9') cout << "hon" << endl;
  
}



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

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a > b;
}

int gcd(int x, int y){
    return x % y == 0 ? y : gcd(y, x % y);
}

int main(){
    int n;
    scanf("%d", &n);
    int d[100005];
    memset(d, 0, sizeof(d));
    for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
    sort(d + 1, d + n + 1);
    if (n & 1) printf("0\n");
    else printf("%d\n", d[n / 2 + 1] - d[n / 2]);
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N, A; cin >> N >> A;
    cout << N * N - A << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll n,a,b;cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}


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

double calc(int m, int v[], double r[]) {
  double a,b = 0.0;
  a = b = 0;
  for(int i = 0; i < m; ++i) {
    a += r[i];
    b += r[i]*v[i];
  }
  return b/a;
}

int main() {
  int t;
  cin >> t;
  ++t;
  double maxE = 0.0;
  int n, m, v[100];
  double r[100];
  while(t--) {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) cin >> v[i] >> r[i];
    if(t == 0) {
      if(maxE - calc(m,v,r) > 0.0000001) cout << "YES" << endl;
      else cout << "NO" << endl;
    } else {
      maxE = max(maxE, calc(m,v,r));
    }
  }

  return 0;
}

Measured memory_bytes: 0
def kawaiso(a, b, c):
  if (a == b and b != c) or (b == c and c != a) or (c == a and a != b):
    return 'Yes'
  else:
    return 'No'
 
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
 
print(kawaiso(a, b, c))

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
      List<int> lst = (new List<string>(Console.ReadLine().Split(' '))).ConvertAll(x => int.Parse(x));
        int ret = 0;
        if (lst[0]>= lst[1]) {
            ret = 10;
        }
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
// #include"prettyprint.hpp"
typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    ll n, mxw;
    cin >> n >> mxw;
    ll w[n], v[n];
    for (ll i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    // debug(arr(w, n));
    // debug(arr(v, n));
    vector<ll> dp(mxw + 1, 0);
    dp[w[0]] = v[0];
    // debug(dp);
    for (int i = 1; i < n; ++i) {
        for (int j = mxw; j >= 1; --j) {
            if (dp[j]) {
                ll sum_w = j + w[i];
                if (sum_w > mxw) continue;
                ll sum_v = dp[j] + v[i];
                dp[sum_w] = max(dp[sum_w], sum_v);
            }
        }
        dp[w[i]] = max(dp[w[i]], v[i]);
        // debug(dp);
    }
    ll ans = 0;
    for (int i = mxw; i >= 1; --i) {
            ans = max(ans, dp[i]);
    }
    cout << ans << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> players(N);
  ll i;
  int tmp;
  for(i=0;i<Q;i++)
    {
      cin >> tmp;
      players[tmp-1]+=1;
    }
  for(i=0;i<N;i++)
    {
      tmp=players[i];
      tmp=tmp+K-Q;
      if(tmp>0)
	cout << "Yes" <<endl;
      else
	cout<< "No" << endl;
    }



  return 0;
}



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

int main(){
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, m;
    cin >> n >> m;
    pii students[n];
    forn(i, n) {
        int x, y;
        cin >> x >> y;
        students[i] = {x, y};
    }
    pii checkpoints[m];
    forn(i, m) {
        int x, y;
        cin >> x >> y;
        checkpoints[i] = {x, y};
    }
    int ans[n];
    forn(i, n) {
        int mindis = 1e9;
        int ind = 0;
        forn(j, m) {
            int x1 = students[i].F, y1 = students[i].S, x2 = checkpoints[j].F, y2 = checkpoints[j].S;
            if (abs(x1 - x2) + abs(y1 - y2) < mindis) {
                mindis = abs(x1 - x2) + abs(y1 - y2);
                ind = j;
            }
        }
        ans[i] = ind + 1;
    }
    forn(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<string>
#include<map>
#include <algorithm>
#include <cmath>
#include<vector>
#include<stack>
#define INF 0x3f3f3f3f  
#define maxn 1000000+10
using namespace std;

string s;
int a[3];
int main()
{
	cin >> s;
	int j = 0;
	for (int i = 0; i < 3; i++)
		a[s[i] - 'a']++;
	for(int i=0;i<3;i++)
		if (a[i] == 0)
		{
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>

#line 1 "lib/modint.hpp"



#include <iostream>

// Modint
struct Mint {
    static const long long mod = 998244353;
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, int b) {
    return a.pow(b);
}


int main() {
    int n, s; std::cin >> n >> s;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::vector<Mint> dp(s + 1);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = s; j >= 0; j--) {
            if (j + a[i] <= s) dp[j + a[i]] += dp[j];
            dp[j] += dp[j];
        }
    }
    std::cout << dp[s] << std::endl;
    return 0;
}


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

int main(){
  	string t;cin >> t;
  	
  	if(t=="Sunny"){
    	cout << "Cloudy";
    }else if(t=="Cloudy"){
    	cout << "Rainy";
    }else{
    	cout << "Sunny";
    }
  
  	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if((b-a)&1)printf("%lld",min((unsigned long long)((n<<1)-a-b+1),(unsigned long long)(a+b-1))>>1);
	else printf("%lld",b-a>>1);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            Integer[] A = new Integer[N];
            Integer[] B = new Integer[N];
            Integer[] C = new Integer[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                C[i] = in.nextInt();
            }

            Arrays.sort(A);
            Arrays.sort(B);
            Arrays.sort(C);

            long[] ways = new long[N];


            for (int i = 0, j = 0; i < N && j < N; ) {
                if (A[i] < B[j]) {
                    ways[j]++;
                    i++;
                } else {
                    j++;
                }
            }

            for (int i = 1; i < N; i++) {
                ways[i] += ways[i - 1];
            }


            long[] ways2 = new long[N];

            for (int i = 0, j = 0; i < N && j < N; ) {
                if (B[i] < C[j]) {
                    ways2[j] += ways[i];
                    i++;
                } else {
                    j++;
                }
            }
            for (int i = 1; i < N; i++) {
                ways2[i] += ways2[i - 1];
            }
            for (int i = 1; i < N; i++) {
                ways2[i] += ways2[i - 1];
            }

            out.println(ways2[N - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 57476
#include<cstdio>
bool G[105][105];
int main(){
	int n,i,j;
	scanf("%d",&n);
	printf("%d\n",(n*(n-1)>>1)-(n>>1));
	if(n&1)for(i=1;i<n;++i)
		for(j=i+1;j<=n;++j)if(i+j!=n)printf("%d %d\n",i,j);
		else;
	else for(i=1;i<n;++i)
		for(j=i+1;j<=n;++j)if(i+j-1!=n)printf("%d %d\n",i,j);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;cin >> N;
    cout << N * N * N << endl;
}


















Measured memory_bytes: 256