akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 50;
const ll OO = 0x3f3f3f3f3f3f3f3fll;

int n, m, d;
int p[N + 5];

struct item {
    ll val;
    int lim, sz;

    bool operator < (const item& rhs) const {
        return val * rhs.sz < rhs.val * sz;
    }
};

item it[N + 5];
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n); read(m), read(d);

    read(it[1].val);
    for(int i = 2; i <= n; ++i) read(it[i].val), read(p[i]);
    for(int i = n; i >= 1; --i) {
        it[i].sz ++;
        it[p[i]].sz += it[i].sz;
        it[p[i]].val += it[i].val;
        it[i].lim = (i == 1 ? oo : d);
    }
    std::sort(it + 1, it + n + 1);

    static ll dp[N * N * N + 5];
    for(int i = 0; i <= N*N*N; ++i) dp[i] = OO;

    dp[0] = 0;
    for(int i = 1; i <= n; ++i) {
        int t = std::min(n, it[i].lim);
        it[i].lim -= t;

        for(int j = 1; j <= t; j <<= 1) {
            for(int k = n*n*n; k >= j * it[i].sz; --k)
                chkmin(dp[k], dp[k - j * it[i].sz] + j * it[i].val);
            t -= j;
        }
        if(t) {
            for(int k = n*n*n; k >= t * it[i].sz; --k)
                chkmin(dp[k], dp[k - t * it[i].sz] + t * it[i].val);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= n*n*n; ++i) if(dp[i] <= m) {
        ll res = i, w = m - dp[i];

        for(int j = 1; j <= n; ++j) {
            ll tmp = std::min((ll) it[j].lim, w / it[j].val);

            w -= tmp * it[j].val;
            res += tmp * it[j].sz;
        }

        chkmax(ans, res);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, a[3000], ans = 0;
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		ans += a[i] - 1;
	}

	cout << ans << endl;

	rtn 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
int main()
{
	string s ;
	cin >> s ;
	leftunique(s);
	if(s.size() == 2){
		cout << "Yes"<< endl;
	} else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include<stdio.h>
int a;
int b;
int c;
int d;
double e;
double f;
double g;

int main(void){
	
	scanf("%d %d",&a,&b);
	f = a;
	g = b;
	c = a / b;
	d = a % b;
	e = f / g;
	printf("%d %d %f\n",c,d,e);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
 #define ll long long
#define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define test int t; cin >> t; while(t--)
 #define inp(n) int n;cin >> n;
 #define mp make_pair
 #define pb push_back
 #define forl(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second

using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)   return a;  return gcd(b, a % b);
}

 int32_t main()
{
     fast;
    
//    test
//    {
//       
//    }
    ll n;
    cin>>n;ll ans=0;
    ll arr[200005],brr[200005];
    for(ll i=0;i<n;i++)cin>>arr[i]; for(ll j=0;j<n;j++)cin>>brr[j];
    priority_queue < pair < ll, ll> > pq;
    for(ll i=0;i<n;i++)
    {
        if(brr[i]>=arr[i])
        pq.push( mp(brr[i],i) );// check for -1 ..//
        else return cout<<"-1"<<endl,0;
    }
    int pre=-1;
    while(!pq.empty())
    {
        ll val,ind;
        auto it=pq.top();
        pq.pop();
        val=it.x;ind=it.y;
        if(pre==ind) {return cout<<"-1",0;}else pre = ind;
    
        brr[ind] = arr[ind]+(val-arr[ind])%(brr[(ind-1+n)%n]+brr[(ind+1)%n]);
        ans+=(val-arr[ind])/(brr[(ind-1+n)%n]+brr[(ind+1)%n]);
        if(brr[ind]<arr[ind]){return cout<<"-1",0;}
        if(brr[ind]>arr[ind])
        {
            pq.push(mp(brr[ind],ind));
        }
        
    }
    cout<<ans<<endl;
    return 0;
 }
  














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

int dp[2][2][110][110];
int main(){
	int W,H;
	while(true){
		cin>>W>>H;
		if(W==0&&H==0) break;
		dp[0][0][2][1]=1;
		dp[1][1][1][2]=1;
		for(int i=1;i<=W;i++){
			for(int j=1;j<=H;j++){
				if((i==1&&j==2)||(i<=2&&j==1)) continue;
				dp[0][0][i][j]=(dp[0][0][i-1][j]+dp[1][0][i-1][j])%100000;
				dp[1][1][i][j]=(dp[1][1][i][j-1]+dp[0][1][i][j-1])%100000;
				dp[1][0][i][j]=(dp[1][1][i-1][j])%100000;
				dp[0][1][i][j]=(dp[0][0][i][j-1])%100000;
			}
		}
		int res=0;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				res=(res+dp[i][j][W][H])%100000;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3268
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int ab = Integer.parseInt(a+b);
		if(isSquare(ab)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static public boolean isSquare(int x) {
		for(int i=0; i<Math.sqrt(x)+1; i++) {
			if(i*i==x) {
				return true;
			}
		}
		return false;
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21844
<?php
while(fscanf(STDIN, "%d %d", $n, $m) && ($n | $m)) {
  $s_arr = $t_arr = array();
  $s_sum = $t_sum = 0;
  
  for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d", $s_arr[$i]);
    $s_sum += $s_arr[$i];
  }
  
  for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d", $t_arr[$i]);
    $t_sum += $t_arr[$i];
  }

  $s_ans = $t_ans = 1000;
  
  foreach ($s_arr as $s) {
    foreach ($t_arr as $t) {
      if ($s_sum - $s + $t == $t_sum - $t + $s && $s_ans + $t_ans > $s + $t) {
        $s_ans = $s;
        $t_ans = $t;
      }
    }
  }
   
  if ($s_ans == 1000 && $t_ans == 1000) {
    print "-1\n";
  } else {
    print $s_ans . " " . $t_ans . "\n";
  }
}

Measured memory_bytes: 6640
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    vector<int> a(N);
    REP (i, N) {
        cin >> a[i];

    }
    ans = a[0];
    REP(i,N-1) ans^=a[i+1];

    REP(i,N) {
        int t = ans^a[i];
        cout << t << " ";
    }
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_e && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_e && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_e && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 4720
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int N, M, K, Q;
ll xA[MAX], yA[MAX];

int main()
{
	int i, j, k;
	scanf("%d%d", &N, &M);
	for (i = 1; i <= N; ++i) scanf("%lld", &xA[i]);
	for (i = 1; i <= M; ++i) scanf("%lld", &yA[i]);
	ll xsum, ysum;
	xsum = ysum = 0;
	for (i = 1; i < N; ++i) xsum = (xsum + (xA[i + 1] - xA[i]) * (ll)(N - i) %MOD * (ll)i % MOD) % MOD;
	for (i = 1; i < M; ++i) ysum = (ysum + (yA[i + 1] - yA[i]) * (ll)(M - i) %MOD * (ll)i % MOD) % MOD;
	printf("%lld", xsum*ysum %MOD);
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
using namespace std;
int g[210][210];
char in[10];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<200;i++)g[i][i]=1;
	for(int i=0;i<a;i++){
		int p,q;scanf("%d%s%d",&p,in,&q);
		p--;q--;
		if(in[0]=='l')g[p][q+100]=1;
		else g[q+100][p]=1;
	}
	for(int k=0;k<200;k++)for(int i=0;i<200;i++)for(int j=0;j<200;j++){
		if(g[i][k]&&g[k][j])g[i][j]=1;
	}
	for(int i=0;i<200;i++)for(int j=i+1;j<200;j++){
		if(g[i][j]&&g[j][i]){printf("1\n");return 0;}
	}
	printf("0\n");
}

Measured memory_bytes: 1176
#include <stdio.h>

int main()
{
	int a, b, sum;
  	scanf("%d%d", &a, &b);
  	sum = a + b;
  	if (sum % 2 == 0){
    	printf("%d", sum / 2);
    } else {
    	printf("%d", sum / 2 + 1);
    }
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define sz(a) ((int)a.size())

const int maxn = 1e5 + 5;

int main(int argc, char* argv[]) {
    if (argc > 1) {
        freopen(argv[1], "r", stdin);
    }

    string s;

    cin >> s;

    int ans = 1e9 + 5;
    rep(i, 1, sz(s)) {
        if (s[i] != s[i - 1]) {
            ans = min(ans, max(i, sz(s) - i));
        }
    }

    if (ans != 1e9 + 5) cout << ans;
    else cout << sz(s);

    return 0;
}



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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];

  int ans = 0;

  rep2(i, 0, N) {
    rep2(j, j = i + 1, N) {
      ans += d[i] * d[j];
    }
  }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;

bool check(int a)
{
	int b[10];
	b[5] = a % 10;
	a /= 10;
	b[4] = a % 10;
	a /= 10;
	b[3] = a % 10;
	a /= 10;
	b[2] = a % 10;
	a /= 10;
	b[1] = a % 10;
	if((b[1] == b[5]) && (b[2] == b[4]))
		return true;
	else return false;
}

int main()
{
	int a, b;
	int ans = 0;
	scanf("%d %d",&a,&b);
	for(int i = a; i <= b; i++)
		if(check(i)) ans++;
	printf("%d\n",ans);
	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()))

cnt=0

#Aのみ読んだ場合を考える
for a in A:
  if K >= a:
    K-=a
    cnt+=1
  else:
    break

maxcnt=cnt
A=A[: cnt ]
#print(A,K)
for i,b in enumerate(B):
  #aの要素なくしてbを入れる
  #bがいれれるまでaをなくすよ
  while b>K and len(A)!=0:
    a = A.pop()
    K += a
    cnt -= 1
    #print('-a,',a,K)
    
  if len(A) == 0:
    _B=B.copy()[i:]
   # print(_B)
    _B.pop(0)
    #まだbが入るかもしれない…！
    while(K>=b):
      K-=b
      cnt+=1
      #print('+b(while),',b,K,cnt)
      if len(_B) == 0:
        break
      b=_B.pop(0)
    if maxcnt < cnt:
      maxcnt=cnt
    break

  K -= b
  cnt+=1
  #print('+b,',b,K,cnt)
  
  if maxcnt < cnt:
    maxcnt=cnt



print(maxcnt)    

Measured memory_bytes: 42448
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
    
int main(){
	int n;
	cin>>n;
	vector<int> an(n);
	REP(i,n){
		cin>>an[i];
	}
	sort(ALL(an));
	REP(i,n-1){
		if(an[i]<0&&an[i+1]<0){
			an[i]=(-1)*an[i];
			an[i+1]=(-1)*an[i+1];
			i++;
		}else if(an[i]<0&&an[i+1]>=0){
			if(abs(an[i])>abs(an[i+1])){
				an[i]=(-1)*an[i];
				an[i+1]=(-1)*an[i+1];
			}
		}
	}
	ll ans=0;
	REP(i,n){
		ans+=an[i];
	}
	OUT(ans);
	return 0;
}

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

int main() {
  int n,x = 0;
  long long sum = 0LL;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    if(a.at(i) < 0){
      a.at(i) *= -1LL;
      x++;
    }
    sum += a.at(i);
  }
  if(x % 2 == 1){
    sort(a.begin(), a.end());
    sum -= a.at(0) * 2LL;
  }
  cout << sum << endl;
}


