akhauriyash/Code-Regression huggingface dataset:
dp=[[0 for j in range(10)] for i in range(10)]

h,w=map(int,input().split())
for i in range(10):
    s=list(map(int,input().split()))
    for j in range(10):
        dp[i][j]=s[j]

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
c=0
for i in range(h):
    s=list(map(int,input().split()))
    for j in range(w):
        if s[j]!=-1 and s[j]!=1:
            c+=dp[s[j]][1]
print(c)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15){
        cout<<"+";return 0;
    }
    if(a*b==15){
        cout<<"*";
    }
    else cout<<"x";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
}

Measured memory_bytes: 134992
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e9+18
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=51;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.14159265359
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
 if(a.ss>b.ss)
 return 1;

 return 0;   
}
int main()
{
    
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
  double  k=30*h+1.0*30/60*m;
    double l=(m/5)*30+(m%5)*6;
     l=abs(l-k);
 //    cout<<l<<" ";
    double r=min(l,360-l);
 
    r=1.0*pie*r/180;
  //  cout<<" "<<r<<" ";
    double s=sqrtl(a*a+b*b-2*a*b*cos(r));
   cout<<fixed<<setprecision(10)<<s;
}

Measured memory_bytes: 4128
#include <iostream>
#include <vector>
#include <algorithm>
#define MAXVAL 200005
using namespace std;

int n, k, cnt[MAXVAL];
int x;
vector<int> v;

int main() {
    ios::sync_with_stdio(0);

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        ++cnt[x];
    }

    for (int i = 1; i <= n; ++i)
        if (cnt[i] > 0)
            v.push_back(cnt[i]);

    if ((int) v.size() <= k) {
        cout << "0\n";
        return 0;
    }

    sort(v.begin(), v.end());
    int sol = 0;
    for (int i = 0; i + k < (int) v.size(); ++i)
        sol += v[i];

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 2168
n = int(input())
ans = 0

half_n = n // 2

for i in range(1, half_n + 1):
  a = 0
  if n % i == 0:
    a = n // i - 1
  else:
    a = n // i
  ans += a

res = n - half_n - 1
ans += res

print(ans)

Measured memory_bytes: 63188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

struct Info{ll v; ll c; ll t;};
struct DP{ll v; ll c; ll t;};

