akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
bool ok[2001];
int main(){
    int n;cin>>n;
    vector<int> A(n);
    for(int i = 0; n > i; i++){
        cin>>A[i];
    }
    for(int bit = 0; (1<<n) > bit; bit++){
        int nya = 0;
        for(int i = 0; n > i; i++){
            if(bit & (1<<i)){
                nya += A[i];
            }
        }
        if(nya < 2001){
            ok[nya] = true;
        }
    }
    int q;cin>>q;
    while(q--){
        int t;cin>>t;
        cout << (ok[t]?"yes":"no") << endl;
    }
}


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

int main(void){
    long long int n;
    cin >> n;
    long long power = 1;
    for(long long i = 1; i <= n; i++){
        power = (power * i) % ((int)pow(10,9) + 7);
    }

    cout << power;
    return 0;
}


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

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int  i = 0; i < n; ++i){
		cin >> v[i];
	}
	int m = min(n, k);
	int ans = 0;
	for(int i = 0; i <= m; ++i){
		for(int j = 0; j <= i; ++j){
			priority_queue<int> que;
			int sum = 0;
			for(int l = 0; l < j; ++l){
				sum += v[l];
				//cout << sum << " ";
				que.push(-v[l]);
			}
			for(int l = n-1; l > (n-1)-(i-j); --l){
				sum += v[l];
				//cout << sum << " ";
				que.push(-v[l]);
			}
			int cnt = 0;
			while(!que.empty()){
				if(cnt+i==k)break;
				if(que.top() < 0)break;
				sum += que.top();
				cnt++;
				que.pop();
			}
			ans = max(ans, sum);
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(228);
 
const int N = 100 + 1;
 
int arr[N][N];
 
int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n, m;
    cin >> n >> m;
    int h;
    cin >> h;
    vector <int> a(h);
    for (int i = 0; i < h; i++)
    {
        cin >> a[i];
    }
    int sz = 0;
    for (int i = 0; i < m; i++)
    {
        if (i % 2 == 0)
        {
            for (int j = 0; j < n; j++)
            {
                if (a[sz] == 0)
                {
                    sz++;
                }
                arr[j][i] = sz + 1;
                a[sz]--;
            }
        }
        else
        {
            for (int j = n - 1; j >= 0; j--)
            {
                if (a[sz] == 0)
                {
                    sz++;
                }
                arr[j][i] = sz + 1;
                a[sz]--;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cout << arr[i][j] << ' ';
        }
        cout << '\n';
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  char s[21];

  scanf("%s",s);

  for(int i=0;i<3;i++)
  {
    printf("%c",s[i]);
  }
  printf("\n");

  return 0;
}

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

int main() {
  
  //x匹 y足
  int x, y;
  cin >> x >> y;
  
  int ans = 0;
  
  for (int i = 0; i <= x; i++){
    
    int a, b;
    a = 4 * i;
    b = 2 * (x - i);
    int t;
    t = a + b;
    
    if (y  == t){
      ans = ans + 1;
    }
    
  }
  
  if (ans > 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
}


Measured memory_bytes: 3560
N = gets.chomp.to_i

line = gets.chomp.split.map(&:to_i)

puts line.join(" ")
1.upto(line.length - 1) do |i|
  key = line[i]

  j = i - 1

  while j > -1 && line[j] > key
    line[j + 1] = line[j]
    j -= 1
  end

  line[j + 1] = key

  puts line.join(" ")
end

Measured memory_bytes: 6116
#include <stdio.h>

int main(){
  int a, b, c, i, cnt=0;

  scanf("%d %d %d", &a, &b, &c);

  for(i=a; i<=b; i++){
    if(!(c % i)){ cnt++; }
  }
  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 596
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X-A)%B << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

long long int ans;
int a[15];

void total(int i, long long int num, long long int tot){
    if (a[i+1]<0) ans += tot + num * 10 + a[i];
    else{
        total(i+1, 0, tot+ 10 * num + a[i]);
        total(i+1, num * 10 + a[i], tot);
    }
}


int main(){
    char S[15];
    scanf("%s", &S);

    int num = strlen(S);
    for(int i = 0; i < num; i++){
        char c[3] = {S[i]};
        a[i] = atoi(c);
    }
    a[num] = -1;
    ans = 0;

    total(0, 0, 0);
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u) a--;
  else b--;
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

string app() {
  string t;
  cin>>t;

  rep(i,t.length()){
    if(t[i]=='?'){
      t[i]='D';
    }
  }

  return t;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <algorithm>

using namespace std;


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

	int ans = a + 10*b + c;
	ans = max(ans, a + b + 10*c);
	ans = max(ans, 10*a + b + c);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
Q = ir()
dir = 0 #最初の向きを0、逆向きを1
head_tail = ['', '']
for _ in range(Q):
    x = sr().split()
    if x[0] == '1':
        dir = (1 - dir)
    else:
        t, f, c = x
        h_d = dir
        if f == '2':
            h_d = (1 - h_d)
        head_tail[h_d] += c

if dir == 0:
    answer = head_tail[0][::-1] + S + head_tail[1]
else:
    answer = head_tail[1][::-1] + S[::-1] + head_tail[0]

print(answer)


Measured memory_bytes: 4548
#include<stdio.h>
using namespace std;

int main(){
	while(1){
		int h,w;
		scanf("%d %d\n", &h,&w);
		if(h==0 && w==0) break;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if((i+j)%2 == 0) printf("#");
				if((i+j)%2 != 0) printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
 
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  cout << (s[0] != s[1] and s[1] != s[2] and s[2] != s[3] ? "Good" : "Bad") << '\n';
}

Measured memory_bytes: 256
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 998244353
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

const int N = 1e7+10;
int fact[N] = {0};
int inv[N] = {0};

ll power(ll x, ll y, ll p)
{
        ll res = 1;      // Initialize result
        x = x % p;  // Update x if it is more than or
        while (y > 0)
        {
                        if (y & 1)
                                        res = (res*x) % p;
                        y = y>>1; // y = y/2
                        x = (x*x) % p;
        }
        return res;
}

void compute()
{
  fact[0] = 1;
  inv[0] = 1;
  for(int i=1;i<=1e7;i++) 
  {
    fact[i] = (1LL*i*fact[i-1]) % MOD;
    inv[i] = power(fact[i],MOD-2,MOD);
  }
}

int C(int n,int i)
{
  int a = fact[n], b = inv[i], c = inv[n-i];
  return ((1LL*a*b) % MOD * 1LL * c) % MOD;
}

int main()
{
  __;
  compute();
  int n;
  cin >> n;
  int a = power(3,n,MOD);
  for(int i=n/2+1;i<=n;i++)
  {
    int temp = C(n,i);
    int b = power(2,n-i,MOD);
    // t(b,temp);
    a -= ((2LL*temp) % MOD * b) % MOD;
    a += MOD;
    a %= MOD;
  }

  cout << a << endl;
  return 0;
}



Measured memory_bytes: 78336
/* ex4_2
   moka223711 */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358

int main(void){
    // 時針の長さがlenh[cm]、分針の長さがlenm[cm]である時計のhour時minute分における
    // 時針の先端と分針の先端の距離を求める
    
    double lenh, lenm, hour, minute, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &lenh, &lenm, &hour, &minute);
    
    // 針が12時を指しているときを0[rad]とする
    // 時針は12時間(12*60分)で一周するので、hour時minute分のとき
    // 時針の角度radhは、2*PIに(hour/12+minute/60/12)をかけたものになる
    radh = 2 * PI * (hour + minute / 60) / 12;
    // 分針は60分で一周するので、分針の角度radmは2*PIにminute/60をかけたものになる
    radm = 2 * PI * minute / 60;
    // なす角を知りたいのでPI(180°)より小さい方を選ぶ
    rad = (radh-radm < PI) ? radh-radm : radm-radh;
    
    // 余弦定理を用いて時針の先端と分針の先端の距離を求める
    ans = sqrt(pow(lenh, 2) + pow(lenm, 2) - 2*lenh*lenm*cos(rad));
    // 誤差は10^{-9}まで許されるので10^{-10}まで表示する
    printf("%.10lf", ans);
    
    return 0;
}


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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s/100;
  s2 = (s-s1*100)/10;
  s3 = s-(s1*100+s2*10);
  cout << s1+s2+s3 << endl;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	int counter = 0;
	int K[30];
	int A[30][30];
	int count[40] = { 0 };

	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			cin >> A[i][j];
			count[A[i][j]]++;
		}
	}

	for (int i = 1; i <= 30; i++) {
		if (count[i] == N) counter++;
	}

	cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    vector<vector<int>> vv(505);
    int N,M,Q;
    cin>>N>>M>>Q;
    rep(i,M){
        int l,r;
        cin>>l>>r;
        vv[l].push_back(r);
    }
    rep(i,505){
        sort(all(vv[i]));
    }
    while(Q--){
        int p,q;
        cin>>p>>q;
        int ans = 0;
        for(int i = p;i <=q;i++){
            ans += upper_bound(all(vv[i]), q) - vv[i].begin();
        }
        cout << ans <<endl;
    }
}

Measured memory_bytes: 2176
#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;

int main(){
    int a[5];
    rep(i,5) cin >> a[i];
    rep(i,5) {
        if(a[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

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

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;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, n) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = min((a), (b))

struct Info {
  ll A, B;
};

bool operator<(const Info &left, const Info &right) { return left.A < right.A; }

unsigned long long XOR(unsigned long long A, unsigned long long B) {
  return A ^ B;
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int m = B / A;
  CHMAX(m, C);

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	int m=1;
	while(m<n) m<<=1;
	if(n<3||m==n)
    {
        printf("No");
        return 0;
    }
	printf("Yes\n");
    printf("%d %d\n",1,n+2);
    printf("%d %d\n",n+2,3);
    printf("%d %d\n",3,n+1);
    printf("%d %d\n",n+1,2);
    printf("%d %d\n",2,n+3);
    for(int i=4;i<n;i+=2)
    {
        printf("%d %d\n",i,n+1);
        printf("%d %d\n",i,n+i+1);
        printf("%d %d\n",i+1,n+1);
        printf("%d %d\n",n+i,i+1);
    }
    if(n%2==0)
    {
        for(int i=2;i<n;i++)
            if((n^(i^1))<n)
            {
                printf("%d %d\n",n,i);
                printf("%d %d\n",n+n,n^i^1);
                break;
            }
	}
	return 0;
}

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

int main(){
    string W,T;
    cin >> W;
    int co = 0;
    for (int i=0;i<(int)W.size();i++){
        if (isupper(W[i])){
            W[i] = tolower(W[i]);
        }
    }
    while(1){
        cin >> T;    
        if (T == "END_OF_TEXT"){
            break;
        }
        for(int j=0;j<(int)T.size();j++){
            if (isupper(T[j])){
                T[j]=tolower(T[j]);
            }
        }
        if(T==W){
            co += 1;
        }    
    }
    cout << co << endl;
    return 0;
    
    
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner cs = new Scanner(System.in);
		int N = cs.nextInt();
		int[] a = new int [N];
		int[] b = new int [N];
		int[] c = new int [N];
		int[] ans = new int [N];
		int e = 0, f = 0, g = 0, k = 0, l = 0, m = 0;
		int[] x = new int [N];
		int[] y = new int [N];
		int[] z = new int [N];
		for(int i = 0; i < N*3; i++){
			switch(i % 3){
			case 0:
				a[e] = cs.nextInt();
				e = e + 1;
				break;
			case 1:
				b[f] = cs.nextInt();
				f = f + 1;
				break;
			case 2:
				c[g] = cs.nextInt();
				g = g + 1;
				break;
			}
		}
		for(int i = 0; i < N - 1; i++){
			for(int j = i + 1; j < N; j++){
				if(a[i] == a[j]){
					x[k] = a[i];
					k = k + 1;
				}
			}
		}
			for(int i = 0; i < k; i++){
				for(int j = 0; j < N; j++){
					if(x[i] == a[j]){
						a[j] = 0;
					}
				}
			}


		for(int o = 0; o < N - 1; o++){
			for(int p = o + 1; p < N; p++){
				if(b[o] == b[p]){
					y[l] = b[o];
					l = l + 1;
				}
			}
		}

			for(int o = 0; o < l; o++){
				for(int p = 0; p < N; p++){
					if(y[o] == b[p]){
						b[p] = 0;
					}
				}
			}


		for(int q = 0; q < N - 1; q++){
			for(int r = q + 1; r < N; r++){
				if(c[q] == c[r]){
					z[m] = c[q];
					m = m + 1;
				}
			}
		}

			for(int q = 0; q < m; q++){
				for(int r = 0; r < N; r++){
					if(z[q] == c[r]){
						c[r] = 0;
					}
				}
			}

		for(int i = 0; i < N; i++){
			ans[i] = a[i] + b[i] + c[i];
			System.out.println(ans[i]);
		}
	}

}

Measured memory_bytes: 29616
//abc173_c.cpp
//Sun Jul  5 20:55:24 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	string s[h];
	for (int i=0;i<h;i++){
		cin >> s[i];
	}

	int ans = 0;
	for (int i=0;i<1<<h;i++){
		for (int j=0;j<1<<w;j++){
//			cout << i << " " << j << endl;
			int tmp = 0;
			for (int k=0;k<h;k++){
				for (int l=0;l<w;l++){
					// cout << "  " << (i>>k&1) << " " << (j>>l&1) << " "<< (s[k][l]=='#') << endl; 
					if (i>>k&1 && j>>l&1 && s[k][l]=='#'){
						tmp++;
					}
				}
			}
			// cout << i << " " << j << " " << tmp << endl;
			if (tmp==k){
				ans++;
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main(){
	int H,W;
	cin>>H>>W;
	int s[52][52] = {};
	for(int i=1;i<=H;i++){
		string ss;
		cin>>ss;
		for(int j=1;j<=W;j++){
			if(ss[j - 1] == '#') s[i][j] = 1;
		}
	}

	for(int i=1; i <= H; i++){
		for(int j=1; j <= W; j++){
			if(s[i][j] == 1 && (s[i + 1][j] + s[i - 1][j] + s[i][j - 1] + s[i][j + 1] == 0)){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e7 + 10;
int N, M;
char S[MAXN], T[MAXN];

inline bool check() {
	register int i, j;
	long long K = 1ll * N * M / __gcd(N, M);
	long long n = K / N, m = K / M;
	swap(n, m);
	for(i = 1, j = 1; i <= N && j <= M; i += n, j += m)
		if(S[i] != T[j])
			return false;
	return true;
}

int main() {
	scanf("%d%d", &N, &M);
	scanf("%s%s", S + 1, T + 1);
	printf("%lld\n", N != 0 && M != 0 && !check() ? -1ll : 1ll * N * M / __gcd(N, M));
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <stack>
#include <vector>
using namespace std;

int vis[10010] = {0};
vector<int> r1[10010], r2[10010];
int scc[10010];
stack<int> st;

int getSCC(int x) {
  if (scc[x] == x) return x;
  return scc[x] = getSCC(scc[x]);
}

void dfs(int s, int n, vector<int> r[], int c) {
  vis[s] = 1;
  for (int i = 0; i < r[s].size(); i++) {
    int t = r[s][i];
    if (!vis[t]) {
      if (c == 2) {
        int k1 = getSCC(s);
        int k2 = getSCC(t);
        scc[k1] = k2;
      }
      dfs(t, n, r, c);
    }
  }
  if (c == 1) {
    st.push(s);
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    r1[x].push_back(y);
    r2[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i, n, r1, 1);
    }
  }
  for (int i = 0; i < n; i++) {
    vis[i] = 0;
    scc[i] = i;
  }
  while (!st.empty()) {
    int now = st.top();
    st.pop();
    if (!vis[now]) {
      dfs(now, n, r2, 2);
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> x >> y;
    cout << (getSCC(x) == getSCC(y)) << endl;
  }
  return 0;
}

Measured memory_bytes: 4968
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Long> list = new ArrayList<>();
		for(int i=0;i<n;i++){
			list.add( sc.nextLong());
		}
		Collections.sort(list);
		// System.out.println(list);

		long diff = list.get(k-1) - list.get(0);
		long minDiff = diff;
		// System.out.println("first diff"+diff);
		for(int i=0;i<n;i++){
			if(i<k){
				continue;
			}
			if(diff==0){
				break;
			}
			long curDiff =(list.get(i)-list.get(i-1)) - (list.get(i-k+1)-list.get(i-k));
			
			diff += curDiff;
			minDiff = Math.min(diff, minDiff);
		}
		System.out.println(minDiff);

	}
}



Measured memory_bytes: 60664
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#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 << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }


int main() {

    string s;
    cin >> s;

    int ans = 0;
    rep(i, 3) {
        int v = s[i] - '0';
        if (v>0) {
            ans++;
        }
    }    
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int a, b;
    cin>>a>>b;

    cout<<max(a + b, max(a - b, a * b))<<endl;
}

Measured memory_bytes: 256
//B
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int snk[] = new int[n];
		for (int i = 0; i < n; i++) {
			snk[i] = 0;
		}
		
		for (int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for (int j = 0; j < d; j++) {
				int a_id = sc.nextInt();
				snk[a_id - 1] = 1;
			}
		}
		
		int count = 0;
		for (int l = 0; l < n; l++) {
			if (snk[l] == 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 46580
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int N; vector<vector<int>> A;
void input()
{
    cin >> N;
    A.resize(2); A[0].resize(N); A[1].resize(N);
    for (int i = 0; i < N; ++i) cin >> A[0][i];
    for (int i = 0; i < N; ++i) cin >> A[1][i];
}

void solve()
{
    int ans = 0;
    for (int i = 0; i < N; ++i){
        int sum = 0;
        for (int j = 0; j <= i; ++j){
            sum += A[0][j];
        }
        for (int j = i; j < N; ++j){
            sum += A[1][j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

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

using namespace std;

int main()
{
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[101],y[101];
    for(int i = 0; i < N; ++i) cin >> x[i];
    for(int i = 0; i < M; ++i) cin >> y[i];
    x[N] = X;
    y[M] = Y;
    sort(x, x+N+1, greater<int>());
    sort(y,y+M+1);

    if(y[0] - x[0] >= 1) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}



Measured memory_bytes: 256
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))

for i in range(101):
    p = X - i not in P
    p1 = X + i not in P
    if p1 or p:
        if p:
            print(X - i)
            exit()
        print(X + i)
        exit()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] D = W.split(" ");
		int MOD = 2019;

		long L = Long.parseLong(D[0]);
		long R = Long.parseLong(D[1]);

		long ed = R<L+MOD?R:L+MOD;
		long i = L;

		long ans = MOD;
		for(;i<ed;i++){
			for(long k=i+1;k<=ed;k++){
				long tmp = Long.remainderUnsigned(i*k, MOD);
				if(tmp < ans ){
					ans = tmp;
				}
			}
		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b;
    cin >> a >> b;

    vector<int> dataA(100000);
    vector<int> dataB(100000);
    for(int i=0; i<100000; i++) {
        dataA[i] = i * 0.08;
        dataB[i] = i * 0.1;
    }
    
    for(int i=0; i<100000; i++) {
        if(dataA[i] == a && dataB[i] == b) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 1024
import numpy as np
n=int(input())
a=np.array(input().split(),dtype=np.int32)
b=np.array(input().split(),dtype=np.int32)
def f(t,a,b):
  power=1<<t
  mask=(power<<1)-1
  aa=a&mask
  bb=b&mask
  aa.sort()
  bb.sort()
  x1,x2,x3=(np.searchsorted(bb,v-aa).sum() for v in [power,power*2,power*3])
  zero_cnt=x1+(x3-x2)
  return (n-zero_cnt)%2
ans=0
for t in range(30):
  x=f(t,a,b)
  if x==1:
    ans+=1<<t
print(ans)

Measured memory_bytes: 35928
implicit none
character(100000) :: s
integer :: i,n
logical :: a(97:122)

read *,s
n = len_trim(s)

a(:) = .false.
do i = 1, n
   a(ichar(s(i:i))) = .true.
enddo

do i = 97, 122
   if (.not. a(i)) then
      print '(a)',char(i)
      stop
   endif
enddo

print '(a)','None'
stop
end

Measured memory_bytes: 700
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int d[m];
    REP(i,m)
        cin >> d[i];
    int cnt[n];
    REP(i,n)
        cnt[i] = n+1;
    REP(i,n)
    REP(j,m) {
        if(d[j] == i+1)
            cnt[i] = 1;
        else if(i-d[j] >= 0)
            cnt[i] = min(cnt[i],cnt[i-d[j]]+1);
    }
    cout << cnt[n-1] << '\n';
}

Measured memory_bytes: 1356
# coding=utf-8
# Date: 2020-01-08
# Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: list(map(int, raw_input().strip().split()))
getss = lambda n: [gets() for _ in range(n)]

h, N = gets()
AB = getss(N)

dp = [0] + [float('inf')] * h
for a, b in AB:
    for i in range(h):
        j = min(i + a, h)
        dp[j] = min(dp[j], dp[i] + b)
print(dp[h])

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
//map<int, int>::iterator itr; 
int find(int n,int arr[],int v){
for(int i=0;i<n;i++){
    if(arr[i]==v)
    return 1;
}
return 0;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;t=1;
    while(t--){
        int x,n;cin>>x>>n;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        int ans=INT_MAX,res=0;
        for(int i=0;i<=101;i++){
            if(abs(i-x)<ans&&find(n,arr,i)==0){
                ans=abs(i-x);
                res=i;
            }
        }
        cout<<res;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N, M;


int solve(){
	if(N == 1 && M == 1) return 1;
	if(N == 1) return M-2;
	return (N-2)*(M-2);
}


signed main(){
	cin >> N >> M;

	if(N > M) swap(N, M);

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
n,p,i,a[51];
main(){
	for(;~scanf("%d", &n),n;) {
		for(p=i=0;i<n;i++)scanf("%d",&a[i]);
		for(i=1;i<=n;i++){
			if(a[i-1]+1!=a[i]||n-i==0) {
				if(i-p-1)printf((n-i)?"%d-%d ":"%d-%d\n",a[p],a[i-1]);
				else printf((n-i)?"%d ":"%d\n",a[p]);
				p=i;
			}
		}
	}
	exit(0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define m 1000000007
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define scan(a,n) for (ll i = 0; i < n; ++i) cin >> a[i]

int main() 
{  
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')
		s+="es";
	else
		s+='s';
	cout<<s;
	return 0;
} 

Measured memory_bytes: 3652
#include <cstdio>

char S[101010];

int main()
{
  scanf("%s", S);

  bool app[26];
  for (int i = 0; i < 26; ++i) {
    app[i] = false;
  }
  for (int i = 0; S[i] != '\0'; ++i) {
    app[S[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; ++i) {
    if (!app[i]) {
      printf("%c\n", (char)(i + 'a'));
      return 0;
    }
  }
  puts("None");
  return 0;
}

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

int N;
int val[20];
const double INF = 1e30;
const int lim = 200005;
double dp[200005][2];

double solve()
{
	for(int j=0; j<2; j++)
	for(int i=0; i<lim; i++) 
		dp[i][j] = INF;

	for(int i=1; i<lim; i++)
		dp[i][0] = 1.0*abs(i-val[0]) / val[0];

	for(int i=1; i<N; i++)
	{
		for(int j=1; j<lim; j++)
			dp[j][i%2] = INF;

		for(int j=1; j<lim; j++)
		{
			if(dp[j][(i+1)%2]==INF) continue;

			for(int k=1; j*k<lim; k++) 
				dp[j*k][i%2] = min(dp[j*k][i%2], max(dp[j][(i+1)%2], 1.0*abs(j*k-val[i])/val[i]));
		}
	}

	double res = INF;
	for(int i=1; i<lim; i++)
		res = min(res, dp[i][(N+1)%2]);

	return res;
}

int main()
{
	cin >> N;
	for(int i=0; i<N; i++)
		cin >> val[i];

	cout.setf(ios::fixed);
	cout.precision(10);

	cout << solve() << endl;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int k, x; cin >> k >> x;
   for (int i = x-k+1; i < k+x; i++){
      cout << i << " ";
   }
   cout << endl;
}

Measured memory_bytes: 3576
import collections

import numpy as np


def main():
    N = int(input())
    S = [list(input()) for _ in range(N)]

    A = np.zeros([N, 26], dtype=np.int32)

    for i in range(N):
        for s in S[i]:
            c = int(ord(s) - ord('a'))
            A[i, c] += 1

    B = np.min(A, axis=0)

    ans = []
    for c in range(26):
        for i in range(B[c]):
            ans.append(chr(c + ord('a')))

    print(''.join(ans))


main()


Measured memory_bytes: 13712
import java.util.*;
class Main {

    static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
            int N = scan.nextInt();
            int change  = Integer.MIN_VALUE;
           if(N % 1000 == 0) {
               change = 0;
           } else {
                int rem = N / 1000;
                change = (rem + 1) * 1000 - N;
            }
            System.out.println(change);
    }
}


Measured memory_bytes: 35920
#include<stdio.h>

int main()
{

  int a, c=0;/*たこ焼きの数・美味しさ値総量*/
  int b[101];/*たこ焼きの美味しさデータ*/
  
  scanf("%d", &a);
  
  for(int i=0; i<a; i++)
  {
      scanf("%d", &b[i]);
  }
  
  for(int i=0; i<a; i++)
  {
  	for(int j=i+1; j<a; j++)
    {
    	c += b[i]*b[j];
    }
  }
  
 printf("%d", c);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll n,m; cin >> n >> m;
    ll t = (n-m)*100 + m*1900;
    cout << t*(1LL<<m) << endl;
}

Measured memory_bytes: 256
use proconio::{input, marker::Chars};
use std::collections::HashMap;

fn main() {
    input! {
        a: Chars,
    }

    let len = a.len();

    let mut map = HashMap::new();

    for c in a {
        *map.entry(c).or_insert(0) += 1;
    }

    let mut count = 0;

    for (_, val) in map {
        count += (len - val) * val;
    }
    count /= 2;
    count += 1;

    println!("{}", count);
}


Measured memory_bytes: 3024
aa=int(input())
bb=int(input())
cc=int(input())
xx=int(input())

counter=0

for a in range(aa+1):
	for b in range(bb+1):
		for c in range(cc+1):
			x=500*a+100*b+50*c
			if x==xx:
				counter+=1

print(counter)


Measured memory_bytes: 3064
n, m = map(int, input().split())
#2次元配列
#a=[list(map(int,input().split())) for i in range(m)]

aa = []
bb = []
for i in range (m):
	a, b = map(int, input().split())
	if(a == 1):
		aa.append(b)
	if(b == n):
		bb.append(a)

if( len(set(aa) & set(bb)) == 0):
	print ("IMPOSSIBLE")
else:
	print ("POSSIBLE")

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

int main(){
   int n;
   cin >> n;
   int d[52];
   int sum =0;
   for (int i=0 ; i<n ; ++i) cin>>d[i];

   for(int i=0 ; i<n ;++i ){
       for(int j=0;j<n; ++j){
        sum+=d[i]*d[j];

       }
       sum-=d[i]*d[i];
   }
   cout << sum / 2 << endl;
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,m; 
ll  dp[5005]; 
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		dp[i]=1;
	}
	for(int i=0;i<n;++i){
		ll sum=0;
		for(int j=1;j<=m;++j){
			ll val=sum+dp[j]*1ll*(j+1);
			val%=mod;
			sum*=2;
			sum+=dp[j]*1ll*j%mod;
			sum%=mod;
			dp[j]=val;
		}
	}
	cout<<dp[m]<<'\n';
	return 0; 
} 

Measured memory_bytes: 3696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type card struct {
	suit  string
	value int
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)

	e := make([]card, n)

	for x := 0; x < n; x++ {
		tmp := ""
		fmt.Fscan(r, &tmp)
		e[x].suit = string([]rune(tmp)[0])
		e[x].value, _ = strconv.Atoi(string([]rune(tmp)[1]))
	}

	bo := make([]card, len(e))
	_ = copy(bo, e)
	so := make([]card, len(e))
	_ = copy(so, e)

	b := bubbleSort(bo)
	print(b, b)
	print(b, selectionSort(so))
}

func bubbleSort(e []card) []card {
	n := len(e)
	flag := true
	for flag {
		flag = false
		for j := n - 1; j > 0; j-- {
			if e[j].value < e[j-1].value {
				tmp := e[j]
				e[j] = e[j-1]
				e[j-1] = tmp
				flag = true
			}
		}
	}
	return e
}

func selectionSort(e []card) []card {
	n := len(e)
	for i := 0; i < n; i++ {
		minj := i
		for j := i; j < n; j++ {
			if e[j].value < e[minj].value {
				minj = j
			}
		}
		tmp := e[i]
		e[i] = e[minj]
		e[minj] = tmp
	}
	return e
}

// Bubble sort always stable
func isStable(bubble, out []card) string {
	for i := 0; i < len(bubble); i++ {
		if bubble[i].suit != out[i].suit {
			return "Not stable"
		}
	}
	return "Stable"
}

func print(in, out []card) {
	n := len(in)
	for x := 0; x < n; x++ {
		if x == n-1 {
			fmt.Printf("%v%d\n", out[x].suit, out[x].value)
		} else {
			fmt.Printf("%v%d ", out[x].suit, out[x].value)
		}
	}
	fmt.Printf("%v\n", isStable(in, out))
}



Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5,MAX_M=1e5;
int N,M;
int ufpar[MAX_N];
int uffndpar(int v){
	if(v==ufpar[v]){
		return v;
	}
	return ufpar[v]=uffndpar(ufpar[v]);
}
bool same(int s,int t){
	s=uffndpar(s);
	t=uffndpar(t);
	return s==t;
}
void unite(int s,int t){
	s=uffndpar(s);
	t=uffndpar(t);
	ufpar[s]=t;
}
vector<int> G[MAX_N];
int A[MAX_M],B[MAX_M];
bool used[MAX_M];
int dst[MAX_N];
void caldst(int v,int p,int d){
	dst[v]=d;
	for(auto e:G[v]){
		if(e!=p){
			caldst(e,v,d+1);
		}
	}
}
int main(){
	cin>>N>>M;
	REP(i,N)ufpar[i]=i;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		A[i]=a;
		B[i]=b;
		if(!same(a,b)){
			unite(a,b);
			G[a].push_back(b);
			G[b].push_back(a);
			used[i]=true;
		}
	}
	caldst(0,-1,0);
	bool flg=false;
	REP(i,M){
		if(used[i])continue;
		if(abs(dst[A[i]]-dst[B[i]])%2==0){
			flg=true;
		}
	}
	ll ans=-M;
	if(flg){
		ans+=(ll)N*(N-1)/2;
	}else{
		ll cnt=0;
		REP(v,N){
			if(dst[v]%2==1){
				cnt++;
			}
		}
		ans+=cnt*(N-cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7424
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

enum class Direction(val offsetX: Int, val offsetY: Int) {
    UP(0, -1),
    DOWN(0, 1),
    Left(-1, 0),
    RIGHT(1, 0),
    UPPER_LEFT(-1, -1),
    UPPER_RIGHT(1, -1),
    LOWER_LEFT(-1, 1),
    LOWER_RIGHT(1, 1),
}

fun solve(out: PrintWriter) {
    val (h, w) = readIntegerList()
    val tmpMap = Array(h) { ("." + readLine()!! + ".").toCharArray() }
    val map = listOf(".".repeat(w + 2).toCharArray()) + tmpMap + (".".repeat(w + 2)).toCharArray()
    for (y in 1..h) {
        for (x in 1..w) {
            if (map[y][x] == '.') {
                map[y][x] = Direction.values().count { map[y + it.offsetY][x + it.offsetX] == '#' }.toChar() + '0'.toInt()
            }
        }
        out.println(map[y].slice(1..w).joinToString(""))
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37844
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	ll n, m, l;
	cin >> n >> m >> l;
	vll a(m), b(m), c(m);
	rep(i, m) cin >> a[i] >> b[i] >> c[i];
	ll q;
	cin >> q;
	vll s(q), t(q);
	rep(i, q) cin >> s[i] >> t[i];

	vector<vll> d1(n + 1, vll(n + 1, INFL));
	vector<vll> d2 = d1;

	rep1(i, n) d1[i][i] = 0;
	rep(i, m) {
		d1[a[i]][b[i]] = c[i];
		d1[b[i]][a[i]] = c[i];
	}
	rep1(k, n) rep1(i, n) rep1(j, n) {
		chmin(d1[i][j], d1[i][k] + d1[k][j]);
	}
	rep1(i, n) rep1(j, n) if(d1[i][j] <= l) d2[i][j] = 1;
	rep1(k, n) rep1(i, n) rep1(j, n) {
		chmin(d2[i][j], d2[i][k] + d2[k][j]);
	}

	vi ans(q);
	rep(i, q) {
		ll& d = d2[s[i]][t[i]];
		ans[i] = (d <= 500 ? d - 1 : -1);
	}
	for(auto i: ans) cout << i << endl;
}


Measured memory_bytes: 4608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,m = LI()
    return n-m-1

print(main())

Measured memory_bytes: 13564
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll> > p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  ll ans = 0, damage = 0;
  queue<pair<ll, ll> > que;
  for (int i = 0; i < n; ++i) {
    ll x = p[i].first;
    ll h = p[i].second;
    while (que.size() && que.front().first < x) {
      damage -= que.front().second;
      que.pop();
    }
    h -= damage;
    if (0 < h) {
      ll t = (h + a - 1) / a;
      ans += t;
      damage += a * t;
      que.push(make_pair(x + 2 * d, a * t));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define MAXN 100100
using namespace std;
int n,v[MAXN],dp[MAXN];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",v+i);
	}
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list()

    for i in map(int, input().split()):
        a.append(i)

    flag = True
    for i in a:
        if i % 2 == 0:
            if i % 3 == 0:
                continue
            elif i % 5 == 0:
                continue
            else:
                flag = False
                break

    if flag:
        print("APPROVED ")
    else:
        print("DENIED ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<((c>=a && b>=c)?"Yes":"No")<<endl;
    
    return 0;
}

Measured memory_bytes: 256