Measured memory_bytes: 1024
def solve():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort(key=lambda t:(t[1],-t[0]))
    time = 0
    ret = True
    for ab in AB:
        time += ab[0]
        if time > ab[1]:
            ret = False
            break
            
    print('Yes' if ret else 'No')
    
solve()

Measured memory_bytes: 72528
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,m; cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s; cin >> s;
    mp[s]++;
  }
  cin >> m;
  rep(i,m){
    string s; cin >> s;
    mp[s]--;
  }
  
  int ans = -(1<<30);
  
  for(auto mp1:mp) chmax(ans,mp1.second);
  
  if(ans < 0) ans = 0;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

hmax = 0
hmin = 0
ans = 10**10
for i in range(N - K + 1):
    hmax = h[i + K - 1]
    hmin = h[i]
    if hmax - hmin < ans:
        ans = hmax - hmin
print(ans)


Measured memory_bytes: 81792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int a[n+1];//今回はi番目のiとa[i]のiが等しい
	for(int i=1;i<n+1;i++) cin>>a[i];
	bool chk=0;
	vector<int> b;b.push_back(1);
	for(int i=0;i<n;i++){
		b.push_back(a[b[i]]);
		if(b[i+1]==2){
			chk=1;
			break;
		}
	}

	if(chk) cout<<b.size()-1<<"\n";
	else cout<<-1<<"\n";
}

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