int mainsolve(){

	ll n,m,s;
	cin >> n >> m >> s;
	vector<ll> a(m), b(m);
	vector<vector<Info>> to(n);
	rep(i,m){
		ll u,v;
		cin >> u >> v >> a[i] >> b[i];
		--u; --v;
		to[u].push_back(Info{v,a[i],b[i]});
		to[v].push_back(Info{u,a[i],b[i]});
	}
	vector<ll> c(n), d(n);
	rep(i,n) cin >> c[i] >> d[i];

	ll INF = 1e18;
	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分
	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 

	queue<DP> q;
	q.push(DP{0,min(maxc-1,s),0});

	while(!q.empty()){
		DP now = q.front(); q.pop();
		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){
			dp[now.v][min(maxc-1,now.c)] = now.t;

			for(Info next : to[now.v]){
				q.push(DP{next.v,now.c - next.c, now.t + next.t}); // 移動
			}
			q.push(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金
		}
	}

	rep(i,n){
		if(i==0) continue;
		ll res = INF;
		rep(j,maxc) res = min(res, dp[i][j]);
		cout << res << endl;
	}
	
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 13728
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;


int main()
{
	int k; 
	cin>>k;
	cout<<(k+1)/2*(k/2)<<endl;
	return 0;
	
	
} 



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

int main(){
	int n=0, k=0, d[100], a[100], l=0, i=0, j=0, m=0, res=0;
	for(i = 0; i < 100; i++) a[i] = d[i] = 0;
	i = j = 0;
	cin >> n >> k;
	for(i = 0; i < k; i++){
		cin >> d[i];
		for(j = 0; j < d[i]; j++){
			cin >> l;
			for(m = 1; m <= n; m++){
				if(l == m) a[m-1]++;
			}
		}
	}
	for(i = 0; i < n; i++){
		if(a[i] == 0) res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3196
try:
  while True:
    b = raw_input()
    import string
    t = string.maketrans("abcdefghijklmnopqrstuvwxyz","bcdefghijklmnopqrstuvwxyza")
    while not("this" in b or "the" in b or "that" in b):
        b = b.translate(t)
    print b
except:
    pass


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;
  int ok = (S[2] == S[3]) && (S[4] == S[5]);
  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std; 
int main() {
    cout << fixed << setprecision(6);
    int n; cin >> n;
    vector<int> x(n),y(n);
    int i;
    vector<int> far(n);
    int sum;
    double m1=0,m2=0,m3=0,mi=0;
    for ( i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for ( i = 0; i < n; i++)
    {
        cin >> y[i];
        far[i] = abs(x[i]-y[i]);
        m1 += far[i];
        m2 += far[i]*far[i];
        m3 += far[i]*far[i]*far[i];
    }
    m2 = sqrt(m2);
    m3 = cbrt(m3);
    mi = *max_element(far.begin(),far.end());
    cout << m1 << endl;
    cout << m2 << endl;
    cout << m3 << endl;
    cout << mi << endl;


        
    return 0;
}


Measured memory_bytes: 3448
n, k = map( int, input().split() )
a = [ 0 ] + list( map( int, input().split() ) )

now = 1
visited = [ 1, -1 ] + [ -1 ] * ( n - 1 )
diary = [ -1, 0 ] + [ -1 ] * ( n - 1 )

for i in range( 1, k+1 ):
    now = a[ now ]
    visited[ i ] = now
    if diary[ now ] != -1:
        cycle = i - diary[ now ]
        d = ( k - i ) % cycle
        now = visited[ diary[ now ] + d ]
        break
    else:
        diary[ now ] = i

print( now )

Measured memory_bytes: 32380
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vl vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll n;
vl A, B;

void solve() {
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (n % 2 == 1) {
    ll a = A[(n - 1) / 2];
    ll b = B[(n - 1) / 2];
    cout << b - a + 1 << endl;
  } else {
    ld a = (A[n / 2 - 1] + A[n / 2]) / 2.0;
    ld b = (B[n / 2 - 1] + B[n / 2]) / 2.0;
    cout << (ll)((b - a) * 2 + 1) << endl;
  }
}

int main() {
  cin >> n;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  solve();
  return 0;
}


Measured memory_bytes: 6604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
int main()
{
    ll a,b,t,n,k,p,q,r,x,y,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    char ch;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
    cin>>n>>k>>x>>y; r=0;
    for(ll i=1;i<=n;i++)
    {
        if(i<=k) r+=x;
        else r+=y;
    }
    cout<<r<<endl;
}






Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
vector<ll>t[200001];
vector<ll>ans;
void dfs(ll u,ll p){
    for(auto x:t[u]){
        if(x==p)continue;
        ans[x]+=ans[u];
        dfs(x,u);
    }
}
int main(){
    IOS;
    ll n,q;cin>>n>>q;
    f(i,0,n-1){
        ll a,b;cin>>a>>b;a--;b--;
        t[a].pb(b);
        t[b].pb(a);
    }
    ans.resize(n);
    f(i,0,q){
        ll a,b;cin>>a>>b;
        ans[a-1]+=b;
    }
    dfs(0,-1);
    f(i,0,n)cout<<ans[i]<<" ";
    return 0;
}   

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

int main() {
  string O,E; cin>>O>>E;
  for(int i=0;;i++){
    if(O.size()==E.size()){
      cout << O[i] << E[i];
      if(i >= O.size()-1){
        cout << endl;
        break;
      }
    }
    else{
      cout << O[i] << E[i];
      if(i >= E.size()-1){
        cout << O[i+1] << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        long D = sc.nextInt();
        int result=0;
        long D2=D*D;
        for(int i=0;i<N;i++){
            long x=sc.nextInt();
            long y=sc.nextInt();
            if(x<=D&&y<=D&&x>=-D&&y>=-D){
                if(x*x+y*y<=D2){
                    result++;
                }
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 59192
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    if(A*B % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

Measured memory_bytes: 256
import sys
I = sys.stdin.readline
N,M= map(int, I().split())
X,G,d,C=list(map(int, I().split())),[set()for _ in range(N)],[0]*M,[0]*N
for i in range(M):
    u,v=sorted(map(int,I().split()),key=lambda x:[X[x-1],-x])
    G[v-1].add((u-1,i))
    d[i]=str(X[v-1])
for x, u in sorted((x,i)for i, x in enumerate(X)):
    if C[u]:continue
    if not G[u]:break
    C[u],S=-1 if sum(C[c]+1 for c, _ in G[u])else 1,[u]
    while S:
        q = S.pop()
        for c, i in G[q]:
            if C[c]:continue
            S+=[c]
            C[c]=-C[q]
print("".join(" BW"[i] for i in C)+"\n"+"\n".join(d) if C[u]else -1)

Measured memory_bytes: 146844
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int h=sc.nextInt();
    int[] a=new int[n];
    
    int res=0;
    for(int i=0;i<n;i++){
     a[i]=sc.nextInt();
      res+=a[i]>=h?1:0;
    }
    System.out.print(res);
  }
}

Measured memory_bytes: 49292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		
		A = A>C?A:C;
		B = B<D?B:D;
		A = B-A>0?B-A:0;
		System.out.println(A);
	}

}

Measured memory_bytes: 21716
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

void Solve()
{
	ld r;
	cin>>r;
	
	cout<< 2*PI*r;
	
}


signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using namespace std;

int main(){
	long long k,a,b;cin>>k>>a>>b;
	if(a>=b||a>=k+1||a+1==b){cout<<k+1<<endl;return 0;}
	
	long long ans=a;
	k-=a-1;
	ans+=(b-a)*(k/2)+(k%2);

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

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int n,a,b;
   double sum,ans=0;
   double x,y;
   cin>>n;
   int basyo[8][2];

   rep(i,0,n) cin>>basyo[i][0] >> basyo[i][1];

   rep(i,0,n-1){
      rep(j,i+1,n){
         x = basyo[i][0] - basyo[j][0];
         y = basyo[i][1] - basyo[j][1];
         ans += sqrt(x * x + y * y);
      }
   }

   cout<<Fixed(10)<<2*ans/n<<'\n';
}

Measured memory_bytes: 256
n = gets.split[0].to_i
c = gets.split.map &:to_i
m = (0..n+1).to_a

for i in 2..n
  for j in c
    if j <= i && m[i-j]+1 < m[i]
      m[i] = m[i-j]+1
    end
  end
end

puts m[n]

Measured memory_bytes: 9144
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner read = new Scanner(System.in);
      int n = read.nextInt(); int k = read.nextInt();
      int q = read.nextInt();
      int array[] = new int[n];
      for(int i = 0; i<q; i++){
          int t = read.nextInt();
          array[t-1]++;
      }
      for(int i = 0; i<n; i++){
          if(array[i]>q-k){
              System.out.println("Yes");
          }
          else{
              System.out.println("No");
          }
      }
      
    }
}

Measured memory_bytes: 56052
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cctype>
using namespace std;

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

#define MAX 1000000000
#define MIN 1

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VI a;

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    printf("%c", s1[0] - 32);
    printf("%c", s2[0] - 32);
    printf("%c\n", s3[0] - 32);
    
    return 0;
}










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

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

using namespace std;

typedef long long int lli;

int main () {
    int r, g, b;
    cin >> r >> g >> b;
    int num = r * 100 + g * 10 + b;
    cout << (num % 4 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

    char pic;
    char ch;
    int n,m;
    int A[100][100]={{0}};
    int b[100],c[100];
    scanf("%d %d",&m,&n);

    for (int i = 0; i < m; i++)
        {
        for (int j = 0; j < n; j++)//3行4列　i行j列
            {
                scanf("%d",&A[i][j]);
            }
        }

    for (int j = 0; j < n; j++)
        {
            scanf("%d",&b[j]);
        }

    for (int i = 0; i < m; i++)
        {
          for (int j = 0; j < n; j++)//3行4列　i行j列
            {
                c[i]+=A[i][j]*b[j];
            }
        }
    
    for (int i = 0; i < m; i++)
    {
        printf("%d\n",c[i]);
    }

    return 0;
}


Measured memory_bytes: 2088
n = int(input())

cnt_a = 0   # Bで始まらないがAで終わる
cnt_b = 0   # Bで始まるがAで終わらない
cnt_ba = 0  # Bで始まりAで終わる

ans = 0
for _ in range(n):
    s = input()
    ans += s.count('AB')
    if s.endswith('A') and s.startswith('B'):
        cnt_ba += 1
    else:
        if s.endswith('A'):
            cnt_a += 1
        if s.startswith('B'):
            cnt_b += 1

if cnt_ba == 0:
    ans += min(cnt_a, cnt_b)
else:
    ans += cnt_ba-1
    if cnt_a > 0:
        cnt_a -= 1
        ans += 1
    if cnt_b > 0:
        cnt_b -= 1
        ans += 1
    # 残ったxxAとBxxを組み合わせてABを作る
    ans += min(cnt_a, cnt_b)

print(ans)

Measured memory_bytes: 9132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main(void)
{
	int i, j;
	//  dic_t dic[200000];
	int ii[100];
	int ilen[100];
	int min, max;
	int len, flg;
	int cnt, maxcnt;
  	char aa[5];
	scanf("%s", aa);

	if (aa[0] == aa[1])
	{
      if (aa[0] == aa[2])
      {
          printf("No\n");
          return 0;
      }
	}
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d)
  cout << "Left" <<endl;
  else if(a+b<c+d)
  cout << "Right" <<endl;
  else 
  cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include<iostream>

#define _USE_MATH_DEFINES
#include<math.h>

using namespace std;

int main(){

    long long int n;
    long long int minWalk;
    scanf("%lld", &n);
    minWalk = n + 1;

    for(int i = 1; i <= sqrt(n); i++){
        if(i * (long long int)(n/i) == n){
            if(i + (long long int)(n/i) < minWalk){
                minWalk = i + (long long int)(n/i);
            }
        }
    }

    printf("%lld\n", minWalk - 2);


    return 0;
}

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

int main()
{
	int x,y;
	cin >> x >> y;

	int b2=y-2*x;
	if ((b2<0)||((b2%2)!=0))
	{
		cout << "No" << endl;
		return 0;
	}

	int a2=4*x-y;
	if ((a2<0)||((a2%2)!=0))
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}





Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int p[] = new int[A];
		int sum  =0;
		for (int i=0;i<A;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.parallelSort(p);
		for (int i=0;i<A-1;i++) {
			sum +=p[i];
		}
		sum +=p[A-1]/2;
		System.out.println(sum);
	}
}


Measured memory_bytes: 35844
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long a=100000;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		a*=1.05;
		if(a%1000==0)
			a-=1000;
		a/=1000;
		a*=1000;
		a+=1000;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

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


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll res = 0;
    rep(i,n-1){
        if(a[i] > a[i+1]){
            res += a[i] - a[i+1];
            a[i+1] = a[i];
        }
    }
    out(res);
}

Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdio.h>
#include <string>
using namespace std;

int main()
{
  int n;
  cin >> n;
  cin.ignore();

  string p, q;

  getline(cin, p);
  getline(cin, q);

  int v[n];
  for (int i = 0; i < n; i++)
  {
    v[i] = i + 1;
  }

  bool pflag = false;
  bool qflag = false;
  int count = 0;
  int pnum, qnum;
  do
  {
    count++;
    string s;
    for (int i = 0; i < n; i++)
    {
      s += to_string(v[i]);
      if (i < n - 1)
      {
        s += ' ';
      }
    }
    // cout << s << "\n";
    if (s == p)
    {
      pnum = count;
    }
    if (s == q)
    {
      qnum = count;
    }

    if (pflag && qflag)
    {
      break;
    }

  } while (next_permutation(v, v + n));

  cout << abs(pnum - qnum) << endl;

  return 0;
}

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

int main() {
    int   n;
    cin  >>n ;
   vector<int> d(n) ;
   for (int i=0 ; i<n ;i++){
       cin >> d[i] ;
   }
   sort(d.begin() ,d.end()) ;
   int k= n/2 ;
   if(n%2!=0)
   cout <<0 <<endl ;
   else if( d[k]==d[k-1])
   cout <<0 <<endl ;
   else
   
  cout << d[k]-d[k-1] << endl;
}



Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 22:56:49 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
def input():
    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
A = list(map(int,input().split()))

#N, *A = map(int, open(0).read().split())

count = np.bincount(A, minlength=4)
total = np.sum(count * np.arange(4, dtype=int))

b = np.arange(N+1)[:, None]
c = np.arange(N+1)[None, :]
S_bc = 2 * b + 3 * c
dp = np.zeros((N+1,N+1))

for s in range(1,total+1):
    prev = dp
    a = s - S_bc
    dp = prev * a + N
    dp[1:] += prev[:-1] * b[1:]
    dp[:-1, 1:] += prev[1:, :-1] * c[:,1:]
    dp /= (a+b+c)
    dp[a<0] = 0
#    print(s,dp)

ans = dp[count[2],count[3]]
print(ans)


Measured memory_bytes: 16784
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
  int X,A;
  int sum = 0;
  cin >> X >> A;
    if( X < A ){
      cout << 0 << endl;
  }else{
      cout << 10 << endl;
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

const int N = 400 + 9, INF = 0x3f3f3f3f;

int n, m, dp[N][N];
bool is_black[N][N];
char s[N][N];

int main() {
	memset(dp, 0x3f, sizeof dp);
	cin >> n >> m;
	char ch;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> ch;
			is_black[i][j] = ch == '#';
		}
	}
	dp[0][0] = is_black[0][0];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if(i == 0 && j == 0)
				continue; 
			dp[i][j] = INF;
			if (i - 1 >= 0) {
				if (is_black[i][j] && !is_black[i - 1][j])
					dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
				else 
					dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			}
			if (j - 1 >= 0) {
				if (is_black[i][j] && !is_black[i][j - 1])
					dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				else 
					dp[i][j] = min(dp[i][j], dp[i][j - 1]);
			}
		}
	}
	cout << dp[n - 1][m - 1] << endl;
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll p=n/k;
    ll q=n-(k*p);
    n=q;
    ll n1;
    if(n-k<0)
        n1=-(n-k);
    else
        n1=(n-k);
    int flag=0;
    while(!flag)
    {
        if(n<n1)
            flag=1;
        else
        {
            n=n1;
            if(n-k<0)
                n1=-(n-k);
            else
                n1=(n-k);
        }
    }
    cout<<n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 998244353;
ll m118;
ll p1018[100005];
ll nim[100005][3], a[100005][3];
ll val[8005][4];
vll fwd[100005][3];
ll binpow(ll a, ll b){
	if (b == 0) return 1;
	ll x = binpow(a, b / 2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
ll bindiv(ll a, ll b){
	ll inv = binpow(b, mod - 2);
	return (a * inv) % mod;
}
int main(){
	fastio;
	m118 = 1e18; m118 %= mod;
	p1018[0] = 1;
	for (ll i = 1; i < 100005; i++) p1018[i] = (p1018[i - 1] * m118) % mod;
	ll n; cin >> n;
	ll m[3];
	for (ll i = 0; i < 3; i++){
		cin >> m[i];
		for (ll j = 0; j < m[i]; j++){
			ll u, v; cin >> u >> v; u--; v--;
			if (u > v) swap(u, v); fwd[u][i].pb(v);
		}
	}
	for (ll i = 0; i < 3; i++){
		nim[n - 1][i] = 0;
		for (ll j = n - 2; j >= 0; j--){
			set <ll> nms;
			for (ll k = 0; k < fwd[j][i].size(); k++) nms.insert(nim[fwd[j][i][k]][i]);
			ll mex = 0;
			while (nms.count(mex)) mex++;
			nim[j][i] = mex;
		}
	}
	for (ll i = 0; i < 3; i++) for (ll j = 0; j < n; j++) (val[nim[j][i]][i] += p1018[j + 1]) %= mod;
	for (ll i = 0; i < 1005; i++){
		for (ll j = 0; j < 1005; j++) (val[i ^ j][3] += (val[i][0] * val[j][1])) %= mod;
	}
	ll ans = 0;
	for (ll i = 0; i < 1005; i++) (ans += (val[i][3] * val[i][2])) %= mod;
	cout << ans << endl;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int N; cin >> N;
  
  int sum = 0 , localmax = 0;
  for(int i = 0 ; i < N ; i++){
  	int p;
    cin >> p;
    localmax = max(localmax,p);
      sum += p;
  }
  cout << sum - localmax/2 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] h = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            h[i] = in.i();
        }
        int[] dp = new int[N + 1];
        h[0] = dp[0] = Integer.MAX_VALUE / 2;
        for (int i = 2; i <= N; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));
        }
        out.println(dp[N]);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36080
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,W,w,v;
    cin>>n>>W;
    ll dp[W+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        cin>>w>>v;
        for(int j=W;j>=w;j--)
            dp[j] = max(dp[j],dp[j-w]+v);
    }
    cout<<dp[W];
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<vector>
#define INF (1LL << 60)
using namespace std;

