akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll n,wt;
    cin>>n>>wt;
    ll w[n+1],v[n+1];
    for(ll i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    ll dp[n+2][wt+2];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=n;i++)
    {
        ll x=w[i];
        for(ll j=1;j<=wt;j++)
        {
            if(j-w[i]>=0){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[n][wt] <<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output

        solve();

    return 0;
}

Measured memory_bytes: 80000
from collections import Counter

MOD = 10**9+7

def judge(N: int, A: list) -> int:
    # 報告数カウンタ
    cnt = Counter(A)
    
    # 奇数
    if N%2 == 1:
        #矛盾チェック
        for k,v in cnt.items():
            if k==0:
                if v != 1:
                    return 0
            else:
                if v != 2:
                    return 0
        
        # 矛盾がなければ2**(N//2)
        ans = 1
        for i in range(N//2):
            ans = (ans*2) %MOD
        
        return ans
    
    else:
        #矛盾チェック
        for k,v in cnt.items():
            if v != 2:
                return 0
            
        # 矛盾がなければ2**(N//2)
        ans = 1
        for i in range(N//2):
            ans = (ans*2) %MOD
        
        return ans
                
N = int(input())
A = list(map(int, input().split()))

print(judge(N,A))

Measured memory_bytes: 14820
#include <stdio.h>
int main(){
  int N,K;
  int i,j;
  
  scanf("%d %d",&N,&K);
  
  double p=0.0; 
 for(i=1;i<N+1;i++){
      j=i;
      double h=1.0;
      while(j<K){
      j*=2;
      h*=0.5;
      }
    p += h/N;
  }
  printf("%.10f",p);
  return 0;
}
  


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

int main(int argc, const char * argv[]) {
    int cnt;
    int H, W;
    string A[55];
    bool flag = true;

    cin >> H >> W;
    for(int i = 0; i < H; i++){
          cin >> A[i];
    }

    for(int i = 0; i < H; i++){
       for(int j = 0; j < W; ++j){
          if(A[i][j] == '#'){
              flag = false;
              if(A[i-1][j] == '#') flag = true;
              if(A[i][j-1] == '#') flag = true;
              if(A[i][j+1] == '#') flag = true;
              if(A[i+1][j] == '#') flag = true;
              if(flag == false) break;
          }
          
       }
       if(flag == false) break;
    }

    if(flag == false) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n,a,b,tanka,uriage,jun[N];
  long long int num[N];
  bool judge;

  while(cin >> n){
    if(n==0)
      break;

    for(int i=0;i<N;i++){
      num[i] = 0;
      jun[i] = 0;
    }

    for(int i=0,b=0;i<n;i++){
      judge = true;
      cin >> a >> tanka >> uriage;
      num[a] += (long long int)tanka * (long long int)uriage;
      for(int j=0;j<i;j++){
	if(jun[j]==a){
	  judge = false;
	  break;
	}
      }
      if(judge){
	jun[b] = a;
	b++;
      }
    }

    judge = true;
    for(a=0;jun[a]!=0;a++){
      if(num[jun[a]]>=1000000){
	cout << jun[a] << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

int arr[100010];
bool chk[100010];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    
    int n, r, i;
    scanf("%d", &n);
    for(i=1;i<=n;i++)
    {
        scanf("%d", &arr[i]);
        if(arr[i] == i)
            chk[i] = 1;
    }
    
    r = 0;
    for(i=1;i<=n;i++)
    {
        if(chk[i])
        {
            if(i != n && chk[i+1])
                chk[i+1] = 0;
            r++;
        }
    }
    printf("%d\n", r);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	
	int color = 0;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			if (color < 0) {
				count += 2;
			}
			color++;
		} else if (s[i] == '1') {
			if (color > 0) {
				count += 2;
			}
			color--;
		}
	}
	
	cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int kaijou(int N){
  int X=1;
  for(int i=1; i<=N; i++){
    X*=i;
  }
  return X;
}

int x[10], y[10];
double dist(int i, int j){
  double dx=x[i]-x[j];
  double dy=y[i]-y[j];
  return pow(dx*dx+dy*dy, 0.5);
}
int main() {
  int N; cin>>N;
  int waru=kaijou(N);
  for(int i=1; i<=N; i++) cin>>x[i]>>y[i];
  double sum=0.0;
  vector<int> v(N);
  for(int i=0; i<N; i++) v[i] = i+1; //1,2,3...
  do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
  cout<<fixed<<setprecision(10)<<sum/waru<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	BIT(int n = 0) {
		initialize(n);
	}
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	T get(int i) {
		if (i == 0)return dat[0];
		else return sum(i) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

ll T[202020], A[202020], B[202020];
ll Q;
int main() {
	cin >> Q;
	vector<ll>dic;
	rep(i, 0, Q) {
		cin >> T[i];
		if (T[i] == 1) {
			cin >> A[i] >> B[i];
			dic.pb(A[i]);
		}
	}
	sort(all(dic));
	dic.erase(unique(all(dic)), dic.end());
	ll sz = dic.size();

	BIT<ll>bitsum(sz);
	BIT<ll>bitnum(sz);
	ll cursz = 0;
	ll bsum = 0;
	ll tot = 0;
	rep(i, 0, Q) {
		if (T[i] == 1) {
			bsum += B[i];
			ll ind = lower_bound(all(dic),A[i]) - dic.begin();
			bitnum.plus(ind, 1);
			bitsum.plus(ind, A[i]);
			tot += A[i];
			cursz++;
		}
		else {
			ll ind = bitnum.lower_bound((cursz+1)/2);
			ll m = (cursz + 1) / 2;
			ll x = dic[ind];
			ll ans = 0;
			ll sum1, sum2;
			if (ind == 0) {
				sum1 = x * m;
			}
			else {
				sum1 = bitsum.sum(ind - 1) + x * (m-bitnum.sum(ind-1));
			}
			sum2 = tot - sum1;
			ans = (m*x - sum1) + (sum2 - (cursz - m)*x) + bsum;
			cout << x << " " << ans << endl;
		}
	}


	return 0;
}


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

struct UnionFind{
  vector<long> p;
  vector<long> w;
  UnionFind(long n){
    p.resize(n+1);
    w.resize(n+1, 1);
    for(long i=1; i<=n; i++)  p[i] = i;
  }
  long find(long x){
    if(p[x] == x)  return x;
    return p[x] = find(p[x]);
  }
  void unite(long x, long y){
    x = find(x);
    y = find(y);
    if(x == y)  return;
    p[x] = y;
    w[x] += w[y];
    w[y] = w[x];
  }
  long weight(long x){
    return w[find(x)];
  }
};

int main(){
  long n, m;  cin >> n >> m;
  UnionFind uf(n);

  vector<pair<long, long>> bri(m);
  for(long i=0; i<m; i++)  cin >> bri[i].first >> bri[i].second;
  
  long ma = n * (n-1) / 2;
  vector<long> ans(m, 0);
  ans[m-1] = ma;
  
  for(long i=m-2; i>=0; i--){
    if(uf.find(bri[i+1].first) == uf.find(bri[i+1].second)){
      ans[i] = ans[i+1];
      continue;
    }
    ans[i] = ans[i+1] - uf.weight(bri[i+1].first) * uf.weight(bri[i+1].second);
    uf.unite(bri[i+1].first, bri[i+1].second);
  }
  
  for(auto ai : ans)
    cout << ai << endl;

  return 0;
}


Measured memory_bytes: 7140
require 'pp'

n, k = gets.split.map(&:to_i)
a_n = gets.split.map(&:to_i)

path = {}
path_rev = {}
now = 1

count = 0

k.times do |t1|
    if path[now].nil?
        path[now] = count
        path_rev[count] = now
    else
        x = path[now]
        l = count - path[now]

        #pp now
        #pp count
        #pp x
        #pp l
        #p path
    
        k = k - x
        k = k % l

        #pp k
        #pp path_rev

        puts path_rev[k+x]
        exit 0
    end

    now = a_n[now-1]
    count += 1
end

puts now


Measured memory_bytes: 42508
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if (a == b) {
		printf("a == b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a < b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n=0,k=0;
int a[200001];
int b[200001];

bool check(int x)
{
	int f = k;
	for (int i=0; i<n; i++)
	{
		if (a[i]*b[i]>x)
		{
			int kk = a[i]-(x/b[i]);
			if (kk<=f)
			{
				f-=kk;
			}	
			else
				return false;
		}	
	}	
	return true;
}

signed main()
{
	cin >> n >> k;
	for (int i=0; i<n; i++)
	{
		cin >> a[i];
	}
	for (int i=0; i<n; i++)
	{
		cin >> b[i];
	}
	sort(a, a+n);
	sort(b, b+n);
	reverse(b, b+n);
	int l = 0, r = 1000000000000000;
	while (l<r-1)
	{
		int m = (l+r)/2;
		if (check(m))
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
	if (check(l))
		cout << l;
	else
		cout << r;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
#include<bitset>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    cin >> n;
    int a[n];
    vector<bitset<60> > v;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        bitset<60> bs(a[i]);
        v.push_back(bs);
    }
    int l = 0;
    int r = 0;
    ll rtn = 0;
    ll ss = a[0];
    bitset<60> xx(0);
    xx = v[0];
    for(l = 0; l <= n-1; l++){
        rtn += r-l+1;
        if(r == n-1) continue;
        while(1){
            bitset<60> bs(ss+a[r+1]);
            bitset<60> bb(0);
            bb = v[r+1] ^ xx;
            if(bs != bb) break;
            r++;
            rtn++;
            ss += a[r];
            xx = xx ^ v[r];
            if(r == n-1) break;
        }
        if(l == r){
            r++;
            ss = a[r];
            xx = v[r];
        }
        else{
            ss = ss - a[l];
            xx = xx ^ v[l];
        }
    }
    cout << rtn << endl;
    return 0;
}

Measured memory_bytes: 2932
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    char a;
    cin >> a;
    if(a >= 'A' && a <= 'Z'){
        cout << 'A' << endl;
    } else{
        cout << 'a' << endl;
    }
}

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

int main(){
    int N, M, C;
    std::cin >> N >> M >> C;
    std::vector<int> B(M);
    for(int i = 0; i < M; i++) std::cin >> B[i];
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int sum = C;
        for(int j = 0; j < M; j++){
            int a;
            std::cin >> a;
            sum += a * B[j];
        }
        if(sum > 0) cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}


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

int main() {
  int N,M; cin >>N >>M;
  vector<int> a(M);
  vector<int> b(M);
  rep(i,0,M) cin >>a[i] >>b[i];
  vector<int> ans(N);
  rep(i,0,M) {
    ans[a[i]-1]++;
    ans[b[i]-1]++;
  }
  rep(i,0,N) cout <<ans[i] <<endl;
  return 0;
}


Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();

			if ( m==-1 && f==-1 && r==-1 ) break;

			if ( m==-1 || f==-1 ) sb.append("F\n");
			else if ( m+f >= 80 ) sb.append("A\n");
			else if ( m+f >= 65 ) sb.append("B\n");
			else if ( m+f >= 50 ) sb.append("C\n");
			else if ( m+f >= 30 ) {
				if ( r>=50 ) sb.append("C\n");
				else sb.append("D\n");
			} else sb.append("F\n");

		}

		System.out.print(sb);
	}

}

Measured memory_bytes: 26236
A, B, C, X, Y = map(int, input().split())
sum1 = A * X + B * Y
sum2 = C * min(X, Y) * 2 + A * (X - min(X, Y)) + B * (Y - min(X , Y))
sum3 = C * max(X, Y) * 2
print(min(sum1, sum2, sum3))

Measured memory_bytes: 3060
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    a = []
    for _ in range(N):
        n = int(input())
        a.append(n)
    c = Counter(a)
    res = 0
    for i in c.values():
        if i%2:
            res += 1
    print(res)



if __name__ == '__main__':
    main()

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

int main() {
    string S;
    cin >> S;

    int K = 0;
    int i = 0;
    while(i < S.length() - 1) {
        if(S[i] == S[i + 1]) {
            if(i == S.length() - 2) {
                i += 2;
                K += 1;
            } else {
                i += 3;
                K += 2;
            }
        } else {
            i += 1;
            K += 1;
        }
    }
    if(i == S.length() - 1) K++;

    cout << K << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

ll inf=1e15;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a(m);
  for(ll i=0;i<m;i++) {
    cin >> a[i];
  }
  sort(a.rbegin(),a.rend());
  vector<ll> num={2,5,5,4,5,6,3,7,6};
  vector<ll> dp(n+1,-inf);
  dp[0]=0;
  for(ll i=1;i<=n;i++) {
    for(ll j=0;j<m;j++) {
      if(i-num[a[j]-1]>-1&&dp[i-num[a[j]-1]]!=-inf) {
        dp[i]=max(dp[i],dp[i-num[a[j]-1]]+1);
      }
    }
  }
  vector<ll> ans(dp[n]);
  ll temp=n;
  for(ll i=0;i<ans.size();i++) {
    for(ll j=0;j<m;j++) {
      if(temp-num[a[j]-1]>-1&&dp[temp-num[a[j]-1]]+1==dp[temp]) {
        ans[i]=a[j];
        temp=temp-num[a[j]-1];
        break;
      }
    }
  }
  for(ll i=0;i<ans.size();i++) {
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int main()
{
  int N;
  cin >> N;
  
  double ans = 0;
  
  for(int i=0; i<N; i++)
  {
    double x;
    string u;
    
    cin >> x >> u;
    
    if(u=="JPY")
    {
      ans += x;
    }else{
      ans += x*380000;
    }
    
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF = 1e9;
int main(){
    ll n;
    cin>>n;
    ll ans = (n/11) * 2;

    if(n % 11 > 6){
        ans += 2;
    }
    else if(n %11 >0){
        ans += 1;
    }
    cout<<ans<<endl;
}




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

int main(void){
   string s,t;
   cin>>s>>t;
   sort(s.begin(),s.end());
   sort(t.begin(),t.end(),greater<char>());
   if(s<t) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;
void swap(int &a, int &b);

int main()
{
	int a, b;
	cin >> a >> b;
	int d, r;
	double f;

	d = a / b;
	r = a%b;
	f = static_cast<double>(a) / b;

	cout << d << " " << r << " "<< fixed<<setprecision(6) << f << endl;

}

void swap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
	return;
}




Measured memory_bytes: 3276
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)

#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'

using ll = long long;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;


typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void dfs(vector<vector<ll>>& g, ll v, vector<bool>& used) {
	used[v] = true;
	for (auto next : g[v]) {
		if (used[next]) continue;
		dfs(g, next, used);
	}
}

void solve() {
	ll n, m;
	cin >> n >> m;

	vector<ll> a(m), b(m);
	REP(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	ll ans = 0;
	REP(i, m) {
		vector<vector<ll>> graph(n);

		REP(j, m) {
			if (j == i) continue;
			graph[a[j]].push_back(b[j]);
			graph[b[j]].push_back(a[j]);
		}

		vector<bool> used(n, false);

		//連結かどうか判定
		dfs(graph, 0, used);
		bool flag = false;
		REP(j, n) if (!used[j]) flag = true;
		if (flag)ans++;
	}
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  long double a,b,c;
  cin>>a>>b>>c;
   long double x=sqrt(a);
    long double y=sqrt(b);
    long double z=sqrt(c);
   long double m=a+b+2*x*y;
     long double n=c;
  if(m<n){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        map<string,int> m;
        int ma=0;
        while(n--){
            string x;cin>>x;
            m[x]++;
            ma=max(ma,m[x]);
        }
        vector<string> v;
        for(auto j: m){
            if(j.snd==ma){
                v.pb(j.fst);
            }
        }
        sort(all(v));
        rep(i,sz(v)){
            cout<<v[i]<<endl;
        }
    }   
    return 0;   
}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n,t;cin>>n>>t;
  int ans=1000*1000;
  for(int i=0;i<n;i++){
    int c,t2;cin>>c>>t2;
    if(t2>t)continue;
    ans=min(ans,c);
  }

  if(ans==1000*1000){
    puts("TLE");
  }else{
    cout<<ans<<endl;
  }

  
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,K,t;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
    if(A.at(i)==1){
      t=i+1;
      break;
    }
  }
  cout << (N-2)/(K-1)+1 << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

typedef struct p{int a;double s;}p;

f(p (*d),int s)
{
	int i,r[2]={-1,-1};
	for(i=0;i<s;i++)
	{
		if(r[0]==-1||d[r[0]].s>d[i].s)
		{
			r[1]=r[0];
			r[0]=i;
		}
		else if(r[1]==-1||d[r[1]].s>d[i].s)
			r[1]=i;
	}
	for(i=0;i<2;i++)
		printf("%d %.2f\n",d[r[i]].a,d[r[i]].s);
	d[r[0]].s=d[r[1]].s=0x7fff;
}

main()
{
	int i,j;
	p s[3][8];
	for(i=0;i<3;i++)
	{
		for(j=0;j<8;j++)
			scanf("%d%lf",&s[i][j].a,&s[i][j].s);
		f(s[i],8);
	}
	f(s[0],24);
	exit(0);
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(void)
{
    int N;
    long long Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; ++i)
    {
        for (int j = N - i; j >= 0; --j)
        {
            int k = N - i - j;
            if (10000 * i + 5000 * j + 1000 * k == Y)
            {
                cout << i << " " << j << " " << k << "\n";
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
}

Measured memory_bytes: 256
/*
                                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/

#include <bits/stdc++.h>

#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
 
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}
signed main()
{   jaldi
	int n;
	cin>>n;
	int a[n],i;
	double sum=0;
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	sum=(double)(a[0]+a[1])/2;
	for(i=2;i<n;i++)
	sum=(double)(sum+a[i])/2;		
	cout<<sum;
}

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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;
bool DP[100001];
int main() {
    IOS;
    int N, K;
    cin >> N >> K;
    int a[N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        DP[a[i]] = true;
    }
    for(int i = a[0] + 1; i <= K ; i++) {
    	if(DP[i]) continue;
        for(int j = 0; j < N; j++) {
            if(i-a[j] >= 0 && !DP[i - a[j]]) {
                DP[i] = true;
                break;
            }
        }
    }
    if(DP[K]) cout << "First";
    else cout << "Second";
    return 0;
}

Measured memory_bytes: 384
from collections import deque
import sys
input = sys.stdin.readline

def solve():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    S = [input().rstrip() for _ in range(H)]
    visited = [[False] * W for _ in range(H)]
    dq = deque([(0, Ch, Cw)])

    while dq:
        d, i, j = dq.popleft()
        if (i, j) == (Dh, Dw):
            print(d)
            exit()
        if visited[i][j]:
            continue
        visited[i][j] = True
        for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
                dq.appendleft((d, ni, nj))
        for di in range(-2, 3):
            for dj in range(-2, 3):
                if di == dj == 0:
                    continue
                ni, nj = i + di, j + dj
                if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.' and not visited[ni][nj]:
                    dq.append((d + 1, ni, nj))
    print(-1)

if __name__ == "__main__":
    solve()

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

int main(void){
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    auto it = unique(v.begin(), v.end());
    int m = it-v.begin();
    printf("%d", m);
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (k (read)))
    (println (/
              (loop for x from 1 to n
                    for log = (if (>= x k)
                                  0
                                  (ceiling (log (/ k x) 2)))
                    sum (expt 0.5d0 log))
              n))))

#-swank(main)


Measured memory_bytes: 18912
// AOJ 2642: Dinner
// 2017.11.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

long long a[500003];

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

int cmp(long long *a, long long *b)
{
	if (*a == *b) return 0;
	if (*a < *b) return 1;
	return -1;
}

int main()
{
	int n, q, c, i;
	long long p, s, t, ans;

	fgets(bp=buf, 30, stdin);
	n = getint(), bp++, p = getint(), bp++, q = getint();
    for (s = 0, t = p*q, i = 0; i < n; i++, t -= p) {
		fgets(bp=buf, 10, stdin);
		c = getint(), a[i] = t - c, s += c;
    }
	qsort(a, n, sizeof(long long), cmp);
    for (ans = s, t = 0, p <<= 1, i = 0; i < n; i++, t += p) {
		s += a[i] + t;
		if (s > ans) ans = s;
	}
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9328
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,z,w=map(int,input().split()) # 必ず捨てられるため、zの値は関係ない
    A=[w]+list(map(int,input().split()))
    dp=[[None]*2 for _ in range(n+1)] # dp[i][turn] 消費枚数i,turnの手から始まるときの最適解

    def dfs(i,turn)->NoneType:
        if(dp[i][turn] is not None): return

        # i+1からn-1のdp[1-turn]を埋めておく(i=n-1のときterminate)
        for j in range(i+1,n):
            dfs(j,1-turn)

        res=-INF if(turn==0) else INF
        if(turn==0):
            for j in range(i+1,n):
                res=max(res,dp[j][1])
            res=max(res,abs(A[-1]-A[i]))
        else:
            for j in range(i+1,n):
                res=min(res,dp[j][0])
            res=min(res,abs(A[-1]-A[i]))
        dp[i][turn]=res

    dfs(0,0)
    print(dp[0][0])
resolve()

Measured memory_bytes: 47964
N=int(input())
L=list(map(int,input().split()))
p=0;q=0
for i in range(1,N):
  if L[i-1]>L[i]:
    p=p+(L[i-1]-L[i])
    L[i]=L[i]+(L[i-1]-L[i])
print(p)

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  rep(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 && a[i] % 5) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<stdio.h>
#include<utility>
#include<algorithm>

int main() {
	int n = 1;
	while (n <= 10000) {
		int a, b;
		scanf("%d %d", &a,&b);///////////////
		if(a==0){
			if(b==0){
				n = 100001;
			}
	
		}
		if (n <= 10000) {
			if (a < b) {
				printf("%d %d\n", a, b);
			}
			else {
				printf("%d %d\n", b, a);
			}
			n++;
		}
	}
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a[5];
    int ans = 1;
    for(int &i: a) cin >> i;
    for(int i=0;i<5;i++) if(a[i]==0) ans = i+1;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 20005;
bool com[MAX_N];
struct DATA{
	int t, s, d;

	bool operator<( const DATA & right ) const {
		return (t < right.t );
	}
};
	
int main()
{
	ios_base::sync_with_stdio(0);
	int N, M;
	while (cin >> N >> M, N ){
		memset (com, false, sizeof (com ) );
		DATA data[M];
		rep (i, M ){
			cin >> data[i].t >> data[i].s >> data[i].d;
		} // end rep
		sort (data, data + M );
		com[1] = true;
		rep (i, M ){
			com[data[i].d] |= com[data[i].s];
		} // end rep
		int res = (int)count (com, com + N + 1, true );
		cout << res << endl;
	} // end while
	
	return 0;
}

Measured memory_bytes: 1472
#include <iostream>
#include <fstream>

#include <vector>

using namespace std;

typedef vector<int> vi_t;
class MyVector{
private:
    vector<int> *_vi;
    int _n;
public:
    MyVector(){
        _vi = NULL;
        _n = 0;
    }

    MyVector(int n){
        _vi = new vector<int>[n];
    _n = n;
    }

    ~MyVector(){
        delete [] _vi;
    }

    void pushBack(int t, int x){
        _vi[t].push_back(x);
        return;
    }
    void dump(int t){
        if(_vi[t].empty()){
            cout << endl;
            return;
        }else{
            for(int i=0;i != _vi[t].size();i++){
                cout << _vi[t][i];
                if(i != _vi[t].size() - 1){
                    cout << " ";
                }else{
                    cout << endl;
                }
            }
            return;
        }
    }
    void clear(int t){
        if(_vi[t].empty()){
            return;
        }else{
            _vi[t].erase(_vi[t].begin(), _vi[t].end());
            return;
        }
    }
};

int main(){

    int n,q;
    cin >> n >> q;
    MyVector v(n);
    for(int i=0;i<q;i++){
        int query,t;
        cin >> query >> t;
        switch(query){
        case 0:
            int x;cin >> x;
            v.pushBack(t,x);
            break;
        case 1:
            v.dump(t);
            break;
        case 2:
            v.clear(t);
            break;
        default: break;    
        }
    }
}


Measured memory_bytes: 5860
function main(input) {
  const lines = input.trim().split("\n");
  const [N, M] = lines.shift().split(' ').map(Number);
  const h = lines.shift().split(' ').map(Number);

  const isGood = Array(N).fill(true);
  lines.forEach(l => {
    const [a, b] = l.split(' ');
    if (h[a-1] > h[b-1])
      isGood[b-1] = false;
    else if (h[a-1] < h[b-1])
      isGood[a-1] = false;
    else {
      isGood[a-1] = false;
      isGood[b-1] = false;
    }
  });
  const res = isGood.filter(g => g).length;
  
  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 57356
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    
    if A > 9 or B > 9:
        print(-1)
    else:
        print(A * B)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m,ai,bi,ci;
struct P{ int a,b,c; };
vector<P> l;
int ret;

int calc(){
    int a=0, b=0, c=0;
    REP(i,m){
        a += l[i].a;
        b += l[i].b;
        c += l[i].c;
    }
    return abs(a) + abs(b) + abs(c);
}

template<int N>
bool comp(const P& a, const P& b){
    int ai=0; int bi=0;
    ai += (N&1) ? a.a : -a.a;
    bi += (N&1) ? b.a : -b.a;
    ai += (N&2) ? a.b : -a.b;
    bi += (N&2) ? b.b : -b.b;
    ai += (N&4) ? a.c : -a.c;
    bi += (N&4) ? b.c : -b.c;
    return ai < bi;
}

signed main(){
    I(n); I(m);
    REP(i,n){
        I(ai); I(bi); I(ci);
        l.pb(P({ai,bi,ci}));
    }

    sort(all(l), comp<0>);
    ret = max(ret, calc());
    sort(all(l), comp<1>);
    ret = max(ret, calc());
        sort(all(l), comp<2>);
    ret = max(ret, calc());
        sort(all(l), comp<3>);
    ret = max(ret, calc());
        sort(all(l), comp<4>);
    ret = max(ret, calc());
        sort(all(l), comp<5>);
    ret = max(ret, calc());
        sort(all(l), comp<6>);
    ret = max(ret, calc());
        sort(all(l), comp<7>);
    ret = max(ret, calc());

    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, c, a[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]), s += a[i];
	sort(a, a + n);
	for (i = n - 1; i >= 0; i--) {
		if (s * 2 < a[i + 1]) break;
		s -= a[i];
	}
    cout << n - i - 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int m, n;
	int ans = 0, cnt = 0; double a = 0;
	while (scanf("%d,%d", &m, &n) != EOF)
	{
		ans += m*n;
		a += n;
		cnt++;
	}
	a = a / cnt + 0.5;
	printf("%d\n%d\n", ans, (int)a);
}

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

int main() {
	int a;
	cin >> a;
	int b;
	cin >> b;
	if (a==b)
	 cout << "a == b" <<endl;
	if (a < b)
	 cout << "a < b" <<endl;
	if (a > b)
	 cout << "a > b" <<endl;
	return 0;
}


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

int main() {

	//printf("%d %d %d %d %c\n", 'a', 'b', 'A', 'B', 65) ;
	

	unsigned long n, m ;
	unsigned long i, j ;

	scanf("%lu", &n) ;

	while (n > 0) {

		char **array ;

		array = (char **)malloc(sizeof(char *)*n) ;
		for (i = 0 ; i < n ; i++)
			array[i] = (char *)malloc(sizeof(char)*2) ;

		for (i = 0 ; i < n ; i++) { 
			scanf("%*c%c%*c%c", &array[i][0], &array[i][1]) ;
			//printf("%c %c\n", array[i][0], array[i][1]) ;
		}

		//printf("piyo\n") ;
		scanf("%lu", &m) ;
		//printf("piyo\n") ;

		for (i = 0 ; i < m ; i++) {

			int flag = 0 ;
			char in = '-' ;
			//printf("hoge\n") ;
			scanf("%*c%c", &in) ;

			//printf("in:%c\n", in) ;

			for (j = 0 ; j < n ; j++) { 
				if (array[j][0] == in) {
					printf("%c", array[j][1]) ;
					break ;
				}
				if (j == n-1) flag = 1 ;
			}
			if (flag) 
				printf("%c", in) ;
			flag = 0 ;
	
		}

		printf("\n") ;

		for (i = 0 ; i < n ; i++)
			free(array[i]) ;

		free(array) ;

		scanf("%lu", &n) ;

	}

	return 0 ;

}

Measured memory_bytes: 576
amari1 = []
amari2 = []
amari3 = []
amari4 = []

prime = [True] * 55556
prime[0] = False
prime[1] = False
for i in range(2, 55556):
  if not prime[i]:
    continue
  now = i
  while now + i <= 55555:
    now += i
    prime[now] = False
    
for i in range(2, 55556):
  if prime[i] == True:
    amari = i % 5
    if amari == 1:
      amari1.append(i)
    elif amari == 2:
      amari2.append(i)
    elif amari == 3:
      amari3.append(i)
    elif amari == 4:
      amari4.append(i)

N = int(input())
print(' '.join(map(str, amari1[:N])))


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll x;
  cin >> x;
  cout << (2199-x)/200 << newl;
  return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

ll b[64];
bool insert(ll x) {
	for(int i=63;i>=0;i--) {
		if( (x >> i) & 1 ) {
			if( b[i] ) x ^= b[i];
			else {
				b[i] = x;
				return true;
			}
		}
	}
	return false;
}


char s[205]; ll A[205];

void solve() {
	int N; scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%lld", &A[i]);
	scanf("%s", s + 1);
	
	for(int i=0;i<64;i++) b[i] = 0;
	for(int i=N;i>=1;i--) {
		if( s[i] == '0' ) insert(A[i]);
		else if( insert(A[i]) ) {
			puts("1");
			return ;
		}
	}
	puts("0");
}

int main() {
	int T; scanf("%d", &T);
	while( T-- ) solve();
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,l; cin>>n>>l;
	int abdif=1e9,sum=0,dif=1e9;
	for(int i=1;i<=n;++i){
		int j=l+i-1;
		sum+=j;
		if(abs(j)<abdif)abdif=abs(j),dif=j;
	}
	cout<<sum-dif<<"\n"s;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int k,n;
	cin>>k>>n;
	int a[n];
	rep(i,n)cin>>a[i];

	int max=k-a[n-1]+a[0];
	rep(i,n-1){
		if(a[i+1]-a[i]>max)max=a[i+1]-a[i];
	}

	cout<<k-max<<endl;

	return 0;
}


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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	string str;
	cin >> str;
	int ans = 0;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		if (str[i] == 'I') cur++;
		else cur--;
		ans = max(ans, cur); 
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 2e5;
const double INF = 1e15;
double dp[21][200100];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  VI xs(N); REP(i,N) cin >> xs[i];
  fill((double*)dp, (double*)dp+21*200100, INF);
  FOR(j,1,MAX+1)
	dp[0][j] = abs(j-xs[0]) * 1. / xs[0];
  
  for(int i=0;i<N-1;++i){
	for(int j=1;j<=MAX;++j){
	  if(dp[i][j] < MAX)
		for(int k=j;k<=MAX;k+=j){
		  dp[i+1][k] = min(dp[i+1][k], max(dp[i][j], abs(k-xs[i+1]) * 1. / xs[i+1]));
		}
	}
  }

  double res = INF;
  REP(j,MAX+1) res = min(res, dp[N-1][j]);
  cout << fixed << setprecision(10) << res << endl;

  return 0;
}

Measured memory_bytes: 34100
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let x: i64 = read();

    let xi: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut rui: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        rui[i + 1] = rui[i] + xi[n - i - 1];
    }

    let mut ans: i64 = 1 << 60;
    for k in 1..n + 1 {
        let mut i: usize = 0;
        let mut last: usize = 0;
        let mut cost: i64 = ((n + k) as i64) * x;
        while last < n {
            let sum: i64 = rui[std::cmp::min(n, last + k)] - rui[last];
            cost += (if i == 0 { 5 } else { (2 * (i + 1) + 1) } as i64) * sum;
            last += k;
            i += 1;
            if cost > ans {
                break;
            }
        }
        ans = std::cmp::min(ans, cost);
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

int main() {
	int n,k;cin>>n>>k;
	vector<long long> p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
		if(i){
			p[i]+=p[i-1];
		}
	}
	long long sum=p[k-1];
	for(int i=1;i+k-1<n;i++){
		long long tempsum=p[i+k-1]-p[i-1];
		sum=max(sum,tempsum);
	}
	cout<<setprecision(13)<<double(sum+k)/2<<endl;

	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static int x;
        static bool flug;
        static int[] memo;
        static int cnt;
        static void Main(string[] args)
        {
            x = int.Parse(ReadLine());
            flug = false;
            memo = new int[x];
            cnt = 0;
            bfs(x);
            WriteLine(flug ? 1 : 0);
        }

        static void bfs(int n)
        {
            if (flug == true) return;
            if (n == 0)
            {
                flug = true;
                return;
            }
            if (memo.Contains(n)) return;

            if (n < 0)
            {
                return;
            }
            memo[cnt] = n;
            cnt++;
            if (n - 100 >= 0) bfs(n - 100);
            if (n - 101 >= 0) bfs(n - 101);
            if (n - 102 >= 0) bfs(n - 102);
            if (n - 103 >= 0) bfs(n - 103);
            if (n - 104 >= 0) bfs(n - 104);
            if (n - 105 >= 0) bfs(n - 105);
        }
    }
}

Measured memory_bytes: 15708