def minus_binary(n, S: str):
    if n == 0:
        if S == "":
            S = "0"
        return S
    
    if n == 1:
        S = "1" + S
        return minus_binary(0, S)

    else:
        if n%2 == 1:
            n -= 1
            S = "1" + S
        else:
            S = "0" + S

        return minus_binary(n/(-2), S)

S = ""
print(minus_binary(N, S))

Measured memory_bytes: 9260
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	for i := 0; i < 50; i++ {
		m, f, r := nextInt(), nextInt(), nextInt()
		if m == -1 && f == -1 && r == -1 {
			break
		}
		if m == -1 || f == -1 {
			fmt.Fprintf(out, "F\n")
			continue
		}
		x := m + f
		switch {
		case x >= 80:
			fmt.Fprintf(out, "A\n")
		case x >= 65:
			fmt.Fprintf(out, "B\n")
		case x >= 50:
			fmt.Fprintf(out, "C\n")
		case x >= 30:
			if r >= 50 {
				fmt.Fprintf(out, "C\n")
			} else {
				fmt.Fprintf(out, "D\n")
			}
		case x <= 30:
			fmt.Fprintf(out, "F\n")
		}
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long d = sc.nextInt();
		d = d*d;
		int count =0;
		for(int i=0;i<n;i++)
		{
			long x = sc.nextInt();
			long y = sc.nextInt();
			
			x=x*x;
			y=y*y;
			
			if(x>d || y>d)
				continue;
			else if( (x==d && y==0) || (y==d && x==0))
				count++;
			else
			{
				if(x+y<=d)
					count++;
			}
		}
		System.out.println(count);
	}

}


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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 998244353
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int s=0;
  for(int i=0;i<n;i++) cin >> a[i],s+=a[i];
  vector<LL> dp1(90001,0),dp2(90001,0);
  dp1[0]=dp2[0]=1;
  for(int i=0;i<n;i++){
    for(int j=90000;j>=a[i];j--){
      dp1[j]=(dp1[j]+dp1[j-a[i]])%MOD;
      dp2[j]=(dp2[j]*2+dp2[j-a[i]])%MOD;
    }
    for(int j=a[i]-1;j>=0;j--) dp2[j]=dp2[j]*2%MOD;
  }
  LL h=(s+1)/2;
  LL x=0;
  for(int i=h;i<=90000;i++){
    x=(x+dp2[i])%MOD;
  }
  // LL y=0;
  // for(int i=0;i<=90000;i++){
  //   y=(y+dp2[i])%MOD;
  // }
  // cout << x SP y SP dp1[h] << endl;
  LL ans=1;
  for(int i=0;i<n;i++){
    ans=ans*3%MOD;
  }
  if(s%2){
    ans=(ans-x+MOD)%MOD;
    ans=(ans-x+MOD)%MOD;
    ans=(ans-x+MOD)%MOD;
    cout << ans << endl;
  }else{
    ans=(ans-x+MOD)%MOD;
    ans=(ans-x+dp1[h]%MOD+MOD)%MOD;
    ans=(ans-x+2*dp1[h]%MOD+MOD)%MOD;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int val = 100001;
vector<int> indegree(val,0);
vector<int> visited(val,0);
vector<vector<int>> graph(val);
vector<int> dp(val,0);
void dfs(int a)
{
    visited[a] = 1;
    int i,j,k;
    for(i=0;i<graph[a].size();i++)
    {
       dp[graph[a][i]] = max(dp[graph[a][i]],dp[a]+1); 
       indegree[graph[a][i]]--;
       if(indegree[graph[a][i]]==0)
       {
           dfs(graph[a][i]);
       }
    }
}
int main() {
    int n,m;cin>>n>>m;
    int i,j,k;
    int a,b;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        graph[a-1].push_back(b-1);
        indegree[b-1]++;
    }
/*    for(i=0;i<n;i++)
    {
        cout<<indegree[i]<<" ";
    }  */
    cout<<endl;
    for(i=0;i<n;i++)
    {   
        if(visited[i]==0&&indegree[i]==0)
        {
            
            dfs(i); 
        }
        
    }
 /*   for(i=0;i<n;i++)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    int ans  = 0;
    for(i=0;i<n;i++)
    {
        ans = max (ans , dp[i]);
    }
    cout<<ans<<endl;
	// your code goes here
	return 0;
}

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

int a[2000005],b[2000005],c[2000005];
int max=10001;

void cs(int n){
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++){
        c[a[i]]++;
    }
    for(int i=1;i<max;i++)
        c[i]+=c[i-1];
    for(int i=n-1;i>=0;i--){
       b[c[a[i]]]=a[i];
       c[a[i]]--;
    }
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    cs(n);
    for(int i=1;i<=n;i++){
        if(i==1) printf("%d",b[i]);
        else printf(" %d",b[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 26112
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String s=in.next();
		boolean t=false;
		for(int i=0;i<s.length()-2;i++){
			if(s.charAt(i)==s.charAt(i+1)){
				System.out.print((i+1)+" "+(i+2));
				t=true;
				break;}
			if(s.charAt(i)==s.charAt(i+2)){
				System.out.print((i+1)+" "+(i+3));
				t=true;
				break;
			}}
		if (!t){
			if(s.charAt(s.length()-2)==s.charAt(s.length()-1)){
				System.out.print((s.length()-1)+" "+s.length());
			}else{
			System.out.print("-1 -1");}
		}
		
	}
}

Measured memory_bytes: 24288
def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if rank[x] == rank[y]:
        par[y] = x
        rank[x] += 1
    elif rank[x] > rank[y]:
        par[y] = x
    elif rank[x] < rank[y]:
        par[x] = y
    
N, M = map(int, input().split())
par = [i for i in range(N)]
rank = [0 for i in range(N)]

for i in range(M):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    if not same(x, y):
        unite(x, y)
    
for i in range(N):
    root(i)

par = list(set(par))
print(len(par))


Measured memory_bytes: 14032
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	string s;
	std::cin >> s;
	
	int ans=0,tmp=0;
	for (int i = 0; i < s.size() + 1; i++) {
	    
	    if(s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C') {
	        tmp++;
	        
	    }else{
	        ans = max(tmp, ans);
	        tmp = 0;
	    }
	}
	
	std::cout << ans << std::endl;
	return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 1e5 + 10;

int check(int x){
	printf("%d\n", x);
	fflush(stdout);
	char S[10];
	scanf("%s", S);
	if(S[0] == 'V') exit(0);
	return S[0] == 'M';
}

int main(){

	int n;
	scanf("%d", &n);

	int L = 0, R = n;
	int lval = check(L), rval = lval;

	while(R - L > 2){
		int M = (L + R) >> 1, val = check(M);
		if(((M - L) & 1) == (val ^ lval)) L = M, lval = val;
		else R = M, rval = val;
	}

	check(L + 1);

	return 0;
}

Measured memory_bytes: 852
N,A,B = map(int,input().split(" "))
if A == 0:
    print(0)
    exit()
ans = N//(A+B)
tmp = N%(A+B)
if tmp == 0:
    ans *= A
else:
    if tmp >= A:
        ans = (ans+1)*A
    else:
        ans = ans*A+tmp
print(ans)

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
tmp=0
lr=[0]
for a in A:
  tmp+=a
  lr.append(tmp)

ans=float('inf')

f,g=1,3
for i in range(2,N-1):
  while abs(lr[i]-lr[f]-lr[f])>abs(lr[i]-lr[f+1]-lr[f+1]):
    f+=1
  while abs((lr[-1]-lr[g])-(lr[g]-lr[i]))>abs((lr[-1]-lr[g+1])-(lr[g+1]-lr[i])):
    g+=1
  l=(lr[f],lr[i]-lr[f],lr[-1]-lr[g],lr[g]-lr[i])
  ans=min(ans,max(l)-min(l))

print(ans)

Measured memory_bytes: 31404
import math
a,b,C = map(int,input().split())
C = math.radians(C)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
S = 1/2*a*b*math.sin(C)
L = a+b+c
h = b * math.sin(C)
print('{0:.5f}\n{1:.5f}\n{2:.5f}'.format(S,L,h))



Measured memory_bytes: 5716
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using llong = long long;

int main(){
  int N;
  cin >> N;
  vector<llong> head(27);
  for(int i=0;i<N;++i){
    string s;
    cin >> s;
    head[s[0]]++;
  }
  
  vector<char> chars = { 'M','A','R','C','H' };
  int size = chars.size();
  llong pat = 0;
  for(int i=0;i<size;++i){
    for(int j=i+1;j<size;++j){
      for(int k=j+1;k<size;++k){
        pat += head[chars[i]]*head[chars[j]]*head[chars[k]];
      }
    }
  }
  cout << pat << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;
    ll sol = (n*(n-1))/2 + (m*(m-1))/2;
    cout << sol << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (k,t) = get!(usize,usize);
    let a = get!([usize]);
    let mx = a.into_iter().max().unwrap();
    if 2*mx-1 < k {
        println!("0");
        return;
    }
    println!("{}", 2*mx-1-k);
}


Measured memory_bytes: 8572
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int m = 1e8;
    rep(i,n){
        int p;
        cin >> p;
        m = min (m, p);
        if(p == m) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	H, W, _ := getInt(), getInt(), getInt()
	s := make([]string, H)
	for i := 0; i < H; i++ {
		s[i] = getString()
	}
	a := make([][]int, H)
	cnt := 1
	for i := 0; i < H; i++ {
		a[i] = make([]int, W)
		for j := 0; j < W; j++ {
			if s[i][j] == '#' {
				a[i][j] = cnt
				cnt++
			}
		}
	}
	/*
		for i := 0; i < H; i++ {
			out(a[i])
		}
	*/
	for y := 0; y < H; y++ {
		for x := 1; x < W; x++ {
			if a[y][x] == 0 {
				a[y][x] = a[y][x-1]
			}
		}
		for x := W - 2; x >= 0; x-- {
			if a[y][x] == 0 {
				a[y][x] = a[y][x+1]
			}
		}
	}
	/*
		out("----")
		for i := 0; i < H; i++ {
			out(a[i])
		}
	*/
	for y := 1; y < H; y++ {
		for x := 0; x < W; x++ {
			if a[y][x] == 0 {
				a[y][x] = a[y-1][x]
			}
		}
	}
	for y := H - 2; y >= 0; y-- {
		for x := 0; x < W; x++ {
			if a[y][x] == 0 {
				a[y][x] = a[y+1][x]
			}
		}
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Print(a[i][j], " ")
		}
		out()
	}
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;