long long int dp[3001][3001];
long long int sum[3001][3001];

long long int slimes(vector<int> &v, int i, int j) {
    if(i == j) return 0;
    if(dp[i][j] != -1) return dp[i][j]; // Look-Up
    long long int minCost = INF;
    for(int k = i; k < j; k++) {
        minCost = min(minCost, (sum[i][j] + slimes(v, i, k) + slimes(v, (k + 1), j)));
    }
    return (dp[i][j] = minCost);
}

void preprocess(vector<int> &v, int n) {
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            sum[i][j] = v[j] + ((j == i) ? 0 : sum[i][j - 1]);
        }
    }
}

int main() {
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    vector<int> v(n + 1);
    for(int i = 1; i <= n; i++) cin >> v[i];
    preprocess(v, n);
    cout << slimes(v, 1, n) << endl;
    return 0;
}

Measured memory_bytes: 76212
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

class Pair<A, B> {
	A car;
	B cdr;

	public Pair(A _car, B _cdr) {
		car = _car;
		cdr = _cdr;
	}

	@Override
	public boolean equals(Object o) {
		if (o == null || !(o instanceof Pair)) {
			return false;
		}
		Pair<?, ?> p = (Pair<?, ?>) o;

		return ((car == null && p.car == null) || (car != null & car.equals(p.car)))
				&& ((cdr == null && p.cdr == null) || (cdr != null & cdr.equals(p.cdr)));

	}