int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  int64_t ans=0;
  if(A%2==B%2){ans=(B-A)/2;}
  else{
   // int win=A-1+1+(B-A-1)/2;
   // int lose=N-B+1+(B-A-1)/2;
   // ans=min(win,lose);
   ans=min(A-1,N-B)+1+(B-A-1)/2;
    }
  cout<<ans<<endl;
  return 0;}

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

using namespace std;

int main(){
  int n;
  int a, b, c;
  int d[10][10];
  int max_t = -1;
  int min_d = 10000;
  int sum_d;
  int min_ind = -1;
  while (true) {
    cin >> n;
    if (n==0) {
      break;
    }
    max_t = -1;
    min_d = 10000;
    min_ind = -1;
    for (int i=0;i<10;i++) {
    for (int j=0;j<10;j++) {
      d[i][j] = 10000;
    }
    d[i][i] = 0;
  }
  
  for (int i=0;i<n;i++) {
    cin >> a >> b >> c;
    d[a][b] = c;
    d[b][a] = c;
    if (a > max_t) {
	max_t = a;
      }
      if (b > max_t) {
	max_t = b;
      }

  }
  for (int k=0;k<(max_t+1);k++) {
    for (int i=0;i<(max_t+1);i++) {
      for (int j=0;j<(max_t+1);j++) {
	if (d[i][k] + d[k][j] < d[i][j]) {
	  d[i][j] = d[i][k] + d[k][j];
	}
      }
    }
  }

  for (int i=0;i<(max_t+1);i++) {
    sum_d = 0;
    for (int j=0;j<(max_t+1);j++) {
      sum_d += d[i][j];
    }
    if (min_d > sum_d) {
      min_d = sum_d;
      min_ind = i;
    }
  }
  cout << min_ind << " " << min_d << endl;
}
}

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