	@Override
	public int hashCode() {
		return (car == null ? 0 : car.hashCode()) ^ (cdr == null ? 0 : cdr.hashCode());
	}

	@Override
	public String toString() {
		return asList().toString();
	}

	public List<Object> asList() {
		List<Object> l = new ArrayList<>();
		l.add(car);
		if (cdr instanceof Pair) {
			l.addAll(((Pair<?, ?>) cdr).asList());
		} else {
			l.add(cdr);
		}
		return l;
	}
}

class Tuple1<A> extends Pair<A, Object> {
	public Tuple1(A a) {
		super(a, null);
	}

	@Override
	public List<Object> asList() {
		List<Object> l = new ArrayList<>();
		l.add(car);
		return l;
	}

}

class Tuple2<A, B> extends Pair<A, Tuple1<B>> {
	public Tuple2(A a, B b) {
		super(a, new Tuple1<B>(b));
	}
}

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int V, E, r;
	List<List<List<Integer>>> g; // [t, d] のリスト

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		V = sc.nextInt();
		E = sc.nextInt();
		r = sc.nextInt();

		g = new ArrayList<>();
		for (int i = 0; i <= V; i++) {
			g.add(new ArrayList<>());
		}

		for (int i = 0; i < E; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int d = sc.nextInt();

			g.get(s).add(Arrays.asList(t, d));
//			g.get(t).add(Arrays.asList(s, d)); //有向だった・・・
		}

		sc.close();

		long[] c = new long[V];
		Arrays.fill(c, Long.MAX_VALUE);
		c[r] = 0;

		PriorityQueue<Tuple2<Integer, Long>> q = new PriorityQueue<>((a, b) -> (Long.compare(a.cdr.car, b.cdr.car)));
		q.add(new Tuple2<Integer, Long>(r, 0L));

		boolean[] v = new boolean[V];

		while (!q.isEmpty()) {
			int a = q.peek().car;
			long b = q.peek().cdr.car;
			q.poll();

			if (v[a]) {
				continue;
			}

			v[a] = true;
			c[a] = b;

			for (List<Integer> x : g.get(a)) {
				q.add(new Tuple2<Integer, Long>(x.get(0), b + x.get(1)));
			}
		}

		for (int i = 0; i < V; i++) {
			if (c[i] == Long.MAX_VALUE) {
				out.println("INF");
			} else {
				out.println(c[i]);
			}
		}
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}



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