using namespace std;

int main(){
	int N, max = 0, cnt = 0, num = 0;
  	cin >> N;
  	vector<int> A(N);
  	for(int i = 0; i < N; i++){
    	cin >> A[i];
    }
  
  	for(int i = 0; i < N; i++){
        	if(A[i] > max){
            	max = A[i];
              	cnt = 1;
              	num = i;
            }else if(A[i] == max){
            	cnt++;
            }

    }
  
  	if(cnt == 1){
  		sort(A.begin(), A.end());
    }
  
  	for(int i = 0; i < N; i++){
      	if(cnt == 1 && i == num){
        	cout << A[N-2] << endl;
        }else{
        	cout << max << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

const int MAX_N = 200200;

//隣接リストでもつ
struct edge {
    int to; 
    edge(int to) : to(to) {};
}; 
vector<vector<edge> > G(MAX_N, vector<edge>());
void add_edge(int from, int to) {
    G[from].push_back(edge(to));
    G[to].push_back(edge(from)); //根付き木は無向グラフ
}

vector<int> w(MAX_N, 0);
vector<int> d(MAX_N, -1); //初期値:-1
void dfs_reachability(int v, int c) {
    d[v] = c + w[v];
    for(int i = 0; i < (int)G[v].size(); ++i) { //頂点vから出る各辺を走査
        int u = G[v][i].to;
        if (d[u] < 0) { 
            dfs_reachability(u, c + w[v]); //同じ色に塗る
        }
    }
}

int main () {
    
    int n,q; cin >>n>>q;
    vector<int> a(n-1); vector<int> b(n-1);
    REP(i,n-1) cin >> a[i] >> b[i];
    for (int i = 0; i < n-1; i++) {
        a[i]--;
        b[i]--;
        add_edge(a[i], b[i]);
    }
    for (int i = 0; i < q; i++) {
        int v,u; cin >>v>>u;
        v--;
        w[v] += u;
    }

    dfs_reachability(0, 0);

    for (int i = 0; i < n; i++) {
        cout << d[i];
        if (i < n-1) {
            cout << " ";
        } 
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 25856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] != t[i])	ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main(){
		 /*int[] a = new int [28];
		 for(int b = 0;b<28;b++)
		 a[b] = int.Parse(Console.ReadLine());
		 Array.Sort(a);
		 int c,d;
		 c=d=0;
		 for(int b = 0,b<28;b++)
		 {
		 if(a[b]+1<b+2)
		 {
		 c+=a[b]+1;
		 break;
		 }
		 */
		 bool[] a=new bool[30];
		 for(int i=0;i<28;i++){
			 int d=int.Parse(Console.ReadLine());
			 a[d-1]=true;
		 }
		 for(int i=0;i<30;i++){
			 if(a[i]==false)Console.WriteLine(i+1);
		 }
	 }
 }
}
      
      

Measured memory_bytes: 9152
import itertools

nx_list = []
while True:
    n, x = map(int, raw_input().split())
    nx_list.append((n, x))
    if n == 0 and x == 0:
        break

for n, x in nx_list:
    if n == 0 and x == 0:
        break

    targets = range(1, n + 1)
    c = itertools.combinations(targets, 3)

    count = 0
    for i in c:
        if sum(i) == x:
            count += 1
    print(count)



Measured memory_bytes: 4720
# import sys
# import math
import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007


def main():

    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    comb = list(itertools.permutations(range(1, N + 1), N))

    a, b = -1, -1
    for i, c in enumerate(comb):
        if c == P:
            a = i
        if c == Q:
            b = i

    print(abs(a - b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 44912
#include <stdio.h>
#include <math.h>

int main(){
    int N,D;
    scanf("%d %d",&N,&D);
    double X[N],Y[N];
    int num=0;
    for (int i=0; i<N; i++) {
        scanf("%lf %lf",&X[i],&Y[i]);
    }
    for (int i=0; i<N; i++) {
        if (sqrt(X[i]*X[i]+Y[i]*Y[i])<=D) {
            num++;
        }
    }
    printf("%d",num);
}


Measured memory_bytes: 5340
m1, d1 = map(int,input().split())
m2, d2 = map(int,input().split())

im1 = int(m1)
im2 = int(m2)
sm1 = str(m1)
sm2 = str(m2)

samurai = {'2':28, '4':30, '6':30, '9':30, '11':30}

f  = 0

if im1 == im2:
    pass
elif im1 + 1 == im2 or (im1 == 12 and im2 == 1):
    if sm1 in samurai:
        if d1 == samurai[sm1]:
            f += 1
    else:
        if d1 == 31:
            f += 1
    if d2 == 1:
        f += 1

if f == 2:
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n,k;
  cin>>n>>k;
  vi h(n);
  rep(i,n)cin>>h[i];
  vi dp(n);
  Rep(i,1,n){
    int m=inf;
    Rep(j,max(0ll,i-k),i){
      m=min(m,dp[j]+abs(h[i]-h[j]));
    }
    if(m==inf)m=0;
    dp[i]+=m;
  }
  cout<<dp[n-1];
}


Measured memory_bytes: 1792
// AOJ 0098: Maximum Sum Sequence II 
// 2017.8.15 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>

int a[102][102];
int s[102][102];

char buf[1000], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, r, c, k, ans;

	fgets(p=buf, 10, stdin), n = getint();
	for (r = 0; r < n; r++) {
		fgets(p=buf, sizeof(buf), stdin);
		for (c = 0; c < n; c++, p++) {
			if (*p == '-') p++, a[r][c] = -getint();
			else                a[r][c] =  getint();
		}
	}

	for (r = 0; r < n; r++)
		for (c = 0; c < n; c++)
			s[r][c+1] += s[r][c] + a[r][c];

	ans = s[0][1];
	for (c = 0; c < n; c++) for (k = c+1; k <= n; k++) {
		int t = 0;
		for (r = 0; r < n; r++) {
			if (t < 0) t  = s[r][k] - s[r][c];
			else       t += s[r][k] - s[r][c];
			if (t > ans) ans = t;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	int a[n];
	int mn = LLONG_MAX , c=0;
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
		if (mn<a[i])
			c++;
		mn = min(mn, a[i]);
	}
	cout<<n-c<<"\n";


	



	return 0;
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve(C, N, M, range = range, min = min):
    K = N // 4 + 1
    S = [0]*K
    T = [0]*K
    U = [0]*(K+1)
    for i in range(N-1):
        U[0] = 10**18
        for j in range(K):
            U[j+1] = min(U[j], S[j])
        k = K-1
        ci = C[i]; cj = C[i+1]
        r = 10**18
        for j in range(K-1, -1, -1):
            while ci + k*M > cj + j*M:
                r = min(r, ci + k*M + S[k])
                k -= 1
            T[j] = min(r - j*M - cj, U[k+1])
        S, T = T, S
    ci = C[-1]
    for i in range(K):
        S[i] += ci + i*M
    write("%d\n" % min(S))
while 1:
    N, M = map(int, readline().split())
    if N == 0:
        break
    *A, = map(int, readline().split())
    *B, = map(int, readline().split())
    C = [(b - a) % M for a, b in zip(A, B)]
    solve(C, N, M)


Measured memory_bytes: 5692
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
int a,b;
int x,y,z;
int main()
{
	cin>>a>>b;
	x=a+b;
	y=a-b;
	z=a*b;
	cout<<max(max(x,y),z);
	//system("pause");
    return 0;
}

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

bool prime[N + 5] = {0};
int n;

void sprime() {
  int i, j;
  prime[0] = 1;
  prime[1] = 1;
  for(i = 2; i < sqrt(N); ++i)
    if(!prime[i])
      for(j = 2; i * j <= N; ++j) prime[i * j] = 1;
}

int main() {
  int i = 2, cnt = 0;
  sprime();
  cin >> n;
  while(cnt < n) {
    if(!(prime[i]) && (i % 5) == 1) {
      cout << i;
      ++i;
      ++cnt;
      if(cnt < n) cout << " ";
    }
    else
      ++i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == -1) break;
			int order = 1;
			for (; Math.pow(4, order) <= n; order++)
				;
			order--;
			while (order > 0)
			{
				int x = (int) (n / Math.pow(4, order));
				System.out.print(x);
				n = (int) (n % Math.pow(4, order));
				order--;
			}
			System.out.println(n);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using D=long double;
using P=pair<ll,ll>;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a,b,c;cin>>a>>b>>c;
	bool f;
	if(c-a-b>0){
		f=4LL*a*b<(c-a-b)*(c-a-b);
	}else{
		f=false;
	}
	if(f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <numeric>
#include <tuple>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  ll n, m, a, b;
  cin >> n >> m;

  vector<vector<ll>> ab(n, vector<ll>(2));
  for (ll i = 0; i < n; i++)
  {
    cin >> a >> b;
    ab[i] = {a, b};
  }

  sort(ab.begin(), ab.end(), [](const vector<ll> x, const vector<ll> y) { return x[0] < y[0]; });

  ll i = 0, sum = 0;
  while (m > 0)
  {
    m -= ab[i][1];
    sum += ab[i][0] * ab[i][1];
    i++;
  }
  i--;
  m += ab[i][1];
  sum -= ab[i][0] * ab[i][1];

  cout << sum + m * ab[i][0] << endl;

  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<ll> w, s;
  for(ll i = 0; 100*a*i <= f; i++){
    for(ll j = 0; 100*a*i+100*b*j <= f; j++){
      w.emplace_back(100*a*i + 100*b*j);
    }
  }

  for(ll i = 0; c*i <= f; i++){
    for(ll j = 0; c*i+d*j <= f; j++){
      s.emplace_back(c*i+d*j);
    }
  }

  ll n = w.size();
  ll m = s.size();

  ll sw = 0, sg = 0;
  double mx = -1;
  REP(i, n) REP(j, m){
    if(w[i]+s[j] > f) continue;
    if(w[i]/100*e < s[j]) continue;
    double p = 100.0 * s[j] / (w[i]+s[j]);
    if(mx < p){
      mx = p;
      sw = w[i]+s[j];
      sg = s[j];
    }
  }
  if(mx == -1) sw = 100*a;
  printf("%lld %lld\n", sw, sg);
  return 0;
}

Measured memory_bytes: 2420
from itertools import product 

H,W,K = map(int,input().split())

c = [list(input()) for i in range(H)]

ans =0
for i in product([0,1],repeat=H):#1の行を赤く塗る
    for j in product([0,1],repeat=W):#1の列をry

        count = 0
        for n in range(0,H,1):
            for m in range(0,W,1):
                if i[n]==1 or j[m] == 1:
                    continue
                if c[n][m]=="#":
                    count+=1
        if count ==K:
            ans +=1

print(ans)

Measured memory_bytes: 68388