using namespace std;

typedef unsigned long long ll;

ll data[4001];
vector<int> V;

void print(){
  vector<int> M;
  for(int i = 0; i < 4001; i++)
    if(data[i] >= 1000000) M.push_back(i);
  if(M.size()){
    for(int i = 0; i < V.size(); i++)
      if(binary_search(M.begin(),M.end(),V[i])) cout << V[i] << endl;
  }else cout << "NA" << endl;
}
int main(){
  ll in;
  while(cin >> in && in){
    V.clear();
    vector<int> VC;
    fill(data,data+4001,0);
    for(int i = 0; i < in; i++){
      sort(VC.begin(), VC.end());
      ll num,p,q;
      cin >> num >> p >> q;
      if(!binary_search(VC.begin(),VC.end(),num)){
	V.push_back(num);
	VC.push_back(num);
      }
      if(data[num] < 1000000) data[num] += p*q;
    }
    print();
  }
  return 0;
}

Measured memory_bytes: 0
h,w,k=map(int,input().split())
ans=[[0]*w for i in range(h)]

num=0
for i in range(h):
 s=input()

 if '#' not in s:
  if i==0 or ans[i-1]==[0]*w:
   continue
  else:
   ans[i]=ans[i-1]

 else:
  for j in range(w):
   if s[j]=='#':
    num+=1
    ans[i][j]=num
   else:
    if j>=1 and ans[i][j-1]!=0:
     ans[i][j]=ans[i][j-1]

if ans[0]==[0]*w:
 i=0
 while ans[i]==[0]*w:
  i+=1
 for j in range(i):
  ans[j]=ans[i]

for i in range(h):
 if ans[i][0]==0:
  j=0
  while ans[i][j]==0:
   j+=1
  for k in range(j):
   ans[i][k]=ans[i][j]

for i in range(h):
 print(*ans[i])

Measured memory_bytes: 7376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll goout(ll n){
    ll count=0;
    for(ll a=1;a<=n;a++){
        ll sub0=(a*3)*(a*3)-(3*a*a);
        if(sub0>n)break;
        if(sub0==n)count++;
        for(ll b=a+1;b<=n;b++){
            ll sub1=(a+b+b)*(a+b+b)-(a*b+b*b+b*a);
            ll sub2=(a+b+a)*(a+b+a)-(a*b+b*a+a*a);
            if(sub2>n)break;
            if(sub1==n)count+=3;
            if(sub2==n)count+=3;
            for(ll c=b+1;c<=n;c++){
                ll sub3=(a+b+c)*(a+b+c)-(a*b+b*c+c*a);
                if(sub3>n)break;
                if(sub3==n){
                    count+=6;
                    break;
                }
                
            }
            
        }
        
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    for(int i=1;i<=N;i++)
      cout << goout(i)<<endl;
    
    
    
    
}


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

pub 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")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
  let mut h: usize = read();
  let mut w: usize = read();
  let mut map = vec![];

  for i in 0..h {
    let mut a: Vec<i64> = read_n(w);
    map.push(a);
  }

  let mut amari = 0;
  let mut moves: Vec<Vec<usize>> = vec![];

  for i in 0..h {
    if i % 2 == 0 {
      for j in 0..w {
        if amari != 0 {
          map[i][j] += amari;
          moves.push(vec![i + 1, j + 1]);
        }

        if map[i][j] % 2 == 1 {
          amari = 1;
          map[i][j] -= 1;
          moves.push(vec![i + 1, j + 1]);
        } else {
          amari = 0;
        }
      }
    } else {
      for j in (0..w).rev() {
        if amari != 0 {
          map[i][j] += amari;
          moves.push(vec![i + 1, j + 1]);
        }
        if map[i][j] % 2 == 1 {
          map[i][j] -= 1;
          amari = 1;
          moves.push(vec![i + 1, j + 1]);
        } else {
          amari = 0;
        }
      }
    }
  }
  println!("{}", (moves.len() - (moves.len() % 2)) / 2);
  for i in 0..moves.len() - (moves.len() % 2) {
    if i % 2 == 1 {
      continue;
    }
    println!(
      "{} {} {} {}",
      moves[i][0],
      moves[i][1],
      moves[i + 1][0],
      moves[i + 1][1]
    );
  }
}

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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n) {
		cin >> p[i];
		p[i]--;
	}
	
	vector<int> idx(n);
	rep(i,n) idx[p[i]] = i;
	
	set<int> bigidx;
	ll res = 0;
	for(int i = n-1; i >= 0; i--){
		bigidx.insert(idx[i]);
		if(i==n-1) continue;
		auto itr = bigidx.find(idx[i]);
		
		
		ll l1 = 0;
		ll r1 = 0;
		ll l2 = 0;
		ll r2 = 0;
		
		// L
		auto litr = itr;
		if(litr != bigidx.begin()){
          litr--;
			l1 = idx[i] - *litr;
		}
		else{
			l1 = idx[i]+1;
			l2 = l1;
		}
		if(l1 != idx[i]+1 && litr != bigidx.begin()){
          litr--;
			l2 = idx[i] - *litr;
		}
		else l2 = idx[i]+1;
		
		// R
		auto ritr = itr;
		if(++ritr != bigidx.end()){
			r1 = *ritr - idx[i];
		}
		else{
			r1 = n - idx[i];
			r2 = r1;
		}
		if(r1 != n - idx[i] && ++ritr != bigidx.end()){
			r2 = *ritr - idx[i];
		}
		else r2 = n - idx[i];
		
		// cout << l2 << l1 << r1 << r2 << endl;
		res += ( (l1 * (r2 - r1)) + ((l2 - l1) * r1) ) * (i+1);
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  ou((n-1)*(m-1));
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
int main(){
    
    int n;
    char source, target, block;

    int M[3][3], T[3][3];
    while( cin >> n && n){
	cin >> source >> target >> block;

	assert( n <= 15 );
	assert( source != target && target != block && block != source );
	assert( 'A' <= source && source <= 'I' );
	assert( 'A' <= target && target <= 'I' );
	assert( 'A' <= block && block <= 'I' );
	rep(i, 3) rep(j, 3) M[i][j] = 0;
	
	M[(source-'A')/3][(source-'A')%3] = 1;

	for ( int t = 0; t < n; t++ ){
	    rep(a, 3) rep(b, 3) T[a][b] = 0;

	    static const int di[4] = {0, -1, 0, 1};
	    static const int dj[4] = {1, 0, -1, 0};
	    int ni, nj;
	    rep(i, 3) rep(j, 3){
		for ( int r = 0; r < 4; r++ ){
		    ni = i + di[r];
		    nj = j + dj[r];
		    if  ( ni < 0 || nj < 0 || ni >= 3 || nj >= 3 || ni*3+nj == (block-'A') ) {
			T[i][j]+=M[i][j];
		    } else {
			T[ni][nj]+=M[i][j];
		    }
		}
	    }
	    rep(a, 3) rep(b, 3) M[a][b] = T[a][b];
	}

	int pos = target - 'A';
	int num = M[pos/3][pos%3];

	int p = 1;
	for (int i = 0; i < n; i++ ) p *= 4;

	//	cout << num << "/" << p << endl;
	printf("%.7lf\n", 1.0*num/p);

	/*
	for ( int i = 0; i < 3; i++ ){
	    for (int j = 0; j < 3; j++ ){
		printf("%25d", M[i][j]);
	    }
	    cout << endl;
	    }
	*/
    }

}

Measured memory_bytes: 0